-
-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TeamEspHack & FilterNpcLikeSetting
- Loading branch information
Showing
7 changed files
with
313 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/main/java/net/wurstclient/settings/filters/FilterNpcLikeSetting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters