diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch | 206 |
1 files changed, 206 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch new file mode 100644 index 0000000000..79f9e2ab8e --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch @@ -0,0 +1,206 @@ +--- a/net/minecraft/world/inventory/AbstractFurnaceMenu.java ++++ b/net/minecraft/world/inventory/AbstractFurnaceMenu.java +@@ -13,6 +13,10 @@ + import net.minecraft.world.item.crafting.RecipeType; + import net.minecraft.world.level.Level; + import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; ++// CraftBukkit start ++import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace; ++import org.bukkit.craftbukkit.inventory.CraftInventoryView; ++// CraftBukkit end + + public abstract class AbstractFurnaceMenu extends RecipeBookMenu<Container> { + +@@ -31,107 +35,116 @@ + private final RecipeType<? extends AbstractCookingRecipe> recipeType; + private final RecipeBookType recipeBookType; + +- protected AbstractFurnaceMenu(MenuType<?> menutype, RecipeType<? extends AbstractCookingRecipe> recipetype, RecipeBookType recipebooktype, int i, Inventory inventory) { +- this(menutype, recipetype, recipebooktype, i, inventory, new SimpleContainer(3), new SimpleContainerData(4)); ++ // CraftBukkit start ++ private CraftInventoryView bukkitEntity = null; ++ private Inventory player; ++ ++ @Override ++ public CraftInventoryView getBukkitView() { ++ if (bukkitEntity != null) { ++ return bukkitEntity; ++ } ++ ++ CraftInventoryFurnace inventory = new CraftInventoryFurnace((AbstractFurnaceBlockEntity) this.container); ++ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); ++ return bukkitEntity; + } ++ // CraftBukkit end + +- protected AbstractFurnaceMenu(MenuType<?> menutype, RecipeType<? extends AbstractCookingRecipe> recipetype, RecipeBookType recipebooktype, int i, Inventory inventory, Container container, ContainerData containerdata) { +- super(menutype, i); +- this.recipeType = recipetype; +- this.recipeBookType = recipebooktype; ++ protected AbstractFurnaceMenu(MenuType<?> menuType, RecipeType<? extends AbstractCookingRecipe> recipeType, RecipeBookType recipeBookType, int containerId, Inventory playerInventory) { ++ this(menuType, recipeType, recipeBookType, containerId, playerInventory, new SimpleContainer(3), new SimpleContainerData(4)); ++ } ++ ++ protected AbstractFurnaceMenu(MenuType<?> menuType, RecipeType<? extends AbstractCookingRecipe> recipeType, RecipeBookType recipeBookType, int containerId, Inventory playerInventory, Container container, ContainerData data) { ++ super(menuType, containerId); ++ this.recipeType = recipeType; ++ this.recipeBookType = recipeBookType; + checkContainerSize(container, 3); +- checkContainerDataCount(containerdata, 4); ++ checkContainerDataCount(data, 4); + this.container = container; +- this.data = containerdata; +- this.level = inventory.player.level(); ++ this.data = data; ++ this.level = playerInventory.player.level(); + this.addSlot(new Slot(container, 0, 56, 17)); + this.addSlot(new FurnaceFuelSlot(this, container, 1, 56, 53)); +- this.addSlot(new FurnaceResultSlot(inventory.player, container, 2, 116, 35)); ++ this.addSlot(new FurnaceResultSlot(playerInventory.player, container, 2, 116, 35)); ++ this.player = playerInventory; // CraftBukkit - save player + + int j; + + 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)); + } + +- this.addDataSlots(containerdata); ++ this.addDataSlots(data); + } + + @Override +- @Override +- public void fillCraftSlotsStackedContents(StackedContents stackedcontents) { ++ public void fillCraftSlotsStackedContents(StackedContents itemHelper) { + if (this.container instanceof StackedContentsCompatible) { +- ((StackedContentsCompatible) this.container).fillStackedContents(stackedcontents); ++ ((StackedContentsCompatible) this.container).fillStackedContents(itemHelper); + } + + } + + @Override +- @Override + public void clearCraftingContent() { + this.getSlot(0).set(ItemStack.EMPTY); + this.getSlot(2).set(ItemStack.EMPTY); + } + + @Override +- @Override + public boolean recipeMatches(RecipeHolder<? extends Recipe<Container>> recipeholder) { + return recipeholder.value().matches(this.container, this.level); + } + + @Override +- @Override + public int getResultSlotIndex() { + return 2; + } + + @Override +- @Override + public int getGridWidth() { + return 1; + } + + @Override +- @Override + public int getGridHeight() { + return 1; + } + + @Override +- @Override + public int getSize() { + return 3; + } + + @Override +- @Override + public boolean stillValid(Player player) { ++ if (!this.checkReachable) return true; // CraftBukkit + return this.container.stillValid(player); + } + + @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 == 2) { ++ if (index == 2) { + 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 (this.canSmelt(itemstack1)) { + if (!this.moveItemStackTo(itemstack1, 0, 1, false)) { + return ItemStack.EMPTY; +@@ -140,11 +153,11 @@ + if (!this.moveItemStackTo(itemstack1, 1, 2, false)) { + return ItemStack.EMPTY; + } +- } else if (i >= 3 && i < 30) { ++ } else 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, 3, 39, false)) { +@@ -167,12 +180,12 @@ + return itemstack; + } + +- protected boolean canSmelt(ItemStack itemstack) { +- return this.level.getRecipeManager().getRecipeFor(this.recipeType, new SimpleContainer(new ItemStack[]{itemstack}), this.level).isPresent(); ++ protected boolean canSmelt(ItemStack stack) { ++ return this.level.getRecipeManager().getRecipeFor((RecipeType<AbstractCookingRecipe>) this.recipeType, new SimpleContainer(new ItemStack[]{stack}), this.level).isPresent(); // Eclipse fail + } + +- protected boolean isFuel(ItemStack itemstack) { +- return AbstractFurnaceBlockEntity.isFuel(itemstack); ++ protected boolean isFuel(ItemStack stack) { ++ return AbstractFurnaceBlockEntity.isFuel(stack); + } + + public float getBurnProgress() { +@@ -197,14 +210,12 @@ + } + + @Override +- @Override + public RecipeBookType getRecipeBookType() { + return this.recipeBookType; + } + + @Override +- @Override +- public boolean shouldMoveToInventory(int i) { +- return i != 1; ++ public boolean shouldMoveToInventory(int slotIndex) { ++ return slotIndex != 1; + } + } |