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.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.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.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) if (containingStack != null)
{ {
int amountToTake = Math.min(containingStack.stackSize, 64); if (containingStack.stackSize > 0)
ItemStack dropStack = containingStack.copy(); {
dropStack.stackSize = amountToTake; 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; float var13 = 0.05F;
entityItem.motionX = ((float) world.rand.nextGaussian() * var13); entityItem.motionX = ((float) world.rand.nextGaussian() * var13);
entityItem.motionY = ((float) world.rand.nextGaussian() * var13 + 0.2F); entityItem.motionY = ((float) world.rand.nextGaussian() * var13 + 0.2F);
entityItem.motionZ = ((float) world.rand.nextGaussian() * var13); entityItem.motionZ = ((float) world.rand.nextGaussian() * var13);
entityItem.delayBeforeCanPickup = 0; entityItem.delayBeforeCanPickup = 0;
world.spawnEntityInWorld(entityItem); world.spawnEntityInWorld(entityItem);
containingStack.stackSize -= amountToTake;
containingStack.stackSize -= amountToTake;
}
if (containingStack.stackSize <= 0) if (containingStack.stackSize <= 0)
{ {
containingStack = null; containingStack = null;

View file

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

View file

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