mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-25 14:44:35 +00:00
Get rid of the ugly RenderBlocksCTMFullbright, some other refactors
This commit is contained in:
1 parent
3ae753ebc3
commit
2f6b455514
20 files changed
+215
-534
No files matched your search
@@ -23,7 +23,7 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
* ZERO is a special case, it is the absolute min point of the block. X, Y, Z, or any combination means that the axes listed in the name are at 1. X, Y, Z, or any combination followed by HALF
|
||||
* means that those axes are at 0.5. X, Y, Z, or any combination after a HALF means those axes are at 1.
|
||||
*/
|
||||
enum Vert {
|
||||
protected enum Vert {
|
||||
// @formatter:off
|
||||
ZERO(0, 0, 0),
|
||||
XYZ(1, 1, 1),
|
||||
@@ -108,7 +108,7 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
*
|
||||
* Each sub-side contains 4 {@link Vert} objects representing its position on the block.
|
||||
*/
|
||||
enum SubSide {
|
||||
protected enum SubSide {
|
||||
// @formatter:off
|
||||
XNEG_LB(ZERO, Z_HALF, YZ_HALF, Y_HALF), XNEG_RB(Z_HALF, Z, Y_HALF_Z, YZ_HALF), XNEG_RT(YZ_HALF, Y_HALF_Z, YZ, Z_HALF_Y), XNEG_LT(Y_HALF, YZ_HALF, Z_HALF_Y, Y),
|
||||
XPOS_LB(XZ, Z_HALF_X, YZ_HALF_X, Y_HALF_XZ), XPOS_RB(Z_HALF_X, X, Y_HALF_X, YZ_HALF_X), XPOS_RT(YZ_HALF_X, Y_HALF_X, XY, Z_HALF_XY), XPOS_LT(Y_HALF_XZ, YZ_HALF_X, Z_HALF_XY, XYZ),
|
||||
@@ -152,38 +152,39 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
}
|
||||
}
|
||||
|
||||
private static CTM ctm = CTM.getInstance();
|
||||
protected static CTM ctm = CTM.getInstance();
|
||||
|
||||
// globals added to save the JVM some trouble. No need to constantly create
|
||||
// and destroy ints if we don't have to
|
||||
int blockLightBitChannel = 0;
|
||||
int redBitChannel = 0;
|
||||
int greenBitChannel = 0;
|
||||
int blueBitChannel = 0;
|
||||
int sunlightBitChannel = 0;
|
||||
protected int blockLightBitChannel = 0;
|
||||
protected int redBitChannel = 0;
|
||||
protected int greenBitChannel = 0;
|
||||
protected int blueBitChannel = 0;
|
||||
protected int sunlightBitChannel = 0;
|
||||
|
||||
public RenderBlocksCTM() {
|
||||
super();
|
||||
renderMaxX = renderMaxY = renderMaxZ = 1;
|
||||
}
|
||||
|
||||
Tessellator tessellator;
|
||||
double minU, maxU;
|
||||
double minV, maxV;
|
||||
int[] lightingCache = new int[4];
|
||||
float[] redCache = new float[4];
|
||||
float[] grnCache = new float[4];
|
||||
float[] bluCache = new float[4];
|
||||
protected Tessellator tessellator;
|
||||
protected double minU, maxU;
|
||||
protected double minV, maxV;
|
||||
protected int[] lightingCache = new int[4];
|
||||
protected float[] redCache = new float[4];
|
||||
protected float[] grnCache = new float[4];
|
||||
protected float[] bluCache = new float[4];
|
||||
public TextureSubmap submap;
|
||||
public TextureSubmap submapSmall;
|
||||
public RenderBlocks rendererOld;
|
||||
public ISubmapManager<RenderBlocksCTM> manager;
|
||||
|
||||
int[][] lightmap = new int[3][3];
|
||||
float[][] redmap = new float[3][3];
|
||||
float[][] grnmap = new float[3][3];
|
||||
float[][] blumap = new float[3][3];
|
||||
protected int[][] lightmap = new int[3][3];
|
||||
protected float[][] redmap = new float[3][3];
|
||||
protected float[][] grnmap = new float[3][3];
|
||||
protected float[][] blumap = new float[3][3];
|
||||
|
||||
int bx, by, bz;
|
||||
protected int bx, by, bz;
|
||||
|
||||
@Override
|
||||
public boolean renderStandardBlock(Block block, int x, int y, int z) {
|
||||
@@ -220,7 +221,7 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
* shakes fist in anger
|
||||
*/
|
||||
// @formatter:on
|
||||
void fillLightmap(int bottomLeft, int bottomRight, int topRight, int topLeft) {
|
||||
protected void fillLightmap(int bottomLeft, int bottomRight, int topRight, int topLeft) {
|
||||
lightmap[0][0] = bottomLeft;
|
||||
lightmap[2][0] = bottomRight;
|
||||
lightmap[2][2] = topRight;
|
||||
@@ -234,7 +235,7 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
lightmap[1][1] = avg(bottomLeft, bottomRight, topRight, topLeft);
|
||||
}
|
||||
|
||||
void fillColormap(float bottomLeft, float bottomRight, float topRight, float topLeft, float[][] map) {
|
||||
protected void fillColormap(float bottomLeft, float bottomRight, float topRight, float topLeft, float[][] map) {
|
||||
map[0][0] = bottomLeft;
|
||||
map[2][0] = bottomRight;
|
||||
map[2][2] = topRight;
|
||||
@@ -248,7 +249,7 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
map[1][1] = (bottomLeft + bottomRight + topRight + topLeft) / 4.0F;
|
||||
}
|
||||
|
||||
void getLight(int x, int y) {
|
||||
protected void getLight(int x, int y) {
|
||||
lightingCache[0] = lightmap[0 + x][0 + y];
|
||||
lightingCache[1] = lightmap[1 + x][0 + y];
|
||||
lightingCache[2] = lightmap[1 + x][1 + y];
|
||||
@@ -273,7 +274,7 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
/**
|
||||
* This works around a bug in CLC atm
|
||||
*/
|
||||
int avg(int... lightVals) {
|
||||
private int avg(int... lightVals) {
|
||||
blockLightBitChannel = 0;
|
||||
redBitChannel = 0;
|
||||
greenBitChannel = 0;
|
||||
@@ -292,7 +293,7 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
| ((blueBitChannel / lightVals.length) & 0xF0000) | ((sunlightBitChannel / lightVals.length) & 0xF00000);
|
||||
}
|
||||
|
||||
void side(SubSide side, int iconIndex) {
|
||||
protected void side(SubSide side, int iconIndex) {
|
||||
|
||||
IIcon icon;
|
||||
TextureSubmap map;
|
||||
@@ -341,13 +342,13 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 4);
|
||||
|
||||
pre(ForgeDirection.WEST);
|
||||
|
||||
fillLightmap(brightnessBottomRight, brightnessTopRight, brightnessTopLeft, brightnessBottomLeft);
|
||||
fillColormap(colorRedBottomRight, colorRedTopRight, colorRedTopLeft, colorRedBottomLeft, redmap);
|
||||
fillColormap(colorGreenBottomRight, colorGreenTopRight, colorGreenTopLeft, colorGreenBottomLeft, grnmap);
|
||||
fillColormap(colorBlueBottomRight, colorBlueTopRight, colorBlueTopLeft, colorBlueBottomLeft, blumap);
|
||||
|
||||
pre(ForgeDirection.WEST);
|
||||
|
||||
getLight(0, 0);
|
||||
side(XNEG_LB, tex[0]);
|
||||
getLight(1, 0);
|
||||
@@ -373,13 +374,13 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 5);
|
||||
|
||||
pre(ForgeDirection.EAST);
|
||||
|
||||
fillLightmap(brightnessTopLeft, brightnessBottomLeft, brightnessBottomRight, brightnessTopRight);
|
||||
fillColormap(colorRedTopLeft, colorRedBottomLeft, colorRedBottomRight, colorRedTopRight, redmap);
|
||||
fillColormap(colorGreenTopLeft, colorGreenBottomLeft, colorGreenBottomRight, colorGreenTopRight, grnmap);
|
||||
fillColormap(colorBlueTopLeft, colorBlueBottomLeft, colorBlueBottomRight, colorBlueTopRight, blumap);
|
||||
|
||||
pre(ForgeDirection.EAST);
|
||||
|
||||
|
||||
getLight(0, 0);
|
||||
side(XPOS_LB, tex[0]);
|
||||
getLight(1, 0);
|
||||
@@ -391,7 +392,6 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
|
||||
post(ForgeDirection.EAST);
|
||||
}
|
||||
rendererOld.clearOverrideBlockTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -406,13 +406,13 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 2);
|
||||
|
||||
pre(ForgeDirection.NORTH);
|
||||
|
||||
fillLightmap(brightnessBottomRight, brightnessTopRight, brightnessTopLeft, brightnessBottomLeft);
|
||||
fillColormap(colorRedBottomRight, colorRedTopRight, colorRedTopLeft, colorRedBottomLeft, redmap);
|
||||
fillColormap(colorGreenBottomRight, colorGreenTopRight, colorGreenTopLeft, colorGreenBottomLeft, grnmap);
|
||||
fillColormap(colorBlueBottomRight, colorBlueTopRight, colorBlueTopLeft, colorBlueBottomLeft, blumap);
|
||||
|
||||
pre(ForgeDirection.NORTH);
|
||||
|
||||
getLight(0, 0);
|
||||
side(ZNEG_LB, tex[0]);
|
||||
getLight(1, 0);
|
||||
@@ -424,7 +424,6 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
|
||||
post(ForgeDirection.NORTH);
|
||||
}
|
||||
rendererOld.clearOverrideBlockTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -439,12 +438,12 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 3);
|
||||
|
||||
pre(ForgeDirection.SOUTH);
|
||||
|
||||
fillLightmap(brightnessBottomLeft, brightnessBottomRight, brightnessTopRight, brightnessTopLeft);
|
||||
fillColormap(colorRedBottomLeft, colorRedBottomRight, colorRedTopRight, colorRedTopLeft, redmap);
|
||||
fillColormap(colorGreenBottomLeft, colorGreenBottomRight, colorGreenTopRight, colorGreenTopLeft, grnmap);
|
||||
fillColormap(colorBlueBottomLeft, colorBlueBottomRight, colorBlueTopRight, colorBlueTopLeft, blumap);
|
||||
|
||||
pre(ForgeDirection.SOUTH);
|
||||
|
||||
getLight(0, 0);
|
||||
side(ZPOS_LB, tex[0]);
|
||||
@@ -457,7 +456,6 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
|
||||
post(ForgeDirection.SOUTH);
|
||||
}
|
||||
rendererOld.clearOverrideBlockTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -472,13 +470,13 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 0);
|
||||
|
||||
pre(ForgeDirection.DOWN);
|
||||
|
||||
fillLightmap(brightnessBottomLeft, brightnessBottomRight, brightnessTopRight, brightnessTopLeft);
|
||||
fillColormap(colorRedBottomLeft, colorRedBottomRight, colorRedTopRight, colorRedTopLeft, redmap);
|
||||
fillColormap(colorGreenBottomLeft, colorGreenBottomRight, colorGreenTopRight, colorGreenTopLeft, grnmap);
|
||||
fillColormap(colorBlueBottomLeft, colorBlueBottomRight, colorBlueTopRight, colorBlueTopLeft, blumap);
|
||||
|
||||
pre(ForgeDirection.DOWN);
|
||||
|
||||
|
||||
getLight(0, 0);
|
||||
side(YNEG_LB, tex[0]);
|
||||
getLight(1, 0);
|
||||
@@ -490,7 +488,6 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
|
||||
post(ForgeDirection.DOWN);
|
||||
}
|
||||
rendererOld.clearOverrideBlockTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -505,13 +502,13 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 1);
|
||||
|
||||
pre(ForgeDirection.UP);
|
||||
|
||||
fillLightmap(brightnessTopRight, brightnessTopLeft, brightnessBottomLeft, brightnessBottomRight);
|
||||
fillColormap(colorRedTopRight, colorRedTopLeft, colorRedBottomLeft, colorRedBottomRight, redmap);
|
||||
fillColormap(colorGreenTopRight, colorGreenTopLeft, colorGreenBottomLeft, colorGreenBottomRight, grnmap);
|
||||
fillColormap(colorBlueTopRight, colorBlueTopLeft, colorBlueBottomLeft, colorBlueBottomRight, blumap);
|
||||
|
||||
pre(ForgeDirection.UP);
|
||||
|
||||
getLight(0, 0);
|
||||
side(YPOS_LB, tex[0]);
|
||||
getLight(1, 0);
|
||||
@@ -523,14 +520,13 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
|
||||
post(ForgeDirection.UP);
|
||||
}
|
||||
rendererOld.clearOverrideBlockTexture();
|
||||
}
|
||||
|
||||
private void pre(ForgeDirection face) {
|
||||
protected void pre(ForgeDirection face) {
|
||||
manager.preRenderSide(this, blockAccess, bx, by, bz, face);
|
||||
}
|
||||
|
||||
private void post(ForgeDirection face) {
|
||||
protected void post(ForgeDirection face) {
|
||||
manager.postRenderSide(this, blockAccess, bx, by, bz, face);
|
||||
}
|
||||
}
|
||||
@@ -1,310 +0,0 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import com.cricketcraft.chisel.api.rendering.CTM;
|
||||
import com.cricketcraft.chisel.api.rendering.TextureSubmap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
// TODO rewrite this to use the updated RenderBlocksCTM code
|
||||
public class RenderBlocksCTMFullbright extends RenderBlocks {
|
||||
|
||||
private static CTM ctm = CTM.getInstance();
|
||||
|
||||
RenderBlocksCTMFullbright() {
|
||||
super();
|
||||
resetVertices();
|
||||
}
|
||||
|
||||
Tessellator tessellator;
|
||||
double[] X = new double[26];
|
||||
double[] Y = new double[26];
|
||||
double[] Z = new double[26];
|
||||
double[] U = new double[26];
|
||||
double[] V = new double[26];
|
||||
TextureSubmap submap;
|
||||
TextureSubmap submapSmall;
|
||||
RenderBlocks rendererOld;
|
||||
|
||||
int bx, by, bz;
|
||||
|
||||
@Override
|
||||
public boolean renderStandardBlock(Block block, int x, int y, int z) {
|
||||
bx = x;
|
||||
by = y;
|
||||
bz = z;
|
||||
|
||||
tessellator = Tessellator.instance;
|
||||
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
|
||||
|
||||
tessellator.addTranslation(x, y, z);
|
||||
|
||||
boolean res = super.renderStandardBlock(block, x, y, z);
|
||||
|
||||
tessellator.addTranslation(-x, -y, -z);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void side(int a, int b, int c, int d, int iconIndex, boolean flip) {
|
||||
IIcon icon;
|
||||
TextureSubmap map;
|
||||
if (iconIndex >= 16) {
|
||||
iconIndex -= 16;
|
||||
map = submapSmall;
|
||||
} else {
|
||||
map = submap;
|
||||
}
|
||||
int x = iconIndex % map.getWidth();
|
||||
int y = iconIndex / map.getHeight();
|
||||
icon = map.getSubIcon(x, y);
|
||||
|
||||
double u0 = icon.getMaxU();
|
||||
double u1 = icon.getMinU();
|
||||
double v0 = icon.getMaxV();
|
||||
double v1 = icon.getMinV();
|
||||
|
||||
U[a] = flip ? u1 : u1;
|
||||
U[b] = flip ? u0 : u1;
|
||||
U[c] = flip ? u0 : u0;
|
||||
U[d] = flip ? u1 : u0;
|
||||
|
||||
V[a] = flip ? v1 : v1;
|
||||
V[b] = flip ? v1 : v0;
|
||||
V[c] = flip ? v0 : v0;
|
||||
V[d] = flip ? v0 : v1;
|
||||
|
||||
vert(a);
|
||||
vert(b);
|
||||
vert(c);
|
||||
vert(d);
|
||||
}
|
||||
|
||||
void vert(int index) {
|
||||
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
|
||||
tessellator.setBrightness(0xF000F0);
|
||||
tessellator.addVertexWithUV(X[index], Y[index], Z[index], U[index], V[index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
IIcon i = rendererOld.overrideBlockTexture;
|
||||
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 0.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMaxU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 4);
|
||||
|
||||
side(1, 14, 9, 23, tex[0], false);
|
||||
side(23, 9, 17, 5, tex[1], false);
|
||||
side(9, 19, 4, 17, tex[3], false);
|
||||
side(14, 0, 19, 9, tex[2], false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
IIcon i = rendererOld.overrideBlockTexture;
|
||||
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMinU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 5);
|
||||
|
||||
side(11, 21, 3, 15, tex[3], false);
|
||||
side(16, 7, 21, 11, tex[2], false);
|
||||
side(25, 11, 15, 2, tex[1], false);
|
||||
side(6, 16, 11, 25, tex[0], false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
IIcon i = rendererOld.overrideBlockTexture;
|
||||
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMaxU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 0.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 2);
|
||||
|
||||
side(2, 15, 8, 22, tex[0], false);
|
||||
side(15, 3, 18, 8, tex[2], false);
|
||||
side(8, 18, 0, 14, tex[3], false);
|
||||
side(22, 8, 14, 1, tex[1], false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
IIcon i = rendererOld.overrideBlockTexture;
|
||||
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMinU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 1.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 3);
|
||||
|
||||
side(17, 4, 20, 10, tex[2], false);
|
||||
side(5, 17, 10, 24, tex[0], false);
|
||||
side(24, 10, 16, 6, tex[1], false);
|
||||
side(10, 20, 7, 16, tex[3], false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
IIcon i = rendererOld.overrideBlockTexture;
|
||||
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 1.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 0.0, i.getMinU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMaxU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 0);
|
||||
|
||||
side(13, 21, 7, 20, tex[3], true);
|
||||
side(19, 13, 20, 4, tex[2], true);
|
||||
side(0, 18, 13, 19, tex[0], true);
|
||||
side(18, 3, 21, 13, tex[1], true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
IIcon i = rendererOld.overrideBlockTexture;
|
||||
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMaxU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 1);
|
||||
|
||||
side(12, 24, 6, 25, tex[3], false);
|
||||
side(22, 12, 25, 2, tex[1], false);
|
||||
side(1, 23, 12, 22, tex[0], false);
|
||||
side(23, 5, 24, 12, tex[2], false);
|
||||
}
|
||||
}
|
||||
|
||||
void resetVertices() {
|
||||
X[0] = 0;
|
||||
Z[0] = 0;
|
||||
Y[0] = 0;
|
||||
|
||||
X[1] = 0;
|
||||
Z[1] = 0;
|
||||
Y[1] = 1;
|
||||
|
||||
X[2] = 1;
|
||||
Z[2] = 0;
|
||||
Y[2] = 1;
|
||||
|
||||
X[3] = 1;
|
||||
Z[3] = 0;
|
||||
Y[3] = 0;
|
||||
|
||||
X[4] = 0;
|
||||
Z[4] = 1;
|
||||
Y[4] = 0;
|
||||
|
||||
X[5] = 0;
|
||||
Z[5] = 1;
|
||||
Y[5] = 1;
|
||||
|
||||
X[6] = 1;
|
||||
Z[6] = 1;
|
||||
Y[6] = 1;
|
||||
|
||||
X[7] = 1;
|
||||
Z[7] = 1;
|
||||
Y[7] = 0;
|
||||
|
||||
X[8] = 0.5;
|
||||
Z[8] = 0;
|
||||
Y[8] = 0.5;
|
||||
|
||||
X[9] = 0;
|
||||
Z[9] = 0.5;
|
||||
Y[9] = 0.5;
|
||||
|
||||
X[10] = 0.5;
|
||||
Z[10] = 1;
|
||||
Y[10] = 0.5;
|
||||
|
||||
X[11] = 1;
|
||||
Z[11] = 0.5;
|
||||
Y[11] = 0.5;
|
||||
|
||||
X[12] = 0.5;
|
||||
Z[12] = 0.5;
|
||||
Y[12] = 1;
|
||||
|
||||
X[13] = 0.5;
|
||||
Z[13] = 0.5;
|
||||
Y[13] = 0;
|
||||
|
||||
X[14] = 0;
|
||||
Z[14] = 0;
|
||||
Y[14] = 0.5;
|
||||
|
||||
X[15] = 1;
|
||||
Z[15] = 0;
|
||||
Y[15] = 0.5;
|
||||
|
||||
X[16] = 1;
|
||||
Z[16] = 1;
|
||||
Y[16] = 0.5;
|
||||
|
||||
X[17] = 0;
|
||||
Z[17] = 1;
|
||||
Y[17] = 0.5;
|
||||
|
||||
X[18] = 0.5;
|
||||
Z[18] = 0;
|
||||
Y[18] = 0;
|
||||
|
||||
X[19] = 0;
|
||||
Z[19] = 0.5;
|
||||
Y[19] = 0;
|
||||
|
||||
X[20] = 0.5;
|
||||
Z[20] = 1;
|
||||
Y[20] = 0;
|
||||
|
||||
X[21] = 1;
|
||||
Z[21] = 0.5;
|
||||
Y[21] = 0;
|
||||
|
||||
X[22] = 0.5;
|
||||
Z[22] = 0;
|
||||
Y[22] = 1;
|
||||
|
||||
X[23] = 0;
|
||||
Z[23] = 0.5;
|
||||
Y[23] = 1;
|
||||
|
||||
X[24] = 0.5;
|
||||
Z[24] = 1;
|
||||
Y[24] = 1;
|
||||
|
||||
X[25] = 1;
|
||||
Z[25] = 0.5;
|
||||
Y[25] = 1;
|
||||
}
|
||||
}
|
||||
@@ -42,9 +42,11 @@ public class RendererCTM implements ISimpleBlockRenderingHandler {
|
||||
|
||||
if (!rendererOld.hasOverrideBlockTexture() && var != null) {
|
||||
RenderBlocks rb = var.getSubmapManager().createRenderContext(rendererOld, world);
|
||||
if (rb != null) {
|
||||
if (rb.getClass() == RenderBlocksCTM.class) {
|
||||
if (rb != null && rb != rendererOld) {
|
||||
rb.blockAccess = world;
|
||||
if (rb instanceof RenderBlocksCTM) {
|
||||
((RenderBlocksCTM)rb).manager = (ISubmapManager<RenderBlocksCTM>) var.getSubmapManager();
|
||||
((RenderBlocksCTM)rb).rendererOld = rendererOld;
|
||||
}
|
||||
return rb.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.utils.Drawing;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class RendererCTMFullbright implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public RenderBlocksCTMFullbright rendererCTMNoLight = new RenderBlocksCTMFullbright();
|
||||
|
||||
public RendererCTMFullbright() {
|
||||
if (Chisel.renderCTMNoLightId == 0) {
|
||||
Chisel.renderCTMNoLightId = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
Drawing.drawBlock(block, metadata, renderer);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
|
||||
// TODO this needs to go...amalgamate into RendererCTM
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks rendererOld) {
|
||||
// int meta = world.getBlockMetadata(x, y, z);
|
||||
//
|
||||
// IVariationInfo var = ((ICarvable) block).getVariation(world, x, y, z, meta);
|
||||
//
|
||||
// if (var != null && var.getType() == TextureType.CTMX) {
|
||||
// rendererCTMNoLight.blockAccess = world;
|
||||
// rendererCTMNoLight.renderMaxX = 1.0;
|
||||
// rendererCTMNoLight.renderMaxY = 1.0;
|
||||
// rendererCTMNoLight.renderMaxZ = 1.0;
|
||||
//
|
||||
// rendererCTMNoLight.submap = var.submap;
|
||||
// rendererCTMNoLight.submapSmall = var.submapSmall;
|
||||
//
|
||||
// rendererCTMNoLight.rendererOld = rendererOld;
|
||||
//
|
||||
// return rendererCTMNoLight.renderStandardBlock(block, x, y, z);
|
||||
// } else {
|
||||
// return rendererOld.renderStandardBlock(block, x, y, z);
|
||||
// }
|
||||
return rendererOld.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int renderId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return Chisel.renderCTMNoLightId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.cricketcraft.chisel.api.rendering.TextureSubmap;
|
||||
|
||||
public class SubmapManagerAntiblock extends SubmapManagerBase<RenderBlocksCTM> {
|
||||
|
||||
private static final RenderBlocksCTM rb = new RenderBlocksCTM() {
|
||||
|
||||
@Override
|
||||
protected void fillLightmap(int bottomLeft, int bottomRight, int topRight, int topLeft) {
|
||||
int maxLight = 0xF000F0;
|
||||
super.fillLightmap(maxLight, maxLight, maxLight, maxLight);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillColormap(float bottomLeft, float bottomRight, float topRight, float topLeft, float[][] map) {
|
||||
int color = 0xFFFFFF;
|
||||
super.fillColormap(color, color, color, color, map);
|
||||
}
|
||||
};
|
||||
|
||||
private String color;
|
||||
private TextureSubmap submap, submapSmall;
|
||||
|
||||
public SubmapManagerAntiblock(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return submapSmall.getBaseIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||
submap = new TextureSubmap(register.registerIcon(modName + ":antiblock/" + color + "-antiBlock-ctm"), 4, 4);
|
||||
submapSmall = new TextureSubmap(register.registerIcon(modName + ":antiblock/" + color + "-antiBlock"), 2, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderBlocksCTM createRenderContext(RenderBlocks rendererOld, IBlockAccess world) {
|
||||
rb.submap = submap;
|
||||
rb.submapSmall = submapSmall;
|
||||
return rb;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.cricketcraft.chisel.api.rendering.ISubmapManager;
|
||||
|
||||
|
||||
public abstract class SubmapManagerBase<T extends RenderBlocks> implements ISubmapManager<T> {
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return getIcon(side, world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T createRenderContext(RenderBlocks rendererOld, IBlockAccess world) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRenderSide(T renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postRenderSide(T renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
}
|
||||
}
|
||||
@@ -5,20 +5,17 @@ import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.cricketcraft.chisel.api.rendering.ISubmapManager;
|
||||
import com.cricketcraft.chisel.api.rendering.TextureSubmap;
|
||||
|
||||
public class SubmapManagerCarpetFloor extends SubmapManagerBase<RenderBlocksCTM> {
|
||||
|
||||
public class SubmapManagerCarpetFloor implements ISubmapManager<RenderBlocksCTM> {
|
||||
|
||||
private static RenderBlocksCTM rb = new RenderBlocksCTM();
|
||||
|
||||
|
||||
private TextureSubmap submap;
|
||||
private TextureSubmap submapSmall;
|
||||
private String color;
|
||||
|
||||
|
||||
public SubmapManagerCarpetFloor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
@@ -42,23 +39,9 @@ public class SubmapManagerCarpetFloor implements ISubmapManager<RenderBlocksCTM>
|
||||
|
||||
@Override
|
||||
public RenderBlocksCTM createRenderContext(RenderBlocks rendererOld, IBlockAccess world) {
|
||||
rb.blockAccess = world;
|
||||
rb.renderMaxX = 1.0;
|
||||
rb.renderMaxY = 1f / 16f;
|
||||
rb.renderMaxZ = 1.0;
|
||||
|
||||
rb.submap = submap;
|
||||
rb.submapSmall = submapSmall;
|
||||
|
||||
rb.rendererOld = rendererOld;
|
||||
return rb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRenderSide(RenderBlocksCTM renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postRenderSide(RenderBlocksCTM renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
}
|
||||
}
|
||||
+1
-16
@@ -5,16 +5,14 @@ import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.cricketcraft.chisel.api.rendering.CTM;
|
||||
import com.cricketcraft.chisel.api.rendering.ISubmapManager;
|
||||
import com.cricketcraft.chisel.api.rendering.TextureSubmap;
|
||||
import com.cricketcraft.chisel.init.ChiselBlocks;
|
||||
|
||||
import static com.cricketcraft.chisel.api.rendering.Dir.*;
|
||||
|
||||
public class SubmapManagerFakeController implements ISubmapManager<RenderBlocks> {
|
||||
public class SubmapManagerFakeController extends SubmapManagerBase<RenderBlocks> {
|
||||
|
||||
private TextureSubmap map;
|
||||
private CTM ctm = CTM.getInstance();
|
||||
@@ -46,17 +44,4 @@ public class SubmapManagerFakeController implements ISubmapManager<RenderBlocks>
|
||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||
map = new TextureSubmap(register.registerIcon(modName + ":futura/WIP/controllerWIP-ctm"), 2, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world) {
|
||||
return rendererOld;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
}
|
||||
}
|
||||
@@ -43,15 +43,9 @@ public class SubmapManagerSlab implements ISubmapManager<RenderBlocksCTM> {
|
||||
|
||||
@Override
|
||||
public RenderBlocksCTM createRenderContext(RenderBlocks rendererOld, IBlockAccess world) {
|
||||
rb.blockAccess = world;
|
||||
rb.renderMaxX = 1.0;
|
||||
rb.renderMaxY = 1f / 2f;
|
||||
rb.renderMaxZ = 1.0;
|
||||
|
||||
rb.submap = submap;
|
||||
rb.submapSmall = submapSmall;
|
||||
|
||||
rb.rendererOld = rendererOld;
|
||||
return rb;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user