Add sound id to name mappings as generator for 1.9 thru 1.20 (#17)
* Add sound id to name mappings as generator for 1.9 thru 1.20 * Fix issues in generators * Add generator to all versions. * Fix versions that offset ID by one for network.
This commit is contained in:
@@ -35,6 +35,7 @@ public class DataGenerators {
|
||||
register(new LanguageDataGenerator());
|
||||
register(new InstrumentsDataGenerator());
|
||||
register(new AttributesDataGenerator());
|
||||
register(new SoundsDataGenerator());
|
||||
}
|
||||
|
||||
public static void register(IDataGenerator generator) {
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package dev.u9g.minecraftdatagenerator.generators;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import dev.u9g.minecraftdatagenerator.mixin.SoundAccessor;
|
||||
import net.minecraft.client.sound.SoundEvent;
|
||||
|
||||
|
||||
public class SoundsDataGenerator implements IDataGenerator {
|
||||
|
||||
public static JsonObject generateSound(SoundEvent soundEvent) {
|
||||
JsonObject soundDesc = new JsonObject();
|
||||
|
||||
soundDesc.addProperty("id", SoundEvent.REGISTRY.getRawId(soundEvent));
|
||||
soundDesc.addProperty("name", ((SoundAccessor) soundEvent).id().getPath());
|
||||
|
||||
return soundDesc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataName() {
|
||||
return "sounds";
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonArray generateDataJson() {
|
||||
JsonArray resultsArray = new JsonArray();
|
||||
SoundEvent.REGISTRY.forEach(sound -> resultsArray.add(generateSound(sound)));
|
||||
return resultsArray;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user