PaperMC/nms-patches/ContainerCartography.patch

60 lines
1.9 KiB
Diff
Raw Normal View History

2019-04-23 04:00:00 +02:00
--- a/net/minecraft/server/ContainerCartography.java
+++ b/net/minecraft/server/ContainerCartography.java
@@ -1,7 +1,29 @@
package net.minecraft.server;
+// 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;
+ }
+
2019-05-14 02:00:00 +02:00
+ CraftInventoryCartography inventory = new CraftInventoryCartography(this.inventory, this.resultInventory);
2019-04-23 04:00:00 +02:00
+ bukkitEntity = new CraftInventoryView(this.player, inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
private final ContainerAccess containerAccess;
private boolean e;
2019-12-10 23:00:00 +01:00
private long f;
@@ -27,6 +49,13 @@
2019-04-23 04:00:00 +02:00
ContainerCartography.this.a((IInventory) this);
super.update();
}
+
+ // CraftBukkit start
+ @Override
+ public Location getLocation() {
+ return containeraccess.getLocation();
+ }
+ // CraftBukkit end
};
this.containerAccess = containeraccess;
this.a(new Slot(this.inventory, 0, 15, 15) {
2019-12-10 23:00:00 +01:00
@@ -104,10 +133,12 @@
2019-04-23 04:00:00 +02:00
this.a(new Slot(playerinventory, j, 8 + j * 18, 142));
}
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
}
@Override
public boolean canUse(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return a(this.containerAccess, entityhuman, Blocks.CARTOGRAPHY_TABLE);
}