From 40c13a9e370fd19fcb6d1f97d2b49d61cfdcfbc5 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Tue, 11 Mar 2014 21:11:46 +0800 Subject: [PATCH] Changed Mechanical Piston to use TileBlock system --- .../mechanical/Mechanical.java | 3 +- .../energy/grid/TileMechanical.java | 16 ++++- .../crusher/BlockMechanicalPiston.java | 51 ---------------- .../process/crusher/TileMechanicalPiston.java | 58 +++++++++++-------- 4 files changed, 49 insertions(+), 79 deletions(-) delete mode 100644 mechanical/src/main/java/resonantinduction/mechanical/process/crusher/BlockMechanicalPiston.java diff --git a/mechanical/src/main/java/resonantinduction/mechanical/Mechanical.java b/mechanical/src/main/java/resonantinduction/mechanical/Mechanical.java index 4cb11f125..6cfcd8189 100644 --- a/mechanical/src/main/java/resonantinduction/mechanical/Mechanical.java +++ b/mechanical/src/main/java/resonantinduction/mechanical/Mechanical.java @@ -29,7 +29,6 @@ import resonantinduction.mechanical.logistic.belt.BlockManipulator; import resonantinduction.mechanical.logistic.belt.TileDetector; import resonantinduction.mechanical.logistic.belt.TileManipulator; import resonantinduction.mechanical.logistic.belt.TileSorter; -import resonantinduction.mechanical.process.crusher.BlockMechanicalPiston; import resonantinduction.mechanical.process.crusher.TileMechanicalPiston; import resonantinduction.mechanical.process.grinder.BlockGrindingWheel; import resonantinduction.mechanical.process.grinder.TileGrinderWheel; @@ -126,7 +125,7 @@ public class Mechanical // Machines blockGrinderWheel = contentRegistry.createTile(BlockGrindingWheel.class, TileGrinderWheel.class); blockPurifier = contentRegistry.createTile(BlockMixer.class, TileMixer.class); - blockMechanicalPiston = contentRegistry.createTile(BlockMechanicalPiston.class, TileMechanicalPiston.class); + blockMechanicalPiston = contentRegistry.newBlock(TileMechanicalPiston.class); OreDictionary.registerOre("gear", itemGear); proxy.preInit(); diff --git a/mechanical/src/main/java/resonantinduction/mechanical/energy/grid/TileMechanical.java b/mechanical/src/main/java/resonantinduction/mechanical/energy/grid/TileMechanical.java index 4792be718..084246ee4 100644 --- a/mechanical/src/main/java/resonantinduction/mechanical/energy/grid/TileMechanical.java +++ b/mechanical/src/main/java/resonantinduction/mechanical/energy/grid/TileMechanical.java @@ -1,5 +1,6 @@ package resonantinduction.mechanical.energy.grid; +import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.ForgeDirection; @@ -8,14 +9,25 @@ import resonantinduction.core.grid.INodeProvider; import resonantinduction.core.grid.Node; import resonantinduction.mechanical.Mechanical; import universalelectricity.api.vector.Vector3; +import calclavia.lib.content.module.TileBase; import calclavia.lib.network.IPacketReceiver; import calclavia.lib.network.PacketHandler; -import calclavia.lib.prefab.tile.TileAdvanced; import com.google.common.io.ByteArrayDataInput; -public abstract class TileMechanical extends TileAdvanced implements INodeProvider, IPacketReceiver +public abstract class TileMechanical extends TileBase implements INodeProvider, IPacketReceiver { + @Deprecated + public TileMechanical() + { + super(null); + } + + public TileMechanical(Material material) + { + super(material); + } + protected static final int PACKET_VELOCITY = Mechanical.contentRegistry.getNextPacketID(); public MechanicalNode mechanicalNode = new PacketMechanicalNode(this).setLoad(0.5f); diff --git a/mechanical/src/main/java/resonantinduction/mechanical/process/crusher/BlockMechanicalPiston.java b/mechanical/src/main/java/resonantinduction/mechanical/process/crusher/BlockMechanicalPiston.java deleted file mode 100644 index 5ba30d6b1..000000000 --- a/mechanical/src/main/java/resonantinduction/mechanical/process/crusher/BlockMechanicalPiston.java +++ /dev/null @@ -1,51 +0,0 @@ -package resonantinduction.mechanical.process.crusher; - -import net.minecraft.block.material.Material; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import resonantinduction.core.Reference; -import calclavia.lib.prefab.block.BlockRotatable; -import calclavia.lib.render.block.BlockRenderingHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -/** - * A block used to build machines. - * - * @author Calclavia - * - */ -public class BlockMechanicalPiston extends BlockRotatable -{ - public BlockMechanicalPiston(int id) - { - super(id, Material.wood); - setTextureName(Reference.PREFIX + "material_steel_dark"); - rotationMask = Byte.parseByte("111111", 2); - } - - @SideOnly(Side.CLIENT) - @Override - public int getRenderType() - { - return BlockRenderingHandler.ID; - } - - @Override - public boolean isOpaqueCube() - { - return false; - } - - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - @Override - public TileEntity createNewTileEntity(World world) - { - return new TileMechanicalPiston(); - } -} diff --git a/mechanical/src/main/java/resonantinduction/mechanical/process/crusher/TileMechanicalPiston.java b/mechanical/src/main/java/resonantinduction/mechanical/process/crusher/TileMechanicalPiston.java index f7c39948f..763b255e7 100644 --- a/mechanical/src/main/java/resonantinduction/mechanical/process/crusher/TileMechanicalPiston.java +++ b/mechanical/src/main/java/resonantinduction/mechanical/process/crusher/TileMechanicalPiston.java @@ -6,23 +6,27 @@ import codechicken.multipart.MultipartHelper; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; import resonantinduction.mechanical.energy.grid.TileMechanical; import universalelectricity.api.vector.Vector3; +import calclavia.lib.prefab.tile.IRotatable; import calclavia.lib.utility.MovementUtility; import cpw.mods.fml.common.Loader; import cpw.mods.fml.relauncher.ReflectionHelper; -public class TileMechanicalPiston extends TileMechanical +public class TileMechanicalPiston extends TileMechanical implements IRotatable { - // Planned CalCore option @ConfigInt() - private int breakCount = 5; + // Planned CalCore option @ConfigInt() + private int breakCount = 5; public TileMechanicalPiston() { + super(Material.piston); + mechanicalNode = new PacketMechanicalNode(this) { @Override @@ -45,6 +49,12 @@ public class TileMechanicalPiston extends TileMechanical } }.setLoad(0.5f); + + isOpaqueCube = false; + normalRender = false; + customItemRender = true; + rotationMask = Byte.parseByte("111111", 2); + textureName = "material_steel_dark"; } @Override @@ -63,7 +73,7 @@ public class TileMechanicalPiston extends TileMechanical { TileEntity tileEntity = from.getTileEntity(worldObj); - if (this.equals(to.getTileEntity(getWorldObj()))) + if (this.equals(to.getTileEntity(getWorldObj()))) { return false; } @@ -181,28 +191,28 @@ public class TileMechanicalPiston extends TileMechanical } } - public void hitOreBlock(Block oreBlock, Vector3 blockPos) - { - if (worldObj.isRemote) - { - // Spawn hit particles logic only, all other information is done Server Side - return; - } - else - { - if (this.breakCount <= 0) - { - getWorldObj().setBlockToAir(blockPos.intX(), blockPos.intY(), blockPos.intZ()); + public void hitOreBlock(Block oreBlock, Vector3 blockPos) + { + if (worldObj.isRemote) + { + // Spawn hit particles logic only, all other information is done Server Side + return; + } + else + { + if (this.breakCount <= 0) + { + getWorldObj().setBlockToAir(blockPos.intX(), blockPos.intY(), blockPos.intZ()); - } - this.breakCount--; - } + } + this.breakCount--; + } - } + } - @SideOnly(Side.CLIENT) - private void spawnParticles(Vector3 blockPos) - { + @SideOnly(Side.CLIENT) + private void spawnParticles(Vector3 blockPos) + { - } + } }