diff --git a/src/minecraft/assemblyline/common/CommonProxy.java b/src/minecraft/assemblyline/common/CommonProxy.java index 816d59f8..3ce520ce 100644 --- a/src/minecraft/assemblyline/common/CommonProxy.java +++ b/src/minecraft/assemblyline/common/CommonProxy.java @@ -22,6 +22,7 @@ import assemblyline.common.machine.encoder.ContainerEncoder; import assemblyline.common.machine.encoder.TileEntityEncoder; import assemblyline.common.machine.imprinter.ContainerImprinter; import assemblyline.common.machine.imprinter.TileEntityImprinter; +import buildcraft.api.tools.IToolWrench; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.registry.GameRegistry; @@ -141,4 +142,13 @@ public class CommonProxy implements IGuiHandler { return false; } + + public static boolean isHoldingBCWrench(EntityPlayer player) + { + if (player.getCurrentEquippedItem() == null) + { + return false; + } + return player.getCurrentEquippedItem().getItem() instanceof IToolWrench; + } } diff --git a/src/minecraft/assemblyline/common/block/BlockALMachine.java b/src/minecraft/assemblyline/common/block/BlockALMachine.java new file mode 100644 index 00000000..d0ca15e0 --- /dev/null +++ b/src/minecraft/assemblyline/common/block/BlockALMachine.java @@ -0,0 +1,54 @@ +package assemblyline.common.block; + +import assemblyline.common.CommonProxy; +import universalelectricity.core.implement.IItemElectric; +import universalelectricity.prefab.BlockMachine; +import universalelectricity.prefab.implement.IToolConfigurator; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public class BlockALMachine extends BlockMachine +{ + + public BlockALMachine(int id, Material material) + { + super(id, material); + } + + public BlockALMachine(int id, int textureIndex, Material material) + { + super(id, textureIndex, material); + } + + @Deprecated + public BlockALMachine(String string, int id, Material material) + { + this(id, material); + } + + @Deprecated + public BlockALMachine(String string, int id, Material material, CreativeTabs creativeTab) + { + this(string, id, material); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) + { + /** + * Check if the player is holding a wrench or an electric item. If so, do not open the GUI. + */ + if (player.inventory.getCurrentItem() != null) + { + if (CommonProxy.isHoldingBCWrench(player)) + { + return this.onUseWrench(world, x, y, z, player, side, hitX, hitY, hitZ); + } + } + + return super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); + } + +} \ No newline at end of file diff --git a/src/minecraft/assemblyline/common/block/BlockCrate.java b/src/minecraft/assemblyline/common/block/BlockCrate.java index 13173f7e..68f8a7e5 100644 --- a/src/minecraft/assemblyline/common/block/BlockCrate.java +++ b/src/minecraft/assemblyline/common/block/BlockCrate.java @@ -12,7 +12,6 @@ import net.minecraft.world.World; import universalelectricity.core.UniversalElectricity; import universalelectricity.core.implement.IItemElectric; import universalelectricity.core.vector.Vector3; -import universalelectricity.prefab.BlockMachine; import universalelectricity.prefab.implement.IToolConfigurator; import assemblyline.common.AssemblyLine; import assemblyline.common.TabAssemblyLine; @@ -24,11 +23,12 @@ import assemblyline.common.TabAssemblyLine; * @author Calclavia * */ -public class BlockCrate extends BlockMachine +public class BlockCrate extends BlockALMachine { public BlockCrate(int id, int texture) { - super("crate", id, UniversalElectricity.machine); + super(id, UniversalElectricity.machine); + this.setBlockName("crate"); this.blockIndexInTexture = texture; this.setCreativeTab(TabAssemblyLine.INSTANCE); this.setTextureFile(AssemblyLine.BLOCK_TEXTURE_PATH); diff --git a/src/minecraft/assemblyline/common/block/BlockTurntable.java b/src/minecraft/assemblyline/common/block/BlockTurntable.java index 4d994917..8e677f0b 100644 --- a/src/minecraft/assemblyline/common/block/BlockTurntable.java +++ b/src/minecraft/assemblyline/common/block/BlockTurntable.java @@ -11,12 +11,11 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; import universalelectricity.core.vector.Vector3; -import universalelectricity.prefab.BlockMachine; import universalelectricity.prefab.implement.IRotatable; import assemblyline.common.AssemblyLine; import assemblyline.common.TabAssemblyLine; -public class BlockTurntable extends BlockMachine +public class BlockTurntable extends BlockALMachine { public BlockTurntable(int par1, int par2) { diff --git a/src/minecraft/assemblyline/common/machine/BlockBeltSorter.java b/src/minecraft/assemblyline/common/machine/BlockBeltSorter.java index bb115b4b..0b72a431 100644 --- a/src/minecraft/assemblyline/common/machine/BlockBeltSorter.java +++ b/src/minecraft/assemblyline/common/machine/BlockBeltSorter.java @@ -1,11 +1,11 @@ package assemblyline.common.machine; import assemblyline.common.TabAssemblyLine; +import assemblyline.common.block.BlockALMachine; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; -import universalelectricity.prefab.BlockMachine; -public class BlockBeltSorter extends BlockMachine +public class BlockBeltSorter extends BlockALMachine { public BlockBeltSorter(int id) diff --git a/src/minecraft/assemblyline/common/machine/armbot/BlockArmbot.java b/src/minecraft/assemblyline/common/machine/armbot/BlockArmbot.java index c58f54bc..e461a7ff 100644 --- a/src/minecraft/assemblyline/common/machine/armbot/BlockArmbot.java +++ b/src/minecraft/assemblyline/common/machine/armbot/BlockArmbot.java @@ -9,18 +9,19 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import universalelectricity.core.UniversalElectricity; import universalelectricity.core.vector.Vector3; -import universalelectricity.prefab.BlockMachine; import universalelectricity.prefab.multiblock.IMultiBlock; import assemblyline.client.render.BlockRenderingHandler; import assemblyline.common.TabAssemblyLine; +import assemblyline.common.block.BlockALMachine; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class BlockArmbot extends BlockMachine +public class BlockArmbot extends BlockALMachine { public BlockArmbot(int id) { - super("armbot", id, UniversalElectricity.machine); + super(id, UniversalElectricity.machine); + this.setBlockName("armbot"); this.setCreativeTab(TabAssemblyLine.INSTANCE); } diff --git a/src/minecraft/assemblyline/common/machine/belt/BlockConveyorBelt.java b/src/minecraft/assemblyline/common/machine/belt/BlockConveyorBelt.java index c8e12279..1dd40cd9 100644 --- a/src/minecraft/assemblyline/common/machine/belt/BlockConveyorBelt.java +++ b/src/minecraft/assemblyline/common/machine/belt/BlockConveyorBelt.java @@ -13,9 +13,9 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; import universalelectricity.core.UniversalElectricity; -import universalelectricity.prefab.BlockMachine; import assemblyline.client.render.BlockRenderingHandler; import assemblyline.common.TabAssemblyLine; +import assemblyline.common.block.BlockALMachine; import assemblyline.common.machine.belt.TileEntityConveyorBelt.SlantType; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -25,11 +25,12 @@ import cpw.mods.fml.relauncher.SideOnly; * * @author Calclavia, DarkGuardsman */ -public class BlockConveyorBelt extends BlockMachine +public class BlockConveyorBelt extends BlockALMachine { public BlockConveyorBelt(int id) { - super("conveyorBelt", id, UniversalElectricity.machine); + super(id, UniversalElectricity.machine); + this.setBlockName("conveyorBelt"); this.setBlockBounds(0, 0, 0, 1, 0.3f, 1); this.setCreativeTab(TabAssemblyLine.INSTANCE); } diff --git a/src/minecraft/assemblyline/common/machine/crane/BlockCraneController.java b/src/minecraft/assemblyline/common/machine/crane/BlockCraneController.java index 43ca64a3..3322144a 100644 --- a/src/minecraft/assemblyline/common/machine/crane/BlockCraneController.java +++ b/src/minecraft/assemblyline/common/machine/crane/BlockCraneController.java @@ -5,13 +5,13 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; import universalelectricity.core.UniversalElectricity; -import universalelectricity.prefab.BlockMachine; import assemblyline.client.render.BlockRenderingHandler; import assemblyline.common.TabAssemblyLine; +import assemblyline.common.block.BlockALMachine; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class BlockCraneController extends BlockMachine +public class BlockCraneController extends BlockALMachine { public BlockCraneController(int id) { diff --git a/src/minecraft/assemblyline/common/machine/crane/BlockCraneFrame.java b/src/minecraft/assemblyline/common/machine/crane/BlockCraneFrame.java index b881c3dc..925e4ab5 100644 --- a/src/minecraft/assemblyline/common/machine/crane/BlockCraneFrame.java +++ b/src/minecraft/assemblyline/common/machine/crane/BlockCraneFrame.java @@ -6,13 +6,13 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; import universalelectricity.core.UniversalElectricity; -import universalelectricity.prefab.BlockMachine; import assemblyline.client.render.BlockRenderingHandler; import assemblyline.common.TabAssemblyLine; +import assemblyline.common.block.BlockALMachine; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class BlockCraneFrame extends BlockMachine +public class BlockCraneFrame extends BlockALMachine { public BlockCraneFrame(int id) { diff --git a/src/minecraft/assemblyline/common/machine/encoder/BlockEncoder.java b/src/minecraft/assemblyline/common/machine/encoder/BlockEncoder.java index 25456d79..26dacb3a 100644 --- a/src/minecraft/assemblyline/common/machine/encoder/BlockEncoder.java +++ b/src/minecraft/assemblyline/common/machine/encoder/BlockEncoder.java @@ -4,12 +4,12 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import universalelectricity.prefab.BlockMachine; import assemblyline.common.AssemblyLine; import assemblyline.common.CommonProxy; import assemblyline.common.TabAssemblyLine; +import assemblyline.common.block.BlockALMachine; -public class BlockEncoder extends BlockMachine +public class BlockEncoder extends BlockALMachine { public BlockEncoder(int id, int texture) { diff --git a/src/minecraft/assemblyline/common/machine/imprinter/BlockImprintable.java b/src/minecraft/assemblyline/common/machine/imprinter/BlockImprintable.java index b239173a..269d47da 100644 --- a/src/minecraft/assemblyline/common/machine/imprinter/BlockImprintable.java +++ b/src/minecraft/assemblyline/common/machine/imprinter/BlockImprintable.java @@ -9,16 +9,16 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.World; -import universalelectricity.prefab.BlockMachine; import universalelectricity.prefab.implement.IRedstoneReceptor; import assemblyline.api.IFilterable; +import assemblyline.common.block.BlockALMachine; /** * Extend this block class if a filter is allowed to be placed inside of this block. * * @author Calclavia */ -public abstract class BlockImprintable extends BlockMachine +public abstract class BlockImprintable extends BlockALMachine { public BlockImprintable(String name, int id, Material material, CreativeTabs creativeTab) { diff --git a/src/minecraft/assemblyline/common/machine/imprinter/BlockImprinter.java b/src/minecraft/assemblyline/common/machine/imprinter/BlockImprinter.java index 2e4dbe4b..655be85e 100644 --- a/src/minecraft/assemblyline/common/machine/imprinter/BlockImprinter.java +++ b/src/minecraft/assemblyline/common/machine/imprinter/BlockImprinter.java @@ -9,12 +9,12 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import universalelectricity.prefab.BlockMachine; import assemblyline.common.AssemblyLine; import assemblyline.common.CommonProxy; import assemblyline.common.TabAssemblyLine; +import assemblyline.common.block.BlockALMachine; -public class BlockImprinter extends BlockMachine +public class BlockImprinter extends BlockALMachine { public BlockImprinter(int id, int texture) { diff --git a/src/minecraft/universalelectricity/prefab/BlockMachine.java b/src/minecraft/universalelectricity/prefab/BlockMachine.java index fe148109..3cb5bd4a 100644 --- a/src/minecraft/universalelectricity/prefab/BlockMachine.java +++ b/src/minecraft/universalelectricity/prefab/BlockMachine.java @@ -1,221 +1,221 @@ -package universalelectricity.prefab; - -import java.util.Random; - -import net.minecraft.block.BlockContainer; -import net.minecraft.block.material.Material; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import universalelectricity.core.implement.IItemElectric; -import universalelectricity.prefab.implement.ISneakUseWrench; -import universalelectricity.prefab.implement.IToolConfigurator; - -/** - * A block you may extend from to create your machine blocks! You do not have to extend from this - * block if you do not want to. It's optional but it comes with some useful functions that will make - * coding easier for you. - */ -public abstract class BlockMachine extends BlockContainer implements ISneakUseWrench -{ - public BlockMachine(int id, Material material) - { - super(id, material); - this.setHardness(0.6f); - } - - public BlockMachine(int id, int textureIndex, Material material) - { - super(id, textureIndex, material); - this.setHardness(0.6f); - } - - @Deprecated - public BlockMachine(String string, int id, Material material) - { - this(id, material); - this.setBlockName(string); - } - - @Deprecated - public BlockMachine(String string, int id, Material material, CreativeTabs creativeTab) - { - this(string, id, material); - this.setCreativeTab(creativeTab); - } - - /** - * DO NOT OVERRIDE THIS FUNCTION! Called when the block is right clicked by the player. This - * modified version detects electric items and wrench actions on your machine block. Do not - * override this function. Use onMachineActivated instead! (It does the same thing) - * - * @param world The World Object. - * @param x , y, z The coordinate of the block. - * @param side The side the player clicked on. - * @param hitX , hitY, hitZ The position the player clicked on relative to the block. - */ - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) - { - int metadata = world.getBlockMetadata(x, y, z); - - /** - * Check if the player is holding a wrench or an electric item. If so, do not open the GUI. - */ - if (par5EntityPlayer.inventory.getCurrentItem() != null) - { - if (par5EntityPlayer.inventory.getCurrentItem().getItem() instanceof IToolConfigurator) - { - world.notifyBlocksOfNeighborChange(x, y, z, this.blockID); - ((IToolConfigurator) par5EntityPlayer.inventory.getCurrentItem().getItem()).wrenchUsed(par5EntityPlayer, x, y, z); - - return this.onUseWrench(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ); - } - else if (par5EntityPlayer.inventory.getCurrentItem().getItem() instanceof IItemElectric) - { - if (this.onUseElectricItem(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ)) - { - return true; - } - } - } - - if (par5EntityPlayer.isSneaking()) - { - if (this.onSneakMachineActivated(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ)) - { - return true; - } - } - - return this.onMachineActivated(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ); - } - - /** - * Called when the machine is right clicked by the player - * - * @return True if something happens - */ - public boolean onMachineActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) - { - return false; - } - - /** - * Called when the machine is being wrenched by a player while sneaking. - * - * @return True if something happens - */ - public boolean onSneakMachineActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) - { - return false; - } - - /** - * Called when a player uses an electric item on the machine - * - * @return True if some happens - */ - public boolean onUseElectricItem(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) - { - return false; - } - - /** - * Called when a player uses a wrench on the machine - * - * @return True if some happens - */ - public boolean onUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) - { - return false; - } - - /** - * Called when a player uses a wrench on the machine while sneaking. Only works with the UE - * wrench. - * - * @return True if some happens - */ - @Override - public boolean onSneakUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) - { - return this.onUseWrench(par1World, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ); - } - - /** - * Returns the TileEntity used by this block. You should use the metadata sensitive version of - * this to get the maximum optimization! - */ - @Override - public TileEntity createNewTileEntity(World var1) - { - return null; - } - - @Override - public void breakBlock(World par1World, int x, int y, int z, int par5, int par6) - { - this.dropEntireInventory(par1World, x, y, z, par5, par6); - super.breakBlock(par1World, x, y, z, par5, par6); - } - - /** - * Override this if you don't need it. This will eject all items out of this machine if it has - * an inventory. - */ - public void dropEntireInventory(World par1World, int x, int y, int z, int par5, int par6) - { - TileEntity tileEntity = par1World.getBlockTileEntity(x, y, z); - - if (tileEntity != null) - { - if (tileEntity instanceof IInventory) - { - IInventory inventory = (IInventory) tileEntity; - - for (int var6 = 0; var6 < inventory.getSizeInventory(); ++var6) - { - ItemStack var7 = inventory.getStackInSlot(var6); - - if (var7 != null) - { - Random random = new Random(); - float var8 = random.nextFloat() * 0.8F + 0.1F; - float var9 = random.nextFloat() * 0.8F + 0.1F; - float var10 = random.nextFloat() * 0.8F + 0.1F; - - while (var7.stackSize > 0) - { - int var11 = random.nextInt(21) + 10; - - if (var11 > var7.stackSize) - { - var11 = var7.stackSize; - } - - var7.stackSize -= var11; - EntityItem var12 = new EntityItem(par1World, (x + var8), (y + var9), (z + var10), new ItemStack(var7.itemID, var11, var7.getItemDamage())); - - if (var7.hasTagCompound()) - { - var12.getEntityItem().setTagCompound((NBTTagCompound) var7.getTagCompound().copy()); - } - - float var13 = 0.05F; - var12.motionX = ((float) random.nextGaussian() * var13); - var12.motionY = ((float) random.nextGaussian() * var13 + 0.2F); - var12.motionZ = ((float) random.nextGaussian() * var13); - par1World.spawnEntityInWorld(var12); - } - } - } - } - } - } -} +package universalelectricity.prefab; + +import java.util.Random; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import universalelectricity.core.implement.IItemElectric; +import universalelectricity.prefab.implement.ISneakUseWrench; +import universalelectricity.prefab.implement.IToolConfigurator; + +/** + * A block you may extend from to create your machine blocks! You do not have to extend from this + * block if you do not want to. It's optional but it comes with some useful functions that will make + * coding easier for you. + */ +public abstract class BlockMachine extends BlockContainer implements ISneakUseWrench +{ + public BlockMachine(int id, Material material) + { + super(id, material); + this.setHardness(0.6f); + } + + public BlockMachine(int id, int textureIndex, Material material) + { + super(id, textureIndex, material); + this.setHardness(0.6f); + } + + @Deprecated + public BlockMachine(String string, int id, Material material) + { + this(id, material); + this.setBlockName(string); + } + + @Deprecated + public BlockMachine(String string, int id, Material material, CreativeTabs creativeTab) + { + this(string, id, material); + this.setCreativeTab(creativeTab); + } + + /** + * DO NOT OVERRIDE THIS FUNCTION! Called when the block is right clicked by the player. This + * modified version detects electric items and wrench actions on your machine block. Do not + * override this function. Use onMachineActivated instead! (It does the same thing) + * + * @param world The World Object. + * @param x , y, z The coordinate of the block. + * @param side The side the player clicked on. + * @param hitX , hitY, hitZ The position the player clicked on relative to the block. + */ + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) + { + int metadata = world.getBlockMetadata(x, y, z); + + /** + * Check if the player is holding a wrench or an electric item. If so, do not open the GUI. + */ + if (par5EntityPlayer.inventory.getCurrentItem() != null) + { + if (par5EntityPlayer.inventory.getCurrentItem().getItem() instanceof IToolConfigurator) + { + world.notifyBlocksOfNeighborChange(x, y, z, this.blockID); + ((IToolConfigurator) par5EntityPlayer.inventory.getCurrentItem().getItem()).wrenchUsed(par5EntityPlayer, x, y, z); + + return this.onUseWrench(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ); + } + else if (par5EntityPlayer.inventory.getCurrentItem().getItem() instanceof IItemElectric) + { + if (this.onUseElectricItem(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ)) + { + return true; + } + } + } + + if (par5EntityPlayer.isSneaking()) + { + if (this.onSneakMachineActivated(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ)) + { + return true; + } + } + + return this.onMachineActivated(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ); + } + + /** + * Called when the machine is right clicked by the player + * + * @return True if something happens + */ + public boolean onMachineActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) + { + return false; + } + + /** + * Called when the machine is being wrenched by a player while sneaking. + * + * @return True if something happens + */ + public boolean onSneakMachineActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) + { + return false; + } + + /** + * Called when a player uses an electric item on the machine + * + * @return True if some happens + */ + public boolean onUseElectricItem(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) + { + return false; + } + + /** + * Called when a player uses a wrench on the machine + * + * @return True if some happens + */ + public boolean onUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) + { + return false; + } + + /** + * Called when a player uses a wrench on the machine while sneaking. Only works with the UE + * wrench. + * + * @return True if some happens + */ + @Override + public boolean onSneakUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) + { + return this.onUseWrench(par1World, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ); + } + + /** + * Returns the TileEntity used by this block. You should use the metadata sensitive version of + * this to get the maximum optimization! + */ + @Override + public TileEntity createNewTileEntity(World var1) + { + return null; + } + + @Override + public void breakBlock(World par1World, int x, int y, int z, int par5, int par6) + { + this.dropEntireInventory(par1World, x, y, z, par5, par6); + super.breakBlock(par1World, x, y, z, par5, par6); + } + + /** + * Override this if you don't need it. This will eject all items out of this machine if it has + * an inventory. + */ + public void dropEntireInventory(World par1World, int x, int y, int z, int par5, int par6) + { + TileEntity tileEntity = par1World.getBlockTileEntity(x, y, z); + + if (tileEntity != null) + { + if (tileEntity instanceof IInventory) + { + IInventory inventory = (IInventory) tileEntity; + + for (int var6 = 0; var6 < inventory.getSizeInventory(); ++var6) + { + ItemStack var7 = inventory.getStackInSlot(var6); + + if (var7 != null) + { + Random random = new Random(); + float var8 = random.nextFloat() * 0.8F + 0.1F; + float var9 = random.nextFloat() * 0.8F + 0.1F; + float var10 = random.nextFloat() * 0.8F + 0.1F; + + while (var7.stackSize > 0) + { + int var11 = random.nextInt(21) + 10; + + if (var11 > var7.stackSize) + { + var11 = var7.stackSize; + } + + var7.stackSize -= var11; + EntityItem var12 = new EntityItem(par1World, (x + var8), (y + var9), (z + var10), new ItemStack(var7.itemID, var11, var7.getItemDamage())); + + if (var7.hasTagCompound()) + { + var12.getEntityItem().setTagCompound((NBTTagCompound) var7.getTagCompound().copy()); + } + + float var13 = 0.05F; + var12.motionX = ((float) random.nextGaussian() * var13); + var12.motionY = ((float) random.nextGaussian() * var13 + 0.2F); + var12.motionZ = ((float) random.nextGaussian() * var13); + par1World.spawnEntityInWorld(var12); + } + } + } + } + } + } +}