diff --git a/src/main/java/net/wurstclient/hacks/TreeBotHack.java b/src/main/java/net/wurstclient/hacks/TreeBotHack.java index c2be1e535a..e8f9c421b1 100644 --- a/src/main/java/net/wurstclient/hacks/TreeBotHack.java +++ b/src/main/java/net/wurstclient/hacks/TreeBotHack.java @@ -15,13 +15,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.joml.Matrix4f; -import org.lwjgl.opengl.GL11; - import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.gl.ShaderProgram; -import net.minecraft.client.gl.VertexBuffer; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.render.GameRenderer; import net.minecraft.client.util.math.MatrixStack; @@ -49,7 +44,6 @@ import net.wurstclient.util.BlockBreaker.BlockBreakingParams; import net.wurstclient.util.BlockUtils; import net.wurstclient.util.OverlayRenderer; -import net.wurstclient.util.RenderUtils; @SearchTags({"tree bot"}) @DontSaveState @@ -280,42 +274,12 @@ public void onRender(MatrixStack matrixStack, float partialTicks) angleFinder.renderPath(matrixStack, pathCmd.isDebugMode(), pathCmd.isDepthTest()); - // 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); - if(tree != null) - drawTree(matrixStack); - - // GL resets - RenderSystem.setShaderColor(1, 1, 1, 1); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glDisable(GL11.GL_BLEND); + tree.draw(matrixStack); overlay.render(matrixStack, partialTicks, currentBlock); } - private void drawTree(MatrixStack matrixStack) - { - RenderSystem.setShaderColor(0, 1, 0, 0.5F); - - matrixStack.push(); - RenderUtils.applyRegionalRenderOffset(matrixStack, - MC.world.getChunk(tree.getStump())); - - Matrix4f viewMatrix = matrixStack.peek().getPositionMatrix(); - Matrix4f projMatrix = RenderSystem.getProjectionMatrix(); - ShaderProgram shader = RenderSystem.getShader(); - - tree.getVertexBuffer().bind(); - tree.getVertexBuffer().draw(viewMatrix, projMatrix, shader); - VertexBuffer.unbind(); - - matrixStack.pop(); - } - private ArrayList getNeighbors(BlockPos pos) { return BlockUtils diff --git a/src/main/java/net/wurstclient/hacks/treebot/Tree.java b/src/main/java/net/wurstclient/hacks/treebot/Tree.java index 9665e9e7d2..98d0135173 100644 --- a/src/main/java/net/wurstclient/hacks/treebot/Tree.java +++ b/src/main/java/net/wurstclient/hacks/treebot/Tree.java @@ -9,14 +9,19 @@ import java.util.ArrayList; +import org.joml.Matrix4f; +import org.lwjgl.opengl.GL11; + 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.BufferBuilder.BuiltBuffer; 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; @@ -65,10 +70,43 @@ public void compileBuffer() VertexBuffer.unbind(); } + public void draw(MatrixStack matrixStack) + { + if(vertexBuffer == null) + return; + + // 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); + + RenderSystem.setShaderColor(0, 1, 0, 0.5F); + + matrixStack.push(); + RenderUtils.applyRegionalRenderOffset(matrixStack, RegionPos.of(stump)); + + Matrix4f viewMatrix = matrixStack.peek().getPositionMatrix(); + Matrix4f projMatrix = RenderSystem.getProjectionMatrix(); + ShaderProgram shader = RenderSystem.getShader(); + + vertexBuffer.bind(); + vertexBuffer.draw(viewMatrix, projMatrix, shader); + VertexBuffer.unbind(); + + matrixStack.pop(); + + // GL resets + RenderSystem.setShaderColor(1, 1, 1, 1); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_BLEND); + } + @Override public void close() { vertexBuffer.close(); + vertexBuffer = null; } public BlockPos getStump() @@ -80,9 +118,4 @@ public ArrayList getLogs() { return logs; } - - public VertexBuffer getVertexBuffer() - { - return vertexBuffer; - } }