2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/inventory/ContainerAnvil.java
|
|
|
|
+++ b/net/minecraft/world/inventory/ContainerAnvil.java
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -19,6 +19,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
|
|
|
+
|
2020-06-25 02:00:00 +02:00
|
|
|
public class ContainerAnvil extends ContainerAnvilAbstract {
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2019-04-25 04:00:00 +02:00
|
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -34,6 +38,10 @@
|
|
|
|
private static final int COST_REPAIR_SACRIFICE = 2;
|
|
|
|
private static final int COST_INCOMPATIBLE_PENALTY = 1;
|
|
|
|
private static final int COST_RENAME = 1;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2018-10-06 03:48:54 +02:00
|
|
|
+ public int maximumRepairCost = 40;
|
2016-11-17 02:41:03 +01:00
|
|
|
+ private CraftInventoryView bukkitEntity;
|
2015-02-26 23:41:06 +01:00
|
|
|
+ // CraftBukkit end
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
public ContainerAnvil(int i, PlayerInventory playerinventory) {
|
2021-06-11 07:00:00 +02:00
|
|
|
this(i, playerinventory, ContainerAccess.NULL);
|
|
|
|
@@ -107,7 +115,7 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
byte b1 = 0;
|
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
if (itemstack.isEmpty()) {
|
2021-06-11 07:00:00 +02:00
|
|
|
- this.resultSlots.setItem(0, ItemStack.EMPTY);
|
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit
|
|
|
|
this.cost.set(0);
|
2016-02-29 22:32:46 +01:00
|
|
|
} else {
|
|
|
|
ItemStack itemstack1 = itemstack.cloneItemStack();
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -125,7 +133,7 @@
|
|
|
|
if (itemstack1.f() && itemstack1.getItem().a(itemstack, itemstack2)) {
|
|
|
|
k = Math.min(itemstack1.getDamage(), itemstack1.i() / 4);
|
2016-02-29 22:32:46 +01:00
|
|
|
if (k <= 0) {
|
2021-06-11 07:00:00 +02:00
|
|
|
- this.resultSlots.setItem(0, ItemStack.EMPTY);
|
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit
|
|
|
|
this.cost.set(0);
|
2016-02-29 22:32:46 +01:00
|
|
|
return;
|
|
|
|
}
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -140,7 +148,7 @@
|
|
|
|
this.repairItemCountCost = i1;
|
2016-02-29 22:32:46 +01:00
|
|
|
} else {
|
2021-06-11 07:00:00 +02:00
|
|
|
if (!flag && (!itemstack1.a(itemstack2.getItem()) || !itemstack1.f())) {
|
|
|
|
- this.resultSlots.setItem(0, ItemStack.EMPTY);
|
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit
|
|
|
|
this.cost.set(0);
|
2017-03-24 23:51:02 +01:00
|
|
|
return;
|
|
|
|
}
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -230,7 +238,7 @@
|
2017-03-24 23:51:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flag2 && !flag1) {
|
2021-06-11 07:00:00 +02:00
|
|
|
- this.resultSlots.setItem(0, ItemStack.EMPTY);
|
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit
|
|
|
|
this.cost.set(0);
|
2016-02-29 22:32:46 +01:00
|
|
|
return;
|
|
|
|
}
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -254,11 +262,11 @@
|
|
|
|
itemstack1 = ItemStack.EMPTY;
|
2018-10-06 03:48:54 +02:00
|
|
|
}
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
- if (b1 == i && b1 > 0 && this.cost.get() >= 40) {
|
|
|
|
- this.cost.set(39);
|
|
|
|
+ if (b1 == i && b1 > 0 && this.cost.get() >= maximumRepairCost) { // CraftBukkit
|
|
|
|
+ this.cost.set(maximumRepairCost - 1); // CraftBukkit
|
2018-10-06 03:48:54 +02:00
|
|
|
}
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
- if (this.cost.get() >= 40 && !this.player.getAbilities().instabuild) {
|
|
|
|
+ if (this.cost.get() >= maximumRepairCost && !this.player.getAbilities().instabuild) { // CraftBukkit
|
|
|
|
itemstack1 = ItemStack.EMPTY;
|
2018-10-06 03:48:54 +02:00
|
|
|
}
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -277,7 +285,7 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
EnchantmentManager.a(map, itemstack1);
|
|
|
|
}
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
- this.resultSlots.setItem(0, itemstack1);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), itemstack1); // CraftBukkit
|
2021-06-11 07:00:00 +02:00
|
|
|
this.d();
|
2016-02-29 22:32:46 +01:00
|
|
|
}
|
|
|
|
}
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -304,4 +312,18 @@
|
|
|
|
public int j() {
|
|
|
|
return this.cost.get();
|
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
|
|
|
|
+ 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(
|
2021-06-11 07:00:00 +02:00
|
|
|
+ access.getLocation(), this.inputSlots, this.resultSlots, this);
|
2018-12-13 01:00:00 +01:00
|
|
|
+ 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
|
|
|
}
|