Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 12:30:06 +01:00
Return the level, not ID. Fixes BUKKIT-3326
CraftItemStack was erroneously using the enchantment ID instead of level for the return value of remove enchantment.
Dieser Commit ist enthalten in:
Ursprung
8954cb291c
Commit
bb83795815
@ -220,12 +220,16 @@ public final class CraftItemStack extends ItemStack {
|
||||
if (list == null) {
|
||||
return 0;
|
||||
}
|
||||
int index = Integer.MIN_VALUE, size = list.size(), level;
|
||||
int index = Integer.MIN_VALUE;
|
||||
int level = Integer.MIN_VALUE;
|
||||
int size = list.size();
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
short id = ((NBTTagCompound) list.get(i)).getShort(ENCHANTMENTS_ID.NBT);
|
||||
NBTTagCompound enchantment = (NBTTagCompound) list.get(i);
|
||||
int id = 0xffff & enchantment.getShort(ENCHANTMENTS_ID.NBT);
|
||||
if (id == ench.getId()) {
|
||||
index = i;
|
||||
level = 0xffff & enchantment.getShort(ENCHANTMENTS_LVL.NBT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -233,24 +237,23 @@ public final class CraftItemStack extends ItemStack {
|
||||
if (index == Integer.MIN_VALUE) {
|
||||
return 0;
|
||||
}
|
||||
if (index == 0 && size == 1) {
|
||||
if (size == 1) {
|
||||
handle.tag.o(ENCHANTMENTS.NBT);
|
||||
if (handle.tag.d()) {
|
||||
handle.tag = null;
|
||||
}
|
||||
return ((NBTTagCompound) list.get(0)).getShort(ENCHANTMENTS_ID.NBT);
|
||||
return level;
|
||||
}
|
||||
|
||||
// This is workaround for not having an index removal
|
||||
listCopy = new NBTTagList(ENCHANTMENTS.NBT);
|
||||
level = Integer.MAX_VALUE;
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (i == index) {
|
||||
level = ((NBTTagCompound) list.get(i)).getShort(ENCHANTMENTS_ID.NBT);
|
||||
continue;
|
||||
if (i != index) {
|
||||
listCopy.add(list.get(i));
|
||||
}
|
||||
listCopy.add(list.get(i));
|
||||
}
|
||||
handle.tag.set(ENCHANTMENTS.NBT, listCopy);
|
||||
|
||||
return level;
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren