@@ -10,9 +10,9 @@
|
||||
+
|
||||
public class ContainerAnvil extends Container {
|
||||
|
||||
private static final Logger f = LogManager.getLogger();
|
||||
@@ -22,8 +26,15 @@
|
||||
private int k;
|
||||
private static final Logger c = LogManager.getLogger();
|
||||
@@ -16,6 +20,12 @@
|
||||
private int h;
|
||||
public String renameText;
|
||||
private final EntityHuman player;
|
||||
+ // CraftBukkit start
|
||||
@@ -22,108 +22,98 @@
|
||||
+ private PlayerInventory playerInventory;
|
||||
+ // CraftBukkit end
|
||||
|
||||
public ContainerAnvil(PlayerInventory playerinventory, final World world, final BlockPosition blockposition, EntityHuman entityhuman) {
|
||||
public ContainerAnvil(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, ContainerAccess.a);
|
||||
@@ -23,6 +33,7 @@
|
||||
|
||||
public ContainerAnvil(int i, PlayerInventory playerinventory, final ContainerAccess containeraccess) {
|
||||
super(Containers.ANVIL, i);
|
||||
+ this.playerInventory = playerinventory; // CraftBukkit
|
||||
this.position = blockposition;
|
||||
this.world = world;
|
||||
this.player = entityhuman;
|
||||
@@ -111,7 +122,7 @@
|
||||
this.resultInventory = new InventoryCraftResult();
|
||||
this.repairInventory = new InventorySubcontainer(2) {
|
||||
@Override
|
||||
@@ -123,7 +134,7 @@
|
||||
byte b1 = 0;
|
||||
|
||||
if (itemstack.isEmpty()) {
|
||||
- this.resultInventory.setItem(0, ItemStack.a);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
|
||||
this.levelCost = 0;
|
||||
this.levelCost.a(0);
|
||||
} else {
|
||||
ItemStack itemstack1 = itemstack.cloneItemStack();
|
||||
@@ -129,7 +140,7 @@
|
||||
@@ -141,7 +152,7 @@
|
||||
if (itemstack1.e() && itemstack1.getItem().a(itemstack, itemstack2)) {
|
||||
k = Math.min(itemstack1.getDamage(), itemstack1.h() / 4);
|
||||
if (k <= 0) {
|
||||
- this.resultInventory.setItem(0, ItemStack.a);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
|
||||
this.levelCost = 0;
|
||||
this.levelCost.a(0);
|
||||
return;
|
||||
}
|
||||
@@ -144,7 +155,7 @@
|
||||
this.k = i1;
|
||||
@@ -156,7 +167,7 @@
|
||||
this.h = i1;
|
||||
} else {
|
||||
if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.e())) {
|
||||
- this.resultInventory.setItem(0, ItemStack.a);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
|
||||
this.levelCost = 0;
|
||||
this.levelCost.a(0);
|
||||
return;
|
||||
}
|
||||
@@ -234,7 +245,7 @@
|
||||
@@ -246,7 +257,7 @@
|
||||
}
|
||||
|
||||
if (flag2 && !flag1) {
|
||||
- this.resultInventory.setItem(0, ItemStack.a);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
|
||||
this.levelCost = 0;
|
||||
this.levelCost.a(0);
|
||||
return;
|
||||
}
|
||||
@@ -258,11 +269,11 @@
|
||||
@@ -270,11 +281,11 @@
|
||||
itemstack1 = ItemStack.a;
|
||||
}
|
||||
|
||||
- if (b1 == i && b1 > 0 && this.levelCost >= 40) {
|
||||
- this.levelCost = 39;
|
||||
+ if (b1 == i && b1 > 0 && this.levelCost >= maximumRepairCost) { // CraftBukkit
|
||||
+ this.levelCost = maximumRepairCost - 1; // CraftBukkit
|
||||
- if (b1 == i && b1 > 0 && this.levelCost.b() >= 40) {
|
||||
- this.levelCost.a(39);
|
||||
+ if (b1 == i && b1 > 0 && this.levelCost.b() >= maximumRepairCost) { // CraftBukkit
|
||||
+ this.levelCost.a(maximumRepairCost - 1); // CraftBukkit
|
||||
}
|
||||
|
||||
- if (this.levelCost >= 40 && !this.player.abilities.canInstantlyBuild) {
|
||||
+ if (this.levelCost >= maximumRepairCost && !this.player.abilities.canInstantlyBuild) { // CraftBukkit
|
||||
- if (this.levelCost.b() >= 40 && !this.player.abilities.canInstantlyBuild) {
|
||||
+ if (this.levelCost.b() >= maximumRepairCost && !this.player.abilities.canInstantlyBuild) { // CraftBukkit
|
||||
itemstack1 = ItemStack.a;
|
||||
}
|
||||
|
||||
@@ -281,7 +292,7 @@
|
||||
@@ -293,7 +304,7 @@
|
||||
EnchantmentManager.a(map, itemstack1);
|
||||
}
|
||||
|
||||
- this.resultInventory.setItem(0, itemstack1);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), itemstack1); // CraftBukkit
|
||||
this.b();
|
||||
this.c();
|
||||
}
|
||||
}
|
||||
@@ -299,6 +310,7 @@
|
||||
}
|
||||
@@ -312,6 +323,7 @@
|
||||
|
||||
@Override
|
||||
public boolean canUse(EntityHuman entityhuman) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return !this.world.getType(this.position).a(TagsBlock.ANVIL) ? false : entityhuman.d((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D;
|
||||
}
|
||||
return (Boolean) this.containerAccess.a((world, blockposition) -> {
|
||||
return !world.getType(blockposition).a(TagsBlock.ANVIL) ? false : entityhuman.e((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) <= 64.0D;
|
||||
}, true);
|
||||
@@ -370,4 +382,18 @@
|
||||
|
||||
@@ -354,4 +366,33 @@
|
||||
|
||||
this.d();
|
||||
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);
|
||||
+
|
||||
+ if (this.lastLevelCost != this.levelCost) {
|
||||
+ icrafting.setContainerData(this, 0, this.levelCost);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ this.lastLevelCost = this.levelCost;
|
||||
+ }
|
||||
+
|
||||
+ @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(world.getWorld(), position.getX(), position.getY(), position.getZ()), this.repairInventory, this.resultInventory, this);
|
||||
+ containerAccess.getLocation(), this.repairInventory, this.resultInventory, this);
|
||||
+ bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
|
||||
Reference in New Issue
Block a user