From 9f5332012398e7d72124b2af42561f8fe137e9e7 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Sat, 11 Jan 2014 18:19:26 +0800 Subject: [PATCH] Using new block registration --- .../electrical/ClientProxy.java | 4 +- .../electrical/Electrical.java | 42 ++++++------------- .../electrical/battery/BlockBattery.java | 5 ++- .../electrical/levitator/BlockLevitator.java | 8 ++-- .../levitator/ItemBlockContractor.java | 2 +- .../levitator/PathfinderEMContractor.java | 4 +- .../electrical/levitator/RenderLevitator.java | 6 +-- ...ileEMLevitator.java => TileLevitator.java} | 18 ++++---- .../electrical/multimeter/ItemMultimeter.java | 5 ++- .../electrical/purifier/BlockPurifier.java | 5 ++- .../electrical/tesla/BlockTesla.java | 5 ++- .../transformer/ItemTransformer.java | 5 ++- .../electrical/wire/ItemWire.java | 5 +++ .../mechanical/grinder/BlockGrinderWheel.java | 5 ++- 14 files changed, 56 insertions(+), 63 deletions(-) rename src/main/java/resonantinduction/electrical/levitator/{TileEMLevitator.java => TileLevitator.java} (96%) diff --git a/src/main/java/resonantinduction/electrical/ClientProxy.java b/src/main/java/resonantinduction/electrical/ClientProxy.java index c19983817..196fbb447 100644 --- a/src/main/java/resonantinduction/electrical/ClientProxy.java +++ b/src/main/java/resonantinduction/electrical/ClientProxy.java @@ -9,7 +9,7 @@ import resonantinduction.electrical.battery.TileBattery; import resonantinduction.electrical.generator.solar.RenderSolarPanel; import resonantinduction.electrical.generator.solar.TileSolarPanel; import resonantinduction.electrical.levitator.RenderLevitator; -import resonantinduction.electrical.levitator.TileEMLevitator; +import resonantinduction.electrical.levitator.TileLevitator; import resonantinduction.electrical.multimeter.GuiMultimeter; import resonantinduction.electrical.multimeter.PartMultimeter; import resonantinduction.electrical.render.ElectricalBlockRenderingHandler; @@ -40,7 +40,7 @@ public class ClientProxy extends CommonProxy MinecraftForgeClient.registerItemRenderer(Electrical.itemMultimeter.itemID, RenderRIItem.INSTANCE); MinecraftForgeClient.registerItemRenderer(Electrical.itemTransformer.itemID, RenderRIItem.INSTANCE); ClientRegistry.bindTileEntitySpecialRenderer(TileTesla.class, new RenderTesla()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEMLevitator.class, new RenderLevitator()); + ClientRegistry.bindTileEntitySpecialRenderer(TileLevitator.class, new RenderLevitator()); ClientRegistry.bindTileEntitySpecialRenderer(TileBattery.class, new RenderBattery()); ClientRegistry.bindTileEntitySpecialRenderer(TileSolarPanel.class, new RenderSolarPanel()); } diff --git a/src/main/java/resonantinduction/electrical/Electrical.java b/src/main/java/resonantinduction/electrical/Electrical.java index e41deb5d7..6d50cd8df 100644 --- a/src/main/java/resonantinduction/electrical/Electrical.java +++ b/src/main/java/resonantinduction/electrical/Electrical.java @@ -27,7 +27,7 @@ import resonantinduction.electrical.generator.solar.BlockSolarPanel; import resonantinduction.electrical.generator.solar.TileSolarPanel; import resonantinduction.electrical.levitator.BlockLevitator; import resonantinduction.electrical.levitator.ItemBlockContractor; -import resonantinduction.electrical.levitator.TileEMLevitator; +import resonantinduction.electrical.levitator.TileLevitator; import resonantinduction.electrical.multimeter.ItemMultimeter; import resonantinduction.electrical.purifier.BlockPurifier; import resonantinduction.electrical.tesla.BlockTesla; @@ -106,23 +106,24 @@ public class Electrical Settings.CONFIGURATION.load(); // Energy - itemPartWire = new ItemWire(Settings.getNextItemID()); - itemMultimeter = new ItemMultimeter(Settings.getNextItemID()); - itemTransformer = new ItemTransformer(Settings.getNextItemID()); - blockTesla = new BlockTesla(Settings.getNextBlockID()); - blockBattery = new BlockBattery(Settings.getNextBlockID()); + itemPartWire = contentRegistry.createItem(ItemWire.class); + itemMultimeter = contentRegistry.createItem(ItemMultimeter.class); + itemTransformer = contentRegistry.createItem(ItemTransformer.class); + blockTesla = contentRegistry.createTile(BlockTesla.class, TileTesla.class); + blockBattery = contentRegistry.createTile(BlockBattery.class, TileBattery.class); + blockEMContractor = contentRegistry.createTile(BlockLevitator.class, TileLevitator.class); // Transport - blockEMContractor = new BlockLevitator(); + blockEMContractor = contentRegistry.createTile(BlockLevitator.class, TileLevitator.class); blockArmbot = contentRegistry.createTile(BlockArmbot.class, TileArmbot.class); // Machines - blockMachinePart = new BlockMachinePart(); - blockGrinderWheel = new BlockGrinderWheel(Settings.getNextBlockID()); - blockPurifier = new BlockPurifier(Settings.getNextBlockID()); + blockMachinePart = contentRegistry.createBlock(BlockMachinePart.class); + blockGrinderWheel = contentRegistry.createTile(BlockGrinderWheel.class, TileGrinderWheel.class); + blockPurifier = contentRegistry.createTile(BlockPurifier.class, TilePurifier.class); // Generator - blockSolarPanel = new BlockSolarPanel(); + blockSolarPanel = contentRegistry.createTile(BlockSolarPanel.class, TileSolarPanel.class); if (Settings.REPLACE_FURNACE) { @@ -133,25 +134,6 @@ public class Electrical Settings.CONFIGURATION.save(); - GameRegistry.registerItem(itemMultimeter, itemMultimeter.getUnlocalizedName()); - GameRegistry.registerItem(itemTransformer, itemTransformer.getUnlocalizedName()); - - GameRegistry.registerBlock(blockSolarPanel, blockSolarPanel.getUnlocalizedName()); - GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName()); - GameRegistry.registerBlock(blockBattery, ItemBlockBattery.class, blockBattery.getUnlocalizedName()); - GameRegistry.registerBlock(blockGrinderWheel, blockGrinderWheel.getUnlocalizedName()); - GameRegistry.registerBlock(blockPurifier, blockPurifier.getUnlocalizedName()); - GameRegistry.registerBlock(blockMachinePart, blockMachinePart.getUnlocalizedName()); - GameRegistry.registerBlock(blockEMContractor, ItemBlockContractor.class, blockEMContractor.getUnlocalizedName()); - - // Tiles - GameRegistry.registerTileEntity(TileTesla.class, blockTesla.getUnlocalizedName()); - GameRegistry.registerTileEntity(TileBattery.class, blockBattery.getUnlocalizedName()); - GameRegistry.registerTileEntity(TileSolarPanel.class, blockSolarPanel.getUnlocalizedName()); - GameRegistry.registerTileEntity(TilePurifier.class, blockPurifier.getUnlocalizedName()); - GameRegistry.registerTileEntity(TileGrinderWheel.class, blockGrinderWheel.getUnlocalizedName()); - GameRegistry.registerTileEntity(TileEMLevitator.class, blockEMContractor.getUnlocalizedName()); - /** * Set reference itemstacks */ diff --git a/src/main/java/resonantinduction/electrical/battery/BlockBattery.java b/src/main/java/resonantinduction/electrical/battery/BlockBattery.java index 63ea7010b..85dcbb492 100644 --- a/src/main/java/resonantinduction/electrical/battery/BlockBattery.java +++ b/src/main/java/resonantinduction/electrical/battery/BlockBattery.java @@ -11,6 +11,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import resonantinduction.core.Reference; +import resonantinduction.core.Settings; import resonantinduction.core.prefab.block.BlockIOBase; import resonantinduction.electrical.render.ElectricalBlockRenderingHandler; import universalelectricity.api.CompatibilityModule; @@ -25,9 +26,9 @@ import cpw.mods.fml.relauncher.SideOnly; */ public class BlockBattery extends BlockIOBase implements ITileEntityProvider { - public BlockBattery(int id) + public BlockBattery() { - super("battery", id); + super("battery", Settings.getNextBlockID()); this.setTextureName(Reference.PREFIX + "machine"); } diff --git a/src/main/java/resonantinduction/electrical/levitator/BlockLevitator.java b/src/main/java/resonantinduction/electrical/levitator/BlockLevitator.java index edb380e0f..39e46cd58 100644 --- a/src/main/java/resonantinduction/electrical/levitator/BlockLevitator.java +++ b/src/main/java/resonantinduction/electrical/levitator/BlockLevitator.java @@ -30,7 +30,7 @@ public class BlockLevitator extends BlockRI @Override public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) { - TileEMLevitator levitator = (TileEMLevitator) world.getBlockTileEntity(x, y, z); + TileLevitator levitator = (TileLevitator) world.getBlockTileEntity(x, y, z); if (entityPlayer.getCurrentEquippedItem() != null) { @@ -58,7 +58,7 @@ public class BlockLevitator extends BlockRI { if (!entityPlayer.isSneaking()) { - TileEMLevitator levitator = (TileEMLevitator) world.getBlockTileEntity(x, y, z); + TileLevitator levitator = (TileLevitator) world.getBlockTileEntity(x, y, z); levitator.incrementFacing(); return true; } @@ -69,7 +69,7 @@ public class BlockLevitator extends BlockRI @Override public void onNeighborBlockChange(World world, int x, int y, int z, int blockID) { - TileEMLevitator tileContractor = (TileEMLevitator) world.getBlockTileEntity(x, y, z); + TileLevitator tileContractor = (TileLevitator) world.getBlockTileEntity(x, y, z); if (!world.isRemote && !tileContractor.isLatched()) { @@ -89,7 +89,7 @@ public class BlockLevitator extends BlockRI @Override public TileEntity createNewTileEntity(World world) { - return new TileEMLevitator(); + return new TileLevitator(); } @Override diff --git a/src/main/java/resonantinduction/electrical/levitator/ItemBlockContractor.java b/src/main/java/resonantinduction/electrical/levitator/ItemBlockContractor.java index cb976b2b7..f78e71013 100644 --- a/src/main/java/resonantinduction/electrical/levitator/ItemBlockContractor.java +++ b/src/main/java/resonantinduction/electrical/levitator/ItemBlockContractor.java @@ -22,7 +22,7 @@ public class ItemBlockContractor extends ItemBlock if (place) { - TileEMLevitator tileContractor = (TileEMLevitator) world.getBlockTileEntity(x, y, z); + TileLevitator tileContractor = (TileLevitator) world.getBlockTileEntity(x, y, z); tileContractor.setDirection(ForgeDirection.getOrientation(side)); if (!tileContractor.isLatched()) diff --git a/src/main/java/resonantinduction/electrical/levitator/PathfinderEMContractor.java b/src/main/java/resonantinduction/electrical/levitator/PathfinderEMContractor.java index 279d45d25..5ddcfd7a1 100644 --- a/src/main/java/resonantinduction/electrical/levitator/PathfinderEMContractor.java +++ b/src/main/java/resonantinduction/electrical/levitator/PathfinderEMContractor.java @@ -38,7 +38,7 @@ public class PathfinderEMContractor extends PathfinderAStar { Vector3 neighbor = currentNode.clone().modifyPositionFromSide(ForgeDirection.getOrientation(i)); - if (TileEMLevitator.canBePath(world, neighbor)) + if (TileLevitator.canBePath(world, neighbor)) { neighbors.add(neighbor); } @@ -67,7 +67,7 @@ public class PathfinderEMContractor extends PathfinderAStar ForgeDirection direction = ForgeDirection.getOrientation(i); Vector3 neighbor = this.goal.clone().translate(new Vector3(direction.offsetX, direction.offsetY, direction.offsetZ)); - if (!TileEMLevitator.canBePath(this.world, neighbor)) + if (!TileLevitator.canBePath(this.world, neighbor)) { blockCount++; } diff --git a/src/main/java/resonantinduction/electrical/levitator/RenderLevitator.java b/src/main/java/resonantinduction/electrical/levitator/RenderLevitator.java index 6db963c55..d80ada56f 100644 --- a/src/main/java/resonantinduction/electrical/levitator/RenderLevitator.java +++ b/src/main/java/resonantinduction/electrical/levitator/RenderLevitator.java @@ -24,7 +24,7 @@ public class RenderLevitator extends TileEntitySpecialRenderer GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - switch (((TileEMLevitator) t).getDirection()) + switch (((TileLevitator) t).getDirection()) { case DOWN: GL11.glRotatef(180, 0, 0, 1); @@ -50,7 +50,7 @@ public class RenderLevitator extends TileEntitySpecialRenderer break; } - if (((TileEMLevitator) t).suck) + if (((TileLevitator) t).suck) { this.bindTexture(TEXTURE); } @@ -59,7 +59,7 @@ public class RenderLevitator extends TileEntitySpecialRenderer this.bindTexture(TEXTURE_PUSH); } - if (((TileEMLevitator) t).canFunction() && !ResonantInduction.proxy.isPaused()) + if (((TileLevitator) t).canFunction() && !ResonantInduction.proxy.isPaused()) { MODEL_SPIN.render(0.0625f); } diff --git a/src/main/java/resonantinduction/electrical/levitator/TileEMLevitator.java b/src/main/java/resonantinduction/electrical/levitator/TileLevitator.java similarity index 96% rename from src/main/java/resonantinduction/electrical/levitator/TileEMLevitator.java rename to src/main/java/resonantinduction/electrical/levitator/TileLevitator.java index 9b704a865..839f97524 100644 --- a/src/main/java/resonantinduction/electrical/levitator/TileEMLevitator.java +++ b/src/main/java/resonantinduction/electrical/levitator/TileLevitator.java @@ -41,7 +41,7 @@ import com.google.common.io.ByteArrayDataInput; * @author Calclavia * */ -public class TileEMLevitator extends TileAdvanced implements IPacketReceiver, IPacketSender, ILinkable +public class TileLevitator extends TileAdvanced implements IPacketReceiver, IPacketSender, ILinkable { private int pushDelay; @@ -59,7 +59,7 @@ public class TileEMLevitator extends TileAdvanced implements IPacketReceiver, IP private ThreadEMPathfinding thread; private PathfinderEMContractor pathfinder; private Set pathfindingTrackers = new HashSet(); - private TileEMLevitator linked; + private TileLevitator linked; private int lastCalcTime = 0; /** Color of beam */ @@ -82,9 +82,9 @@ public class TileEMLevitator extends TileAdvanced implements IPacketReceiver, IP if (tempLinkVector != null) { - if (tempLinkVector.getTileEntity(worldObj) instanceof TileEMLevitator) + if (tempLinkVector.getTileEntity(worldObj) instanceof TileLevitator) { - setLink((TileEMLevitator) tempLinkVector.getTileEntity(worldObj), true); + setLink((TileLevitator) tempLinkVector.getTileEntity(worldObj), true); } tempLinkVector = null; @@ -165,7 +165,7 @@ public class TileEMLevitator extends TileAdvanced implements IPacketReceiver, IP { Vector3 result = results.get(i).clone(); - if (TileEMLevitator.canBePath(worldObj, result)) + if (TileLevitator.canBePath(worldObj, result)) { if (i - 1 >= 0) { @@ -553,7 +553,7 @@ public class TileEMLevitator extends TileAdvanced implements IPacketReceiver, IP /** * Link between two TileEntities, do pathfinding operation. */ - public void setLink(TileEMLevitator tileEntity, boolean setOpponent) + public void setLink(TileLevitator tileEntity, boolean setOpponent) { if (linked != null && setOpponent) { @@ -581,7 +581,7 @@ public class TileEMLevitator extends TileAdvanced implements IPacketReceiver, IP if (start.distance(target) < Settings.MAX_CONTRACTOR_DISTANCE) { - if (TileEMLevitator.canBePath(worldObj, start) && TileEMLevitator.canBePath(worldObj, target)) + if (TileLevitator.canBePath(worldObj, start) && TileLevitator.canBePath(worldObj, target)) { thread = new ThreadEMPathfinding(new PathfinderEMContractor(worldObj, target), start); thread.start(); @@ -602,9 +602,9 @@ public class TileEMLevitator extends TileAdvanced implements IPacketReceiver, IP { if (vector != null) { - if (vector.getTileEntity(this.worldObj) instanceof TileEMLevitator) + if (vector.getTileEntity(this.worldObj) instanceof TileLevitator) { - this.setLink((TileEMLevitator) vector.getTileEntity(this.worldObj), true); + this.setLink((TileLevitator) vector.getTileEntity(this.worldObj), true); if (this.worldObj.isRemote) { diff --git a/src/main/java/resonantinduction/electrical/multimeter/ItemMultimeter.java b/src/main/java/resonantinduction/electrical/multimeter/ItemMultimeter.java index 4423bb510..327171de1 100644 --- a/src/main/java/resonantinduction/electrical/multimeter/ItemMultimeter.java +++ b/src/main/java/resonantinduction/electrical/multimeter/ItemMultimeter.java @@ -8,6 +8,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Icon; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; +import resonantinduction.core.Settings; import resonantinduction.core.prefab.part.ItemMultipartBase; import resonantinduction.electrical.wire.EnumWireMaterial; import calclavia.lib.utility.LanguageUtility; @@ -21,9 +22,9 @@ public class ItemMultimeter extends ItemMultipartBase { private Icon[] icons = new Icon[EnumWireMaterial.values().length]; - public ItemMultimeter(int id) + public ItemMultimeter() { - super("multimeter", id); + super("multimeter", Settings.getNextItemID()); } @Override diff --git a/src/main/java/resonantinduction/electrical/purifier/BlockPurifier.java b/src/main/java/resonantinduction/electrical/purifier/BlockPurifier.java index 149f07ddf..98b927d72 100644 --- a/src/main/java/resonantinduction/electrical/purifier/BlockPurifier.java +++ b/src/main/java/resonantinduction/electrical/purifier/BlockPurifier.java @@ -4,6 +4,7 @@ import net.minecraft.block.ITileEntityProvider; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; +import resonantinduction.core.Settings; import resonantinduction.core.prefab.block.BlockRotatableBase; import resonantinduction.mechanical.grinder.TilePurifier; import universalelectricity.api.vector.VectorWorld; @@ -16,9 +17,9 @@ import universalelectricity.api.vector.VectorWorld; */ public class BlockPurifier extends BlockRotatableBase implements ITileEntityProvider { - public BlockPurifier(int id) + public BlockPurifier() { - super("purifier", id); + super("purifier", Settings.getNextBlockID()); } @Override diff --git a/src/main/java/resonantinduction/electrical/tesla/BlockTesla.java b/src/main/java/resonantinduction/electrical/tesla/BlockTesla.java index 6813a1f89..9c88dd65c 100644 --- a/src/main/java/resonantinduction/electrical/tesla/BlockTesla.java +++ b/src/main/java/resonantinduction/electrical/tesla/BlockTesla.java @@ -9,6 +9,7 @@ import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import resonantinduction.core.Reference; +import resonantinduction.core.Settings; import resonantinduction.core.Utility; import resonantinduction.core.prefab.block.BlockIOBase; import resonantinduction.electrical.render.ElectricalBlockRenderingHandler; @@ -22,9 +23,9 @@ import cpw.mods.fml.relauncher.SideOnly; */ public class BlockTesla extends BlockIOBase implements ITileEntityProvider { - public BlockTesla(int id) + public BlockTesla() { - super("tesla", id); + super("tesla", Settings.getNextBlockID()); this.setTextureName(Reference.PREFIX + "machine"); } diff --git a/src/main/java/resonantinduction/electrical/transformer/ItemTransformer.java b/src/main/java/resonantinduction/electrical/transformer/ItemTransformer.java index a1cffce0e..85db2a20d 100644 --- a/src/main/java/resonantinduction/electrical/transformer/ItemTransformer.java +++ b/src/main/java/resonantinduction/electrical/transformer/ItemTransformer.java @@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.world.World; +import resonantinduction.core.Settings; import resonantinduction.core.prefab.part.ItemMultipartBase; import resonantinduction.electrical.wire.EnumWireMaterial; import codechicken.lib.vec.BlockCoord; @@ -15,9 +16,9 @@ public class ItemTransformer extends ItemMultipartBase { private Icon[] icons = new Icon[EnumWireMaterial.values().length]; - public ItemTransformer(int id) + public ItemTransformer() { - super("transformer", id); + super("transformer", Settings.getNextItemID()); } @Override diff --git a/src/main/java/resonantinduction/electrical/wire/ItemWire.java b/src/main/java/resonantinduction/electrical/wire/ItemWire.java index 7a1fdf902..b7ca93a26 100644 --- a/src/main/java/resonantinduction/electrical/wire/ItemWire.java +++ b/src/main/java/resonantinduction/electrical/wire/ItemWire.java @@ -39,6 +39,11 @@ public class ItemWire extends JItemMultiPart { private Icon[] icons = new Icon[EnumWireMaterial.values().length]; + public ItemWire() + { + this(Settings.getNextItemID()); + } + public ItemWire(int id) { super(Settings.CONFIGURATION.get(Configuration.CATEGORY_ITEM, "wire", id).getInt(id)); diff --git a/src/main/java/resonantinduction/mechanical/grinder/BlockGrinderWheel.java b/src/main/java/resonantinduction/mechanical/grinder/BlockGrinderWheel.java index 1fcccaccb..6b6cb16a4 100644 --- a/src/main/java/resonantinduction/mechanical/grinder/BlockGrinderWheel.java +++ b/src/main/java/resonantinduction/mechanical/grinder/BlockGrinderWheel.java @@ -7,6 +7,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; +import resonantinduction.core.Settings; import resonantinduction.core.prefab.block.BlockRotatableBase; import universalelectricity.api.vector.VectorWorld; @@ -18,9 +19,9 @@ import universalelectricity.api.vector.VectorWorld; */ public class BlockGrinderWheel extends BlockRotatableBase implements ITileEntityProvider { - public BlockGrinderWheel(int id) + public BlockGrinderWheel() { - super("grindingWheel", id); + super("grindingWheel", Settings.getNextBlockID()); this.setBlockBounds(0.05f, 0.05f, 0.05f, 0.95f, 0.95f, 0.95f); }