diff options
author | MiniDigger | Martin <[email protected]> | 2024-01-14 11:04:49 +0100 |
---|---|---|
committer | MiniDigger | Martin <[email protected]> | 2024-01-14 11:04:49 +0100 |
commit | bee74680e607c2e29b038329f62181238911cd83 (patch) | |
tree | 708fd1a4a0227d9071243adf2a42d5e9e96cde4a /patch-remap/mache-spigotflower/net/minecraft/world/inventory/CartographyTableMenu.java.patch | |
parent | 0a44692ef6ff6e255d48eb3ba1bb114166eafda9 (diff) | |
download | Paper-softspoon.tar.gz Paper-softspoon.zip |
add remapped patches as a testsoftspoon
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/inventory/CartographyTableMenu.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/inventory/CartographyTableMenu.java.patch | 275 |
1 files changed, 275 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/inventory/CartographyTableMenu.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/inventory/CartographyTableMenu.java.patch new file mode 100644 index 0000000000..aa95522d8f --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/inventory/CartographyTableMenu.java.patch @@ -0,0 +1,275 @@ +--- a/net/minecraft/world/inventory/CartographyTableMenu.java ++++ b/net/minecraft/world/inventory/CartographyTableMenu.java +@@ -5,15 +5,35 @@ + import net.minecraft.world.Container; + import net.minecraft.world.SimpleContainer; + import net.minecraft.world.entity.player.Inventory; +-import net.minecraft.world.entity.player.Player; + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.item.Items; + import net.minecraft.world.item.MapItem; + import net.minecraft.world.level.block.Blocks; + import net.minecraft.world.level.saveddata.maps.MapItemSavedData; ++// CraftBukkit start ++import org.bukkit.Location; ++import org.bukkit.craftbukkit.inventory.CraftInventoryCartography; ++import org.bukkit.craftbukkit.inventory.CraftInventoryView; ++import org.bukkit.entity.Player; ++// CraftBukkit end + + public class CartographyTableMenu extends AbstractContainerMenu { + ++ // CraftBukkit start ++ private CraftInventoryView bukkitEntity = null; ++ private Player player; ++ ++ @Override ++ public CraftInventoryView getBukkitView() { ++ if (bukkitEntity != null) { ++ return bukkitEntity; ++ } ++ ++ CraftInventoryCartography inventory = new CraftInventoryCartography(this.container, this.resultContainer); ++ bukkitEntity = new CraftInventoryView(this.player, inventory, this); ++ return bukkitEntity; ++ } ++ // CraftBukkit end + public static final int MAP_SLOT = 0; + public static final int ADDITIONAL_SLOT = 1; + public static final int RESULT_SLOT = 2; +@@ -26,66 +46,74 @@ + public final Container container; + private final ResultContainer resultContainer; + +- public CartographyTableMenu(int i, Inventory inventory) { +- this(i, inventory, ContainerLevelAccess.NULL); ++ public CartographyTableMenu(int containerId, Inventory playerInventory) { ++ this(containerId, playerInventory, ContainerLevelAccess.NULL); + } + +- public CartographyTableMenu(int i, Inventory inventory, final ContainerLevelAccess containerlevelaccess) { +- super(MenuType.CARTOGRAPHY_TABLE, i); ++ public CartographyTableMenu(int containerId, Inventory playerInventory, final ContainerLevelAccess access) { ++ super(MenuType.CARTOGRAPHY_TABLE, containerId); + this.container = new SimpleContainer(2) { + @Override +- @Override + public void setChanged() { + CartographyTableMenu.this.slotsChanged(this); + super.setChanged(); + } ++ ++ // CraftBukkit start ++ @Override ++ public Location getLocation() { ++ return access.getLocation(); ++ } ++ // CraftBukkit end + }; + this.resultContainer = new ResultContainer() { + @Override +- @Override + public void setChanged() { + CartographyTableMenu.this.slotsChanged(this); + super.setChanged(); + } ++ ++ // CraftBukkit start ++ @Override ++ public Location getLocation() { ++ return access.getLocation(); ++ } ++ // CraftBukkit end + }; +- this.access = containerlevelaccess; ++ this.access = access; + this.addSlot(new Slot(this.container, 0, 15, 15) { + @Override +- @Override +- public boolean mayPlace(ItemStack itemstack) { +- return itemstack.is(Items.FILLED_MAP); ++ public boolean mayPlace(ItemStack stack) { ++ return stack.is(Items.FILLED_MAP); + } + }); + this.addSlot(new Slot(this.container, 1, 15, 52) { + @Override +- @Override +- public boolean mayPlace(ItemStack itemstack) { +- return itemstack.is(Items.PAPER) || itemstack.is(Items.MAP) || itemstack.is(Items.GLASS_PANE); ++ public boolean mayPlace(ItemStack stack) { ++ return stack.is(Items.PAPER) || stack.is(Items.MAP) || stack.is(Items.GLASS_PANE); + } + }); + this.addSlot(new Slot(this.resultContainer, 2, 145, 39) { + @Override +- @Override +- public boolean mayPlace(ItemStack itemstack) { ++ public boolean mayPlace(ItemStack stack) { + return false; + } + + @Override +- @Override +- public void onTake(Player player, ItemStack itemstack) { ++ public void onTake(net.minecraft.world.entity.player.Player player, ItemStack stack) { + ((Slot) CartographyTableMenu.this.slots.get(0)).remove(1); + ((Slot) CartographyTableMenu.this.slots.get(1)).remove(1); +- itemstack.getItem().onCraftedBy(itemstack, player.level(), player); +- containerlevelaccess.execute((level, blockpos) -> { +- long j = level.getGameTime(); ++ stack.getItem().onCraftedBy(stack, player.level(), player); ++ access.execute((world, blockposition) -> { ++ long j = world.getGameTime(); + + if (CartographyTableMenu.this.lastSoundTime != j) { +- level.playSound((Player) null, blockpos, SoundEvents.UI_CARTOGRAPHY_TABLE_TAKE_RESULT, SoundSource.BLOCKS, 1.0F, 1.0F); ++ world.playSound((net.minecraft.world.entity.player.Player) null, blockposition, SoundEvents.UI_CARTOGRAPHY_TABLE_TAKE_RESULT, SoundSource.BLOCKS, 1.0F, 1.0F); + CartographyTableMenu.this.lastSoundTime = j; + } + + }); +- super.onTake(player, itemstack); ++ super.onTake(player, stack); + } + }); + +@@ -93,25 +121,25 @@ + + for (j = 0; j < 3; ++j) { + for (int k = 0; k < 9; ++k) { +- this.addSlot(new Slot(inventory, k + j * 9 + 9, 8 + k * 18, 84 + j * 18)); ++ this.addSlot(new Slot(playerInventory, k + j * 9 + 9, 8 + k * 18, 84 + j * 18)); + } + } + + for (j = 0; j < 9; ++j) { +- this.addSlot(new Slot(inventory, j, 8 + j * 18, 142)); ++ this.addSlot(new Slot(playerInventory, j, 8 + j * 18, 142)); + } + ++ player = (Player) playerInventory.player.getBukkitEntity(); // CraftBukkit + } + + @Override +- @Override +- public boolean stillValid(Player player) { ++ public boolean stillValid(net.minecraft.world.entity.player.Player player) { ++ if (!this.checkReachable) return true; // CraftBukkit + return stillValid(this.access, player, Blocks.CARTOGRAPHY_TABLE); + } + + @Override +- @Override +- public void slotsChanged(Container container) { ++ public void slotsChanged(Container inventory) { + ItemStack itemstack = this.container.getItem(0); + ItemStack itemstack1 = this.container.getItem(1); + ItemStack itemstack2 = this.resultContainer.getItem(2); +@@ -124,33 +152,33 @@ + + } + +- private void setupResultSlot(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2) { +- this.access.execute((level, blockpos) -> { +- MapItemSavedData mapitemsaveddata = MapItem.getSavedData(itemstack, level); ++ private void setupResultSlot(ItemStack map, ItemStack firstSlotStack, ItemStack resultOutput) { ++ this.access.execute((world, blockposition) -> { ++ MapItemSavedData worldmap = MapItem.getSavedData(map, world); + +- if (mapitemsaveddata != null) { ++ if (worldmap != null) { + ItemStack itemstack3; + +- if (itemstack1.is(Items.PAPER) && !mapitemsaveddata.locked && mapitemsaveddata.scale < 4) { +- itemstack3 = itemstack.copyWithCount(1); ++ if (firstSlotStack.is(Items.PAPER) && !worldmap.locked && worldmap.scale < 4) { ++ itemstack3 = map.copyWithCount(1); + itemstack3.getOrCreateTag().putInt("map_scale_direction", 1); + this.broadcastChanges(); +- } else if (itemstack1.is(Items.GLASS_PANE) && !mapitemsaveddata.locked) { +- itemstack3 = itemstack.copyWithCount(1); ++ } else if (firstSlotStack.is(Items.GLASS_PANE) && !worldmap.locked) { ++ itemstack3 = map.copyWithCount(1); + itemstack3.getOrCreateTag().putBoolean("map_to_lock", true); + this.broadcastChanges(); + } else { +- if (!itemstack1.is(Items.MAP)) { ++ if (!firstSlotStack.is(Items.MAP)) { + this.resultContainer.removeItemNoUpdate(2); + this.broadcastChanges(); + return; + } + +- itemstack3 = itemstack.copyWithCount(2); ++ itemstack3 = map.copyWithCount(2); + this.broadcastChanges(); + } + +- if (!ItemStack.matches(itemstack3, itemstack2)) { ++ if (!ItemStack.matches(itemstack3, resultOutput)) { + this.resultContainer.setItem(2, itemstack3); + this.broadcastChanges(); + } +@@ -160,39 +188,37 @@ + } + + @Override +- @Override +- public boolean canTakeItemForPickAll(ItemStack itemstack, Slot slot) { +- return slot.container != this.resultContainer && super.canTakeItemForPickAll(itemstack, slot); ++ public boolean canTakeItemForPickAll(ItemStack stack, Slot slot) { ++ return slot.container != this.resultContainer && super.canTakeItemForPickAll(stack, slot); + } + + @Override +- @Override +- public ItemStack quickMoveStack(Player player, int i) { ++ public ItemStack quickMoveStack(net.minecraft.world.entity.player.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 == 2) { ++ if (index == 2) { + itemstack1.getItem().onCraftedBy(itemstack1, player.level(), player); + if (!this.moveItemStackTo(itemstack1, 3, 39, true)) { + return ItemStack.EMPTY; + } + + slot.onQuickCraft(itemstack1, itemstack); +- } else if (i != 1 && i != 0) { ++ } else if (index != 1 && index != 0) { + if (itemstack1.is(Items.FILLED_MAP)) { + if (!this.moveItemStackTo(itemstack1, 0, 1, false)) { + return ItemStack.EMPTY; + } + } else if (!itemstack1.is(Items.PAPER) && !itemstack1.is(Items.MAP) && !itemstack1.is(Items.GLASS_PANE)) { +- if (i >= 3 && i < 30) { ++ if (index >= 3 && index < 30) { + if (!this.moveItemStackTo(itemstack1, 30, 39, false)) { + return ItemStack.EMPTY; + } +- } else if (i >= 30 && i < 39 && !this.moveItemStackTo(itemstack1, 3, 30, false)) { ++ } else if (index >= 30 && index < 39 && !this.moveItemStackTo(itemstack1, 3, 30, false)) { + return ItemStack.EMPTY; + } + } else if (!this.moveItemStackTo(itemstack1, 1, 2, false)) { +@@ -219,11 +245,10 @@ + } + + @Override +- @Override +- public void removed(Player player) { ++ public void removed(net.minecraft.world.entity.player.Player player) { + super.removed(player); + this.resultContainer.removeItemNoUpdate(2); +- this.access.execute((level, blockpos) -> { ++ this.access.execute((world, blockposition) -> { + this.clearContainer(player, this.container); + }); + } |