3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 20:40:08 +01:00

Add some expansions to Anvil Inventory API

Dieser Commit ist enthalten in:
Xor Boole 2016-11-30 16:40:40 +11:00 committet von md_5
Ursprung 6d5a66f00f
Commit eb6c1bf31a
2 geänderte Dateien mit 38 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -11,9 +11,12 @@
public class ContainerAnvil extends Container { public class ContainerAnvil extends Container {
private static final Logger f = LogManager.getLogger(); 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 int k;
private String l; - private String l;
+ public String l; // PAIL: private -> public
private final EntityHuman m; private final EntityHuman m;
+ // CraftBukkit start + // CraftBukkit start
+ private CraftInventoryView bukkitEntity; + 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; 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(); this.e();
} }
+ +
+ // CraftBukkit start + // CraftBukkit start
+ @Override + @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() { + public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) { + if (bukkitEntity != null) {
+ return bukkitEntity; + return bukkitEntity;
+ } + }
+ +
+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryAnvil( + 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); + bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity; + return bukkitEntity;
+ } + }

Datei anzeigen

@ -1,19 +1,22 @@
package org.bukkit.craftbukkit.inventory; package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.ContainerAnvil;
import net.minecraft.server.IInventory; import net.minecraft.server.IInventory;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.inventory.AnvilInventory; import org.bukkit.inventory.AnvilInventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class CraftInventoryAnvil extends CraftInventory implements AnvilInventory { public class CraftInventoryAnvil extends CraftInventory implements AnvilInventory {
private final Location location; private final Location location;
private final IInventory resultInventory; 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); super(inventory);
this.location = location; this.location = location;
this.resultInventory = resultInventory; this.resultInventory = resultInventory;
this.container = container;
} }
public IInventory getResultInventory() { public IInventory getResultInventory() {
@ -53,4 +56,19 @@ public class CraftInventoryAnvil extends CraftInventory implements AnvilInventor
public Location getLocation() { public Location getLocation() {
return location; 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
}
} }