Paper/nms-patches/ContainerLoom.patch

86 lines
2.7 KiB
Diff
Raw Normal View History

2019-04-23 04:00:00 +02:00
--- 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;
2019-12-10 23:00:00 +01:00
@@ -29,6 +51,13 @@
2019-04-23 04:00:00 +02:00
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
2019-12-10 23:00:00 +01:00
@@ -36,6 +65,13 @@
2019-04-23 04:00:00 +02:00
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) {
2019-12-10 23:00:00 +01:00
@@ -96,10 +132,12 @@
2019-04-23 04:00:00 +02:00
}
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);
}
2019-12-10 23:00:00 +01:00
@@ -218,6 +256,11 @@
2019-04-23 04:00:00 +02:00
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);