--- a/net/minecraft/world/inventory/ContainerLoom.java +++ b/net/minecraft/world/inventory/ContainerLoom.java @@ -23,8 +23,30 @@ import net.minecraft.world.level.block.entity.BannerPatternLayers; 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.inputContainer, this.outputContainer); + bukkitEntity = new CraftInventoryView(this.player, inventory, this); + return bukkitEntity; + } + // CraftBukkit end private static final int PATTERN_NOT_SET = -1; private static final int INV_SLOT_START = 4; private static final int INV_SLOT_END = 31; @@ -60,6 +82,13 @@ ContainerLoom.this.slotsChanged(this); ContainerLoom.this.slotUpdateListener.run(); } + + // CraftBukkit start + @Override + public Location getLocation() { + return containeraccess.getLocation(); + } + // CraftBukkit end }; this.outputContainer = new InventorySubcontainer(1) { @Override @@ -67,21 +96,28 @@ super.setChanged(); ContainerLoom.this.slotUpdateListener.run(); } + + // CraftBukkit start + @Override + public Location getLocation() { + return containeraccess.getLocation(); + } + // CraftBukkit end }; this.access = containeraccess; - this.bannerSlot = this.addSlot(new Slot(this, this.inputContainer, 0, 13, 26) { + this.bannerSlot = this.addSlot(new Slot(this.inputContainer, 0, 13, 26) { // CraftBukkit - decompile error @Override public boolean mayPlace(ItemStack itemstack) { return itemstack.getItem() instanceof ItemBanner; } }); - this.dyeSlot = this.addSlot(new Slot(this, this.inputContainer, 1, 33, 26) { + this.dyeSlot = this.addSlot(new Slot(this.inputContainer, 1, 33, 26) { // CraftBukkit - decompile error @Override public boolean mayPlace(ItemStack itemstack) { return itemstack.getItem() instanceof ItemDye; } }); - this.patternSlot = this.addSlot(new Slot(this, this.inputContainer, 2, 23, 45) { + this.patternSlot = this.addSlot(new Slot(this.inputContainer, 2, 23, 45) { // CraftBukkit - decompile error @Override public boolean mayPlace(ItemStack itemstack) { return itemstack.getItem() instanceof ItemBannerPattern; @@ -128,10 +164,12 @@ this.addDataSlot(this.selectedBannerPatternIndex); this.patternGetter = playerinventory.player.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN); + player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit } @Override public boolean stillValid(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit return stillValid(this.access, entityhuman, Blocks.LOOM); } @@ -306,6 +344,11 @@ EnumColor enumcolor = ((ItemDye) itemstack1.getItem()).getDyeColor(); itemstack2.update(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY, (bannerpatternlayers) -> { + // CraftBukkit start + if (bannerpatternlayers.layers().size() > 20) { + bannerpatternlayers = new BannerPatternLayers(List.copyOf(bannerpatternlayers.layers().subList(0, 20))); + } + // CraftBukkit end return (new BannerPatternLayers.a()).addAll(bannerpatternlayers).add(holder, enumcolor).build(); }); }