Add in support for rendering sides with overriden textures.
Also special facing support. Salination Plants now fully connected - the Controller texture could do with some cleaning up to improve the connected look.
This commit is contained in:
parent
b1a11b0ba2
commit
6d0f8096f0
11 changed files with 203 additions and 63 deletions
|
@ -5,9 +5,12 @@ 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;
|
||||
|
@ -32,18 +35,21 @@ public class CTMRenderingHandler implements ISimpleBlockRenderingHandler
|
|||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
CTMData blockCTM = ((IBlockCTM)block).getCTMData(meta);
|
||||
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.submap = blockCTM.submap;
|
||||
rendererCTM.submapSmall = blockCTM.submapSmall;
|
||||
rendererCTM.blockMetas = blockCTM.acceptableBlockMetas;
|
||||
rendererCTM.dataCTM = blockCTM;
|
||||
|
||||
rendererCTM.rendererOld = rendererOld;
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ 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;
|
||||
|
@ -35,10 +36,8 @@ public class RenderBlocksCTM extends RenderBlocks
|
|||
float[] R = new float[26];
|
||||
float[] G = new float[26];
|
||||
float[] B = new float[26];
|
||||
TextureSubmap submap;
|
||||
TextureSubmap submapSmall;
|
||||
CTMData dataCTM;
|
||||
RenderBlocks rendererOld;
|
||||
HashMap<Block, List<Integer>> blockMetas;
|
||||
|
||||
int bx, by, bz;
|
||||
|
||||
|
@ -104,9 +103,9 @@ public class RenderBlocksCTM extends RenderBlocks
|
|||
B[xd] = (B[d] + B[a]) / 2;
|
||||
}
|
||||
|
||||
void side(int a, int b, int c, int d, int iconIndex, boolean flip)
|
||||
void side(int a, int b, int c, int d, int iconIndex, boolean flip, int side)
|
||||
{
|
||||
IIcon icon = iconIndex >= 16 ? submapSmall.icons[iconIndex - 16] : submap.icons[iconIndex];
|
||||
IIcon icon = iconIndex >= 16 ? dataCTM.getSmallSubmap(side).icons[iconIndex - 16] : dataCTM.getSubmap(side).icons[iconIndex];
|
||||
|
||||
double u0 = icon.getMaxU();
|
||||
double u1 = icon.getMinU();
|
||||
|
@ -153,13 +152,13 @@ public class RenderBlocksCTM extends RenderBlocks
|
|||
tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMaxU(), i.getMinV());
|
||||
} else
|
||||
{
|
||||
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 4, blockMetas);
|
||||
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);
|
||||
side(23, 9, 17, 5, tex[1], false);
|
||||
side(9, 19, 4, 17, tex[3], false);
|
||||
side(14, 0, 19, 9, tex[2], false);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,13 +175,13 @@ public class RenderBlocksCTM extends RenderBlocks
|
|||
tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMinU(), i.getMinV());
|
||||
} else
|
||||
{
|
||||
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 5, blockMetas);
|
||||
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);
|
||||
side(16, 7, 21, 11, tex[2], false);
|
||||
side(25, 11, 15, 2, tex[1], false);
|
||||
side(6, 16, 11, 25, tex[0], false);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,13 +198,13 @@ public class RenderBlocksCTM extends RenderBlocks
|
|||
tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV());
|
||||
} else
|
||||
{
|
||||
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 2, blockMetas);
|
||||
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);
|
||||
side(15, 3, 18, 8, tex[2], false);
|
||||
side(8, 18, 0, 14, tex[3], false);
|
||||
side(22, 8, 14, 1, tex[1], false);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,13 +222,13 @@ public class RenderBlocksCTM extends RenderBlocks
|
|||
tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMinV());
|
||||
} else
|
||||
{
|
||||
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 3, blockMetas);
|
||||
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);
|
||||
side(5, 17, 10, 24, tex[0], false);
|
||||
side(24, 10, 16, 6, tex[1], false);
|
||||
side(10, 20, 7, 16, tex[3], false);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -246,13 +245,13 @@ public class RenderBlocksCTM extends RenderBlocks
|
|||
tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
} else
|
||||
{
|
||||
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 0, blockMetas);
|
||||
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);
|
||||
side(19, 13, 20, 4, tex[2], true);
|
||||
side(0, 18, 13, 19, tex[0], true);
|
||||
side(18, 3, 21, 13, tex[1], true);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,13 +268,13 @@ public class RenderBlocksCTM extends RenderBlocks
|
|||
tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMaxU(), i.getMinV());
|
||||
} else
|
||||
{
|
||||
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 1, blockMetas);
|
||||
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);
|
||||
side(22, 12, 25, 2, tex[1], false);
|
||||
side(1, 23, 12, 22, tex[0], false);
|
||||
side(23, 5, 24, 12, tex[2], false);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,36 +11,100 @@ 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 IIcon icon;
|
||||
|
||||
public TextureSubmap submap;
|
||||
|
||||
public TextureSubmap submapSmall;
|
||||
|
||||
public String texture;
|
||||
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)
|
||||
{
|
||||
texture = textureName;
|
||||
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)
|
||||
{
|
||||
icon = register.registerIcon("mekanism:" + texture);
|
||||
submap = new TextureSubmap(register.registerIcon("mekanism:" + texture + "-ctm"), 4, 4);
|
||||
submapSmall = new TextureSubmap(icon, 2, 2);
|
||||
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);
|
||||
|
|
31
src/main/java/mekanism/common/CTMTextureData.java
Normal file
31
src/main/java/mekanism/common/CTMTextureData.java
Normal 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -2,7 +2,10 @@ package mekanism.common.base;
|
|||
|
||||
import mekanism.common.CTMData;
|
||||
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IBlockCTM
|
||||
{
|
||||
public CTMData getCTMData(int meta);
|
||||
public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta);
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class BlockBasic extends Block implements IBlockCTM
|
|||
{
|
||||
public IIcon[][] icons = new IIcon[256][6];
|
||||
|
||||
public CTMData[] ctms = new CTMData[16];
|
||||
public CTMData[][] ctms = new CTMData[16][2];
|
||||
|
||||
public BlockBasic()
|
||||
{
|
||||
|
@ -135,17 +135,19 @@ public class BlockBasic extends Block implements IBlockCTM
|
|||
icons[14][2] = register.registerIcon("mekanism:SalinationBlock");
|
||||
icons[15][0] = register.registerIcon("mekanism:SalinationValve");
|
||||
|
||||
ctms[9] = new CTMData("ctm/DynamicTank", this, Arrays.asList(9, 11)).registerIcons(register);
|
||||
ctms[10] = new CTMData("ctm/DynamicGlass", this, Arrays.asList(10)).registerIcons(register);
|
||||
ctms[11] = new CTMData("ctm/DynamicValve", this, Arrays.asList(11, 9)).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[15] = new CTMData("ctm/SalinationValve", this, Arrays.asList(15)).addOtherBlockConnectivities(MekanismBlocks.BasicBlock2, Arrays.asList(0)).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] = new CTMData("ctm/SalinationBlock", this, Arrays.asList(0)).addOtherBlockConnectivities(MekanismBlocks.BasicBlock, Arrays.asList(15)).registerIcons(register);
|
||||
ctms[0][0] = new CTMData("ctm/SalinationBlock", this, Arrays.asList(0)).addOtherBlockConnectivities(MekanismBlocks.BasicBlock, Arrays.asList(14, 15)).registerIcons(register);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,7 +179,7 @@ public class BlockBasic extends Block implements IBlockCTM
|
|||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
return ctms[metadata].icon;
|
||||
return ctms[metadata][0].getIcon(side);
|
||||
case 14:
|
||||
TileEntitySalinationController tileEntity14 = (TileEntitySalinationController)world.getTileEntity(x, y, z);
|
||||
|
||||
|
@ -805,7 +807,7 @@ public class BlockBasic extends Block implements IBlockCTM
|
|||
Coord4D obj = new Coord4D(x, y, z).getFromSide(ForgeDirection.getOrientation(side).getOpposite());
|
||||
if(this == MekanismBlocks.BasicBlock && obj.getMetadata(world) == 10)
|
||||
{
|
||||
return ctms[10].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);
|
||||
|
@ -853,8 +855,13 @@ public class BlockBasic extends Block implements IBlockCTM
|
|||
}
|
||||
|
||||
@Override
|
||||
public CTMData getCTMData(int meta)
|
||||
public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta)
|
||||
{
|
||||
return ctms[meta];
|
||||
if(ctms[meta][1] != null && MekanismUtils.isActive(world, x, y, z))
|
||||
{
|
||||
return ctms[meta][1];
|
||||
}
|
||||
|
||||
return ctms[meta][0];
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -300,7 +300,7 @@ public class BlockReactor extends BlockContainer implements IBlockCTM
|
|||
}
|
||||
|
||||
@Override
|
||||
public CTMData getCTMData(int meta)
|
||||
public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta)
|
||||
{
|
||||
return ctms[meta];
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"animation": {
|
||||
"frametime": 10
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue