CraftBukkit/nms-patches/net/minecraft/world/inventory/ContainerBrewingStand.patch
2024-12-04 03:20:00 +11:00

60 lines
2.1 KiB
Diff

--- a/net/minecraft/world/inventory/ContainerBrewingStand.java
+++ b/net/minecraft/world/inventory/ContainerBrewingStand.java
@@ -17,6 +17,11 @@
import net.minecraft.world.item.alchemy.PotionContents;
import net.minecraft.world.item.alchemy.PotionRegistry;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventoryBrewer;
+import org.bukkit.craftbukkit.inventory.view.CraftBrewingStandView;
+// CraftBukkit end
+
public class ContainerBrewingStand extends Container {
static final MinecraftKey EMPTY_SLOT_FUEL = MinecraftKey.withDefaultNamespace("container/slot/brewing_fuel");
@@ -35,12 +40,18 @@
private final IContainerProperties brewingStandData;
private final Slot ingredientSlot;
+ // CraftBukkit start
+ private CraftBrewingStandView bukkitEntity = null;
+ private PlayerInventory player;
+ // CraftBukkit end
+
public ContainerBrewingStand(int i, PlayerInventory playerinventory) {
this(i, playerinventory, new InventorySubcontainer(5), new ContainerProperties(2));
}
public ContainerBrewingStand(int i, PlayerInventory playerinventory, IInventory iinventory, IContainerProperties icontainerproperties) {
super(Containers.BREWING_STAND, i);
+ player = playerinventory; // CraftBukkit
checkContainerSize(iinventory, 5);
checkContainerDataCount(icontainerproperties, 2);
this.brewingStand = iinventory;
@@ -58,6 +69,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.brewingStand.stillValid(entityhuman);
}
@@ -198,4 +210,17 @@
return ContainerBrewingStand.EMPTY_SLOT_FUEL;
}
}
+
+ // CraftBukkit start
+ @Override
+ public CraftBrewingStandView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ CraftInventoryBrewer inventory = new CraftInventoryBrewer(this.brewingStand);
+ bukkitEntity = new CraftBrewingStandView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
}