Paper/nms-patches/ContainerFurnace.patch

71 lines
2.6 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/ContainerFurnace.java
+++ b/net/minecraft/server/ContainerFurnace.java
2019-04-23 04:00:00 +02:00
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
2019-04-23 04:00:00 +02:00
+
public abstract class ContainerFurnace extends ContainerRecipeBook<IInventory> {
2019-04-23 04:00:00 +02:00
private final IInventory furnace;
@@ -7,6 +12,22 @@
protected final World c;
private final Recipes<? extends RecipeCooking> f;
2015-02-26 23:41:06 +01:00
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ CraftInventoryFurnace inventory = new CraftInventoryFurnace((TileEntityFurnace) this.furnace);
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
2015-02-26 23:41:06 +01:00
+ // CraftBukkit end
+
2019-04-23 04:00:00 +02:00
protected ContainerFurnace(Containers<?> containers, Recipes<? extends RecipeCooking> recipes, int i, PlayerInventory playerinventory) {
this(containers, recipes, i, playerinventory, new InventorySubcontainer(3), new ContainerProperties(4));
}
@@ -22,6 +43,7 @@
this.a(new Slot(iinventory, 0, 56, 17));
2019-04-23 04:00:00 +02:00
this.a((Slot) (new SlotFurnaceFuel(this, iinventory, 1, 56, 53)));
this.a((Slot) (new SlotFurnaceResult(playerinventory.player, iinventory, 2, 116, 35)));
+ this.player = playerinventory; // CraftBukkit - save player
2019-04-23 04:00:00 +02:00
int j;
2019-04-23 04:00:00 +02:00
@@ -53,7 +75,7 @@
@Override
public void a(boolean flag, IRecipe<?> irecipe, EntityPlayer entityplayer) {
- (new AutoRecipeFurnace<>(this)).a(entityplayer, irecipe, flag);
+ (new AutoRecipeFurnace(this)).a(entityplayer, irecipe, flag); // CraftBukkit - decompile error
}
2019-04-23 04:00:00 +02:00
@Override
@@ -78,6 +100,7 @@
@Override
2017-09-18 12:00:00 +02:00
public boolean canUse(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.furnace.a(entityhuman);
}
2019-04-23 04:00:00 +02:00
@@ -133,7 +156,7 @@
}
protected boolean a(ItemStack itemstack) {
2019-05-27 22:30:00 +02:00
- return this.c.getCraftingManager().craft(this.f, new InventorySubcontainer(new ItemStack[]{itemstack}), this.c).isPresent();
+ return this.c.getCraftingManager().craft((Recipes<RecipeCooking>) this.f, new InventorySubcontainer(new ItemStack[]{itemstack}), this.c).isPresent(); // Eclipse fail
2019-04-23 04:00:00 +02:00
}
protected boolean b(ItemStack itemstack) {