Fixed block names and implemented BC wrench API
This commit is contained in:
parent
394becf356
commit
43cf672769
13 changed files with 309 additions and 244 deletions
|
@ -22,6 +22,7 @@ import assemblyline.common.machine.encoder.ContainerEncoder;
|
||||||
import assemblyline.common.machine.encoder.TileEntityEncoder;
|
import assemblyline.common.machine.encoder.TileEntityEncoder;
|
||||||
import assemblyline.common.machine.imprinter.ContainerImprinter;
|
import assemblyline.common.machine.imprinter.ContainerImprinter;
|
||||||
import assemblyline.common.machine.imprinter.TileEntityImprinter;
|
import assemblyline.common.machine.imprinter.TileEntityImprinter;
|
||||||
|
import buildcraft.api.tools.IToolWrench;
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
import cpw.mods.fml.common.network.IGuiHandler;
|
import cpw.mods.fml.common.network.IGuiHandler;
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
@ -141,4 +142,13 @@ public class CommonProxy implements IGuiHandler
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isHoldingBCWrench(EntityPlayer player)
|
||||||
|
{
|
||||||
|
if (player.getCurrentEquippedItem() == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return player.getCurrentEquippedItem().getItem() instanceof IToolWrench;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
54
src/minecraft/assemblyline/common/block/BlockALMachine.java
Normal file
54
src/minecraft/assemblyline/common/block/BlockALMachine.java
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -12,7 +12,6 @@ import net.minecraft.world.World;
|
||||||
import universalelectricity.core.UniversalElectricity;
|
import universalelectricity.core.UniversalElectricity;
|
||||||
import universalelectricity.core.implement.IItemElectric;
|
import universalelectricity.core.implement.IItemElectric;
|
||||||
import universalelectricity.core.vector.Vector3;
|
import universalelectricity.core.vector.Vector3;
|
||||||
import universalelectricity.prefab.BlockMachine;
|
|
||||||
import universalelectricity.prefab.implement.IToolConfigurator;
|
import universalelectricity.prefab.implement.IToolConfigurator;
|
||||||
import assemblyline.common.AssemblyLine;
|
import assemblyline.common.AssemblyLine;
|
||||||
import assemblyline.common.TabAssemblyLine;
|
import assemblyline.common.TabAssemblyLine;
|
||||||
|
@ -24,11 +23,12 @@ import assemblyline.common.TabAssemblyLine;
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class BlockCrate extends BlockMachine
|
public class BlockCrate extends BlockALMachine
|
||||||
{
|
{
|
||||||
public BlockCrate(int id, int texture)
|
public BlockCrate(int id, int texture)
|
||||||
{
|
{
|
||||||
super("crate", id, UniversalElectricity.machine);
|
super(id, UniversalElectricity.machine);
|
||||||
|
this.setBlockName("crate");
|
||||||
this.blockIndexInTexture = texture;
|
this.blockIndexInTexture = texture;
|
||||||
this.setCreativeTab(TabAssemblyLine.INSTANCE);
|
this.setCreativeTab(TabAssemblyLine.INSTANCE);
|
||||||
this.setTextureFile(AssemblyLine.BLOCK_TEXTURE_PATH);
|
this.setTextureFile(AssemblyLine.BLOCK_TEXTURE_PATH);
|
||||||
|
|
|
@ -11,12 +11,11 @@ import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import universalelectricity.core.vector.Vector3;
|
import universalelectricity.core.vector.Vector3;
|
||||||
import universalelectricity.prefab.BlockMachine;
|
|
||||||
import universalelectricity.prefab.implement.IRotatable;
|
import universalelectricity.prefab.implement.IRotatable;
|
||||||
import assemblyline.common.AssemblyLine;
|
import assemblyline.common.AssemblyLine;
|
||||||
import assemblyline.common.TabAssemblyLine;
|
import assemblyline.common.TabAssemblyLine;
|
||||||
|
|
||||||
public class BlockTurntable extends BlockMachine
|
public class BlockTurntable extends BlockALMachine
|
||||||
{
|
{
|
||||||
public BlockTurntable(int par1, int par2)
|
public BlockTurntable(int par1, int par2)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package assemblyline.common.machine;
|
package assemblyline.common.machine;
|
||||||
|
|
||||||
import assemblyline.common.TabAssemblyLine;
|
import assemblyline.common.TabAssemblyLine;
|
||||||
|
import assemblyline.common.block.BlockALMachine;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import universalelectricity.prefab.BlockMachine;
|
|
||||||
|
|
||||||
public class BlockBeltSorter extends BlockMachine
|
public class BlockBeltSorter extends BlockALMachine
|
||||||
{
|
{
|
||||||
|
|
||||||
public BlockBeltSorter(int id)
|
public BlockBeltSorter(int id)
|
||||||
|
|
|
@ -9,18 +9,19 @@ import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import universalelectricity.core.UniversalElectricity;
|
import universalelectricity.core.UniversalElectricity;
|
||||||
import universalelectricity.core.vector.Vector3;
|
import universalelectricity.core.vector.Vector3;
|
||||||
import universalelectricity.prefab.BlockMachine;
|
|
||||||
import universalelectricity.prefab.multiblock.IMultiBlock;
|
import universalelectricity.prefab.multiblock.IMultiBlock;
|
||||||
import assemblyline.client.render.BlockRenderingHandler;
|
import assemblyline.client.render.BlockRenderingHandler;
|
||||||
import assemblyline.common.TabAssemblyLine;
|
import assemblyline.common.TabAssemblyLine;
|
||||||
|
import assemblyline.common.block.BlockALMachine;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class BlockArmbot extends BlockMachine
|
public class BlockArmbot extends BlockALMachine
|
||||||
{
|
{
|
||||||
public BlockArmbot(int id)
|
public BlockArmbot(int id)
|
||||||
{
|
{
|
||||||
super("armbot", id, UniversalElectricity.machine);
|
super(id, UniversalElectricity.machine);
|
||||||
|
this.setBlockName("armbot");
|
||||||
this.setCreativeTab(TabAssemblyLine.INSTANCE);
|
this.setCreativeTab(TabAssemblyLine.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,9 @@ import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import universalelectricity.core.UniversalElectricity;
|
import universalelectricity.core.UniversalElectricity;
|
||||||
import universalelectricity.prefab.BlockMachine;
|
|
||||||
import assemblyline.client.render.BlockRenderingHandler;
|
import assemblyline.client.render.BlockRenderingHandler;
|
||||||
import assemblyline.common.TabAssemblyLine;
|
import assemblyline.common.TabAssemblyLine;
|
||||||
|
import assemblyline.common.block.BlockALMachine;
|
||||||
import assemblyline.common.machine.belt.TileEntityConveyorBelt.SlantType;
|
import assemblyline.common.machine.belt.TileEntityConveyorBelt.SlantType;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
@ -25,11 +25,12 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
*
|
*
|
||||||
* @author Calclavia, DarkGuardsman
|
* @author Calclavia, DarkGuardsman
|
||||||
*/
|
*/
|
||||||
public class BlockConveyorBelt extends BlockMachine
|
public class BlockConveyorBelt extends BlockALMachine
|
||||||
{
|
{
|
||||||
public BlockConveyorBelt(int id)
|
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.setBlockBounds(0, 0, 0, 1, 0.3f, 1);
|
||||||
this.setCreativeTab(TabAssemblyLine.INSTANCE);
|
this.setCreativeTab(TabAssemblyLine.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,13 @@ 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 universalelectricity.core.UniversalElectricity;
|
import universalelectricity.core.UniversalElectricity;
|
||||||
import universalelectricity.prefab.BlockMachine;
|
|
||||||
import assemblyline.client.render.BlockRenderingHandler;
|
import assemblyline.client.render.BlockRenderingHandler;
|
||||||
import assemblyline.common.TabAssemblyLine;
|
import assemblyline.common.TabAssemblyLine;
|
||||||
|
import assemblyline.common.block.BlockALMachine;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class BlockCraneController extends BlockMachine
|
public class BlockCraneController extends BlockALMachine
|
||||||
{
|
{
|
||||||
public BlockCraneController(int id)
|
public BlockCraneController(int id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,13 +6,13 @@ import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import universalelectricity.core.UniversalElectricity;
|
import universalelectricity.core.UniversalElectricity;
|
||||||
import universalelectricity.prefab.BlockMachine;
|
|
||||||
import assemblyline.client.render.BlockRenderingHandler;
|
import assemblyline.client.render.BlockRenderingHandler;
|
||||||
import assemblyline.common.TabAssemblyLine;
|
import assemblyline.common.TabAssemblyLine;
|
||||||
|
import assemblyline.common.block.BlockALMachine;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class BlockCraneFrame extends BlockMachine
|
public class BlockCraneFrame extends BlockALMachine
|
||||||
{
|
{
|
||||||
public BlockCraneFrame(int id)
|
public BlockCraneFrame(int id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,12 +4,12 @@ import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import universalelectricity.prefab.BlockMachine;
|
|
||||||
import assemblyline.common.AssemblyLine;
|
import assemblyline.common.AssemblyLine;
|
||||||
import assemblyline.common.CommonProxy;
|
import assemblyline.common.CommonProxy;
|
||||||
import assemblyline.common.TabAssemblyLine;
|
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)
|
public BlockEncoder(int id, int texture)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,16 +9,16 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import universalelectricity.prefab.BlockMachine;
|
|
||||||
import universalelectricity.prefab.implement.IRedstoneReceptor;
|
import universalelectricity.prefab.implement.IRedstoneReceptor;
|
||||||
import assemblyline.api.IFilterable;
|
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.
|
* Extend this block class if a filter is allowed to be placed inside of this block.
|
||||||
*
|
*
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
*/
|
*/
|
||||||
public abstract class BlockImprintable extends BlockMachine
|
public abstract class BlockImprintable extends BlockALMachine
|
||||||
{
|
{
|
||||||
public BlockImprintable(String name, int id, Material material, CreativeTabs creativeTab)
|
public BlockImprintable(String name, int id, Material material, CreativeTabs creativeTab)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,12 +9,12 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import universalelectricity.prefab.BlockMachine;
|
|
||||||
import assemblyline.common.AssemblyLine;
|
import assemblyline.common.AssemblyLine;
|
||||||
import assemblyline.common.CommonProxy;
|
import assemblyline.common.CommonProxy;
|
||||||
import assemblyline.common.TabAssemblyLine;
|
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)
|
public BlockImprinter(int id, int texture)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,221 +1,221 @@
|
||||||
package universalelectricity.prefab;
|
package universalelectricity.prefab;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.BlockContainer;
|
import net.minecraft.block.BlockContainer;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import universalelectricity.core.implement.IItemElectric;
|
import universalelectricity.core.implement.IItemElectric;
|
||||||
import universalelectricity.prefab.implement.ISneakUseWrench;
|
import universalelectricity.prefab.implement.ISneakUseWrench;
|
||||||
import universalelectricity.prefab.implement.IToolConfigurator;
|
import universalelectricity.prefab.implement.IToolConfigurator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A block you may extend from to create your machine blocks! You do not have to extend from this
|
* 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
|
* block if you do not want to. It's optional but it comes with some useful functions that will make
|
||||||
* coding easier for you.
|
* coding easier for you.
|
||||||
*/
|
*/
|
||||||
public abstract class BlockMachine extends BlockContainer implements ISneakUseWrench
|
public abstract class BlockMachine extends BlockContainer implements ISneakUseWrench
|
||||||
{
|
{
|
||||||
public BlockMachine(int id, Material material)
|
public BlockMachine(int id, Material material)
|
||||||
{
|
{
|
||||||
super(id, material);
|
super(id, material);
|
||||||
this.setHardness(0.6f);
|
this.setHardness(0.6f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockMachine(int id, int textureIndex, Material material)
|
public BlockMachine(int id, int textureIndex, Material material)
|
||||||
{
|
{
|
||||||
super(id, textureIndex, material);
|
super(id, textureIndex, material);
|
||||||
this.setHardness(0.6f);
|
this.setHardness(0.6f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public BlockMachine(String string, int id, Material material)
|
public BlockMachine(String string, int id, Material material)
|
||||||
{
|
{
|
||||||
this(id, material);
|
this(id, material);
|
||||||
this.setBlockName(string);
|
this.setBlockName(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public BlockMachine(String string, int id, Material material, CreativeTabs creativeTab)
|
public BlockMachine(String string, int id, Material material, CreativeTabs creativeTab)
|
||||||
{
|
{
|
||||||
this(string, id, material);
|
this(string, id, material);
|
||||||
this.setCreativeTab(creativeTab);
|
this.setCreativeTab(creativeTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DO NOT OVERRIDE THIS FUNCTION! Called when the block is right clicked by the player. This
|
* 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
|
* 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)
|
* override this function. Use onMachineActivated instead! (It does the same thing)
|
||||||
*
|
*
|
||||||
* @param world The World Object.
|
* @param world The World Object.
|
||||||
* @param x , y, z The coordinate of the block.
|
* @param x , y, z The coordinate of the block.
|
||||||
* @param side The side the player clicked on.
|
* @param side The side the player clicked on.
|
||||||
* @param hitX , hitY, hitZ The position the player clicked on relative to the block.
|
* @param hitX , hitY, hitZ The position the player clicked on relative to the block.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
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);
|
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.
|
* 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() != null)
|
||||||
{
|
{
|
||||||
if (par5EntityPlayer.inventory.getCurrentItem().getItem() instanceof IToolConfigurator)
|
if (par5EntityPlayer.inventory.getCurrentItem().getItem() instanceof IToolConfigurator)
|
||||||
{
|
{
|
||||||
world.notifyBlocksOfNeighborChange(x, y, z, this.blockID);
|
world.notifyBlocksOfNeighborChange(x, y, z, this.blockID);
|
||||||
((IToolConfigurator) par5EntityPlayer.inventory.getCurrentItem().getItem()).wrenchUsed(par5EntityPlayer, x, y, z);
|
((IToolConfigurator) par5EntityPlayer.inventory.getCurrentItem().getItem()).wrenchUsed(par5EntityPlayer, x, y, z);
|
||||||
|
|
||||||
return this.onUseWrench(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ);
|
return this.onUseWrench(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ);
|
||||||
}
|
}
|
||||||
else if (par5EntityPlayer.inventory.getCurrentItem().getItem() instanceof IItemElectric)
|
else if (par5EntityPlayer.inventory.getCurrentItem().getItem() instanceof IItemElectric)
|
||||||
{
|
{
|
||||||
if (this.onUseElectricItem(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ))
|
if (this.onUseElectricItem(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (par5EntityPlayer.isSneaking())
|
if (par5EntityPlayer.isSneaking())
|
||||||
{
|
{
|
||||||
if (this.onSneakMachineActivated(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ))
|
if (this.onSneakMachineActivated(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.onMachineActivated(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ);
|
return this.onMachineActivated(world, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the machine is right clicked by the player
|
* Called when the machine is right clicked by the player
|
||||||
*
|
*
|
||||||
* @return True if something happens
|
* @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)
|
public boolean onMachineActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the machine is being wrenched by a player while sneaking.
|
* Called when the machine is being wrenched by a player while sneaking.
|
||||||
*
|
*
|
||||||
* @return True if something happens
|
* @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)
|
public boolean onSneakMachineActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player uses an electric item on the machine
|
* Called when a player uses an electric item on the machine
|
||||||
*
|
*
|
||||||
* @return True if some happens
|
* @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)
|
public boolean onUseElectricItem(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player uses a wrench on the machine
|
* Called when a player uses a wrench on the machine
|
||||||
*
|
*
|
||||||
* @return True if some happens
|
* @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)
|
public boolean onUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player uses a wrench on the machine while sneaking. Only works with the UE
|
* Called when a player uses a wrench on the machine while sneaking. Only works with the UE
|
||||||
* wrench.
|
* wrench.
|
||||||
*
|
*
|
||||||
* @return True if some happens
|
* @return True if some happens
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean onSneakUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
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);
|
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
|
* Returns the TileEntity used by this block. You should use the metadata sensitive version of
|
||||||
* this to get the maximum optimization!
|
* this to get the maximum optimization!
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(World var1)
|
public TileEntity createNewTileEntity(World var1)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World par1World, int x, int y, int z, int par5, int par6)
|
public void breakBlock(World par1World, int x, int y, int z, int par5, int par6)
|
||||||
{
|
{
|
||||||
this.dropEntireInventory(par1World, x, y, z, par5, par6);
|
this.dropEntireInventory(par1World, x, y, z, par5, par6);
|
||||||
super.breakBlock(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
|
* Override this if you don't need it. This will eject all items out of this machine if it has
|
||||||
* an inventory.
|
* an inventory.
|
||||||
*/
|
*/
|
||||||
public void dropEntireInventory(World par1World, int x, int y, int z, int par5, int par6)
|
public void dropEntireInventory(World par1World, int x, int y, int z, int par5, int par6)
|
||||||
{
|
{
|
||||||
TileEntity tileEntity = par1World.getBlockTileEntity(x, y, z);
|
TileEntity tileEntity = par1World.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
if (tileEntity != null)
|
if (tileEntity != null)
|
||||||
{
|
{
|
||||||
if (tileEntity instanceof IInventory)
|
if (tileEntity instanceof IInventory)
|
||||||
{
|
{
|
||||||
IInventory inventory = (IInventory) tileEntity;
|
IInventory inventory = (IInventory) tileEntity;
|
||||||
|
|
||||||
for (int var6 = 0; var6 < inventory.getSizeInventory(); ++var6)
|
for (int var6 = 0; var6 < inventory.getSizeInventory(); ++var6)
|
||||||
{
|
{
|
||||||
ItemStack var7 = inventory.getStackInSlot(var6);
|
ItemStack var7 = inventory.getStackInSlot(var6);
|
||||||
|
|
||||||
if (var7 != null)
|
if (var7 != null)
|
||||||
{
|
{
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
float var8 = random.nextFloat() * 0.8F + 0.1F;
|
float var8 = random.nextFloat() * 0.8F + 0.1F;
|
||||||
float var9 = random.nextFloat() * 0.8F + 0.1F;
|
float var9 = random.nextFloat() * 0.8F + 0.1F;
|
||||||
float var10 = random.nextFloat() * 0.8F + 0.1F;
|
float var10 = random.nextFloat() * 0.8F + 0.1F;
|
||||||
|
|
||||||
while (var7.stackSize > 0)
|
while (var7.stackSize > 0)
|
||||||
{
|
{
|
||||||
int var11 = random.nextInt(21) + 10;
|
int var11 = random.nextInt(21) + 10;
|
||||||
|
|
||||||
if (var11 > var7.stackSize)
|
if (var11 > var7.stackSize)
|
||||||
{
|
{
|
||||||
var11 = var7.stackSize;
|
var11 = var7.stackSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
var7.stackSize -= var11;
|
var7.stackSize -= var11;
|
||||||
EntityItem var12 = new EntityItem(par1World, (x + var8), (y + var9), (z + var10), new ItemStack(var7.itemID, var11, var7.getItemDamage()));
|
EntityItem var12 = new EntityItem(par1World, (x + var8), (y + var9), (z + var10), new ItemStack(var7.itemID, var11, var7.getItemDamage()));
|
||||||
|
|
||||||
if (var7.hasTagCompound())
|
if (var7.hasTagCompound())
|
||||||
{
|
{
|
||||||
var12.getEntityItem().setTagCompound((NBTTagCompound) var7.getTagCompound().copy());
|
var12.getEntityItem().setTagCompound((NBTTagCompound) var7.getTagCompound().copy());
|
||||||
}
|
}
|
||||||
|
|
||||||
float var13 = 0.05F;
|
float var13 = 0.05F;
|
||||||
var12.motionX = ((float) random.nextGaussian() * var13);
|
var12.motionX = ((float) random.nextGaussian() * var13);
|
||||||
var12.motionY = ((float) random.nextGaussian() * var13 + 0.2F);
|
var12.motionY = ((float) random.nextGaussian() * var13 + 0.2F);
|
||||||
var12.motionZ = ((float) random.nextGaussian() * var13);
|
var12.motionZ = ((float) random.nextGaussian() * var13);
|
||||||
par1World.spawnEntityInWorld(var12);
|
par1World.spawnEntityInWorld(var12);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue