0
0
mirror of https://github.com/Wurst-Imperium/Wurst7.git synced 2024-09-20 01:12:13 +02:00

Merge #835 (PortalESP)

This commit is contained in:
Alexander01998 2023-12-15 10:26:29 +01:00
commit 676d07ae9c
5 changed files with 408 additions and 0 deletions

View File

@ -150,6 +150,7 @@ public final class HackList implements UpdateListener
public final PanicHack panicHack = new PanicHack();
public final ParkourHack parkourHack = new ParkourHack();
public final PlayerEspHack playerEspHack = new PlayerEspHack();
public final PortalEspHack portalEspHack = new PortalEspHack();
public final PortalGuiHack portalGuiHack = new PortalGuiHack();
public final PotionSaverHack potionSaverHack = new PotionSaverHack();
public final ProphuntEspHack prophuntEspHack = new ProphuntEspHack();

View File

@ -0,0 +1,196 @@
/*
* Copyright (c) 2014-2023 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.awt.Color;
import java.util.Arrays;
import java.util.List;
import java.util.function.BiPredicate;
import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.BlockPos;
import net.wurstclient.Category;
import net.wurstclient.events.CameraTransformViewBobbingListener;
import net.wurstclient.events.PacketInputListener;
import net.wurstclient.events.RenderListener;
import net.wurstclient.events.UpdateListener;
import net.wurstclient.hack.Hack;
import net.wurstclient.hacks.portalesp.PortalEspBlockGroup;
import net.wurstclient.hacks.portalesp.PortalEspRenderer;
import net.wurstclient.settings.CheckboxSetting;
import net.wurstclient.settings.ChunkAreaSetting;
import net.wurstclient.settings.ColorSetting;
import net.wurstclient.settings.EspStyleSetting;
import net.wurstclient.util.ChunkSearcher.Result;
import net.wurstclient.util.ChunkSearcherCoordinator;
import net.wurstclient.util.RenderUtils;
public final class PortalEspHack extends Hack implements UpdateListener,
CameraTransformViewBobbingListener, RenderListener
{
private final EspStyleSetting style = new EspStyleSetting();
private final PortalEspBlockGroup netherPortal =
new PortalEspBlockGroup(Blocks.NETHER_PORTAL,
new ColorSetting("Nether portal color",
"Nether portals will be highlighted in this color.", Color.RED),
new CheckboxSetting("Include nether portals", true));
private final PortalEspBlockGroup endPortal =
new PortalEspBlockGroup(Blocks.END_PORTAL,
new ColorSetting("End portal color",
"End portals will be highlighted in this color.", Color.GREEN),
new CheckboxSetting("Include end portals", true));
private final PortalEspBlockGroup endPortalFrame = new PortalEspBlockGroup(
Blocks.END_PORTAL_FRAME,
new ColorSetting("End portal frame color",
"End portal frames will be highlighted in this color.", Color.BLUE),
new CheckboxSetting("Include end portal frames", true));
private final PortalEspBlockGroup endGateway = new PortalEspBlockGroup(
Blocks.END_GATEWAY,
new ColorSetting("End gateway color",
"End gateways will be highlighted in this color.", Color.YELLOW),
new CheckboxSetting("Include end gateways", true));
private final List<PortalEspBlockGroup> groups =
Arrays.asList(netherPortal, endPortal, endPortalFrame, endGateway);
private final ChunkAreaSetting area = new ChunkAreaSetting("Area",
"The area around the player to search in.\n"
+ "Higher values require a faster computer.");
private final BiPredicate<BlockPos, BlockState> query =
(pos, state) -> state.getBlock() == Blocks.NETHER_PORTAL
|| state.getBlock() == Blocks.END_PORTAL
|| state.getBlock() == Blocks.END_PORTAL_FRAME
|| state.getBlock() == Blocks.END_GATEWAY;
private final ChunkSearcherCoordinator coordinator =
new ChunkSearcherCoordinator(query, area);
private boolean groupsUpToDate;
public PortalEspHack()
{
super("PortalESP");
setCategory(Category.RENDER);
addSetting(style);
groups.stream().flatMap(PortalEspBlockGroup::getSettings)
.forEach(this::addSetting);
addSetting(area);
}
@Override
public void onEnable()
{
groupsUpToDate = false;
EVENTS.add(UpdateListener.class, this);
EVENTS.add(PacketInputListener.class, coordinator);
EVENTS.add(CameraTransformViewBobbingListener.class, this);
EVENTS.add(RenderListener.class, this);
PortalEspRenderer.prepareBuffers();
}
@Override
public void onDisable()
{
EVENTS.remove(UpdateListener.class, this);
EVENTS.remove(PacketInputListener.class, coordinator);
EVENTS.remove(CameraTransformViewBobbingListener.class, this);
EVENTS.remove(RenderListener.class, this);
coordinator.reset();
groups.forEach(PortalEspBlockGroup::clear);
PortalEspRenderer.closeBuffers();
}
@Override
public void onCameraTransformViewBobbing(
CameraTransformViewBobbingEvent event)
{
if(style.getSelected().hasLines())
event.cancel();
}
@Override
public void onUpdate()
{
boolean searchersChanged = coordinator.update();
if(searchersChanged)
groupsUpToDate = false;
if(!groupsUpToDate && coordinator.isDone())
updateGroupBoxes();
}
@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.glEnable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_DEPTH_TEST);
matrixStack.push();
RenderUtils.applyRegionalRenderOffset(matrixStack);
PortalEspRenderer espRenderer =
new PortalEspRenderer(matrixStack, partialTicks);
if(style.getSelected().hasBoxes())
{
RenderSystem.setShader(GameRenderer::getPositionProgram);
groups.stream().filter(PortalEspBlockGroup::isEnabled)
.forEach(espRenderer::renderBoxes);
}
if(style.getSelected().hasLines())
{
RenderSystem.setShader(GameRenderer::getPositionProgram);
groups.stream().filter(PortalEspBlockGroup::isEnabled)
.forEach(espRenderer::renderLines);
}
matrixStack.pop();
// GL resets
RenderSystem.setShaderColor(1, 1, 1, 1);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_BLEND);
}
private void updateGroupBoxes()
{
groups.forEach(PortalEspBlockGroup::clear);
coordinator.getMatches().forEach(this::addToGroupBoxes);
groupsUpToDate = true;
}
private void addToGroupBoxes(Result result)
{
for(PortalEspBlockGroup group : groups)
if(result.state().getBlock() == group.getBlock())
{
group.add(result.pos());
break;
}
}
}

View File

@ -0,0 +1,86 @@
/*
* Copyright (c) 2014-2023 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.portalesp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;
import net.minecraft.block.Block;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.wurstclient.settings.CheckboxSetting;
import net.wurstclient.settings.ColorSetting;
import net.wurstclient.settings.Setting;
import net.wurstclient.util.BlockUtils;
public final class PortalEspBlockGroup
{
protected final ArrayList<Box> boxes = new ArrayList<>();
private final Block block;
private final ColorSetting color;
private final CheckboxSetting enabled;
public PortalEspBlockGroup(Block block, ColorSetting color,
CheckboxSetting enabled)
{
this.block = block;
this.color = Objects.requireNonNull(color);
this.enabled = enabled;
}
public void add(BlockPos pos)
{
Box box = getBox(pos);
if(box == null)
return;
boxes.add(box);
}
private Box getBox(BlockPos pos)
{
if(!BlockUtils.canBeClicked(pos))
return null;
return BlockUtils.getBoundingBox(pos);
}
public void clear()
{
boxes.clear();
}
public boolean isEnabled()
{
return enabled == null || enabled.isChecked();
}
public Stream<Setting> getSettings()
{
return Stream.of(enabled, color).filter(Objects::nonNull);
}
public Block getBlock()
{
return block;
}
public float[] getColorF()
{
return color.getColorF();
}
public List<Box> getBoxes()
{
return Collections.unmodifiableList(boxes);
}
}

View File

@ -0,0 +1,124 @@
/*
* Copyright (c) 2014-2023 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.portalesp;
import java.util.Objects;
import java.util.stream.Stream;
import org.joml.Matrix4f;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gl.ShaderProgram;
import net.minecraft.client.gl.VertexBuffer;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;
import net.wurstclient.util.RegionPos;
import net.wurstclient.util.RenderUtils;
import net.wurstclient.util.RotationUtils;
public final class PortalEspRenderer
{
private static VertexBuffer solidBox;
private static VertexBuffer outlinedBox;
private final MatrixStack matrixStack;
private final RegionPos region;
private final Vec3d start;
public PortalEspRenderer(MatrixStack matrixStack, float partialTicks)
{
this.matrixStack = matrixStack;
region = RenderUtils.getCameraRegion();
start = RotationUtils.getClientLookVec(partialTicks)
.add(RenderUtils.getCameraPos()).subtract(region.toVec3d());
}
public void renderBoxes(PortalEspBlockGroup group)
{
float[] colorF = group.getColorF();
for(Box box : group.getBoxes())
{
matrixStack.push();
matrixStack.translate(box.minX - region.x(), box.minY,
box.minZ - region.z());
matrixStack.scale((float)(box.maxX - box.minX),
(float)(box.maxY - box.minY), (float)(box.maxZ - box.minZ));
Matrix4f viewMatrix = matrixStack.peek().getPositionMatrix();
Matrix4f projMatrix = RenderSystem.getProjectionMatrix();
ShaderProgram shader = RenderSystem.getShader();
RenderSystem.setShaderColor(colorF[0], colorF[1], colorF[2], 0.25F);
solidBox.bind();
solidBox.draw(viewMatrix, projMatrix, shader);
VertexBuffer.unbind();
RenderSystem.setShaderColor(colorF[0], colorF[1], colorF[2], 0.5F);
outlinedBox.bind();
outlinedBox.draw(viewMatrix, projMatrix, shader);
VertexBuffer.unbind();
matrixStack.pop();
}
}
public void renderLines(PortalEspBlockGroup group)
{
Matrix4f matrix = matrixStack.peek().getPositionMatrix();
Tessellator tessellator = RenderSystem.renderThreadTesselator();
BufferBuilder bufferBuilder = tessellator.getBuffer();
float[] colorF = group.getColorF();
RenderSystem.setShaderColor(colorF[0], colorF[1], colorF[2], 0.5F);
bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES,
VertexFormats.POSITION);
for(Box box : group.getBoxes())
{
Vec3d end = box.getCenter().subtract(region.toVec3d());
bufferBuilder
.vertex(matrix, (float)start.x, (float)start.y, (float)start.z)
.next();
bufferBuilder
.vertex(matrix, (float)end.x, (float)end.y, (float)end.z)
.next();
}
tessellator.draw();
}
public static void prepareBuffers()
{
closeBuffers();
solidBox = new VertexBuffer(VertexBuffer.Usage.STATIC);
outlinedBox = new VertexBuffer(VertexBuffer.Usage.STATIC);
Box box = new Box(BlockPos.ORIGIN);
RenderUtils.drawSolidBox(box, solidBox);
RenderUtils.drawOutlinedBox(box, outlinedBox);
}
public static void closeBuffers()
{
Stream.of(solidBox, outlinedBox).filter(Objects::nonNull)
.forEach(VertexBuffer::close);
}
}

View File

@ -130,6 +130,7 @@
"description.wurst.hack.panic": "Instantly turns off all enabled hacks.\nBe careful with this one!",
"description.wurst.hack.parkour": "Makes you jump automatically when reaching the edge of a block.\nUseful for parkours and jump'n'runs.",
"description.wurst.hack.playeresp": "Highlights nearby players.\nESP boxes of friends will appear in blue.",
"description.wurst.hack.portalesp": "Highlights nearby portals.",
"description.wurst.hack.portalgui": "Allows you to open GUIs in portals.",
"description.wurst.hack.potionsaver": "Freezes all potion effects while you are standing still.",
"description.wurst.hack.prophuntesp": "Allows you to see fake blocks in Prophunt.\nMade for Mineplex Prophunt. Might not work on other servers.",