Skip to content

Commit

Permalink
Merge branch 'master' into pr470-mobspawnesp-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Oct 8, 2021
2 parents 70bf0db + b4ed10a commit 49aa35e
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 42 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -12,7 +12,7 @@ loader_version=0.11.6
fabric_version=0.37.1+1.17

# Mod Properties
mod_version = v7.17-MC1.17.1
mod_version = v7.17.1-MC1.17.1
maven_group = net.wurstclient
archives_base_name = Wurst-Client

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/wurstclient/WurstClient.java
Expand Up @@ -56,7 +56,7 @@ public enum WurstClient
public static final MinecraftClient MC = MinecraftClient.getInstance();
public static final IMinecraftClient IMC = (IMinecraftClient)MC;

public static final String VERSION = "7.17";
public static final String VERSION = "7.17.1";
public static final String MC_VERSION = "1.17.1";

private WurstAnalytics analytics;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/net/wurstclient/clickgui/SettingsWindow.java
Expand Up @@ -9,6 +9,7 @@

import java.util.stream.Stream;

import net.minecraft.util.math.MathHelper;
import net.wurstclient.Feature;
import net.wurstclient.WurstClient;
import net.wurstclient.settings.Setting;
Expand All @@ -24,6 +25,7 @@ public SettingsWindow(Feature feature, Window parent, int buttonY)

setClosable(true);
setMinimizable(false);
setMaxHeight(187);
pack();

setInitialPosition(parent, buttonY);
Expand All @@ -41,6 +43,9 @@ private void setInitialPosition(Window parent, int buttonY)
if(y + getHeight() > mcWindow.getScaledHeight())
y -= getHeight() - 14;

x = MathHelper.clamp(x, 0, mcWindow.getScaledWidth());
y = MathHelper.clamp(y, 0, mcWindow.getScaledHeight());

setX(x);
setY(y);
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/wurstclient/hack/Hack.java
Expand Up @@ -11,6 +11,7 @@

import net.wurstclient.Category;
import net.wurstclient.Feature;
import net.wurstclient.hacks.ClickGuiHack;
import net.wurstclient.hacks.NavigatorHack;
import net.wurstclient.hacks.TooManyHaxHack;

Expand Down Expand Up @@ -76,7 +77,7 @@ public final void setEnabled(boolean enabled)

this.enabled = enabled;

if(!(this instanceof NavigatorHack))
if(!(this instanceof NavigatorHack || this instanceof ClickGuiHack))
WURST.getHud().getHackList().updateState(this);

if(enabled)
Expand Down
47 changes: 32 additions & 15 deletions src/main/java/net/wurstclient/hacks/PlayerEspHack.java
Expand Up @@ -27,6 +27,7 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.Vec3d;
import net.wurstclient.Category;
Expand Down Expand Up @@ -189,35 +190,51 @@ private void renderBoxes(MatrixStack matrixStack, double partialTicks,
private void renderTracers(MatrixStack matrixStack, double partialTicks,
int regionX, int regionZ)
{
Vec3d start =
RotationUtils.getClientLookVec().add(RenderUtils.getCameraPos());
RenderSystem.setShader(GameRenderer::getPositionColorShader);
RenderSystem.setShaderColor(1, 1, 1, 1);

Matrix4f matrix = matrixStack.peek().getModel();
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
RenderSystem.setShader(GameRenderer::getPositionShader);

BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES,
VertexFormats.POSITION);
VertexFormats.POSITION_COLOR);

Vec3d start = RotationUtils.getClientLookVec()
.add(RenderUtils.getCameraPos()).subtract(regionX, 0, regionZ);

for(PlayerEntity e : players)
{
Vec3d interpolationOffset = new Vec3d(e.getX(), e.getY(), e.getZ())
.subtract(e.prevX, e.prevY, e.prevZ).multiply(1 - partialTicks);

Vec3d end = e.getBoundingBox().getCenter()
.subtract(new Vec3d(e.getX(), e.getY(), e.getZ())
.subtract(e.prevX, e.prevY, e.prevZ)
.multiply(1 - partialTicks));
.subtract(interpolationOffset).subtract(regionX, 0, regionZ);

float r, g, b;

if(WURST.getFriends().contains(e.getEntityName()))
RenderSystem.setShaderColor(0, 0, 1, 0.5F);
else
{
r = 0;
g = 0;
b = 1;

}else
{
float f = MC.player.distanceTo(e) / 20F;
RenderSystem.setShaderColor(2 - f, f, 0, 0.5F);
r = MathHelper.clamp(2 - f, 0, 1);
g = MathHelper.clamp(f, 0, 1);
b = 0;
}

bufferBuilder.vertex(matrix, (float)start.x - regionX,
(float)start.y, (float)start.z - regionZ).next();
bufferBuilder.vertex(matrix, (float)end.x - regionX, (float)end.y,
(float)end.z - regionZ).next();
bufferBuilder
.vertex(matrix, (float)start.x, (float)start.y, (float)start.z)
.color(r, g, b, 0.5F).next();

bufferBuilder
.vertex(matrix, (float)end.x, (float)end.y, (float)end.z)
.color(r, g, b, 0.5F).next();
}

bufferBuilder.end();
BufferRenderer.draw(bufferBuilder);
}
Expand Down
31 changes: 16 additions & 15 deletions src/main/java/net/wurstclient/hud/HackListHUD.java
Expand Up @@ -9,6 +9,7 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;

import net.minecraft.client.font.TextRenderer;
Expand Down Expand Up @@ -53,11 +54,6 @@ public void render(MatrixStack matrixStack, float partialTicks)

}else
textColor = 0x04ffffff;

// YesCheat+ mode indicator
// YesCheatSpf yesCheatSpf = WurstClient.INSTANCE.special.yesCheatSpf;
// if(yesCheatSpf.modeIndicator.isChecked())
// drawString("YesCheat+: " + yesCheatSpf.getProfile().getName());

int height = posY + activeHax.size() * 9;
Window sr = WurstClient.MC.getWindow();
Expand Down Expand Up @@ -96,15 +92,25 @@ public void updateState(Hack hack)
return;

activeHax.add(entry);
Collections.sort(activeHax);
sort();

}else if(!otf.isAnimations())
activeHax.remove(entry);
}

private void sort()
{
Comparator<HackListEntry> comparator =
Comparator.comparing(hle -> hle.hack, otf.getComparator());
Collections.sort(activeHax, comparator);
}

@Override
public void onUpdate()
{
if(otf.shouldSort())
sort();

if(!otf.isAnimations())
return;

Expand Down Expand Up @@ -172,7 +178,6 @@ private void drawWithOffset(MatrixStack matrixStack, HackListEntry e,
}

private static final class HackListEntry
implements Comparable<HackListEntry>
{
private final Hack hack;
private int offset;
Expand All @@ -185,19 +190,15 @@ public HackListEntry(Hack mod, int offset)
prevOffset = offset;
}

@Override
public int compareTo(HackListEntry o)
{
return hack.getRenderName()
.compareToIgnoreCase(o.hack.getRenderName());
}

@Override
public boolean equals(Object obj)
{
if(!(obj instanceof HackListEntry other))
// do not use Java 16 syntax here,
// it breaks Eclipse's Clean Up feature
if(!(obj instanceof HackListEntry))
return false;

HackListEntry other = (HackListEntry)obj;
return hack == other.hack;
}

Expand Down
41 changes: 32 additions & 9 deletions src/main/java/net/wurstclient/mixin/TitleScreenMixin.java
Expand Up @@ -27,32 +27,55 @@
@Mixin(TitleScreen.class)
public abstract class TitleScreenMixin extends Screen
{
private ClickableWidget realmsButton = null;
private ButtonWidget altsButton;

private TitleScreenMixin(WurstClient wurst, Text text_1)
{
super(text_1);
}

@Inject(at = {@At("RETURN")}, method = {"initWidgetsNormal(II)V"})
private void onInitWidgetsNormal(int y, int spacingY, CallbackInfo ci)
@Inject(at = {@At("RETURN")}, method = {"init()V"})
private void onInitWidgetsNormal(CallbackInfo ci)
{
if(!WurstClient.INSTANCE.isEnabled())
return;

addDrawableChild(new ButtonWidget(width / 2 + 2, y + spacingY * 2, 98,
20, new LiteralText("Alt Manager"),
b -> client.setScreen(new AltManagerScreen(this,
WurstClient.INSTANCE.getAltManager()))));

for(Drawable d : ((IScreen)this).getButtons())
{
if(!(d instanceof ClickableWidget button))
if(!(d instanceof ClickableWidget))
continue;

ClickableWidget button = (ClickableWidget)d;
if(!button.getMessage().getString()
.equals(I18n.translate("menu.online")))
continue;

button.setWidth(98);
realmsButton = button;
break;
}

if(realmsButton == null)
throw new IllegalStateException("Couldn't find realms button!");

// make Realms button smaller
realmsButton.setWidth(98);

// add AltManager button
addDrawableChild(altsButton = new ButtonWidget(width / 2 + 2,
realmsButton.y, 98, 20, new LiteralText("Alt Manager"),
b -> client.setScreen(new AltManagerScreen(this,
WurstClient.INSTANCE.getAltManager()))));
}

@Inject(at = {@At("RETURN")}, method = {"tick()V"})
private void onTick(CallbackInfo ci)
{
if(realmsButton == null || altsButton == null)
return;

// adjust AltManager button if Realms button has been moved
// happens when ModMenu is installed
altsButton.y = realmsButton.y;
}
}
70 changes: 70 additions & 0 deletions src/main/java/net/wurstclient/other_features/HackListOtf.java
Expand Up @@ -7,8 +7,12 @@
*/
package net.wurstclient.other_features;

import java.util.Comparator;

import net.wurstclient.DontBlock;
import net.wurstclient.SearchTags;
import net.wurstclient.WurstClient;
import net.wurstclient.hack.Hack;
import net.wurstclient.other_feature.OtherFeature;
import net.wurstclient.settings.CheckboxSetting;
import net.wurstclient.settings.EnumSetting;
Expand All @@ -29,9 +33,18 @@ public final class HackListOtf extends OtherFeature
private final EnumSetting<Position> position =
new EnumSetting<>("Position", Position.values(), Position.LEFT);

private final EnumSetting<SortBy> sortBy =
new EnumSetting<>("Sort by", SortBy.values(), SortBy.NAME);

private final CheckboxSetting revSort =
new CheckboxSetting("Reverse sorting", false);

private final CheckboxSetting animations =
new CheckboxSetting("Animations", true);

private SortBy prevSortBy;
private Boolean prevRevSort;

public HackListOtf()
{
super("HackList", "Shows a list of active hacks on the screen.\n"
Expand All @@ -40,6 +53,8 @@ public HackListOtf()

addSetting(mode);
addSetting(position);
addSetting(sortBy);
addSetting(revSort);
addSetting(animations);
}

Expand All @@ -58,6 +73,38 @@ public boolean isAnimations()
return animations.isChecked();
}

public Comparator<Hack> getComparator()
{
if(revSort.isChecked())
return sortBy.getSelected().comparator.reversed();

return sortBy.getSelected().comparator;
}

public boolean shouldSort()
{
try
{
// width of a renderName could change at any time
// must sort the HackList every tick
if(sortBy.getSelected() == SortBy.WIDTH)
return true;

if(sortBy.getSelected() != prevSortBy)
return true;

if(!Boolean.valueOf(revSort.isChecked()).equals(prevRevSort))
return true;

return false;

}finally
{
prevSortBy = sortBy.getSelected();
prevRevSort = revSort.isChecked();
}
}

public static enum Mode
{
AUTO("Auto"),
Expand Down Expand Up @@ -99,4 +146,27 @@ public String toString()
return name;
}
}

public static enum SortBy
{
NAME("Name", (a, b) -> a.getName().compareToIgnoreCase(b.getName())),

WIDTH("Width", Comparator.comparingInt(
h -> WurstClient.MC.textRenderer.getWidth(h.getRenderName())));

private final String name;
private final Comparator<Hack> comparator;

private SortBy(String name, Comparator<Hack> comparator)
{
this.name = name;
this.comparator = comparator;
}

@Override
public String toString()
{
return name;
}
}
}

0 comments on commit 49aa35e

Please sign in to comment.