More progress
This commit is contained in:
@@ -18,7 +18,7 @@ For consistency, the old API methods now forward to use the
|
||||
ItemMeta API equivalents, and should deprecate the old API's.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
|
||||
index 9ebfbff46b..b1dfd64d15 100644
|
||||
index 8e8fab497..0a1596ff0 100644
|
||||
--- a/src/main/java/net/minecraft/server/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/server/ItemStack.java
|
||||
@@ -0,0 +0,0 @@ import com.mojang.brigadier.StringReader;
|
||||
@@ -31,9 +31,9 @@ index 9ebfbff46b..b1dfd64d15 100644
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
@@ -0,0 +0,0 @@ public final class ItemStack {
|
||||
decimalformat.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ROOT));
|
||||
return decimalformat;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ private static final java.util.Comparator<? super NBTTagCompound> enchantSorter = java.util.Comparator.comparing(o -> o.getString("id"));
|
||||
+ private void processEnchantOrder(NBTTagCompound tag) {
|
||||
@@ -50,9 +50,10 @@ index 9ebfbff46b..b1dfd64d15 100644
|
||||
+ } catch (Exception ignored) {}
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
+
|
||||
public ItemStack(IMaterial imaterial) {
|
||||
this(imaterial, 1);
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public final class ItemStack {
|
||||
if (nbttagcompound.hasKeyOfType("tag", 10)) {
|
||||
// CraftBukkit start - make defensive copy as this data may be coming from the save thread
|
||||
@@ -66,9 +67,9 @@ index 9ebfbff46b..b1dfd64d15 100644
|
||||
public void setTag(@Nullable NBTTagCompound nbttagcompound) {
|
||||
this.tag = nbttagcompound;
|
||||
+ processEnchantOrder(this.tag); // Paper
|
||||
}
|
||||
|
||||
public IChatBaseComponent getName() {
|
||||
// CraftBukkit start - ensure null tags do not get inappropriately used (SpigotCraft#463)
|
||||
if (this.tag == null && this.item != null && this.item.usesDurability()) {
|
||||
this.setDamage(this.getDamage());
|
||||
@@ -0,0 +0,0 @@ public final class ItemStack {
|
||||
nbttagcompound.setString("id", String.valueOf(IRegistry.ENCHANTMENT.getKey(enchantment)));
|
||||
nbttagcompound.setShort("lvl", (short) ((byte) i));
|
||||
@@ -78,7 +79,7 @@ index 9ebfbff46b..b1dfd64d15 100644
|
||||
|
||||
public boolean hasEnchantments() {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
index b0f9fa0ecd..9c9852f7a2 100644
|
||||
index 15e3edee2..410444747 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
@@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack {
|
||||
@@ -140,13 +141,7 @@ index b0f9fa0ecd..9c9852f7a2 100644
|
||||
- NBTTagList list = getEnchantmentList(handle), listCopy;
|
||||
- if (list == null) {
|
||||
- return 0;
|
||||
+ // Paper start - replace entire method
|
||||
+ final ItemMeta itemMeta = getItemMeta();
|
||||
+ int level = itemMeta.getEnchantLevel(ench);
|
||||
+ if (level > 0) {
|
||||
+ itemMeta.removeEnchant(ench);
|
||||
+ setItemMeta(itemMeta);
|
||||
}
|
||||
- }
|
||||
- int index = Integer.MIN_VALUE;
|
||||
- int level = Integer.MIN_VALUE;
|
||||
- int size = list.size();
|
||||
@@ -178,11 +173,17 @@ index b0f9fa0ecd..9c9852f7a2 100644
|
||||
- if (i != index) {
|
||||
- listCopy.add(list.get(i));
|
||||
- }
|
||||
- }
|
||||
+ // Paper start - replace entire method
|
||||
+ final ItemMeta itemMeta = getItemMeta();
|
||||
+ int level = itemMeta.getEnchantLevel(ench);
|
||||
+ if (level > 0) {
|
||||
+ itemMeta.removeEnchant(ench);
|
||||
+ setItemMeta(itemMeta);
|
||||
}
|
||||
- handle.getTag().set(ENCHANTMENTS.NBT, listCopy);
|
||||
-
|
||||
return level;
|
||||
+ // Paper end
|
||||
|
||||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,7 +194,7 @@ index b0f9fa0ecd..9c9852f7a2 100644
|
||||
|
||||
static Map<Enchantment, Integer> getEnchantments(net.minecraft.server.ItemStack item) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
index 33c988ead3..479a5686aa 100644
|
||||
index 0f901453d..5ee968f2e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
@@ -0,0 +0,0 @@ import com.google.common.collect.ImmutableList;
|
||||
@@ -204,14 +205,14 @@ index 33c988ead3..479a5686aa 100644
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
@@ -0,0 +0,0 @@ import java.util.ArrayList;
|
||||
@@ -0,0 +0,0 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
+import java.util.Comparator; // Paper
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -0,0 +0,0 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
@@ -306,9 +307,10 @@ index 33c988ead3..479a5686aa 100644
|
||||
if (this.hasAttributeModifiers()) {
|
||||
clone.attributeModifiers = LinkedHashMultimap.create(this.attributeModifiers);
|
||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
return HANDLED_TAGS;
|
||||
}
|
||||
}
|
||||
|
||||
+
|
||||
+ // Paper start
|
||||
+ private static class EnchantmentMap extends TreeMap<Enchantment, Integer> {
|
||||
+ private EnchantmentMap(Map<Enchantment, Integer> enchantments) {
|
||||
@@ -326,7 +328,5 @@ index 33c988ead3..479a5686aa 100644
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
// Spigot start
|
||||
private final Spigot spigot = new Spigot()
|
||||
{
|
||||
}
|
||||
--
|
||||
Reference in New Issue
Block a user