|
7 | 7 | import org.bukkit.block.ChiseledBookshelf; |
8 | 8 | import org.bukkit.block.Crafter; |
9 | 9 | import org.bukkit.block.Furnace; |
| 10 | +import org.bukkit.block.Smoker; |
| 11 | +import org.bukkit.block.BlastFurnace; |
10 | 12 | import org.bukkit.block.ShulkerBox; |
11 | 13 | import org.bukkit.entity.Player; |
12 | 14 | import org.bukkit.inventory.BrewerInventory; |
@@ -89,12 +91,16 @@ public static List<ItemStack> addItemsToFurnace(Furnace furnace, ItemStack ... s |
89 | 91 | if(!ItemUtil.isStackValid(stack)) |
90 | 92 | continue; |
91 | 93 |
|
92 | | - if (ItemUtil.isFurnacable(stack) && fitsInSlot(stack, furnace.getInventory().getSmelting())) { |
| 94 | + if (((furnace instanceof Smoker && ItemUtil.isCookable(stack)) |
| 95 | + || (furnace instanceof BlastFurnace && ItemUtil.isBlastSmeltable(stack)) |
| 96 | + || (furnace instanceof Furnace && !(furnace instanceof Smoker) |
| 97 | + && !(furnace instanceof BlastFurnace) && ItemUtil.isFurnacable(stack))) |
| 98 | + && fitsPartiallyInSlot(stack, furnace.getInventory().getSmelting())) { |
93 | 99 | if (furnace.getInventory().getSmelting() == null) |
94 | 100 | furnace.getInventory().setSmelting(stack); |
95 | 101 | else |
96 | 102 | leftovers.add(ItemUtil.addToStack(furnace.getInventory().getSmelting(), stack)); |
97 | | - } else if (ItemUtil.isAFuel(stack) && fitsInSlot(stack, furnace.getInventory().getFuel())) { |
| 103 | + } else if (ItemUtil.isAFuel(stack) && fitsPartiallyInSlot(stack, furnace.getInventory().getFuel())) { |
98 | 104 | if (furnace.getInventory().getFuel() == null) |
99 | 105 | furnace.getInventory().setFuel(stack); |
100 | 106 | else |
@@ -123,13 +129,15 @@ public static List<ItemStack> addItemsToBrewingStand(BrewingStand brewingStand, |
123 | 129 |
|
124 | 130 | for(ItemStack stack : stacks) { |
125 | 131 | BrewerInventory inv = brewingStand.getInventory(); |
126 | | - if (ItemUtil.isAPotionIngredient(stack) && InventoryUtil.fitsInSlot(stack, inv.getIngredient())) { |
| 132 | + if (ItemUtil.isAPotionIngredient(stack) |
| 133 | + && InventoryUtil.fitsPartiallyInSlot(stack, inv.getIngredient())) { |
127 | 134 | if (inv.getIngredient() == null) { |
128 | 135 | inv.setIngredient(stack); |
129 | 136 | } else { |
130 | 137 | leftovers.add(ItemUtil.addToStack(inv.getIngredient(), stack)); |
131 | 138 | } |
132 | | - } else if (stack.getType() == Material.BLAZE_POWDER && InventoryUtil.fitsInSlot(stack, inv.getFuel())) { |
| 139 | + } else if (stack.getType() == Material.BLAZE_POWDER |
| 140 | + && InventoryUtil.fitsPartiallyInSlot(stack, inv.getFuel())) { |
133 | 141 | if (inv.getFuel() == null) { |
134 | 142 | inv.setFuel(stack); |
135 | 143 | } else { |
@@ -330,6 +338,18 @@ public static boolean fitsInSlot(ItemStack stack, ItemStack slot) { |
330 | 338 | return slot == null || ItemUtil.areItemsIdentical(stack, slot) && stack.getAmount() + slot.getAmount() <= stack.getMaxStackSize(); |
331 | 339 | } |
332 | 340 |
|
| 341 | + /** |
| 342 | + * Checks whether the itemstack can partially stack onto the other itemstack. |
| 343 | + * |
| 344 | + * @param stack The stack to add. |
| 345 | + * @param slot The base stack. |
| 346 | + * @return whether it can be added or not. |
| 347 | + */ |
| 348 | + public static boolean fitsPartiallyInSlot(ItemStack stack, ItemStack slot) { |
| 349 | + |
| 350 | + return slot == null || (ItemUtil.areItemsIdentical(stack, slot) && slot.getAmount() < stack.getMaxStackSize()); |
| 351 | + } |
| 352 | + |
333 | 353 | /** |
334 | 354 | * Checks whether the block has an inventory. |
335 | 355 | * |
|
0 commit comments