Using new block registration

This commit is contained in:
Calclavia 2014-01-11 18:19:26 +08:00
parent 51ae09aa3b
commit 9f53320123
14 changed files with 56 additions and 63 deletions

View file

@ -9,7 +9,7 @@ import resonantinduction.electrical.battery.TileBattery;
import resonantinduction.electrical.generator.solar.RenderSolarPanel; import resonantinduction.electrical.generator.solar.RenderSolarPanel;
import resonantinduction.electrical.generator.solar.TileSolarPanel; import resonantinduction.electrical.generator.solar.TileSolarPanel;
import resonantinduction.electrical.levitator.RenderLevitator; import resonantinduction.electrical.levitator.RenderLevitator;
import resonantinduction.electrical.levitator.TileEMLevitator; import resonantinduction.electrical.levitator.TileLevitator;
import resonantinduction.electrical.multimeter.GuiMultimeter; import resonantinduction.electrical.multimeter.GuiMultimeter;
import resonantinduction.electrical.multimeter.PartMultimeter; import resonantinduction.electrical.multimeter.PartMultimeter;
import resonantinduction.electrical.render.ElectricalBlockRenderingHandler; import resonantinduction.electrical.render.ElectricalBlockRenderingHandler;
@ -40,7 +40,7 @@ public class ClientProxy extends CommonProxy
MinecraftForgeClient.registerItemRenderer(Electrical.itemMultimeter.itemID, RenderRIItem.INSTANCE); MinecraftForgeClient.registerItemRenderer(Electrical.itemMultimeter.itemID, RenderRIItem.INSTANCE);
MinecraftForgeClient.registerItemRenderer(Electrical.itemTransformer.itemID, RenderRIItem.INSTANCE); MinecraftForgeClient.registerItemRenderer(Electrical.itemTransformer.itemID, RenderRIItem.INSTANCE);
ClientRegistry.bindTileEntitySpecialRenderer(TileTesla.class, new RenderTesla()); 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(TileBattery.class, new RenderBattery());
ClientRegistry.bindTileEntitySpecialRenderer(TileSolarPanel.class, new RenderSolarPanel()); ClientRegistry.bindTileEntitySpecialRenderer(TileSolarPanel.class, new RenderSolarPanel());
} }

View file

@ -27,7 +27,7 @@ import resonantinduction.electrical.generator.solar.BlockSolarPanel;
import resonantinduction.electrical.generator.solar.TileSolarPanel; import resonantinduction.electrical.generator.solar.TileSolarPanel;
import resonantinduction.electrical.levitator.BlockLevitator; import resonantinduction.electrical.levitator.BlockLevitator;
import resonantinduction.electrical.levitator.ItemBlockContractor; import resonantinduction.electrical.levitator.ItemBlockContractor;
import resonantinduction.electrical.levitator.TileEMLevitator; import resonantinduction.electrical.levitator.TileLevitator;
import resonantinduction.electrical.multimeter.ItemMultimeter; import resonantinduction.electrical.multimeter.ItemMultimeter;
import resonantinduction.electrical.purifier.BlockPurifier; import resonantinduction.electrical.purifier.BlockPurifier;
import resonantinduction.electrical.tesla.BlockTesla; import resonantinduction.electrical.tesla.BlockTesla;
@ -106,23 +106,24 @@ public class Electrical
Settings.CONFIGURATION.load(); Settings.CONFIGURATION.load();
// Energy // Energy
itemPartWire = new ItemWire(Settings.getNextItemID()); itemPartWire = contentRegistry.createItem(ItemWire.class);
itemMultimeter = new ItemMultimeter(Settings.getNextItemID()); itemMultimeter = contentRegistry.createItem(ItemMultimeter.class);
itemTransformer = new ItemTransformer(Settings.getNextItemID()); itemTransformer = contentRegistry.createItem(ItemTransformer.class);
blockTesla = new BlockTesla(Settings.getNextBlockID()); blockTesla = contentRegistry.createTile(BlockTesla.class, TileTesla.class);
blockBattery = new BlockBattery(Settings.getNextBlockID()); blockBattery = contentRegistry.createTile(BlockBattery.class, TileBattery.class);
blockEMContractor = contentRegistry.createTile(BlockLevitator.class, TileLevitator.class);
// Transport // Transport
blockEMContractor = new BlockLevitator(); blockEMContractor = contentRegistry.createTile(BlockLevitator.class, TileLevitator.class);
blockArmbot = contentRegistry.createTile(BlockArmbot.class, TileArmbot.class); blockArmbot = contentRegistry.createTile(BlockArmbot.class, TileArmbot.class);
// Machines // Machines
blockMachinePart = new BlockMachinePart(); blockMachinePart = contentRegistry.createBlock(BlockMachinePart.class);
blockGrinderWheel = new BlockGrinderWheel(Settings.getNextBlockID()); blockGrinderWheel = contentRegistry.createTile(BlockGrinderWheel.class, TileGrinderWheel.class);
blockPurifier = new BlockPurifier(Settings.getNextBlockID()); blockPurifier = contentRegistry.createTile(BlockPurifier.class, TilePurifier.class);
// Generator // Generator
blockSolarPanel = new BlockSolarPanel(); blockSolarPanel = contentRegistry.createTile(BlockSolarPanel.class, TileSolarPanel.class);
if (Settings.REPLACE_FURNACE) if (Settings.REPLACE_FURNACE)
{ {
@ -133,25 +134,6 @@ public class Electrical
Settings.CONFIGURATION.save(); 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 * Set reference itemstacks
*/ */

View file

@ -11,6 +11,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World; import net.minecraft.world.World;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.Settings;
import resonantinduction.core.prefab.block.BlockIOBase; import resonantinduction.core.prefab.block.BlockIOBase;
import resonantinduction.electrical.render.ElectricalBlockRenderingHandler; import resonantinduction.electrical.render.ElectricalBlockRenderingHandler;
import universalelectricity.api.CompatibilityModule; import universalelectricity.api.CompatibilityModule;
@ -25,9 +26,9 @@ import cpw.mods.fml.relauncher.SideOnly;
*/ */
public class BlockBattery extends BlockIOBase implements ITileEntityProvider 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"); this.setTextureName(Reference.PREFIX + "machine");
} }

View file

@ -30,7 +30,7 @@ public class BlockLevitator extends BlockRI
@Override @Override
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) 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) if (entityPlayer.getCurrentEquippedItem() != null)
{ {
@ -58,7 +58,7 @@ public class BlockLevitator extends BlockRI
{ {
if (!entityPlayer.isSneaking()) if (!entityPlayer.isSneaking())
{ {
TileEMLevitator levitator = (TileEMLevitator) world.getBlockTileEntity(x, y, z); TileLevitator levitator = (TileLevitator) world.getBlockTileEntity(x, y, z);
levitator.incrementFacing(); levitator.incrementFacing();
return true; return true;
} }
@ -69,7 +69,7 @@ public class BlockLevitator extends BlockRI
@Override @Override
public void onNeighborBlockChange(World world, int x, int y, int z, int blockID) 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()) if (!world.isRemote && !tileContractor.isLatched())
{ {
@ -89,7 +89,7 @@ public class BlockLevitator extends BlockRI
@Override @Override
public TileEntity createNewTileEntity(World world) public TileEntity createNewTileEntity(World world)
{ {
return new TileEMLevitator(); return new TileLevitator();
} }
@Override @Override

View file

@ -22,7 +22,7 @@ public class ItemBlockContractor extends ItemBlock
if (place) if (place)
{ {
TileEMLevitator tileContractor = (TileEMLevitator) world.getBlockTileEntity(x, y, z); TileLevitator tileContractor = (TileLevitator) world.getBlockTileEntity(x, y, z);
tileContractor.setDirection(ForgeDirection.getOrientation(side)); tileContractor.setDirection(ForgeDirection.getOrientation(side));
if (!tileContractor.isLatched()) if (!tileContractor.isLatched())

View file

@ -38,7 +38,7 @@ public class PathfinderEMContractor extends PathfinderAStar
{ {
Vector3 neighbor = currentNode.clone().modifyPositionFromSide(ForgeDirection.getOrientation(i)); Vector3 neighbor = currentNode.clone().modifyPositionFromSide(ForgeDirection.getOrientation(i));
if (TileEMLevitator.canBePath(world, neighbor)) if (TileLevitator.canBePath(world, neighbor))
{ {
neighbors.add(neighbor); neighbors.add(neighbor);
} }
@ -67,7 +67,7 @@ public class PathfinderEMContractor extends PathfinderAStar
ForgeDirection direction = ForgeDirection.getOrientation(i); ForgeDirection direction = ForgeDirection.getOrientation(i);
Vector3 neighbor = this.goal.clone().translate(new Vector3(direction.offsetX, direction.offsetY, direction.offsetZ)); 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++; blockCount++;
} }

View file

@ -24,7 +24,7 @@ public class RenderLevitator extends TileEntitySpecialRenderer
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
switch (((TileEMLevitator) t).getDirection()) switch (((TileLevitator) t).getDirection())
{ {
case DOWN: case DOWN:
GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(180, 0, 0, 1);
@ -50,7 +50,7 @@ public class RenderLevitator extends TileEntitySpecialRenderer
break; break;
} }
if (((TileEMLevitator) t).suck) if (((TileLevitator) t).suck)
{ {
this.bindTexture(TEXTURE); this.bindTexture(TEXTURE);
} }
@ -59,7 +59,7 @@ public class RenderLevitator extends TileEntitySpecialRenderer
this.bindTexture(TEXTURE_PUSH); this.bindTexture(TEXTURE_PUSH);
} }
if (((TileEMLevitator) t).canFunction() && !ResonantInduction.proxy.isPaused()) if (((TileLevitator) t).canFunction() && !ResonantInduction.proxy.isPaused())
{ {
MODEL_SPIN.render(0.0625f); MODEL_SPIN.render(0.0625f);
} }

View file

@ -41,7 +41,7 @@ import com.google.common.io.ByteArrayDataInput;
* @author Calclavia * @author Calclavia
* *
*/ */
public class TileEMLevitator extends TileAdvanced implements IPacketReceiver, IPacketSender, ILinkable public class TileLevitator extends TileAdvanced implements IPacketReceiver, IPacketSender, ILinkable
{ {
private int pushDelay; private int pushDelay;
@ -59,7 +59,7 @@ public class TileEMLevitator extends TileAdvanced implements IPacketReceiver, IP
private ThreadEMPathfinding thread; private ThreadEMPathfinding thread;
private PathfinderEMContractor pathfinder; private PathfinderEMContractor pathfinder;
private Set<EntityItem> pathfindingTrackers = new HashSet<EntityItem>(); private Set<EntityItem> pathfindingTrackers = new HashSet<EntityItem>();
private TileEMLevitator linked; private TileLevitator linked;
private int lastCalcTime = 0; private int lastCalcTime = 0;
/** Color of beam */ /** Color of beam */
@ -82,9 +82,9 @@ public class TileEMLevitator extends TileAdvanced implements IPacketReceiver, IP
if (tempLinkVector != null) 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; tempLinkVector = null;
@ -165,7 +165,7 @@ public class TileEMLevitator extends TileAdvanced implements IPacketReceiver, IP
{ {
Vector3 result = results.get(i).clone(); Vector3 result = results.get(i).clone();
if (TileEMLevitator.canBePath(worldObj, result)) if (TileLevitator.canBePath(worldObj, result))
{ {
if (i - 1 >= 0) if (i - 1 >= 0)
{ {
@ -553,7 +553,7 @@ public class TileEMLevitator extends TileAdvanced implements IPacketReceiver, IP
/** /**
* Link between two TileEntities, do pathfinding operation. * 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) 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 (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 = new ThreadEMPathfinding(new PathfinderEMContractor(worldObj, target), start);
thread.start(); thread.start();
@ -602,9 +602,9 @@ public class TileEMLevitator extends TileAdvanced implements IPacketReceiver, IP
{ {
if (vector != null) 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) if (this.worldObj.isRemote)
{ {

View file

@ -8,6 +8,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.Settings;
import resonantinduction.core.prefab.part.ItemMultipartBase; import resonantinduction.core.prefab.part.ItemMultipartBase;
import resonantinduction.electrical.wire.EnumWireMaterial; import resonantinduction.electrical.wire.EnumWireMaterial;
import calclavia.lib.utility.LanguageUtility; import calclavia.lib.utility.LanguageUtility;
@ -21,9 +22,9 @@ public class ItemMultimeter extends ItemMultipartBase
{ {
private Icon[] icons = new Icon[EnumWireMaterial.values().length]; private Icon[] icons = new Icon[EnumWireMaterial.values().length];
public ItemMultimeter(int id) public ItemMultimeter()
{ {
super("multimeter", id); super("multimeter", Settings.getNextItemID());
} }
@Override @Override

View file

@ -4,6 +4,7 @@ import net.minecraft.block.ITileEntityProvider;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.Settings;
import resonantinduction.core.prefab.block.BlockRotatableBase; import resonantinduction.core.prefab.block.BlockRotatableBase;
import resonantinduction.mechanical.grinder.TilePurifier; import resonantinduction.mechanical.grinder.TilePurifier;
import universalelectricity.api.vector.VectorWorld; import universalelectricity.api.vector.VectorWorld;
@ -16,9 +17,9 @@ import universalelectricity.api.vector.VectorWorld;
*/ */
public class BlockPurifier extends BlockRotatableBase implements ITileEntityProvider public class BlockPurifier extends BlockRotatableBase implements ITileEntityProvider
{ {
public BlockPurifier(int id) public BlockPurifier()
{ {
super("purifier", id); super("purifier", Settings.getNextBlockID());
} }
@Override @Override

View file

@ -9,6 +9,7 @@ import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.Settings;
import resonantinduction.core.Utility; import resonantinduction.core.Utility;
import resonantinduction.core.prefab.block.BlockIOBase; import resonantinduction.core.prefab.block.BlockIOBase;
import resonantinduction.electrical.render.ElectricalBlockRenderingHandler; import resonantinduction.electrical.render.ElectricalBlockRenderingHandler;
@ -22,9 +23,9 @@ import cpw.mods.fml.relauncher.SideOnly;
*/ */
public class BlockTesla extends BlockIOBase implements ITileEntityProvider 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"); this.setTextureName(Reference.PREFIX + "machine");
} }

View file

@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import net.minecraft.world.World; import net.minecraft.world.World;
import resonantinduction.core.Settings;
import resonantinduction.core.prefab.part.ItemMultipartBase; import resonantinduction.core.prefab.part.ItemMultipartBase;
import resonantinduction.electrical.wire.EnumWireMaterial; import resonantinduction.electrical.wire.EnumWireMaterial;
import codechicken.lib.vec.BlockCoord; import codechicken.lib.vec.BlockCoord;
@ -15,9 +16,9 @@ public class ItemTransformer extends ItemMultipartBase
{ {
private Icon[] icons = new Icon[EnumWireMaterial.values().length]; private Icon[] icons = new Icon[EnumWireMaterial.values().length];
public ItemTransformer(int id) public ItemTransformer()
{ {
super("transformer", id); super("transformer", Settings.getNextItemID());
} }
@Override @Override

View file

@ -39,6 +39,11 @@ public class ItemWire extends JItemMultiPart
{ {
private Icon[] icons = new Icon[EnumWireMaterial.values().length]; private Icon[] icons = new Icon[EnumWireMaterial.values().length];
public ItemWire()
{
this(Settings.getNextItemID());
}
public ItemWire(int id) public ItemWire(int id)
{ {
super(Settings.CONFIGURATION.get(Configuration.CATEGORY_ITEM, "wire", id).getInt(id)); super(Settings.CONFIGURATION.get(Configuration.CATEGORY_ITEM, "wire", id).getInt(id));

View file

@ -7,6 +7,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.Settings;
import resonantinduction.core.prefab.block.BlockRotatableBase; import resonantinduction.core.prefab.block.BlockRotatableBase;
import universalelectricity.api.vector.VectorWorld; import universalelectricity.api.vector.VectorWorld;
@ -18,9 +19,9 @@ import universalelectricity.api.vector.VectorWorld;
*/ */
public class BlockGrinderWheel extends BlockRotatableBase implements ITileEntityProvider 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); this.setBlockBounds(0.05f, 0.05f, 0.05f, 0.95f, 0.95f, 0.95f);
} }