-
-
Notifications
You must be signed in to change notification settings - Fork 418
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
Add TeamEspHack #1049
Open
LilyKensa
wants to merge
2
commits into
Wurst-Imperium:master
Choose a base branch
from
LilyKensa:teamesp-pr
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add TeamEspHack #1049
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/net/wurstclient/settings/filters/FilterTeammatesSetting.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,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); | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Efficient Box Rendering.
The
renderBoxes
method efficiently calculates player positions and colors. Consider caching results if performance becomes an issue.