diff --git a/src/main/java/com/hbm/render/block/ct/IconCT.java b/src/main/java/com/hbm/render/block/ct/IconCT.java new file mode 100644 index 000000000..d9221ce54 --- /dev/null +++ b/src/main/java/com/hbm/render/block/ct/IconCT.java @@ -0,0 +1,99 @@ +package com.hbm.render.block.ct; + +import net.minecraft.util.IIcon; + +public class IconCT implements IIcon { + + + public static final int l = 0; //left + public static final int r = 1; //right + public static final int t = 0; //top + public static final int b = 2; //bottom + public static final int f = 0; //full + public static final int c = 4; //connected + public static final int j = 8; //junction + public static final int h = 12; //horizontal + public static final int v = 16; //vertical + + public static final int ftl = 0; + public static final int ftr = 1; + public static final int fbl = 2; + public static final int fbr = 3; + public static final int ctl = 4; + public static final int ctr = 5; + public static final int cbl = 6; + public static final int cbr = 7; + public static final int jtl = 8; + public static final int jtr = 9; + public static final int jbl = 10; + public static final int jbr = 11; + public static final int htl = 12; + public static final int htr = 13; + public static final int hbl = 14; + public static final int hbr = 15; + public static final int vtl = 16; + public static final int vtr = 17; + public static final int vbl = 18; + public static final int vbr = 19; + + private IIcon parent; + private int type; + private float minU; + private float maxU; + private float minV; + private float maxV; + + + public IconCT(IIcon parent, int type) { + this.parent = parent; + this.type = type; + + int sub = ((type & f) != 0) ? 2 : 4; + } + + @Override + public int getIconWidth() { + return this.parent.getIconWidth(); + } + + @Override + public int getIconHeight() { + return this.parent.getIconHeight(); + } + + @Override + public float getMinU() { + return 0; + } + + @Override + public float getMaxU() { + return 0; + } + + @Override + public float getMinV() { + return this.minV; + } + + @Override + public float getMaxV() { + return this.maxV; + } + + @Override + public float getInterpolatedU(double interp) { + return 0; + } + + @Override + public float getInterpolatedV(double interp) { + return 0; + } + + @Override + public String getIconName() { + return this.parent.getIconName() + "_" + type; + } + +} diff --git a/src/main/java/com/hbm/render/block/ct/RenderBlocksCT.java b/src/main/java/com/hbm/render/block/ct/RenderBlocksCT.java new file mode 100644 index 000000000..916e750f9 --- /dev/null +++ b/src/main/java/com/hbm/render/block/ct/RenderBlocksCT.java @@ -0,0 +1,101 @@ +package com.hbm.render.block.ct; + +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; + +public class RenderBlocksCT extends RenderBlocks { + + VertInfo tl; + VertInfo tc; + VertInfo tr; + VertInfo cl; + VertInfo cc; + VertInfo cr; + VertInfo bl; + VertInfo bc; + VertInfo br; + + Tessellator tess; + + public RenderBlocksCT() { + super(); + this.tess = Tessellator.instance; + } + + private void initSideInfo() { + + if(!this.enableAO) + return; + + this.tl = new VertInfo(this.colorRedTopLeft, this.colorGreenTopLeft, this.colorBlueTopLeft, this.brightnessTopLeft); + this.tr = new VertInfo(this.colorRedTopRight, this.colorGreenTopRight, this.colorBlueTopRight, this.brightnessTopRight); + this.bl = new VertInfo(this.colorRedBottomLeft, this.colorGreenBottomLeft, this.colorBlueBottomLeft, this.brightnessBottomLeft); + this.br = new VertInfo(this.colorRedBottomRight, this.colorGreenBottomRight, this.colorBlueBottomRight, this.brightnessBottomRight); + + this.tc = VertInfo.avg(tl, tr); + this.bc = VertInfo.avg(bl, br); + this.cl = VertInfo.avg(tl, bl); + this.cr = VertInfo.avg(tr, br); + + this.cc = VertInfo.avg(tl, tr, bl, br); + } + + private void drawFace(double[] ftl, double[] ftr, double[] fbl, double[] fbr) { + + double[] ftc = avgCoords(ftl, ftr); + ///TODO/// + } + + private void drawVert(double x, double y, double z, double u, double v, VertInfo info) { + + if(this.enableAO) { + tess.setColorOpaque_F(info.red, info.blue, info.green); + tess.setBrightness(info.brightness); + } + + tess.addVertexWithUV(x, y, z, u, v); + } + + private double[] avgCoords(double[] first, double[] second) { + return new double[] { + (first[0] + second[0]) / 2, + (first[1] + second[1]) / 2, + (first[2] + second[2]) / 2 + }; + } + + public static class VertInfo { + float red; + float green; + float blue; + int brightness; + + public VertInfo(float red, float green, float blue, int brightness) { + this.red = red; + this.green = green; + this.blue = blue; + this.brightness = brightness; + } + + public static VertInfo avg(VertInfo...infos) { + float r = 0F; + float g = 0F; + float b = 0F; + int l = 0; + + for(VertInfo vert : infos) { + r += vert.red; + g += vert.green; + b += vert.blue; + l += vert.brightness; + } + + r /= infos.length; + g /= infos.length; + b /= infos.length; + l /= infos.length; + + return new VertInfo(r, g, b, l); + } + } +} diff --git a/src/main/resources/assets/hbm/textures/blocks/test_ct.png b/src/main/resources/assets/hbm/textures/blocks/test_ct.png new file mode 100644 index 000000000..3efc3f85c Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/test_ct.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/test_ct_ct.png b/src/main/resources/assets/hbm/textures/blocks/test_ct_ct.png new file mode 100644 index 000000000..3ebf39fc3 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/test_ct_ct.png differ