Crate top slot in creative auto fills crate

Added this for testing so that i can right click the top slot of a crate
with an item to fill the crate all the way up.
This commit is contained in:
Robert Seifert 2013-05-07 03:58:55 -04:00
parent 94b83ea1c5
commit 16ce63aadd
3 changed files with 28 additions and 11 deletions

View file

@ -84,8 +84,10 @@ public class BlockCrate extends BlockALMachine
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
{
if (super.onBlockActivated(world, x, y, z, entityPlayer, side, hitX, hitY, hitZ)){
return true;}
if (super.onBlockActivated(world, x, y, z, entityPlayer, side, hitX, hitY, hitZ))
{
return true;
}
if (!world.isRemote)
{
@ -100,7 +102,13 @@ public class BlockCrate extends BlockALMachine
tileEntity.prevClickTime = world.getWorldTime();
ItemStack current = entityPlayer.inventory.getCurrentItem();
if(side == 1 && entityPlayer.capabilities.isCreativeMode)
{
if (current != null && tileEntity.getStackInSlot(0) == null)
{
tileEntity.setInventorySlotContents(0, new ItemStack(current.itemID, TileEntityCrate.getMaxLimit(world.getBlockMetadata(x, y, z)), current.getItemDamage()));
}
}
// Add items
if (side == 1 || (side > 1 && hitY > 0.5) || !entityPlayer.capabilities.isCreativeMode)
{
@ -410,6 +418,18 @@ public class BlockCrate extends BlockALMachine
{
list.add(new ItemStack(this, 1, i));
}
try
{
ItemStack stack = new ItemStack(this);
ItemBlockCrate.setContainingItemStack(stack, new ItemStack(1, 2048, 0));
list.add(stack);
// 3903
}
catch (Exception e)
{
e.printStackTrace();
}
}
}

View file

@ -49,7 +49,7 @@ public class ItemBlockCrate extends ItemBlock
EntityPlayer player = (EntityPlayer) entity;
ItemStack containingStack = getContainingItemStack(itemStack);
if (containingStack != null)
if (containingStack != null && !player.capabilities.isCreativeMode)
{
player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 5, (int) ((float) containingStack.stackSize / (float) TileEntityCrate.getMaxLimit(itemStack.getItemDamage())) * 5));
}

View file

@ -153,14 +153,11 @@ public class TileEntityCrate extends TileEntityAdvanced implements ITier, IInven
{
if (stack != null)
{
if (stack.isStackable())
{
this.containingItems[slot] = stack;
this.containingItems[slot] = stack;
if (stack != null && stack.stackSize > this.getInventoryStackLimit())
{
stack.stackSize = this.getInventoryStackLimit();
}
if (stack != null && stack.stackSize > this.getInventoryStackLimit())
{
stack.stackSize = this.getInventoryStackLimit();
}
}
else