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

105 lines
4.2 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
2024-04-24 01:15:00 +10:00
@@ -23,8 +23,30 @@
import net.minecraft.world.level.block.entity.BannerPatternLayers;
2021-03-16 09:00:00 +11:00
import net.minecraft.world.level.block.entity.EnumBannerPatternType;
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.view.CraftLoomView;
2019-04-23 12:00:00 +10:00
+import org.bukkit.entity.Player;
+// CraftBukkit end
+
public class ContainerLoom extends Container {
+ // CraftBukkit start
+ private CraftLoomView bukkitEntity = null;
2019-04-23 12:00:00 +10:00
+ private Player player;
+
+ @Override
+ public CraftLoomView getBukkitView() {
2019-04-23 12:00:00 +10:00
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
2021-06-11 15:00:00 +10:00
+ CraftInventoryLoom inventory = new CraftInventoryLoom(this.inputContainer, this.outputContainer);
+ bukkitEntity = new CraftLoomView(this.player, inventory, this);
2019-04-23 12:00:00 +10:00
+ return bukkitEntity;
+ }
+ // CraftBukkit end
2022-06-08 02:00:00 +10:00
private static final int PATTERN_NOT_SET = -1;
2021-06-11 15:00:00 +10:00
private static final int INV_SLOT_START = 4;
private static final int INV_SLOT_END = 31;
2022-06-08 02:00:00 +10:00
@@ -60,6 +82,13 @@
2021-11-22 09:00:00 +11:00
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
2024-04-24 01:15:00 +10:00
@@ -67,21 +96,28 @@
2021-11-22 09:00:00 +11:00
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;
2024-04-24 01:15:00 +10:00
- 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 @@
2019-04-23 12:00:00 +10:00
2021-11-22 09:00:00 +11:00
this.addDataSlot(this.selectedBannerPatternIndex);
2024-04-24 01:15:00 +10:00
this.patternGetter = playerinventory.player.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN);
2019-04-23 12:00:00 +10:00
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
}
@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
}
2024-04-24 01:15:00 +10:00
@@ -306,6 +344,11 @@
EnumColor enumcolor = ((ItemDye) itemstack1.getItem()).getDyeColor();
2019-04-23 12:00:00 +10:00
2024-04-24 01:15:00 +10:00
itemstack2.update(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY, (bannerpatternlayers) -> {
2022-06-08 02:00:00 +10:00
+ // CraftBukkit start
2024-04-24 01:15:00 +10:00
+ if (bannerpatternlayers.layers().size() > 20) {
+ bannerpatternlayers = new BannerPatternLayers(List.copyOf(bannerpatternlayers.layers().subList(0, 20)));
2022-06-08 02:00:00 +10:00
+ }
+ // CraftBukkit end
2024-04-24 01:15:00 +10:00
return (new BannerPatternLayers.a()).addAll(bannerpatternlayers).add(holder, enumcolor).build();
});
}