Skip to content

Commit

Permalink
Add TeamEspHack & FilterNpcLikeSetting
Browse files Browse the repository at this point in the history
  • Loading branch information
LilyKensa committed Aug 9, 2024
1 parent 8304275 commit 21ce72b
Show file tree
Hide file tree
Showing 7 changed files with 313 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/net/wurstclient/hack/HackList.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/wurstclient/hacks/PlayerEspHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
240 changes: 240 additions & 0 deletions src/main/java/net/wurstclient/hacks/TeamEspHack.java
Original file line number Diff line number Diff line change
@@ -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<PlayerEntity> 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<AbstractClientPlayerEntity> 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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/wurst/translations/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/wurst/translations/zh_tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -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尋求更多。",
Expand Down

0 comments on commit 21ce72b

Please sign in to comment.