diff --git a/common/mekanism/common/BinRecipe.java b/common/mekanism/common/BinRecipe.java index 57dfaebf5..3e0b4625d 100644 --- a/common/mekanism/common/BinRecipe.java +++ b/common/mekanism/common/BinRecipe.java @@ -37,6 +37,11 @@ public class BinRecipe implements IRecipe, ICraftingHandler @Override public ItemStack getCraftingResult(InventoryCrafting inv) + { + return getResult(inv); + } + + public ItemStack getResult(IInventory inv) { ItemStack bin = null; @@ -60,7 +65,6 @@ public class BinRecipe implements IRecipe, ICraftingHandler return null; } - int slotLoc = -1; ItemStack addStack = null; for(int i = 0; i < 9; i++) @@ -75,7 +79,6 @@ public class BinRecipe implements IRecipe, ICraftingHandler } addStack = stack.copy(); - slotLoc = i; } } @@ -88,7 +91,7 @@ public class BinRecipe implements IRecipe, ICraftingHandler return null; } - ItemStack remain = binInv.add(addStack); + binInv.add(addStack); return bin; } @@ -112,28 +115,57 @@ public class BinRecipe implements IRecipe, ICraftingHandler @Override public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix) { - if(getCraftingResult((InventoryCrafting)craftMatrix) != null) + if(getResult(craftMatrix) != null) { - for(int i = 0; i < craftMatrix.getSizeInventory(); i++) + if(!isBin(item)) { - if(!isBin(item) && isBin(craftMatrix.getStackInSlot(i))) + for(int i = 0; i < craftMatrix.getSizeInventory(); i++) { - ItemStack bin = craftMatrix.getStackInSlot(i); - InventoryBin inv = new InventoryBin(bin); - - bin.stackTagCompound.setInteger("newCount", inv.getItemCount()-item.stackSize); + if(isBin(craftMatrix.getStackInSlot(i))) + { + ItemStack bin = craftMatrix.getStackInSlot(i); + InventoryBin inv = new InventoryBin(bin.copy()); + + int size = inv.getItemCount(); + + ItemStack testRemove = inv.removeStack(); + + bin.stackTagCompound.setInteger("newCount", size-(testRemove != null ? testRemove.stackSize : 0)); + } } - else if(isBin(item) && craftMatrix.getStackInSlot(i) != null && !isBin(craftMatrix.getStackInSlot(i))) + } + else { + int bin = -1; + int other = -1; + + for(int i = 0; i < craftMatrix.getSizeInventory(); i++) + { + if(isBin(craftMatrix.getStackInSlot(i))) + { + bin = i; + } + else if(!isBin(craftMatrix.getStackInSlot(i)) && craftMatrix.getStackInSlot(i) != null) + { + other = i; + } + } + + ItemStack binStack = craftMatrix.getStackInSlot(bin); + ItemStack otherStack = craftMatrix.getStackInSlot(other); + + ItemStack testRemain = new InventoryBin(binStack.copy()).add(otherStack.copy()); + + if(testRemain != null && testRemain.stackSize > 0) { ItemStack proxy = new ItemStack(Mekanism.ItemProxy); - ((ItemProxy)proxy.getItem()).setSavedItem(proxy, craftMatrix.getStackInSlot(i)); - - craftMatrix.setInventorySlotContents(i, proxy); + ((ItemProxy)proxy.getItem()).setSavedItem(proxy, testRemain.copy()); + craftMatrix.setInventorySlotContents(other, proxy); } - else if(isBin(item) && isBin(craftMatrix.getStackInSlot(i))) - { - craftMatrix.setInventorySlotContents(i, null); + else { + craftMatrix.setInventorySlotContents(other, null); } + + craftMatrix.setInventorySlotContents(bin, null); } } } diff --git a/common/mekanism/common/block/BlockBasic.java b/common/mekanism/common/block/BlockBasic.java index 799e234bf..eab09a921 100644 --- a/common/mekanism/common/block/BlockBasic.java +++ b/common/mekanism/common/block/BlockBasic.java @@ -218,6 +218,18 @@ public class BlockBasic extends Block if(filled != null) { + if(player.capabilities.isCreativeMode) + { + tileEntity.structure.fluidStored.amount -= FluidContainerRegistry.getFluidForFilledItem(filled).amount; + + if(tileEntity.structure.fluidStored.amount == 0) + { + tileEntity.structure.fluidStored = null; + } + + return true; + } + if(itemStack.stackSize > 1) { for(int i = 0; i < player.inventory.mainInventory.length; i++) diff --git a/common/mekanism/common/inventory/InventoryBin.java b/common/mekanism/common/inventory/InventoryBin.java index c2bad144a..c30c1adc3 100644 --- a/common/mekanism/common/inventory/InventoryBin.java +++ b/common/mekanism/common/inventory/InventoryBin.java @@ -88,6 +88,12 @@ public class InventoryBin int id = bin.stackTagCompound.getInteger("itemID"); int meta = bin.stackTagCompound.getInteger("itemMeta"); + if(getItemCount() == 0 || id == 0) + { + setItemType(null); + return null; + } + return new ItemStack(id, 1, meta); } diff --git a/common/mekanism/common/item/ItemBlockBasic.java b/common/mekanism/common/item/ItemBlockBasic.java index 5ae871b0b..56328cb77 100644 --- a/common/mekanism/common/item/ItemBlockBasic.java +++ b/common/mekanism/common/item/ItemBlockBasic.java @@ -75,21 +75,15 @@ public class ItemBlockBasic extends ItemBlock { if(itemstack.getItemDamage() == 6) { - if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) + InventoryBin inv = new InventoryBin(itemstack); + + if(inv.getItemCount() > 0) { - list.add("Hold " + EnumColor.AQUA + "shift" + EnumColor.GREY + " for more details."); + list.add(EnumColor.BRIGHT_GREEN + inv.getItemType().getDisplayName()); + list.add(EnumColor.INDIGO + "Item amount: " + EnumColor.GREY + inv.getItemCount()); } else { - InventoryBin inv = new InventoryBin(itemstack); - - if(inv.getItemCount() > 0) - { - list.add(EnumColor.BRIGHT_GREEN + inv.getItemType().getDisplayName()); - list.add(EnumColor.INDIGO + "Item amount: " + EnumColor.GREY + inv.getItemCount()); - } - else { - list.add(EnumColor.DARK_RED + "Empty"); - } + list.add(EnumColor.DARK_RED + "Empty"); } } } @@ -108,7 +102,7 @@ public class ItemBlockBasic extends ItemBlock return true; } - if(stack.stackTagCompound == null || !stack.stackTagCompound.hasKey("newCount") || stack.stackTagCompound.getInteger("newCount") == 0) + if(stack.stackTagCompound == null || !stack.stackTagCompound.hasKey("newCount")) { return true; }