From 21ce72be39c4bf4598fd65005d7ab3fb4b9c0204 Mon Sep 17 00:00:00 2001 From: Lily Kensa Date: Sat, 10 Aug 2024 00:59:24 +0800 Subject: [PATCH 1/2] Add TeamEspHack & FilterNpcLikeSetting --- .../java/net/wurstclient/hack/HackList.java | 1 + .../net/wurstclient/hacks/PlayerEspHack.java | 1 + .../net/wurstclient/hacks/TeamEspHack.java | 240 ++++++++++++++++++ .../filterlists/EntityFilterList.java | 1 + .../filters/FilterNpcLikeSetting.java | 68 +++++ .../assets/wurst/translations/en_us.json | 1 + .../assets/wurst/translations/zh_tw.json | 1 + 7 files changed, 313 insertions(+) create mode 100644 src/main/java/net/wurstclient/hacks/TeamEspHack.java create mode 100644 src/main/java/net/wurstclient/settings/filters/FilterNpcLikeSetting.java diff --git a/src/main/java/net/wurstclient/hack/HackList.java b/src/main/java/net/wurstclient/hack/HackList.java index d750429540..944873c9be 100644 --- a/src/main/java/net/wurstclient/hack/HackList.java +++ b/src/main/java/net/wurstclient/hack/HackList.java @@ -172,6 +172,7 @@ public final class HackList implements UpdateListener public final SpeedNukerHack speedNukerHack = new SpeedNukerHack(); public final SpiderHack spiderHack = new SpiderHack(); public final StepHack stepHack = new StepHack(); + public final TeamEspHack teamEspHack = new TeamEspHack(); public final TemplateToolHack templateToolHack = new TemplateToolHack(); public final ThrowHack throwHack = new ThrowHack(); public final TillauraHack tillauraHack = new TillauraHack(); diff --git a/src/main/java/net/wurstclient/hacks/PlayerEspHack.java b/src/main/java/net/wurstclient/hacks/PlayerEspHack.java index dcd883fda8..4536885d7b 100644 --- a/src/main/java/net/wurstclient/hacks/PlayerEspHack.java +++ b/src/main/java/net/wurstclient/hacks/PlayerEspHack.java @@ -77,6 +77,7 @@ public PlayerEspHack() @Override protected void onEnable() { + WURST.getHax().teamEspHack.setEnabled(false); EVENTS.add(UpdateListener.class, this); EVENTS.add(CameraTransformViewBobbingListener.class, this); EVENTS.add(RenderListener.class, this); diff --git a/src/main/java/net/wurstclient/hacks/TeamEspHack.java b/src/main/java/net/wurstclient/hacks/TeamEspHack.java new file mode 100644 index 0000000000..b5a7b60a7f --- /dev/null +++ b/src/main/java/net/wurstclient/hacks/TeamEspHack.java @@ -0,0 +1,240 @@ +/* + * Copyright (c) 2014-2024 Wurst-Imperium and contributors. + * + * This source code is subject to the terms of the GNU General Public + * License, version 3. If a copy of the GPL was not distributed with this + * file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt + */ +package net.wurstclient.hacks; + +import java.util.ArrayList; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import net.minecraft.client.render.*; +import net.minecraft.text.TextColor; +import net.wurstclient.settings.filters.FilterNpcLikeSetting; +import org.joml.Matrix4f; +import org.lwjgl.opengl.GL11; + +import com.mojang.blaze3d.systems.RenderSystem; + +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.math.Box; +import net.minecraft.util.math.Vec3d; +import net.wurstclient.Category; +import net.wurstclient.SearchTags; +import net.wurstclient.events.CameraTransformViewBobbingListener; +import net.wurstclient.events.RenderListener; +import net.wurstclient.events.UpdateListener; +import net.wurstclient.hack.Hack; +import net.wurstclient.settings.EspBoxSizeSetting; +import net.wurstclient.settings.EspStyleSetting; +import net.wurstclient.settings.EspStyleSetting.EspStyle; +import net.wurstclient.settings.filterlists.EntityFilterList; +import net.wurstclient.settings.filters.FilterInvisibleSetting; +import net.wurstclient.settings.filters.FilterSleepingSetting; +import net.wurstclient.util.EntityUtils; +import net.wurstclient.util.FakePlayerEntity; +import net.wurstclient.util.RegionPos; +import net.wurstclient.util.RenderUtils; +import net.wurstclient.util.RotationUtils; + +// Pretty much just cloned from PlayerEspHack.java +@SearchTags({"team esp", "TeamTracers", "team tracers"}) +public final class TeamEspHack extends Hack implements UpdateListener, + CameraTransformViewBobbingListener, RenderListener +{ + private final EspStyleSetting style = + new EspStyleSetting(EspStyle.LINES_AND_BOXES); + + private final EspBoxSizeSetting boxSize = new EspBoxSizeSetting( + "\u00a7lAccurate\u00a7r mode shows the exact hitbox of each player.\n" + + "\u00a7lFancy\u00a7r mode shows slightly larger boxes that look better."); + + private final EntityFilterList entityFilters = + new EntityFilterList(FilterNpcLikeSetting.genericVision(false), + FilterSleepingSetting.genericVision(false), + FilterInvisibleSetting.genericVision(false)); + + private final ArrayList players = new ArrayList<>(); + + public TeamEspHack() + { + super("TeamESP"); + setCategory(Category.RENDER); + + addSetting(style); + addSetting(boxSize); + entityFilters.forEach(this::addSetting); + } + + @Override + protected void onEnable() + { + WURST.getHax().playerEspHack.setEnabled(false); + EVENTS.add(UpdateListener.class, this); + EVENTS.add(CameraTransformViewBobbingListener.class, this); + EVENTS.add(RenderListener.class, this); + } + + @Override + protected void onDisable() + { + EVENTS.remove(UpdateListener.class, this); + EVENTS.remove(CameraTransformViewBobbingListener.class, this); + EVENTS.remove(RenderListener.class, this); + } + + @Override + public void onUpdate() + { + PlayerEntity player = MC.player; + ClientWorld world = MC.world; + + players.clear(); + Stream stream = world.getPlayers() + .parallelStream().filter(e -> !e.isRemoved() && e.getHealth() > 0) + .filter(e -> e != player) + .filter(e -> !(e instanceof FakePlayerEntity)) + .filter(e -> Math.abs(e.getY() - MC.player.getY()) <= 1e6); + + stream = entityFilters.applyTo(stream); + + players.addAll(stream.collect(Collectors.toList())); + } + + @Override + public void onCameraTransformViewBobbing( + CameraTransformViewBobbingEvent event) + { + if(style.hasLines()) + event.cancel(); + } + + @Override + public void onRender(MatrixStack matrixStack, float partialTicks) + { + // GL settings + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + matrixStack.push(); + + RegionPos region = RenderUtils.getCameraRegion(); + RenderUtils.applyRegionalRenderOffset(matrixStack, region); + + // draw boxes + if(style.hasBoxes()) + renderBoxes(matrixStack, partialTicks, region); + + if(style.hasLines()) + renderTracers(matrixStack, partialTicks, region); + + matrixStack.pop(); + + // GL resets + RenderSystem.setShaderColor(1, 1, 1, 1); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_BLEND); + } + + private void renderBoxes(MatrixStack matrixStack, float partialTicks, + RegionPos region) + { + float extraSize = boxSize.getExtraSize(); + + for(PlayerEntity e : players) + { + matrixStack.push(); + + Vec3d lerpedPos = EntityUtils.getLerpedPos(e, partialTicks) + .subtract(region.toVec3d()); + matrixStack.translate(lerpedPos.x, lerpedPos.y, lerpedPos.z); + + matrixStack.scale(e.getWidth() + extraSize, + e.getHeight() + extraSize, e.getWidth() + extraSize); + + TextColor colorComponent = e.getDisplayName().getStyle().getColor(); + + float r = 0.8f, g = 0.8f, b = 0.8f; + + if(colorComponent != null) + { + int teamColor = colorComponent.getRgb(); + + b = (float)(teamColor % 256); + g = (float)(teamColor % 65536 / 256); + r = (float)(teamColor / 65536); + + b /= 256; + g /= 256; + r /= 256; + } + + RenderSystem.setShaderColor(r, g, b, 0.5F); + + Box bb = new Box(-0.5, 0, -0.5, 0.5, 1, 0.5); + RenderUtils.drawOutlinedBox(bb, matrixStack); + + matrixStack.pop(); + } + } + + private void renderTracers(MatrixStack matrixStack, float partialTicks, + RegionPos region) + { + if(players.isEmpty()) + return; + + RenderSystem.setShader(GameRenderer::getPositionColorProgram); + RenderSystem.setShaderColor(1, 1, 1, 1); + + Matrix4f matrix = matrixStack.peek().getPositionMatrix(); + + Tessellator tessellator = RenderSystem.renderThreadTesselator(); + BufferBuilder bufferBuilder = tessellator.begin( + VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR); + + Vec3d regionVec = region.toVec3d(); + Vec3d start = RotationUtils.getClientLookVec(partialTicks) + .add(RenderUtils.getCameraPos()).subtract(regionVec); + + for(PlayerEntity e : players) + { + Vec3d end = EntityUtils.getLerpedBox(e, partialTicks).getCenter() + .subtract(regionVec); + + TextColor colorComponent = e.getDisplayName().getStyle().getColor(); + + float r = 0.8f, g = 0.8f, b = 0.8f; + + if(colorComponent != null) + { + int teamColor = colorComponent.getRgb(); + + b = (float)(teamColor % 256); + g = (float)(teamColor % 65536 / 256); + r = (float)(teamColor / 65536); + + b /= 256; + g /= 256; + r /= 256; + } + + bufferBuilder + .vertex(matrix, (float)start.x, (float)start.y, (float)start.z) + .color(r, g, b, 0.5F); + + bufferBuilder + .vertex(matrix, (float)end.x, (float)end.y, (float)end.z) + .color(r, g, b, 0.5F); + } + + BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); + } +} diff --git a/src/main/java/net/wurstclient/settings/filterlists/EntityFilterList.java b/src/main/java/net/wurstclient/settings/filterlists/EntityFilterList.java index 68aad62b78..5de72c364f 100644 --- a/src/main/java/net/wurstclient/settings/filterlists/EntityFilterList.java +++ b/src/main/java/net/wurstclient/settings/filterlists/EntityFilterList.java @@ -62,6 +62,7 @@ public final boolean testOne(Entity entity) public static EntityFilterList genericCombat() { return new EntityFilterList(FilterPlayersSetting.genericCombat(false), + FilterNpcLikeSetting.genericCombat(false), FilterSleepingSetting.genericCombat(false), FilterFlyingSetting.genericCombat(0), FilterHostileSetting.genericCombat(false), diff --git a/src/main/java/net/wurstclient/settings/filters/FilterNpcLikeSetting.java b/src/main/java/net/wurstclient/settings/filters/FilterNpcLikeSetting.java new file mode 100644 index 0000000000..82f3a8d2c7 --- /dev/null +++ b/src/main/java/net/wurstclient/settings/filters/FilterNpcLikeSetting.java @@ -0,0 +1,68 @@ +package net.wurstclient.settings.filters; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; + +public final class FilterNpcLikeSetting extends EntityFilterCheckbox +{ + public FilterNpcLikeSetting(String description, boolean checked) + { + super("Filter NPC-like", description, checked); + } + + @Override + public boolean test(Entity e) + { + if(!(e instanceof PlayerEntity)) + return true; + + String name = e.getName().getString(); + if(name.length() != 10) + return true; + + int letters = 0, digits = 0, maxLetters = 0, maxDigits = 0; + for(int c : name.chars().toArray()) + { + if(Character.isDigit(c)) + { + letters = 0; + digits += 1; + }else if(Character.isLetter(c) && Character.isLowerCase(c)) + { + digits = 0; + letters += 1; + }else + { + return true; + } + + if(letters > maxLetters) + maxLetters = letters; + if(digits > maxDigits) + maxDigits = digits; + } + + if(maxDigits == 0) + return true; + if(maxLetters >= 4 && maxDigits >= 4) + return true; + if(maxLetters >= 5) + return true; + + return false; + } + + public static FilterNpcLikeSetting genericCombat(boolean checked) + { + return new FilterNpcLikeSetting( + "Won't attack NPC-like players (Sort by Hypixel NPC names.)", + checked); + } + + public static FilterNpcLikeSetting genericVision(boolean checked) + { + return new FilterNpcLikeSetting( + "Won't show NPC-like players (Sort by Hypixel NPC names.)", + checked); + } +} diff --git a/src/main/resources/assets/wurst/translations/en_us.json b/src/main/resources/assets/wurst/translations/en_us.json index f7aec70c3b..ac3d466d26 100644 --- a/src/main/resources/assets/wurst/translations/en_us.json +++ b/src/main/resources/assets/wurst/translations/en_us.json @@ -208,6 +208,7 @@ "description.wurst.hack.spider": "Allows you to climb up walls like a spider.", "description.wurst.hack.step": "Allows you to step up full blocks.", "description.wurst.hack.templatetool": "Allows you to create custom templates for AutoBuild by scanning existing buildings.", + "description.wurst.hack.teamesp": "Highlights nearby teammates/enemies.\nESP boxes will appear in the same color of their name tag.", "description.wurst.hack.throw": "Uses an item multiple times. Can be used to throw snowballs and eggs, spawn mobs, place minecarts, etc. in very large quantities.\n\nThis can cause a lot of lag and even crash a server.", "description.wurst.hack.tillaura": "Automatically turns dirt, grass, etc. into farmland.\nNot to be confused with Killaura.", "description.wurst.hack.timer": "Changes the speed of almost everything.", diff --git a/src/main/resources/assets/wurst/translations/zh_tw.json b/src/main/resources/assets/wurst/translations/zh_tw.json index e189a0ecf4..e30f3776a2 100644 --- a/src/main/resources/assets/wurst/translations/zh_tw.json +++ b/src/main/resources/assets/wurst/translations/zh_tw.json @@ -143,6 +143,7 @@ "description.wurst.hack.step": "允許你走上更高高度(取決於你的設定)的格子方塊。", "description.wurst.hack.throw": "迅速丟你手中種類的物品,可以用於丟雪球、雞蛋、刷怪蛋、礦車,諸如此類。\n\n會生成大量的數量,這會產生大量的lag且可能會導致服務器崩潰。", "description.wurst.hack.tillaura": "自動將泥土、草塊、諸如此類。轉化為耕地。\n不要和Killaura搞混。", + "description.wurst.hack.teamesp": "高亮透視附近的隊友或敵人。\n會顯示跟他們的名字標籤同樣顏色的框框。", "description.wurst.hack.timer": "改變大部分東西的速度。", "description.wurst.hack.tired": "讓你看起來很像2015年的Alexander。\n僅限其他玩家可視。", "description.wurst.hack.toomanyhax": "關閉那些你並不想要使用的功能。\n讓你確保你不會不小心開啟錯誤的作弊功能導致被服務器封禁。\n這個是給那些“只想作弊一點點的用戶”。\n\n使用指令§6. toomanyhax§r來選擇哪些功能需要被遮罩。\n輸入§6. help toomanyhax§r尋求更多。", From e27ce536f941524f90deb601af421188535516fd Mon Sep 17 00:00:00 2001 From: Lily Kensa Date: Sat, 10 Aug 2024 09:54:17 +0800 Subject: [PATCH 2/2] Add FilterTeammatesSetting --- .../net/wurstclient/hacks/AimAssistHack.java | 2 + .../filterlists/EntityFilterList.java | 1 + .../filters/FilterTeammatesSetting.java | 47 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 src/main/java/net/wurstclient/settings/filters/FilterTeammatesSetting.java diff --git a/src/main/java/net/wurstclient/hacks/AimAssistHack.java b/src/main/java/net/wurstclient/hacks/AimAssistHack.java index 35b21e01a1..a122046479 100644 --- a/src/main/java/net/wurstclient/hacks/AimAssistHack.java +++ b/src/main/java/net/wurstclient/hacks/AimAssistHack.java @@ -60,6 +60,8 @@ public final class AimAssistHack extends Hack private final EntityFilterList entityFilters = new EntityFilterList(FilterPlayersSetting.genericCombat(false), + FilterTeammatesSetting.genericCombat(false), + FilterNpcLikeSetting.genericCombat(false), FilterSleepingSetting.genericCombat(false), FilterFlyingSetting.genericCombat(0), FilterHostileSetting.genericCombat(false), diff --git a/src/main/java/net/wurstclient/settings/filterlists/EntityFilterList.java b/src/main/java/net/wurstclient/settings/filterlists/EntityFilterList.java index 5de72c364f..51db92511f 100644 --- a/src/main/java/net/wurstclient/settings/filterlists/EntityFilterList.java +++ b/src/main/java/net/wurstclient/settings/filterlists/EntityFilterList.java @@ -62,6 +62,7 @@ public final boolean testOne(Entity entity) public static EntityFilterList genericCombat() { return new EntityFilterList(FilterPlayersSetting.genericCombat(false), + FilterTeammatesSetting.genericCombat(false), FilterNpcLikeSetting.genericCombat(false), FilterSleepingSetting.genericCombat(false), FilterFlyingSetting.genericCombat(0), diff --git a/src/main/java/net/wurstclient/settings/filters/FilterTeammatesSetting.java b/src/main/java/net/wurstclient/settings/filters/FilterTeammatesSetting.java new file mode 100644 index 0000000000..a90ff5dc5d --- /dev/null +++ b/src/main/java/net/wurstclient/settings/filters/FilterTeammatesSetting.java @@ -0,0 +1,47 @@ +package net.wurstclient.settings.filters; + +import net.minecraft.entity.Entity; +import net.minecraft.text.Text; +import net.minecraft.text.TextColor; +import net.wurstclient.WurstClient; + +public final class FilterTeammatesSetting extends EntityFilterCheckbox +{ + public FilterTeammatesSetting(String description, boolean checked) + { + super("Filter teammates", description, checked); + } + + @Override + public boolean test(Entity e) + { + Text theirName = e.getDisplayName(); + if(theirName == null) + return false; + TextColor theirColor = theirName.getStyle().getColor(); + if(theirColor == null) + return false; + + assert WurstClient.MC.player != null; + Text myName = WurstClient.MC.player.getDisplayName(); + if(myName == null) + return false; + TextColor myColor = myName.getStyle().getColor(); + if(myColor == null) + return false; + + return !theirColor.equals(myColor); + } + + public static FilterTeammatesSetting genericCombat(boolean checked) + { + return new FilterTeammatesSetting( + "Won't attack players with the same name tag color.", checked); + } + + public static FilterTeammatesSetting genericVision(boolean checked) + { + return new FilterTeammatesSetting( + "Won't show players with the same name tag color.", checked); + } +}