Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 24.89 KB | None | 0 0
  1. package me.zeroeightsix.kami.util;
  2.  
  3. import me.zeroeightsix.kami.command.Command;
  4. import net.minecraft.client.renderer.BufferBuilder;
  5. import net.minecraft.client.renderer.GlStateManager;
  6. import net.minecraft.client.renderer.Tessellator;
  7. import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
  8. import net.minecraft.util.math.BlockPos;
  9. import net.minecraft.util.math.AxisAlignedBB;
  10. import org.lwjgl.opengl.GL11;
  11.  
  12. import static org.lwjgl.opengl.GL11.*;
  13.  
  14. /**
  15.  * Created by 086 on 9/07/2017.
  16.  */
  17. public class KamiTessellator extends Tessellator {
  18.  
  19.     public static KamiTessellator INSTANCE = new KamiTessellator();
  20.  
  21.     public KamiTessellator() {
  22.         super(0x200000);
  23.     }
  24.  
  25.     public static void prepare(int mode) {
  26.         prepareGL();
  27.         begin(mode);
  28.     }
  29.  
  30.     public static void prepareGL() {
  31. //        GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
  32.         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  33.         GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
  34.         GlStateManager.glLineWidth(1.5F);
  35.         GlStateManager.disableTexture2D();
  36.         GlStateManager.depthMask(false);
  37.         GlStateManager.enableBlend();
  38.         GlStateManager.disableDepth();
  39.         GlStateManager.disableLighting();
  40.         GlStateManager.disableCull();
  41.         GlStateManager.enableAlpha();
  42.         GlStateManager.color(1,1,1);
  43.     }
  44.  
  45.     public static void begin(int mode) {
  46.         INSTANCE.getBuffer().begin(mode, DefaultVertexFormats.POSITION_COLOR);
  47.     }
  48.  
  49.     public static void release() {
  50.         render();
  51.         releaseGL();
  52.     }
  53.  
  54.     public static void render() {
  55.         INSTANCE.draw();
  56.     }
  57.  
  58.     public static void releaseGL() {
  59.         GlStateManager.enableCull();
  60.         GlStateManager.depthMask(true);
  61.         GlStateManager.enableTexture2D();
  62.         GlStateManager.enableBlend();
  63.         GlStateManager.enableDepth();
  64.     }
  65.  
  66.     public static void drawBox(BlockPos blockPos, int argb, int sides) {
  67.         final int a = (argb >>> 24) & 0xFF;
  68.         final int r = (argb >>> 16) & 0xFF;
  69.         final int g = (argb >>> 8) & 0xFF;
  70.         final int b = argb & 0xFF;
  71.         drawBox(blockPos, r, g, b, a, sides);
  72.     }
  73.  
  74.     public static void drawBox(float x, float y, float z, int argb, int sides) {
  75.         final int a = (argb >>> 24) & 0xFF;
  76.         final int r = (argb >>> 16) & 0xFF;
  77.         final int g = (argb >>> 8) & 0xFF;
  78.         final int b = argb & 0xFF;
  79.         drawBox(INSTANCE.getBuffer(), x, y, z, 1, 1, 1, r, g, b, a, sides);
  80.     }
  81.  
  82.     public static void drawBox(BlockPos blockPos, int r, int g, int b, int a, int sides) {
  83.         drawBox(INSTANCE.getBuffer(), blockPos.x, blockPos.y, blockPos.z, 1, 1, 1, r, g, b, a, sides);
  84.     }
  85.  
  86.     public static BufferBuilder getBufferBuilder() {
  87.         return INSTANCE.getBuffer();
  88.     }
  89.  
  90.     public static void drawBox(final BufferBuilder buffer, float x, float y, float z, float w, float h, float d, int r, int g, int b, int a, int sides) {
  91.         if ((sides & GeometryMasks.Quad.DOWN) != 0) {
  92.             buffer.pos(x+w, y, z).color(r, g, b, a).endVertex();
  93.             buffer.pos(x+w, y, z+d).color(r, g, b, a).endVertex();
  94.             buffer.pos(x, y, z+d).color(r, g, b, a).endVertex();
  95.             buffer.pos(x, y, z).color(r, g, b, a).endVertex();
  96.         }
  97.  
  98.         if ((sides & GeometryMasks.Quad.UP) != 0) {
  99.             buffer.pos(x+w, y+h, z).color(r, g, b, a).endVertex();
  100.             buffer.pos(x, y+h, z).color(r, g, b, a).endVertex();
  101.             buffer.pos(x, y+h, z+d).color(r, g, b, a).endVertex();
  102.             buffer.pos(x+w, y+h, z+d).color(r, g, b, a).endVertex();
  103.         }
  104.  
  105.         if ((sides & GeometryMasks.Quad.NORTH) != 0) {
  106.             buffer.pos(x+w, y, z).color(r, g, b, a).endVertex();
  107.             buffer.pos(x, y, z).color(r, g, b, a).endVertex();
  108.             buffer.pos(x, y+h, z).color(r, g, b, a).endVertex();
  109.             buffer.pos(x+w, y+h, z).color(r, g, b, a).endVertex();
  110.         }
  111.  
  112.         if ((sides & GeometryMasks.Quad.SOUTH) != 0) {
  113.             buffer.pos(x, y, z+d).color(r, g, b, a).endVertex();
  114.             buffer.pos(x+w, y, z+d).color(r, g, b, a).endVertex();
  115.             buffer.pos(x+w, y+h, z+d).color(r, g, b, a).endVertex();
  116.             buffer.pos(x, y+h, z+d).color(r, g, b, a).endVertex();
  117.         }
  118.  
  119.         if ((sides & GeometryMasks.Quad.WEST) != 0) {
  120.             buffer.pos(x, y, z).color(r, g, b, a).endVertex();
  121.             buffer.pos(x, y, z+d).color(r, g, b, a).endVertex();
  122.             buffer.pos(x, y+h, z+d).color(r, g, b, a).endVertex();
  123.             buffer.pos(x, y+h, z).color(r, g, b, a).endVertex();
  124.         }
  125.  
  126.         if ((sides & GeometryMasks.Quad.EAST) != 0) {
  127.             buffer.pos(x+w, y, z+d).color(r, g, b, a).endVertex();
  128.             buffer.pos(x+w, y, z).color(r, g, b, a).endVertex();
  129.             buffer.pos(x+w, y+h, z).color(r, g, b, a).endVertex();
  130.             buffer.pos(x+w, y+h, z+d).color(r, g, b, a).endVertex();
  131.         }
  132.     }
  133.  
  134.     public static void drawFace(BlockPos blockPos, int argb, int sides) {
  135.         final int a = (argb >>> 24) & 0xFF;
  136.         final int r = (argb >>> 16) & 0xFF;
  137.         final int g = (argb >>> 8) & 0xFF;
  138.         final int b = argb & 0xFF;
  139.         drawFace(blockPos, r, g, b, a, sides);
  140.     }
  141.  
  142.     public static void drawFace(BlockPos blockPos, int r, int g, int b, int a, int sides) {
  143.         drawFace(INSTANCE.getBuffer(), blockPos.x, blockPos.y, blockPos.z, 1, 1, 1, r, g, b, a, sides);
  144.     }
  145.  
  146.     public static void drawFace(final BufferBuilder buffer, float x, float y, float z, float w, float h, float d, int r, int g, int b, int a, int sides) {
  147.         if ((sides & GeometryMasks.Quad.DOWN) != 0) {
  148.  
  149.             buffer.pos(x+w, y, z).color(r, g, b, a).endVertex();
  150.             buffer.pos(x+w, y, z+d).color(r, g, b, a).endVertex();
  151.             buffer.pos(x, y, z+d).color(r, g, b, a).endVertex();
  152.             buffer.pos(x, y, z).color(r, g, b, a).endVertex();
  153.         }
  154.  
  155.     }
  156.  
  157.     public static void drawFaceOutline(BlockPos blockPos, int r, int g, int b, int a, int sides) {
  158.         drawFaceOutline(INSTANCE.getBuffer(), blockPos.x, blockPos.y, blockPos.z, 1, 1, 1, r, g, b, a, sides);
  159.     }
  160.  
  161.     public static void drawFaceOutline(final BufferBuilder buffer, float x, float y, float z, float w, float h, float d, int r, int g, int b, int a, int sides) {
  162.         if ((sides & GeometryMasks.Quad.DOWN) != 0) {
  163.  
  164.             buffer.pos(x+w, y, z).color(r, g, b, a).endVertex();
  165.             buffer.pos(x+w, y, z+0.02).color(r, g, b, a).endVertex();
  166.             buffer.pos(x, y, z+0.02).color(r, g, b, a).endVertex();
  167.             buffer.pos(x, y, z).color(r, g, b, a).endVertex();
  168.  
  169.             buffer.pos(x+0.02, y, z).color(r, g, b, a).endVertex();
  170.             buffer.pos(x+0.02, y, z+d).color(r, g, b, a).endVertex();
  171.             buffer.pos(x, y, z+d).color(r, g, b, a).endVertex();
  172.             buffer.pos(x, y, z).color(r, g, b, a).endVertex();
  173.  
  174.             buffer.pos(x+w, y, z+d-0.02).color(r, g, b, a).endVertex();
  175.             buffer.pos(x+w, y, z+d).color(r, g, b, a).endVertex();
  176.             buffer.pos(x, y, z+d).color(r, g, b, a).endVertex();
  177.             buffer.pos(x, y, z+d-0.02).color(r, g, b, a).endVertex();
  178.  
  179.             buffer.pos(x+w, y, z).color(r, g, b, a).endVertex();
  180.             buffer.pos(x+w, y, z+d).color(r, g, b, a).endVertex();
  181.             buffer.pos(x+w-0.02, y, z+d).color(r, g, b, a).endVertex();
  182.             buffer.pos(x+w-0.02, y, z).color(r, g, b, a).endVertex();
  183.         }
  184.  
  185.     }
  186.  
  187.     public static void drawBoxOutline(BlockPos blockPos, int argb, int sides) {
  188.         final int a = (argb >>> 24) & 0xFF;
  189.         final int r = (argb >>> 16) & 0xFF;
  190.         final int g = (argb >>> 8) & 0xFF;
  191.         final int b = argb & 0xFF;
  192.         drawBoxOutline(blockPos, r, g, b, a, sides);
  193.     }
  194.  
  195.     public static void drawBoxOutline(float x, float y, float z, int argb, int sides) {
  196.         final int a = (argb >>> 24) & 0xFF;
  197.         final int r = (argb >>> 16) & 0xFF;
  198.         final int g = (argb >>> 8) & 0xFF;
  199.         final int b = argb & 0xFF;
  200.         drawBoxOutline(INSTANCE.getBuffer(), x, y, z, 1, 1, 1, r, g, b, a, sides);
  201.     }
  202.     public static void drawBoxOutline(BlockPos blockPos, int r, int g, int b, int a, int sides) {
  203.         drawBoxOutline(INSTANCE.getBuffer(), blockPos.x, blockPos.y, blockPos.z, 1, 1, 1, r, g, b, a, sides);
  204.     }
  205.  
  206.     public static void drawBoxOutline(BufferBuilder buffer, float x, float y, float z, float w, float h, float d, int r, int g, int b, int a, int sides) {
  207.         if ((sides & GeometryMasks.Quad.DOWN) != 0) {
  208.  
  209.             buffer.pos(x+w, y, z).color(r, g, b, a).endVertex();
  210.             buffer.pos(x+w, y, z+0.02).color(r, g, b, a).endVertex();
  211.             buffer.pos(x, y, z+0.02).color(r, g, b, a).endVertex();
  212.             buffer.pos(x, y, z).color(r, g, b, a).endVertex();
  213.  
  214.             buffer.pos(x+0.02, y, z).color(r, g, b, a).endVertex();
  215.             buffer.pos(x+0.02, y, z+d).color(r, g, b, a).endVertex();
  216.             buffer.pos(x, y, z+d).color(r, g, b, a).endVertex();
  217.             buffer.pos(x, y, z).color(r, g, b, a).endVertex();
  218.  
  219.             buffer.pos(x+w, y, z+d-0.02).color(r, g, b, a).endVertex();
  220.             buffer.pos(x+w, y, z+d).color(r, g, b, a).endVertex();
  221.             buffer.pos(x, y, z+d).color(r, g, b, a).endVertex();
  222.             buffer.pos(x, y, z+d-0.02).color(r, g, b, a).endVertex();
  223.  
  224.             buffer.pos(x+w, y, z).color(r, g, b, a).endVertex();
  225.             buffer.pos(x+w, y, z+d).color(r, g, b, a).endVertex();
  226.             buffer.pos(x+w-0.02, y, z+d).color(r, g, b, a).endVertex();
  227.             buffer.pos(x+w-0.02, y, z).color(r, g, b, a).endVertex();
  228.         }
  229.     }
  230.  
  231.     public static void drawLines(BlockPos blockPos, int argb, int sides) {
  232.         final int a = (argb >>> 24) & 0xFF;
  233.         final int r = (argb >>> 16) & 0xFF;
  234.         final int g = (argb >>> 8) & 0xFF;
  235.         final int b = argb & 0xFF;
  236.         drawLines(blockPos, r, g, b, a, sides);
  237.     }
  238.  
  239.     public static void drawLines(BlockPos blockPos, int r, int g, int b, int a, int sides) {
  240.         drawLines(INSTANCE.getBuffer(), blockPos.x, blockPos.y, blockPos.z, 1, 1, 1, r, g, b, a, sides);
  241.     }
  242.  
  243.     public static void drawLines(final BufferBuilder buffer, float x, float y, float z, float w, float h, float d, int r, int g, int b, int a, int sides) {
  244.         if ((sides & GeometryMasks.Line.DOWN_WEST) != 0) {
  245.             buffer.pos(x, y, z).color(r, g, b, a).endVertex();
  246.             buffer.pos(x, y, z+d).color(r, g, b, a).endVertex();
  247.         }
  248.  
  249.         if ((sides & GeometryMasks.Line.UP_WEST) != 0) {
  250.             buffer.pos(x, y+h, z).color(r, g, b, a).endVertex();
  251.             buffer.pos(x, y+h, z+d).color(r, g, b, a).endVertex();
  252.         }
  253.  
  254.         if ((sides & GeometryMasks.Line.DOWN_EAST) != 0) {
  255.             buffer.pos(x+w, y, z).color(r, g, b, a).endVertex();
  256.             buffer.pos(x+w, y, z+d).color(r, g, b, a).endVertex();
  257.         }
  258.  
  259.         if ((sides & GeometryMasks.Line.UP_EAST) != 0) {
  260.             buffer.pos(x+w, y+h, z).color(r, g, b, a).endVertex();
  261.             buffer.pos(x+w, y+h, z+d).color(r, g, b, a).endVertex();
  262.         }
  263.  
  264.         if ((sides & GeometryMasks.Line.DOWN_NORTH) != 0) {
  265.             buffer.pos(x, y, z).color(r, g, b, a).endVertex();
  266.             buffer.pos(x+w, y, z).color(r, g, b, a).endVertex();
  267.         }
  268.  
  269.         if ((sides & GeometryMasks.Line.UP_NORTH) != 0) {
  270.             buffer.pos(x, y+h, z).color(r, g, b, a).endVertex();
  271.             buffer.pos(x+w, y+h, z).color(r, g, b, a).endVertex();
  272.         }
  273.  
  274.         if ((sides & GeometryMasks.Line.DOWN_SOUTH) != 0) {
  275.             buffer.pos(x, y, z+d).color(r, g, b, a).endVertex();
  276.             buffer.pos(x+w, y, z+d).color(r, g, b, a).endVertex();
  277.         }
  278.  
  279.         if ((sides & GeometryMasks.Line.UP_SOUTH) != 0) {
  280.             buffer.pos(x, y+h, z+d).color(r, g, b, a).endVertex();
  281.             buffer.pos(x+w, y+h, z+d).color(r, g, b, a).endVertex();
  282.         }
  283.  
  284.         if ((sides & GeometryMasks.Line.NORTH_WEST) != 0) {
  285.             buffer.pos(x, y, z).color(r, g, b, a).endVertex();
  286.             buffer.pos(x, y+h, z).color(r, g, b, a).endVertex();
  287.         }
  288.  
  289.         if ((sides & GeometryMasks.Line.NORTH_EAST) != 0) {
  290.             buffer.pos(x+w, y, z).color(r, g, b, a).endVertex();
  291.             buffer.pos(x+w, y+h, z).color(r, g, b, a).endVertex();
  292.         }
  293.  
  294.         if ((sides & GeometryMasks.Line.SOUTH_WEST) != 0) {
  295.             buffer.pos(x, y, z+d).color(r, g, b, a).endVertex();
  296.             buffer.pos(x, y+h, z+d).color(r, g, b, a).endVertex();
  297.         }
  298.  
  299.         if ((sides & GeometryMasks.Line.SOUTH_EAST) != 0) {
  300.             buffer.pos(x+w, y, z+d).color(r, g, b, a).endVertex();
  301.             buffer.pos(x+w, y+h, z+d).color(r, g, b, a).endVertex();
  302.         }
  303.     }
  304.     public static void drawBox2(AxisAlignedBB bb, int r, int g, int b, int a, int sides) {
  305.         final Tessellator tessellator = Tessellator.getInstance();
  306.         final BufferBuilder bufferBuilder = tessellator.getBuffer();
  307.         bufferBuilder.begin(GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
  308.         if ((sides & GeometryMasks.Quad.DOWN) != 0) {
  309.             bufferBuilder.pos(bb.maxX, bb.minY, bb.minZ).color(r, g, b, a).endVertex();
  310.             bufferBuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(r, g, b, a).endVertex();
  311.             bufferBuilder.pos(bb.minX, bb.minY, bb.maxZ).color(r, g, b, a).endVertex();
  312.             bufferBuilder.pos(bb.minX, bb.minY, bb.minZ).color(r, g, b, a).endVertex();
  313.         }
  314.  
  315.         if ((sides & GeometryMasks.Quad.UP) != 0) {
  316.             bufferBuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(r, g, b, a).endVertex();
  317.             bufferBuilder.pos(bb.minX, bb.maxY, bb.minZ).color(r, g, b, a).endVertex();
  318.             bufferBuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(r, g, b, a).endVertex();
  319.             bufferBuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(r, g, b, a).endVertex();
  320.         }
  321.  
  322.         if ((sides & GeometryMasks.Quad.NORTH) != 0) {
  323.             bufferBuilder.pos(bb.maxX, bb.minY, bb.minZ).color(r, g, b, a).endVertex();
  324.             bufferBuilder.pos(bb.minX, bb.minY, bb.minZ).color(r, g, b, a).endVertex();
  325.             bufferBuilder.pos(bb.minX, bb.maxY, bb.minZ).color(r, g, b, a).endVertex();
  326.             bufferBuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(r, g, b, a).endVertex();
  327.         }
  328.  
  329.         if ((sides & GeometryMasks.Quad.SOUTH) != 0) {
  330.             bufferBuilder.pos(bb.minX, bb.minY, bb.maxZ).color(r, g, b, a).endVertex();
  331.             bufferBuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(r, g, b, a).endVertex();
  332.             bufferBuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(r, g, b, a).endVertex();
  333.             bufferBuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(r, g, b, a).endVertex();
  334.         }
  335.  
  336.         if ((sides & GeometryMasks.Quad.WEST) != 0) {
  337.             bufferBuilder.pos(bb.minX, bb.minY, bb.minZ).color(r, g, b, a).endVertex();
  338.             bufferBuilder.pos(bb.minX, bb.minY, bb.maxZ).color(r, g, b, a).endVertex();
  339.             bufferBuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(r, g, b, a).endVertex();
  340.             bufferBuilder.pos(bb.minX, bb.maxY, bb.minZ).color(r, g, b, a).endVertex();
  341.         }
  342.  
  343.         if ((sides & GeometryMasks.Quad.EAST) != 0) {
  344.             bufferBuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(r, g, b, a).endVertex();
  345.             bufferBuilder.pos(bb.maxX, bb.minY, bb.minZ).color(r, g, b, a).endVertex();
  346.             bufferBuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(r, g, b, a).endVertex();
  347.             bufferBuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(r, g, b, a).endVertex();
  348.         }
  349.         tessellator.draw();
  350.     }
  351.     public static void drawFullBox2(AxisAlignedBB bb, BlockPos blockPos, float width, int argb) {
  352.         final int a = (argb >>> 24) & 0xFF;
  353.         final int r = (argb >>> 16) & 0xFF;
  354.         final int g = (argb >>> 8) & 0xFF;
  355.         final int b = argb & 0xFF;
  356.         drawFullBox2(bb, blockPos, width, r, g, b, a);
  357.     }
  358.  
  359.     public static void drawFullBox2(AxisAlignedBB bb, BlockPos blockPos, float width, int red, int green, int blue, int alpha) {
  360.         KamiTessellator.prepare(GL11.GL_QUADS);
  361.         drawBox2(bb, red, green, blue, alpha, GeometryMasks.Quad.ALL);
  362.         KamiTessellator.release();
  363.         drawBoundingBox(bb, width, red, green, blue, 255);
  364.     }
  365.     public static void drawFullBox(AxisAlignedBB bb, BlockPos blockPos, float width, int argb, int alpha2) {
  366.         final int a = (argb >>> 24) & 0xFF;
  367.         final int r = (argb >>> 16) & 0xFF;
  368.         final int g = (argb >>> 8) & 0xFF;
  369.         final int b = argb & 0xFF;
  370.         drawFullBox(bb, blockPos, width, r, g, b, a, alpha2);
  371.     }
  372.  
  373.     public static void drawFullBox(AxisAlignedBB bb, BlockPos blockPos, float width, int red, int green, int blue, int alpha, int alpha2) {
  374.         KamiTessellator.prepare(GL11.GL_QUADS);
  375.         drawBox(blockPos, red, green, blue, alpha, GeometryMasks.Quad.ALL);
  376.         KamiTessellator.release();
  377.         drawBoundingBox(bb, width, red, green, blue, alpha2);
  378.     }
  379.     public static void drawFullFace(AxisAlignedBB bb, BlockPos blockPos, float width, int argb, int alpha2) {
  380.         final int a = (argb >>> 24) & 0xFF;
  381.         final int r = (argb >>> 16) & 0xFF;
  382.         final int g = (argb >>> 8) & 0xFF;
  383.         final int b = argb & 0xFF;
  384.         drawFullFace(bb, blockPos, width, r, g, b, a, alpha2);
  385.     }
  386.  
  387.     public static void drawFullFace(AxisAlignedBB bb, BlockPos blockPos, float width, int red, int green, int blue, int alpha, int alpha2) {
  388.         KamiTessellator.prepare(GL11.GL_QUADS);
  389.         drawFace(blockPos, red, green, blue, alpha, GeometryMasks.Quad.ALL);
  390.         KamiTessellator.release();
  391.         drawBoundingBoxFace(bb, width, red, green, blue, alpha2);
  392.     }
  393.     public static void drawBoundingBox(AxisAlignedBB bb, float width, int argb) {
  394.         final int a = (argb >>> 24) & 0xFF;
  395.         final int r = (argb >>> 16) & 0xFF;
  396.         final int g = (argb >>> 8) & 0xFF;
  397.         final int b = argb & 0xFF;
  398.         drawBoundingBox(bb, width, r, g, b, a);
  399.     }
  400.     public static void drawBoundingBox(AxisAlignedBB bb, float width, int red, int green, int blue, int alpha) {
  401.         GlStateManager.pushMatrix();
  402.         GlStateManager.enableBlend();
  403.         GlStateManager.disableDepth();
  404.         GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1);
  405.         GlStateManager.disableTexture2D();
  406.         GlStateManager.depthMask(false);
  407.         glEnable(GL_LINE_SMOOTH);
  408.         glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
  409.         glLineWidth(width);
  410.  
  411.         //final float alpha = (color >> 24 & 0xFF) / 255.0F;
  412.         //final float red = (color >> 16 & 0xFF) / 255.0F;
  413.         //final float green = (color >> 8 & 0xFF) / 255.0F;
  414.         //final float blue = (color & 0xFF) / 255.0F;
  415.  
  416.         final Tessellator tessellator = Tessellator.getInstance();
  417.         final BufferBuilder bufferbuilder = tessellator.getBuffer();
  418.  
  419.  
  420.         //bottom
  421.         bufferbuilder.begin(GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR);
  422.         bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  423.         bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  424.         bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  425.         bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  426.         bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  427.  
  428.         bufferbuilder.pos(bb.minX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
  429.         bufferbuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  430.         bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  431.         bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  432.         bufferbuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  433.         bufferbuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  434.         bufferbuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  435.         bufferbuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
  436.         bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  437.         bufferbuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
  438.         bufferbuilder.pos(bb.minX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
  439.         /*
  440.         bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  441.         bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  442.         bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  443.         bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  444.         bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  445.         bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  446.         bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  447.         bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  448.         //top
  449.         bufferbuilder.pos(bb.minX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
  450.         bufferbuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  451.         bufferbuilder.pos(bb.minX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
  452.         bufferbuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
  453.         bufferbuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
  454.         bufferbuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  455.         bufferbuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  456.         bufferbuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  457.         //four lines
  458.         bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  459.         bufferbuilder.pos(bb.minX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
  460.         bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  461.         bufferbuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
  462.         bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  463.         bufferbuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  464.         bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  465.         bufferbuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  466.         */
  467.  
  468.  
  469.         tessellator.draw();
  470.         glDisable(GL_LINE_SMOOTH);
  471.         GlStateManager.depthMask(true);
  472.         GlStateManager.enableDepth();
  473.         GlStateManager.enableTexture2D();
  474.         GlStateManager.disableBlend();
  475.         GlStateManager.popMatrix();
  476.     }
  477.  
  478.     public static void drawBoundingBoxFace(AxisAlignedBB bb, float width, int red, int green, int blue, int alpha) {
  479.         GlStateManager.pushMatrix();
  480.         GlStateManager.enableBlend();
  481.         GlStateManager.disableDepth();
  482.         GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1);
  483.         GlStateManager.disableTexture2D();
  484.         GlStateManager.depthMask(false);
  485.         glEnable(GL_LINE_SMOOTH);
  486.         glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
  487.         glLineWidth(width);
  488.  
  489.         //final float alpha = (color >> 24 & 0xFF) / 255.0F;
  490.         //final float red = (color >> 16 & 0xFF) / 255.0F;
  491.         //final float green = (color >> 8 & 0xFF) / 255.0F;
  492.         //final float blue = (color & 0xFF) / 255.0F;
  493.  
  494.         final Tessellator tessellator = Tessellator.getInstance();
  495.         final BufferBuilder bufferbuilder = tessellator.getBuffer();
  496.  
  497.         bufferbuilder.begin(GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR);
  498.         bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  499.         bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  500.         bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  501.         bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  502.         bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  503.  
  504.         tessellator.draw();
  505.         glDisable(GL_LINE_SMOOTH);
  506.         GlStateManager.depthMask(true);
  507.         GlStateManager.enableDepth();
  508.         GlStateManager.enableTexture2D();
  509.         GlStateManager.disableBlend();
  510.         GlStateManager.popMatrix();
  511.     }
  512.  
  513. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement