From dd99f582afb513dc729e60a5f366120317e29af6 Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Wed, 27 Jan 2016 01:36:39 +0000 Subject: [PATCH] State & Render stuffs, get the MInfuser rendering again. Still no textures. WIP. --- .../java/mekanism/client/ClientProxy.java | 80 +++- .../mekanism/client/MekanismKeyHandler.java | 4 +- .../tileentity/RenderMetallurgicInfuser.java | 6 +- .../java/mekanism/common/CommonProxy.java | 14 +- src/main/java/mekanism/common/Mekanism.java | 70 +-- .../java/mekanism/common/MekanismBlocks.java | 136 +++++- src/main/java/mekanism/common/Tier.java | 10 +- .../java/mekanism/common/base/IFactory.java | 19 +- .../mekanism/common/block/BlockBasic.java | 85 +++- .../mekanism/common/block/BlockMachine.java | 371 +++------------ .../common/block/states/BlockStateBasic.java | 193 ++++++++ .../block/states/BlockStateBounding.java | 17 + .../block/states/BlockStateEnergyCube.java | 21 + .../common/block/states/BlockStateFacing.java | 27 ++ .../block/states/BlockStateGasTank.java | 17 + .../block/states/BlockStateMachine.java | 438 ++++++++++++++++++ .../common/block/states/BlockStateOre.java | 34 ++ .../block/states/BlockStatePlastic.java | 38 ++ .../container/ContainerElectricChest.java | 4 +- .../inventory/slot/SlotElectricChest.java | 4 +- .../common/item/ItemBlockMachine.java | 65 +-- .../common/network/PacketConfigSync.java | 11 +- .../common/network/PacketElectricChest.java | 8 +- .../mekanism/common/recipe/RecipeHandler.java | 38 +- .../tile/TileEntityAdvancedFactory.java | 4 +- .../common/tile/TileEntityBasicBlock.java | 8 +- .../common/tile/TileEntityChargepad.java | 6 +- .../tile/TileEntityChemicalCrystallizer.java | 6 +- .../TileEntityChemicalDissolutionChamber.java | 6 +- .../tile/TileEntityChemicalInfuser.java | 5 +- .../TileEntityChemicalInjectionChamber.java | 8 +- .../tile/TileEntityChemicalOxidizer.java | 6 +- .../common/tile/TileEntityChemicalWasher.java | 6 +- .../common/tile/TileEntityCombiner.java | 6 +- .../common/tile/TileEntityCrusher.java | 4 +- .../common/tile/TileEntityDigitalMiner.java | 4 +- .../tile/TileEntityElectrolyticSeparator.java | 4 +- .../common/tile/TileEntityEliteFactory.java | 4 +- .../tile/TileEntityEnergizedSmelter.java | 4 +- .../tile/TileEntityEnrichmentChamber.java | 4 +- .../common/tile/TileEntityFactory.java | 8 +- .../tile/TileEntityFluidicPlenisher.java | 4 +- .../tile/TileEntityLogisticalSorter.java | 5 +- .../tile/TileEntityMetallurgicInfuser.java | 4 +- .../tile/TileEntityOredictionificator.java | 10 +- .../tile/TileEntityOsmiumCompressor.java | 5 +- .../mekanism/common/tile/TileEntityPRC.java | 4 +- .../tile/TileEntityPrecisionSawmill.java | 4 +- .../tile/TileEntityPurificationChamber.java | 6 +- .../tile/TileEntityRotaryCondensentrator.java | 4 +- .../tile/TileEntitySeismicVibrator.java | 4 +- .../common/tile/TileEntityTeleporter.java | 4 +- .../mekanism/common/util/RecipeUtils.java | 8 +- .../blockstates/metallurgic_infuser.json | 18 + .../models/block/metallurgic_infuser.json | 265 +++++++++++ .../models/item/metallurgic_infuser.json | 11 + 56 files changed, 1589 insertions(+), 570 deletions(-) create mode 100644 src/main/java/mekanism/common/block/states/BlockStateBasic.java create mode 100644 src/main/java/mekanism/common/block/states/BlockStateBounding.java create mode 100644 src/main/java/mekanism/common/block/states/BlockStateEnergyCube.java create mode 100644 src/main/java/mekanism/common/block/states/BlockStateFacing.java create mode 100644 src/main/java/mekanism/common/block/states/BlockStateGasTank.java create mode 100644 src/main/java/mekanism/common/block/states/BlockStateMachine.java create mode 100644 src/main/java/mekanism/common/block/states/BlockStateOre.java create mode 100644 src/main/java/mekanism/common/block/states/BlockStatePlastic.java create mode 100644 src/main/resources/assets/mekanism/blockstates/metallurgic_infuser.json create mode 100644 src/main/resources/assets/mekanism/models/block/metallurgic_infuser.json create mode 100644 src/main/resources/assets/mekanism/models/item/metallurgic_infuser.json diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index 9f97001f7..c2d817a44 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -95,21 +95,18 @@ import mekanism.client.render.tileentity.RenderSolarNeutronActivator; import mekanism.client.render.tileentity.RenderTeleporter; import mekanism.common.CommonProxy; import mekanism.common.Mekanism; +import mekanism.common.MekanismBlocks; +import mekanism.common.MekanismItems; import mekanism.common.base.IElectricChest; -import mekanism.common.base.ISideConfiguration; -import mekanism.common.base.IUpgradeTile; -import mekanism.common.block.BlockMachine.MachineType; +import mekanism.common.block.states.BlockStateMachine; import mekanism.common.entity.EntityBabySkeleton; import mekanism.common.entity.EntityBalloon; import mekanism.common.entity.EntityFlame; import mekanism.common.entity.EntityObsidianTNT; import mekanism.common.entity.EntityRobit; import mekanism.common.inventory.InventoryElectricChest; -import mekanism.common.item.ItemPortableTeleporter; -import mekanism.common.item.ItemSeismicReader; import mekanism.common.multiblock.MultiblockManager; import mekanism.common.network.PacketPortableTeleporter.PortableTeleporterMessage; -import mekanism.common.tile.TileEntityAdvancedElectricMachine; import mekanism.common.tile.TileEntityAdvancedFactory; import mekanism.common.tile.TileEntityAmbientAccumulator; import mekanism.common.tile.TileEntityBin; @@ -126,14 +123,12 @@ import mekanism.common.tile.TileEntityDigitalMiner; import mekanism.common.tile.TileEntityDynamicTank; import mekanism.common.tile.TileEntityDynamicValve; import mekanism.common.tile.TileEntityElectricChest; -import mekanism.common.tile.TileEntityElectricMachine; import mekanism.common.tile.TileEntityElectricPump; import mekanism.common.tile.TileEntityElectrolyticSeparator; import mekanism.common.tile.TileEntityEliteFactory; import mekanism.common.tile.TileEntityEnergizedSmelter; import mekanism.common.tile.TileEntityEnergyCube; import mekanism.common.tile.TileEntityEnrichmentChamber; -import mekanism.common.tile.TileEntityEntangledBlock; import mekanism.common.tile.TileEntityFactory; import mekanism.common.tile.TileEntityFluidicPlenisher; import mekanism.common.tile.TileEntityGasTank; @@ -160,13 +155,16 @@ import mekanism.common.tile.TileEntitySolarEvaporationController; import mekanism.common.tile.TileEntitySolarNeutronActivator; import mekanism.common.tile.TileEntityStructuralGlass; import mekanism.common.tile.TileEntityTeleporter; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderSkeleton; +import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.entity.monster.EntitySkeleton; 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; @@ -236,7 +234,7 @@ public class ClientProxy extends CommonProxy else { ItemStack stack = entityplayer.getCurrentEquippedItem(); - if(stack != null && stack.getItem() instanceof IElectricChest && MachineType.get(stack) == MachineType.ELECTRIC_CHEST) + if(stack != null && stack.getItem() instanceof IElectricChest && BlockStateMachine.MachineType.get(stack) == BlockStateMachine.MachineType.ELECTRIC_CHEST) { InventoryElectricChest inventory = new InventoryElectricChest(entityplayer); //TODO FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiElectricChest(entityplayer.inventory, inventory)); @@ -253,7 +251,7 @@ public class ClientProxy extends CommonProxy else { ItemStack stack = entityplayer.getCurrentEquippedItem(); - if(stack != null && stack.getItem() instanceof IElectricChest && MachineType.get(stack) == MachineType.ELECTRIC_CHEST) + if(stack != null && stack.getItem() instanceof IElectricChest && BlockStateMachine.MachineType.get(stack) == BlockStateMachine.MachineType.ELECTRIC_CHEST) { //TODO FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiPasswordEnter(stack)); } @@ -268,7 +266,7 @@ public class ClientProxy extends CommonProxy else { ItemStack stack = entityplayer.getCurrentEquippedItem(); - if(stack != null && stack.getItem() instanceof IElectricChest && MachineType.get(stack) == MachineType.ELECTRIC_CHEST) + if(stack != null && stack.getItem() instanceof IElectricChest && BlockStateMachine.MachineType.get(stack) == BlockStateMachine.MachineType.ELECTRIC_CHEST) { //TODO FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiPasswordModify(stack)); } @@ -402,10 +400,70 @@ public class ClientProxy extends CommonProxy RenderingRegistry.registerBlockHandler(new PlasticRenderingHandler()); RenderingRegistry.registerBlockHandler(new CTMRenderingHandler()); */ +// registerItemRender(MekanismItems.PartTransmitter); + registerItemRender(MekanismItems.ElectricBow); + registerItemRender(MekanismItems.Dust); + registerItemRender(MekanismItems.Ingot); + registerItemRender(MekanismItems.EnergyTablet); + registerItemRender(MekanismItems.SpeedUpgrade); + registerItemRender(MekanismItems.EnergyUpgrade); + registerItemRender(MekanismItems.FilterUpgrade); + registerItemRender(MekanismItems.GasUpgrade); + registerItemRender(MekanismItems.Robit); + registerItemRender(MekanismItems.AtomicDisassembler); + registerItemRender(MekanismItems.EnrichedAlloy); + registerItemRender(MekanismItems.ReinforcedAlloy); + registerItemRender(MekanismItems.AtomicAlloy); + registerItemRender(MekanismItems.ItemProxy); + registerItemRender(MekanismItems.ControlCircuit); + registerItemRender(MekanismItems.EnrichedIron); + registerItemRender(MekanismItems.CompressedCarbon); + registerItemRender(MekanismItems.CompressedRedstone); + registerItemRender(MekanismItems.CompressedDiamond); + registerItemRender(MekanismItems.CompressedObsidian); + registerItemRender(MekanismItems.PortableTeleporter); + registerItemRender(MekanismItems.TeleportationCore); + registerItemRender(MekanismItems.Clump); + registerItemRender(MekanismItems.DirtyDust); + registerItemRender(MekanismItems.Configurator); + registerItemRender(MekanismItems.NetworkReader); + registerItemRender(MekanismItems.WalkieTalkie); + registerItemRender(MekanismItems.Jetpack); + registerItemRender(MekanismItems.Dictionary); + registerItemRender(MekanismItems.GasMask); + registerItemRender(MekanismItems.ScubaTank); + registerItemRender(MekanismItems.Balloon); + registerItemRender(MekanismItems.Shard); + registerItemRender(MekanismItems.ElectrolyticCore); + registerItemRender(MekanismItems.Sawdust); + registerItemRender(MekanismItems.Salt); + registerItemRender(MekanismItems.BrineBucket); + registerItemRender(MekanismItems.LithiumBucket); + registerItemRender(MekanismItems.HeavyWaterBucket); + registerItemRender(MekanismItems.Crystal); + registerItemRender(MekanismItems.FreeRunners); + registerItemRender(MekanismItems.ArmoredJetpack); + registerItemRender(MekanismItems.FilterCard); + registerItemRender(MekanismItems.SeismicReader); + registerItemRender(MekanismItems.Substrate); + registerItemRender(MekanismItems.Polyethene); + registerItemRender(MekanismItems.BioFuel); +// registerItemRender(MekanismItems.GlowPanel); + registerItemRender(MekanismItems.Flamethrower); + registerItemRender(MekanismItems.GaugeDropper); + registerItemRender(MekanismItems.FactoryInstaller); + registerItemRender(MekanismItems.OtherDust); + + MekanismBlocks.registerRender(); Mekanism.logger.info("Render registrations complete."); } + public void registerItemRender(Item item) + { + Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); + } + @Override public GuiScreen getClientGui(int ID, EntityPlayer player, World world, BlockPos pos) { diff --git a/src/main/java/mekanism/client/MekanismKeyHandler.java b/src/main/java/mekanism/client/MekanismKeyHandler.java index eb6b143e2..fc2270581 100644 --- a/src/main/java/mekanism/client/MekanismKeyHandler.java +++ b/src/main/java/mekanism/client/MekanismKeyHandler.java @@ -11,7 +11,7 @@ import mekanism.api.EnumColor; import mekanism.api.util.StackUtils; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; -import mekanism.common.block.BlockMachine.MachineType; +import mekanism.common.block.states.BlockStateMachine; import mekanism.common.item.*; import mekanism.common.item.ItemConfigurator.ConfiguratorMode; import mekanism.common.item.ItemJetpack.JetpackMode; @@ -91,7 +91,7 @@ public class MekanismKeyHandler extends MekKeyHandler { ItemBlockMachine machine = (ItemBlockMachine)item; - if(MachineType.get(toolStack) == MachineType.PORTABLE_TANK) + if(BlockStateMachine.MachineType.get(toolStack) == BlockStateMachine.MachineType.PORTABLE_TANK) { machine.setBucketMode(toolStack, !machine.getBucketMode(toolStack)); Mekanism.packetHandler.sendToServer(new PortableTankStateMessage(machine.getBucketMode(toolStack))); diff --git a/src/main/java/mekanism/client/render/tileentity/RenderMetallurgicInfuser.java b/src/main/java/mekanism/client/render/tileentity/RenderMetallurgicInfuser.java index 8b1889025..eeb74fc8a 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderMetallurgicInfuser.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderMetallurgicInfuser.java @@ -21,12 +21,15 @@ public class RenderMetallurgicInfuser extends TileEntitySpecialRenderer getProperty() + { + return getBasicBlock().getProperty(); + } + + @Override + public IBlockState getStateFromMeta(int meta) + { + BasicBlockType type = BasicBlockType.getBlockType(getBasicBlock(), meta&0xF); + + return this.getDefaultState().withProperty(getProperty(), type); + } + + @Override + public int getMetaFromState(IBlockState state) + { + BasicBlockType type = state.getValue(getProperty()); + return type.meta; + } /* @Override public IIcon getIcon(ItemStack stack, int side) @@ -297,7 +338,7 @@ public class BlockBasic extends Block//TODO? implements IBlockCTM, ICustomBlockI @SideOnly(Side.CLIENT) public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) { - switch(blockType) + switch(getBasicBlock()) { case BASIC_BLOCK_1: for(int i = 0; i < 16; i++) @@ -348,7 +389,7 @@ public class BlockBasic extends Block//TODO? implements IBlockCTM, ICustomBlockI IBlockState state = world.getBlockState(pos); int meta = state.getBlock().getMetaFromState(state); - switch(blockType) + switch(getBasicBlock()) { case BASIC_BLOCK_1: switch(meta) @@ -414,7 +455,7 @@ public class BlockBasic extends Block//TODO? implements IBlockCTM, ICustomBlockI IBlockState state = world.getBlockState(pos); int meta = state.getBlock().getMetaFromState(state); - if(blockType == BasicBlock.BASIC_BLOCK_1) + if(getBasicBlock() == BasicBlock.BASIC_BLOCK_1) { if(!world.isRemote && meta == 6) { @@ -443,7 +484,7 @@ public class BlockBasic extends Block//TODO? implements IBlockCTM, ICustomBlockI { int metadata = state.getBlock().getMetaFromState(state); - if(blockType == BasicBlock.BASIC_BLOCK_1) + if(getBasicBlock() == BasicBlock.BASIC_BLOCK_1) { if(metadata != 6) { @@ -546,7 +587,7 @@ public class BlockBasic extends Block//TODO? implements IBlockCTM, ICustomBlockI return ((IStructuralMultiblock)world.getTileEntity(pos)).onActivate(entityplayer); } } - else if(blockType == BasicBlock.BASIC_BLOCK_2) + else if(getBasicBlock() == BasicBlock.BASIC_BLOCK_2) { if(world.isRemote) { @@ -566,7 +607,7 @@ public class BlockBasic extends Block//TODO? implements IBlockCTM, ICustomBlockI public boolean isSideSolid(IBlockAccess world, BlockPos pos, EnumFacing side) { IBlockState state = world.getBlockState(pos); - return !(blockType == BasicBlock.BASIC_BLOCK_1 && state.getBlock().getMetaFromState(state) == 10); + return !(getBasicBlock() == BasicBlock.BASIC_BLOCK_1 && state.getBlock().getMetaFromState(state) == 10); } public static boolean manageInventory(EntityPlayer player, TileEntityDynamicTank tileEntity) @@ -717,7 +758,7 @@ public class BlockBasic extends Block//TODO? implements IBlockCTM, ICustomBlockI } } - if(blockType == BasicBlock.BASIC_BLOCK_1) + if(getBasicBlock() == BasicBlock.BASIC_BLOCK_1) { switch(metadata) { @@ -737,7 +778,7 @@ public class BlockBasic extends Block//TODO? implements IBlockCTM, ICustomBlockI public boolean hasTileEntity(IBlockState state) { int metadata = state.getBlock().getMetaFromState(state); - switch(blockType) + switch(getBasicBlock()) { case BASIC_BLOCK_1: switch(metadata) @@ -788,7 +829,7 @@ public class BlockBasic extends Block//TODO? implements IBlockCTM, ICustomBlockI public TileEntity createTileEntity(World world, IBlockState state) { int metadata = state.getBlock().getMetaFromState(state); - switch(blockType) + switch(getBasicBlock()) { case BASIC_BLOCK_1: switch(metadata) @@ -897,7 +938,7 @@ public class BlockBasic extends Block//TODO? implements IBlockCTM, ICustomBlockI IBlockState state = world.getBlockState(pos); ItemStack ret = new ItemStack(this, 1, state.getBlock().getMetaFromState(state)); - if(blockType == BasicBlock.BASIC_BLOCK_1) + if(getBasicBlock() == BasicBlock.BASIC_BLOCK_1) { if(ret.getItemDamage() == 6) { @@ -912,7 +953,7 @@ public class BlockBasic extends Block//TODO? implements IBlockCTM, ICustomBlockI } } } - else if(blockType == BasicBlock.BASIC_BLOCK_2) + else if(getBasicBlock() == BasicBlock.BASIC_BLOCK_2) { if(ret.getItemDamage() == 3) { @@ -990,7 +1031,7 @@ public class BlockBasic extends Block//TODO? implements IBlockCTM, ICustomBlockI { Coord4D obj = new Coord4D(pos).offset(EnumFacing.getFront(side).getOpposite()); - if(blockType == BasicBlock.BASIC_BLOCK_1 && obj.getBlockState(world) == 10) + if(getBasicBlock() == BasicBlock.BASIC_BLOCK_1 && obj.getBlockState(world) == 10) { return ctms[10][0].shouldRenderSide(world, pos, side); } @@ -1050,7 +1091,7 @@ public class BlockBasic extends Block//TODO? implements IBlockCTM, ICustomBlockI return ctms[meta][1]; } - if(blockType == BasicBlock.BASIC_BLOCK_2) + if(getBasicBlock() == BasicBlock.BASIC_BLOCK_2) { if(meta == 3) { @@ -1067,10 +1108,4 @@ public class BlockBasic extends Block//TODO? implements IBlockCTM, ICustomBlockI return ctms[meta][0]; } */ - - public static enum BasicBlock - { - BASIC_BLOCK_1, - BASIC_BLOCK_2; - } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index bd93438f4..428a32e53 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -1,8 +1,5 @@ package mekanism.common.block; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; import java.util.List; import java.util.Random; @@ -10,13 +7,10 @@ import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.client; import mekanism.api.MekanismConfig.general; -import mekanism.api.MekanismConfig.machines; -import mekanism.api.MekanismConfig.usage; import mekanism.api.energy.IEnergizedItem; import mekanism.api.energy.IStrictEnergyStorage; import mekanism.common.ItemAttacher; import mekanism.common.Mekanism; -import mekanism.common.MekanismBlocks; import mekanism.common.base.IActiveState; import mekanism.common.base.IBoundingBlock; import mekanism.common.base.IElectricChest; @@ -29,49 +23,24 @@ import mekanism.common.base.ISustainedData; import mekanism.common.base.ISustainedInventory; import mekanism.common.base.ISustainedTank; import mekanism.common.base.IUpgradeTile; +import mekanism.common.block.states.BlockStateBasic.BasicBlock; +import mekanism.common.block.states.BlockStateMachine; +import mekanism.common.block.states.BlockStateMachine.MachineBlock; +import mekanism.common.block.states.BlockStateMachine.MachineType; import mekanism.common.item.ItemBlockMachine; import mekanism.common.network.PacketElectricChest.ElectricChestMessage; import mekanism.common.network.PacketElectricChest.ElectricChestPacketType; import mekanism.common.network.PacketLogisticalSorterGui.LogisticalSorterGuiMessage; import mekanism.common.network.PacketLogisticalSorterGui.SorterGuiPacket; -import mekanism.common.recipe.ShapedMekanismRecipe; -import mekanism.common.tile.TileEntityAdvancedFactory; -import mekanism.common.tile.TileEntityAmbientAccumulator; import mekanism.common.tile.TileEntityBasicBlock; import mekanism.common.tile.TileEntityChargepad; -import mekanism.common.tile.TileEntityChemicalCrystallizer; -import mekanism.common.tile.TileEntityChemicalDissolutionChamber; -import mekanism.common.tile.TileEntityChemicalInfuser; -import mekanism.common.tile.TileEntityChemicalInjectionChamber; -import mekanism.common.tile.TileEntityChemicalOxidizer; -import mekanism.common.tile.TileEntityChemicalWasher; -import mekanism.common.tile.TileEntityCombiner; import mekanism.common.tile.TileEntityContainerBlock; -import mekanism.common.tile.TileEntityCrusher; -import mekanism.common.tile.TileEntityDigitalMiner; import mekanism.common.tile.TileEntityElectricChest; -import mekanism.common.tile.TileEntityElectricPump; -import mekanism.common.tile.TileEntityElectrolyticSeparator; -import mekanism.common.tile.TileEntityEliteFactory; -import mekanism.common.tile.TileEntityEnergizedSmelter; -import mekanism.common.tile.TileEntityEnrichmentChamber; -import mekanism.common.tile.TileEntityEntangledBlock; import mekanism.common.tile.TileEntityFactory; -import mekanism.common.tile.TileEntityFluidicPlenisher; -import mekanism.common.tile.TileEntityLaser; import mekanism.common.tile.TileEntityLaserAmplifier; -import mekanism.common.tile.TileEntityLaserTractorBeam; import mekanism.common.tile.TileEntityLogisticalSorter; import mekanism.common.tile.TileEntityMetallurgicInfuser; -import mekanism.common.tile.TileEntityOredictionificator; -import mekanism.common.tile.TileEntityOsmiumCompressor; -import mekanism.common.tile.TileEntityPRC; import mekanism.common.tile.TileEntityPortableTank; -import mekanism.common.tile.TileEntityPrecisionSawmill; -import mekanism.common.tile.TileEntityPurificationChamber; -import mekanism.common.tile.TileEntityRotaryCondensentrator; -import mekanism.common.tile.TileEntitySeismicVibrator; -import mekanism.common.tile.TileEntitySolarNeutronActivator; import mekanism.common.tile.TileEntityTeleporter; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; @@ -79,6 +48,8 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; +import net.minecraft.block.properties.PropertyEnum; +import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -106,6 +77,7 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import buildcraft.api.tools.IToolWrench; + import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -151,21 +123,55 @@ import net.minecraftforge.fml.relauncher.SideOnly; * @author AidanBrady * */ -public class BlockMachine extends BlockContainer implements ISpecialBounds//, IBlockCTM, ICustomBlockIcon +public abstract class BlockMachine extends BlockContainer implements ISpecialBounds//, IBlockCTM, ICustomBlockIcon { //public CTMData[][] ctms = new CTMData[16][4]; - public MachineBlock blockType; - - public BlockMachine(MachineBlock type) + public BlockMachine() { super(Material.iron); setHardness(3.5F); setResistance(16F); setCreativeTab(Mekanism.tabMekanism); - blockType = type; } + public static BlockMachine getBlockMachine(MachineBlock block) + { + return new BlockMachine() { + @Override + public MachineBlock getMachineBlock() + { + return block; + } + }; + } + + public abstract MachineBlock getMachineBlock(); + + public BlockState createBlockState() + { + return new BlockStateMachine(this, getProperty()); + } + + public PropertyEnum getProperty() + { + return getMachineBlock().getProperty(); + } + + @Override + public IBlockState getStateFromMeta(int meta) + { + MachineType type = MachineType.get(getMachineBlock(), meta&0xF); + + return this.getDefaultState().withProperty(getProperty(), type); + } + + @Override + public int getMetaFromState(IBlockState state) + { + MachineType type = state.getValue(getProperty()); + return type.meta; + } /* @Override @SideOnly(Side.CLIENT) @@ -493,9 +499,9 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds//, IB @SideOnly(Side.CLIENT) public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) { - for(MachineType type : MachineType.getValidMachines()) + for(MachineType type : BlockStateMachine.MachineType.getValidMachines()) { - if(type.typeBlock == blockType && type.isEnabled()) + if(type.typeBlock == getMachineBlock() && type.isEnabled()) { switch(type) { @@ -558,7 +564,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds//, IB if(MekanismUtils.hasUsableWrench(entityplayer, pos)) { - if(entityplayer.isSneaking() && MachineType.get(blockType, metadata) != MachineType.ELECTRIC_CHEST) + if(entityplayer.isSneaking() && BlockStateMachine.MachineType.get(getMachineBlock(), metadata) != BlockStateMachine.MachineType.ELECTRIC_CHEST) { dismantleBlock(world, pos, false); return true; @@ -596,7 +602,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds//, IB if(tileEntity != null) { - MachineType type = MachineType.get(blockType, metadata); + MachineType type = BlockStateMachine.MachineType.get(getMachineBlock(), metadata); switch(type) { @@ -675,12 +681,12 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds//, IB public TileEntity createTileEntity(World world, IBlockState state) { int metadata = getMetaFromState(state); - if(MachineType.get(blockType, metadata) == null) + if(BlockStateMachine.MachineType.get(getMachineBlock(), metadata) == null) { return null; } - return MachineType.get(blockType, metadata).create(); + return BlockStateMachine.MachineType.get(getMachineBlock(), metadata).create(); } @Override @@ -711,7 +717,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds//, IB public float getBlockHardness(World world, BlockPos pos) { IBlockState state = world.getBlockState(pos); - if(MachineType.get(blockType, state.getBlock().getMetaFromState(state)) != MachineType.ELECTRIC_CHEST) + if(BlockStateMachine.MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)) != BlockStateMachine.MachineType.ELECTRIC_CHEST) { return blockHardness; } @@ -725,7 +731,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds//, IB public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) { IBlockState state = world.getBlockState(pos); - if(MachineType.get(blockType, state.getBlock().getMetaFromState(state)) != MachineType.ELECTRIC_CHEST) + if(BlockStateMachine.MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)) != BlockStateMachine.MachineType.ELECTRIC_CHEST) { return blockResistance; } @@ -991,7 +997,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds//, IB public boolean canConnectRedstone(IBlockAccess world, BlockPos pos, EnumFacing side) { IBlockState state = world.getBlockState(pos); - MachineType type = MachineType.get(blockType, state.getBlock().getMetaFromState(state)); + MachineType type = BlockStateMachine.MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)); switch(type) { @@ -1027,7 +1033,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds//, IB public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos) { IBlockState state = world.getBlockState(pos); - MachineType type = MachineType.get(blockType, state.getBlock().getMetaFromState(state)); + MachineType type = BlockStateMachine.MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)); switch(type) { @@ -1058,7 +1064,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds//, IB public boolean isSideSolid(IBlockAccess world, BlockPos pos, EnumFacing side) { IBlockState state = world.getBlockState(pos); - MachineType type = MachineType.get(blockType, state.getBlock().getMetaFromState(state)); + MachineType type = BlockStateMachine.MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)); switch(type) { @@ -1072,268 +1078,6 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds//, IB } } - public static enum MachineBlock - { - MACHINE_BLOCK_1, - MACHINE_BLOCK_2, - MACHINE_BLOCK_3; - - public Block getBlock() - { - switch(this) - { - case MACHINE_BLOCK_1: - return MekanismBlocks.MachineBlock; - case MACHINE_BLOCK_2: - return MekanismBlocks.MachineBlock2; - case MACHINE_BLOCK_3: - return MekanismBlocks.MachineBlock3; - default: - return null; - } - } - } - - public static enum MachineType - { - ENRICHMENT_CHAMBER(MachineBlock.MACHINE_BLOCK_1, 0, "EnrichmentChamber", 3, TileEntityEnrichmentChamber.class, true, false, true), - OSMIUM_COMPRESSOR(MachineBlock.MACHINE_BLOCK_1, 1, "OsmiumCompressor", 4, TileEntityOsmiumCompressor.class, true, false, true), - COMBINER(MachineBlock.MACHINE_BLOCK_1, 2, "Combiner", 5, TileEntityCombiner.class, true, false, true), - CRUSHER(MachineBlock.MACHINE_BLOCK_1, 3, "Crusher", 6, TileEntityCrusher.class, true, false, true), - DIGITAL_MINER(MachineBlock.MACHINE_BLOCK_1, 4, "DigitalMiner", 2, TileEntityDigitalMiner.class, true, true, true), - BASIC_FACTORY(MachineBlock.MACHINE_BLOCK_1, 5, "Factory", 11, TileEntityFactory.class, true, false, true), - ADVANCED_FACTORY(MachineBlock.MACHINE_BLOCK_1, 6, "Factory", 11, TileEntityAdvancedFactory.class, true, false, true), - ELITE_FACTORY(MachineBlock.MACHINE_BLOCK_1, 7, "Factory", 11, TileEntityEliteFactory.class, true, false, true), - METALLURGIC_INFUSER(MachineBlock.MACHINE_BLOCK_1, 8, "MetallurgicInfuser", 12, TileEntityMetallurgicInfuser.class, true, true, true), - PURIFICATION_CHAMBER(MachineBlock.MACHINE_BLOCK_1, 9, "PurificationChamber", 15, TileEntityPurificationChamber.class, true, false, true), - ENERGIZED_SMELTER(MachineBlock.MACHINE_BLOCK_1, 10, "EnergizedSmelter", 16, TileEntityEnergizedSmelter.class, true, false, true), - TELEPORTER(MachineBlock.MACHINE_BLOCK_1, 11, "Teleporter", 13, TileEntityTeleporter.class, true, false, false), - ELECTRIC_PUMP(MachineBlock.MACHINE_BLOCK_1, 12, "ElectricPump", 17, TileEntityElectricPump.class, true, true, false), - ELECTRIC_CHEST(MachineBlock.MACHINE_BLOCK_1, 13, "ElectricChest", -1, TileEntityElectricChest.class, true, true, false), - CHARGEPAD(MachineBlock.MACHINE_BLOCK_1, 14, "Chargepad", -1, TileEntityChargepad.class, true, true, false), - LOGISTICAL_SORTER(MachineBlock.MACHINE_BLOCK_1, 15, "LogisticalSorter", -1, TileEntityLogisticalSorter.class, false, true, false), - ROTARY_CONDENSENTRATOR(MachineBlock.MACHINE_BLOCK_2, 0, "RotaryCondensentrator", 7, TileEntityRotaryCondensentrator.class, true, true, false), - CHEMICAL_OXIDIZER(MachineBlock.MACHINE_BLOCK_2, 1, "ChemicalOxidizer", 29, TileEntityChemicalOxidizer.class, true, true, true), - CHEMICAL_INFUSER(MachineBlock.MACHINE_BLOCK_2, 2, "ChemicalInfuser", 30, TileEntityChemicalInfuser.class, true, true, false), - CHEMICAL_INJECTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 3, "ChemicalInjectionChamber", 31, TileEntityChemicalInjectionChamber.class, true, false, true), - ELECTROLYTIC_SEPARATOR(MachineBlock.MACHINE_BLOCK_2, 4, "ElectrolyticSeparator", 32, TileEntityElectrolyticSeparator.class, true, true, false), - PRECISION_SAWMILL(MachineBlock.MACHINE_BLOCK_2, 5, "PrecisionSawmill", 34, TileEntityPrecisionSawmill.class, true, false, true), - CHEMICAL_DISSOLUTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 6, "ChemicalDissolutionChamber", 35, TileEntityChemicalDissolutionChamber.class, true, true, true), - CHEMICAL_WASHER(MachineBlock.MACHINE_BLOCK_2, 7, "ChemicalWasher", 36, TileEntityChemicalWasher.class, true, true, false), - CHEMICAL_CRYSTALLIZER(MachineBlock.MACHINE_BLOCK_2, 8, "ChemicalCrystallizer", 37, TileEntityChemicalCrystallizer.class, true, true, true), - SEISMIC_VIBRATOR(MachineBlock.MACHINE_BLOCK_2, 9, "SeismicVibrator", 39, TileEntitySeismicVibrator.class, true, true, false), - PRESSURIZED_REACTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 10, "PressurizedReactionChamber", 40, TileEntityPRC.class, true, true, false), - PORTABLE_TANK(MachineBlock.MACHINE_BLOCK_2, 11, "PortableTank", 41, TileEntityPortableTank.class, false, true, false), - FLUIDIC_PLENISHER(MachineBlock.MACHINE_BLOCK_2, 12, "FluidicPlenisher", 42, TileEntityFluidicPlenisher.class, true, true, false), - LASER(MachineBlock.MACHINE_BLOCK_2, 13, "Laser", -1, TileEntityLaser.class, true, true, false), - LASER_AMPLIFIER(MachineBlock.MACHINE_BLOCK_2, 14, "LaserAmplifier", 44, TileEntityLaserAmplifier.class, false, true, false), - LASER_TRACTOR_BEAM(MachineBlock.MACHINE_BLOCK_2, 15, "LaserTractorBeam", 45, TileEntityLaserTractorBeam.class, false, true, false), - ENTANGLED_BLOCK(MachineBlock.MACHINE_BLOCK_3, 0, "EntangledBlock", 46, TileEntityEntangledBlock.class, true, false, false), - SOLAR_NEUTRON_ACTIVATOR(MachineBlock.MACHINE_BLOCK_3, 1, "SolarNeutronActivator", 47, TileEntitySolarNeutronActivator.class, false, true, false), - AMBIENT_ACCUMULATOR(MachineBlock.MACHINE_BLOCK_3, 2, "AmbientAccumulator", 48, TileEntityAmbientAccumulator.class, true, false, false), - OREDICTIONIFICATOR(MachineBlock.MACHINE_BLOCK_3, 3, "Oredictionificator", 52, TileEntityOredictionificator.class, false, false, false); - - public MachineBlock typeBlock; - public int meta; - public String name; - public int guiId; - public double baseEnergy; - public Class tileEntityClass; - public boolean isElectric; - public boolean hasModel; - public boolean supportsUpgrades; - public Collection machineRecipes = new HashSet(); - - private MachineType(MachineBlock block, int i, String s, int j, Class tileClass, boolean electric, boolean model, boolean upgrades) - { - typeBlock = block; - meta = i; - name = s; - guiId = j; - tileEntityClass = tileClass; - isElectric = electric; - hasModel = model; - supportsUpgrades = upgrades; - } - - public boolean isEnabled() - { - return machines.isEnabled(this.name); - } - - public void addRecipes(Collection recipes) - { - machineRecipes.addAll(recipes); - } - - public void addRecipe(ShapedMekanismRecipe recipe) - { - machineRecipes.add(recipe); - } - - public Collection getRecipes() - { - return machineRecipes; - } - - public static List getValidMachines() - { - List ret = new ArrayList(); - - for(MachineType type : MachineType.values()) - { - if(type != ENTANGLED_BLOCK && type != AMBIENT_ACCUMULATOR) - { - ret.add(type); - } - } - - return ret; - } - - public static MachineType get(Block block, int meta) - { - if(block instanceof BlockMachine) - { - return get(((BlockMachine)block).blockType, meta); - } - - return null; - } - - public static MachineType get(MachineBlock block, int meta) - { - for(MachineType type : values()) - { - if(type.meta == meta && type.typeBlock == block) - { - return type; - } - } - - return null; - } - - public TileEntity create() - { - try { - return tileEntityClass.newInstance(); - } catch(Exception e) { - Mekanism.logger.error("Unable to indirectly create tile entity."); - e.printStackTrace(); - return null; - } - } - - /** Used for getting the base energy storage. */ - public double getUsage() - { - switch(this) - { - case ENRICHMENT_CHAMBER: - return usage.enrichmentChamberUsage; - case OSMIUM_COMPRESSOR: - return usage.osmiumCompressorUsage; - case COMBINER: - return usage.combinerUsage; - case CRUSHER: - return usage.crusherUsage; - case DIGITAL_MINER: - return usage.digitalMinerUsage; - case BASIC_FACTORY: - return usage.factoryUsage * 3; - case ADVANCED_FACTORY: - return usage.factoryUsage * 5; - case ELITE_FACTORY: - return usage.factoryUsage * 7; - case METALLURGIC_INFUSER: - return usage.metallurgicInfuserUsage; - case PURIFICATION_CHAMBER: - return usage.purificationChamberUsage; - case ENERGIZED_SMELTER: - return usage.energizedSmelterUsage; - case TELEPORTER: - return 12500; - case ELECTRIC_PUMP: - return usage.electricPumpUsage; - case ELECTRIC_CHEST: - return 30; - case CHARGEPAD: - return 25; - case LOGISTICAL_SORTER: - return 0; - case ROTARY_CONDENSENTRATOR: - return usage.rotaryCondensentratorUsage; - case CHEMICAL_OXIDIZER: - return usage.oxidationChamberUsage; - case CHEMICAL_INFUSER: - return usage.chemicalInfuserUsage; - case CHEMICAL_INJECTION_CHAMBER: - return usage.chemicalInjectionChamberUsage; - case ELECTROLYTIC_SEPARATOR: - return general.FROM_H2 * 2; - case PRECISION_SAWMILL: - return usage.precisionSawmillUsage; - case CHEMICAL_DISSOLUTION_CHAMBER: - return usage.chemicalDissolutionChamberUsage; - case CHEMICAL_WASHER: - return usage.chemicalWasherUsage; - case CHEMICAL_CRYSTALLIZER: - return usage.chemicalCrystallizerUsage; - case SEISMIC_VIBRATOR: - return usage.seismicVibratorUsage; - case PRESSURIZED_REACTION_CHAMBER: - return usage.pressurizedReactionBaseUsage; - case PORTABLE_TANK: - return 0; - case FLUIDIC_PLENISHER: - return usage.fluidicPlenisherUsage; - case LASER: - return usage.laserUsage; - case LASER_AMPLIFIER: - return 0; - case LASER_TRACTOR_BEAM: - return 0; - case ENTANGLED_BLOCK: - return 0; - case SOLAR_NEUTRON_ACTIVATOR: - return 0; - case AMBIENT_ACCUMULATOR: - return 0; - default: - return 0; - } - } - - public static void updateAllUsages() - { - for(MachineType type : values()) - { - type.updateUsage(); - } - } - - public void updateUsage() - { - baseEnergy = 400 * getUsage(); - } - - public String getDescription() - { - return LangUtils.localize("tooltip." + name); - } - - public ItemStack getStack() - { - return new ItemStack(typeBlock.getBlock(), 1, meta); - } - - public static MachineType get(ItemStack stack) - { - return get(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage()); - } - } - @Override public void setRenderBounds(Block block, int metadata) {} @@ -1396,7 +1140,6 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds//, IB return 0; } - /* @Override public CTMData getCTMData(IBlockAccess world, BlockPos pos, int meta) diff --git a/src/main/java/mekanism/common/block/states/BlockStateBasic.java b/src/main/java/mekanism/common/block/states/BlockStateBasic.java new file mode 100644 index 000000000..c8e8f2210 --- /dev/null +++ b/src/main/java/mekanism/common/block/states/BlockStateBasic.java @@ -0,0 +1,193 @@ +package mekanism.common.block.states; + +import mekanism.common.MekanismBlocks; +import mekanism.common.block.BlockBasic; +import mekanism.common.block.BlockMachine; + +import net.minecraft.block.Block; +import net.minecraft.block.properties.PropertyBool; +import net.minecraft.block.properties.PropertyEnum; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.block.statemap.StateMapperBase; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumFacing.Plane; +import net.minecraft.util.IStringSerializable; +import net.minecraft.util.ResourceLocation; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; + +public class BlockStateBasic extends BlockStateFacing +{ + public static final PropertyBool activeProperty = PropertyBool.create("active"); + + public BlockStateBasic(BlockBasic block, PropertyEnum typeProperty) + { + super(block, typeProperty); + } + + public static enum BasicBlock + { + BASIC_BLOCK_1, + BASIC_BLOCK_2; + + public BlockBasic implBlock; + private PropertyEnum predicatedProperty; + + public PropertyEnum getProperty() + { + if(predicatedProperty == null) + { + predicatedProperty = PropertyEnum.create("type", BasicBlockType.class, new BasicBlockPredicate(this)); + } + return predicatedProperty; + } + + public Block getBlock() + { + switch(this) + { + case BASIC_BLOCK_1: + return MekanismBlocks.BasicBlock; + case BASIC_BLOCK_2: + return MekanismBlocks.BasicBlock2; + default: + return null; + } + } + } + + public static enum BasicBlockType implements IStringSerializable + { + OSMIUM_BLOCK(BasicBlock.BASIC_BLOCK_1, 0, Predicates.alwaysFalse(), false), + BRONZE_BLOCK(BasicBlock.BASIC_BLOCK_1, 1, Predicates.alwaysFalse(), false), + REFINED_OBSIDIAN(BasicBlock.BASIC_BLOCK_1, 2, Predicates.alwaysFalse(), false), + COAL_BLOCK(BasicBlock.BASIC_BLOCK_1, 3, Predicates.alwaysFalse(), false), + REFINED_GLOWSTONE(BasicBlock.BASIC_BLOCK_1, 4, Predicates.alwaysFalse(), false), + STEEL_BLOCK(BasicBlock.BASIC_BLOCK_1, 5, Predicates.alwaysFalse(), false), + BIN(BasicBlock.BASIC_BLOCK_1, 6, Plane.HORIZONTAL, false), + TELEPORTER_FRAME(BasicBlock.BASIC_BLOCK_1, 7, Predicates.alwaysFalse(), false), + STEEL_CASING(BasicBlock.BASIC_BLOCK_1, 8, Predicates.alwaysFalse(), false), + DYNAMIC_TANK(BasicBlock.BASIC_BLOCK_1, 9, Predicates.alwaysFalse(), false), + DYNAMIC_GLASS(BasicBlock.BASIC_BLOCK_1, 10, Predicates.alwaysFalse(), false), + DYNAMIC_VALVE(BasicBlock.BASIC_BLOCK_1, 11, Predicates.alwaysFalse(), false), + COPPER_BLOCK(BasicBlock.BASIC_BLOCK_1, 12, Predicates.alwaysFalse(), false), + TIN_BLOCK(BasicBlock.BASIC_BLOCK_1, 13, Predicates.alwaysFalse(), false), + SALINATION_CONTROLLER(BasicBlock.BASIC_BLOCK_1, 14, Plane.HORIZONTAL, false), + SALINATION_VALVE(BasicBlock.BASIC_BLOCK_1, 15, Predicates.alwaysFalse(), false), + SALINATION_BLOCK(BasicBlock.BASIC_BLOCK_2, 0, Predicates.alwaysFalse(), false); + + public BasicBlock blockType; + public int meta; + public Predicate facingPredicate; + public boolean activable; + + private BasicBlockType(BasicBlock block, int metadata, Predicate facingAllowed, boolean activeState) + { + blockType = block; + meta = metadata; + facingPredicate = facingAllowed; + activable = activeState; + } + + public static BasicBlockType getBlockType(BasicBlock blockID, int metadata) + { + BasicBlockType firstTry = values()[blockID.ordinal() << 4 | metadata]; + if(firstTry.blockType == blockID && firstTry.meta == metadata) + return firstTry; + for(BasicBlockType type : values()) + { + if(type.blockType == blockID && type.meta == metadata) + return type; + } + return null; + } + + @Override + public String getName() + { + return name().toLowerCase(); + } + + public ItemStack getStack(int amount) + { + return new ItemStack(blockType.implBlock, amount, meta); + } + + public boolean canRotateTo(EnumFacing side) + { + return facingPredicate.apply(side); + } + + public boolean hasRotations() + { + return !facingPredicate.equals(Predicates.alwaysFalse()); + } + + public boolean hasActiveTexture() + { + return activable; + } + } + + public static class BasicBlockPredicate implements Predicate + { + public BasicBlock basicBlock; + + public BasicBlockPredicate(BasicBlock type) + { + basicBlock = type; + } + + @Override + public boolean apply(BasicBlockType input) + { + return input.blockType == basicBlock; + } + } + + public static class BasicBlockStateMapper extends StateMapperBase + { + @Override + protected ModelResourceLocation getModelResourceLocation(IBlockState state) + { + BlockBasic block = (BlockBasic)state.getBlock(); + BasicBlockType type = state.getValue(block.getProperty()); + StringBuilder builder = new StringBuilder(); + if(type.hasRotations()) + { + EnumFacing facing = state.getValue(facingProperty); + if(type.canRotateTo(facing)) + { + builder.append(facingProperty.getName()); + builder.append("="); + builder.append(facing.getName()); + } + else + { + return new ModelResourceLocation("builtin/missing", "missing"); + } + } + if(type.hasActiveTexture()) + { + String active = state.getValue(activeProperty) ? "active" : "inactive"; + if(builder.length() > 0) + { + builder.append(","); + } + builder.append(active); + } + + if(builder.length() == 0) + { + builder.append("normal"); + } + + ResourceLocation baseLocation = new ResourceLocation("mekanism", type.getName()); + return new ModelResourceLocation(baseLocation, builder.toString()); + } + } + +} diff --git a/src/main/java/mekanism/common/block/states/BlockStateBounding.java b/src/main/java/mekanism/common/block/states/BlockStateBounding.java new file mode 100644 index 000000000..cc9aa31d6 --- /dev/null +++ b/src/main/java/mekanism/common/block/states/BlockStateBounding.java @@ -0,0 +1,17 @@ +package mekanism.common.block.states; + +import mekanism.common.MekanismBlocks; +import mekanism.common.block.BlockBounding; + +import net.minecraft.block.properties.PropertyBool; +import net.minecraft.block.state.BlockState; + +public class BlockStateBounding extends BlockState +{ + public static PropertyBool advancedProperty = PropertyBool.create("advanced"); + + public BlockStateBounding(BlockBounding block) + { + super(block, advancedProperty); + } +} diff --git a/src/main/java/mekanism/common/block/states/BlockStateEnergyCube.java b/src/main/java/mekanism/common/block/states/BlockStateEnergyCube.java new file mode 100644 index 000000000..4324da397 --- /dev/null +++ b/src/main/java/mekanism/common/block/states/BlockStateEnergyCube.java @@ -0,0 +1,21 @@ +package mekanism.common.block.states; + +import mekanism.common.MekanismBlocks; +import mekanism.common.Tier; +import mekanism.common.block.BlockEnergyCube; + +import net.minecraft.block.Block; +import net.minecraft.block.properties.PropertyEnum; + +/** + * Created by ben on 23/12/14. + */ +public class BlockStateEnergyCube extends BlockStateFacing +{ + public static final PropertyEnum typeProperty = PropertyEnum.create("tier", Tier.EnergyCubeTier.class); + + public BlockStateEnergyCube(BlockEnergyCube block) + { + super(block, typeProperty); + } +} diff --git a/src/main/java/mekanism/common/block/states/BlockStateFacing.java b/src/main/java/mekanism/common/block/states/BlockStateFacing.java new file mode 100644 index 000000000..b2276514b --- /dev/null +++ b/src/main/java/mekanism/common/block/states/BlockStateFacing.java @@ -0,0 +1,27 @@ +package mekanism.common.block.states; + +import net.minecraft.block.Block; +import net.minecraft.block.properties.PropertyBool; +import net.minecraft.block.properties.PropertyDirection; +import net.minecraft.block.properties.PropertyEnum; +import net.minecraft.block.state.BlockState; + +public class BlockStateFacing extends BlockState +{ + public static final PropertyDirection facingProperty = PropertyDirection.create("facing"); + + public BlockStateFacing(Block block, PropertyEnum typeProperty, PropertyBool activeProperty) + { + super(block, facingProperty, typeProperty, activeProperty); + } + + public BlockStateFacing(Block block, PropertyEnum typeProperty) + { + super(block, facingProperty, typeProperty); + } + + public BlockStateFacing(Block block) + { + super(block, facingProperty); + } +} diff --git a/src/main/java/mekanism/common/block/states/BlockStateGasTank.java b/src/main/java/mekanism/common/block/states/BlockStateGasTank.java new file mode 100644 index 000000000..b7372f1b4 --- /dev/null +++ b/src/main/java/mekanism/common/block/states/BlockStateGasTank.java @@ -0,0 +1,17 @@ +package mekanism.common.block.states; + +import mekanism.common.MekanismBlocks; +import mekanism.common.block.BlockGasTank; + + +/** + * Created by ben on 23/12/14. + */ +public class BlockStateGasTank extends BlockStateFacing +{ + + public BlockStateGasTank(BlockGasTank block) + { + super(block); + } +} diff --git a/src/main/java/mekanism/common/block/states/BlockStateMachine.java b/src/main/java/mekanism/common/block/states/BlockStateMachine.java new file mode 100644 index 000000000..e5496ca71 --- /dev/null +++ b/src/main/java/mekanism/common/block/states/BlockStateMachine.java @@ -0,0 +1,438 @@ +package mekanism.common.block.states; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; + +import mekanism.api.MekanismConfig.general; +import mekanism.api.MekanismConfig.machines; +import mekanism.api.MekanismConfig.usage; +import mekanism.common.Mekanism; +import mekanism.common.MekanismBlocks; +import mekanism.common.block.BlockMachine; +import mekanism.common.recipe.ShapedMekanismRecipe; +import mekanism.common.tile.TileEntityAdvancedFactory; +import mekanism.common.tile.TileEntityAmbientAccumulator; +import mekanism.common.tile.TileEntityChargepad; +import mekanism.common.tile.TileEntityChemicalCrystallizer; +import mekanism.common.tile.TileEntityChemicalDissolutionChamber; +import mekanism.common.tile.TileEntityChemicalInfuser; +import mekanism.common.tile.TileEntityChemicalInjectionChamber; +import mekanism.common.tile.TileEntityChemicalOxidizer; +import mekanism.common.tile.TileEntityChemicalWasher; +import mekanism.common.tile.TileEntityCombiner; +import mekanism.common.tile.TileEntityCrusher; +import mekanism.common.tile.TileEntityDigitalMiner; +import mekanism.common.tile.TileEntityElectricChest; +import mekanism.common.tile.TileEntityElectricPump; +import mekanism.common.tile.TileEntityElectrolyticSeparator; +import mekanism.common.tile.TileEntityEliteFactory; +import mekanism.common.tile.TileEntityEnergizedSmelter; +import mekanism.common.tile.TileEntityEnrichmentChamber; +import mekanism.common.tile.TileEntityEntangledBlock; +import mekanism.common.tile.TileEntityFactory; +import mekanism.common.tile.TileEntityFluidicPlenisher; +import mekanism.common.tile.TileEntityLaser; +import mekanism.common.tile.TileEntityLaserAmplifier; +import mekanism.common.tile.TileEntityLaserTractorBeam; +import mekanism.common.tile.TileEntityLogisticalSorter; +import mekanism.common.tile.TileEntityMetallurgicInfuser; +import mekanism.common.tile.TileEntityOredictionificator; +import mekanism.common.tile.TileEntityOsmiumCompressor; +import mekanism.common.tile.TileEntityPRC; +import mekanism.common.tile.TileEntityPortableTank; +import mekanism.common.tile.TileEntityPrecisionSawmill; +import mekanism.common.tile.TileEntityPurificationChamber; +import mekanism.common.tile.TileEntityRotaryCondensentrator; +import mekanism.common.tile.TileEntitySeismicVibrator; +import mekanism.common.tile.TileEntitySolarNeutronActivator; +import mekanism.common.tile.TileEntityTeleporter; +import mekanism.common.util.LangUtils; + +import net.minecraft.block.Block; +import net.minecraft.block.properties.PropertyBool; +import net.minecraft.block.properties.PropertyEnum; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.block.statemap.StateMapperBase; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumFacing.Plane; +import net.minecraft.util.IStringSerializable; +import net.minecraft.util.ResourceLocation; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; + +public class BlockStateMachine extends BlockStateFacing +{ + public static final PropertyBool activeProperty = PropertyBool.create("active"); + + public BlockStateMachine(BlockMachine block, PropertyEnum typeProperty) + { + super(block, typeProperty, activeProperty); + } + + public static final Predicate never = Predicates.alwaysFalse(); + public static final Predicate always = Predicates.alwaysTrue(); + + public static enum MachineBlock + { + MACHINE_BLOCK_1, + MACHINE_BLOCK_2, + MACHINE_BLOCK_3; + + PropertyEnum machineTypeProperty; + + public PropertyEnum getProperty() + { + if(machineTypeProperty == null) + { + machineTypeProperty = PropertyEnum.create("machineType", MachineType.class, new MachineBlockPredicate(this)); + } + + return machineTypeProperty; + } + + public Block getBlock() + { + switch(this) + { + case MACHINE_BLOCK_1: + return MekanismBlocks.MachineBlock; + case MACHINE_BLOCK_2: + return MekanismBlocks.MachineBlock2; + case MACHINE_BLOCK_3: + return MekanismBlocks.MachineBlock3; + default: + return null; + } + } + } + + public static enum MachineType implements IStringSerializable + { + ENRICHMENT_CHAMBER(MachineBlock.MACHINE_BLOCK_1, 0, "EnrichmentChamber", 3, TileEntityEnrichmentChamber.class, true, false, true, Plane.HORIZONTAL, true), + OSMIUM_COMPRESSOR(MachineBlock.MACHINE_BLOCK_1, 1, "OsmiumCompressor", 4, TileEntityOsmiumCompressor.class, true, false, true, Plane.HORIZONTAL, true), + COMBINER(MachineBlock.MACHINE_BLOCK_1, 2, "Combiner", 5, TileEntityCombiner.class, true, false, true, Plane.HORIZONTAL, true), + CRUSHER(MachineBlock.MACHINE_BLOCK_1, 3, "Crusher", 6, TileEntityCrusher.class, true, false, true, Plane.HORIZONTAL, true), + DIGITAL_MINER(MachineBlock.MACHINE_BLOCK_1, 4, "DigitalMiner", 2, TileEntityDigitalMiner.class, true, true, true, Plane.HORIZONTAL, true), + BASIC_FACTORY(MachineBlock.MACHINE_BLOCK_1, 5, "Factory", 11, TileEntityFactory.class, true, false, true, Plane.HORIZONTAL, true), + ADVANCED_FACTORY(MachineBlock.MACHINE_BLOCK_1, 6, "Factory", 11, TileEntityAdvancedFactory.class, true, false, true, Plane.HORIZONTAL, true), + ELITE_FACTORY(MachineBlock.MACHINE_BLOCK_1, 7, "Factory", 11, TileEntityEliteFactory.class, true, false, true, Plane.HORIZONTAL, true), + METALLURGIC_INFUSER(MachineBlock.MACHINE_BLOCK_1, 8, "MetallurgicInfuser", 12, TileEntityMetallurgicInfuser.class, true, true, true, Plane.HORIZONTAL, false), + PURIFICATION_CHAMBER(MachineBlock.MACHINE_BLOCK_1, 9, "PurificationChamber", 15, TileEntityPurificationChamber.class, true, false, true, Plane.HORIZONTAL, true), + ENERGIZED_SMELTER(MachineBlock.MACHINE_BLOCK_1, 10, "EnergizedSmelter", 16, TileEntityEnergizedSmelter.class, true, false, true, Plane.HORIZONTAL, true), + TELEPORTER(MachineBlock.MACHINE_BLOCK_1, 11, "Teleporter", 13, TileEntityTeleporter.class, true, false, false, never, false), + ELECTRIC_PUMP(MachineBlock.MACHINE_BLOCK_1, 12, "ElectricPump", 17, TileEntityElectricPump.class, true, true, false, Plane.HORIZONTAL, false), + ELECTRIC_CHEST(MachineBlock.MACHINE_BLOCK_1, 13, "ElectricChest", -1, TileEntityElectricChest.class, true, true, false, Plane.HORIZONTAL, false), + CHARGEPAD(MachineBlock.MACHINE_BLOCK_1, 14, "Chargepad", -1, TileEntityChargepad.class, true, true, false, Plane.HORIZONTAL, false), + LOGISTICAL_SORTER(MachineBlock.MACHINE_BLOCK_1, 15, "LogisticalSorter", -1, TileEntityLogisticalSorter.class, false, true, false, Plane.HORIZONTAL, true), + ROTARY_CONDENSENTRATOR(MachineBlock.MACHINE_BLOCK_2, 0, "RotaryCondensentrator", 7, TileEntityRotaryCondensentrator.class, true, true, false, Plane.HORIZONTAL, false), + CHEMICAL_OXIDIZER(MachineBlock.MACHINE_BLOCK_2, 1, "ChemicalOxidizer", 29, TileEntityChemicalOxidizer.class, true, true, true, Plane.HORIZONTAL, true), + CHEMICAL_INFUSER(MachineBlock.MACHINE_BLOCK_2, 2, "ChemicalInfuser", 30, TileEntityChemicalInfuser.class, true, true, false, Plane.HORIZONTAL, true), + CHEMICAL_INJECTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 3, "ChemicalInjectionChamber", 31, TileEntityChemicalInjectionChamber.class, true, false, true, Plane.HORIZONTAL, true), + ELECTROLYTIC_SEPARATOR(MachineBlock.MACHINE_BLOCK_2, 4, "ElectrolyticSeparator", 32, TileEntityElectrolyticSeparator.class, true, true, false, Plane.HORIZONTAL, true), + PRECISION_SAWMILL(MachineBlock.MACHINE_BLOCK_2, 5, "PrecisionSawmill", 34, TileEntityPrecisionSawmill.class, true, false, true, Plane.HORIZONTAL, true), + CHEMICAL_DISSOLUTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 6, "ChemicalDissolutionChamber", 35, TileEntityChemicalDissolutionChamber.class, true, true, true, Plane.HORIZONTAL, true), + CHEMICAL_WASHER(MachineBlock.MACHINE_BLOCK_2, 7, "ChemicalWasher", 36, TileEntityChemicalWasher.class, true, true, false, Plane.HORIZONTAL, true), + CHEMICAL_CRYSTALLIZER(MachineBlock.MACHINE_BLOCK_2, 8, "ChemicalCrystallizer", 37, TileEntityChemicalCrystallizer.class, true, true, true, Plane.HORIZONTAL, true), + SEISMIC_VIBRATOR(MachineBlock.MACHINE_BLOCK_2, 9, "SeismicVibrator", 39, TileEntitySeismicVibrator.class, true, true, false, Plane.HORIZONTAL, true), + PRESSURIZED_REACTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 10, "PressurizedReactionChamber", 40, TileEntityPRC.class, true, true, false, Plane.HORIZONTAL, true), + PORTABLE_TANK(MachineBlock.MACHINE_BLOCK_2, 11, "PortableTank", 41, TileEntityPortableTank.class, false, true, false, never, true), + FLUIDIC_PLENISHER(MachineBlock.MACHINE_BLOCK_2, 12, "FluidicPlenisher", 42, TileEntityFluidicPlenisher.class, true, true, false, Plane.HORIZONTAL, true), + LASER(MachineBlock.MACHINE_BLOCK_2, 13, "Laser", -1, TileEntityLaser.class, true, true, false, always, false), + LASER_AMPLIFIER(MachineBlock.MACHINE_BLOCK_2, 14, "LaserAmplifier", 44, TileEntityLaserAmplifier.class, false, true, false, always, true), + LASER_TRACTOR_BEAM(MachineBlock.MACHINE_BLOCK_2, 15, "LaserTractorBeam", 45, TileEntityLaserTractorBeam.class, false, true, false, always, true), + ENTANGLED_BLOCK(MachineBlock.MACHINE_BLOCK_3, 0, "EntangledBlock", 46, TileEntityEntangledBlock.class, true, false, false, Plane.HORIZONTAL, true), + SOLAR_NEUTRON_ACTIVATOR(MachineBlock.MACHINE_BLOCK_3, 1, "SolarNeutronActivator", 47, TileEntitySolarNeutronActivator.class, false, true, false, Plane.HORIZONTAL, true), + AMBIENT_ACCUMULATOR(MachineBlock.MACHINE_BLOCK_3, 2, "AmbientAccumulator", 48, TileEntityAmbientAccumulator.class, true, false, false, never, true), + OREDICTIONIFICATOR(MachineBlock.MACHINE_BLOCK_3, 3, "Oredictionificator", 52, TileEntityOredictionificator.class, false, false, false, Plane.HORIZONTAL, true); + + public MachineBlock typeBlock; + public int meta; + public String machineName; + public int guiId; + public double baseEnergy; + public Class tileEntityClass; + public boolean isElectric; + public boolean hasModel; + public boolean supportsUpgrades; + public Collection machineRecipes = new HashSet(); + public Predicate facingPredicate; + public boolean activable; + + private MachineType(MachineBlock block, int i, String s, int j, Class tileClass, boolean electric, boolean model, boolean upgrades, Predicate predicate, boolean hasActiveTexture) + { + typeBlock = block; + meta = i; + machineName = s; + guiId = j; + tileEntityClass = tileClass; + isElectric = electric; + hasModel = model; + supportsUpgrades = upgrades; + facingPredicate = predicate; + activable = hasActiveTexture; + } + + public boolean isEnabled() + { + return machines.isEnabled(this.machineName); + } + + public void addRecipes(Collection recipes) + { + machineRecipes.addAll(recipes); + } + + public void addRecipe(ShapedMekanismRecipe recipe) + { + machineRecipes.add(recipe); + } + + public Collection getRecipes() + { + return machineRecipes; + } + + public static List getValidMachines() + { + List ret = new ArrayList(); + + for(MachineType type : MachineType.values()) + { + if(type != ENTANGLED_BLOCK && type != AMBIENT_ACCUMULATOR) + { + ret.add(type); + } + } + + return ret; + } + + public static MachineType get(Block block, int meta) + { + if(block instanceof BlockMachine) + { + return get(((BlockMachine)block).getMachineBlock(), meta); + } + + return null; + } + + public static MachineType get(MachineBlock block, int meta) + { + for(MachineType type : values()) + { + if(type.meta == meta && type.typeBlock == block) + { + return type; + } + } + + return null; + } + + public TileEntity create() + { + try { + return tileEntityClass.newInstance(); + } catch(Exception e) { + Mekanism.logger.error("Unable to indirectly create tile entity."); + e.printStackTrace(); + return null; + } + } + + /** Used for getting the base energy storage. */ + public double getUsage() + { + switch(this) + { + case ENRICHMENT_CHAMBER: + return usage.enrichmentChamberUsage; + case OSMIUM_COMPRESSOR: + return usage.osmiumCompressorUsage; + case COMBINER: + return usage.combinerUsage; + case CRUSHER: + return usage.crusherUsage; + case DIGITAL_MINER: + return usage.digitalMinerUsage; + case BASIC_FACTORY: + return usage.factoryUsage * 3; + case ADVANCED_FACTORY: + return usage.factoryUsage * 5; + case ELITE_FACTORY: + return usage.factoryUsage * 7; + case METALLURGIC_INFUSER: + return usage.metallurgicInfuserUsage; + case PURIFICATION_CHAMBER: + return usage.purificationChamberUsage; + case ENERGIZED_SMELTER: + return usage.energizedSmelterUsage; + case TELEPORTER: + return 12500; + case ELECTRIC_PUMP: + return usage.electricPumpUsage; + case ELECTRIC_CHEST: + return 30; + case CHARGEPAD: + return 25; + case LOGISTICAL_SORTER: + return 0; + case ROTARY_CONDENSENTRATOR: + return usage.rotaryCondensentratorUsage; + case CHEMICAL_OXIDIZER: + return usage.oxidationChamberUsage; + case CHEMICAL_INFUSER: + return usage.chemicalInfuserUsage; + case CHEMICAL_INJECTION_CHAMBER: + return usage.chemicalInjectionChamberUsage; + case ELECTROLYTIC_SEPARATOR: + return general.FROM_H2 * 2; + case PRECISION_SAWMILL: + return usage.precisionSawmillUsage; + case CHEMICAL_DISSOLUTION_CHAMBER: + return usage.chemicalDissolutionChamberUsage; + case CHEMICAL_WASHER: + return usage.chemicalWasherUsage; + case CHEMICAL_CRYSTALLIZER: + return usage.chemicalCrystallizerUsage; + case SEISMIC_VIBRATOR: + return usage.seismicVibratorUsage; + case PRESSURIZED_REACTION_CHAMBER: + return usage.pressurizedReactionBaseUsage; + case PORTABLE_TANK: + return 0; + case FLUIDIC_PLENISHER: + return usage.fluidicPlenisherUsage; + case LASER: + return usage.laserUsage; + case LASER_AMPLIFIER: + return 0; + case LASER_TRACTOR_BEAM: + return 0; + case ENTANGLED_BLOCK: + return 0; + case SOLAR_NEUTRON_ACTIVATOR: + return 0; + case AMBIENT_ACCUMULATOR: + return 0; + default: + return 0; + } + } + + public static void updateAllUsages() + { + for(MachineType type : values()) + { + type.updateUsage(); + } + } + + public void updateUsage() + { + baseEnergy = 400 * getUsage(); + } + + public String getDescription() + { + return LangUtils.localize("tooltip." + machineName); + } + + public ItemStack getStack() + { + return new ItemStack(typeBlock.getBlock(), 1, meta); + } + + public static MachineType get(ItemStack stack) + { + return get(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage()); + } + + @Override + public String getName() + { + return name().toLowerCase(); + } + + public boolean canRotateTo(EnumFacing side) + { + return facingPredicate.apply(side); + } + + public boolean hasRotations() + { + return !facingPredicate.equals(Predicates.alwaysFalse()); + } + + public boolean hasActiveTexture() + { + return activable; + } + + } + + public static class MachineBlockPredicate implements Predicate + { + public MachineBlock machineBlock; + + public MachineBlockPredicate(MachineBlock type) + { + machineBlock = type; + } + + @Override + public boolean apply(MachineType input) + { + return input.typeBlock == machineBlock; + } + } + + public static class MachineBlockStateMapper extends StateMapperBase + { + @Override + protected ModelResourceLocation getModelResourceLocation(IBlockState state) + { + BlockMachine block = (BlockMachine)state.getBlock(); + MachineType type = state.getValue(block.getProperty()); + StringBuilder builder = new StringBuilder(); + if(type.hasRotations()) + { + EnumFacing facing = state.getValue(facingProperty); + if(type.canRotateTo(facing)) + { + builder.append(facingProperty.getName()); + builder.append("="); + builder.append(facing.getName()); + } + else + { + return new ModelResourceLocation("builtin/missing", "missing"); + } + } + if(type.hasActiveTexture()) + { + String active = state.getValue(activeProperty) ? "active" : "inactive"; + if(builder.length() > 0) + { + builder.append(","); + } + builder.append(active); + } + + if(builder.length() == 0) + { + builder.append("normal"); + } + + ResourceLocation baseLocation = new ResourceLocation("mekanism", type.getName()); + return new ModelResourceLocation(baseLocation, builder.toString()); + } + } +} diff --git a/src/main/java/mekanism/common/block/states/BlockStateOre.java b/src/main/java/mekanism/common/block/states/BlockStateOre.java new file mode 100644 index 000000000..d42234d32 --- /dev/null +++ b/src/main/java/mekanism/common/block/states/BlockStateOre.java @@ -0,0 +1,34 @@ +package mekanism.common.block.states; + +import mekanism.common.MekanismBlocks; +import mekanism.common.block.BlockOre; + +import net.minecraft.block.properties.PropertyEnum; +import net.minecraft.block.state.BlockState; +import net.minecraft.util.IStringSerializable; + +/** + * Created by ben on 23/12/14. + */ +public class BlockStateOre extends BlockState +{ + public static final PropertyEnum typeProperty = PropertyEnum.create("type", EnumOreType.class); + + public BlockStateOre(BlockOre block) + { + super(block, typeProperty); + } + + public static enum EnumOreType implements IStringSerializable + { + OSMIUM, + COPPER, + TIN; + + @Override + public String getName() + { + return name().toLowerCase(); + } + } +} diff --git a/src/main/java/mekanism/common/block/states/BlockStatePlastic.java b/src/main/java/mekanism/common/block/states/BlockStatePlastic.java new file mode 100644 index 000000000..9a285a4af --- /dev/null +++ b/src/main/java/mekanism/common/block/states/BlockStatePlastic.java @@ -0,0 +1,38 @@ +package mekanism.common.block.states; + +import mekanism.api.EnumColor; +import mekanism.common.MekanismBlocks; +import mekanism.common.block.BlockPlastic; + +import net.minecraft.block.Block; +import net.minecraft.block.properties.PropertyDirection; +import net.minecraft.block.properties.PropertyEnum; +import net.minecraft.block.state.BlockState; +import net.minecraft.item.EnumDyeColor; +import net.minecraft.util.IStringSerializable; + +public class BlockStatePlastic extends BlockState +{ + public static PropertyEnum colorProperty = PropertyEnum.create("color", EnumDyeColor.class); + public static PropertyEnum typeProperty = PropertyEnum.create("type", PlasticBlockType.class); + + public BlockStatePlastic(BlockPlastic block) + { + super(block, colorProperty, typeProperty); + } + + public static enum PlasticBlockType implements IStringSerializable + { + PLASTIC, + SLICK, + GLOW, + REINFORCED, + ROAD; + + @Override + public String getName() + { + return name().toLowerCase(); + } + } +} diff --git a/src/main/java/mekanism/common/inventory/container/ContainerElectricChest.java b/src/main/java/mekanism/common/inventory/container/ContainerElectricChest.java index d68e4fce7..cb35a9e83 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerElectricChest.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerElectricChest.java @@ -1,7 +1,7 @@ package mekanism.common.inventory.container; import mekanism.common.base.IElectricChest; -import mekanism.common.block.BlockMachine.MachineType; +import mekanism.common.block.states.BlockStateMachine; import mekanism.common.inventory.slot.SlotElectricChest; import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge; import mekanism.common.tile.TileEntityElectricChest; @@ -170,7 +170,7 @@ public class ContainerElectricChest extends Container ItemStack itemStack = player.inventory.getStackInSlot(destSlot); if(itemStack != null && itemStack.getItem() instanceof IElectricChest) { - if(MachineType.get(itemStack) == MachineType.ELECTRIC_CHEST) + if(BlockStateMachine.MachineType.get(itemStack) == BlockStateMachine.MachineType.ELECTRIC_CHEST) { return null; } diff --git a/src/main/java/mekanism/common/inventory/slot/SlotElectricChest.java b/src/main/java/mekanism/common/inventory/slot/SlotElectricChest.java index 76a5670c8..b843e3a6d 100644 --- a/src/main/java/mekanism/common/inventory/slot/SlotElectricChest.java +++ b/src/main/java/mekanism/common/inventory/slot/SlotElectricChest.java @@ -1,7 +1,7 @@ package mekanism.common.inventory.slot; import mekanism.common.base.IElectricChest; -import mekanism.common.block.BlockMachine.MachineType; +import mekanism.common.block.states.BlockStateMachine; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -27,7 +27,7 @@ public class SlotElectricChest extends Slot if(itemstack.getItem() instanceof IElectricChest) { - if(MachineType.get(itemstack) == MachineType.ELECTRIC_CHEST) + if(BlockStateMachine.MachineType.get(itemstack) == BlockStateMachine.MachineType.ELECTRIC_CHEST) { return false; } diff --git a/src/main/java/mekanism/common/item/ItemBlockMachine.java b/src/main/java/mekanism/common/item/ItemBlockMachine.java index b62f341e6..8b2ea7045 100644 --- a/src/main/java/mekanism/common/item/ItemBlockMachine.java +++ b/src/main/java/mekanism/common/item/ItemBlockMachine.java @@ -22,7 +22,8 @@ import mekanism.common.Tier.BaseTier; import mekanism.common.Upgrade; import mekanism.common.base.*; import mekanism.common.base.IRedstoneControl.RedstoneControl; -import mekanism.common.block.BlockMachine.MachineType; +import mekanism.common.block.states.BlockStateMachine.MachineType; +import mekanism.common.block.states.BlockStateMachine; import mekanism.common.integration.IC2ItemManager; import mekanism.common.inventory.InventoryElectricChest; import mekanism.common.network.PacketElectricChest.ElectricChestMessage; @@ -126,9 +127,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec @Override public String getUnlocalizedName(ItemStack itemstack) { - if(MachineType.get(itemstack) != null) + if(BlockStateMachine.MachineType.get(itemstack) != null) { - return getUnlocalizedName() + "." + MachineType.get(itemstack).name; + return getUnlocalizedName() + "." + BlockStateMachine.MachineType.get(itemstack).machineName; } return "null"; @@ -137,11 +138,11 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec @Override public String getItemStackDisplayName(ItemStack itemstack) { - MachineType type = MachineType.get(itemstack); + MachineType type = BlockStateMachine.MachineType.get(itemstack); - if(type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY || type == MachineType.ELITE_FACTORY) + if(type == BlockStateMachine.MachineType.BASIC_FACTORY || type == BlockStateMachine.MachineType.ADVANCED_FACTORY || type == BlockStateMachine.MachineType.ELITE_FACTORY) { - BaseTier tier = type == MachineType.BASIC_FACTORY ? BaseTier.BASIC : (type == MachineType.ADVANCED_FACTORY ? BaseTier.ADVANCED : BaseTier.ELITE); + BaseTier tier = type == BlockStateMachine.MachineType.BASIC_FACTORY ? BaseTier.BASIC : (type == BlockStateMachine.MachineType.ADVANCED_FACTORY ? BaseTier.ADVANCED : BaseTier.ELITE); if(StatCollector.canTranslate("tile." + tier.getName() + RecipeType.values()[getRecipeType(itemstack)].getUnlocalizedName() + "Factory")) { @@ -158,11 +159,11 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { - MachineType type = MachineType.get(itemstack); + MachineType type = BlockStateMachine.MachineType.get(itemstack); if(!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) { - if(type == MachineType.PORTABLE_TANK) + if(type == BlockStateMachine.MachineType.PORTABLE_TANK) { FluidStack fluidStack = getFluidStack(itemstack); @@ -177,18 +178,18 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } else if(!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.modeSwitchKey)) { - if(type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY || type == MachineType.ELITE_FACTORY) + if(type == BlockStateMachine.MachineType.BASIC_FACTORY || type == BlockStateMachine.MachineType.ADVANCED_FACTORY || type == BlockStateMachine.MachineType.ELITE_FACTORY) { list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.recipeType") + ": " + EnumColor.GREY + RecipeType.values()[getRecipeType(itemstack)].getLocalizedName()); } - if(type == MachineType.ELECTRIC_CHEST) + if(type == BlockStateMachine.MachineType.ELECTRIC_CHEST) { list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.auth") + ": " + EnumColor.GREY + LangUtils.transYesNo(getAuthenticated(itemstack))); list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.locked") + ": " + EnumColor.GREY + LangUtils.transYesNo(getLocked(itemstack))); } - if(type == MachineType.PORTABLE_TANK) + if(type == BlockStateMachine.MachineType.PORTABLE_TANK) { list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.portableTank.bucketMode") + ": " + EnumColor.GREY + LangUtils.transYesNo(getBucketMode(itemstack))); } @@ -198,7 +199,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec list.add(EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); } - if(hasTank(itemstack) && type != MachineType.PORTABLE_TANK) + if(hasTank(itemstack) && type != BlockStateMachine.MachineType.PORTABLE_TANK) { FluidStack fluidStack = getFluidStack(itemstack); @@ -208,7 +209,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } } - if(type != MachineType.CHARGEPAD && type != MachineType.LOGISTICAL_SORTER) + if(type != BlockStateMachine.MachineType.CHARGEPAD && type != BlockStateMachine.MachineType.LOGISTICAL_SORTER) { list.add(EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + EnumColor.GREY + LangUtils.transYesNo(getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); } @@ -231,9 +232,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec @Override public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { - MachineType type = MachineType.get(stack); + MachineType type = BlockStateMachine.MachineType.get(stack); - if(type == MachineType.PORTABLE_TANK && getBucketMode(stack)) + if(type == BlockStateMachine.MachineType.PORTABLE_TANK && getBucketMode(stack)) { return false; } @@ -246,9 +247,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec { boolean place = true; - MachineType type = MachineType.get(stack); + MachineType type = BlockStateMachine.MachineType.get(stack); - if(type == MachineType.DIGITAL_MINER) + if(type == BlockStateMachine.MachineType.DIGITAL_MINER) { for(int xPos = -1; xPos <= +1; xPos++) { @@ -267,7 +268,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } } } - else if(type == MachineType.SOLAR_NEUTRON_ACTIVATOR) + else if(type == BlockStateMachine.MachineType.SOLAR_NEUTRON_ACTIVATOR) { if(pos.getY()+1 > 255 || !world.getBlockState(pos.up()).getBlock().isReplaceable(world, pos.up())) { @@ -385,9 +386,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec @Override public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag) { - MachineType type = MachineType.get(itemstack); + MachineType type = BlockStateMachine.MachineType.get(itemstack); - if(type == MachineType.ELECTRIC_CHEST) + if(type == BlockStateMachine.MachineType.ELECTRIC_CHEST) { if(world != null && !world.isRemote) { @@ -434,7 +435,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } } } - else if(type == MachineType.PORTABLE_TANK) + else if(type == BlockStateMachine.MachineType.PORTABLE_TANK) { if(world != null && !world.isRemote) { @@ -497,9 +498,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { - MachineType type = MachineType.get(itemstack); + MachineType type = BlockStateMachine.MachineType.get(itemstack); - if(MachineType.get(itemstack) == MachineType.ELECTRIC_CHEST) + if(BlockStateMachine.MachineType.get(itemstack) == BlockStateMachine.MachineType.ELECTRIC_CHEST) { if(!world.isRemote) { @@ -517,7 +518,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } } } - else if(type == MachineType.PORTABLE_TANK && getBucketMode(itemstack)) + else if(type == BlockStateMachine.MachineType.PORTABLE_TANK && getBucketMode(itemstack)) { MovingObjectPosition pos = getMovingObjectPositionFromPlayer(world, entityplayer, !entityplayer.isSneaking()); @@ -705,9 +706,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec return false; } - MachineType type = MachineType.get((ItemStack)data[0]); + MachineType type = BlockStateMachine.MachineType.get((ItemStack)data[0]); - return type == MachineType.ELECTRIC_PUMP || type == MachineType.PORTABLE_TANK || type == MachineType.FLUIDIC_PLENISHER; + return type == BlockStateMachine.MachineType.ELECTRIC_PUMP || type == BlockStateMachine.MachineType.PORTABLE_TANK || type == BlockStateMachine.MachineType.FLUIDIC_PLENISHER; } @Override @@ -841,7 +842,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec @Override public double getEnergy(ItemStack itemStack) { - if(itemStack.getTagCompound() == null || !MachineType.get(itemStack).isElectric) + if(itemStack.getTagCompound() == null || !BlockStateMachine.MachineType.get(itemStack).isElectric) { return 0; } @@ -852,7 +853,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec @Override public void setEnergy(ItemStack itemStack, double amount) { - if(!MachineType.get(itemStack).isElectric) + if(!BlockStateMachine.MachineType.get(itemStack).isElectric) { return; } @@ -869,7 +870,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec @Override public double getMaxEnergy(ItemStack itemStack) { - return MekanismUtils.getMaxEnergy(itemStack, MachineType.get(Block.getBlockFromItem(itemStack.getItem()), itemStack.getItemDamage()).baseEnergy); + return MekanismUtils.getMaxEnergy(itemStack, BlockStateMachine.MachineType.get(Block.getBlockFromItem(itemStack.getItem()), itemStack.getItemDamage()).baseEnergy); } @Override @@ -881,7 +882,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec @Override public boolean canReceive(ItemStack itemStack) { - return MachineType.get(itemStack).isElectric; + return BlockStateMachine.MachineType.get(itemStack).isElectric; } @Override @@ -982,7 +983,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec @Override public int fill(ItemStack container, FluidStack resource, boolean doFill) { - if(MachineType.get(container) == MachineType.PORTABLE_TANK && resource != null) + if(BlockStateMachine.MachineType.get(container) == BlockStateMachine.MachineType.PORTABLE_TANK && resource != null) { FluidStack stored = getFluidStack(container); int toFill; @@ -1015,7 +1016,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec @Override public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) { - if(MachineType.get(container) == MachineType.PORTABLE_TANK) + if(BlockStateMachine.MachineType.get(container) == BlockStateMachine.MachineType.PORTABLE_TANK) { FluidStack stored = getFluidStack(container); diff --git a/src/main/java/mekanism/common/network/PacketConfigSync.java b/src/main/java/mekanism/common/network/PacketConfigSync.java index 43a2644e9..50f6b5936 100644 --- a/src/main/java/mekanism/common/network/PacketConfigSync.java +++ b/src/main/java/mekanism/common/network/PacketConfigSync.java @@ -8,7 +8,8 @@ import mekanism.api.util.UnitDisplayUtils.EnergyType; import mekanism.common.Mekanism; import mekanism.common.Tier; import mekanism.common.base.IModule; -import mekanism.common.block.BlockMachine.MachineType; +import mekanism.common.block.states.BlockStateMachine.MachineType; +import mekanism.common.block.states.BlockStateMachine; import mekanism.common.network.PacketConfigSync.ConfigSyncMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; @@ -63,9 +64,9 @@ public class PacketConfigSync implements IMessageHandler { public TileEntityChemicalInjectionChamber() { - super("injection", "ChemicalInjectionChamber", usage.chemicalInjectionChamberUsage, 1, 200, MachineType.CHEMICAL_INJECTION_CHAMBER.baseEnergy); + super("injection", "ChemicalInjectionChamber", usage.chemicalInjectionChamberUsage, 1, 200, BlockStateMachine.MachineType.CHEMICAL_INJECTION_CHAMBER.baseEnergy); configComponent.addSupported(TransmissionType.GAS); configComponent.addOutput(TransmissionType.GAS, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java b/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java index 627f34553..7dad9856e 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java @@ -20,7 +20,7 @@ import mekanism.common.base.ITankManager; import mekanism.common.base.IRedstoneControl; import mekanism.common.base.ISustainedData; import mekanism.common.base.IUpgradeTile; -import mekanism.common.block.BlockMachine.MachineType; +import mekanism.common.block.states.BlockStateMachine; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.ItemStackInput; @@ -32,10 +32,8 @@ import mekanism.common.util.MekanismUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing.Axis; -import net.minecraft.util.IChatComponent; public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock implements ITubeConnection, IRedstoneControl, IUpgradeTile, ISustainedData, ITankManager { @@ -71,7 +69,7 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp public TileEntityChemicalOxidizer() { - super("machine.oxidizer", "ChemicalOxidizer", MachineType.CHEMICAL_OXIDIZER.baseEnergy); + super("machine.oxidizer", "ChemicalOxidizer", BlockStateMachine.MachineType.CHEMICAL_OXIDIZER.baseEnergy); inventory = new ItemStack[4]; } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java b/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java index b68e4c6ec..77d8bc737 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java @@ -12,7 +12,7 @@ import mekanism.common.base.IRedstoneControl; import mekanism.common.base.ISustainedData; import mekanism.common.base.ITankManager; import mekanism.common.base.IUpgradeTile; -import mekanism.common.block.BlockMachine.MachineType; +import mekanism.common.block.states.BlockStateMachine; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.GasInput; @@ -22,10 +22,8 @@ import mekanism.common.util.*; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing.Axis; -import net.minecraft.util.IChatComponent; import net.minecraftforge.fluids.*; import java.util.ArrayList; @@ -67,7 +65,7 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple public TileEntityChemicalWasher() { - super("machine.washer", "ChemicalWasher", MachineType.CHEMICAL_WASHER.baseEnergy); + super("machine.washer", "ChemicalWasher", BlockStateMachine.MachineType.CHEMICAL_WASHER.baseEnergy); inventory = new ItemStack[5]; } diff --git a/src/main/java/mekanism/common/tile/TileEntityCombiner.java b/src/main/java/mekanism/common/tile/TileEntityCombiner.java index 436aeefed..deac5ac7c 100644 --- a/src/main/java/mekanism/common/tile/TileEntityCombiner.java +++ b/src/main/java/mekanism/common/tile/TileEntityCombiner.java @@ -6,7 +6,7 @@ import mekanism.api.MekanismConfig.usage; import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; -import mekanism.common.block.BlockMachine.MachineType; +import mekanism.common.block.states.BlockStateMachine; import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.recipe.machines.CombinerRecipe; @@ -14,14 +14,12 @@ import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.IChatComponent; public class TileEntityCombiner extends TileEntityAdvancedElectricMachine { public TileEntityCombiner() { - super("combiner", "Combiner", usage.combinerUsage, 1, 200, MachineType.COMBINER.baseEnergy); + super("combiner", "Combiner", usage.combinerUsage, 1, 200, BlockStateMachine.MachineType.COMBINER.baseEnergy); } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntityCrusher.java b/src/main/java/mekanism/common/tile/TileEntityCrusher.java index 8a1c7d31c..82c5ddced 100644 --- a/src/main/java/mekanism/common/tile/TileEntityCrusher.java +++ b/src/main/java/mekanism/common/tile/TileEntityCrusher.java @@ -3,7 +3,7 @@ package mekanism.common.tile; import java.util.Map; import mekanism.api.MekanismConfig.usage; -import mekanism.common.block.BlockMachine.MachineType; +import mekanism.common.block.states.BlockStateMachine; import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.recipe.machines.CrusherRecipe; @@ -14,7 +14,7 @@ public class TileEntityCrusher extends TileEntityElectricMachine { public TileEntityCrusher() { - super("crusher", "Crusher", usage.crusherUsage, 200, MachineType.CRUSHER.baseEnergy); + super("crusher", "Crusher", usage.crusherUsage, 200, BlockStateMachine.MachineType.CRUSHER.baseEnergy); } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java b/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java index 53112f5b2..9e110fe4b 100644 --- a/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java +++ b/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java @@ -11,7 +11,7 @@ import mekanism.common.HashList; import mekanism.common.Mekanism; import mekanism.common.Upgrade; import mekanism.common.base.*; -import mekanism.common.block.BlockMachine.MachineType; +import mekanism.common.block.states.BlockStateMachine; import mekanism.common.content.miner.MItemStackFilter; import mekanism.common.content.miner.MOreDictFilter; import mekanism.common.content.miner.MinerFilter; @@ -104,7 +104,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I public TileEntityDigitalMiner() { - super("DigitalMiner", MachineType.DIGITAL_MINER.baseEnergy); + super("DigitalMiner", BlockStateMachine.MachineType.DIGITAL_MINER.baseEnergy); inventory = new ItemStack[29]; radius = 10; } diff --git a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java index 3e32885bd..8edd035ae 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java @@ -9,7 +9,7 @@ import mekanism.common.Mekanism; import mekanism.common.Upgrade; import mekanism.common.Upgrade.IUpgradeInfoHandler; import mekanism.common.base.*; -import mekanism.common.block.BlockMachine.MachineType; +import mekanism.common.block.states.BlockStateMachine; import mekanism.common.integration.IComputerIntegration; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.recipe.RecipeHandler; @@ -84,7 +84,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp public TileEntityElectrolyticSeparator() { - super("ElectrolyticSeparator", MachineType.ELECTROLYTIC_SEPARATOR.baseEnergy); + super("ElectrolyticSeparator", BlockStateMachine.MachineType.ELECTROLYTIC_SEPARATOR.baseEnergy); inventory = new ItemStack[5]; } diff --git a/src/main/java/mekanism/common/tile/TileEntityEliteFactory.java b/src/main/java/mekanism/common/tile/TileEntityEliteFactory.java index b697022e8..c0b9165ea 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEliteFactory.java +++ b/src/main/java/mekanism/common/tile/TileEntityEliteFactory.java @@ -4,7 +4,7 @@ import mekanism.api.EnumColor; import mekanism.api.transmitters.TransmissionType; import mekanism.common.SideData; import mekanism.common.Tier.FactoryTier; -import mekanism.common.block.BlockMachine.MachineType; +import mekanism.common.block.states.BlockStateMachine; import mekanism.common.tile.component.TileComponentConfig; import mekanism.common.tile.component.TileComponentEjector; import mekanism.common.tile.component.TileComponentUpgrade; @@ -14,7 +14,7 @@ public class TileEntityEliteFactory extends TileEntityFactory { public TileEntityEliteFactory() { - super(FactoryTier.ELITE, MachineType.ELITE_FACTORY); + super(FactoryTier.ELITE, BlockStateMachine.MachineType.ELITE_FACTORY); configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.GAS); diff --git a/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java b/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java index 90e4c6468..d7f069692 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java +++ b/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java @@ -3,7 +3,7 @@ package mekanism.common.tile; import java.util.Map; import mekanism.api.MekanismConfig.usage; -import mekanism.common.block.BlockMachine.MachineType; +import mekanism.common.block.states.BlockStateMachine; import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.machines.SmeltingRecipe; @@ -12,7 +12,7 @@ public class TileEntityEnergizedSmelter extends TileEntityElectricMachine upgrades = new HashMap(); @@ -176,7 +176,7 @@ public class RecipeUtils { ItemStack itemstack = inv.getStackInSlot(i); - if(itemstack != null && MachineType.get(itemstack) != null && MachineType.get(itemstack).supportsUpgrades) + if(itemstack != null && BlockStateMachine.MachineType.get(itemstack) != null && BlockStateMachine.MachineType.get(itemstack).supportsUpgrades) { Map stackMap = Upgrade.buildMap(itemstack.getTagCompound()); diff --git a/src/main/resources/assets/mekanism/blockstates/metallurgic_infuser.json b/src/main/resources/assets/mekanism/blockstates/metallurgic_infuser.json new file mode 100644 index 000000000..032b344bf --- /dev/null +++ b/src/main/resources/assets/mekanism/blockstates/metallurgic_infuser.json @@ -0,0 +1,18 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "mekanism:metallurgic_infuser" + }, + "variants": { + "normal": [{}], + "facing": { + "north": {}, + "south": {}, + "east": {}, + "west": {} + }, + "active": [{}], + "inventory": [{}] + } +} + diff --git a/src/main/resources/assets/mekanism/models/block/metallurgic_infuser.json b/src/main/resources/assets/mekanism/models/block/metallurgic_infuser.json new file mode 100644 index 000000000..a736cf8c8 --- /dev/null +++ b/src/main/resources/assets/mekanism/models/block/metallurgic_infuser.json @@ -0,0 +1,265 @@ +{ + "textures": { + "render": "mekanism:blocks/models/MetallurgicInfuser" + }, + "elements": [ + { "__comment": "Base", + "from": [ 1, 0, 0 ], + "to": [ 15, 2, 16 ], + "faces": { + "down": { "uv": [7.5, 0, 11, 4], "texture": "render", "cullface": "down" }, + "up": { "uv": [4, 0, 7.5, 4], "texture": "render" }, + "north": { "uv": [4, 4, 7.5, 4.5], "texture": "render", "cullface": "north" }, + "south": { "uv": [11.5, 4, 7.5, 4.5], "texture": "render", "cullface": "south" }, + "west": { "uv": [7.5, 4, 11.5, 4.5], "texture": "render" }, + "east": { "uv": [0, 4, 4, 4.5], "texture": "render" } + } + }, + { "__comment": "EastChamber", + "from": [ 13.5, 2, 2 ], + "to": [ 14.5, 8, 7 ], + "faces": { + "down": { "texture": "render" }, + "up": { "texture": "render" }, + "north": { "texture": "render" }, + "south": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "TopChamber", + "from": [ 2.5, 8, 2 ], + "to": [ 13.5, 9, 7 ], + "faces": { + "up": { "texture": "render" }, + "north": { "texture": "render" }, + "south": { "texture": "render" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "BackChamber", + "from": [ 2.5, 2, 7 ], + "to": [ 13.5, 8, 8 ], + "faces": { + "down": { "texture": "render" }, + "up": { "texture": "render" }, + "south": { "texture": "render" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "WestChamber", + "from": [ 1.5, 2, 2 ], + "to": [ 2.5, 8, 7 ], + "faces": { + "down": { "texture": "render" }, + "up": { "texture": "render" }, + "north": { "texture": "render" }, + "south": { "texture": "render" }, + "west": { "texture": "render" } + } + }, + { "__comment": "FCTop", + "from": [ 2.5, 7, 1 ], + "to": [ 13.5, 8, 2 ], + "faces": { + "up": { "texture": "render" }, + "north": { "texture": "render" }, + "south": { "texture": "render" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "FCBottom", + "from": [ 2.5, 2, 1 ], + "to": [ 13.5, 3, 2 ], + "faces": { + "down": { "texture": "render" }, + "north": { "texture": "render" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "FCEast", + "from": [ 12.5, 3, 1 ], + "to": [ 13.5, 7, 2 ], + "faces": { + "north": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "FCWest", + "from": [ 2.5, 3, 1 ], + "to": [ 3.5, 7, 2 ], + "faces": { + "north": { "texture": "render" }, + "west": { "texture": "render" } + } + }, + { "__comment": "FCDoor", + "from": [ 3.5, 3, 0.5 ], + "to": [ 12.5, 7, 1.5 ], + "faces": { + "down": { "texture": "render" }, + "up": { "texture": "render" }, + "north": { "texture": "render" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "Cable1", + "from": [ 3.5, 3.5, 8 ], + "to": [ 4.5, 4.5, 15 ], + "faces": { + "down": { "texture": "render" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "Cable2", + "from": [ 3, 4, 8 ], + "to": [ 5, 6, 15 ], + "faces": { + "down": { "texture": "render" }, + "up": { "texture": "render" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "Cable3", + "from": [ 11, 4, 8 ], + "to": [ 13, 6, 15 ], + "faces": { + "down": { "texture": "render" }, + "up": { "texture": "render" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "Cable4", + "from": [ 3.5, 5.5, 8 ], + "to": [ 4.5, 6.5, 15 ], + "faces": { + "up": { "texture": "render" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "Cable5", + "from": [ 11.5, 3.5, 8 ], + "to": [ 12.5, 4.5, 15 ], + "faces": { + "down": { "texture": "render" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "Cable6", + "from": [ 11.5, 5.5, 8 ], + "to": [ 12.5, 6.5, 15 ], + "faces": { + "up": { "texture": "render" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "TopPanelDec", + "from": [ 1.5, 11.5, 13.5 ], + "to": [ 14.5, 12.5, 14.5 ], + "faces": { + "down": { "texture": "render" }, + "north": { "texture": "render" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "BackPlate", + "from": [ 1, 2, 14 ], + "to": [ 15, 14, 16 ], + "faces": { + "up": { "texture": "render" }, + "north": { "texture": "render" }, + "south": { "texture": "render", "cullface": "south" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "TopPanel", + "from": [ 1, 12, 11 ], + "to": [ 15, 14, 14 ], + "faces": { + "down": { "texture": "render" }, + "up": { "texture": "render" }, + "north": { "texture": "render" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "TopPanelExtr", + "from": [ 1, 13, 10 ], + "to": [ 15, 14, 11 ], + "faces": { + "down": { "texture": "render" }, + "up": { "texture": "render" }, + "north": { "texture": "render" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "ConnectorRight", + "from": [ 9.5, 9, 3 ], + "to": [ 12.5, 10, 6 ], + "faces": { + "up": { "texture": "render" }, + "north": { "texture": "render" }, + "south": { "texture": "render" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "ConnectorLeft", + "from": [ 3.5, 9, 3 ], + "to": [ 6.5, 10, 6 ], + "faces": { + "up": { "texture": "render" }, + "north": { "texture": "render" }, + "south": { "texture": "render" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "ConnectorWireRight", + "from": [ 10.5, 10, 4 ], + "to": [ 11.5, 13, 5 ], + "faces": { + "up": { "texture": "render" }, + "north": { "texture": "render" }, + "south": { "texture": "render" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "ConnectorWireLeft", + "from": [ 4.5, 10, 4 ], + "to": [ 5.5, 13, 5 ], + "faces": { + "up": { "texture": "render" }, + "north": { "texture": "render" }, + "south": { "texture": "render" }, + "west": { "texture": "render" }, + "east": { "texture": "render" } + } + }, + { "__comment": "ConnectorWireTop", + "from": [ 5.5, 12, 4 ], + "to": [ 10.5, 13, 5 ], + "faces": { + "down": { "texture": "render" }, + "up": { "texture": "render" }, + "north": { "texture": "render" }, + "south": { "texture": "render" } + } + } + ] +} + diff --git a/src/main/resources/assets/mekanism/models/item/metallurgic_infuser.json b/src/main/resources/assets/mekanism/models/item/metallurgic_infuser.json new file mode 100644 index 000000000..8385b0dc7 --- /dev/null +++ b/src/main/resources/assets/mekanism/models/item/metallurgic_infuser.json @@ -0,0 +1,11 @@ +{ + "parent": "mekanism:block/metallurgic_infuser", + "display": { + "thirdperson": { + "rotation": [ 10, -45, 170 ], + "translation": [ 0, 1.5, -2.75 ], + "scale": [ 0.375, 0.375, 0.375 ] + } + } +} +