aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/inventory/BeaconMenu.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/inventory/BeaconMenu.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/inventory/BeaconMenu.java.patch185
1 files changed, 185 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/inventory/BeaconMenu.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/inventory/BeaconMenu.java.patch
new file mode 100644
index 0000000000..75fbc4e670
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/inventory/BeaconMenu.java.patch
@@ -0,0 +1,185 @@
+--- a/net/minecraft/world/inventory/BeaconMenu.java
++++ b/net/minecraft/world/inventory/BeaconMenu.java
+@@ -7,10 +7,13 @@
+ import net.minecraft.world.Container;
+ import net.minecraft.world.SimpleContainer;
+ import net.minecraft.world.effect.MobEffect;
++import net.minecraft.world.entity.player.Inventory;
+ import net.minecraft.world.entity.player.Player;
+ import net.minecraft.world.item.ItemStack;
+ import net.minecraft.world.level.Level;
+ import net.minecraft.world.level.block.Blocks;
++import org.bukkit.craftbukkit.inventory.CraftInventoryView;
++// CraftBukkit end
+
+ public class BeaconMenu extends AbstractContainerMenu {
+
+@@ -26,32 +29,35 @@
+ private final BeaconMenu.PaymentSlot paymentSlot;
+ private final ContainerLevelAccess access;
+ private final ContainerData beaconData;
++ // CraftBukkit start
++ private CraftInventoryView bukkitEntity = null;
++ private Inventory player;
++ // CraftBukkit end
+
+- public BeaconMenu(int i, Container container) {
+- this(i, container, new SimpleContainerData(3), ContainerLevelAccess.NULL);
++ public BeaconMenu(int containerId, Container container) {
++ this(containerId, container, new SimpleContainerData(3), ContainerLevelAccess.NULL);
+ }
+
+- public BeaconMenu(int i, Container container, ContainerData containerdata, ContainerLevelAccess containerlevelaccess) {
+- super(MenuType.BEACON, i);
++ public BeaconMenu(int containerId, Container container, ContainerData beaconData, ContainerLevelAccess access) {
++ super(MenuType.BEACON, containerId);
++ player = (Inventory) container; // CraftBukkit - TODO: check this
+ this.beacon = new SimpleContainer(1) {
+ @Override
+- @Override
+- public boolean canPlaceItem(int j, ItemStack itemstack) {
+- return itemstack.is(ItemTags.BEACON_PAYMENT_ITEMS);
++ public boolean canPlaceItem(int index, ItemStack stack) {
++ return stack.is(ItemTags.BEACON_PAYMENT_ITEMS);
+ }
+
+ @Override
+- @Override
+ public int getMaxStackSize() {
+ return 1;
+ }
+ };
+- checkContainerDataCount(containerdata, 3);
+- this.beaconData = containerdata;
+- this.access = containerlevelaccess;
++ checkContainerDataCount(beaconData, 3);
++ this.beaconData = beaconData;
++ this.access = access;
+ this.paymentSlot = new BeaconMenu.PaymentSlot(this.beacon, 0, 136, 110);
+ this.addSlot(this.paymentSlot);
+- this.addDataSlots(containerdata);
++ this.addDataSlots(beaconData);
+ boolean flag = true;
+ boolean flag1 = true;
+
+@@ -70,7 +76,6 @@
+ }
+
+ @Override
+- @Override
+ public void removed(Player player) {
+ super.removed(player);
+ if (!player.level().isClientSide) {
+@@ -84,29 +89,27 @@
+ }
+
+ @Override
+- @Override
+ public boolean stillValid(Player player) {
++ if (!this.checkReachable) return true; // CraftBukkit
+ return stillValid(this.access, player, Blocks.BEACON);
+ }
+
+ @Override
+- @Override
+- public void setData(int i, int j) {
+- super.setData(i, j);
++ public void setData(int id, int data) {
++ super.setData(id, data);
+ this.broadcastChanges();
+ }
+
+ @Override
+- @Override
+- public ItemStack quickMoveStack(Player player, int i) {
++ public ItemStack quickMoveStack(Player player, int index) {
+ ItemStack itemstack = ItemStack.EMPTY;
+- Slot slot = (Slot) this.slots.get(i);
++ Slot slot = (Slot) this.slots.get(index);
+
+ if (slot != null && slot.hasItem()) {
+ ItemStack itemstack1 = slot.getItem();
+
+ itemstack = itemstack1.copy();
+- if (i == 0) {
++ if (index == 0) {
+ if (!this.moveItemStackTo(itemstack1, 1, 37, true)) {
+ return ItemStack.EMPTY;
+ }
+@@ -116,11 +119,11 @@
+ if (!this.moveItemStackTo(itemstack1, 0, 1, false)) {
+ return ItemStack.EMPTY;
+ }
+- } else if (i >= 1 && i < 28) {
++ } else if (index >= 1 && index < 28) {
+ if (!this.moveItemStackTo(itemstack1, 28, 37, false)) {
+ return ItemStack.EMPTY;
+ }
+- } else if (i >= 28 && i < 37) {
++ } else if (index >= 28 && index < 37) {
+ if (!this.moveItemStackTo(itemstack1, 1, 28, false)) {
+ return ItemStack.EMPTY;
+ }
+@@ -148,8 +151,8 @@
+ return this.beaconData.get(0);
+ }
+
+- public static int encodeEffect(@Nullable MobEffect mobeffect) {
+- return mobeffect == null ? 0 : BuiltInRegistries.MOB_EFFECT.getId(mobeffect) + 1;
++ public static int encodeEffect(@Nullable MobEffect mobeffectlist) {
++ return mobeffectlist == null ? 0 : BuiltInRegistries.MOB_EFFECT.getId(mobeffectlist) + 1;
+ }
+
+ @Nullable
+@@ -167,10 +170,10 @@
+ return decodeEffect(this.beaconData.get(2));
+ }
+
+- public void updateEffects(Optional<MobEffect> optional, Optional<MobEffect> optional1) {
++ public void updateEffects(Optional<MobEffect> primaryEffect, Optional<MobEffect> secondaryEffect) {
+ if (this.paymentSlot.hasItem()) {
+- this.beaconData.set(1, encodeEffect((MobEffect) optional.orElse((Object) null)));
+- this.beaconData.set(2, encodeEffect((MobEffect) optional1.orElse((Object) null)));
++ this.beaconData.set(1, encodeEffect((MobEffect) primaryEffect.orElse(null))); // CraftBukkit - decompile error
++ this.beaconData.set(2, encodeEffect((MobEffect) secondaryEffect.orElse(null))); // CraftBukkit - decompile error
+ this.paymentSlot.remove(1);
+ this.access.execute(Level::blockEntityChanged);
+ }
+@@ -183,20 +186,31 @@
+
+ private class PaymentSlot extends Slot {
+
+- public PaymentSlot(Container container, int i, int j, int k) {
+- super(container, i, j, k);
++ public PaymentSlot(Container container, int slot, int x, int y) {
++ super(container, slot, x, y);
+ }
+
+ @Override
+- @Override
+- public boolean mayPlace(ItemStack itemstack) {
+- return itemstack.is(ItemTags.BEACON_PAYMENT_ITEMS);
++ public boolean mayPlace(ItemStack stack) {
++ return stack.is(ItemTags.BEACON_PAYMENT_ITEMS);
+ }
+
+ @Override
+- @Override
+ public int getMaxStackSize() {
+ return 1;
+ }
+ }
++
++ // CraftBukkit start
++ @Override
++ public CraftInventoryView getBukkitView() {
++ if (bukkitEntity != null) {
++ return bukkitEntity;
++ }
++
++ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryBeacon(this.beacon);
++ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
++ return bukkitEntity;
++ }
++ // CraftBukkit end
+ }