edited crate item interaction behavior

It wasn't really checking if the item it was interacting with was a
crate, null, or unstackable before trying to insert or eject.
This commit is contained in:
Robert Seifert 2013-04-21 02:07:19 -04:00
parent 1b26c2f407
commit 2d27765897

View file

@ -29,6 +29,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class BlockCrate extends BlockALMachine public class BlockCrate extends BlockALMachine
{ {
Icon crate_icon; Icon crate_icon;
public BlockCrate(int id, int texture) public BlockCrate(int id, int texture)
{ {
super(id, UniversalElectricity.machine); super(id, UniversalElectricity.machine);
@ -40,7 +41,7 @@ public class BlockCrate extends BlockALMachine
@Override @Override
public void registerIcons(IconRegister iconReg) public void registerIcons(IconRegister iconReg)
{ {
this.crate_icon = iconReg.registerIcon(AssemblyLine.TEXTURE_NAME_PREFIX+"crate"); this.crate_icon = iconReg.registerIcon(AssemblyLine.TEXTURE_NAME_PREFIX + "crate");
} }
@Override @Override
@ -109,17 +110,22 @@ public class BlockCrate extends BlockALMachine
} }
tileEntity.prevClickTime = world.getWorldTime(); tileEntity.prevClickTime = world.getWorldTime();
ItemStack current = entityPlayer.inventory.getCurrentItem();
// Add items // Add items
if (side == 1 || (side > 1 && hitY > 0.5) || !entityPlayer.capabilities.isCreativeMode) if (side == 1 || (side > 1 && hitY > 0.5) || !entityPlayer.capabilities.isCreativeMode)
{
if (current != null && current.getMaxStackSize() > 1 && current.itemID != this.blockID)
{ {
this.tryInsert(tileEntity, entityPlayer, allMode); this.tryInsert(tileEntity, entityPlayer, allMode);
} }
}
// Remove items // Remove items
else if (side == 0 || (side > 1 && hitY <= 0.5)) else if (side == 0 || (side > 1 && hitY <= 0.5))
{ {
this.tryEject(tileEntity, entityPlayer, allMode); this.tryEject(tileEntity, entityPlayer, allMode);
} }
} }
} }