craftbukkit/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch

69 lines
2.3 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/inventory/ContainerStonecutter.java
+++ b/net/minecraft/world/inventory/ContainerStonecutter.java
2024-06-14 01:05:00 +10:00
@@ -17,6 +17,13 @@
2021-03-16 09:00:00 +11:00
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.Blocks;
2021-03-09 08:47:33 +11:00
2019-04-23 12:00:00 +10:00
+// CraftBukkit start
+import org.bukkit.Location;
2019-04-23 12:00:00 +10:00
+import org.bukkit.craftbukkit.inventory.CraftInventoryStonecutter;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+import org.bukkit.entity.Player;
+// CraftBukkit end
2021-03-09 08:47:33 +11:00
+
2019-04-23 12:00:00 +10:00
public class ContainerStonecutter extends Container {
2021-06-11 15:00:00 +10:00
public static final int INPUT_SLOT = 0;
2024-06-14 01:05:00 +10:00
@@ -36,6 +43,21 @@
2021-06-11 15:00:00 +10:00
Runnable slotUpdateListener;
public final IInventory container;
final InventoryCraftResult resultContainer;
2019-04-23 12:00:00 +10:00
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private Player player;
+
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
2021-06-11 15:00:00 +10:00
+ CraftInventoryStonecutter inventory = new CraftInventoryStonecutter(this.container, this.resultContainer);
2019-04-23 12:00:00 +10:00
+ bukkitEntity = new CraftInventoryView(this.player, inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
public ContainerStonecutter(int i, PlayerInventory playerinventory) {
2021-06-11 15:00:00 +10:00
this(i, playerinventory, ContainerAccess.NULL);
2024-06-14 01:05:00 +10:00
@@ -55,6 +77,13 @@
2021-11-22 09:00:00 +11:00
ContainerStonecutter.this.slotsChanged(this);
2021-06-11 15:00:00 +10:00
ContainerStonecutter.this.slotUpdateListener.run();
}
+
+ // CraftBukkit start
+ @Override
+ public Location getLocation() {
+ return containeraccess.getLocation();
+ }
+ // CraftBukkit end
};
2021-06-11 15:00:00 +10:00
this.resultContainer = new InventoryCraftResult();
this.access = containeraccess;
2024-06-14 01:05:00 +10:00
@@ -106,6 +135,7 @@
2019-04-23 12:00:00 +10:00
}
2021-11-22 09:00:00 +11:00
this.addDataSlot(this.selectedRecipeIndex);
2019-04-23 12:00:00 +10:00
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
}
2021-11-22 09:00:00 +11:00
public int getSelectedRecipeIndex() {
2024-06-14 01:05:00 +10:00
@@ -126,6 +156,7 @@
2021-06-11 15:00:00 +10:00
2019-04-23 12:00:00 +10:00
@Override
2021-11-22 09:00:00 +11:00
public boolean stillValid(EntityHuman entityhuman) {
2019-04-23 12:00:00 +10:00
+ if (!this.checkReachable) return true; // CraftBukkit
2021-11-22 09:00:00 +11:00
return stillValid(this.access, entityhuman, Blocks.STONECUTTER);
2019-04-23 12:00:00 +10:00
}