Skip to content

Commit

Permalink
Fix certain NBT read/writes that should be nameless
Browse files Browse the repository at this point in the history
  • Loading branch information
Konicai committed Sep 9, 2023
1 parent fa846a7 commit 8dfcd35
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,15 @@ public ItemStack readItemStack(ByteBuf buf) throws IOException {
}

int item = this.readVarInt(buf);
return new ItemStack(item, buf.readByte(), this.readTag(buf));
return new ItemStack(item, buf.readByte(), this.readAnyTag(buf));
}

public void writeItemStack(ByteBuf buf, ItemStack item) throws IOException {
buf.writeBoolean(item != null);
if (item != null) {
this.writeVarInt(buf, item.getId());
buf.writeByte(item.getAmount());
this.writeTag(buf, item.getNbt());
this.writeAnyTag(buf, item.getNbt());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class MetadataType<T> {
public static final MetadataType<Optional<UUID>> OPTIONAL_UUID = new MetadataType<>(optionalReader(MinecraftCodecHelper::readUUID), optionalWriter(MinecraftCodecHelper::writeUUID), ObjectEntityMetadata::new);
public static final IntMetadataType BLOCK_STATE = new IntMetadataType(MinecraftCodecHelper::readVarInt, MinecraftCodecHelper::writeVarInt, IntEntityMetadata::new);
public static final IntMetadataType OPTIONAL_BLOCK_STATE = new IntMetadataType(MinecraftCodecHelper::readVarInt, MinecraftCodecHelper::writeVarInt, IntEntityMetadata::new);
public static final MetadataType<CompoundTag> NBT_TAG = new MetadataType<>(MinecraftCodecHelper::readTag, MinecraftCodecHelper::writeTag, ObjectEntityMetadata::new);
public static final MetadataType<CompoundTag> NBT_TAG = new MetadataType<>(MinecraftCodecHelper::readAnyTag, MinecraftCodecHelper::writeAnyTag, ObjectEntityMetadata::new);
public static final MetadataType<Particle> PARTICLE = new MetadataType<>(MinecraftCodecHelper::readParticle, MinecraftCodecHelper::writeParticle, ObjectEntityMetadata::new);
public static final MetadataType<VillagerData> VILLAGER_DATA = new MetadataType<>(MinecraftCodecHelper::readVillagerData, MinecraftCodecHelper::writeVillagerData, ObjectEntityMetadata::new);
public static final OptionalIntMetadataType OPTIONAL_VARINT = new OptionalIntMetadataType(ObjectEntityMetadata::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public class ClientboundBlockEntityDataPacket implements MinecraftPacket {
public ClientboundBlockEntityDataPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
this.position = helper.readPosition(in);
this.type = helper.readBlockEntityType(in);
this.nbt = helper.readTag(in);
this.nbt = helper.readAnyTag(in);
}

@Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
helper.writePosition(out, this.position);
helper.writeBlockEntityType(out, this.type);
helper.writeTag(out, this.nbt);
helper.writeAnyTag(out, this.nbt);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ClientboundLevelChunkWithLightPacket(ByteBuf in, MinecraftCodecHelper hel
int blockEntityZ = xz & 15;
int blockEntityY = in.readShort();
BlockEntityType type = helper.readBlockEntityType(in);
CompoundTag tag = helper.readTag(in);
CompoundTag tag = helper.readAnyTag(in);
this.blockEntities[i] = new BlockEntityInfo(blockEntityX, blockEntityY, blockEntityZ, type, tag);
}

Expand All @@ -58,7 +58,7 @@ public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOExcepti
out.writeByte(((blockEntity.getX() & 15) << 4) | blockEntity.getZ() & 15);
out.writeShort(blockEntity.getY());
helper.writeBlockEntityType(out, blockEntity.getType());
helper.writeTag(out, blockEntity.getNbt());
helper.writeAnyTag(out, blockEntity.getNbt());
}

helper.writeLightUpdateData(out, this.lightData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public class ClientboundTagQueryPacket implements MinecraftPacket {

public ClientboundTagQueryPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
this.transactionId = helper.readVarInt(in);
this.nbt = helper.readTag(in);
this.nbt = helper.readAnyTag(in);
}

@Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
helper.writeVarInt(out, this.transactionId);
helper.writeTag(out, this.nbt);
helper.writeAnyTag(out, this.nbt);
}
}

0 comments on commit 8dfcd35

Please sign in to comment.