@Override
 public RecyclableCollection<PacketData> toData(ProtocolVersion version) throws IOException {
   effectId = IdRemapper.EFFECT.getTable(version).getRemap(effectId);
   if (version.isBefore(ProtocolVersion.MINECRAFT_1_9)) {
     effectId = LegacyEffect.getLegacyId(version, effectId);
     if (effectId == 2001) {
       data = IdRemapper.BLOCK.getTable(version).getRemap((data & 0xFFF) << 4) >> 4;
     }
   }
   PacketData serializer = PacketData.create(ClientBoundPacket.PLAY_WORLD_EVENT_ID, version);
   serializer.writeInt(effectId);
   serializer.writePosition(position);
   serializer.writeInt(data);
   serializer.writeBoolean(disableRelative);
   return RecyclableSingletonList.create(serializer);
 }
Example #2
0
 @Override
 public RecyclableCollection<PacketData> toData(ProtocolVersion version) {
   PacketData serializer = PacketData.create(ClientBoundPacket.PLAY_SPAWN_NAMED_ID, version);
   serializer.writeVarInt(playerEntityId);
   serializer.writeString(
       version == ProtocolVersion.MINECRAFT_1_7_10
           ? uuid.toString()
           : uuid.toString().replace("-", ""));
   serializer.writeString(name);
   if (version == ProtocolVersion.MINECRAFT_1_7_10) {
     serializer.writeVarInt(properties.size());
     for (Property property : properties) {
       serializer.writeString(property.getName());
       serializer.writeString(property.getValue());
       serializer.writeString(property.getSignature());
     }
   }
   serializer.writeInt((int) (x * 32));
   serializer.writeInt((int) (y * 32));
   serializer.writeInt((int) (z * 32));
   serializer.writeByte(yaw);
   serializer.writeByte(pitch);
   serializer.writeShort(0);
   serializer.writeBytes(
       LegacyDataWatcherSerializer.encodeData(
           version, WatchedDataRemapper.transform(wplayer, metadata, version)));
   return RecyclableSingletonList.create(serializer);
 }