2023-06-07 17:30:00 +02:00
|
|
|
--- a/net/minecraft/world/inventory/TransientCraftingContainer.java
|
|
|
|
+++ b/net/minecraft/world/inventory/TransientCraftingContainer.java
|
|
|
|
@@ -8,6 +8,16 @@
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.entity.player.EntityHuman;
|
|
|
|
import net.minecraft.world.item.ItemStack;
|
2021-03-08 22:47:33 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+// CraftBukkit start
|
|
|
|
+import java.util.List;
|
2023-06-07 17:30:00 +02:00
|
|
|
+import net.minecraft.world.IInventory;
|
2023-09-21 18:40:00 +02:00
|
|
|
+import net.minecraft.world.item.crafting.RecipeHolder;
|
2016-02-29 22:32:46 +01:00
|
|
|
+import org.bukkit.Location;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
|
|
+import org.bukkit.entity.HumanEntity;
|
|
|
|
+import org.bukkit.event.inventory.InventoryType;
|
|
|
|
+// CraftBukkit end
|
2021-03-08 22:47:33 +01:00
|
|
|
+
|
2023-06-07 17:30:00 +02:00
|
|
|
public class TransientCraftingContainer implements InventoryCrafting {
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2021-03-08 22:47:33 +01:00
|
|
|
private final NonNullList<ItemStack> items;
|
2023-06-07 17:30:00 +02:00
|
|
|
@@ -15,6 +25,68 @@
|
2021-06-11 07:00:00 +02:00
|
|
|
private final int height;
|
2023-06-07 17:30:00 +02:00
|
|
|
private final Container menu;
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - add fields
|
|
|
|
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
2023-09-21 18:40:00 +02:00
|
|
|
+ private RecipeHolder<?> currentRecipe;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ public IInventory resultInventory;
|
|
|
|
+ private EntityHuman owner;
|
|
|
|
+ private int maxStack = MAX_STACK;
|
|
|
|
+
|
2016-11-17 02:41:03 +01:00
|
|
|
+ public List<ItemStack> getContents() {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ return this.items;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void onOpen(CraftHumanEntity who) {
|
|
|
|
+ transaction.add(who);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public InventoryType getInvType() {
|
2016-11-17 02:41:03 +01:00
|
|
|
+ return items.size() == 4 ? InventoryType.CRAFTING : InventoryType.WORKBENCH;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void onClose(CraftHumanEntity who) {
|
|
|
|
+ transaction.remove(who);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<HumanEntity> getViewers() {
|
|
|
|
+ return transaction;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public org.bukkit.inventory.InventoryHolder getOwner() {
|
2015-05-21 08:56:58 +02:00
|
|
|
+ return (owner == null) ? null : owner.getBukkitEntity();
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
+ @Override
|
|
|
|
+ public int getMaxStackSize() {
|
|
|
|
+ return maxStack;
|
|
|
|
+ }
|
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ public void setMaxStackSize(int size) {
|
|
|
|
+ maxStack = size;
|
|
|
|
+ resultInventory.setMaxStackSize(size);
|
|
|
|
+ }
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ @Override
|
|
|
|
+ public Location getLocation() {
|
2021-06-11 07:00:00 +02:00
|
|
|
+ return menu instanceof ContainerWorkbench ? ((ContainerWorkbench) menu).access.getLocation() : owner.getBukkitEntity().getLocation();
|
2016-02-29 22:32:46 +01:00
|
|
|
+ }
|
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
+ @Override
|
2023-09-21 18:40:00 +02:00
|
|
|
+ public RecipeHolder<?> getCurrentRecipe() {
|
2018-07-15 02:00:00 +02:00
|
|
|
+ return currentRecipe;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2023-09-21 18:40:00 +02:00
|
|
|
+ public void setCurrentRecipe(RecipeHolder<?> currentRecipe) {
|
2018-07-15 02:00:00 +02:00
|
|
|
+ this.currentRecipe = currentRecipe;
|
|
|
|
+ }
|
|
|
|
+
|
2023-06-07 17:30:00 +02:00
|
|
|
+ public TransientCraftingContainer(Container container, int i, int j, EntityHuman player) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this(container, i, j);
|
|
|
|
+ this.owner = player;
|
|
|
|
+ }
|
2015-02-26 23:41:06 +01:00
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
2023-06-07 17:30:00 +02:00
|
|
|
public TransientCraftingContainer(Container container, int i, int j) {
|
|
|
|
this(container, i, j, NonNullList.withSize(i * j, ItemStack.EMPTY));
|
|
|
|
}
|