aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/inventory/CartographyTableMenu.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/inventory/CartographyTableMenu.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/inventory/CartographyTableMenu.java.patch312
1 files changed, 312 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/inventory/CartographyTableMenu.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/inventory/CartographyTableMenu.java.patch
new file mode 100644
index 0000000000..2fd70c98be
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/inventory/CartographyTableMenu.java.patch
@@ -0,0 +1,312 @@
+--- a/net/minecraft/world/inventory/CartographyTableMenu.java
++++ b/net/minecraft/world/inventory/CartographyTableMenu.java
+@@ -1,20 +1,39 @@
+ package net.minecraft.world.inventory;
+
+-import net.minecraft.core.BlockPos;
+ import net.minecraft.sounds.SoundEvents;
+ import net.minecraft.sounds.SoundSource;
+ 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.Level;
+ 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;
+@@ -24,20 +43,8 @@
+ private static final int USE_ROW_SLOT_END = 39;
+ private final ContainerLevelAccess access;
+ long lastSoundTime;
+- public final Container container = new SimpleContainer(2) {
+- @Override
+- public void setChanged() {
+- CartographyTableMenu.this.slotsChanged(this);
+- super.setChanged();
+- }
+- };
+- private final ResultContainer resultContainer = new ResultContainer() {
+- @Override
+- public void setChanged() {
+- CartographyTableMenu.this.slotsChanged(this);
+- super.setChanged();
+- }
+- };
++ public final Container container;
++ private final ResultContainer resultContainer;
+
+ public CartographyTableMenu(int containerId, Inventory playerInventory) {
+ this(containerId, playerInventory, ContainerLevelAccess.NULL);
+@@ -45,6 +52,34 @@
+
+ public CartographyTableMenu(int containerId, Inventory playerInventory, final ContainerLevelAccess access) {
+ super(MenuType.CARTOGRAPHY_TABLE, containerId);
++ this.container = new SimpleContainer(2) {
++ @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
++ public void setChanged() {
++ CartographyTableMenu.this.slotsChanged(this);
++ super.setChanged();
++ }
++
++ // CraftBukkit start
++ @Override
++ public Location getLocation() {
++ return access.getLocation();
++ }
++ // CraftBukkit end
++ };
+ this.access = access;
+ this.addSlot(new Slot(this.container, 0, 15, 15) {
+ @Override
+@@ -65,63 +100,72 @@
+ }
+
+ @Override
+- public void onTake(Player player, ItemStack stack) {
+- CartographyTableMenu.this.slots.get(0).remove(1);
+- CartographyTableMenu.this.slots.get(1).remove(1);
++ 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);
+ stack.getItem().onCraftedBy(stack, player.level(), player);
+- access.execute((level, blockPos) -> {
+- long gameTime = level.getGameTime();
+- if (CartographyTableMenu.this.lastSoundTime != gameTime) {
+- level.playSound(null, blockPos, SoundEvents.UI_CARTOGRAPHY_TABLE_TAKE_RESULT, SoundSource.BLOCKS, 1.0F, 1.0F);
+- CartographyTableMenu.this.lastSoundTime = gameTime;
++ access.execute((world, blockposition) -> {
++ long j = world.getGameTime();
++
++ if (CartographyTableMenu.this.lastSoundTime != j) {
++ 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, stack);
+ }
+ });
+
+- for (int i = 0; i < 3; i++) {
+- for (int i1 = 0; i1 < 9; i1++) {
+- this.addSlot(new Slot(playerInventory, i1 + i * 9 + 9, 8 + i1 * 18, 84 + i * 18));
++ int j;
++
++ for (j = 0; j < 3; ++j) {
++ for (int k = 0; k < 9; ++k) {
++ this.addSlot(new Slot(playerInventory, k + j * 9 + 9, 8 + k * 18, 84 + j * 18));
+ }
+ }
+
+- for (int i = 0; i < 9; i++) {
+- this.addSlot(new Slot(playerInventory, i, 8 + i * 18, 142));
++ for (j = 0; j < 9; ++j) {
++ this.addSlot(new Slot(playerInventory, j, 8 + j * 18, 142));
+ }
++
++ player = (Player) playerInventory.player.getBukkitEntity(); // CraftBukkit
+ }
+
+ @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
+ public void slotsChanged(Container inventory) {
+- ItemStack item = this.container.getItem(0);
+- ItemStack item1 = this.container.getItem(1);
+- ItemStack item2 = this.resultContainer.getItem(2);
+- if (item2.isEmpty() || !item.isEmpty() && !item1.isEmpty()) {
+- if (!item.isEmpty() && !item1.isEmpty()) {
+- this.setupResultSlot(item, item1, item2);
+- }
+- } else {
++ ItemStack itemstack = this.container.getItem(0);
++ ItemStack itemstack1 = this.container.getItem(1);
++ ItemStack itemstack2 = this.resultContainer.getItem(2);
++
++ if (!itemstack2.isEmpty() && (itemstack.isEmpty() || itemstack1.isEmpty())) {
+ this.resultContainer.removeItemNoUpdate(2);
++ } else if (!itemstack.isEmpty() && !itemstack1.isEmpty()) {
++ this.setupResultSlot(itemstack, itemstack1, itemstack2);
+ }
++
+ }
+
+ private void setupResultSlot(ItemStack map, ItemStack firstSlotStack, ItemStack resultOutput) {
+- this.access.execute((level, blockPos) -> {
+- MapItemSavedData savedData = MapItem.getSavedData(map, level);
+- if (savedData != null) {
+- ItemStack itemStack;
+- if (firstSlotStack.is(Items.PAPER) && !savedData.locked && savedData.scale < 4) {
+- itemStack = map.copyWithCount(1);
+- itemStack.getOrCreateTag().putInt("map_scale_direction", 1);
++ this.access.execute((world, blockposition) -> {
++ MapItemSavedData worldmap = MapItem.getSavedData(map, world);
++
++ if (worldmap != null) {
++ ItemStack itemstack3;
++
++ 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 (firstSlotStack.is(Items.GLASS_PANE) && !savedData.locked) {
+- itemStack = map.copyWithCount(1);
+- itemStack.getOrCreateTag().putBoolean("map_to_lock", true);
++ } else if (firstSlotStack.is(Items.GLASS_PANE) && !worldmap.locked) {
++ itemstack3 = map.copyWithCount(1);
++ itemstack3.getOrCreateTag().putBoolean("map_to_lock", true);
+ this.broadcastChanges();
+ } else {
+ if (!firstSlotStack.is(Items.MAP)) {
+@@ -130,14 +174,15 @@
+ return;
+ }
+
+- itemStack = map.copyWithCount(2);
++ itemstack3 = map.copyWithCount(2);
+ this.broadcastChanges();
+ }
+
+- if (!ItemStack.matches(itemStack, resultOutput)) {
+- this.resultContainer.setItem(2, itemStack);
++ if (!ItemStack.matches(itemstack3, resultOutput)) {
++ this.resultContainer.setItem(2, itemstack3);
+ this.broadcastChanges();
+ }
++
+ }
+ });
+ }
+@@ -148,59 +193,63 @@
+ }
+
+ @Override
+- public ItemStack quickMoveStack(Player player, int index) {
+- ItemStack itemStack = ItemStack.EMPTY;
+- Slot slot = this.slots.get(index);
++ public ItemStack quickMoveStack(net.minecraft.world.entity.player.Player player, int index) {
++ ItemStack itemstack = ItemStack.EMPTY;
++ Slot slot = (Slot) this.slots.get(index);
++
+ if (slot != null && slot.hasItem()) {
+- ItemStack item = slot.getItem();
+- itemStack = item.copy();
++ ItemStack itemstack1 = slot.getItem();
++
++ itemstack = itemstack1.copy();
+ if (index == 2) {
+- item.getItem().onCraftedBy(item, player.level(), player);
+- if (!this.moveItemStackTo(item, 3, 39, true)) {
++ itemstack1.getItem().onCraftedBy(itemstack1, player.level(), player);
++ if (!this.moveItemStackTo(itemstack1, 3, 39, true)) {
+ return ItemStack.EMPTY;
+ }
+
+- slot.onQuickCraft(item, itemStack);
++ slot.onQuickCraft(itemstack1, itemstack);
+ } else if (index != 1 && index != 0) {
+- if (item.is(Items.FILLED_MAP)) {
+- if (!this.moveItemStackTo(item, 0, 1, false)) {
++ if (itemstack1.is(Items.FILLED_MAP)) {
++ if (!this.moveItemStackTo(itemstack1, 0, 1, false)) {
+ return ItemStack.EMPTY;
+ }
+- } else if (!item.is(Items.PAPER) && !item.is(Items.MAP) && !item.is(Items.GLASS_PANE)) {
++ } else if (!itemstack1.is(Items.PAPER) && !itemstack1.is(Items.MAP) && !itemstack1.is(Items.GLASS_PANE)) {
+ if (index >= 3 && index < 30) {
+- if (!this.moveItemStackTo(item, 30, 39, false)) {
++ if (!this.moveItemStackTo(itemstack1, 30, 39, false)) {
+ return ItemStack.EMPTY;
+ }
+- } else if (index >= 30 && index < 39 && !this.moveItemStackTo(item, 3, 30, false)) {
++ } else if (index >= 30 && index < 39 && !this.moveItemStackTo(itemstack1, 3, 30, false)) {
+ return ItemStack.EMPTY;
+ }
+- } else if (!this.moveItemStackTo(item, 1, 2, false)) {
++ } else if (!this.moveItemStackTo(itemstack1, 1, 2, false)) {
+ return ItemStack.EMPTY;
+ }
+- } else if (!this.moveItemStackTo(item, 3, 39, false)) {
++ } else if (!this.moveItemStackTo(itemstack1, 3, 39, false)) {
+ return ItemStack.EMPTY;
+ }
+
+- if (item.isEmpty()) {
++ if (itemstack1.isEmpty()) {
+ slot.setByPlayer(ItemStack.EMPTY);
+ }
+
+ slot.setChanged();
+- if (item.getCount() == itemStack.getCount()) {
++ if (itemstack1.getCount() == itemstack.getCount()) {
+ return ItemStack.EMPTY;
+ }
+
+- slot.onTake(player, item);
++ slot.onTake(player, itemstack1);
+ this.broadcastChanges();
+ }
+
+- return itemStack;
++ return itemstack;
+ }
+
+ @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.clearContainer(player, this.container));
++ this.access.execute((world, blockposition) -> {
++ this.clearContainer(player, this.container);
++ });
+ }
+ }