Skip to content

Commit

Permalink
2
Browse files Browse the repository at this point in the history
  • Loading branch information
Ecdcaeb committed Aug 4, 2024
1 parent 77d5780 commit ceefdcd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 29 deletions.
12 changes: 1 addition & 11 deletions src/main/java/rml/layer/compat/crt/RMLCrTLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class RMLCrTLoader {

public static IScriptProvider getScriptProviders(){
RMLScriptProvider providerCustom = new RMLScriptProvider();
ResourceModLoader.loadModuleFindAssets(CrTModule.TYPE, (containerHolder, root, file) -> {
ResourceModLoader.loadModuleFindAssets(ModuleType.valueOf(new ResourceLocation("rml", "mod_crt")), (containerHolder, root, file) -> {
String relative = root.relativize(file).toString();
if (!"zs".equals(FilenameUtils.getExtension(file.toString())) || relative.startsWith("_"))
return;
Expand All @@ -61,14 +61,4 @@ public static IScriptProvider getScriptProviders(){
@PrivateAPI public static void inject(CrTFindingIScriptIteratorEvent event){
event.load(getScriptProviders());
}

/**
* @Project ResourceModLoader
* @Author Hileb
* @Date 2024/7/30 10:15
**/
public static class CrTModule{

public static ModuleType TYPE = new ModuleType(new ResourceLocation("rml", "mod_crt"), "crt", false);
}
}
36 changes: 18 additions & 18 deletions src/main/java/rml/loader/deserialize/RMLLoaders.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static void error(ModuleType moduleType, ContainerHolder containerHolder,
public static class OreDic {
private static Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
public static void load(){
ResourceModLoader.loadModuleFindAssets(ModuleType.ORE_DIC, (containerHolder, root, file) -> {
ResourceModLoader.loadModuleFindAssets(ModuleType.valueOf(new ResourceLocation("rml", "ore_dic")), (containerHolder, root, file) -> {
String relative = root.relativize(file).toString();
if (!"json".equals(FilenameUtils.getExtension(file.toString())) || relative.startsWith("_"))
return;
Expand All @@ -93,11 +93,11 @@ public static void load(){
}
catch (JsonParseException | JsonDeserializeException e)
{
error(ModuleType.ORE_DIC, containerHolder, e, "Parsing error loading Ore dic {}", key);
error(ModuleType.valueOf(new ResourceLocation("rml", "ore_dic")), containerHolder, e, "Parsing error loading Ore dic {}", key);
}
catch (IOException e)
{
error(ModuleType.ORE_DIC, containerHolder, e, "Couldn't read ore dic {} from {}", key, file);
error(ModuleType.valueOf(new ResourceLocation("rml", "ore_dic")), containerHolder, e, "Couldn't read ore dic {} from {}", key, file);
}finally
{
IOUtils.closeQuietly(reader);
Expand All @@ -118,7 +118,7 @@ public static class TagOre{
**/
public static class LootTable {
public static void load(LootTableRegistryEvent event) {
ResourceModLoader.loadModuleFindAssets(ModuleType.LOOT_TABLES, (containerHolder, root, file) -> {
ResourceModLoader.loadModuleFindAssets(ModuleType.valueOf(new ResourceLocation("rml", "loot_tables")), (containerHolder, root, file) -> {
String relative = root.relativize(file).toString();
if (!"json".equals(FilenameUtils.getExtension(file.toString())) || relative.startsWith("_"))
return;
Expand All @@ -140,7 +140,7 @@ public static class Function {
public static LineProcessor<List<String>> processor(){ return new LineProcessor<List<String>>() {final List<String> result = Lists.newArrayList();@Override public boolean processLine(String line) {result.add(line);return true;}@Override public List<String> getResult() {return result;}};}

public static void load(FunctionLoadEvent event) {
ResourceModLoader.loadModuleFindAssets(ModuleType.FUNCTIONS, (containerHolder, root, file) -> {
ResourceModLoader.loadModuleFindAssets(ModuleType.valueOf(new ResourceLocation("rml", "functions")), (containerHolder, root, file) -> {
String relative = root.relativize(file).toString();
switch (FilenameUtils.getExtension(file.toString())) {
case "mcfunction" :
Expand All @@ -155,7 +155,7 @@ public static void load(FunctionLoadEvent event) {
);
event.register(key, functionObject);
} catch (IOException e) {
error(ModuleType.FUNCTIONS, containerHolder, e,"Couldn't read function {} from {}", key, file);
error(ModuleType.valueOf(new ResourceLocation("rml", "functions")), containerHolder, e,"Couldn't read function {} from {}", key, file);
}
break;
default:
Expand All @@ -167,7 +167,7 @@ public static void load(FunctionLoadEvent event) {

public static void loadExecutors() {

ResourceModLoader.loadModuleFindAssets(ModuleType.FUNCTIONS, (containerHolder, root, file) -> {
ResourceModLoader.loadModuleFindAssets(ModuleType.valueOf(new ResourceLocation("rml", "functions")), (containerHolder, root, file) -> {
String relative = root.relativize(file).toString();
switch (FilenameUtils.getExtension(file.toString())) {
case "executor" :
Expand All @@ -177,9 +177,9 @@ public static void loadExecutors() {
JsonElement jsonElement = RMLLoaders.JSON_PARSER.parse(Files.newBufferedReader(file));
Deserializer.decode(FunctionExecutor[].class, jsonElement);
} catch (IOException e) {
error(ModuleType.FUNCTIONS, containerHolder, e,"Couldn't read function executor {} from {}", key, file);
error(ModuleType.valueOf(new ResourceLocation("rml", "functions")), containerHolder, e,"Couldn't read function executor {} from {}", key, file);
} catch (JsonDeserializeException e) {
error(ModuleType.FUNCTIONS, containerHolder, e, "Couldn't read function executor {} from {}", key, file);
error(ModuleType.valueOf(new ResourceLocation("rml", "functions")), containerHolder, e, "Couldn't read function executor {} from {}", key, file);
}
break;
default:
Expand All @@ -190,17 +190,17 @@ public static void loadExecutors() {
}
public static class MissingRemap {
public static void load() {
ResourceModLoader.loadModuleFindAssets(ModuleType.REGISTRY_REMAP, (containerHolder, root, file) -> {
ResourceModLoader.loadModuleFindAssets(ModuleType.valueOf(new ResourceLocation("rml", "registry_remap")), (containerHolder, root, file) -> {
String relative = root.relativize(file).toString();
if (!"json".equals(FilenameUtils.getExtension(file.toString())) || relative.startsWith("_"))
return;
try {
JsonElement jsonElement = RMLLoaders.JSON_PARSER.parse(FileHelper.getCachedFile(file));
Arrays.stream(Deserializer.decode(RemapCollection[].class, jsonElement)).forEach(RemapCollection.Manager::merge);
} catch (IOException e) {
error(ModuleType.REGISTRY_REMAP, containerHolder, e, "Could not cache the file {} ", file);
error(ModuleType.valueOf(new ResourceLocation("rml", "registry_remap")), containerHolder, e, "Could not cache the file {} ", file);
} catch (JsonDeserializeException e) {
error(ModuleType.REGISTRY_REMAP, containerHolder, e, "Could not deserialize registry_remap {}", file);
error(ModuleType.valueOf(new ResourceLocation("rml", "registry_remap")), containerHolder, e, "Could not deserialize registry_remap {}", file);
}
});
}
Expand All @@ -215,7 +215,7 @@ public static class CustomVillageLoader {
public static List<IVillager> load() {

final List<IVillager> list = new ArrayList<>();
ResourceModLoader.loadModuleFindAssets(ModuleType.CUSTOM_VILLAGERS, (containerHolder, root, file) -> {
ResourceModLoader.loadModuleFindAssets(ModuleType.valueOf(new ResourceLocation("rml", "custom_villagers")), (containerHolder, root, file) -> {
String relative = root.relativize(file).toString();
if (!"json".equals(FilenameUtils.getExtension(file.toString())) || relative.startsWith("_"))
return;
Expand All @@ -231,12 +231,12 @@ public static List<IVillager> load() {
IVillager IVillager = Deserializer.decode(rml.loader.api.world.villagers.IVillager.class, jsonElement);
list.add(IVillager);
} catch (Exception e) {
error(ModuleType.CUSTOM_VILLAGERS, containerHolder, e,"Error load village at {}", file);
error(ModuleType.valueOf(new ResourceLocation("rml", "custom_villagers")), containerHolder, e,"Error load village at {}", file);
}
} catch (JsonParseException e) {
error(ModuleType.CUSTOM_VILLAGERS, containerHolder, e,"Parsing error loading villager {}", key);
error(ModuleType.valueOf(new ResourceLocation("rml", "custom_villagers")), containerHolder, e,"Parsing error loading villager {}", key);
} catch (IOException e) {
error(ModuleType.CUSTOM_VILLAGERS, containerHolder, e,"Couldn't read villager {} from {}", key, file);
error(ModuleType.valueOf(new ResourceLocation("rml", "custom_villagers")), containerHolder, e,"Couldn't read villager {} from {}", key, file);
} finally {
IOUtils.closeQuietly(reader);
}
Expand All @@ -250,7 +250,7 @@ public static class MCMainScreenTextLoader {
public static List<String> rawTexts;

public static void load() {
ResourceModLoader.loadModuleFindAssets(ModuleType.SPLASH_TEXT, (containerHolder, root, file) -> {
ResourceModLoader.loadModuleFindAssets(ModuleType.valueOf(new ResourceLocation("rml", "splash_text")), (containerHolder, root, file) -> {
BufferedReader bufferedreader = null;
try {
bufferedreader = Files.newBufferedReader(file);
Expand Down Expand Up @@ -293,7 +293,7 @@ public static String processComponent(String raw) {
public static class ConfigLoader {
public static final FieldAccessor<Map<String, Multimap<Config.Type, ASMDataTable.ASMData>>, ConfigManager> asm_data = ReflectionHelper.getFieldAccessor(ConfigManager.class, "asm_data");
public static void load(){
ResourceModLoader.loadModuleFindAssets(ModuleType.CONFIG_DEFINE, (containerHolder, root, file) -> {
ResourceModLoader.loadModuleFindAssets(ModuleType.valueOf(new ResourceLocation("rml", "config_define")), (containerHolder, root, file) -> {
String relative = root.relativize(file).toString();
if (!"cfg".equals(FilenameUtils.getExtension(file.toString())) || relative.startsWith("_"))
return;
Expand Down

0 comments on commit ceefdcd

Please sign in to comment.