Fixed crates

This commit is contained in:
Henry Mao 2012-12-15 23:29:54 +08:00
parent 481b0d9852
commit 1781a35ae4
5 changed files with 36 additions and 18 deletions

View file

@ -1 +1 @@
22
24

View file

@ -16,4 +16,6 @@ Minecraft 1.4.2
@ AssemblyLine_v0.1.6.19.jar AssemblyLine_v0.1.6.19_api.zip
@ AssemblyLine_v0.1.6.20.jar AssemblyLine_v0.1.6.20_api.zip
@ AssemblyLine_v0.1.6.21.jar AssemblyLine_v0.1.6.21_api.zip
* AssemblyLine_v0.1.6.22.jar AssemblyLine_v0.1.6.22_api.zip
x AssemblyLine_v0.1.6.22.jar AssemblyLine_v0.1.6.22_api.zip
x AssemblyLine_v0.1.6.23.jar AssemblyLine_v0.1.6.23_api.zip
* AssemblyLine_v0.1.6.24.jar AssemblyLine_v0.1.6.24_api.zip

View file

@ -92,21 +92,24 @@ public class BlockCrate extends BlockMachine
if (containingStack != null)
{
int amountToTake = Math.min(containingStack.stackSize, 64);
ItemStack dropStack = containingStack.copy();
dropStack.stackSize = amountToTake;
if (containingStack.stackSize > 0)
{
int amountToTake = Math.min(containingStack.stackSize, 64);
ItemStack dropStack = containingStack.copy();
dropStack.stackSize = amountToTake;
EntityItem entityItem = new EntityItem(world, par5EntityPlayer.posX, par5EntityPlayer.posY, par5EntityPlayer.posZ, dropStack);
EntityItem entityItem = new EntityItem(world, par5EntityPlayer.posX, par5EntityPlayer.posY, par5EntityPlayer.posZ, dropStack);
float var13 = 0.05F;
entityItem.motionX = ((float) world.rand.nextGaussian() * var13);
entityItem.motionY = ((float) world.rand.nextGaussian() * var13 + 0.2F);
entityItem.motionZ = ((float) world.rand.nextGaussian() * var13);
entityItem.delayBeforeCanPickup = 0;
world.spawnEntityInWorld(entityItem);
containingStack.stackSize -= amountToTake;
float var13 = 0.05F;
entityItem.motionX = ((float) world.rand.nextGaussian() * var13);
entityItem.motionY = ((float) world.rand.nextGaussian() * var13 + 0.2F);
entityItem.motionZ = ((float) world.rand.nextGaussian() * var13);
entityItem.delayBeforeCanPickup = 0;
world.spawnEntityInWorld(entityItem);
containingStack.stackSize -= amountToTake;
}
if (containingStack.stackSize <= 0)
{
containingStack = null;

View file

@ -123,11 +123,21 @@ public class TileEntityCrate extends TileEntityAdvanced implements ISidedInvento
@Override
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
{
this.containingItems[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
if (par2ItemStack != null)
{
par2ItemStack.stackSize = this.getInventoryStackLimit();
if (par2ItemStack.isStackable())
{
this.containingItems[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{
par2ItemStack.stackSize = this.getInventoryStackLimit();
}
}
}
else
{
this.containingItems[par1] = null;
}
if (!this.worldObj.isRemote)

View file

@ -276,10 +276,13 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver impleme
if (stackInInventory == null)
{
inventory.setInventorySlotContents(slotIndex, itemStack);
if (inventory.getStackInSlot(slotIndex) == null) { return itemStack; }
return null;
}
else if (stackInInventory.isItemEqual(itemStack))
{
stackInInventory = stackInInventory.copy();
int rejectedAmount = Math.max((stackInInventory.stackSize + itemStack.stackSize) - stackInInventory.getItem().getItemStackLimit(), 0);
stackInInventory.stackSize = Math.min(Math.max((stackInInventory.stackSize + itemStack.stackSize - rejectedAmount), 0), stackInInventory.getItem().getItemStackLimit());
itemStack.stackSize = rejectedAmount;