1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00
into cleanup/blockplacing

Conflicts:
	CHANGELOG.md
This commit is contained in:
TheBusyBiscuit 2020-08-03 17:28:17 +02:00
commit 012a0a7df9
3 changed files with 24 additions and 4 deletions

View File

@ -25,6 +25,7 @@
#### Additions
* Added an option for Industrial Miners to mine Ancient Debris
* (API) Added support for adding custom Piglin Barter drops
* (API) Added BlockPlacerPlaceEvent
* (API) Added ToolUseHandler
@ -40,6 +41,7 @@
* Fixed #2179
* Fixed Reinforced Spawners not working sometimes
* Fixed Explosive Pickaxe not handling normal Shulker boxes correctly
* Fixed #2103
## Release Candidate 15 (01 Aug 2020)

View File

@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
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.PlayerProfile;
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.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 {
public BackpackCrafter(Category category, SlimefunItemStack item, ItemStack[] recipe, BlockFace trigger) {
BackpackCrafter(Category category, SlimefunItemStack item, ItemStack[] recipe, BlockFace trigger) {
super(category, item, recipe, trigger);
}
@ -34,7 +44,15 @@ abstract class BackpackCrafter extends MultiBlockMachine {
Inventory fakeInv = Bukkit.createInventory(null, 9, "Fake Inventory");
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);
}
@ -91,7 +109,6 @@ abstract class BackpackCrafter extends MultiBlockMachine {
PlayerProfile.fromUUID(UUID.fromString(idSplit[0]), profile -> {
Optional<PlayerBackpack> optional = profile.getBackpack(Integer.parseInt(idSplit[1]));
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++) {
if (isCraftable(inv, inputs.get(i))) {
ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
if (Slimefun.hasUnlocked(p, output, true)) {
craft(inv, dispenser, p, b, output);
}