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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ public class DataGenerators {
|
||||
register(new TintsDataGenerator());
|
||||
register(new LanguageDataGenerator());
|
||||
register(new InstrumentsDataGenerator());
|
||||
register(new SoundsDataGenerator());
|
||||
}
|
||||
|
||||
public static void register(IDataGenerator generator) {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
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;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
|
||||
public class SoundsDataGenerator implements IDataGenerator {
|
||||
|
||||
public static JsonObject generateSound(Registry<SoundEvent> registry, SoundEvent soundEvent) {
|
||||
JsonObject soundDesc = new JsonObject();
|
||||
|
||||
soundDesc.addProperty("id", 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();
|
||||
Registry<SoundEvent> soundEventRegistry = Registry.SOUND_EVENT;
|
||||
soundEventRegistry.forEach(sound -> resultsArray.add(generateSound(soundEventRegistry, (SoundEvent) sound)));
|
||||
return resultsArray;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package dev.u9g.minecraftdatagenerator.mixin;
|
||||
|
||||
import net.minecraft.client.sound.SoundEvent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(SoundEvent.class)
|
||||
public interface SoundAccessor {
|
||||
@Accessor("id")
|
||||
Identifier id();
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
"mixins": [
|
||||
"MiningToolItemAccessor",
|
||||
"ReadyMixin",
|
||||
"SoundAccessor",
|
||||
"StatusEffectAccessor"
|
||||
],
|
||||
"client": [
|
||||
|
||||
@@ -34,6 +34,7 @@ public class DataGenerators {
|
||||
register(new TintsDataGenerator());
|
||||
register(new LanguageDataGenerator());
|
||||
register(new InstrumentsDataGenerator());
|
||||
register(new SoundsDataGenerator());
|
||||
}
|
||||
|
||||
public static void register(IDataGenerator generator) {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package dev.u9g.minecraftdatagenerator.generators;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import dev.u9g.minecraftdatagenerator.mixin.SoundAccessor;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
|
||||
public class SoundsDataGenerator implements IDataGenerator {
|
||||
|
||||
public static JsonObject generateSound(Registry<SoundEvent> registry, SoundEvent soundEvent) {
|
||||
JsonObject soundDesc = new JsonObject();
|
||||
|
||||
soundDesc.addProperty("id", 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();
|
||||
Registry<SoundEvent> soundEventRegistry = Registry.SOUND_EVENT;
|
||||
soundEventRegistry.forEach(sound -> resultsArray.add(generateSound(soundEventRegistry, sound)));
|
||||
return resultsArray;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.u9g.minecraftdatagenerator.mixin;
|
||||
|
||||
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(SoundEvent.class)
|
||||
public interface SoundAccessor {
|
||||
@Accessor("id")
|
||||
Identifier id();
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
"mixins": [
|
||||
"MiningToolItemAccessor",
|
||||
"ReadyMixin",
|
||||
"SoundAccessor",
|
||||
"StatusEffectAccessor"
|
||||
],
|
||||
"client": [
|
||||
|
||||
@@ -34,6 +34,7 @@ public class DataGenerators {
|
||||
register(new TintsDataGenerator());
|
||||
register(new LanguageDataGenerator());
|
||||
register(new InstrumentsDataGenerator());
|
||||
register(new SoundsDataGenerator());
|
||||
}
|
||||
|
||||
public static void register(IDataGenerator generator) {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package dev.u9g.minecraftdatagenerator.generators;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import dev.u9g.minecraftdatagenerator.mixin.SoundAccessor;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
|
||||
public class SoundsDataGenerator implements IDataGenerator {
|
||||
|
||||
public static JsonObject generateSound(Registry<SoundEvent> registry, SoundEvent soundEvent) {
|
||||
JsonObject soundDesc = new JsonObject();
|
||||
|
||||
soundDesc.addProperty("id", 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();
|
||||
Registry<SoundEvent> soundEventRegistry = Registry.SOUND_EVENT;
|
||||
soundEventRegistry.forEach(sound -> resultsArray.add(generateSound(soundEventRegistry, sound)));
|
||||
return resultsArray;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.u9g.minecraftdatagenerator.mixin;
|
||||
|
||||
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(SoundEvent.class)
|
||||
public interface SoundAccessor {
|
||||
@Accessor("id")
|
||||
Identifier id();
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
"mixins": [
|
||||
"MiningToolItemAccessor",
|
||||
"ReadyMixin",
|
||||
"SoundAccessor",
|
||||
"StatusEffectAccessor"
|
||||
],
|
||||
"client": [
|
||||
|
||||
@@ -34,6 +34,7 @@ public class DataGenerators {
|
||||
register(new TintsDataGenerator());
|
||||
register(new LanguageDataGenerator());
|
||||
register(new InstrumentsDataGenerator());
|
||||
register(new SoundsDataGenerator());
|
||||
}
|
||||
|
||||
public static void register(IDataGenerator generator) {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package dev.u9g.minecraftdatagenerator.generators;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import dev.u9g.minecraftdatagenerator.mixin.SoundAccessor;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
|
||||
public class SoundsDataGenerator implements IDataGenerator {
|
||||
|
||||
public static JsonObject generateSound(Registry<SoundEvent> registry, SoundEvent soundEvent) {
|
||||
JsonObject soundDesc = new JsonObject();
|
||||
|
||||
soundDesc.addProperty("id", 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();
|
||||
Registry<SoundEvent> soundEventRegistry = Registry.SOUND_EVENT;
|
||||
soundEventRegistry.forEach(sound -> resultsArray.add(generateSound(soundEventRegistry, sound)));
|
||||
return resultsArray;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.u9g.minecraftdatagenerator.mixin;
|
||||
|
||||
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(SoundEvent.class)
|
||||
public interface SoundAccessor {
|
||||
@Accessor("id")
|
||||
Identifier id();
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
"EULAMixin",
|
||||
"MiningToolItemAccessor",
|
||||
"ReadyMixin",
|
||||
"SoundAccessor",
|
||||
"StatusEffectAccessor"
|
||||
],
|
||||
"client": [
|
||||
|
||||
@@ -3,6 +3,7 @@ package dev.u9g.minecraftdatagenerator.generators;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.internal.Streams;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import org.lwjgl.system.CallbackI;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -34,6 +35,7 @@ public class DataGenerators {
|
||||
// register(new RecipeDataGenerator()); - On hold until mcdata supports multiple materials for a recipe
|
||||
register(new LanguageDataGenerator());
|
||||
register(new InstrumentsDataGenerator());
|
||||
register(new SoundsDataGenerator());
|
||||
}
|
||||
|
||||
public static void register(IDataGenerator generator) {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package dev.u9g.minecraftdatagenerator.generators;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import dev.u9g.minecraftdatagenerator.mixin.SoundAccessor;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
|
||||
public class SoundsDataGenerator implements IDataGenerator {
|
||||
|
||||
public static JsonObject generateSound(Registry<SoundEvent> registry, SoundEvent soundEvent) {
|
||||
JsonObject soundDesc = new JsonObject();
|
||||
|
||||
soundDesc.addProperty("id", 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();
|
||||
Registry<SoundEvent> soundEventRegistry = Registry.SOUND_EVENT;
|
||||
soundEventRegistry.forEach(sound -> resultsArray.add(generateSound(soundEventRegistry, sound)));
|
||||
return resultsArray;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.u9g.minecraftdatagenerator.mixin;
|
||||
|
||||
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(SoundEvent.class)
|
||||
public interface SoundAccessor {
|
||||
@Accessor("id")
|
||||
Identifier id();
|
||||
}
|
||||
@@ -6,7 +6,8 @@
|
||||
"mixins": [
|
||||
"ClientPlayerInteractionManagerMixin",
|
||||
"MiningToolItemAccessor",
|
||||
"ReadyMixin"
|
||||
"ReadyMixin",
|
||||
"SoundAccessor"
|
||||
],
|
||||
"client": [
|
||||
],
|
||||
|
||||
@@ -33,6 +33,7 @@ public class DataGenerators {
|
||||
// register(new RecipeDataGenerator()); - On hold until mcdata supports multiple materials for a recipe
|
||||
register(new LanguageDataGenerator());
|
||||
register(new InstrumentsDataGenerator());
|
||||
register(new SoundsDataGenerator());
|
||||
}
|
||||
|
||||
public static void register(IDataGenerator generator) {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package dev.u9g.minecraftdatagenerator.generators;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import dev.u9g.minecraftdatagenerator.mixin.SoundAccessor;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
|
||||
public class SoundsDataGenerator implements IDataGenerator {
|
||||
|
||||
public static JsonObject generateSound(Registry<SoundEvent> registry, SoundEvent soundEvent) {
|
||||
JsonObject soundDesc = new JsonObject();
|
||||
|
||||
soundDesc.addProperty("id", 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();
|
||||
Registry<SoundEvent> soundEventRegistry = Registry.SOUND_EVENT;
|
||||
soundEventRegistry.forEach(sound -> resultsArray.add(generateSound(soundEventRegistry, sound)));
|
||||
return resultsArray;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.u9g.minecraftdatagenerator.mixin;
|
||||
|
||||
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(SoundEvent.class)
|
||||
public interface SoundAccessor {
|
||||
@Accessor("id")
|
||||
Identifier id();
|
||||
}
|
||||
@@ -7,7 +7,8 @@
|
||||
"ClientPlayerInteractionManagerMixin",
|
||||
"EULAMixin",
|
||||
"MiningToolItemAccessor",
|
||||
"ReadyMixin"
|
||||
"ReadyMixin",
|
||||
"SoundAccessor"
|
||||
],
|
||||
"client": [
|
||||
],
|
||||
|
||||
@@ -34,6 +34,7 @@ public class DataGenerators {
|
||||
// register(new RecipeDataGenerator()); - On hold until mcdata supports multiple materials for a recipe
|
||||
register(new LanguageDataGenerator());
|
||||
register(new InstrumentsDataGenerator());
|
||||
register(new SoundsDataGenerator());
|
||||
}
|
||||
|
||||
public static void register(IDataGenerator generator) {
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package dev.u9g.minecraftdatagenerator.generators;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
|
||||
public class SoundsDataGenerator implements IDataGenerator {
|
||||
|
||||
public static JsonObject generateSound(Registry<SoundEvent> registry, SoundEvent soundEvent) {
|
||||
JsonObject soundDesc = new JsonObject();
|
||||
|
||||
soundDesc.addProperty("id", registry.getRawId(soundEvent)+1); // the plus 1 is required for 1.19.2+ due to Mojang using 0 in the packet to say that you should read a string id instead.
|
||||
soundDesc.addProperty("name", soundEvent.getId().getPath());
|
||||
|
||||
return soundDesc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataName() {
|
||||
return "sounds";
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonArray generateDataJson() {
|
||||
JsonArray resultsArray = new JsonArray();
|
||||
Registry<SoundEvent> soundEventRegistry = Registry.SOUND_EVENT;
|
||||
soundEventRegistry.forEach(sound -> resultsArray.add(generateSound(soundEventRegistry, sound)));
|
||||
return resultsArray;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ public class DataGenerators {
|
||||
// register(new RecipeDataGenerator()); - On hold until mcdata supports multiple materials for a recipe
|
||||
register(new LanguageDataGenerator());
|
||||
register(new InstrumentsDataGenerator());
|
||||
register(new SoundsDataGenerator());
|
||||
}
|
||||
|
||||
public static void register(IDataGenerator generator) {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package dev.u9g.minecraftdatagenerator.generators;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
|
||||
public class SoundsDataGenerator implements IDataGenerator {
|
||||
|
||||
public static JsonObject generateSound(Registry<SoundEvent> registry, SoundEvent soundEvent) {
|
||||
JsonObject soundDesc = new JsonObject();
|
||||
|
||||
soundDesc.addProperty("id", registry.getRawId(soundEvent));
|
||||
soundDesc.addProperty("name", soundEvent.getId().getPath());
|
||||
|
||||
return soundDesc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataName() {
|
||||
return "sounds";
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonArray generateDataJson() {
|
||||
JsonArray resultsArray = new JsonArray();
|
||||
Registry<SoundEvent> soundEventRegistry = Registry.SOUND_EVENT;
|
||||
soundEventRegistry.forEach(sound -> resultsArray.add(generateSound(soundEventRegistry, sound)));
|
||||
return resultsArray;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ public class DataGenerators {
|
||||
// register(new RecipeDataGenerator()); - On hold until mcdata supports multiple materials for a recipe
|
||||
register(new LanguageDataGenerator());
|
||||
register(new InstrumentsDataGenerator());
|
||||
register(new SoundsDataGenerator());
|
||||
}
|
||||
|
||||
public static void register(IDataGenerator generator) {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package dev.u9g.minecraftdatagenerator.generators;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import dev.u9g.minecraftdatagenerator.util.DGU;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
|
||||
public class SoundsDataGenerator implements IDataGenerator {
|
||||
|
||||
public static JsonObject generateSound(Registry<SoundEvent> registry, SoundEvent soundEvent) {
|
||||
JsonObject soundDesc = new JsonObject();
|
||||
|
||||
soundDesc.addProperty("id", registry.getRawId(soundEvent)+1); // the plus 1 is required for 1.19.2+ due to Mojang using 0 in the packet to say that you should read a string id instead.
|
||||
soundDesc.addProperty("name", soundEvent.getId().getPath());
|
||||
|
||||
return soundDesc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataName() {
|
||||
return "sounds";
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonArray generateDataJson() {
|
||||
JsonArray resultsArray = new JsonArray();
|
||||
Registry<SoundEvent> soundEventRegistry = DGU.getWorld().getRegistryManager().get(RegistryKeys.SOUND_EVENT);
|
||||
soundEventRegistry.forEach(sound -> resultsArray.add(generateSound(soundEventRegistry, sound)));
|
||||
return resultsArray;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ public class DataGenerators {
|
||||
// register(new RecipeDataGenerator()); - On hold until mcdata supports multiple materials for a recipe
|
||||
register(new LanguageDataGenerator());
|
||||
register(new InstrumentsDataGenerator());
|
||||
register(new SoundsDataGenerator());
|
||||
}
|
||||
|
||||
public static void register(IDataGenerator generator) {
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package dev.u9g.minecraftdatagenerator.generators;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
|
||||
public class SoundsDataGenerator implements IDataGenerator {
|
||||
|
||||
public static JsonObject generateSound(Registry<SoundEvent> registry, SoundEvent soundEvent) {
|
||||
JsonObject soundDesc = new JsonObject();
|
||||
|
||||
soundDesc.addProperty("id", registry.getRawId(soundEvent));
|
||||
soundDesc.addProperty("name", soundEvent.getId().getPath());
|
||||
|
||||
return soundDesc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataName() {
|
||||
return "sounds";
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonArray generateDataJson() {
|
||||
JsonArray resultsArray = new JsonArray();
|
||||
Registry<SoundEvent> soundEventRegistry = Registry.SOUND_EVENT;
|
||||
soundEventRegistry.forEach(sound -> resultsArray.add(generateSound(soundEventRegistry, sound)));
|
||||
return resultsArray;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user