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

87 lines
2.8 KiB
Diff
Raw Normal View History

2021-03-15 23:00:00 +01:00
--- a/net/minecraft/world/inventory/ContainerLoom.java
+++ b/net/minecraft/world/inventory/ContainerLoom.java
@@ -16,8 +16,30 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.EnumBannerPatternType;
+// 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;
2021-03-15 23:00:00 +01:00
@@ -45,6 +67,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
2021-03-15 23:00:00 +01:00
@@ -52,6 +81,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) {
2021-03-15 23:00:00 +01:00
@@ -112,10 +148,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);
}
2021-03-15 23:00:00 +01:00
@@ -234,6 +272,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);