Fix ItemStack Data Conversion
Spigot did not copy our version, and their version is not 100% correct. The current state results in item meta and damage data value conversions clashing for control For example on a horse egg, on itemstack creation, the 100 Damage is converted to 0 and sets EntityTag SetItemMeta then drops the previous NBTTagCompound and makes a new one, which has no EntityType associated to it as the previous stack had no metadata. This change makes it so that itemstack conversion is delayed until after meta applies Pretty much restores our previous implementation before Spigot tried to resolve it.
Dieser Commit ist enthalten in:
Ursprung
cd8f388582
Commit
ef781648ef
71
Spigot-Server-Patches/0198-Fix-ItemStack-Data-Conversion.patch
Normale Datei
71
Spigot-Server-Patches/0198-Fix-ItemStack-Data-Conversion.patch
Normale Datei
@ -0,0 +1,71 @@
|
|||||||
|
From 976cceb1eaba63b9e7bcf5726db579aaf9bc2069 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Aikar <aikar@aikar.co>
|
||||||
|
Date: Thu, 29 Dec 2016 07:54:48 -0500
|
||||||
|
Subject: [PATCH] Fix ItemStack Data Conversion
|
||||||
|
|
||||||
|
Spigot did not copy our version, and their version is not 100% correct.
|
||||||
|
|
||||||
|
The current state results in item meta and damage data value conversions clashing for control
|
||||||
|
|
||||||
|
For example on a horse egg, on itemstack creation, the 100 Damage is converted to 0 and sets EntityTag
|
||||||
|
|
||||||
|
SetItemMeta then drops the previous NBTTagCompound and makes a new one, which has no EntityType associated
|
||||||
|
to it as the previous stack had no metadata.
|
||||||
|
|
||||||
|
This change makes it so that itemstack conversion is delayed until after meta applies
|
||||||
|
|
||||||
|
Pretty much restores our previous implementation before Spigot tried to resolve it.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
|
||||||
|
index 6db93b953..2d7cac940 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/ItemStack.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/ItemStack.java
|
||||||
|
@@ -56,6 +56,9 @@ public final class ItemStack {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack(Item item, int i, int j) {
|
||||||
|
+ this(item, i, j, true); // Paper
|
||||||
|
+ }
|
||||||
|
+ public ItemStack(Item item, int i, int j, boolean convert) { // Paper
|
||||||
|
this.item = item;
|
||||||
|
this.damage = j;
|
||||||
|
this.count = i;
|
||||||
|
@@ -63,7 +66,7 @@ public final class ItemStack {
|
||||||
|
if (MinecraftServer.getServer() != null) {
|
||||||
|
this.setData(j);
|
||||||
|
}
|
||||||
|
- this.convertStack();
|
||||||
|
+ if (convert) this.convertStack(); // Paper
|
||||||
|
// CraftBukkit end
|
||||||
|
if (this.damage < 0) {
|
||||||
|
// this.damage = 0; // CraftBukkit - remove this.
|
||||||
|
@@ -454,7 +457,7 @@ public final class ItemStack {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack cloneItemStack() {
|
||||||
|
- ItemStack itemstack = new ItemStack(this.item, this.count, this.damage);
|
||||||
|
+ ItemStack itemstack = new ItemStack(this.item, this.count, this.damage, false); // Paper - no need to convert a clone
|
||||||
|
|
||||||
|
if (this.tag != null) {
|
||||||
|
itemstack.tag = this.tag.g();
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||||
|
index fafc6b68d..dc1c416c7 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||||
|
@@ -41,10 +41,11 @@ public final class CraftItemStack extends ItemStack {
|
||||||
|
return net.minecraft.server.ItemStack.a;
|
||||||
|
}
|
||||||
|
|
||||||
|
- net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(item, original.getAmount(), original.getDurability());
|
||||||
|
+ net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(item, original.getAmount(), original.getDurability(), false); // Paper
|
||||||
|
if (original.hasItemMeta()) {
|
||||||
|
setItemMeta(stack, original.getItemMeta());
|
||||||
|
- }
|
||||||
|
+ } else { stack.convertStack(); } // Paper - setItemMeta will convert also
|
||||||
|
+
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.11.0
|
||||||
|
|
In neuem Issue referenzieren
Einen Benutzer sperren