diff --git a/src/main/java/mekanism/common/CTMTextureData.java b/src/main/java/mekanism/common/CTMTextureData.java deleted file mode 100644 index 6603892cd..000000000 --- a/src/main/java/mekanism/common/CTMTextureData.java +++ /dev/null @@ -1,32 +0,0 @@ -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); - } - - -*/ -} diff --git a/src/main/java/mekanism/common/base/IBlockCTM.java b/src/main/java/mekanism/common/base/IBlockCTM.java deleted file mode 100644 index 8ed25f71c..000000000 --- a/src/main/java/mekanism/common/base/IBlockCTM.java +++ /dev/null @@ -1,10 +0,0 @@ -package mekanism.common.base; - -import net.minecraft.world.IBlockAccess; - -public interface IBlockCTM -{ - //public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta); - - public boolean shouldRenderBlock(IBlockAccess world, int x, int y, int z, int meta); -} diff --git a/src/main/java/mekanism/common/block/BlockBasic.java b/src/main/java/mekanism/common/block/BlockBasic.java index a62ef6fbd..e393d8e60 100644 --- a/src/main/java/mekanism/common/block/BlockBasic.java +++ b/src/main/java/mekanism/common/block/BlockBasic.java @@ -130,12 +130,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock//TODO? imple @Override public BlockState createBlockState() { - return new BlockStateBasic(this, getProperty()); - } - - public PropertyEnum getProperty() - { - return getBasicBlock().getProperty(); + return new BlockStateBasic(this, getTypeProperty()); } @Override @@ -143,13 +138,13 @@ public abstract class BlockBasic extends Block implements ICTMBlock//TODO? imple { BlockStateBasic.BasicBlockType type = BlockStateBasic.BasicBlockType.get(getBasicBlock(), meta&0xF); - return getDefaultState().withProperty(getProperty(), type); + return getDefaultState().withProperty(getTypeProperty(), type); } @Override public int getMetaFromState(IBlockState state) { - BlockStateBasic.BasicBlockType type = state.getValue(getProperty()); + BlockStateBasic.BasicBlockType type = state.getValue(getTypeProperty()); return type.meta; } diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index 24e8dad45..0a41cb36e 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -130,7 +130,7 @@ import buildcraft.api.tools.IToolWrench; * @author AidanBrady * */ -public abstract class BlockMachine extends BlockContainer implements ISpecialBounds, ICTMBlock//, ICustomBlockIcon +public abstract class BlockMachine extends BlockContainer implements ISpecialBounds, ICTMBlock { public CTMData[][] ctmData = new CTMData[16][4]; @@ -173,14 +173,10 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou return state.withProperty(BlockStateBasic.ctmProperty, ctx); } + @Override public BlockState createBlockState() { - return new BlockStateMachine(this, getProperty()); - } - - public PropertyEnum getProperty() - { - return getMachineBlock().getProperty(); + return new BlockStateMachine(this, getTypeProperty()); } @Override @@ -188,13 +184,13 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou { MachineType type = MachineType.get(getMachineBlock(), meta & 0xF); - return getDefaultState().withProperty(getProperty(), type); + return getDefaultState().withProperty(getTypeProperty(), type); } @Override public int getMetaFromState(IBlockState state) { - MachineType type = state.getValue(getProperty()); + MachineType type = state.getValue(getTypeProperty()); return type.meta; } @@ -399,7 +395,7 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou @SideOnly(Side.CLIENT) public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) { - for(MachineType type : BlockStateMachine.MachineType.getValidMachines()) + for(MachineType type : MachineType.getValidMachines()) { if(type.typeBlock == getMachineBlock() && type.isEnabled()) { @@ -510,7 +506,7 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou if(tileEntity != null) { - MachineType type = BlockStateMachine.MachineType.get(getMachineBlock(), metadata); + MachineType type = MachineType.get(getMachineBlock(), metadata); switch(type) { @@ -615,12 +611,12 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou { int metadata = getMetaFromState(state); - if(BlockStateMachine.MachineType.get(getMachineBlock(), metadata) == null) + if(MachineType.get(getMachineBlock(), metadata) == null) { return null; } - return BlockStateMachine.MachineType.get(getMachineBlock(), metadata).create(); + return MachineType.get(getMachineBlock(), metadata).create(); } @Override @@ -666,7 +662,7 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) { IBlockState state = world.getBlockState(pos); - if(BlockStateMachine.MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)) != BlockStateMachine.MachineType.PERSONAL_CHEST) + if(MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)) != MachineType.PERSONAL_CHEST) { return blockResistance; } @@ -945,7 +941,7 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou public boolean canConnectRedstone(IBlockAccess world, BlockPos pos, EnumFacing side) { IBlockState state = world.getBlockState(pos); - MachineType type = BlockStateMachine.MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)); + MachineType type = MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)); switch(type) { @@ -981,7 +977,7 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos) { IBlockState state = world.getBlockState(pos); - MachineType type = BlockStateMachine.MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)); + MachineType type = MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)); switch(type) { @@ -1020,7 +1016,7 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou public boolean isSideSolid(IBlockAccess world, BlockPos pos, EnumFacing side) { IBlockState state = world.getBlockState(pos); - MachineType type = BlockStateMachine.MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)); + MachineType type = MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)); switch(type) { diff --git a/src/main/java/mekanism/common/block/states/BlockStateBasic.java b/src/main/java/mekanism/common/block/states/BlockStateBasic.java index f356dff36..b2cebc522 100644 --- a/src/main/java/mekanism/common/block/states/BlockStateBasic.java +++ b/src/main/java/mekanism/common/block/states/BlockStateBasic.java @@ -138,7 +138,7 @@ public class BlockStateBasic extends ExtendedBlockState { if(state.getBlock() instanceof BlockBasic) { - return state.getValue(((BlockBasic)state.getBlock()).getProperty()); + return state.getValue(((BlockBasic)state.getBlock()).getTypeProperty()); } return null; @@ -244,7 +244,7 @@ public class BlockStateBasic extends ExtendedBlockState protected ModelResourceLocation getModelResourceLocation(IBlockState state) { BlockBasic block = (BlockBasic)state.getBlock(); - BasicBlockType type = state.getValue(block.getProperty()); + BasicBlockType type = state.getValue(block.getTypeProperty()); StringBuilder builder = new StringBuilder(); String nameOverride = null; diff --git a/src/main/java/mekanism/common/block/states/BlockStateMachine.java b/src/main/java/mekanism/common/block/states/BlockStateMachine.java index 55247b14f..ff97aadc8 100644 --- a/src/main/java/mekanism/common/block/states/BlockStateMachine.java +++ b/src/main/java/mekanism/common/block/states/BlockStateMachine.java @@ -418,7 +418,7 @@ public class BlockStateMachine extends ExtendedBlockState protected ModelResourceLocation getModelResourceLocation(IBlockState state) { BlockMachine block = (BlockMachine)state.getBlock(); - MachineType type = state.getValue(block.getProperty()); + MachineType type = state.getValue(block.getTypeProperty()); StringBuilder builder = new StringBuilder(); String nameOverride = null; diff --git a/src/main/java/mekanism/common/content/tank/TankUpdateProtocol.java b/src/main/java/mekanism/common/content/tank/TankUpdateProtocol.java index 719899cec..94d19c759 100644 --- a/src/main/java/mekanism/common/content/tank/TankUpdateProtocol.java +++ b/src/main/java/mekanism/common/content/tank/TankUpdateProtocol.java @@ -31,7 +31,7 @@ public class TankUpdateProtocol extends UpdateProtocol protected boolean isValidFrame(int x, int y, int z) { IBlockState state = pointer.getWorld().getBlockState(new BlockPos(x, y, z)); - return state.getBlock() == MekanismBlocks.BasicBlock && state.getValue(((BlockBasic)state.getBlock()).getProperty()) == BasicBlockType.DYNAMIC_TANK; + return state.getBlock() == MekanismBlocks.BasicBlock && state.getValue(((BlockBasic)state.getBlock()).getTypeProperty()) == BasicBlockType.DYNAMIC_TANK; } @Override diff --git a/src/main/java/mekanism/common/item/ItemBlockOre.java b/src/main/java/mekanism/common/item/ItemBlockOre.java index 094d07fee..16b71a1b5 100644 --- a/src/main/java/mekanism/common/item/ItemBlockOre.java +++ b/src/main/java/mekanism/common/item/ItemBlockOre.java @@ -53,14 +53,6 @@ public class ItemBlockOre extends ItemBlock return i; } -/* - @Override - public IIcon getIconFromDamage(int i) - { - return metaBlock.getIcon(2, i); - } -*/ - @Override public String getUnlocalizedName(ItemStack itemstack) { diff --git a/src/main/java/mekanism/generators/client/GeneratorsClientProxy.java b/src/main/java/mekanism/generators/client/GeneratorsClientProxy.java index 7c5c53061..b2aa8cc23 100644 --- a/src/main/java/mekanism/generators/client/GeneratorsClientProxy.java +++ b/src/main/java/mekanism/generators/client/GeneratorsClientProxy.java @@ -42,6 +42,7 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.event.TextureStitchEvent; @@ -88,9 +89,9 @@ public class GeneratorsClientProxy extends GeneratorsCommonProxy } @Override - public GuiScreen getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) + public GuiScreen getClientGui(int ID, EntityPlayer player, World world, BlockPos pos) { - TileEntity tileEntity = world.getTileEntity(x, y, z); + TileEntity tileEntity = world.getTileEntity(pos); switch(ID) { diff --git a/src/main/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java b/src/main/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java index 471e665a9..5263e9edc 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java +++ b/src/main/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java @@ -12,6 +12,7 @@ import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiRateBar; import mekanism.client.gui.element.GuiRateBar.IRateInfoHandler; import mekanism.client.render.MekanismRenderer; +import mekanism.client.render.MekanismRenderer.FluidType; import mekanism.common.inventory.container.ContainerFilter; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; @@ -141,7 +142,7 @@ public class GuiIndustrialTurbine extends GuiMekanism } mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining)); + drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, MekanismRenderer.getFluidTexture(fluid.getFluid(), FluidType.STILL), 16, 16 - (16 - renderRemaining)); start+=16; if(renderRemaining == 0 || scale == 0) diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java b/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java index ee0479c20..2ecc9b1e0 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java @@ -1,5 +1,6 @@ package mekanism.generators.client.gui; +import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -144,7 +145,7 @@ public class GuiReactorFuel extends GuiMekanism } @Override - public void mouseClicked(int mouseX, int mouseY, int button) + public void mouseClicked(int mouseX, int mouseY, int button) throws IOException { super.mouseClicked(mouseX, mouseY, button); @@ -164,7 +165,7 @@ public class GuiReactorFuel extends GuiMekanism } @Override - public void keyTyped(char c, int i) + public void keyTyped(char c, int i) throws IOException { if(!injectionRateField.isFocused() || i == Keyboard.KEY_ESCAPE) { @@ -212,7 +213,7 @@ public class GuiReactorFuel extends GuiMekanism String prevRad = injectionRateField != null ? injectionRateField.getText() : ""; - injectionRateField = new GuiTextField(fontRendererObj, guiWidth + 98, guiHeight + 115, 26, 11); + injectionRateField = new GuiTextField(0, fontRendererObj, guiWidth + 98, guiHeight + 115, 26, 11); injectionRateField.setMaxStringLength(2); injectionRateField.setText(prevRad); } diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java b/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java index ae6270dcf..c5ee86ad4 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java @@ -21,6 +21,8 @@ import mekanism.client.gui.element.GuiNumberGauge.INumberInfoHandler; import mekanism.client.gui.element.GuiProgress; import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; import mekanism.client.gui.element.GuiProgress.ProgressBar; +import mekanism.client.render.MekanismRenderer; +import mekanism.client.render.MekanismRenderer.FluidType; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; import mekanism.common.inventory.container.ContainerNull; @@ -32,7 +34,9 @@ import mekanism.generators.client.gui.element.GuiFuelTab; import mekanism.generators.client.gui.element.GuiStatTab; import mekanism.generators.common.tile.reactor.TileEntityReactorController; import net.minecraft.block.BlockStaticLiquid; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -61,9 +65,9 @@ public class GuiReactorHeat extends GuiMekanism guiElements.add(new GuiNumberGauge(new INumberInfoHandler() { @Override - public IIcon getIcon() + public TextureAtlasSprite getIcon() { - return BlockStaticLiquid.getLiquidIcon("lava_still"); + return MekanismRenderer.getFluidTexture(FluidRegistry.LAVA, FluidType.STILL); } @Override @@ -95,9 +99,9 @@ public class GuiReactorHeat extends GuiMekanism guiElements.add(new GuiNumberGauge(new INumberInfoHandler() { @Override - public IIcon getIcon() + public TextureAtlasSprite getIcon() { - return BlockStaticLiquid.getLiquidIcon("lava_still"); + return MekanismRenderer.getFluidTexture(FluidRegistry.LAVA, FluidType.STILL); } @Override diff --git a/src/main/java/mekanism/generators/client/render/RenderIndustrialTurbine.java b/src/main/java/mekanism/generators/client/render/RenderIndustrialTurbine.java index e61829d1b..308b864bc 100644 --- a/src/main/java/mekanism/generators/client/render/RenderIndustrialTurbine.java +++ b/src/main/java/mekanism/generators/client/render/RenderIndustrialTurbine.java @@ -6,6 +6,7 @@ import java.util.Map; import mekanism.api.Coord4D; import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer.DisplayInteger; +import mekanism.client.render.MekanismRenderer.FluidType; import mekanism.client.render.MekanismRenderer.Model3D; import mekanism.client.render.tileentity.RenderDynamicTank.RenderData; import mekanism.common.content.tank.TankUpdateProtocol; @@ -139,14 +140,14 @@ public class RenderIndustrialTurbine extends TileEntitySpecialRenderer Model3D toReturn = new Model3D(); toReturn.baseBlock = Blocks.water; - toReturn.setTexture(STEAM.getIcon()); + toReturn.setTexture(MekanismRenderer.getFluidTexture(STEAM, FluidType.STILL)); final int stages = getStages(data.height); DisplayInteger display = DisplayInteger.createAndStart(); cachedFluids.put(data, display); - if(STEAM.getIcon() != null) + if(STEAM.getStill() != null) { toReturn.minX = 0 + .01; toReturn.minY = 0 + .01; diff --git a/src/main/java/mekanism/generators/common/GeneratorsBlocks.java b/src/main/java/mekanism/generators/common/GeneratorsBlocks.java index d1806b3df..0a7422101 100644 --- a/src/main/java/mekanism/generators/common/GeneratorsBlocks.java +++ b/src/main/java/mekanism/generators/common/GeneratorsBlocks.java @@ -1,5 +1,7 @@ package mekanism.generators.common; +import static mekanism.generators.common.block.states.BlockStateReactor.ReactorBlock.REACTOR_BLOCK; +import static mekanism.generators.common.block.states.BlockStateReactor.ReactorBlock.REACTOR_GLASS; import mekanism.generators.common.block.BlockGenerator; import mekanism.generators.common.block.BlockReactor; import mekanism.generators.common.item.ItemBlockGenerator; @@ -12,8 +14,8 @@ import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; public class GeneratorsBlocks { public static final Block Generator = new BlockGenerator().setUnlocalizedName("Generator"); - public static final Block Reactor = new BlockReactor().setUnlocalizedName("Reactor"); - public static final Block ReactorGlass = new BlockReactor().setUnlocalizedName("ReactorGlass"); + public static final Block Reactor = BlockReactor.getReactorBlock(REACTOR_BLOCK).setUnlocalizedName("Reactor"); + public static final Block ReactorGlass = BlockReactor.getReactorBlock(REACTOR_GLASS).setUnlocalizedName("ReactorGlass"); public static void register() { diff --git a/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java b/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java index 46c3ede49..5c78dafcc 100644 --- a/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java +++ b/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java @@ -34,8 +34,8 @@ import mekanism.generators.common.tile.turbine.TileEntityTurbineVent; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.registry.GameRegistry; /** @@ -45,8 +45,6 @@ import net.minecraftforge.fml.common.registry.GameRegistry; */ public class GeneratorsCommonProxy implements IGuiProvider { - public static int GENERATOR_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); - /** * Register normal tile entities */ @@ -123,15 +121,15 @@ public class GeneratorsCommonProxy implements IGuiProvider } @Override - public Object getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) + public Object getClientGui(int ID, EntityPlayer player, World world, BlockPos pos) { return null; } @Override - public Container getServerGui(int ID, EntityPlayer player, World world, int x, int y, int z) + public Container getServerGui(int ID, EntityPlayer player, World world, BlockPos pos) { - TileEntity tileEntity = world.getTileEntity(x, y, z); + TileEntity tileEntity = world.getTileEntity(pos); switch(ID) { diff --git a/src/main/java/mekanism/generators/common/GeneratorsGuiHandler.java b/src/main/java/mekanism/generators/common/GeneratorsGuiHandler.java index 507d92ec7..df51274e1 100644 --- a/src/main/java/mekanism/generators/common/GeneratorsGuiHandler.java +++ b/src/main/java/mekanism/generators/common/GeneratorsGuiHandler.java @@ -1,6 +1,7 @@ package mekanism.generators.common; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; @@ -15,12 +16,12 @@ public class GeneratorsGuiHandler implements IGuiHandler @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - return MekanismGenerators.proxy.getServerGui(ID, player, world, x, y, z); + return MekanismGenerators.proxy.getServerGui(ID, player, world, new BlockPos(x, y, z)); } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - return MekanismGenerators.proxy.getClientGui(ID, player, world, x, y, z); + return MekanismGenerators.proxy.getClientGui(ID, player, world, new BlockPos(x, y, z)); } } diff --git a/src/main/java/mekanism/generators/common/block/BlockGenerator.java b/src/main/java/mekanism/generators/common/block/BlockGenerator.java index 1138cba24..1fcc8fe0a 100644 --- a/src/main/java/mekanism/generators/common/block/BlockGenerator.java +++ b/src/main/java/mekanism/generators/common/block/BlockGenerator.java @@ -8,9 +8,9 @@ import mekanism.api.MekanismConfig.client; import mekanism.api.MekanismConfig.general; import mekanism.api.energy.IEnergizedItem; import mekanism.client.render.ctm.CTMData; +import mekanism.client.render.ctm.ICTMBlock; import mekanism.common.Mekanism; import mekanism.common.base.IActiveState; -import mekanism.common.base.IBlockCTM; import mekanism.common.base.IBoundingBlock; import mekanism.common.base.ISpecialBounds; import mekanism.common.base.ISustainedData; @@ -82,14 +82,10 @@ import codechicken.lib.render.TextureUtils.IIconRegister; * @author AidanBrady * */ -public class BlockGenerator extends BlockContainer implements ISpecialBounds, IBlockCTM +public class BlockGenerator extends BlockContainer implements ISpecialBounds, ICTMBlock { - public IIcon[][] icons = new IIcon[16][16]; - public CTMData[] ctms = new CTMData[16]; - public IIcon BASE_ICON; - public Random machineRand = new Random(); public BlockGenerator() @@ -122,23 +118,17 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IB } @Override - public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta) + public CTMData getCTMData(IBlockState state) { return ctms[meta]; } - @Override - public boolean shouldRenderBlock(IBlockAccess world, int x, int y, int z, int meta) - { - return !GeneratorType.getFromMetadata(meta).hasModel; - } - @Override public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos pos, IBlockState state) { setBlockBoundsBasedOnState(world, pos); - return super.getCollisionBoundingBox(world, pos); + return super.getCollisionBoundingBox(world, pos, state); } @Override @@ -167,11 +157,11 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IB } @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) + public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock) { if(!world.isRemote) { - TileEntity tileEntity = world.getTileEntity(x, y, z); + TileEntity tileEntity = world.getTileEntity(pos); if(tileEntity instanceof IMultiblock) { @@ -180,7 +170,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IB if(tileEntity instanceof TileEntityBasicBlock) { - ((TileEntityBasicBlock)tileEntity).onNeighborChange(block); + ((TileEntityBasicBlock)tileEntity).onNeighborChange(neighborBlock); } } } @@ -299,7 +289,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IB world.spawnParticle(EnumParticleTypes.FLAME, (double)(xRandom + iRandom), (double)yRandom, (double)(zRandom - jRandom), 0.0D, 0.0D, 0.0D); break; case BIO_GENERATOR: - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, x+.25, y+.2, z+.5, 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX()+.25, pos.getY()+.2, pos.getZ()+.5, 0.0D, 0.0D, 0.0D); break; default: break; @@ -314,7 +304,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IB world.spawnParticle(EnumParticleTypes.FLAME, (double)(xRandom + iRandom), (double)yRandom + 0.5F, (double)(zRandom - jRandom), 0.0D, 0.0D, 0.0D); break; case BIO_GENERATOR: - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, x+.75, y+.2, z+.5, 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX()+.75, pos.getY()+.2, pos.getZ()+.5, 0.0D, 0.0D, 0.0D); break; default: break; @@ -329,7 +319,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IB world.spawnParticle(EnumParticleTypes.FLAME, (double)(xRandom - jRandom), (double)yRandom + 0.5F, (double)(zRandom - iRandom), 0.0D, 0.0D, 0.0D); break; case BIO_GENERATOR: - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, x+.5, y+.2, z+.25, 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX()+.5, pos.getY()+.2, pos.getZ()+.25, 0.0D, 0.0D, 0.0D); break; default: break; @@ -344,7 +334,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IB world.spawnParticle(EnumParticleTypes.FLAME, (double)(xRandom - jRandom), (double)yRandom + 0.5F, (double)(zRandom + iRandom), 0.0D, 0.0D, 0.0D); break; case BIO_GENERATOR: - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, x+.5, y+.2, z+.75, 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX()+.5, pos.getY()+.2, pos.getZ()+.75, 0.0D, 0.0D, 0.0D); break; default: break; @@ -369,7 +359,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IB { for(int zPos=-1;zPos<=1;zPos++) { - nonAir |= world.isAirBlock(x+xPos, y+2, z+zPos); + nonAir |= world.isAirBlock(pos.add(xPos, 2, zPos)); } } @@ -383,7 +373,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IB for(int yPos = pos.getY()+1; yPos <= pos.getY()+4; yPos++) { - nonAir |= world.isAirBlock(x, yPos, z); + nonAir |= world.isAirBlock(pos.add(0, yPos, 0)); } return (!nonAir) && canPlace; @@ -437,20 +427,20 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IB { Item tool = entityplayer.getCurrentEquippedItem().getItem(); - if(MekanismUtils.hasUsableWrench(entityplayer, x, y, z)) + if(MekanismUtils.hasUsableWrench(entityplayer, pos)) { if(SecurityUtils.canAccess(entityplayer, tileEntity)) { if(entityplayer.isSneaking()) { - dismantleBlock(world, x, y, z, false); + dismantleBlock(world, pos, false); return true; } if(MekanismUtils.isBCWrench(tool)) { - ((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z); + ((IToolWrench)tool).wrenchUsed(entityplayer, pos); } int change = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()][tileEntity.facing]; @@ -468,7 +458,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IB if(metadata == GeneratorType.TURBINE_CASING.meta || metadata == GeneratorType.TURBINE_VALVE.meta || metadata == GeneratorType.TURBINE_VENT.meta) { - return ((IMultiblock)world.getTileEntity(x, y, z)).onActivate(entityplayer); + return ((IMultiblock)tileEntity).onActivate(entityplayer); } if(metadata == GeneratorType.TURBINE_ROTOR.meta) @@ -539,7 +529,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IB { if(SecurityUtils.canAccess(entityplayer, tileEntity)) { - entityplayer.openGui(MekanismGenerators.instance, guiId, world, x, y, z); + entityplayer.openGui(MekanismGenerators.instance, guiId, world, pos.getX(), pos.getY(), pos.getZ()); } else { SecurityUtils.displayNoAccess(entityplayer); @@ -577,22 +567,16 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IB return null; } - @Override - public boolean rendersAsNormalBlock() - { - return false; - } - @Override public boolean isOpaqueCube() { return false; } - + @Override - public int getRenderType() + public boolean isFullCube() { - return Mekanism.proxy.CTM_RENDER_ID; + return false; } /*This method is not used, metadata manipulation is required to create a Tile Entity.*/ @@ -603,7 +587,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IB } @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) + public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos) { int metadata = world.getBlockMetadata(x, y, z); @@ -619,20 +603,6 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IB setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } } - - @Override - public void onBlockAdded(World world, int x, int y, int z) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if(!world.isRemote) - { - if(tileEntity instanceof TileEntityBasicBlock) - { - ((TileEntityBasicBlock)tileEntity).onAdded(); - } - } - } @Override public boolean removedByPlayer(World world, BlockPos pos, EntityPlayer player, boolean willHarvest) @@ -658,7 +628,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IB TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos); ItemStack itemStack = new ItemStack(GeneratorsBlocks.Generator, 1, world.getBlockMetadata(pos)); - if(itemStack.stackTagCompound == null) + if(itemStack.getTagCompound() == null) { itemStack.setTagCompound(new NBTTagCompound()); } diff --git a/src/main/java/mekanism/generators/common/block/BlockReactor.java b/src/main/java/mekanism/generators/common/block/BlockReactor.java index d0db075be..8b335dacc 100644 --- a/src/main/java/mekanism/generators/common/block/BlockReactor.java +++ b/src/main/java/mekanism/generators/common/block/BlockReactor.java @@ -3,44 +3,44 @@ package mekanism.generators.common.block; import java.util.Arrays; import java.util.List; -import mekanism.api.Coord4D; +import mekanism.client.render.ctm.CTMBlockRenderContext; import mekanism.client.render.ctm.CTMData; +import mekanism.client.render.ctm.ICTMBlock; import mekanism.common.Mekanism; -import mekanism.common.base.IBlockCTM; +import mekanism.common.block.states.BlockStateBasic; import mekanism.common.tile.TileEntityBasicBlock; import mekanism.common.tile.TileEntityElectricBlock; -import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.generators.common.GeneratorsBlocks; import mekanism.generators.common.MekanismGenerators; +import mekanism.generators.common.block.states.BlockStateReactor; +import mekanism.generators.common.block.states.BlockStateReactor.ReactorBlock; +import mekanism.generators.common.block.states.BlockStateReactor.ReactorBlockType; import mekanism.generators.common.tile.reactor.TileEntityReactorController; -import mekanism.generators.common.tile.reactor.TileEntityReactorFrame; -import mekanism.generators.common.tile.reactor.TileEntityReactorGlass; -import mekanism.generators.common.tile.reactor.TileEntityReactorLaserFocusMatrix; import mekanism.generators.common.tile.reactor.TileEntityReactorLogicAdapter; -import mekanism.generators.common.tile.reactor.TileEntityReactorNeutronCapture; -import mekanism.generators.common.tile.reactor.TileEntityReactorPort; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import buildcraft.api.tools.IToolWrench; import codechicken.lib.render.TextureUtils.IIconRegister; -public class BlockReactor extends BlockContainer implements IBlockCTM +public abstract class BlockReactor extends BlockContainer implements ICTMBlock { - public IIcon[][] icons = new IIcon[16][16]; - public CTMData[][] ctms = new CTMData[16][2]; public BlockReactor() @@ -50,6 +50,35 @@ public class BlockReactor extends BlockContainer implements IBlockCTM setResistance(8F); setCreativeTab(Mekanism.tabMekanism); } + + public static BlockReactor getReactorBlock(ReactorBlock block) + { + return new BlockReactor() + { + @Override + public ReactorBlock getReactorBlock() + { + return block; + } + }; + } + + public abstract ReactorBlock getReactorBlock(); + + @SideOnly(Side.CLIENT) + @Override + public IBlockState getExtendedState(IBlockState stateIn, IBlockAccess w, BlockPos pos) + { + if(stateIn.getBlock() == null || stateIn.getBlock().getMaterial() == Material.air) + { + return stateIn; + } + + IExtendedBlockState state = (IExtendedBlockState)stateIn; + CTMBlockRenderContext ctx = new CTMBlockRenderContext(w, pos); + + return state.withProperty(BlockStateBasic.ctmProperty, ctx); + } @Override @SideOnly(Side.CLIENT) @@ -141,29 +170,29 @@ public class BlockReactor extends BlockContainer implements IBlockCTM } @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) + public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock) { if(!world.isRemote) { - TileEntity tileEntity = world.getTileEntity(x, y, z); + TileEntity tileEntity = world.getTileEntity(pos); if(tileEntity instanceof TileEntityBasicBlock) { - ((TileEntityBasicBlock)tileEntity).onNeighborChange(block); + ((TileEntityBasicBlock)tileEntity).onNeighborChange(neighborBlock); } } } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ) + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumFacing facing, float playerX, float playerY, float playerZ) { if(world.isRemote) { return true; } - TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getTileEntity(x, y, z); - int metadata = world.getBlockMetadata(x, y, z); + TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getTileEntity(pos); + int metadata = state.getBlock().getMetaFromState(state); if(entityplayer.getCurrentEquippedItem() != null) { @@ -171,32 +200,12 @@ public class BlockReactor extends BlockContainer implements IBlockCTM { if(entityplayer.isSneaking()) { - dismantleBlock(world, x, y, z, false); + dismantleBlock(world, pos, false); return true; } - ((IToolWrench)entityplayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityplayer, x, y, z); + ((IToolWrench)entityplayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityplayer, pos); - int change = 0; - - switch(tileEntity.facing) - { - case 3: - change = 5; - break; - case 5: - change = 2; - break; - case 2: - change = 4; - break; - case 4: - change = 3; - break; - } - - tileEntity.setFacing((short)change); - world.notifyBlocksOfNeighborChange(x, y, z, this); return true; } } @@ -205,7 +214,7 @@ public class BlockReactor extends BlockContainer implements IBlockCTM { if(!entityplayer.isSneaking()) { - entityplayer.openGui(MekanismGenerators.instance, ReactorBlockType.get(this, metadata).guiId, world, x, y, z); + entityplayer.openGui(MekanismGenerators.instance, ReactorBlockType.get(this, metadata).guiId, world, pos.getX(), pos.getY(), pos.getZ()); return true; } } @@ -214,7 +223,7 @@ public class BlockReactor extends BlockContainer implements IBlockCTM { if(!entityplayer.isSneaking()) { - entityplayer.openGui(MekanismGenerators.instance, ReactorBlockType.get(this, metadata).guiId, world, x, y, z); + entityplayer.openGui(MekanismGenerators.instance, BlockStateReactor.ReactorBlockType.get(this, metadata).guiId, world, pos.getX(), pos.getY(), pos.getZ()); return true; } } @@ -226,9 +235,9 @@ public class BlockReactor extends BlockContainer implements IBlockCTM @SideOnly(Side.CLIENT) public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) { - for(ReactorBlockType type : ReactorBlockType.values()) + for(BlockStateReactor.ReactorBlockType type : BlockStateReactor.ReactorBlockType.values()) { - if(type.typeBlock == this && type != ReactorBlockType.NEUTRON_CAPTURE) + if(type.blockType == getReactorBlock() && type.isValidReactorBlock()) { list.add(new ItemStack(item, 1, type.meta)); } @@ -236,34 +245,28 @@ public class BlockReactor extends BlockContainer implements IBlockCTM } @Override - public TileEntity createTileEntity(World world, int metadata) + public TileEntity createTileEntity(World world, IBlockState state) { - ReactorBlockType type = ReactorBlockType.get(this, metadata); - - if(type != null) + int metadata = getMetaFromState(state); + + if(ReactorBlockType.get(getReactorBlock(), metadata) == null) { - return type.create(); + return null; } - return null; - } - - @Override - public boolean renderAsNormalBlock() - { - return false; + return ReactorBlockType.get(getReactorBlock(), metadata).create(); } @Override - public int getRenderBlockPass() + public EnumWorldBlockLayer getBlockLayer() { - return this == GeneratorsBlocks.Reactor ? 0 : 1; + return this == GeneratorsBlocks.Reactor ? EnumWorldBlockLayer.CUTOUT : EnumWorldBlockLayer.TRANSLUCENT; } @Override public int getRenderType() { - return Mekanism.proxy.CTM_RENDER_ID; + return 3; } @Override @@ -273,17 +276,9 @@ public class BlockReactor extends BlockContainer implements IBlockCTM } @Override - public void onBlockAdded(World world, int x, int y, int z) + public boolean isFullCube() { - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if(!world.isRemote) - { - if(tileEntity instanceof TileEntityBasicBlock) - { - ((TileEntityBasicBlock)tileEntity).onAdded(); - } - } + return false; } /*This method is not used, metadata manipulation is required to create a Tile Entity.*/ @@ -303,41 +298,36 @@ public class BlockReactor extends BlockContainer implements IBlockCTM return ctms[meta][0]; } - - @Override - public boolean shouldRenderBlock(IBlockAccess world, int x, int y, int z, int meta) - { - return true; - } @Override @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) + public boolean shouldSideBeRendered(IBlockAccess world, BlockPos pos, EnumFacing side) { - Coord4D obj = new Coord4D(x, y, z).offset(EnumFacing.getFront(side).getOpposite()); + BlockPos offsetPos = pos.offset(side.getOpposite()); if(this == GeneratorsBlocks.ReactorGlass) { - int metadata = obj.getBlockState(world); + IBlockState state = world.getBlockState(offsetPos); + int metadata = state.getBlock().getMetaFromState(state); switch(metadata) { case 0: case 1: - return ctms[metadata][0].shouldRenderSide(world, x, y, z, side); + return ctms[metadata][0].shouldRenderSide(world, pos, side); default: - return super.shouldSideBeRendered(world, x, y, z, side); + return super.shouldSideBeRendered(world, pos, side); } } else { - return super.shouldSideBeRendered(world, x, y, z, side); + return super.shouldSideBeRendered(world, pos, side); } } @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) + public int getWeakPower(IBlockAccess world, BlockPos pos, IBlockState state, EnumFacing side) { - TileEntity tile = world.getTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(pos); if(tile instanceof TileEntityReactorLogicAdapter) { @@ -348,15 +338,16 @@ public class BlockReactor extends BlockContainer implements IBlockCTM } @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, EnumFacing side) + public boolean isSideSolid(IBlockAccess world, BlockPos pos, EnumFacing side) { - ReactorBlockType type = ReactorBlockType.get(this, world.getBlockMetadata(x, y, z)); + IBlockState state = world.getBlockState(pos); + ReactorBlockType type = ReactorBlockType.get(getReactorBlock(), state.getBlock().getMetaFromState(state)); switch(type) { - case FRAME: - case PORT: - case ADAPTER: + case REACTOR_FRAME: + case REACTOR_PORT: + case REACTOR_LOGIC_ADAPTER: return true; default: return false; @@ -364,89 +355,26 @@ public class BlockReactor extends BlockContainer implements IBlockCTM } @Override - public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) + public boolean canConnectRedstone(IBlockAccess world, BlockPos pos, EnumFacing side) { - ReactorBlockType type = ReactorBlockType.get(this, world.getBlockMetadata(x, y, z)); + IBlockState state = world.getBlockState(pos); + ReactorBlockType type = BlockStateReactor.ReactorBlockType.get(this, state.getBlock().getMetaFromState(state)); switch(type) { - case ADAPTER: + case REACTOR_LOGIC_ADAPTER: return true; default: return false; } } - public static enum ReactorBlockType + public ItemStack dismantleBlock(World world, BlockPos pos, boolean returnBlock) { - CONTROLLER(GeneratorsBlocks.Reactor, 0, "ReactorController", 10, TileEntityReactorController.class), - FRAME(GeneratorsBlocks.Reactor, 1, "ReactorFrame", -1, TileEntityReactorFrame.class), - NEUTRON_CAPTURE(GeneratorsBlocks.Reactor, 2, "ReactorNeutronCapturePlate", 14, TileEntityReactorNeutronCapture.class), - PORT(GeneratorsBlocks.Reactor, 3, "ReactorPort", -1, TileEntityReactorPort.class), - ADAPTER(GeneratorsBlocks.Reactor, 4, "ReactorLogicAdapter", 15, TileEntityReactorLogicAdapter.class), - GLASS(GeneratorsBlocks.ReactorGlass, 0, "ReactorGlass", -1, TileEntityReactorGlass.class), - LASER_FOCUS_MATRIX(GeneratorsBlocks.ReactorGlass, 1, "ReactorLaserFocusMatrix", -1, TileEntityReactorLaserFocusMatrix.class); + IBlockState state = world.getBlockState(pos); + ItemStack itemStack = new ItemStack(this, 1, state.getBlock().getMetaFromState(state)); - public Block typeBlock; - public int meta; - public String name; - public int guiId; - public Class tileEntityClass; - - private ReactorBlockType(Block b, int i, String s, int j, Class tileClass) - { - typeBlock = b; - meta = i; - name = s; - guiId = j; - tileEntityClass = tileClass; - } - - public static ReactorBlockType get(Block block, int meta) - { - for(ReactorBlockType type : values()) - { - if(type.typeBlock == block && type.meta == meta) - { - return type; - } - } - - return null; - } - - public static ReactorBlockType get(ItemStack stack) - { - return get(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage()); - } - - public TileEntity create() - { - try { - return tileEntityClass.newInstance(); - } catch(Exception e) { - Mekanism.logger.error("Unable to indirectly create tile entity."); - e.printStackTrace(); - return null; - } - } - - public String getDescription() - { - return LangUtils.localize("tooltip." + name); - } - - public ItemStack getStack() - { - return new ItemStack(typeBlock, 1, meta); - } - } - - public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) - { - ItemStack itemStack = new ItemStack(this, 1, world.getBlockMetadata(x, y, z)); - - world.setBlockToAir(x, y, z); + world.setBlockToAir(pos); if(!returnBlock) { @@ -455,7 +383,7 @@ public class BlockReactor extends BlockContainer implements IBlockCTM double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); + EntityItem entityItem = new EntityItem(world, pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, itemStack); world.spawnEntityInWorld(entityItem); } diff --git a/src/main/java/mekanism/generators/common/block/states/BlockStateGenerator.java b/src/main/java/mekanism/generators/common/block/states/BlockStateGenerator.java new file mode 100644 index 000000000..bb5974e0c --- /dev/null +++ b/src/main/java/mekanism/generators/common/block/states/BlockStateGenerator.java @@ -0,0 +1,6 @@ +package mekanism.generators.common.block.states; + +public class BlockStateGenerator +{ + +} diff --git a/src/main/java/mekanism/generators/common/block/states/BlockStateReactor.java b/src/main/java/mekanism/generators/common/block/states/BlockStateReactor.java new file mode 100644 index 000000000..18f7f8274 --- /dev/null +++ b/src/main/java/mekanism/generators/common/block/states/BlockStateReactor.java @@ -0,0 +1,172 @@ +package mekanism.generators.common.block.states; + +import mekanism.common.Mekanism; +import mekanism.common.block.BlockBasic; +import mekanism.common.block.states.BlockStateBasic; +import mekanism.common.tile.TileEntityElectricBlock; +import mekanism.common.util.LangUtils; +import mekanism.generators.common.GeneratorsBlocks; +import mekanism.generators.common.block.BlockReactor; +import mekanism.generators.common.tile.reactor.TileEntityReactorController; +import mekanism.generators.common.tile.reactor.TileEntityReactorFrame; +import mekanism.generators.common.tile.reactor.TileEntityReactorGlass; +import mekanism.generators.common.tile.reactor.TileEntityReactorLaserFocusMatrix; +import mekanism.generators.common.tile.reactor.TileEntityReactorLogicAdapter; +import mekanism.generators.common.tile.reactor.TileEntityReactorNeutronCapture; +import mekanism.generators.common.tile.reactor.TileEntityReactorPort; +import net.minecraft.block.Block; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.properties.PropertyBool; +import net.minecraft.block.properties.PropertyEnum; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IStringSerializable; +import net.minecraftforge.common.property.ExtendedBlockState; +import net.minecraftforge.common.property.IUnlistedProperty; + +import com.google.common.base.Predicate; + +public class BlockStateReactor extends ExtendedBlockState +{ + public static final PropertyBool activeProperty = PropertyBool.create("active"); + + public BlockStateReactor(BlockBasic block, PropertyEnum typeProperty) + { + super(block, new IProperty[] {typeProperty, activeProperty}, new IUnlistedProperty[] {BlockStateBasic.ctmProperty}); + } + + public static enum ReactorBlock + { + REACTOR_BLOCK, + REACTOR_GLASS; + + private PropertyEnum predicatedProperty; + + public PropertyEnum getProperty() + { + if(predicatedProperty == null) + { + predicatedProperty = PropertyEnum.create("type", ReactorBlockType.class, new ReactorBlockPredicate(this)); + } + + return predicatedProperty; + } + + public Block getBlock() + { + switch(this) + { + case REACTOR_BLOCK: + return GeneratorsBlocks.Reactor; + case REACTOR_GLASS: + return GeneratorsBlocks.ReactorGlass; + default: + return null; + } + } + } + + public static class ReactorBlockPredicate implements Predicate + { + public ReactorBlock basicBlock; + + public ReactorBlockPredicate(ReactorBlock type) + { + basicBlock = type; + } + + @Override + public boolean apply(ReactorBlockType input) + { + return input.blockType == basicBlock && input.isValidReactorBlock(); + } + } + + public static enum ReactorBlockType implements IStringSerializable + { + REACTOR_CONTROLLER(ReactorBlock.REACTOR_BLOCK, 0, "ReactorController", 10, TileEntityReactorController.class, false), + REACTOR_FRAME(ReactorBlock.REACTOR_BLOCK, 1, "ReactorFrame", -1, TileEntityReactorFrame.class, false), + NEUTRON_CAPTURE(ReactorBlock.REACTOR_BLOCK, 2, "ReactorNeutronCapturePlate", 14, TileEntityReactorNeutronCapture.class, false), + REACTOR_PORT(ReactorBlock.REACTOR_BLOCK, 3, "ReactorPort", -1, TileEntityReactorPort.class, false), + REACTOR_LOGIC_ADAPTER(ReactorBlock.REACTOR_BLOCK, 4, "ReactorLogicAdapter", 15, TileEntityReactorLogicAdapter.class, false), + REACTOR_GLASS(ReactorBlock.REACTOR_GLASS, 0, "ReactorGlass", -1, TileEntityReactorGlass.class, false), + LASER_FOCUS_MATRIX(ReactorBlock.REACTOR_GLASS, 1, "ReactorLaserFocusMatrix", -1, TileEntityReactorLaserFocusMatrix.class, true); + + public ReactorBlock blockType; + public int meta; + public String name; + public int guiId; + public Class tileEntityClass; + public boolean activable; + + private ReactorBlockType(ReactorBlock b, int i, String s, int j, Class tileClass, boolean activeState) + { + blockType = b; + meta = i; + name = s; + guiId = j; + tileEntityClass = tileClass; + activable = activeState; + } + + public boolean isValidReactorBlock() + { + return this != NEUTRON_CAPTURE; + } + + public static ReactorBlockType get(Block block, int meta) + { + if(block instanceof BlockReactor) + { + return get(((BlockReactor)block).getReactorBlock(), meta); + } + + return null; + } + + public static ReactorBlockType get(ReactorBlock block, int meta) + { + for(ReactorBlockType type : values()) + { + if(type.meta == meta && type.blockType == block) + { + return type; + } + } + + return null; + } + + public static ReactorBlockType get(ItemStack stack) + { + return get(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage()); + } + + public TileEntity create() + { + try { + return tileEntityClass.newInstance(); + } catch(Exception e) { + Mekanism.logger.error("Unable to indirectly create tile entity."); + e.printStackTrace(); + return null; + } + } + + @Override + public String getName() + { + return name().toLowerCase(); + } + + public String getDescription() + { + return LangUtils.localize("tooltip." + name); + } + + public ItemStack getStack() + { + return new ItemStack(blockType.getBlock(), 1, meta); + } + } +} diff --git a/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java b/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java index c82654dfb..54d729b5c 100644 --- a/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java +++ b/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java @@ -133,9 +133,9 @@ public class ContainerReactorController extends Container @Override @SideOnly(Side.CLIENT) - public boolean func_111238_b() + public boolean canBeHovered() { - return tileEntity != null && MekanismUtils.isActive(tileEntity.getWorld(), tileEntity.getPos().getX(), tileEntity.getPos().getY(), tileEntity.getPos().getZ()); + return tileEntity != null && MekanismUtils.isActive(tileEntity.getWorld(), tileEntity.getPos()); } } } diff --git a/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java b/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java index a7f552217..9fe98bc85 100644 --- a/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java +++ b/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java @@ -178,7 +178,7 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp { for(int zPos =- 1; zPos <= 1; zPos++) { - if(!world.isAirBlock(x+xPos, y+2, z+zPos) || y+2 > 255) + if(!world.isAirBlock(pos.add(xPos, 2, zPos)) || pos.getY()+2 > 255) { place = false; break outer; @@ -194,9 +194,9 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp } outer: - for(int yPos = y+1; yPos <= y+4; yPos++) + for(int yPos = 1; yPos <= 4; yPos++) { - if(!world.isAirBlock(x, yPos, z) || yPos > 255) + if(!world.isAirBlock(pos.add(0, yPos, 0)) || yPos > 255) { place = false; break outer; diff --git a/src/main/java/mekanism/generators/common/item/ItemBlockReactor.java b/src/main/java/mekanism/generators/common/item/ItemBlockReactor.java index ab51f864f..b534357c2 100644 --- a/src/main/java/mekanism/generators/common/item/ItemBlockReactor.java +++ b/src/main/java/mekanism/generators/common/item/ItemBlockReactor.java @@ -5,7 +5,8 @@ import java.util.List; import mekanism.api.EnumColor; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; -import mekanism.generators.common.block.BlockReactor.ReactorBlockType; +import mekanism.generators.common.block.states.BlockStateReactor; +import mekanism.generators.common.block.states.BlockStateReactor.ReactorBlockType; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; @@ -32,23 +33,17 @@ public class ItemBlockReactor extends ItemBlock return i; } - @Override - public IIcon getIconFromDamage(int i) - { - return metaBlock.getIcon(2, i); - } - @Override public String getUnlocalizedName(ItemStack itemstack) { - return getUnlocalizedName() + "." + ReactorBlockType.get(itemstack).name; + return getUnlocalizedName() + "." + BlockStateReactor.ReactorBlockType.get(itemstack).name; } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { - ReactorBlockType type = ReactorBlockType.get(itemstack); + BlockStateReactor.ReactorBlockType type = BlockStateReactor.ReactorBlockType.get(itemstack); if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLogicAdapter.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLogicAdapter.java index 8d7696989..b0d497abe 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLogicAdapter.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLogicAdapter.java @@ -36,7 +36,7 @@ public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implem if(outputting != prevOutputting) { - worldObj.notifyBlocksOfNeighborChange(getPos(), getBlockType()); + worldObj.notifyNeighborsOfStateChange(getPos(), getBlockType()); } prevOutputting = outputting; diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java index 59210a33e..a890aa985 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java @@ -43,7 +43,7 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl { if(changed) { - worldObj.func_147453_f(xCoord, yCoord, zCoord, getBlockType()); + worldObj.notifyNeighborsOfStateChange(getPos(), getBlockType()); } super.onUpdate(); diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityRotationalComplex.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityRotationalComplex.java index b45b7de04..61e14acf5 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityRotationalComplex.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityRotationalComplex.java @@ -18,7 +18,7 @@ public class TileEntityRotationalComplex extends TileEntityInternalMultiblock super.setMultiblock(id); - Coord4D coord = Coord4D.get(this).getFromSide(EnumFacing.DOWN); + Coord4D coord = Coord4D.get(this).offset(EnumFacing.DOWN); TileEntity tile = coord.getTileEntity(worldObj); if(tile instanceof TileEntityTurbineRotor) diff --git a/src/main/resources/assets/mekanism/textures/blocks/models/energy_cube_advanced.png b/src/main/resources/assets/mekanism/textures/blocks/models/energy_cube_advanced.png deleted file mode 100644 index f928fd6d1..000000000 Binary files a/src/main/resources/assets/mekanism/textures/blocks/models/energy_cube_advanced.png and /dev/null differ diff --git a/src/main/resources/assets/mekanism/textures/blocks/models/energy_cube_basic.png b/src/main/resources/assets/mekanism/textures/blocks/models/energy_cube_basic.png deleted file mode 100644 index d96c1d6cc..000000000 Binary files a/src/main/resources/assets/mekanism/textures/blocks/models/energy_cube_basic.png and /dev/null differ diff --git a/src/main/resources/assets/mekanism/textures/blocks/models/energy_cube_creative.png b/src/main/resources/assets/mekanism/textures/blocks/models/energy_cube_creative.png deleted file mode 100644 index c90b05671..000000000 Binary files a/src/main/resources/assets/mekanism/textures/blocks/models/energy_cube_creative.png and /dev/null differ diff --git a/src/main/resources/assets/mekanism/textures/blocks/models/energy_cube_elite.png b/src/main/resources/assets/mekanism/textures/blocks/models/energy_cube_elite.png deleted file mode 100644 index 7c993a8e6..000000000 Binary files a/src/main/resources/assets/mekanism/textures/blocks/models/energy_cube_elite.png and /dev/null differ diff --git a/src/main/resources/assets/mekanism/textures/blocks/models/energy_cube_ultimate.png b/src/main/resources/assets/mekanism/textures/blocks/models/energy_cube_ultimate.png deleted file mode 100644 index 917e17d57..000000000 Binary files a/src/main/resources/assets/mekanism/textures/blocks/models/energy_cube_ultimate.png and /dev/null differ diff --git a/src/main/resources/assets/mekanism/textures/blocks/models/security_desk.png b/src/main/resources/assets/mekanism/textures/blocks/models/security_desk.png deleted file mode 100644 index 13d06ad61..000000000 Binary files a/src/main/resources/assets/mekanism/textures/blocks/models/security_desk.png and /dev/null differ diff --git a/src/main/resources/assets/mekanism/textures/blocks/models/seismic_vibrator.png b/src/main/resources/assets/mekanism/textures/blocks/models/seismic_vibrator.png deleted file mode 100644 index 50e718261..000000000 Binary files a/src/main/resources/assets/mekanism/textures/blocks/models/seismic_vibrator.png and /dev/null differ diff --git a/src/main/resources/assets/mekanism/textures/blocks/models/solar_neutron_activator.png b/src/main/resources/assets/mekanism/textures/blocks/models/solar_neutron_activator.png deleted file mode 100644 index 159ad1865..000000000 Binary files a/src/main/resources/assets/mekanism/textures/blocks/models/solar_neutron_activator.png and /dev/null differ diff --git a/src/main/resources/assets/mekanismgenerators/blockstates/reactor_controller.json b/src/main/resources/assets/mekanismgenerators/blockstates/reactor_controller.json new file mode 100644 index 000000000..61ab2f43f --- /dev/null +++ b/src/main/resources/assets/mekanismgenerators/blockstates/reactor_controller.json @@ -0,0 +1,21 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "mekanism:machine", + "textures": { + "sides": "mekanism:blocks/ctm/thermal_evaporation_block", + "front": "mekanism:blocks/ctm/thermal_evaporation_controller" + } + }, + "variants": { + "normal": [{}], + "facing": { + "north": {}, + "south": {"y": 180}, + "east": {"y": 90}, + "west": {"y": -90} + }, + "inventory": [{}] + } +} + diff --git a/src/main/resources/assets/mekanismgenerators/blockstates/rotational_complex.json b/src/main/resources/assets/mekanismgenerators/blockstates/rotational_complex.json new file mode 100644 index 000000000..e492f62f0 --- /dev/null +++ b/src/main/resources/assets/mekanismgenerators/blockstates/rotational_complex.json @@ -0,0 +1,17 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "mekanism:machine", + "textures": { + "sides": "mekanism:blocks/RotationalComplexSide", + "front": "mekanism:blocks/RotationalComplexSide", + "up": "mekanism:blocks/RotationalComplexTop", + "down": "mekanism:blocks/RotationalComplexTop" + } + }, + "variants": { + "normal": [{}], + "inventory": [{}] + } +} + diff --git a/src/main/resources/assets/mekanismgenerators/models/item/Hohlraum.json b/src/main/resources/assets/mekanismgenerators/models/item/Hohlraum.json new file mode 100644 index 000000000..bffcc527e --- /dev/null +++ b/src/main/resources/assets/mekanismgenerators/models/item/Hohlraum.json @@ -0,0 +1,7 @@ +{ + "parent": "mekanism:item/standard_item", + "textures": { + "layer0": "mekanismgenerators:items/Hohlraum" + } +} + diff --git a/src/main/resources/assets/mekanismgenerators/models/item/SolarPanel.json b/src/main/resources/assets/mekanismgenerators/models/item/SolarPanel.json new file mode 100644 index 000000000..9279b2aac --- /dev/null +++ b/src/main/resources/assets/mekanismgenerators/models/item/SolarPanel.json @@ -0,0 +1,7 @@ +{ + "parent": "mekanism:item/standard_item", + "textures": { + "layer0": "mekanismgenerators:items/SolarPanel" + } +} + diff --git a/src/main/resources/assets/mekanismgenerators/models/item/TurbineBlade.json b/src/main/resources/assets/mekanismgenerators/models/item/TurbineBlade.json new file mode 100644 index 000000000..af6b52ed1 --- /dev/null +++ b/src/main/resources/assets/mekanismgenerators/models/item/TurbineBlade.json @@ -0,0 +1,7 @@ +{ + "parent": "mekanism:item/standard_item", + "textures": { + "layer0": "mekanismgenerators:items/TurbineBlade" + } +} + diff --git a/src/main/resources/assets/mekanism/textures/blocks/RotationalComplexSide.png b/src/main/resources/assets/mekanismgenerators/textures/blocks/RotationalComplexSide.png similarity index 100% rename from src/main/resources/assets/mekanism/textures/blocks/RotationalComplexSide.png rename to src/main/resources/assets/mekanismgenerators/textures/blocks/RotationalComplexSide.png diff --git a/src/main/resources/assets/mekanism/textures/blocks/RotationalComplexTop.png b/src/main/resources/assets/mekanismgenerators/textures/blocks/RotationalComplexTop.png similarity index 100% rename from src/main/resources/assets/mekanism/textures/blocks/RotationalComplexTop.png rename to src/main/resources/assets/mekanismgenerators/textures/blocks/RotationalComplexTop.png diff --git a/src/main/resources/assets/mekanism/textures/blocks/TurbineRod.png b/src/main/resources/assets/mekanismgenerators/textures/blocks/TurbineRod.png similarity index 100% rename from src/main/resources/assets/mekanism/textures/blocks/TurbineRod.png rename to src/main/resources/assets/mekanismgenerators/textures/blocks/TurbineRod.png diff --git a/src/main/resources/assets/mekanism/textures/items/Hohlraum.png b/src/main/resources/assets/mekanismgenerators/textures/items/Hohlraum.png similarity index 100% rename from src/main/resources/assets/mekanism/textures/items/Hohlraum.png rename to src/main/resources/assets/mekanismgenerators/textures/items/Hohlraum.png diff --git a/src/main/resources/assets/mekanism/textures/items/SolarPanel.png b/src/main/resources/assets/mekanismgenerators/textures/items/SolarPanel.png similarity index 100% rename from src/main/resources/assets/mekanism/textures/items/SolarPanel.png rename to src/main/resources/assets/mekanismgenerators/textures/items/SolarPanel.png diff --git a/src/main/resources/assets/mekanism/textures/items/TurbineBlade.png b/src/main/resources/assets/mekanismgenerators/textures/items/TurbineBlade.png similarity index 100% rename from src/main/resources/assets/mekanism/textures/items/TurbineBlade.png rename to src/main/resources/assets/mekanismgenerators/textures/items/TurbineBlade.png