13
0
geforkt von Mirrors/Paper

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

By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2021-04-25 08:34:44 +10:00
Ursprung 93ddc2d863
Commit 4d865daa32
3 geänderte Dateien mit 11 neuen und 37 gelöschten Zeilen

Datei anzeigen

@ -1,37 +1,6 @@
--- a/net/minecraft/world/inventory/ContainerAnvilAbstract.java
+++ b/net/minecraft/world/inventory/ContainerAnvilAbstract.java
@@ -11,13 +11,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 @@
@@ -85,6 +85,7 @@
@Override
public boolean canUse(EntityHuman entityhuman) {

Datei anzeigen

@ -18,7 +18,7 @@
public ContainerSmithing(int i, PlayerInventory playerinventory) {
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);
if (list.isEmpty()) {
@ -31,13 +31,12 @@
this.resultInventory.a((IRecipe) this.h);
- this.resultInventory.setItem(0, itemstack);
+ // CraftBukkit start
+ this.repairInventory.setCurrentRecipe(this.h);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack);
+ // CraftBukkit end
}
}
@@ -85,4 +93,18 @@
@@ -85,4 +92,18 @@
public boolean a(ItemStack itemstack, Slot slot) {
return slot.inventory != this.resultInventory && super.a(itemstack, slot);
}

Datei anzeigen

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