package protocolsupport.protocol.packet.middleimpl.clientbound.play.v_4_5_6_7_8;

import protocolsupport.api.ProtocolVersion;
import protocolsupport.protocol.packet.ClientBoundPacket;
import protocolsupport.protocol.packet.middle.clientbound.play.MiddleWorldCustomSound;
import protocolsupport.protocol.packet.middleimpl.ClientBoundPacketData;
import protocolsupport.protocol.serializer.StringSerializer;
import protocolsupport.utils.recyclable.RecyclableCollection;
import protocolsupport.utils.recyclable.RecyclableSingletonList;

public class WorldCustomSound extends MiddleWorldCustomSound {

	@Override
	public RecyclableCollection<ClientBoundPacketData> toData() {
		ProtocolVersion version = connection.getVersion();
		ClientBoundPacketData serializer = ClientBoundPacketData.create(ClientBoundPacket.PLAY_WORLD_CUSTOM_SOUND_ID);
		if (version.isBeforeOrEq(ProtocolVersion.MINECRAFT_1_5_2) && id.length() > 32) {
			id = id.substring(0, 32);
		}
		StringSerializer.writeString(serializer, version, id);
		serializer.writeInt(x);
		serializer.writeInt(y);
		serializer.writeInt(z);
		serializer.writeFloat(volume);
		serializer.writeByte((int) (pitch * 63.5));
		return RecyclableSingletonList.create(serializer);
	}

}

@@ -398,16 +398,52 @@
 alizer;%0A
+import protocolsupport.utils.Utils;%0A
 import p
@@ -929,54 +929,40 @@
 5_2)
- && id.length() %3E 32) %7B%0A%09%09%09id = id.subs
+) %7B%0A%09%09%09id = Utils.clampS
 tring(
-0
+id
 , 32

Use Utils::clampString