ForgePatch/patches/minecraft/net/minecraft/network/PacketBuffer.java.patch

48 lines
1.9 KiB
Diff

--- a/net/minecraft/network/PacketBuffer.java
+++ b/net/minecraft/network/PacketBuffer.java
@@ -39,7 +39,7 @@
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
-public class PacketBuffer extends ByteBuf {
+public class PacketBuffer extends ByteBuf implements net.minecraftforge.common.extensions.IForgePacketBuffer {
private final ByteBuf field_150794_a;
public PacketBuffer(ByteBuf p_i45154_1_) {
@@ -292,6 +292,15 @@
}
public PacketBuffer func_150788_a(ItemStack p_150788_1_) {
+ return writeItemStack(p_150788_1_, true);
+ }
+
+ /**
+ * Most ItemStack serialization is Server to Client,and doesn't need to know the FULL tag details.
+ * One exception is items from the creative menu, which must be sent from Client to Server with their full NBT.
+ * If you want to send the FULL tag set limitedTag to false
+ */
+ public PacketBuffer writeItemStack(ItemStack p_150788_1_, boolean limitedTag) {
if (p_150788_1_.func_190926_b()) {
this.writeBoolean(false);
} else {
@@ -300,8 +309,8 @@
this.func_150787_b(Item.func_150891_b(item));
this.writeByte(p_150788_1_.func_190916_E());
CompoundNBT compoundnbt = null;
- if (item.func_77645_m() || item.func_77651_p()) {
- compoundnbt = p_150788_1_.func_77978_p();
+ if (item.isDamageable(p_150788_1_) || item.func_77651_p()) {
+ compoundnbt = limitedTag ? p_150788_1_.getShareTag() : p_150788_1_.func_77978_p();
}
this.func_150786_a(compoundnbt);
@@ -317,7 +326,7 @@
int i = this.func_150792_a();
int j = this.readByte();
ItemStack itemstack = new ItemStack(Item.func_150899_d(i), j);
- itemstack.func_77982_d(this.func_150793_b());
+ itemstack.readShareTag(this.func_150793_b());
return itemstack;
}
}