From 70c1354a4a96698758a88c032866288f79de6f5a Mon Sep 17 00:00:00 2001 From: Benjamin Culkin Date: Sat, 24 Aug 2024 08:16:37 -0400 Subject: Initial commit --- .../jp/plusplus/fbs/render/TessellatorWrapper.java | 168 +++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 src/main/java/jp/plusplus/fbs/render/TessellatorWrapper.java (limited to 'src/main/java/jp/plusplus/fbs/render/TessellatorWrapper.java') diff --git a/src/main/java/jp/plusplus/fbs/render/TessellatorWrapper.java b/src/main/java/jp/plusplus/fbs/render/TessellatorWrapper.java new file mode 100644 index 0000000..c9937e4 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/render/TessellatorWrapper.java @@ -0,0 +1,168 @@ +package jp.plusplus.fbs.render; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; + +/** + * Created by plusplus_F on 2015/06/28. + * なんで!!!てってれーたーには!!!!面描画メソッドが!!!!用意されてないんですか!!!!!1111 + */ +public class TessellatorWrapper { + private static Tessellator tessellator=Tessellator.instance; + private static boolean isBlockRender; + + public static void SetBlockRender(boolean flag){ + isBlockRender=flag; + } + + public static void DrawXPos(float bx, float by, float bz, float my, float mz, IIcon icon){ + float minU=icon.getInterpolatedU(16*bz); + float maxU=icon.getInterpolatedU(16*mz); + float minV=icon.getInterpolatedV(16*my); + float maxV=icon.getInterpolatedV(16*by); + + if(isBlockRender){ + tessellator.setNormal(1.0f, 0.0f, 0.0f); + tessellator.addVertexWithUV(bx, my, bz, minU, minV); + tessellator.addVertexWithUV(bx, my, mz, maxU, minV); + tessellator.addVertexWithUV(bx, by, mz, maxU, maxV); + tessellator.addVertexWithUV(bx, by, bz, minU, maxV); + } + else{ + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0f, 0.0f, 0.0f); + tessellator.addVertexWithUV(bx, my, bz, minU, minV); + tessellator.addVertexWithUV(bx, my, mz, maxU, minV); + tessellator.addVertexWithUV(bx, by, mz, maxU, maxV); + tessellator.addVertexWithUV(bx, by, bz, minU, maxV); + tessellator.draw(); + } + } + public static void DrawXNeg(float bx, float by, float bz, float my, float mz, IIcon icon){ + float minU=icon.getInterpolatedU(16 * bz); + float maxU=icon.getInterpolatedU(16 * mz); + float minV=icon.getInterpolatedV(16 * my); + float maxV=icon.getInterpolatedV(16 * by); + + if(isBlockRender){ + tessellator.setNormal(-1.0f, 0.0f, 0.0f); + tessellator.addVertexWithUV(bx, my, bz, minU, minV); + tessellator.addVertexWithUV(bx, by, bz, minU, maxV); + tessellator.addVertexWithUV(bx, by, mz, maxU, maxV); + tessellator.addVertexWithUV(bx, my, mz, maxU, minV); + } + else{ + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0f, 0.0f, 0.0f); + tessellator.addVertexWithUV(bx, my, bz, minU, minV); + tessellator.addVertexWithUV(bx, by, bz, minU, maxV); + tessellator.addVertexWithUV(bx, by, mz, maxU, maxV); + tessellator.addVertexWithUV(bx, my, mz, maxU, minV); + tessellator.draw(); + } + } + + public static void DrawYPos(float bx, float by, float bz, float mx, float mz, IIcon icon){ + float minU=icon.getInterpolatedU(16 * bx); + float maxU=icon.getInterpolatedU(16 * mx); + float minV=icon.getInterpolatedV(16 * bz); + float maxV=icon.getInterpolatedV(16 * mz); + + if(isBlockRender){ + tessellator.setNormal(0.0f, 1.0f, 0.0f); + tessellator.addVertexWithUV(bx, by, bz, minU, minV); + tessellator.addVertexWithUV(bx, by, mz, minU, maxV); + tessellator.addVertexWithUV(mx, by, mz, maxU, maxV); + tessellator.addVertexWithUV(mx, by, bz, maxU, minV); + } + else{ + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0f, 1.0f, 0.0f); + tessellator.addVertexWithUV(bx, by, bz, minU, minV); + tessellator.addVertexWithUV(bx, by, mz, minU, maxV); + tessellator.addVertexWithUV(mx, by, mz, maxU, maxV); + tessellator.addVertexWithUV(mx, by, bz, maxU, minV); + tessellator.draw(); + } + } + public static void DrawYNeg(float bx, float by, float bz, float mx, float mz, IIcon icon){ + float minU=icon.getInterpolatedU(16 * bx); + float maxU=icon.getInterpolatedU(16 * mx); + float minV=icon.getInterpolatedV(16 * bz); + float maxV=icon.getInterpolatedV(16 * mz); + + if(isBlockRender){ + tessellator.setNormal(0.0f,-1.0f,0.0f); + tessellator.addVertexWithUV(bx, by, bz, minU, minV); + tessellator.addVertexWithUV(mx, by, bz, maxU, minV); + tessellator.addVertexWithUV(mx, by, mz, maxU, maxV); + tessellator.addVertexWithUV(bx, by, mz, minU, maxV); + } + else{ + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0f,-1.0f,0.0f); + tessellator.addVertexWithUV(bx, by, bz, minU, minV); + tessellator.addVertexWithUV(mx, by, bz, maxU, minV); + tessellator.addVertexWithUV(mx, by, mz, maxU, maxV); + tessellator.addVertexWithUV(bx, by, mz, minU, maxV); + tessellator.draw(); + } + } + + public static void DrawZPos(float bx, float by, float bz, float mx, float my, IIcon icon){ + float minU=icon.getInterpolatedU(16 * bx); + float maxU=icon.getInterpolatedU(16 * mx); + float minV=icon.getInterpolatedV(16 * by); + float maxV=icon.getInterpolatedV(16 * my); + + if(isBlockRender){ + tessellator.setNormal(0.0f,0.0f,1.0f); + tessellator.addVertexWithUV(bx, by, bz, minU, minV); + tessellator.addVertexWithUV(mx, by, bz, maxU, minV); + tessellator.addVertexWithUV(mx, my, bz, maxU, maxV); + tessellator.addVertexWithUV(bx, my, bz, minU, maxV); + } + else{ + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0f,0.0f,1.0f); + tessellator.addVertexWithUV(bx, by, bz, minU, minV); + tessellator.addVertexWithUV(mx, by, bz, maxU, minV); + tessellator.addVertexWithUV(mx, my, bz, maxU, maxV); + tessellator.addVertexWithUV(bx, my, bz, minU, maxV); + tessellator.draw(); + } + } + public static void DrawZNeg(float bx, float by, float bz, float mx, float my, IIcon icon){ + float minU=icon.getInterpolatedU(16*bx); + float maxU=icon.getInterpolatedU(16*mx); + float minV=icon.getInterpolatedV(16 * by); + float maxV=icon.getInterpolatedV(16*my); + + if(isBlockRender){ + tessellator.setNormal(0.0f, 0.0f, -1.0f); + tessellator.addVertexWithUV(bx, by, bz, minU, minV); + tessellator.addVertexWithUV(bx, my, bz, minU, maxV); + tessellator.addVertexWithUV(mx, my, bz, maxU, maxV); + tessellator.addVertexWithUV(mx, by, bz, maxU, minV); + } + else{ + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0f, 0.0f, -1.0f); + tessellator.addVertexWithUV(bx, by, bz, minU, minV); + tessellator.addVertexWithUV(bx, my, bz, minU, maxV); + tessellator.addVertexWithUV(mx, my, bz, maxU, maxV); + tessellator.addVertexWithUV(mx, by, bz, maxU, minV); + tessellator.draw(); + } + } + + public static void DrawAllFaces(float bx, float by, float bz, float mx, float my, float mz, IIcon icon) { + DrawYNeg(bx, by, bz, mx, mz, icon); + DrawYPos(bx, my, bz, mx, mz, icon); + DrawZNeg(bx, by, bz, mx, my, icon); + DrawZPos(bx, by, mz, mx, my, icon); + DrawXNeg(bx, by, bz, my, mz, icon); + DrawXPos(mx, by, bz, my, mz, icon); + } + +} -- cgit v1.2.3