geforkt von Mirrors/Paper
Implement maximum repair cost API to AnvilInventory
Dieser Commit ist enthalten in:
Ursprung
6a0c4e1cc2
Commit
1ceee63341
@ -11,11 +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,14 @@
|
@@ -22,8 +26,15 @@
|
||||||
private int k;
|
private int k;
|
||||||
public String renameText;
|
public String renameText;
|
||||||
private final EntityHuman m;
|
private final EntityHuman m;
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
|
+ public int maximumRepairCost = 40;
|
||||||
+ private int lastLevelCost;
|
+ private int lastLevelCost;
|
||||||
+ private CraftInventoryView bukkitEntity;
|
+ private CraftInventoryView bukkitEntity;
|
||||||
+ private PlayerInventory player;
|
+ private PlayerInventory player;
|
||||||
@ -26,7 +27,7 @@
|
|||||||
this.j = blockposition;
|
this.j = blockposition;
|
||||||
this.i = world;
|
this.i = world;
|
||||||
this.m = entityhuman;
|
this.m = entityhuman;
|
||||||
@@ -111,7 +121,7 @@
|
@@ -111,7 +122,7 @@
|
||||||
byte b1 = 0;
|
byte b1 = 0;
|
||||||
|
|
||||||
if (itemstack.isEmpty()) {
|
if (itemstack.isEmpty()) {
|
||||||
@ -35,7 +36,7 @@
|
|||||||
this.levelCost = 0;
|
this.levelCost = 0;
|
||||||
} else {
|
} else {
|
||||||
ItemStack itemstack1 = itemstack.cloneItemStack();
|
ItemStack itemstack1 = itemstack.cloneItemStack();
|
||||||
@@ -129,7 +139,7 @@
|
@@ -129,7 +140,7 @@
|
||||||
if (itemstack1.e() && itemstack1.getItem().a(itemstack, itemstack2)) {
|
if (itemstack1.e() && itemstack1.getItem().a(itemstack, itemstack2)) {
|
||||||
k = Math.min(itemstack1.getDamage(), itemstack1.h() / 4);
|
k = Math.min(itemstack1.getDamage(), itemstack1.h() / 4);
|
||||||
if (k <= 0) {
|
if (k <= 0) {
|
||||||
@ -44,7 +45,7 @@
|
|||||||
this.levelCost = 0;
|
this.levelCost = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -144,7 +154,7 @@
|
@@ -144,7 +155,7 @@
|
||||||
this.k = l;
|
this.k = l;
|
||||||
} else {
|
} else {
|
||||||
if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.e())) {
|
if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.e())) {
|
||||||
@ -53,7 +54,7 @@
|
|||||||
this.levelCost = 0;
|
this.levelCost = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -237,7 +247,7 @@
|
@@ -237,7 +248,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag2 && !flag1) {
|
if (flag2 && !flag1) {
|
||||||
@ -62,7 +63,22 @@
|
|||||||
this.levelCost = 0;
|
this.levelCost = 0;
|
||||||
return;
|
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);
|
EnchantmentManager.a(map, itemstack1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +87,7 @@
|
|||||||
this.b();
|
this.b();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -302,6 +312,7 @@
|
@@ -302,6 +313,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUse(EntityHuman entityhuman) {
|
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;
|
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();
|
this.d();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.bukkit.craftbukkit.inventory;
|
package org.bukkit.craftbukkit.inventory;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import net.minecraft.server.ContainerAnvil;
|
import net.minecraft.server.ContainerAnvil;
|
||||||
import net.minecraft.server.IInventory;
|
import net.minecraft.server.IInventory;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -71,4 +72,15 @@ public class CraftInventoryAnvil extends CraftInventory implements AnvilInventor
|
|||||||
public void setRepairCost(int i) {
|
public void setRepairCost(int i) {
|
||||||
container.levelCost = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren