diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/inventory/ItemCombinerMenu.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/inventory/ItemCombinerMenu.java.patch | 238 |
1 files changed, 238 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/inventory/ItemCombinerMenu.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/inventory/ItemCombinerMenu.java.patch new file mode 100644 index 0000000000..3736efd372 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/inventory/ItemCombinerMenu.java.patch @@ -0,0 +1,238 @@ +--- a/net/minecraft/world/inventory/ItemCombinerMenu.java ++++ b/net/minecraft/world/inventory/ItemCombinerMenu.java +@@ -1,17 +1,17 @@ + package net.minecraft.world.inventory; + ++import java.util.Iterator; + import java.util.List; + import javax.annotation.Nullable; +-import net.minecraft.core.BlockPos; + 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.level.Level; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + + public abstract class ItemCombinerMenu extends AbstractContainerMenu { ++ + private static final int INVENTORY_SLOTS_PER_ROW = 9; + private static final int INVENTORY_SLOTS_PER_COLUMN = 3; + protected final ContainerLevelAccess access; +@@ -25,63 +25,70 @@ + + protected abstract void onTake(Player player, ItemStack stack); + +- protected abstract boolean isValidBlock(BlockState state); ++ protected abstract boolean isValidBlock(IBlockData state); + + public ItemCombinerMenu(@Nullable MenuType<?> type, int containerId, Inventory playerInventory, ContainerLevelAccess access) { + super(type, containerId); + this.access = access; + this.player = playerInventory.player; +- ItemCombinerMenuSlotDefinition itemCombinerMenuSlotDefinition = this.createInputSlotDefinitions(); +- this.inputSlots = this.createContainer(itemCombinerMenuSlotDefinition.getNumOfInputSlots()); +- this.inputSlotIndexes = itemCombinerMenuSlotDefinition.getInputSlotIndexes(); +- this.resultSlotIndex = itemCombinerMenuSlotDefinition.getResultSlotIndex(); +- this.createInputSlots(itemCombinerMenuSlotDefinition); +- this.createResultSlot(itemCombinerMenuSlotDefinition); ++ ItemCombinerMenuSlotDefinition itemcombinermenuslotdefinition = this.createInputSlotDefinitions(); ++ ++ this.inputSlots = this.createContainer(itemcombinermenuslotdefinition.getNumOfInputSlots()); ++ this.inputSlotIndexes = itemcombinermenuslotdefinition.getInputSlotIndexes(); ++ this.resultSlotIndex = itemcombinermenuslotdefinition.getResultSlotIndex(); ++ this.createInputSlots(itemcombinermenuslotdefinition); ++ this.createResultSlot(itemcombinermenuslotdefinition); + this.createInventorySlots(playerInventory); + } + + private void createInputSlots(ItemCombinerMenuSlotDefinition slotDefinition) { +- for (final ItemCombinerMenuSlotDefinition.SlotDefinition slotDefinition1 : slotDefinition.getSlots()) { +- this.addSlot(new Slot(this.inputSlots, slotDefinition1.slotIndex(), slotDefinition1.x(), slotDefinition1.y()) { ++ Iterator iterator = slotDefinition.getSlots().iterator(); ++ ++ while (iterator.hasNext()) { ++ final ItemCombinerMenuSlotDefinition.b itemcombinermenuslotdefinition_b = (ItemCombinerMenuSlotDefinition.b) iterator.next(); ++ ++ this.addSlot(new Slot(this.inputSlots, itemcombinermenuslotdefinition_b.slotIndex(), itemcombinermenuslotdefinition_b.x(), itemcombinermenuslotdefinition_b.y()) { + @Override + public boolean mayPlace(ItemStack stack) { +- return slotDefinition1.mayPlace().test(stack); ++ return itemcombinermenuslotdefinition_b.mayPlace().test(stack); + } + }); + } ++ + } + + private void createResultSlot(ItemCombinerMenuSlotDefinition slotDefinition) { +- this.addSlot( +- new Slot(this.resultSlots, slotDefinition.getResultSlot().slotIndex(), slotDefinition.getResultSlot().x(), slotDefinition.getResultSlot().y()) { +- @Override +- public boolean mayPlace(ItemStack stack) { +- return false; +- } +- +- @Override +- public boolean mayPickup(Player player) { +- return ItemCombinerMenu.this.mayPickup(player, this.hasItem()); +- } +- +- @Override +- public void onTake(Player player, ItemStack stack) { +- ItemCombinerMenu.this.onTake(player, stack); +- } ++ this.addSlot(new Slot(this.resultSlots, slotDefinition.getResultSlot().slotIndex(), slotDefinition.getResultSlot().x(), slotDefinition.getResultSlot().y()) { ++ @Override ++ public boolean mayPlace(ItemStack stack) { ++ return false; + } +- ); ++ ++ @Override ++ public boolean mayPickup(Player player) { ++ return ItemCombinerMenu.this.mayPickup(player, this.hasItem()); ++ } ++ ++ @Override ++ public void onTake(Player player, ItemStack stack) { ++ ItemCombinerMenu.this.onTake(player, stack); ++ } ++ }); + } + + private void createInventorySlots(Inventory inventory) { +- for (int i = 0; i < 3; i++) { +- for (int i1 = 0; i1 < 9; i1++) { +- this.addSlot(new Slot(inventory, i1 + i * 9 + 9, 8 + i1 * 18, 84 + i * 18)); ++ int i; ++ ++ for (i = 0; i < 3; ++i) { ++ for (int j = 0; j < 9; ++j) { ++ this.addSlot(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + +- for (int i = 0; i < 9; i++) { ++ for (i = 0; i < 9; ++i) { + this.addSlot(new Slot(inventory, i, 8 + i * 18, 142)); + } ++ + } + + public abstract void createResult(); +@@ -104,73 +111,75 @@ + if (inventory == this.inputSlots) { + this.createResult(); + } ++ + } + + @Override + public void removed(Player player) { + super.removed(player); +- this.access.execute((level, blockPos) -> this.clearContainer(player, this.inputSlots)); ++ this.access.execute((world, blockposition) -> { ++ this.clearContainer(player, this.inputSlots); ++ }); + } + + @Override + public boolean stillValid(Player player) { +- return this.access +- .evaluate( +- (level, blockPos) -> !this.isValidBlock(level.getBlockState(blockPos)) +- ? false +- : player.distanceToSqr((double)blockPos.getX() + 0.5, (double)blockPos.getY() + 0.5, (double)blockPos.getZ() + 0.5) <= 64.0, +- true +- ); ++ if (!this.checkReachable) return true; // CraftBukkit ++ return (Boolean) this.access.evaluate((world, blockposition) -> { ++ return !this.isValidBlock(world.getBlockState(blockposition)) ? false : player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) <= 64.0D; ++ }, true); + } + + @Override + public ItemStack quickMoveStack(Player player, int index) { +- ItemStack itemStack = ItemStack.EMPTY; +- Slot slot = this.slots.get(index); ++ ItemStack itemstack = ItemStack.EMPTY; ++ Slot slot = (Slot) this.slots.get(index); ++ + if (slot != null && slot.hasItem()) { +- ItemStack item = slot.getItem(); +- itemStack = item.copy(); +- int inventorySlotStart = this.getInventorySlotStart(); +- int useRowEnd = this.getUseRowEnd(); ++ ItemStack itemstack1 = slot.getItem(); ++ ++ itemstack = itemstack1.copy(); ++ int j = this.getInventorySlotStart(); ++ int k = this.getUseRowEnd(); ++ + if (index == this.getResultSlot()) { +- if (!this.moveItemStackTo(item, inventorySlotStart, useRowEnd, true)) { ++ if (!this.moveItemStackTo(itemstack1, j, k, true)) { + return ItemStack.EMPTY; + } + +- slot.onQuickCraft(item, itemStack); ++ slot.onQuickCraft(itemstack1, itemstack); + } else if (this.inputSlotIndexes.contains(index)) { +- if (!this.moveItemStackTo(item, inventorySlotStart, useRowEnd, false)) { ++ if (!this.moveItemStackTo(itemstack1, j, k, false)) { + return ItemStack.EMPTY; + } +- } else if (this.canMoveIntoInputSlots(item) && index >= this.getInventorySlotStart() && index < this.getUseRowEnd()) { +- int slotToQuickMoveTo = this.getSlotToQuickMoveTo(itemStack); +- if (!this.moveItemStackTo(item, slotToQuickMoveTo, this.getResultSlot(), false)) { ++ } else if (this.canMoveIntoInputSlots(itemstack1) && index >= this.getInventorySlotStart() && index < this.getUseRowEnd()) { ++ int l = this.getSlotToQuickMoveTo(itemstack); ++ ++ if (!this.moveItemStackTo(itemstack1, l, this.getResultSlot(), false)) { + return ItemStack.EMPTY; + } + } else if (index >= this.getInventorySlotStart() && index < this.getInventorySlotEnd()) { +- if (!this.moveItemStackTo(item, this.getUseRowStart(), this.getUseRowEnd(), false)) { ++ if (!this.moveItemStackTo(itemstack1, this.getUseRowStart(), this.getUseRowEnd(), false)) { + return ItemStack.EMPTY; + } +- } else if (index >= this.getUseRowStart() +- && index < this.getUseRowEnd() +- && !this.moveItemStackTo(item, this.getInventorySlotStart(), this.getInventorySlotEnd(), false)) { ++ } else if (index >= this.getUseRowStart() && index < this.getUseRowEnd() && !this.moveItemStackTo(itemstack1, this.getInventorySlotStart(), this.getInventorySlotEnd(), false)) { + return ItemStack.EMPTY; + } + +- if (item.isEmpty()) { ++ if (itemstack1.isEmpty()) { + slot.setByPlayer(ItemStack.EMPTY); + } else { + slot.setChanged(); + } + +- if (item.getCount() == itemStack.getCount()) { ++ if (itemstack1.getCount() == itemstack.getCount()) { + return ItemStack.EMPTY; + } + +- slot.onTake(player, item); ++ slot.onTake(player, itemstack1); + } + +- return itemStack; ++ return itemstack; + } + + protected boolean canMoveIntoInputSlots(ItemStack stack) { +@@ -178,7 +187,7 @@ + } + + public int getSlotToQuickMoveTo(ItemStack stack) { +- return this.inputSlots.isEmpty() ? 0 : this.inputSlotIndexes.get(0); ++ return this.inputSlots.isEmpty() ? 0 : (Integer) this.inputSlotIndexes.get(0); + } + + public int getResultSlot() { |