3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-21 14:00:11 +01:00
Paper/nms-patches/ContainerLoom.patch
2019-04-23 12:00:00 +10:00

86 Zeilen
2.7 KiB
Diff

--- a/net/minecraft/server/ContainerLoom.java
+++ b/net/minecraft/server/ContainerLoom.java
@@ -1,7 +1,29 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.inventory.CraftInventoryLoom;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+import org.bukkit.entity.Player;
+// CraftBukkit end
+
public class ContainerLoom extends Container {
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private Player player;
+
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ CraftInventoryLoom inventory = new CraftInventoryLoom(this.craftInventory, this.resultInventory);
+ bukkitEntity = new CraftInventoryView(this.player, inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
private final ContainerAccess containerAccess;
private final ContainerProperty d;
private Runnable e;
@@ -28,6 +50,13 @@
ContainerLoom.this.a((IInventory) this);
ContainerLoom.this.e.run();
}
+
+ // CraftBukkit start
+ @Override
+ public Location getLocation() {
+ return containeraccess.getLocation();
+ }
+ // CraftBukkit end
};
this.resultInventory = new InventorySubcontainer(1) {
@Override
@@ -35,6 +64,13 @@
super.update();
ContainerLoom.this.e.run();
}
+
+ // CraftBukkit start
+ @Override
+ public Location getLocation() {
+ return containeraccess.getLocation();
+ }
+ // CraftBukkit end
};
this.containerAccess = containeraccess;
this.f = this.a(new Slot(this.craftInventory, 0, 13, 26) {
@@ -89,10 +125,12 @@
}
this.a(this.d);
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
}
@Override
public boolean canUse(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return a(this.containerAccess, entityhuman, Blocks.LOOM);
}
@@ -211,6 +249,11 @@
if (nbttagcompound.hasKeyOfType("Patterns", 9)) {
nbttaglist = nbttagcompound.getList("Patterns", 10);
+ // CraftBukkit start
+ while (nbttaglist.size() > 20) {
+ nbttaglist.remove(20);
+ }
+ // CraftBukkit end
} else {
nbttaglist = new NBTTagList();
nbttagcompound.set("Patterns", nbttaglist);