Better Crate Control Functions

This commit is contained in:
Henry Mao 2013-02-06 19:18:35 +08:00
parent c3e5c5f383
commit 0019108b57
2 changed files with 73 additions and 38 deletions

View file

@ -154,7 +154,7 @@ public class AssemblyLine
GameRegistry.addRecipe(new ShapedOreRecipe(itemImprint, new Object[] { "R", "P", "I", 'P', Item.paper, 'R', Item.redstone, 'I', new ItemStack(Item.dyePowder, 1, 0) }));
// Imprinter (VANILLA COMPATIBLE)
GameRegistry.addRecipe(new ShapedOreRecipe(blockImprinter, new Object[] { "SIS", "SPS", "WCW", 'S', Item.ingotIron, 'C', Block.chest, 'W', Block.workbench, 'P', Block.pistonStickyBase, 'I', new ItemStack(Item.dyePowder, 1, 0) }));
GameRegistry.addRecipe(new ShapedOreRecipe(blockImprinter, new Object[] { "SIS", "SPS", "WCW", 'S', Item.ingotIron, 'C', Block.chest, 'W', Block.workbench, 'P', Block.pistonBase, 'I', new ItemStack(Item.dyePowder, 1, 0) }));
// Detector
GameRegistry.addRecipe(new ShapedOreRecipe(blockDetector, new Object[] { "SES", "SCS", "SPS", 'S', "ingotSteel", 'C', "basicCircuit", 'E', Item.eyeOfEnder }));

View file

@ -28,14 +28,11 @@ public class BlockCrate extends BlockMachine
this.setTextureFile(AssemblyLine.BLOCK_TEXTURE_PATH);
}
/**
* Placed the item the player is holding into the crate.
*/
@Override
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player)
{
if (!world.isRemote)
{
if (world.isRemote)
return true;
if (world.getBlockTileEntity(x, y, z) instanceof TileEntityCrate)
{
TileEntityCrate tileEntity = (TileEntityCrate) world.getBlockTileEntity(x, y, z);
@ -51,8 +48,51 @@ public class BlockCrate extends BlockMachine
}
tileEntity.prevClickTime = world.getWorldTime();
// add items
if (side == 1 || (side > 1 && hitY > 0.5))
if (allMode)
{
this.ejectItems(tileEntity, player, TileEntityCrate.MAX_LIMIT);
}
else
{
ItemStack stack = tileEntity.getStackInSlot(0);
if (stack != null)
{
this.ejectItems(tileEntity, player, stack.getMaxStackSize());
}
}
}
}
}
/**
* Placed the item the player is holding into the crate.
*/
@Override
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if (!world.isRemote)
{
if (world.getBlockTileEntity(x, y, z) instanceof TileEntityCrate)
{
TileEntityCrate tileEntity = (TileEntityCrate) world.getBlockTileEntity(x, y, z);
/**
* Make double clicking input all stacks.
*/
boolean allMode = false;
if (world.getWorldTime() - tileEntity.prevClickTime < 10)
{
allMode = true;
}
tileEntity.prevClickTime = world.getWorldTime();
// Add items
if (side == 1 || (side > 1 && hitY > 0.5) || !player.capabilities.isCreativeMode)
{
if (allMode)
{
@ -80,14 +120,9 @@ public class BlockCrate extends BlockMachine
}
}
}
return true;
}
@Override
public int getRenderType()
{
return super.getRenderType();
return true;
}
/**