Merge pull request #54 from TheBritishMidget/master

Added more Shapes to Waypoints Module
This commit is contained in:
noil 2021-02-09 13:13:27 -05:00 committed by GitHub
commit 67f4ebe83d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 230 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.AxisAlignedBB;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL32;
import org.lwjgl.util.glu.Sphere;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
@ -443,6 +444,208 @@ public final class RenderUtil {
tessellator.draw();
}
public static void drawFilledPyramid(AxisAlignedBB bb, int color) {
final float alpha = (color >> 24 & 0xFF) / 255.0F;
final float red = (color >> 16 & 0xFF) / 255.0F;
final float green = (color >> 8 & 0xFF) / 255.0F;
final float blue = (color & 0xFF) / 255.0F;
final Tessellator tessellator = Tessellator.getInstance();
GlStateManager.disableCull();
final BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR);
bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex(); // 1
bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex(); // 2
bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex(); // 3
bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.maxY, 0).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex(); // 4
bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.maxY, 0).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex(); // 5
bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.maxY, 0).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex(); // 6
bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.maxY, 0).color(red, green, blue, alpha).endVertex();
tessellator.draw();
}
public static void drawBoundingBoxPyramid(AxisAlignedBB bb, float width, int color) {
final float alpha = (color >> 24 & 0xFF) / 255.0F;
final float red = (color >> 16 & 0xFF) / 255.0F;
final float green = (color >> 8 & 0xFF) / 255.0F;
final float blue = (color & 0xFF) / 255.0F;
glLineWidth(width);
final Tessellator tessellator = Tessellator.getInstance();
final BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR);
bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, 0.0F).endVertex();
bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.maxY, 0).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.maxY, 0).color(red, green, blue, 0.0F).endVertex();
bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.maxY, 0).color(red, green, blue, 0.0F).endVertex();
bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.maxY, 0).color(red, green, blue, 0.0F).endVertex();
tessellator.draw();
}
public static void drawFilledDiamond(AxisAlignedBB bb, float yOffset, float extraY, int color) {
final float alpha = (color >> 24 & 0xFF) / 255.0F;
final float red = (color >> 16 & 0xFF) / 255.0F;
final float green = (color >> 8 & 0xFF) / 255.0F;
final float blue = (color & 0xFF) / 255.0F;
final Tessellator tessellator = Tessellator.getInstance();
GlStateManager.disableCull();
final BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR);
// Top Half
bufferbuilder.pos(bb.minX, yOffset, bb.minZ).color(red, green, blue, alpha).endVertex(); // 1
bufferbuilder.pos(bb.minX, yOffset, bb.maxZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.maxY + extraY, 0).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.minX, yOffset, bb.maxZ).color(red, green, blue, alpha).endVertex(); // 2
bufferbuilder.pos(bb.maxX, yOffset, bb.maxZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.maxY + extraY, 0).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.maxX, yOffset, bb.maxZ).color(red, green, blue, alpha).endVertex(); // 3
bufferbuilder.pos(bb.maxX, yOffset, bb.minZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.maxY + extraY, 0).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.maxX, yOffset, bb.minZ).color(red, green, blue, alpha).endVertex(); // 4
bufferbuilder.pos(bb.minX, yOffset, bb.minZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.maxY + extraY, 0).color(red, green, blue, alpha).endVertex();
// Bottom Half
bufferbuilder.pos(bb.minX, yOffset, bb.minZ).color(red, green, blue, alpha).endVertex(); // 5
bufferbuilder.pos(bb.minX, yOffset, bb.maxZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.minY - extraY, 0).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.minX, yOffset, bb.maxZ).color(red, green, blue, alpha).endVertex(); // 6
bufferbuilder.pos(bb.maxX, yOffset, bb.maxZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.minY - extraY, 0).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.maxX, yOffset, bb.maxZ).color(red, green, blue, alpha).endVertex(); // 7
bufferbuilder.pos(bb.maxX, yOffset, bb.minZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.minY - extraY, 0).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.maxX, yOffset, bb.minZ).color(red, green, blue, alpha).endVertex(); // 8
bufferbuilder.pos(bb.minX, yOffset, bb.minZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.minY - extraY, 0).color(red, green, blue, alpha).endVertex();
tessellator.draw();
}
public static void drawBoundingBoxDiamond(AxisAlignedBB bb, float width, float yOffset, float extraY, int color) {
final float alpha = (color >> 24 & 0xFF) / 255.0F;
final float red = (color >> 16 & 0xFF) / 255.0F;
final float green = (color >> 8 & 0xFF) / 255.0F;
final float blue = (color & 0xFF) / 255.0F;
glLineWidth(width);
final Tessellator tessellator = Tessellator.getInstance();
final BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR);
// Top Half
bufferbuilder.pos(bb.minX, yOffset, bb.minZ).color(red, green, blue, 0).endVertex();
bufferbuilder.pos(bb.minX, yOffset, bb.minZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.maxX, yOffset, bb.minZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.maxX, yOffset, bb.maxZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.minX, yOffset, bb.maxZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.minX, yOffset, bb.minZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.maxY + extraY, 0).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.maxX, yOffset, bb.minZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.maxY + extraY, 0).color(red, green, blue, 0).endVertex();
bufferbuilder.pos(bb.maxX, yOffset, bb.maxZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.maxY + extraY, 0).color(red, green, blue, 0).endVertex();
bufferbuilder.pos(bb.minX, yOffset, bb.maxZ).color(red, green, blue, alpha).endVertex();
// Bottom Half
bufferbuilder.pos(0, bb.minY - extraY, 0).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(bb.minX, yOffset, bb.minZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.minY - extraY, 0).color(red, green, blue, 0).endVertex();
bufferbuilder.pos(bb.maxX, yOffset, bb.minZ).color(red, green, blue, alpha).endVertex();
bufferbuilder.pos(0, bb.minY - extraY, 0).color(red, green, blue, 0).endVertex();
bufferbuilder.pos(bb.maxX, yOffset, bb.maxZ).color(red, green, blue, alpha).endVertex();
tessellator.draw();
}
public static void drawSphere(float radius, int slices, int stacks, int color) {
final float alpha = (color >> 24 & 0xFF) / 255.0F;
final float red = (color >> 16 & 0xFF) / 255.0F;
final float green = (color >> 8 & 0xFF) / 255.0F;
final float blue = (color & 0xFF) / 255.0F;
glColor4f(red, green, blue, alpha);
new Sphere().draw(radius, slices, stacks);
}
public static void drawCrosses(AxisAlignedBB bb, float width, int color) {
GlStateManager.glLineWidth(width);
glColor(color);

View File

@ -15,6 +15,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.network.play.client.CPacketClientStatus;
import net.minecraft.util.math.AxisAlignedBB;
import org.lwjgl.util.glu.Sphere;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
import java.sql.Timestamp;
@ -35,12 +36,19 @@ public final class WaypointsModule extends Module {
public final Value<Integer> tracersAlpha = new Value<Integer>("TracersAlpha", new String[]{"talpha", "ta", "topacity", "top"}, "Alpha value for each drawn line.", 255, 1, 255, 1);
public final Value<Boolean> box = new Value<Boolean>("Box", new String[]{"b"}, "Renders a 3D object at each waypoint.", true);
public final Value<Shape> shape = new Value<Shape>("Shape", new String[]{"s"}, "Selects what shape should be rendered.", Shape.CUBE);
public final Value<Boolean> boxRotate = new Value<Boolean>("BoxRotate", new String[]{"brotate", "rotate", "br"}, "Rotates each 3D object around in a circle.", true);
public final Value<Float> boxRotateSpeed = new Value<Float>("BoxRotateSpeed", new String[]{"brotatespeed", "rotatespeed", "spinspeed", "brs"}, "The speed at which the 3D object rotates around.", 0.5f, 0.1f, 2.0f, 0.1f);
public final Value<Float> boxWidth = new Value<Float>("BoxWidth", new String[]{"width", "w"}, "Pixel width of the 3D objects lines.", 1f, 0.1f, 5.0f, 0.1f);
public final Value<Integer> boxAlpha = new Value<Integer>("BoxAlpha", new String[]{"balpha", "ba", "bopacity", "bop"}, "Alpha value for the 3D rendered object.", 127, 1, 255, 1);
public final Value<Float> boxSize = new Value<Float>("BoxSize", new String[]{"size", "scale", "s"}, "Size of the 3D rendered object.", 0.5f, 0.1f, 3.0f, 0.1f);
public final Value<Float> boxYOffset = new Value<Float>("BoxYOffset", new String[]{"byoffset", "byoff", "byo"}, "Y-level offset of the 3D rendered object.", 0.0f, -1.0f, 1.0f, 0.1f);
public final Value<Float> diamondYIncrease = new Value<Float>("DiamondExtraY", new String[]{"de", "dextray", "diamondy"}, "Extra height added to the top of the diamond object.", 0.5f, 0.1f, 3.0f, 0.1f);
public enum Shape {
CUBE, PYRAMID, DIAMOND, SPHERE
}
private final Minecraft mc = Minecraft.getMinecraft();
private String host = "";
@ -107,8 +115,25 @@ public final class WaypointsModule extends Module {
this.boxSize.getValue(),
this.boxSize.getValue() + this.boxYOffset.getValue(),
this.boxSize.getValue());
RenderUtil.drawFilledBox(bb, color);
RenderUtil.drawBoundingBox(bb, this.boxWidth.getValue(), color);
switch (shape.getValue()) {
case CUBE:
RenderUtil.drawFilledBox(bb, color);
RenderUtil.drawBoundingBox(bb, this.boxWidth.getValue(), color);
break;
case PYRAMID:
RenderUtil.drawFilledPyramid(bb, color);
RenderUtil.drawBoundingBoxPyramid(bb, this.boxWidth.getValue(), color);
break;
case DIAMOND:
RenderUtil.drawFilledDiamond(bb, this.boxYOffset.getValue(), this.diamondYIncrease.getValue(), color);
RenderUtil.drawBoundingBoxDiamond(bb, this.boxWidth.getValue(), this.boxYOffset.getValue(), this.diamondYIncrease.getValue(), color);
break;
case SPHERE:
RenderUtil.drawSphere(boxSize.getValue(), 32, 32, color);
break;
}
GlStateManager.popMatrix();
}
}