mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 02:25:28 +01:00
Implement maximum repair cost API to AnvilInventory
This commit is contained in:
parent
6a0c4e1cc2
commit
1ceee63341
@ -11,11 +11,12 @@
|
||||
public class ContainerAnvil extends Container {
|
||||
|
||||
private static final Logger f = LogManager.getLogger();
|
||||
@@ -22,8 +26,14 @@
|
||||
@@ -22,8 +26,15 @@
|
||||
private int k;
|
||||
public String renameText;
|
||||
private final EntityHuman m;
|
||||
+ // CraftBukkit start
|
||||
+ public int maximumRepairCost = 40;
|
||||
+ private int lastLevelCost;
|
||||
+ private CraftInventoryView bukkitEntity;
|
||||
+ private PlayerInventory player;
|
||||
@ -26,7 +27,7 @@
|
||||
this.j = blockposition;
|
||||
this.i = world;
|
||||
this.m = entityhuman;
|
||||
@@ -111,7 +121,7 @@
|
||||
@@ -111,7 +122,7 @@
|
||||
byte b1 = 0;
|
||||
|
||||
if (itemstack.isEmpty()) {
|
||||
@ -35,7 +36,7 @@
|
||||
this.levelCost = 0;
|
||||
} else {
|
||||
ItemStack itemstack1 = itemstack.cloneItemStack();
|
||||
@@ -129,7 +139,7 @@
|
||||
@@ -129,7 +140,7 @@
|
||||
if (itemstack1.e() && itemstack1.getItem().a(itemstack, itemstack2)) {
|
||||
k = Math.min(itemstack1.getDamage(), itemstack1.h() / 4);
|
||||
if (k <= 0) {
|
||||
@ -44,7 +45,7 @@
|
||||
this.levelCost = 0;
|
||||
return;
|
||||
}
|
||||
@@ -144,7 +154,7 @@
|
||||
@@ -144,7 +155,7 @@
|
||||
this.k = l;
|
||||
} else {
|
||||
if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.e())) {
|
||||
@ -53,7 +54,7 @@
|
||||
this.levelCost = 0;
|
||||
return;
|
||||
}
|
||||
@@ -237,7 +247,7 @@
|
||||
@@ -237,7 +248,7 @@
|
||||
}
|
||||
|
||||
if (flag2 && !flag1) {
|
||||
@ -62,7 +63,22 @@
|
||||
this.levelCost = 0;
|
||||
return;
|
||||
}
|
||||
@@ -284,7 +294,7 @@
|
||||
@@ -261,11 +272,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 (this.levelCost >= 40 && !this.m.abilities.canInstantlyBuild) {
|
||||
+ if (this.levelCost >= maximumRepairCost && !this.m.abilities.canInstantlyBuild) { // CraftBukkit
|
||||
itemstack1 = ItemStack.a;
|
||||
}
|
||||
|
||||
@@ -284,7 +295,7 @@
|
||||
EnchantmentManager.a(map, itemstack1);
|
||||
}
|
||||
|
||||
@ -71,7 +87,7 @@
|
||||
this.b();
|
||||
}
|
||||
}
|
||||
@@ -302,6 +312,7 @@
|
||||
@@ -302,6 +313,7 @@
|
||||
}
|
||||
|
||||
public boolean canUse(EntityHuman entityhuman) {
|
||||
@ -79,7 +95,7 @@
|
||||
return !this.i.getType(this.j).a(TagsBlock.ANVIL) ? false : entityhuman.d((double) this.j.getX() + 0.5D, (double) this.j.getY() + 0.5D, (double) this.j.getZ() + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
@@ -357,4 +368,33 @@
|
||||
@@ -357,4 +369,33 @@
|
||||
|
||||
this.d();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.inventory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.server.ContainerAnvil;
|
||||
import net.minecraft.server.IInventory;
|
||||
import org.bukkit.Location;
|
||||
@ -71,4 +72,15 @@ public class CraftInventoryAnvil extends CraftInventory implements AnvilInventor
|
||||
public void setRepairCost(int i) {
|
||||
container.levelCost = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumRepairCost() {
|
||||
return container.maximumRepairCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaximumRepairCost(int levels) {
|
||||
Preconditions.checkArgument(levels >= 0, "Maximum repair cost must be positive (or 0)");
|
||||
container.maximumRepairCost = levels;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user