mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-18 07:53:07 +01:00
Quick Fix
- Replaced reference to String#toLowerCase in AllSoundEvents
This commit is contained in:
parent
6f06ebffa3
commit
e7b09dc63f
1 changed files with 19 additions and 22 deletions
|
@ -4,6 +4,7 @@ import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
import com.simibubi.create.foundation.utility.data.ICanGenerateJson;
|
import com.simibubi.create.foundation.utility.data.ICanGenerateJson;
|
||||||
import net.minecraft.data.DirectoryCache;
|
import net.minecraft.data.DirectoryCache;
|
||||||
import net.minecraft.data.IDataProvider;
|
import net.minecraft.data.IDataProvider;
|
||||||
|
@ -16,7 +17,6 @@ import net.minecraftforge.registries.IForgeRegistry;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
|
||||||
public enum AllSoundEvents implements ICanGenerateJson {
|
public enum AllSoundEvents implements ICanGenerateJson {
|
||||||
|
|
||||||
CUCKOO_PIG("creeperclock"),
|
CUCKOO_PIG("creeperclock"),
|
||||||
|
@ -32,42 +32,40 @@ public enum AllSoundEvents implements ICanGenerateJson {
|
||||||
BLOCKZAPPER_DENY(SoundEvents.BLOCK_NOTE_BLOCK_BASS),
|
BLOCKZAPPER_DENY(SoundEvents.BLOCK_NOTE_BLOCK_BASS),
|
||||||
BLOCK_FUNNEL_EAT(SoundEvents.ENTITY_GENERIC_EAT),
|
BLOCK_FUNNEL_EAT(SoundEvents.ENTITY_GENERIC_EAT),
|
||||||
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
String id;
|
String id;
|
||||||
SoundEvent event, child;
|
SoundEvent event, child;
|
||||||
|
|
||||||
//For adding our own sounds at assets/create/sounds/name.ogg
|
// For adding our own sounds at assets/create/sounds/name.ogg
|
||||||
AllSoundEvents(){
|
AllSoundEvents() {
|
||||||
id = name().toLowerCase();
|
id = Lang.asId(name());
|
||||||
}
|
}
|
||||||
|
|
||||||
AllSoundEvents(String name){
|
AllSoundEvents(String name) {
|
||||||
id = name;
|
id = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
//For wrapping a existing sound with new subtitle
|
// For wrapping a existing sound with new subtitle
|
||||||
AllSoundEvents(SoundEvent child){
|
AllSoundEvents(SoundEvent child) {
|
||||||
id = name().toLowerCase();
|
this();
|
||||||
this.child = child;
|
this.child = child;
|
||||||
}
|
}
|
||||||
|
|
||||||
//subtitles are taken from the lang file (create.subtitle.sound_event_name)
|
// subtitles are taken from the lang file (create.subtitle.sound_event_name)
|
||||||
|
|
||||||
public SoundEvent get(){
|
public SoundEvent get() {
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getName(){
|
private String getName() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void register(RegistryEvent.Register<SoundEvent> event) {
|
public static void register(RegistryEvent.Register<SoundEvent> event) {
|
||||||
IForgeRegistry<SoundEvent> registry = event.getRegistry();
|
IForgeRegistry<SoundEvent> registry = event.getRegistry();
|
||||||
|
|
||||||
for (AllSoundEvents entry :
|
for (AllSoundEvents entry : values()) {
|
||||||
values()) {
|
|
||||||
|
|
||||||
ResourceLocation rec = new ResourceLocation(Create.ID, entry.getName());
|
ResourceLocation rec = new ResourceLocation(Create.ID, entry.getName());
|
||||||
SoundEvent sound = new SoundEvent(rec).setRegistryName(rec);
|
SoundEvent sound = new SoundEvent(rec).setRegistryName(rec);
|
||||||
|
@ -76,24 +74,23 @@ public enum AllSoundEvents implements ICanGenerateJson {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generate(Path path, DirectoryCache cache){
|
public void generate(Path path, DirectoryCache cache) {
|
||||||
Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
|
Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
|
||||||
path = path.resolve("assets/create");
|
path = path.resolve("assets/create");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JsonObject json = new JsonObject();
|
JsonObject json = new JsonObject();
|
||||||
for (AllSoundEvents soundEvent :
|
for (AllSoundEvents soundEvent : values()) {
|
||||||
values()) {
|
|
||||||
JsonObject entry = new JsonObject();
|
JsonObject entry = new JsonObject();
|
||||||
JsonArray arr = new JsonArray();
|
JsonArray arr = new JsonArray();
|
||||||
if (soundEvent.child != null){
|
if (soundEvent.child != null) {
|
||||||
//wrapper
|
// wrapper
|
||||||
JsonObject s = new JsonObject();
|
JsonObject s = new JsonObject();
|
||||||
s.addProperty("name", soundEvent.child.getName().toString());
|
s.addProperty("name", soundEvent.child.getName().toString());
|
||||||
s.addProperty("type", "event");
|
s.addProperty("type", "event");
|
||||||
arr.add(s);
|
arr.add(s);
|
||||||
} else{
|
} else {
|
||||||
//own sound
|
// own sound
|
||||||
arr.add(Create.ID + ":" + soundEvent.getName());
|
arr.add(Create.ID + ":" + soundEvent.getName());
|
||||||
}
|
}
|
||||||
entry.add("sounds", arr);
|
entry.add("sounds", arr);
|
||||||
|
|
Loading…
Reference in a new issue