2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/ContainerAnvil.java
|
|
|
|
+++ b/net/minecraft/server/ContainerAnvil.java
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -6,6 +6,10 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
+// CraftBukkit start
|
2016-02-29 22:32:46 +01:00
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
|
|
|
+// CraftBukkit end
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
public class ContainerAnvil extends Container {
|
|
|
|
|
|
|
|
private static final Logger f = LogManager.getLogger();
|
2018-10-06 03:48:54 +02:00
|
|
|
@@ -22,8 +26,15 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
private int k;
|
2017-05-14 04:00:00 +02:00
|
|
|
public String renameText;
|
2018-12-13 01:00:00 +01:00
|
|
|
private final EntityHuman player;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2018-10-06 03:48:54 +02:00
|
|
|
+ public int maximumRepairCost = 40;
|
2017-06-23 12:35:17 +02:00
|
|
|
+ private int lastLevelCost;
|
2016-11-17 02:41:03 +01:00
|
|
|
+ private CraftInventoryView bukkitEntity;
|
2018-12-13 01:00:00 +01:00
|
|
|
+ private PlayerInventory playerInventory;
|
2015-02-26 23:41:06 +01:00
|
|
|
+ // CraftBukkit end
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
public ContainerAnvil(PlayerInventory playerinventory, final World world, final BlockPosition blockposition, EntityHuman entityhuman) {
|
2018-12-13 01:00:00 +01:00
|
|
|
+ this.playerInventory = playerinventory; // CraftBukkit
|
|
|
|
this.position = blockposition;
|
|
|
|
this.world = world;
|
|
|
|
this.player = entityhuman;
|
2018-10-06 03:48:54 +02:00
|
|
|
@@ -111,7 +122,7 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
byte b1 = 0;
|
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
if (itemstack.isEmpty()) {
|
2018-12-13 01:00:00 +01:00
|
|
|
- this.resultInventory.setItem(0, ItemStack.a);
|
2016-11-17 02:41:03 +01:00
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
|
2017-05-14 04:00:00 +02:00
|
|
|
this.levelCost = 0;
|
2016-02-29 22:32:46 +01:00
|
|
|
} else {
|
|
|
|
ItemStack itemstack1 = itemstack.cloneItemStack();
|
2018-10-06 03:48:54 +02:00
|
|
|
@@ -129,7 +140,7 @@
|
2018-07-15 02:00:00 +02:00
|
|
|
if (itemstack1.e() && itemstack1.getItem().a(itemstack, itemstack2)) {
|
|
|
|
k = Math.min(itemstack1.getDamage(), itemstack1.h() / 4);
|
2016-02-29 22:32:46 +01:00
|
|
|
if (k <= 0) {
|
2018-12-13 01:00:00 +01:00
|
|
|
- this.resultInventory.setItem(0, ItemStack.a);
|
2016-11-17 02:41:03 +01:00
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
|
2017-05-14 04:00:00 +02:00
|
|
|
this.levelCost = 0;
|
2016-02-29 22:32:46 +01:00
|
|
|
return;
|
|
|
|
}
|
2018-10-06 03:48:54 +02:00
|
|
|
@@ -144,7 +155,7 @@
|
2018-12-06 00:00:00 +01:00
|
|
|
this.k = i1;
|
2016-02-29 22:32:46 +01:00
|
|
|
} else {
|
2018-07-15 02:00:00 +02:00
|
|
|
if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.e())) {
|
2018-12-13 01:00:00 +01:00
|
|
|
- this.resultInventory.setItem(0, ItemStack.a);
|
2017-03-24 23:51:02 +01:00
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
|
2017-05-14 04:00:00 +02:00
|
|
|
this.levelCost = 0;
|
2017-03-24 23:51:02 +01:00
|
|
|
return;
|
|
|
|
}
|
2018-12-06 00:00:00 +01:00
|
|
|
@@ -234,7 +245,7 @@
|
2017-03-24 23:51:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flag2 && !flag1) {
|
2018-12-13 01:00:00 +01:00
|
|
|
- this.resultInventory.setItem(0, ItemStack.a);
|
2016-11-17 02:41:03 +01:00
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
|
2017-05-14 04:00:00 +02:00
|
|
|
this.levelCost = 0;
|
2016-02-29 22:32:46 +01:00
|
|
|
return;
|
|
|
|
}
|
2018-12-06 00:00:00 +01:00
|
|
|
@@ -258,11 +269,11 @@
|
2018-10-06 03:48:54 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2018-12-13 01:00:00 +01:00
|
|
|
- if (this.levelCost >= 40 && !this.player.abilities.canInstantlyBuild) {
|
|
|
|
+ if (this.levelCost >= maximumRepairCost && !this.player.abilities.canInstantlyBuild) { // CraftBukkit
|
2018-10-06 03:48:54 +02:00
|
|
|
itemstack1 = ItemStack.a;
|
|
|
|
}
|
|
|
|
|
2018-12-06 00:00:00 +01:00
|
|
|
@@ -281,7 +292,7 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
EnchantmentManager.a(map, itemstack1);
|
|
|
|
}
|
|
|
|
|
2018-12-13 01:00:00 +01:00
|
|
|
- this.resultInventory.setItem(0, itemstack1);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), itemstack1); // CraftBukkit
|
|
|
|
this.b();
|
|
|
|
}
|
|
|
|
}
|
2018-12-06 00:00:00 +01:00
|
|
|
@@ -299,6 +310,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2017-09-18 12:00:00 +02:00
|
|
|
public boolean canUse(EntityHuman entityhuman) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (!this.checkReachable) return true; // CraftBukkit
|
2018-12-13 01:00:00 +01:00
|
|
|
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;
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2018-12-06 00:00:00 +01:00
|
|
|
@@ -354,4 +366,33 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
this.d();
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2016-11-17 02:41:03 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ @Override
|
2016-11-30 06:40:40 +01:00
|
|
|
+ public void b() {
|
|
|
|
+ super.b();
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < this.listeners.size(); ++i) {
|
|
|
|
+ ICrafting icrafting = (ICrafting) this.listeners.get(i);
|
|
|
|
+
|
2017-06-23 12:35:17 +02:00
|
|
|
+ if (this.lastLevelCost != this.levelCost) {
|
|
|
|
+ icrafting.setContainerData(this, 0, this.levelCost);
|
|
|
|
+ }
|
2016-11-30 06:40:40 +01:00
|
|
|
+ }
|
2017-06-23 12:35:17 +02:00
|
|
|
+
|
|
|
|
+ this.lastLevelCost = this.levelCost;
|
2016-11-30 06:40:40 +01:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2014-11-25 22:32:16 +01:00
|
|
|
+ public CraftInventoryView getBukkitView() {
|
|
|
|
+ if (bukkitEntity != null) {
|
|
|
|
+ return bukkitEntity;
|
|
|
|
+ }
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryAnvil(
|
2018-12-13 01:00:00 +01:00
|
|
|
+ new org.bukkit.Location(world.getWorld(), position.getX(), position.getY(), position.getZ()), this.repairInventory, this.resultInventory, this);
|
|
|
|
+ bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ return bukkitEntity;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2016-11-17 02:41:03 +01:00
|
|
|
}
|