Add some expansions to Anvil Inventory API

This commit is contained in:
Xor Boole 2016-11-30 16:40:40 +11:00 committed by md_5
parent 6d5a66f00f
commit eb6c1bf31a
2 changed files with 38 additions and 6 deletions

View File

@ -11,9 +11,12 @@
public class ContainerAnvil extends Container {
private static final Logger f = LogManager.getLogger();
@@ -22,8 +26,13 @@
@@ -20,10 +24,15 @@
private final BlockPosition j;
public int a;
private int k;
private String l;
- private String l;
+ public String l; // PAIL: private -> public
private final EntityHuman m;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity;
@ -69,20 +72,31 @@
return this.i.getType(this.j).getBlock() != Blocks.ANVIL ? false : entityhuman.d((double) this.j.getX() + 0.5D, (double) this.j.getY() + 0.5D, (double) this.j.getZ() + 0.5D) <= 64.0D;
}
@@ -350,4 +360,18 @@
@@ -350,4 +360,29 @@
this.e();
}
+
+ // CraftBukkit start
+ @Override
+ public void b() {
+ super.b();
+
+ for (int i = 0; i < this.listeners.size(); ++i) {
+ ICrafting icrafting = (ICrafting) this.listeners.get(i);
+
+ icrafting.setContainerData(this, 0, this.a);
+ }
+ }
+
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryAnvil(
+ new org.bukkit.Location(i.getWorld(), j.getX(), j.getY(), j.getZ()), this.h, this.g);
+ new org.bukkit.Location(i.getWorld(), j.getX(), j.getY(), j.getZ()), this.h, this.g, this);
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }

View File

@ -1,19 +1,22 @@
package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.ContainerAnvil;
import net.minecraft.server.IInventory;
import org.bukkit.Location;
import org.bukkit.inventory.AnvilInventory;
import org.bukkit.inventory.ItemStack;
public class CraftInventoryAnvil extends CraftInventory implements AnvilInventory {
private final Location location;
private final IInventory resultInventory;
private final ContainerAnvil container;
public CraftInventoryAnvil(Location location, IInventory inventory, IInventory resultInventory) {
public CraftInventoryAnvil(Location location, IInventory inventory, IInventory resultInventory, ContainerAnvil container) {
super(inventory);
this.location = location;
this.resultInventory = resultInventory;
this.container = container;
}
public IInventory getResultInventory() {
@ -53,4 +56,19 @@ public class CraftInventoryAnvil extends CraftInventory implements AnvilInventor
public Location getLocation() {
return location;
}
@Override
public String getRenameText() {
return container.l; // PAIL: renameText
}
@Override
public int getRepairCost() {
return container.a; // PAIL: levelCost
}
@Override
public void setRepairCost(int i) {
container.a = i; // PAIL:levelCost
}
}