2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/PacketDataSerializer.java
|
|
|
|
+++ b/net/minecraft/server/PacketDataSerializer.java
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -26,6 +26,8 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
import java.util.UUID;
|
2016-05-10 13:47:39 +02:00
|
|
|
import javax.annotation.Nullable;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit
|
|
|
|
+
|
|
|
|
public class PacketDataSerializer extends ByteBuf {
|
|
|
|
|
|
|
|
private final ByteBuf a;
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -154,7 +156,7 @@
|
2015-02-26 23:41:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public <T extends Enum<T>> T a(Class<T> oclass) {
|
2019-04-23 04:00:00 +02:00
|
|
|
- return ((Enum[]) oclass.getEnumConstants())[this.i()];
|
|
|
|
+ return ((T[]) oclass.getEnumConstants())[this.i()]; // CraftBukkit - fix decompile error
|
2015-02-26 23:41:06 +01:00
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
public PacketDataSerializer a(Enum<?> oenum) {
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -231,7 +233,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this)));
|
|
|
|
- } catch (IOException ioexception) {
|
|
|
|
+ } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
|
|
|
|
throw new EncoderException(ioexception);
|
|
|
|
}
|
|
|
|
}
|
2020-08-11 23:00:00 +02:00
|
|
|
@@ -268,7 +270,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
public PacketDataSerializer a(ItemStack itemstack) {
|
|
|
|
- if (itemstack.isEmpty()) {
|
|
|
|
+ if (itemstack.isEmpty() || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem()
|
2018-10-22 21:00:00 +02:00
|
|
|
this.writeBoolean(false);
|
2014-11-25 22:32:16 +01:00
|
|
|
} else {
|
2018-10-22 21:00:00 +02:00
|
|
|
this.writeBoolean(true);
|
2020-08-11 23:00:00 +02:00
|
|
|
@@ -297,6 +299,11 @@
|
2018-10-22 21:00:00 +02:00
|
|
|
ItemStack itemstack = new ItemStack(Item.getById(i), b0);
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
itemstack.setTag(this.l());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (itemstack.getTag() != null) {
|
|
|
|
+ CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2016-11-17 02:41:03 +01:00
|
|
|
return itemstack;
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2016-11-17 02:41:03 +01:00
|
|
|
}
|