2015-05-25 18:37:24 +08:00
|
|
|
--- a/net/minecraft/server/PacketDataSerializer.java
|
|
|
|
+++ b/net/minecraft/server/PacketDataSerializer.java
|
2016-05-10 19:47:39 +08:00
|
|
|
@@ -21,6 +21,8 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
import java.util.UUID;
|
2016-05-10 19:47:39 +08:00
|
|
|
import javax.annotation.Nullable;
|
2014-11-26 05:32:16 +08:00
|
|
|
|
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit
|
|
|
|
+
|
|
|
|
public class PacketDataSerializer extends ByteBuf {
|
|
|
|
|
|
|
|
private final ByteBuf a;
|
2016-06-09 09:43:49 +08:00
|
|
|
@@ -128,7 +130,7 @@
|
2015-02-27 06:41:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public <T extends Enum<T>> T a(Class<T> oclass) {
|
2016-03-01 05:32:46 +08:00
|
|
|
- return ((Enum[]) oclass.getEnumConstants())[this.g()];
|
|
|
|
+ return ((T[]) oclass.getEnumConstants())[this.g()]; // CraftBukkit - fix decompile error
|
2015-02-27 06:41:06 +08:00
|
|
|
}
|
|
|
|
|
2016-03-01 05:32:46 +08:00
|
|
|
public PacketDataSerializer a(Enum<?> oenum) {
|
2016-06-09 09:43:49 +08:00
|
|
|
@@ -205,7 +207,7 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this)));
|
|
|
|
- } catch (IOException ioexception) {
|
|
|
|
+ } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
|
|
|
|
throw new EncoderException(ioexception);
|
|
|
|
}
|
|
|
|
}
|
2016-06-09 09:43:49 +08:00
|
|
|
@@ -232,7 +234,7 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
}
|
|
|
|
|
2016-11-17 09:41:03 +08:00
|
|
|
public PacketDataSerializer a(ItemStack itemstack) {
|
|
|
|
- if (itemstack.isEmpty()) {
|
|
|
|
+ if (itemstack.isEmpty() || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem()
|
2014-11-26 05:32:16 +08:00
|
|
|
this.writeShort(-1);
|
|
|
|
} else {
|
|
|
|
this.writeShort(Item.getId(itemstack.getItem()));
|
2016-06-09 09:43:49 +08:00
|
|
|
@@ -261,6 +263,11 @@
|
2016-11-17 09:41:03 +08:00
|
|
|
ItemStack itemstack = new ItemStack(Item.getById(short0), b0, short1);
|
2014-11-26 05:32:16 +08:00
|
|
|
|
2016-03-01 05:32:46 +08:00
|
|
|
itemstack.setTag(this.j());
|
2014-11-26 05:32:16 +08:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (itemstack.getTag() != null) {
|
|
|
|
+ CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2016-11-17 09:41:03 +08:00
|
|
|
return itemstack;
|
2014-11-26 05:32:16 +08:00
|
|
|
}
|
2016-11-17 09:41:03 +08:00
|
|
|
}
|