1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00
This commit is contained in:
TheBusyBiscuit 2020-08-03 17:25:27 +02:00
parent 6dd2129dfe
commit d8f5992282
3 changed files with 23 additions and 4 deletions

View File

@ -32,6 +32,7 @@
#### Fixes #### Fixes
* Fixed Programmable Androids rotating in the wrong direction * Fixed Programmable Androids rotating in the wrong direction
* Fixed #2176 * Fixed #2176
* Fixed #2103
## Release Candidate 15 (01 Aug 2020) ## Release Candidate 15 (01 Aug 2020)

View File

@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors; import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack; import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
@ -24,9 +24,19 @@ import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
/**
* This abstract super class is responsible for some utility methods for machines which
* are capable of upgrading backpacks.
*
* @author TheBusyBiscuit
*
* @see EnhancedCraftingTable
* @see MagicWorkbench
*
*/
abstract class BackpackCrafter extends MultiBlockMachine { abstract class BackpackCrafter extends MultiBlockMachine {
public BackpackCrafter(Category category, SlimefunItemStack item, ItemStack[] recipe, BlockFace trigger) { BackpackCrafter(Category category, SlimefunItemStack item, ItemStack[] recipe, BlockFace trigger) {
super(category, item, recipe, trigger); super(category, item, recipe, trigger);
} }
@ -34,7 +44,15 @@ abstract class BackpackCrafter extends MultiBlockMachine {
Inventory fakeInv = Bukkit.createInventory(null, 9, "Fake Inventory"); Inventory fakeInv = Bukkit.createInventory(null, 9, "Fake Inventory");
for (int j = 0; j < inv.getContents().length; j++) { for (int j = 0; j < inv.getContents().length; j++) {
ItemStack stack = inv.getContents()[j] != null && inv.getContents()[j].getAmount() > 1 ? new CustomItem(inv.getContents()[j], inv.getContents()[j].getAmount() - 1) : null; ItemStack stack = inv.getContents()[j];
// Fixes #2103 - Properly simulating the consumption
// (which may leave behind empty buckets or glass bottles)
if (stack != null) {
stack = stack.clone();
ItemUtils.consumeItem(stack, true);
}
fakeInv.setItem(j, stack); fakeInv.setItem(j, stack);
} }
@ -91,7 +109,6 @@ abstract class BackpackCrafter extends MultiBlockMachine {
PlayerProfile.fromUUID(UUID.fromString(idSplit[0]), profile -> { PlayerProfile.fromUUID(UUID.fromString(idSplit[0]), profile -> {
Optional<PlayerBackpack> optional = profile.getBackpack(Integer.parseInt(idSplit[1])); Optional<PlayerBackpack> optional = profile.getBackpack(Integer.parseInt(idSplit[1]));
optional.ifPresent(playerBackpack -> playerBackpack.setSize(size)); optional.ifPresent(playerBackpack -> playerBackpack.setSize(size));
}); });

View File

@ -43,6 +43,7 @@ public class EnhancedCraftingTable extends BackpackCrafter {
for (int i = 0; i < inputs.size(); i++) { for (int i = 0; i < inputs.size(); i++) {
if (isCraftable(inv, inputs.get(i))) { if (isCraftable(inv, inputs.get(i))) {
ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone(); ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
if (Slimefun.hasUnlocked(p, output, true)) { if (Slimefun.hasUnlocked(p, output, true)) {
craft(inv, dispenser, p, b, output); craft(inv, dispenser, p, b, output);
} }