Skip to content

Commit

Permalink
Use OverlayRenderer in TreeBotHack
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Oct 31, 2023
1 parent f7decff commit 251cfa4
Showing 1 changed file with 9 additions and 49 deletions.
58 changes: 9 additions & 49 deletions src/main/java/net/wurstclient/hacks/TreeBotHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
Expand All @@ -48,7 +47,7 @@
import net.wurstclient.treebot.Tree;
import net.wurstclient.treebot.TreeBotUtils;
import net.wurstclient.util.BlockUtils;
import net.wurstclient.util.RegionPos;
import net.wurstclient.util.OverlayRenderer;
import net.wurstclient.util.RenderUtils;
import net.wurstclient.util.RotationUtils;

Expand All @@ -67,8 +66,7 @@ public final class TreeBotHack extends Hack
private Tree tree;

private BlockPos currentBlock;
private float progress;
private float prevProgress;
private final OverlayRenderer overlay = new OverlayRenderer();

public TreeBotHack()
{
Expand Down Expand Up @@ -124,6 +122,8 @@ public void onDisable()
MC.interactionManager.cancelBlockBreaking();
currentBlock = null;
}

overlay.resetProgress();
}

@Override
Expand Down Expand Up @@ -236,18 +236,9 @@ private void breakBlocks(ArrayList<BlockPos> blocksInRange)
MC.interactionManager.cancelBlockBreaking();

if(currentBlock != null && BlockUtils.getHardness(currentBlock) < 1)
{
prevProgress = progress;
progress = MC.interactionManager.currentBreakingProgress;

if(progress < prevProgress)
prevProgress = progress;

}else
{
progress = 1;
prevProgress = 1;
}
overlay.updateProgress();
else
overlay.resetProgress();
}

private boolean breakBlock(BlockPos pos)
Expand Down Expand Up @@ -301,13 +292,12 @@ public void onRender(MatrixStack matrixStack, float partialTicks)
if(tree != null)
drawTree(matrixStack);

if(currentBlock != null)
drawCurrentBlock(matrixStack, partialTicks);

// GL resets
RenderSystem.setShaderColor(1, 1, 1, 1);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_BLEND);

overlay.render(matrixStack, partialTicks, currentBlock);
}

private void drawTree(MatrixStack matrixStack)
Expand All @@ -329,36 +319,6 @@ private void drawTree(MatrixStack matrixStack)
matrixStack.pop();
}

private void drawCurrentBlock(MatrixStack matrixStack, float partialTicks)
{
matrixStack.push();

RegionPos region = RenderUtils.getCameraRegion();
RenderUtils.applyRegionalRenderOffset(matrixStack, region);

Box box = new Box(BlockPos.ORIGIN);
float p = prevProgress + (progress - prevProgress) * partialTicks;
float red = p * 2F;
float green = 2 - red;

matrixStack.translate(currentBlock.getX() - region.x(),
currentBlock.getY(), currentBlock.getZ() - region.z());
if(p < 1)
{
matrixStack.translate(0.5, 0.5, 0.5);
matrixStack.scale(p, p, p);
matrixStack.translate(-0.5, -0.5, -0.5);
}

RenderSystem.setShaderColor(red, green, 0, 0.25F);
RenderUtils.drawSolidBox(box, matrixStack);

RenderSystem.setShaderColor(red, green, 0, 0.5F);
RenderUtils.drawOutlinedBox(box, matrixStack);

matrixStack.pop();
}

private ArrayList<BlockPos> getNeighbors(BlockPos pos)
{
return BlockUtils
Expand Down

0 comments on commit 251cfa4

Please sign in to comment.