ProtocolLib

3M Downloads

SCOREBOARD_OBJECTIVE NumberFormat (Blank, Fixed, Styled) 1.20.4+

LeeTheTech opened this issue ยท 0 comments

commented
  • [ X] This feature is not currently present in a development build

Describe the solution you'd like
Hello! I was hoping a API could be implemented for NumberFormat.

Describe alternatives you've considered
You can do this with reflection but it would be nice if you didn't. Here's an example on 1.20.4 for BlankFormat:

PacketContainer container = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_OBJECTIVE);

Object packet = container.getHandle();
Class<?> packetClass = packet.getClass();

String numberFormatFieldName = "g";
Field numberFormatField = packetClass.getDeclaredField(numberFormatFieldName);
numberFormatField.setAccessible(true);

Class<?> blankFormatClass = Class.forName("net.minecraft.network.chat.numbers.BlankFormat");
Object blankFormatInstance = blankFormatClass.getField("a").get(null);


numberFormatField.set(packet, blankFormatInstance);

Additional context
This feature was added in 1.20.4.
Video: https://youtu.be/PVoFoH8nQ_4?si=uIDbjEDyiPP7h1j3&t=323