0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-25 03:26:14 +00:00
craftbukkit/nms-patches/net/minecraft/world/inventory/ContainerFurnace.patch
2024-10-23 02:15:00 +11:00

63 lines
2.7 KiB
Diff

--- a/net/minecraft/world/inventory/ContainerFurnace.java
+++ b/net/minecraft/world/inventory/ContainerFurnace.java
@@ -18,6 +18,12 @@
import net.minecraft.world.item.crafting.SingleRecipeInput;
import net.minecraft.world.level.World;
+// CraftBukkit start
+import net.minecraft.world.level.block.entity.TileEntityFurnace;
+import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace;
+import org.bukkit.craftbukkit.inventory.view.CraftFurnaceView;
+// CraftBukkit end
+
public abstract class ContainerFurnace extends ContainerRecipeBook {
public static final int INGREDIENT_SLOT = 0;
@@ -36,6 +42,22 @@
private final RecipePropertySet acceptedInputs;
private final RecipeBookType recipeBookType;
+ // CraftBukkit start
+ private CraftFurnaceView bukkitEntity = null;
+ private PlayerInventory player;
+
+ @Override
+ public CraftFurnaceView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ CraftInventoryFurnace inventory = new CraftInventoryFurnace((TileEntityFurnace) this.container);
+ bukkitEntity = new CraftFurnaceView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
+
protected ContainerFurnace(Containers<?> containers, Recipes<? extends RecipeCooking> recipes, ResourceKey<RecipePropertySet> resourcekey, RecipeBookType recipebooktype, int i, PlayerInventory playerinventory) {
this(containers, recipes, resourcekey, recipebooktype, i, playerinventory, new InventorySubcontainer(3), new ContainerProperties(4));
}
@@ -53,6 +75,7 @@
this.addSlot(new Slot(iinventory, 0, 56, 17));
this.addSlot(new SlotFurnaceFuel(this, iinventory, 1, 56, 53));
this.addSlot(new SlotFurnaceResult(playerinventory.player, iinventory, 2, 116, 35));
+ this.player = playerinventory; // CraftBukkit - save player
this.addStandardInventorySlots(playerinventory, 8, 84);
this.addDataSlots(icontainerproperties);
}
@@ -71,6 +94,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.container.stillValid(entityhuman);
}
@@ -180,6 +204,6 @@
public boolean recipeMatches(RecipeHolder<RecipeCooking> recipeholder1) {
return ((RecipeCooking) recipeholder1.value()).matches(new SingleRecipeInput(ContainerFurnace.this.container.getItem(0)), worldserver);
}
- }, 1, 1, List.of(this.getSlot(0)), list, playerinventory, recipeholder, flag, flag1);
+ }, 1, 1, List.of(this.getSlot(0)), list, playerinventory, (RecipeHolder<RecipeCooking>) recipeholder, flag, flag1); // CraftBukkit - decompile error
}
}