Teleporters now follow CTM

This commit is contained in:
Aidan C. Brady 2015-03-26 23:53:22 -04:00
parent 3ba0dd5172
commit a0af78ef46
9 changed files with 48 additions and 27 deletions

View file

@ -5,9 +5,11 @@ import mekanism.client.ClientProxy;
import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer;
import mekanism.common.CTMData; import mekanism.common.CTMData;
import mekanism.common.base.IBlockCTM; import mekanism.common.base.IBlockCTM;
import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.tile.TileEntityBasicBlock; import mekanism.common.tile.TileEntityBasicBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
@ -53,6 +55,28 @@ public class CTMRenderingHandler implements ISimpleBlockRenderingHandler
return rendererCTM.renderStandardBlock(block, x, y, z); return rendererCTM.renderStandardBlock(block, x, y, z);
} }
if(MachineType.get(block, meta) != null)
{
if(!MachineType.get(block, meta).hasModel)
{
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityBasicBlock)
{
if(((TileEntityBasicBlock)tile).facing >= 2)
{
rendererOld.uvRotateTop = MekanismRenderer.directionMap[((TileEntityBasicBlock)tile).facing-2];
rendererOld.uvRotateBottom = MekanismRenderer.directionMap[((TileEntityBasicBlock)tile).facing-2];
}
}
rendererOld.renderStandardBlock(block, x, y, z);
rendererOld.setRenderBoundsFromBlock(block);
return true;
}
}
return rendererOld.renderStandardBlock(block, x, y, z); return rendererOld.renderStandardBlock(block, x, y, z);
} }

View file

@ -237,29 +237,7 @@ public class MachineRenderingHandler implements ISimpleBlockRenderingHandler
@Override @Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
{ {
int metadata = world.getBlockMetadata(x, y, z); //Handled by CTMRenderingHandler
if(MachineType.get(block, metadata) != null)
{
if(!MachineType.get(block, metadata).hasModel)
{
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityBasicBlock)
{
if(((TileEntityBasicBlock)tile).facing >= 2)
{
renderer.uvRotateTop = MekanismRenderer.directionMap[((TileEntityBasicBlock)tile).facing-2];
renderer.uvRotateBottom = MekanismRenderer.directionMap[((TileEntityBasicBlock)tile).facing-2];
}
}
renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBoundsFromBlock(block);
return true;
}
}
return false; return false;
} }

View file

@ -148,6 +148,7 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon
switch(blockType) switch(blockType)
{ {
case BASIC_BLOCK_1: case BASIC_BLOCK_1:
ctms[7][0] = new CTMData("ctm/TeleporterFrame", this, Arrays.asList(7)).addOtherBlockConnectivities(MekanismBlocks.MachineBlock, Arrays.asList(11)).registerIcons(register);
ctms[9][0] = new CTMData("ctm/DynamicTank", this, Arrays.asList(9, 11)).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[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[11][0] = new CTMData("ctm/DynamicValve", this, Arrays.asList(11, 9)).registerIcons(register);
@ -166,7 +167,7 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon
MekanismRenderer.loadDynamicTextures(register, "Bin", icons[6], DefIcon.getActivePair(register.registerIcon("mekanism:BinSide"), 3, 4, 5), MekanismRenderer.loadDynamicTextures(register, "Bin", icons[6], DefIcon.getActivePair(register.registerIcon("mekanism:BinSide"), 3, 4, 5),
new DefIcon(register.registerIcon("mekanism:BinTop"), 0), new DefIcon(register.registerIcon("mekanism:BinTopOn"), 6)); new DefIcon(register.registerIcon("mekanism:BinTop"), 0), new DefIcon(register.registerIcon("mekanism:BinTopOn"), 6));
icons[7][0] = register.registerIcon("mekanism:TeleporterFrame"); icons[7][0] = ctms[7][0].mainTextureData.icon;
icons[8][0] = register.registerIcon("mekanism:SteelCasing"); icons[8][0] = register.registerIcon("mekanism:SteelCasing");
icons[9][0] = ctms[9][0].mainTextureData.icon; icons[9][0] = ctms[9][0].mainTextureData.icon;
icons[10][0] = ctms[10][0].mainTextureData.icon; icons[10][0] = ctms[10][0].mainTextureData.icon;

View file

@ -1,6 +1,7 @@
package mekanism.common.block; package mekanism.common.block;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -17,11 +18,13 @@ import mekanism.api.energy.IStrictEnergyStorage;
import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.MekanismRenderer.DefIcon; import mekanism.client.render.MekanismRenderer.DefIcon;
import mekanism.client.render.MekanismRenderer.ICustomBlockIcon; import mekanism.client.render.MekanismRenderer.ICustomBlockIcon;
import mekanism.common.CTMData;
import mekanism.common.ItemAttacher; import mekanism.common.ItemAttacher;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.MekanismBlocks; import mekanism.common.MekanismBlocks;
import mekanism.common.Tier.BaseTier; import mekanism.common.Tier.BaseTier;
import mekanism.common.base.IActiveState; import mekanism.common.base.IActiveState;
import mekanism.common.base.IBlockCTM;
import mekanism.common.base.IBoundingBlock; import mekanism.common.base.IBoundingBlock;
import mekanism.common.base.IElectricChest; import mekanism.common.base.IElectricChest;
import mekanism.common.base.IFactory; import mekanism.common.base.IFactory;
@ -156,11 +159,13 @@ import dan200.computercraft.api.peripheral.IPeripheralProvider;
* *
*/ */
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheralProvider", modid = "ComputerCraft") @Interface(iface = "dan200.computercraft.api.peripheral.IPeripheralProvider", modid = "ComputerCraft")
public class BlockMachine extends BlockContainer implements ISpecialBounds, IPeripheralProvider, ICustomBlockIcon public class BlockMachine extends BlockContainer implements ISpecialBounds, IPeripheralProvider, IBlockCTM, ICustomBlockIcon
{ {
public IIcon[][] icons = new IIcon[16][16]; public IIcon[][] icons = new IIcon[16][16];
public IIcon[][][] factoryIcons = new IIcon[4][16][16]; public IIcon[][][] factoryIcons = new IIcon[4][16][16];
public CTMData[][] ctms = new CTMData[16][4];
public IIcon BASE_ICON; public IIcon BASE_ICON;
public MachineBlock blockType; public MachineBlock blockType;
@ -184,6 +189,8 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
switch(blockType) switch(blockType)
{ {
case MACHINE_BLOCK_1: case MACHINE_BLOCK_1:
ctms[11][0] = new CTMData("ctm/Teleporter", this, Arrays.asList(11)).addOtherBlockConnectivities(MekanismBlocks.BasicBlock, Arrays.asList(7)).registerIcons(register);
MekanismRenderer.loadDynamicTextures(register, MachineType.ENRICHMENT_CHAMBER.name, icons[0], def); MekanismRenderer.loadDynamicTextures(register, MachineType.ENRICHMENT_CHAMBER.name, icons[0], def);
MekanismRenderer.loadDynamicTextures(register, MachineType.OSMIUM_COMPRESSOR.name, icons[1], def); MekanismRenderer.loadDynamicTextures(register, MachineType.OSMIUM_COMPRESSOR.name, icons[1], def);
MekanismRenderer.loadDynamicTextures(register, MachineType.COMBINER.name, icons[2], def); MekanismRenderer.loadDynamicTextures(register, MachineType.COMBINER.name, icons[2], def);
@ -210,7 +217,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
MekanismRenderer.loadDynamicTextures(register, MachineType.PURIFICATION_CHAMBER.name, icons[9], def); MekanismRenderer.loadDynamicTextures(register, MachineType.PURIFICATION_CHAMBER.name, icons[9], def);
MekanismRenderer.loadDynamicTextures(register, MachineType.ENERGIZED_SMELTER.name, icons[10], def); MekanismRenderer.loadDynamicTextures(register, MachineType.ENERGIZED_SMELTER.name, icons[10], def);
icons[11][0] = register.registerIcon("mekanism:Teleporter"); icons[11][0] = ctms[11][0].mainTextureData.icon;
break; break;
case MACHINE_BLOCK_2: case MACHINE_BLOCK_2:
MekanismRenderer.loadDynamicTextures(register, MachineType.CHEMICAL_INJECTION_CHAMBER.name, icons[3], def); MekanismRenderer.loadDynamicTextures(register, MachineType.CHEMICAL_INJECTION_CHAMBER.name, icons[3], def);
@ -710,7 +717,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
@Override @Override
public int getRenderType() public int getRenderType()
{ {
return Mekanism.proxy.MACHINE_RENDER_ID; return Mekanism.proxy.CTM_RENDER_ID;
} }
@Override @Override
@ -1382,4 +1389,15 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
return false; 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];
}
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB