I want to get SoundType from config, I writed this code:
System.out.println("Getted by registry: " + Sponge.getGame().getRegistry(). getAllFor(scroll_sound_node.getString(), SoundType.class).size()); System.out.println("Getted by config: " + scroll_sound_node.getValue(TypeToken.of(SoundType.class)));
Nothing of this works, first saying that size of returned collection is 0, second throws exception:
Caused by: ninja.leaping.configurate.objectmapping.ObjectMappingException: Input 'ENTITY_EXPERIENCE_ORB_PICKUP' was not a valid value for type org.spongepowered.api.effect.sound.SoundType
Well, that’s because the ID isn’t ENTITY_EXPERIENCE_ORB_PICKUP
. I do not know why you thought the name of a static field of a different class has anything to do with the ID. The ID of the experience orb pickup sound is just as it is in the vanilla /playsound command, i.e. entity.experience_orb.pickup
Hm, yes, “entity.experience_orb.pickup” works…
Can you please post, where is list of “true” ID`s for SoundType?
What he means is that the field names aren’t the actual id’s used. You can get them by referencing the fields and calling getId()
. For example: ItemTypes.DIAMOND_SWORD.getId()
or SoundTypes.BLOCK_ANVIL_HIT.getId()
.
That is exactly what you need.
For future reference, static field names of catalog classes are in no way related to the actual IDs of the CatalogType values they hold. The Minecraft ID is used for things whenever possible, we try not to invent our own.