Merge branch 'experimentalCTM' into 1.8

This commit is contained in:
Ben Spiers 2014-09-01 20:05:22 +01:00
commit 33de5d3967
76 changed files with 1232 additions and 167 deletions

View file

@ -47,6 +47,7 @@ public class MekanismConfig
public static boolean machineEffects = true;
public static boolean oldTransmitterRender = false;
public static boolean replaceSoundsWhenResuming = true;
public static boolean renderCTM = true;
}
public static class usage

View file

@ -55,6 +55,7 @@ import mekanism.client.render.RenderGlowPanel;
import mekanism.client.render.RenderPartTransmitter;
import mekanism.client.render.RenderTickHandler;
import mekanism.client.render.block.BasicRenderingHandler;
import mekanism.client.render.block.CTMRenderingHandler;
import mekanism.client.render.block.MachineRenderingHandler;
import mekanism.client.render.entity.RenderBalloon;
import mekanism.client.render.entity.RenderFlame;
@ -174,6 +175,7 @@ public class ClientProxy extends CommonProxy
{
public static int MACHINE_RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
public static int BASIC_RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
public static int CTM_RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
@Override
public void loadConfiguration()
@ -189,6 +191,7 @@ public class ClientProxy extends CommonProxy
client.oldTransmitterRender = Mekanism.configuration.get("client", "OldTransmitterRender", false).getBoolean();
client.replaceSoundsWhenResuming = Mekanism.configuration.get("client", "ReplaceSoundsWhenResuming", true,
"If true, will reduce lagging between player sounds. Setting to false will reduce GC load").getBoolean();
client.renderCTM = Mekanism.configuration.get("client", "Use CTM Renderer", true).getBoolean();
if(Mekanism.configuration.hasChanged())
Mekanism.configuration.save();
@ -336,6 +339,7 @@ public class ClientProxy extends CommonProxy
//Register block handlers
RenderingRegistry.registerBlockHandler(new MachineRenderingHandler());
RenderingRegistry.registerBlockHandler(new BasicRenderingHandler());
RenderingRegistry.registerBlockHandler(new CTMRenderingHandler());
Mekanism.logger.info("Render registrations complete.");
}

View file

@ -0,0 +1,314 @@
package mekanism.client.render;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import net.minecraft.block.Block;
import net.minecraft.world.IBlockAccess;
/**
* CTM Logic adapted from Chisel.
* Code licensed under GPLv2
* @author AUTOMATIC_MAIDEN, asie, pokefenn, unpairedbracket
*/
public class CTM
{
static int submaps[][] = {
{16, 17, 18, 19},
{16, 9, 18, 13},
{8, 9, 12, 13},
{8, 17, 12, 19},
{16, 9, 6, 15},
{8, 17, 14, 7},
{2, 11, 6, 15},
{8, 9, 14, 15},
{10, 1, 14, 15},
{10, 11, 14, 5},
{0, 11, 4, 15},
{0, 1, 14, 15},
{},
{},
{},
{},
{16, 17, 6, 7},
{16, 9, 6, 5},
{8, 9, 4, 5},
{8, 17, 4, 7},
{2, 11, 18, 13},
{10, 3, 12, 19},
{10, 11, 12, 13},
{10, 3, 14, 7},
{0, 11, 14, 15},
{10, 11, 4, 15},
{10, 11, 4, 5},
{10, 1, 14, 5},
{},
{},
{},
{},
{2, 3, 6, 7},
{2, 1, 6, 5},
{0, 1, 4, 5},
{0, 3, 4, 7},
{2, 11, 6, 5},
{8, 9, 4, 15},
{2, 1, 6, 15},
{8, 9, 14, 5},
{0, 1, 4, 15},
{0, 1, 14, 5},
{10, 1, 4, 15},
{0, 11, 14, 5},
{},
{},
{},
{},
{2, 3, 18, 19},
{2, 1, 18, 13},
{0, 1, 12, 13},
{0, 3, 12, 19},
{10, 1, 12, 13},
{0, 3, 14, 7},
{0, 11, 12, 13},
{10, 3, 4, 7},
{0, 11, 4, 5},
{10, 1, 4, 5},
{10, 11, 14, 15},
{0, 1, 4, 5},
{},
{},
{},
{},
};
public static int[] getSubmapIndices(IBlockAccess world, int x, int y, int z, int side, HashMap<Block, List<Integer>> blockMetas)
{
int index = getTexture(world, x, y, z, side, blockMetas);
return submaps[index];
}
public static int getTexture(IBlockAccess world, int x, int y, int z, int side, HashMap<Block, List<Integer>> blockMetas)
{
if(world == null)
return 0;
int texture = 0;
boolean b[] = new boolean[6];
if(side <= 1)
{
b[0] = isConnected(world, x - 1, y, z, side, blockMetas);
b[1] = isConnected(world, x + 1, y, z, side, blockMetas);
b[2] = isConnected(world, x, y, z + 1, side, blockMetas);
b[3] = isConnected(world, x, y, z - 1, side, blockMetas);
} else if(side == 2)
{
b[0] = isConnected(world, x + 1, y, z, side, blockMetas);
b[1] = isConnected(world, x - 1, y, z, side, blockMetas);
b[2] = isConnected(world, x, y - 1, z, side, blockMetas);
b[3] = isConnected(world, x, y + 1, z, side, blockMetas);
} else if(side == 3)
{
b[0] = isConnected(world, x - 1, y, z, side, blockMetas);
b[1] = isConnected(world, x + 1, y, z, side, blockMetas);
b[2] = isConnected(world, x, y - 1, z, side, blockMetas);
b[3] = isConnected(world, x, y + 1, z, side, blockMetas);
} else if(side == 4)
{
b[0] = isConnected(world, x, y, z - 1, side, blockMetas);
b[1] = isConnected(world, x, y, z + 1, side, blockMetas);
b[2] = isConnected(world, x, y - 1, z, side, blockMetas);
b[3] = isConnected(world, x, y + 1, z, side, blockMetas);
} else if(side == 5)
{
b[0] = isConnected(world, x, y, z + 1, side, blockMetas);
b[1] = isConnected(world, x, y, z - 1, side, blockMetas);
b[2] = isConnected(world, x, y - 1, z, side, blockMetas);
b[3] = isConnected(world, x, y + 1, z, side, blockMetas);
}
if(b[0] & !b[1] & !b[2] & !b[3])
texture = 3;
else if(!b[0] & b[1] & !b[2] & !b[3])
texture = 1;
else if(!b[0] & !b[1] & b[2] & !b[3])
texture = 16;
else if(!b[0] & !b[1] & !b[2] & b[3])
texture = 48;
else if(b[0] & b[1] & !b[2] & !b[3])
texture = 2;
else if(!b[0] & !b[1] & b[2] & b[3])
texture = 32;
else if(b[0] & !b[1] & b[2] & !b[3])
texture = 19;
else if(b[0] & !b[1] & !b[2] & b[3])
texture = 51;
else if(!b[0] & b[1] & b[2] & !b[3])
texture = 17;
else if(!b[0] & b[1] & !b[2] & b[3])
texture = 49;
else if(!b[0] & b[1] & b[2] & b[3])
texture = 33;
else if(b[0] & !b[1] & b[2] & b[3])
texture = 35;
else if(b[0] & b[1] & !b[2] & b[3])
texture = 50;
else if(b[0] & b[1] & b[2] & !b[3])
texture = 18;
else if(b[0] & b[1] & b[2] & b[3])
texture = 34;
boolean b2[] = new boolean[6];
if(side <= 1)
{
b2[0] = !isConnected(world, x + 1, y, z + 1, side, blockMetas);
b2[1] = !isConnected(world, x - 1, y, z + 1, side, blockMetas);
b2[2] = !isConnected(world, x + 1, y, z - 1, side, blockMetas);
b2[3] = !isConnected(world, x - 1, y, z - 1, side, blockMetas);
} else if(side == 2)
{
b2[0] = !isConnected(world, x - 1, y - 1, z, side, blockMetas);
b2[1] = !isConnected(world, x + 1, y - 1, z, side, blockMetas);
b2[2] = !isConnected(world, x - 1, y + 1, z, side, blockMetas);
b2[3] = !isConnected(world, x + 1, y + 1, z, side, blockMetas);
} else if(side == 3)
{
b2[0] = !isConnected(world, x + 1, y - 1, z, side, blockMetas);
b2[1] = !isConnected(world, x - 1, y - 1, z, side, blockMetas);
b2[2] = !isConnected(world, x + 1, y + 1, z, side, blockMetas);
b2[3] = !isConnected(world, x - 1, y + 1, z, side, blockMetas);
} else if(side == 4)
{
b2[0] = !isConnected(world, x, y - 1, z + 1, side, blockMetas);
b2[1] = !isConnected(world, x, y - 1, z - 1, side, blockMetas);
b2[2] = !isConnected(world, x, y + 1, z + 1, side, blockMetas);
b2[3] = !isConnected(world, x, y + 1, z - 1, side, blockMetas);
} else if(side == 5)
{
b2[0] = !isConnected(world, x, y - 1, z - 1, side, blockMetas);
b2[1] = !isConnected(world, x, y - 1, z + 1, side, blockMetas);
b2[2] = !isConnected(world, x, y + 1, z - 1, side, blockMetas);
b2[3] = !isConnected(world, x, y + 1, z + 1, side, blockMetas);
}
if(texture == 17 && b2[0])
texture = 4;
if(texture == 19 && b2[1])
texture = 5;
if(texture == 49 && b2[2])
texture = 20;
if(texture == 51 && b2[3])
texture = 21;
if(texture == 18 && b2[0] && b2[1])
texture = 7;
if(texture == 33 && b2[0] && b2[2])
texture = 6;
if(texture == 35 && b2[3] && b2[1])
texture = 23;
if(texture == 50 && b2[3] && b2[2])
texture = 22;
if(texture == 18 && !b2[0] && b2[1])
texture = 39;
if(texture == 33 && b2[0] && !b2[2])
texture = 38;
if(texture == 35 && !b2[3] && b2[1])
texture = 53;
if(texture == 50 && b2[3] && !b2[2])
texture = 52;
if(texture == 18 && b2[0] && !b2[1])
texture = 37;
if(texture == 33 && !b2[0] && b2[2])
texture = 36;
if(texture == 35 && b2[3] && !b2[1])
texture = 55;
if(texture == 50 && !b2[3] && b2[2])
texture = 54;
if(texture == 34 && b2[0] && b2[1] && b2[2] && b2[3])
texture = 58;
if(texture == 34 && !b2[0] && b2[1] && b2[2] && b2[3])
texture = 9;
if(texture == 34 && b2[0] && !b2[1] && b2[2] && b2[3])
texture = 25;
if(texture == 34 && b2[0] && b2[1] && !b2[2] && b2[3])
texture = 8;
if(texture == 34 && b2[0] && b2[1] && b2[2] && !b2[3])
texture = 24;
if(texture == 34 && b2[0] && b2[1] && !b2[2] && !b2[3])
texture = 11;
if(texture == 34 && !b2[0] && !b2[1] && b2[2] && b2[3])
texture = 26;
if(texture == 34 && !b2[0] && b2[1] && !b2[2] && b2[3])
texture = 27;
if(texture == 34 && b2[0] && !b2[1] && b2[2] && !b2[3])
texture = 10;
if(texture == 34 && b2[0] && !b2[1] && !b2[2] && b2[3])
texture = 42;
if(texture == 34 && !b2[0] && b2[1] && b2[2] && !b2[3])
texture = 43;
if(texture == 34 && b2[0] && !b2[1] && !b2[2] && !b2[3])
texture = 40;
if(texture == 34 && !b2[0] && b2[1] && !b2[2] && !b2[3])
texture = 41;
if(texture == 34 && !b2[0] && !b2[1] && b2[2] && !b2[3])
texture = 56;
if(texture == 34 && !b2[0] && !b2[1] && !b2[2] && b2[3])
texture = 57;
return texture;
}
public static boolean isConnected(IBlockAccess world, int x, int y, int z, int side, HashMap<Block, List<Integer>> blockMetas)
{
int x2 = x, y2 = y, z2 = z;
switch(side)
{
case 0:
y2--;
break;
case 1:
y2++;
break;
case 2:
z2--;
break;
case 3:
z2++;
break;
case 4:
x2--;
break;
case 5:
x2++;
break;
}
Block block1 = world.getBlock(x, y, z);
Block block2 = world.getBlock(x2, y2, z2);
int meta1 = world.getBlockMetadata(x, y, z);
int meta2 = world.getBlockMetadata(x2, y2, z2);
boolean validBlockMeta1 = false;
boolean invalidBlockMeta2 = true;
for(Entry<Block, List<Integer>> entry : blockMetas.entrySet())
{
validBlockMeta1 |= block1.equals(entry.getKey()) && entry.getValue().contains(meta1);
invalidBlockMeta2 &= !(block2.equals(entry.getKey()) && entry.getValue().contains(meta2));
}
return validBlockMeta1 && invalidBlockMeta2;
}
}

View file

@ -0,0 +1,73 @@
package mekanism.client.render.block;
import mekanism.api.MekanismConfig;
import mekanism.client.ClientProxy;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.CTMData;
import mekanism.common.base.IBlockCTM;
import mekanism.common.tile.TileEntityBasicBlock;
import mekanism.common.util.MekanismUtils;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
/**
* CTM ISBRH adapted from Chisel
* Code licensed under GPLv2
* @author AUTOMATIC_MAIDEN, asie, pokefenn, unpairedbracket
*/
public class CTMRenderingHandler implements ISimpleBlockRenderingHandler
{
RenderBlocksCTM rendererCTM = new RenderBlocksCTM();
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
{
MekanismRenderer.renderItem(renderer, metadata, block);
}
@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);
CTMData blockCTM = ((IBlockCTM)block).getCTMData(world, x, y, z, meta);
if(MekanismConfig.client.renderCTM && blockCTM != null)
{
if(blockCTM.hasFacingOverride() && world.getTileEntity(x, y, z) instanceof TileEntityBasicBlock)
{
TileEntityBasicBlock tile = (TileEntityBasicBlock)world.getTileEntity(x, y, z);
blockCTM.setFacing(tile.facing);
}
rendererCTM.blockAccess = world;
rendererCTM.renderMaxX = 1.0;
rendererCTM.renderMaxY = 1.0;
rendererCTM.renderMaxZ = 1.0;
rendererCTM.dataCTM = blockCTM;
rendererCTM.rendererOld = rendererOld;
return rendererCTM.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 ClientProxy.CTM_RENDER_ID;
}
}

View file

@ -0,0 +1,387 @@
package mekanism.client.render.block;
import java.util.HashMap;
import java.util.List;
import mekanism.client.render.CTM;
import mekanism.common.CTMData;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.IIcon;
/**
* CTM RenderBlocks adapted from Chisel
* Code licensed under GPLv2
* @author AUTOMATIC_MAIDEN, asie, pokefenn, unpairedbracket
*/
public class RenderBlocksCTM extends RenderBlocks
{
RenderBlocksCTM()
{
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];
int[] L = new int[26];
float[] R = new float[26];
float[] G = new float[26];
float[] B = new float[26];
CTMData dataCTM;
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 setupSides(int a, int b, int c, int d, int xa, int xb, int xc, int xd, int e)
{
L[a] = brightnessBottomLeft;
L[b] = brightnessBottomRight;
L[c] = brightnessTopRight;
L[d] = brightnessTopLeft;
L[e] = (brightnessBottomLeft + brightnessTopLeft + brightnessTopRight + brightnessBottomRight) / 4;
L[xa] = (L[a] + L[b]) / 2;
L[xb] = (L[b] + L[c]) / 2;
L[xc] = (L[c] + L[d]) / 2;
L[xd] = (L[d] + L[a]) / 2;
R[a] = colorRedBottomLeft;
R[b] = colorRedBottomRight;
R[c] = colorRedTopRight;
R[d] = colorRedTopLeft;
R[e] = (colorRedBottomLeft + colorRedTopLeft + colorRedTopRight + colorRedBottomRight) / 4;
R[xa] = (R[a] + R[b]) / 2;
R[xb] = (R[b] + R[c]) / 2;
R[xc] = (R[c] + R[d]) / 2;
R[xd] = (R[d] + R[a]) / 2;
G[a] = colorGreenBottomLeft;
G[b] = colorGreenBottomRight;
G[c] = colorGreenTopRight;
G[d] = colorGreenTopLeft;
G[e] = (colorGreenBottomLeft + colorGreenTopLeft + colorGreenTopRight + colorGreenBottomRight) / 4;
G[xa] = (G[a] + G[b]) / 2;
G[xb] = (G[b] + G[c]) / 2;
G[xc] = (G[c] + G[d]) / 2;
G[xd] = (G[d] + G[a]) / 2;
B[a] = colorBlueBottomLeft;
B[b] = colorBlueBottomRight;
B[c] = colorBlueTopRight;
B[d] = colorBlueTopLeft;
B[e] = (colorBlueBottomLeft + colorBlueTopLeft + colorBlueTopRight + colorBlueBottomRight) / 4;
B[xa] = (B[a] + B[b]) / 2;
B[xb] = (B[b] + B[c]) / 2;
B[xc] = (B[c] + B[d]) / 2;
B[xd] = (B[d] + B[a]) / 2;
}
void side(int a, int b, int c, int d, int iconIndex, boolean flip, int side)
{
IIcon icon = iconIndex >= 16 ? dataCTM.getSmallSubmap(side).icons[iconIndex - 16] : dataCTM.getSubmap(side).icons[iconIndex];
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)
{
if(enableAO)
{
tessellator.setColorOpaque_F(R[index], G[index], B[index]);
tessellator.setBrightness(L[index]);
}
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, dataCTM.acceptableBlockMetas);
setupSides(1, 0, 4, 5, 14, 19, 17, 23, 9);
side(1, 14, 9, 23, tex[0], false, 4);
side(23, 9, 17, 5, tex[1], false, 4);
side(9, 19, 4, 17, tex[3], false, 4);
side(14, 0, 19, 9, tex[2], false, 4);
}
}
@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, dataCTM.acceptableBlockMetas);
setupSides(3, 2, 6, 7, 15, 25, 16, 21, 11);
side(11, 21, 3, 15, tex[3], false, 5);
side(16, 7, 21, 11, tex[2], false, 5);
side(25, 11, 15, 2, tex[1], false, 5);
side(6, 16, 11, 25, tex[0], false, 5);
}
}
@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, dataCTM.acceptableBlockMetas);
setupSides(2, 3, 0, 1, 15, 18, 14, 22, 8);
side(2, 15, 8, 22, tex[0], false, 2);
side(15, 3, 18, 8, tex[2], false, 2);
side(8, 18, 0, 14, tex[3], false, 2);
side(22, 8, 14, 1, tex[1], false, 2);
}
}
@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, dataCTM.acceptableBlockMetas);
setupSides(4, 7, 6, 5, 20, 16, 24, 17, 10);
side(17, 4, 20, 10, tex[2], false, 3);
side(5, 17, 10, 24, tex[0], false, 3);
side(24, 10, 16, 6, tex[1], false, 3);
side(10, 20, 7, 16, tex[3], false, 3);
}
}
@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, dataCTM.acceptableBlockMetas);
setupSides(0, 3, 7, 4, 18, 21, 20, 19, 13);
side(13, 21, 7, 20, tex[3], true, 0);
side(19, 13, 20, 4, tex[2], true, 0);
side(0, 18, 13, 19, tex[0], true, 0);
side(18, 3, 21, 13, tex[1], true, 0);
}
}
@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, dataCTM.acceptableBlockMetas);
setupSides(2, 1, 5, 6, 22, 23, 24, 25, 12);
side(12, 24, 6, 25, tex[3], false, 1);
side(22, 12, 25, 2, tex[1], false, 1);
side(1, 23, 12, 22, tex[0], false, 1);
side(23, 5, 24, 12, tex[2], false, 1);
}
}
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;
}
}

View file

@ -0,0 +1,42 @@
package mekanism.client.render.block;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
/**
* Multi-texture class adapted from Chisel
* Code licensed under GPLv2
* @author AUTOMATIC_MAIDEN, asie, pokefenn, unpairedbracket
*/
public class TextureSubmap
{
public int width, height;
public IIcon icon;
public IIcon icons[];
public TextureSubmap(IIcon i, int w, int h)
{
icon = i;
width = w;
height = h;
icons = new IIcon[width * height];
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void TexturesStitched(TextureStitchEvent.Post event)
{
for(int x = 0; x < width; x++)
{
for(int y = 0; y < height; y++)
{
icons[y * width + x] = new TextureVirtual(icon, width, height, x, y);
}
}
}
}

View file

@ -0,0 +1,97 @@
package mekanism.client.render.block;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* Texture component class adapted from Chisel
* Code licensed under GPLv2
* @author AUTOMATIC_MAIDEN, asie, pokefenn, unpairedbracket
*/
public class TextureVirtual implements IIcon
{
int ox, oy;
float u0, u1, v0, v1;
String name;
IIcon icon;
TextureVirtual(IIcon parent, int w, int h, int x, int y)
{
icon = parent;
u0 = icon.getInterpolatedU(16.0 * (x) / w);
u1 = icon.getInterpolatedU(16.0 * (x + 1) / w);
v0 = icon.getInterpolatedV(16.0 * (y) / h);
v1 = icon.getInterpolatedV(16.0 * (y + 1) / h);
name = icon.getIconName() + "|" + x + "." + y;
ox = icon.getIconWidth();
oy = icon.getIconHeight();
}
@Override
@SideOnly(Side.CLIENT)
public float getMinU()
{
return u0;
}
@Override
@SideOnly(Side.CLIENT)
public float getMaxU()
{
return u1;
}
@Override
@SideOnly(Side.CLIENT)
public float getInterpolatedU(double d0)
{
return (float) (u0 + (u1 - u0) * d0 / 16.0);
}
@Override
@SideOnly(Side.CLIENT)
public float getMinV()
{
return v0;
}
@Override
@SideOnly(Side.CLIENT)
public float getMaxV()
{
return v1;
}
@Override
@SideOnly(Side.CLIENT)
public float getInterpolatedV(double d0)
{
return (float) (v0 + (v1 - v0) * d0 / 16.0);
}
@Override
@SideOnly(Side.CLIENT)
public String getIconName()
{
return name;
}
@Override
@SideOnly(Side.CLIENT)
public int getIconWidth()
{
return ox;
}
@Override
@SideOnly(Side.CLIENT)
public int getIconHeight()
{
return oy;
}
}

View file

@ -0,0 +1,129 @@
package mekanism.common;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import mekanism.api.Coord4D;
import mekanism.client.render.block.TextureSubmap;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CTMData
{
public CTMTextureData mainTextureData;
public HashMap<Block, List<Integer>> acceptableBlockMetas = new HashMap<Block, List<Integer>>();
public CTMTextureData[] sideOverrides = new CTMTextureData[6];
public CTMTextureData facingOverride;
public int facing;
public CTMData(String textureName, Block block, List<Integer> connectableMeta)
{
mainTextureData = new CTMTextureData(textureName);
acceptableBlockMetas.put(block, connectableMeta);
}
public CTMData addSideOverride(ForgeDirection side, String sideTexture)
{
sideOverrides[side.ordinal()] = new CTMTextureData(sideTexture);
return this;
}
public CTMData addFacingOverride(String facingTexture)
{
facingOverride = new CTMTextureData(facingTexture);
return this;
}
public boolean hasFacingOverride()
{
return facingOverride != null;
}
public void setFacing(int newFacing)
{
facing = newFacing;
}
public CTMData registerIcons(IIconRegister register)
{
mainTextureData.registerIcons(register);
if(facingOverride != null)
{
facingOverride.registerIcons(register);
}
for(CTMTextureData data : sideOverrides)
{
if(data != null)
{
data.registerIcons(register);
}
}
return this;
}
public CTMTextureData getTextureData(int side)
{
if(hasFacingOverride() && side == facing)
{
return facingOverride;
}
if(sideOverrides[side] != null)
{
return sideOverrides[side];
}
return mainTextureData;
}
public IIcon getIcon(int side)
{
return getTextureData(side).icon;
}
public TextureSubmap getSubmap(int side)
{
return getTextureData(side).submap;
}
public TextureSubmap getSmallSubmap(int side)
{
return getTextureData(side).submapSmall;
}
public CTMData addOtherBlockConnectivities(Block block, List<Integer> connectableMeta)
{
acceptableBlockMetas.put(block, connectableMeta);
return this;
}
@SideOnly(Side.CLIENT)
public boolean shouldRenderSide(IBlockAccess world, int x, int y, int z, int side)
{
Coord4D obj = new Coord4D(x, y, z);
Block coordBlock = obj.getBlock(world);
int coordMeta = obj.getMetadata(world);
boolean valid = false;
for(Entry<Block, List<Integer>> entry : acceptableBlockMetas.entrySet())
{
valid |= entry.getKey().equals(coordBlock) && entry.getValue().contains(coordMeta);
}
return !valid;
}
}

View file

@ -0,0 +1,31 @@
package mekanism.common;
import mekanism.client.render.block.TextureSubmap;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
public class CTMTextureData
{
public IIcon icon;
public TextureSubmap submap;
public TextureSubmap submapSmall;
public String texture;
public CTMTextureData(String textureName)
{
texture = textureName;
}
public void registerIcons(IIconRegister register)
{
icon = register.registerIcon("mekanism:" + texture);
submap = new TextureSubmap(register.registerIcon("mekanism:" + texture + "-ctm"), 4, 4);
submapSmall = new TextureSubmap(icon, 2, 2);
}
}

View file

@ -1,127 +0,0 @@
package mekanism.common;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import mekanism.api.Coord4D;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ConnectedTextureRenderer
{
public static final byte[][] sideEdges = {{2, 5, 3, 4}, {2, 5, 3, 4}, {1, 4, 0, 5}, {1, 5, 0, 4}, {1, 3, 0, 2}, {1, 2, 0, 3}};
public Block block;
public List<Integer> metadata;
public String iconTitle;
public Map<Integer, IIcon> glassMap = new HashMap<Integer, IIcon>();
public ConnectedTextureRenderer(String title, Block b, List<Integer> meta)
{
iconTitle = title;
block = b;
metadata = meta;
}
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register)
{
glassMap.put(0, register.registerIcon("mekanism:" + iconTitle + "_13"));
glassMap.put(1, register.registerIcon("mekanism:" + iconTitle + "_20"));
glassMap.put(4, register.registerIcon("mekanism:" + iconTitle + "_19"));
glassMap.put(5, register.registerIcon("mekanism:" + iconTitle + "_23"));
glassMap.put(7, register.registerIcon("mekanism:" + iconTitle + "_1"));
glassMap.put(16, register.registerIcon("mekanism:" + iconTitle + "_7"));
glassMap.put(17, register.registerIcon("mekanism:" + iconTitle + "_35"));
glassMap.put(20, register.registerIcon("mekanism:" + iconTitle + "_40"));
glassMap.put(21, register.registerIcon("mekanism:" + iconTitle + "_21"));
glassMap.put(23, register.registerIcon("mekanism:" + iconTitle + "_31"));
glassMap.put(28, register.registerIcon("mekanism:" + iconTitle + "_14"));
glassMap.put(29, register.registerIcon("mekanism:" + iconTitle + "_45"));
glassMap.put(31, register.registerIcon("mekanism:" + iconTitle + "_2"));
glassMap.put(64, register.registerIcon("mekanism:" + iconTitle + "_8"));
glassMap.put(65, register.registerIcon("mekanism:" + iconTitle + "_41"));
glassMap.put(68, register.registerIcon("mekanism:" + iconTitle + "_46"));
glassMap.put(69, register.registerIcon("mekanism:" + iconTitle + "_22"));
glassMap.put(71, register.registerIcon("mekanism:" + iconTitle + "_32"));
glassMap.put(80, register.registerIcon("mekanism:" + iconTitle + "_11"));
glassMap.put(81, register.registerIcon("mekanism:" + iconTitle + "_10"));
glassMap.put(84, register.registerIcon("mekanism:" + iconTitle + "_9"));
glassMap.put(85, register.registerIcon("mekanism:" + iconTitle + "_17"));
glassMap.put(87, register.registerIcon("mekanism:" + iconTitle + "_5"));
glassMap.put(92, register.registerIcon("mekanism:" + iconTitle + "_34"));
glassMap.put(93, register.registerIcon("mekanism:" + iconTitle + "_18"));
glassMap.put(95, register.registerIcon("mekanism:" + iconTitle + "_6"));
glassMap.put(112, register.registerIcon("mekanism:" + iconTitle + "_25"));
glassMap.put(113, register.registerIcon("mekanism:" + iconTitle + "_43"));
glassMap.put(116, register.registerIcon("mekanism:" + iconTitle + "_42"));
glassMap.put(117, register.registerIcon("mekanism:" + iconTitle + "_29"));
glassMap.put(119, register.registerIcon("mekanism:" + iconTitle + "_37"));
glassMap.put(124, register.registerIcon("mekanism:" + iconTitle + "_26"));
glassMap.put(125, register.registerIcon("mekanism:" + iconTitle + "_30"));
glassMap.put(127, register.registerIcon("mekanism:" + iconTitle + "_38"));
glassMap.put(193, register.registerIcon("mekanism:" + iconTitle + "_12"));
glassMap.put(197, register.registerIcon("mekanism:" + iconTitle + "_44"));
glassMap.put(199, register.registerIcon("mekanism:" + iconTitle + "_0"));
glassMap.put(209, register.registerIcon("mekanism:" + iconTitle + "_33"));
glassMap.put(213, register.registerIcon("mekanism:" + iconTitle + "_16"));
glassMap.put(215, register.registerIcon("mekanism:" + iconTitle + "_4"));
glassMap.put(221, register.registerIcon("mekanism:" + iconTitle + "_15"));
glassMap.put(223, register.registerIcon("mekanism:" + iconTitle + "_3"));
glassMap.put(241, register.registerIcon("mekanism:" + iconTitle + "_24"));
glassMap.put(245, register.registerIcon("mekanism:" + iconTitle + "_28"));
glassMap.put(247, register.registerIcon("mekanism:" + iconTitle + "_36"));
glassMap.put(253, register.registerIcon("mekanism:" + iconTitle + "_27"));
glassMap.put(255, register.registerIcon("mekanism:" + iconTitle + "_39"));
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
{
int map = 0;
for(int face = 0; face < 4; face++)
{
int side0 = sideEdges[side][((face + 3) % 4)];
int side1 = sideEdges[side][face];
if(!canConnect(world, new Coord4D(x, y, z), sideEdges[side][face], side))
{
map |= (7 << face * 2) % 256 | 7 >>> 8 - face * 2;
}
else if(!canConnect(world, new Coord4D(x, y, z).getFromSide(ForgeDirection.getOrientation(side0)), side1, side))
{
map |= 1 << face * 2;
}
else if(!canConnect(world, new Coord4D(x, y, z).getFromSide(ForgeDirection.getOrientation(side1)), side0, side))
{
map |= 1 << face * 2;
}
}
return glassMap.get(map);
}
private boolean canConnect(IBlockAccess access, Coord4D obj, int side, int face)
{
Coord4D coord = obj.getFromSide(ForgeDirection.getOrientation(side));
Coord4D coordAbove = obj.getFromSide(ForgeDirection.getOrientation(face));
return (coord.getBlock(access) == block && metadata.contains(coord.getMetadata(access))) && (coordAbove.getBlock(access) != block || metadata.contains(coordAbove.getMetadata(access)));
}
@SideOnly(Side.CLIENT)
public boolean shouldRenderSide(IBlockAccess world, int x, int y, int z, int side)
{
Coord4D obj = new Coord4D(x, y, z).getFromSide(ForgeDirection.getOrientation(side).getOpposite());
return obj.getBlock(world) != block || !metadata.contains(obj.getMetadata(world));
}
}

View file

@ -0,0 +1,11 @@
package mekanism.common.base;
import mekanism.common.CTMData;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public interface IBlockCTM
{
public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta);
}

View file

@ -8,7 +8,8 @@ import java.util.Random;
import mekanism.api.Coord4D;
import mekanism.api.Range4D;
import mekanism.client.ClientProxy;
import mekanism.common.ConnectedTextureRenderer;
import mekanism.common.base.IBlockCTM;
import mekanism.common.CTMData;
import mekanism.common.ItemAttacher;
import mekanism.common.Mekanism;
import mekanism.common.MekanismBlocks;
@ -72,11 +73,11 @@ import cpw.mods.fml.relauncher.SideOnly;
* @author AidanBrady
*
*/
public class BlockBasic extends Block
public class BlockBasic extends Block implements IBlockCTM
{
public IIcon[][] icons = new IIcon[256][6];
public ConnectedTextureRenderer glassRenderer = new ConnectedTextureRenderer("glass/DynamicGlass", this, Arrays.asList(10));
public CTMData[][] ctms = new CTMData[16][2];
public BlockBasic()
{
@ -134,11 +135,19 @@ public class BlockBasic extends Block
icons[14][2] = register.registerIcon("mekanism:SalinationBlock");
icons[15][0] = register.registerIcon("mekanism:SalinationValve");
glassRenderer.registerIcons(register);
ctms[9][0] = new CTMData("ctm/DynamicTank", this, Arrays.asList(9, 11)).registerIcons(register);
ctms[10][0] = new CTMData("ctm/DynamicGlass", this, Arrays.asList(10)).registerIcons(register);
ctms[11][0] = new CTMData("ctm/DynamicValve", this, Arrays.asList(11, 9)).registerIcons(register);
ctms[14][0] = new CTMData("ctm/SalinationBlock", this, Arrays.asList(14, 15)).addOtherBlockConnectivities(MekanismBlocks.BasicBlock2, Arrays.asList(0)).addFacingOverride("ctm/SalinationController").registerIcons(register);
ctms[14][1] = new CTMData("ctm/SalinationBlock", this, Arrays.asList(14, 15)).addOtherBlockConnectivities(MekanismBlocks.BasicBlock2, Arrays.asList(0)).addFacingOverride("ctm/SalinationControllerOn").registerIcons(register);
ctms[15][0] = new CTMData("ctm/SalinationValve", this, Arrays.asList(15, 14)).addOtherBlockConnectivities(MekanismBlocks.BasicBlock2, Arrays.asList(0)).registerIcons(register);
}
else if(this == MekanismBlocks.BasicBlock2)
{
icons[0][0] = register.registerIcon("mekanism:SalinationBlock");
ctms[0][0] = new CTMData("ctm/SalinationBlock", this, Arrays.asList(0)).addOtherBlockConnectivities(MekanismBlocks.BasicBlock, Arrays.asList(14, 15)).registerIcons(register);
}
}
@ -150,40 +159,40 @@ public class BlockBasic extends Block
if(this == MekanismBlocks.BasicBlock)
{
if(metadata == 6)
switch(metadata)
{
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z);
case 6:
TileEntityBasicBlock tileEntity6 = (TileEntityBasicBlock)world.getTileEntity(x, y, z);
if(side == 0 || side == 1)
{
return MekanismUtils.isActive(world, x, y, z) ? icons[6][3] : icons[6][1];
}
else if(side == tileEntity.facing)
{
return MekanismUtils.isActive(world, x, y, z) ? icons[6][4] : icons[6][2];
}
else {
return icons[6][0];
}
}
else if(metadata == 10)
{
return glassRenderer.getIcon(world, x, y, z, side);
}
else if(metadata == 14)
{
TileEntitySalinationController tileEntity = (TileEntitySalinationController)world.getTileEntity(x, y, z);
if(side == 0 || side == 1)
{
return MekanismUtils.isActive(world, x, y, z) ? icons[6][3] : icons[6][1];
}
else if(side == tileEntity6.facing)
{
return MekanismUtils.isActive(world, x, y, z) ? icons[6][4] : icons[6][2];
}
else
{
return icons[6][0];
}
case 9:
case 10:
case 11:
return ctms[metadata][0].getIcon(side);
case 14:
TileEntitySalinationController tileEntity14 = (TileEntitySalinationController)world.getTileEntity(x, y, z);
if(side == tileEntity.facing)
{
return tileEntity.structured ? icons[14][1] : icons[14][0];
}
else {
return icons[14][2];
}
}
else {
return getIcon(side, metadata);
if(side == tileEntity14.facing)
{
return tileEntity14.structured ? icons[14][1] : icons[14][0];
}
else
{
return icons[14][2];
}
default:
return getIcon(side, metadata);
}
}
else if(this == MekanismBlocks.BasicBlock2)
@ -583,7 +592,7 @@ public class BlockBasic extends Block
@SideOnly(Side.CLIENT)
public int getRenderType()
{
return ClientProxy.BASIC_RENDER_ID;
return ClientProxy.CTM_RENDER_ID;
}
@Override
@ -795,9 +804,10 @@ public class BlockBasic extends Block
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side)
{
if(this == MekanismBlocks.BasicBlock && world.getBlockMetadata(x, y, z) == 10)
Coord4D obj = new Coord4D(x, y, z).getFromSide(ForgeDirection.getOrientation(side).getOpposite());
if(this == MekanismBlocks.BasicBlock && obj.getMetadata(world) == 10)
{
return glassRenderer.shouldRenderSide(world, x, y, z, side);
return ctms[10][0].shouldRenderSide(world, x, y, z, side);
}
else {
return super.shouldSideBeRendered(world, x, y, z, side);
@ -843,4 +853,15 @@ public class BlockBasic extends Block
return false;
}
@Override
public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta)
{
if(ctms[meta][1] != null && MekanismUtils.isActive(world, x, y, z))
{
return ctms[meta][1];
}
return ctms[meta][0];
}
}

View file

@ -10,6 +10,7 @@ import mekanism.api.Coord4D;
import mekanism.api.ISalinationSolar;
import mekanism.api.Range4D;
import mekanism.common.Mekanism;
import mekanism.common.base.IActiveState;
import mekanism.common.content.tank.TankUpdateProtocol;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.util.MekanismUtils;
@ -26,7 +27,7 @@ import net.minecraftforge.fluids.FluidTank;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TileEntitySalinationController extends TileEntitySalinationBlock
public class TileEntitySalinationController extends TileEntitySalinationBlock implements IActiveState
{
public static final int MAX_BRINE = 10000;
public static final int MAX_SOLARS = 4;
@ -755,4 +756,28 @@ public class TileEntitySalinationController extends TileEntitySalinationBlock
{
return INFINITE_EXTENT_AABB;
}
@Override
public boolean getActive()
{
return structured;
}
@Override
public void setActive(boolean active)
{
}
@Override
public boolean renderUpdate()
{
return false;
}
@Override
public boolean lightUpdate()
{
return false;
}
}

View file

@ -1,10 +1,16 @@
package mekanism.generators.common.block;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import mekanism.api.Coord4D;
import mekanism.client.ClientProxy;
import mekanism.common.CTMData;
import mekanism.common.ItemAttacher;
import mekanism.common.Mekanism;
import mekanism.common.MekanismBlocks;
import mekanism.common.base.IBlockCTM;
import mekanism.common.tile.TileEntityBasicBlock;
import mekanism.common.tile.TileEntityElectricBlock;
import mekanism.common.util.MekanismUtils;
@ -29,15 +35,19 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.tools.IToolWrench;
import cpw.mods.fml.common.ModAPIManager;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockReactor extends BlockContainer
public class BlockReactor extends BlockContainer implements IBlockCTM
{
public IIcon[][] icons = new IIcon[16][16];
public CTMData[] ctms = new CTMData[16];
public BlockReactor()
{
super(Material.iron);
@ -63,6 +73,9 @@ public class BlockReactor extends BlockContainer
{
icons[0][0] = register.registerIcon("mekanism:ReactorGlass");
icons[1][0] = register.registerIcon("mekanism:ReactorLaserFocus");
ctms[0] = new CTMData("ctm/ReactorGlass", this, Arrays.asList(0, 1)).registerIcons(register);
ctms[1] = new CTMData("ctm/ReactorLaserFocus", this, Arrays.asList(1, 0)).registerIcons(register);
}
}
@ -253,6 +266,12 @@ public class BlockReactor extends BlockContainer
return this == GeneratorsBlocks.Reactor ? 0 : 1;
}
@Override
public int getRenderType()
{
return ClientProxy.CTM_RENDER_ID;
}
@Override
public boolean isOpaqueCube()
{
@ -280,6 +299,34 @@ public class BlockReactor extends BlockContainer
return null;
}
@Override
public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta)
{
return ctms[meta];
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side)
{
Coord4D obj = new Coord4D(x, y, z).getFromSide(ForgeDirection.getOrientation(side).getOpposite());
if(this == GeneratorsBlocks.ReactorGlass)
{
int metadata = obj.getMetadata(world);
switch(metadata)
{
case 0:
case 1:
return ctms[metadata].shouldRenderSide(world, x, y, z, side);
default:
return super.shouldSideBeRendered(world, x, y, z, side);
}
}
else {
return super.shouldSideBeRendered(world, x, y, z, side);
}
}
public static enum ReactorBlockType
{
CONTROLLER(GeneratorsBlocks.Reactor, 0, "ReactorController", 10, TileEntityReactorController.class),

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -0,0 +1,5 @@
{
"animation": {
"frametime": 10
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -0,0 +1,5 @@
{
"animation": {
"frametime": 10
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB