Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate Hoglins from Passive Mob #959

Closed
wants to merge 11 commits into from
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ org.gradle.parallel=true
# Fabric Properties
# check these at https://fabricmc.net/develop/ and
# https://www.curseforge.com/minecraft/mc-mods/fabric-api
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.15.7

#Fabric api
fabric_version=0.96.4+1.20.4
fabric_version=0.92.0+1.20.1

# Mod Properties
mod_version = v7.41.1-MC1.20.4
mod_version = v7.41.1-MC1.20.1
maven_group = net.wurstclient
archives_base_name = Wurst-Client

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/wurstclient/FriendsList.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void middleClick(Entity entity)
if(!middleClickFriends.isChecked())
return;

String name = entity.getName().getString();
String name = entity.getEntityName();

if(contains(name))
removeAndSave(name);
Expand All @@ -75,7 +75,7 @@ public boolean contains(String name)

public boolean isFriend(Entity entity)
{
return entity != null && contains(entity.getName().getString());
return entity != null && contains(entity.getEntityName());
}

public ArrayList<String> toList()
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/wurstclient/WurstClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public enum WurstClient
public static IMinecraftClient IMC;

public static final String VERSION = "7.41.1";
public static final String MC_VERSION = "1.20.4";
public static final String MC_VERSION = "1.20.1";

private WurstAnalytics analytics;
private EventManager eventManager;
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/net/wurstclient/altmanager/AltRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.util.DefaultSkinHelper;
import net.minecraft.client.util.SkinTextures;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.Uuids;
Expand All @@ -42,12 +41,13 @@ private static void bindSkinTexture(String name)

if(loadedSkins.get(name) == null)
{
UUID uuid = Uuids.getOfflinePlayerUuid(name);
UUID uuid =
Uuids.getUuidFromProfile(new GameProfile((UUID)null, name));

PlayerListEntry entry =
new PlayerListEntry(new GameProfile(uuid, name), false);

loadedSkins.put(name, entry.getSkinTextures().texture());
loadedSkins.put(name, entry.getSkinTexture());
}

RenderSystem.setShaderTexture(0, loadedSkins.get(name));
Expand Down Expand Up @@ -124,8 +124,7 @@ public static void drawAltBody(DrawContext context, String name, int x,
bindSkinTexture(name);

boolean slim = DefaultSkinHelper
.getSkinTextures(Uuids.getOfflinePlayerUuid(name))
.model() == SkinTextures.Model.SLIM;
.getModel(Uuids.getOfflinePlayerUuid(name)).equals("slim");

GL11.glEnable(GL11.GL_BLEND);
RenderSystem.setShaderColor(1, 1, 1, 1);
Expand Down Expand Up @@ -256,8 +255,7 @@ public static void drawAltBack(DrawContext context, String name, int x,
bindSkinTexture(name);

boolean slim = DefaultSkinHelper
.getSkinTextures(Uuids.getOfflinePlayerUuid(name))
.model() == SkinTextures.Model.SLIM;
.getModel(Uuids.getOfflinePlayerUuid(name)).equals("slim");

GL11.glEnable(GL11.GL_BLEND);
RenderSystem.setShaderColor(1, 1, 1, 1);
Expand Down
73 changes: 68 additions & 5 deletions src/main/java/net/wurstclient/altmanager/LoginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,84 @@
*/
package net.wurstclient.altmanager;

import java.net.Proxy;
import java.util.Optional;

import net.minecraft.client.session.Session;
import net.minecraft.util.Uuids;
import com.mojang.authlib.Agent;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.exceptions.AuthenticationException;
import com.mojang.authlib.exceptions.AuthenticationUnavailableException;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;

import net.minecraft.client.util.Session;
import net.wurstclient.WurstClient;

public enum LoginManager
{
;

public static void changeCrackedName(String newName)
public static void login(String email, String password)
throws LoginException
{
Session session =
new Session(newName, Uuids.getOfflinePlayerUuid(newName), "",
YggdrasilUserAuthentication auth =
(YggdrasilUserAuthentication)new YggdrasilAuthenticationService(
Proxy.NO_PROXY, "").createUserAuthentication(Agent.MINECRAFT);

auth.setUsername(email);
auth.setPassword(password);

try
{
auth.logIn();

GameProfile profile = auth.getSelectedProfile();
String username = profile.getName();
String uuid = profile.getId().toString();
String accessToken = auth.getAuthenticatedToken();

Session session = new Session(username, uuid, accessToken,
Optional.empty(), Optional.empty(), Session.AccountType.MOJANG);

WurstClient.IMC.setSession(session);

}catch(AuthenticationUnavailableException e)
{
throw new LoginException("Cannot contact authentication server!",
e);

}catch(AuthenticationException e)
{
e.printStackTrace();
String msg = e.getMessage().toLowerCase();

if(msg.contains("invalid username or password."))
throw new LoginException("Wrong password! (or shadowbanned)",
e);

if(msg.contains("account migrated"))
throw new LoginException("Account migrated to Mojang account.",
e);

if(msg.contains("migrated"))
throw new LoginException(
"Account migrated to Microsoft account.", e);

throw new LoginException("Cannot contact authentication server!",
e);

}catch(NullPointerException e)
{
e.printStackTrace();

throw new LoginException("Wrong password! (or shadowbanned)", e);
}
}

public static void changeCrackedName(String newName)
{
Session session = new Session(newName, "", "", Optional.empty(),
Optional.empty(), Session.AccountType.MOJANG);

WurstClient.IMC.setSession(session);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;

import net.minecraft.client.session.Session;
import net.minecraft.client.util.Session;
import net.wurstclient.WurstClient;
import net.wurstclient.util.json.JsonException;
import net.wurstclient.util.json.JsonUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public MinecraftProfile(UUID uuid, String name, String mcAccessToken)
this.mcAccessToken = mcAccessToken;
}

public UUID getUUID()
public String getUUID()
{
return uuid;
return "" + uuid;
}

public String getName()
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/net/wurstclient/altmanager/MojangAlt.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ public MojangAlt(String email, String password, String name,
@Override
public void login() throws LoginException
{
MicrosoftLoginManager.login(email, password);
try
{
MicrosoftLoginManager.login(email, password);
}catch(Exception e)
{
LoginManager.login(email, password);
}
Comment on lines +64 to +70
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The introduction of a try-catch block in the login() method to attempt login with MicrosoftLoginManager and fallback to LoginManager in case of an exception is a good practice. This ensures compatibility with both Microsoft and Mojang accounts, enhancing the flexibility of the authentication process. However, it's important to log or handle the caught exception to aid in debugging and provide feedback to the user.

Consider logging the exception or providing user feedback in case the Microsoft login attempt fails before falling back to Mojang authentication.

name = getNameFromSession();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.mojang.blaze3d.systems.RenderSystem;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
Expand Down Expand Up @@ -144,6 +143,9 @@ private void createSkinFolder()
@Override
public final void tick()
{
nameOrEmailBox.tick();
passwordBox.tick();

String nameOrEmail = nameOrEmailBox.getText().trim();
boolean alex = nameOrEmail.equalsIgnoreCase("Alexander01998");

Expand Down Expand Up @@ -344,7 +346,7 @@ public boolean mouseClicked(double x, double y, int button)
public void render(DrawContext context, int mouseX, int mouseY,
float partialTicks)
{
renderBackground(context, mouseX, mouseY, partialTicks);
renderBackground(context);

MatrixStack matrixStack = context.getMatrices();
Matrix4f matrix = matrixStack.peek().getPositionMatrix();
Expand Down Expand Up @@ -397,8 +399,7 @@ public void render(DrawContext context, int mouseX, int mouseY,
errorTimer--;
}

for(Drawable drawable : drawables)
drawable.render(context, mouseX, mouseY, partialTicks);
super.render(context, mouseX, mouseY, partialTicks);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import net.fabricmc.fabric.api.client.screen.v1.Screens;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.screen.ConfirmScreen;
import net.minecraft.client.gui.screen.NoticeScreen;
import net.minecraft.client.gui.screen.Screen;
Expand Down Expand Up @@ -183,12 +182,10 @@ public boolean mouseReleased(double mouseX, double mouseY, int button)
}

@Override
public boolean mouseScrolled(double mouseX, double mouseY,
double horizontalAmount, double verticalAmount)
public boolean mouseScrolled(double d, double e, double amount)
{
listGui.mouseScrolled(mouseX, mouseY, horizontalAmount, verticalAmount);
return super.mouseScrolled(mouseX, mouseY, horizontalAmount,
verticalAmount);
listGui.mouseScrolled(d, e, amount);
return super.mouseScrolled(d, e, amount);
}

@Override
Expand Down Expand Up @@ -416,7 +413,7 @@ private void confirmRemove(boolean confirmed)
public void render(DrawContext context, int mouseX, int mouseY,
float partialTicks)
{
renderBackground(context, mouseX, mouseY, partialTicks);
renderBackground(context);
listGui.render(context, mouseX, mouseY, partialTicks);

MatrixStack matrixStack = context.getMatrices();
Expand Down Expand Up @@ -472,9 +469,7 @@ public void render(DrawContext context, int mouseX, int mouseY,
errorTimer--;
}

for(Drawable drawable : drawables)
drawable.render(context, mouseX, mouseY, partialTicks);

super.render(context, mouseX, mouseY, partialTicks);
renderButtonTooltip(context, mouseX, mouseY);
renderAltTooltip(context, mouseX, mouseY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,18 @@ protected void pressDoneButton()

}catch(LoginException e)
{
message = "\u00a7c\u00a7lMicrosoft:\u00a7c " + e.getMessage();
doErrorEffect();
try
{
LoginManager.login(nameOrEmail, password);

}catch(LoginException e2)
{
message = "\u00a7c\u00a7lMicrosoft:\u00a7c "
+ e.getMessage() + "\n\u00a7c\u00a7lMojang:\u00a7c "
+ e2.getMessage();

doErrorEffect();
}
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
Expand Down Expand Up @@ -238,12 +237,10 @@ public boolean mouseReleased(double mouseX, double mouseY, int button)
}

@Override
public boolean mouseScrolled(double mouseX, double mouseY,
double horizontalAmount, double verticalAmount)
public boolean mouseScrolled(double mouseX, double mouseY, double amount)
{
listGui.mouseScrolled(mouseX, mouseY, horizontalAmount, verticalAmount);
return super.mouseScrolled(mouseX, mouseY, horizontalAmount,
verticalAmount);
listGui.mouseScrolled(mouseX, mouseY, amount);
return super.mouseScrolled(mouseX, mouseY, amount);
}

@Override
Expand Down Expand Up @@ -284,6 +281,9 @@ public void tick()

pricePlusButton.active = offerToAdd != null && offerToAdd.price() < 64;
priceMinusButton.active = offerToAdd != null && offerToAdd.price() > 1;

levelField.tick();
priceField.tick();
}

@Override
Expand All @@ -303,9 +303,7 @@ public void render(DrawContext context, int mouseX, int mouseY,

levelField.render(context, mouseX, mouseY, partialTicks);
priceField.render(context, mouseX, mouseY, partialTicks);

for(Drawable drawable : drawables)
drawable.render(context, mouseX, mouseY, partialTicks);
super.render(context, mouseX, mouseY, partialTicks);

matrixStack.translate(width / 2 - 100, 0, 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package net.wurstclient.clickgui.screens;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.Text;
import net.wurstclient.clickgui.ClickGui;
Expand Down Expand Up @@ -44,21 +43,17 @@ public boolean mouseReleased(double mouseX, double mouseY, int mouseButton)
}

@Override
public boolean mouseScrolled(double mouseX, double mouseY,
double horizontalAmount, double verticalAmount)
public boolean mouseScrolled(double mouseX, double mouseY, double delta)
{
gui.handleMouseScroll(mouseX, mouseY, verticalAmount);
return super.mouseScrolled(mouseX, mouseY, horizontalAmount,
verticalAmount);
gui.handleMouseScroll(mouseX, mouseY, delta);
return super.mouseScrolled(mouseX, mouseY, delta);
}

@Override
public void render(DrawContext context, int mouseX, int mouseY,
float partialTicks)
{
for(Drawable drawable : drawables)
drawable.render(context, mouseX, mouseY, partialTicks);

super.render(context, mouseX, mouseY, partialTicks);
gui.render(context, mouseX, mouseY, partialTicks);
}
}
Loading
Loading