SPIGOT-6434: Smithing Table and Anvil inventories .getType() returns CRAFTING

This commit is contained in:
md_5 2021-04-25 08:34:44 +10:00
parent c5494d195a
commit a8d7c94a5b
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
3 changed files with 11 additions and 37 deletions

View File

@ -1,37 +1,6 @@
--- a/net/minecraft/world/inventory/ContainerAnvilAbstract.java --- a/net/minecraft/world/inventory/ContainerAnvilAbstract.java
+++ b/net/minecraft/world/inventory/ContainerAnvilAbstract.java +++ b/net/minecraft/world/inventory/ContainerAnvilAbstract.java
@@ -11,13 +11,7 @@ @@ -85,6 +85,7 @@
public abstract class ContainerAnvilAbstract extends Container {
protected final InventoryCraftResult resultInventory = new InventoryCraftResult();
- protected final IInventory repairInventory = new InventorySubcontainer(2) {
- @Override
- public void update() {
- super.update();
- ContainerAnvilAbstract.this.a((IInventory) this);
- }
- };
+ protected final IInventory repairInventory; // CraftBukkit - instantiate repairInventory in the constructor
protected final ContainerAccess containerAccess;
protected final EntityHuman player;
@@ -31,6 +25,15 @@
super(containers, i);
this.containerAccess = containeraccess;
this.player = playerinventory.player;
+ // CraftBukkit start
+ this.repairInventory = new InventoryCrafting(this, 1, 2, player) {
+ @Override
+ public void update() {
+ super.update();
+ ContainerAnvilAbstract.this.a((IInventory) this);
+ }
+ };
+ // CraftBukkit end
this.a(new Slot(this.repairInventory, 0, 27, 47));
this.a(new Slot(this.repairInventory, 1, 76, 47));
this.a(new Slot(this.resultInventory, 2, 134, 47) {
@@ -85,6 +88,7 @@
@Override @Override
public boolean canUse(EntityHuman entityhuman) { public boolean canUse(EntityHuman entityhuman) {

View File

@ -18,7 +18,7 @@
public ContainerSmithing(int i, PlayerInventory playerinventory) { public ContainerSmithing(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.a); this(i, playerinventory, ContainerAccess.a);
@@ -63,13 +68,16 @@ @@ -63,13 +68,15 @@
List<RecipeSmithing> list = this.g.getCraftingManager().b(Recipes.SMITHING, this.repairInventory, this.g); List<RecipeSmithing> list = this.g.getCraftingManager().b(Recipes.SMITHING, this.repairInventory, this.g);
if (list.isEmpty()) { if (list.isEmpty()) {
@ -31,13 +31,12 @@
this.resultInventory.a((IRecipe) this.h); this.resultInventory.a((IRecipe) this.h);
- this.resultInventory.setItem(0, itemstack); - this.resultInventory.setItem(0, itemstack);
+ // CraftBukkit start + // CraftBukkit start
+ this.repairInventory.setCurrentRecipe(this.h);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack);
+ // CraftBukkit end + // CraftBukkit end
} }
} }
@@ -85,4 +93,18 @@ @@ -85,4 +92,18 @@
public boolean a(ItemStack itemstack, Slot slot) { public boolean a(ItemStack itemstack, Slot slot) {
return slot.inventory != this.resultInventory && super.a(itemstack, slot); return slot.inventory != this.resultInventory && super.a(itemstack, slot);
} }

View File

@ -1,6 +1,7 @@
package org.bukkit.craftbukkit.inventory; package org.bukkit.craftbukkit.inventory;
import net.minecraft.world.IInventory; import net.minecraft.world.IInventory;
import net.minecraft.world.inventory.InventoryCraftResult;
import net.minecraft.world.item.crafting.IRecipe; import net.minecraft.world.item.crafting.IRecipe;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -11,11 +12,16 @@ public class CraftInventorySmithing extends CraftResultInventory implements Smit
private final Location location; private final Location location;
public CraftInventorySmithing(Location location, IInventory inventory, IInventory resultInventory) { public CraftInventorySmithing(Location location, IInventory inventory, InventoryCraftResult resultInventory) {
super(inventory, resultInventory); super(inventory, resultInventory);
this.location = location; this.location = location;
} }
@Override
public InventoryCraftResult getResultInventory() {
return (InventoryCraftResult) super.getResultInventory();
}
@Override @Override
public Location getLocation() { public Location getLocation() {
return location; return location;
@ -33,7 +39,7 @@ public class CraftInventorySmithing extends CraftResultInventory implements Smit
@Override @Override
public Recipe getRecipe() { public Recipe getRecipe() {
IRecipe recipe = getInventory().getCurrentRecipe(); IRecipe recipe = getResultInventory().ak_();
return (recipe == null) ? null : recipe.toBukkitRecipe(); return (recipe == null) ? null : recipe.toBukkitRecipe();
} }
} }