craftbukkit/nms-patches/net/minecraft/world/inventory/ContainerLoom.patch

90 lines
3 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/inventory/ContainerLoom.java
+++ b/net/minecraft/world/inventory/ContainerLoom.java
2021-11-22 09:00:00 +11:00
@@ -18,8 +18,30 @@
2021-03-16 09:00:00 +11:00
import net.minecraft.world.level.block.entity.EnumBannerPatternType;
2021-11-22 09:00:00 +11:00
import net.minecraft.world.level.block.entity.TileEntityTypes;
2019-04-23 12:00:00 +10:00
+// 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;
+ }
+
2021-06-11 15:00:00 +10:00
+ CraftInventoryLoom inventory = new CraftInventoryLoom(this.inputContainer, this.outputContainer);
2019-04-23 12:00:00 +10:00
+ bukkitEntity = new CraftInventoryView(this.player, inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
2021-06-11 15:00:00 +10:00
private static final int INV_SLOT_START = 4;
private static final int INV_SLOT_END = 31;
private static final int USE_ROW_SLOT_START = 31;
2021-11-22 09:00:00 +11:00
@@ -51,6 +73,13 @@
ContainerLoom.this.slotsChanged(this);
2021-06-11 15:00:00 +10:00
ContainerLoom.this.slotUpdateListener.run();
2019-04-23 12:00:00 +10:00
}
+
+ // CraftBukkit start
+ @Override
+ public Location getLocation() {
+ return containeraccess.getLocation();
+ }
+ // CraftBukkit end
};
2021-06-11 15:00:00 +10:00
this.outputContainer = new InventorySubcontainer(1) {
2019-04-23 12:00:00 +10:00
@Override
2021-11-22 09:00:00 +11:00
@@ -58,6 +87,13 @@
super.setChanged();
2021-06-11 15:00:00 +10:00
ContainerLoom.this.slotUpdateListener.run();
2019-04-23 12:00:00 +10:00
}
+
+ // CraftBukkit start
+ @Override
+ public Location getLocation() {
+ return containeraccess.getLocation();
+ }
+ // CraftBukkit end
};
2021-06-11 15:00:00 +10:00
this.access = containeraccess;
2021-11-22 09:00:00 +11:00
this.bannerSlot = this.addSlot(new Slot(this.inputContainer, 0, 13, 26) {
@@ -118,6 +154,7 @@
2019-04-23 12:00:00 +10:00
}
2021-11-22 09:00:00 +11:00
this.addDataSlot(this.selectedBannerPatternIndex);
2019-04-23 12:00:00 +10:00
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
}
2021-11-22 09:00:00 +11:00
public int getSelectedBannerPatternIndex() {
@@ -126,6 +163,7 @@
2021-06-11 15:00:00 +10:00
2019-04-23 12:00:00 +10:00
@Override
2021-11-22 09:00:00 +11:00
public boolean stillValid(EntityHuman entityhuman) {
2019-04-23 12:00:00 +10:00
+ if (!this.checkReachable) return true; // CraftBukkit
2021-11-22 09:00:00 +11:00
return stillValid(this.access, entityhuman, Blocks.LOOM);
2019-04-23 12:00:00 +10:00
}
2021-11-22 09:00:00 +11:00
@@ -248,6 +286,11 @@
2019-04-23 12:00:00 +10:00
2021-11-22 09:00:00 +11:00
if (nbttagcompound != null && nbttagcompound.contains("Patterns", 9)) {
2019-04-23 12:00:00 +10:00
nbttaglist = nbttagcompound.getList("Patterns", 10);
+ // CraftBukkit start
+ while (nbttaglist.size() > 20) {
+ nbttaglist.remove(20);
+ }
+ // CraftBukkit end
} else {
nbttaglist = new NBTTagList();
2021-11-22 09:00:00 +11:00
if (nbttagcompound == null) {