Paper/paper-server/nms-patches/net/minecraft/world/inventory/ContainerCartography.patch

75 lines
2.5 KiB
Diff
Raw Normal View History

2021-03-15 23:00:00 +01:00
--- a/net/minecraft/world/inventory/ContainerCartography.java
+++ b/net/minecraft/world/inventory/ContainerCartography.java
@@ -12,8 +12,30 @@
2021-03-15 23:00:00 +01:00
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.saveddata.maps.WorldMap;
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.inventory.CraftInventoryCartography;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+import org.bukkit.entity.Player;
+// CraftBukkit end
+
public class ContainerCartography extends Container {
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private Player player;
+
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ CraftInventoryCartography inventory = new CraftInventoryCartography(this.container, this.resultContainer);
+ bukkitEntity = new CraftInventoryView(this.player, inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
public static final int MAP_SLOT = 0;
public static final int ADDITIONAL_SLOT = 1;
public static final int RESULT_SLOT = 2;
@@ -38,6 +60,13 @@
ContainerCartography.this.slotsChanged(this);
super.setChanged();
}
+
+ // CraftBukkit start
+ @Override
+ public Location getLocation() {
+ return containeraccess.getLocation();
+ }
+ // CraftBukkit end
};
this.resultContainer = new InventoryCraftResult() {
@Override
@@ -45,6 +74,13 @@
ContainerCartography.this.slotsChanged(this);
super.setChanged();
}
+
+ // CraftBukkit start
+ @Override
+ public Location getLocation() {
+ return containeraccess.getLocation();
+ }
+ // CraftBukkit end
};
this.access = containeraccess;
this.addSlot(new Slot(this.container, 0, 15, 15) {
@@ -95,10 +131,12 @@
this.addSlot(new Slot(playerinventory, j, 8 + j * 18, 142));
}
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
}
@Override
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return stillValid(this.access, entityhuman, Blocks.CARTOGRAPHY_TABLE);
}