Better Crate Control Functions
This commit is contained in:
parent
c3e5c5f383
commit
0019108b57
2 changed files with 73 additions and 38 deletions
|
@ -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) }));
|
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)
|
// 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
|
// Detector
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockDetector, new Object[] { "SES", "SCS", "SPS", 'S', "ingotSteel", 'C', "basicCircuit", 'E', Item.eyeOfEnder }));
|
GameRegistry.addRecipe(new ShapedOreRecipe(blockDetector, new Object[] { "SES", "SCS", "SPS", 'S', "ingotSteel", 'C', "basicCircuit", 'E', Item.eyeOfEnder }));
|
||||||
|
|
|
@ -28,44 +28,27 @@ public class BlockCrate extends BlockMachine
|
||||||
this.setTextureFile(AssemblyLine.BLOCK_TEXTURE_PATH);
|
this.setTextureFile(AssemblyLine.BLOCK_TEXTURE_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Placed the item the player is holding into the crate.
|
|
||||||
*/
|
|
||||||
@Override
|
@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);
|
if (world.getBlockTileEntity(x, y, z) instanceof TileEntityCrate)
|
||||||
|
|
||||||
/**
|
|
||||||
* Make double clicking input all stacks.
|
|
||||||
*/
|
|
||||||
boolean allMode = false;
|
|
||||||
|
|
||||||
if (world.getWorldTime() - tileEntity.prevClickTime < 10)
|
|
||||||
{
|
{
|
||||||
allMode = true;
|
TileEntityCrate tileEntity = (TileEntityCrate) world.getBlockTileEntity(x, y, z);
|
||||||
}
|
|
||||||
|
|
||||||
tileEntity.prevClickTime = world.getWorldTime();
|
/**
|
||||||
// add items
|
* Make double clicking input all stacks.
|
||||||
if (side == 1 || (side > 1 && hitY > 0.5))
|
*/
|
||||||
{
|
boolean allMode = false;
|
||||||
if (allMode)
|
|
||||||
|
if (world.getWorldTime() - tileEntity.prevClickTime < 10)
|
||||||
{
|
{
|
||||||
this.insertAllItems(tileEntity, player);
|
allMode = true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
tileEntity.prevClickTime = world.getWorldTime();
|
||||||
this.insertCurrentItem(tileEntity, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// remove items
|
|
||||||
else if (side == 0 || (side > 1 && hitY <= 0.5))
|
|
||||||
{
|
|
||||||
if (allMode)
|
if (allMode)
|
||||||
{
|
{
|
||||||
this.ejectItems(tileEntity, player, TileEntityCrate.MAX_LIMIT);
|
this.ejectItems(tileEntity, player, TileEntityCrate.MAX_LIMIT);
|
||||||
|
@ -73,23 +56,75 @@ public class BlockCrate extends BlockMachine
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ItemStack stack = tileEntity.getStackInSlot(0);
|
ItemStack stack = tileEntity.getStackInSlot(0);
|
||||||
|
|
||||||
if (stack != null)
|
if (stack != null)
|
||||||
{
|
{
|
||||||
this.ejectItems(tileEntity, player, stack.getMaxStackSize());
|
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)
|
||||||
|
{
|
||||||
|
this.insertAllItems(tileEntity, player);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.insertCurrentItem(tileEntity, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// remove items
|
||||||
|
else if (side == 0 || (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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRenderType()
|
|
||||||
{
|
|
||||||
return super.getRenderType();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a the itemStack the player is holding into the crate.
|
* Inserts a the itemStack the player is holding into the crate.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue