Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,15 @@ repositories {
name 'CleanroomMC Maven'
url 'https://maven.cleanroommc.com'
}
maven {
name 'CurseMaven'
url 'https://curse.cleanroommc.com'
}
}


dependencies {
implementation 'curse.maven:resource-mod-loader-945917:5768125+5768126'
if (propertyBool('use_asset_mover')) {
implementation "com.cleanroommc:assetmover:${propertyString('asset_mover_version')}"
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mods/Hileb/shotaasm/impl/ShotaCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Runnable compile(final ScriptFile file) {
return () -> {};
} else return null;
} else {
String singleName = file.name().substring(0, file.name().lastIndexOf('.')).replace('.', '_');
String singleName = file.name().substring(0, file.name().lastIndexOf('.')).replace('.', '_') + file.hashCode();
String name = "mods.Hileb.shotaasm.dynamic." + singleName;
StringBuilder builder = new StringBuilder("package mods.Hileb.shotaasm.dynamic;");
for (String s : file.property().get("import")) {
Expand Down Expand Up @@ -72,7 +72,7 @@ public Runnable compile(final ScriptFile file) {
} catch (InstantiationException | IllegalAccessException | InvocationTargetException |
NoSuchMethodException |
ClassNotFoundException | MalformedURLException e) {
throw new RuntimeException(e);
throw new RuntimeException("Unable to compile for " + file.name(), e);
}
}
}
Expand Down
73 changes: 73 additions & 0 deletions src/main/java/mods/Hileb/shotaasm/impl/rml/ShotaRMLLocator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package mods.Hileb.shotaasm.impl.rml;

import mods.Hileb.shotaasm.ShotaASM;
import mods.Hileb.shotaasm.ScriptLoader;
import mods.Hileb.shotaasm.api.IScriptLocator;
import mods.Hileb.shotaasm.api.ScriptFile;
import mods.Hileb.shotaasm.api.ShotaContext;

import net.minecraft.launchwrapper.Launch;
import net.minecraft.util.ResourceLocation;

import org.apache.commons.io.IOUtils;
import org.apache.commons.io.FilenameUtils;

import org.apache.logging.log4j.message.FormattedMessage;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

import rml.loader.ResourceModLoader;
import rml.loader.api.mods.module.ModuleType;
import rml.loader.api.mods.ContainerHolder;
import rml.jrx.utils.file.FileHelper;

public class ShotaRMLLocator implements IScriptLocator {

@Override
public Collection<ScriptFile> getScripts() {
final List<ScriptFile> list = new ArrayList<>();

if (ShotaContext.isClassExist("rml.loader.ResourceModLoader")) {
ResourceModLoader.loadModuleFindAssets(ModuleType.valueOf(new ResourceLocation("shotaasm", "shotaasm")), (containerHolder, module, root, file) -> {
String relative = root.relativize(file).toString();
String name = FilenameUtils.removeExtension(relative).replaceAll("\\\\", "/");
ResourceLocation key = new ResourceLocation(containerHolder.getContainer().getModId(), name);

try
{
ScriptFile scriptFile = ScriptFile.create(key.toString().replace(':', '$').replace('/', '$'), new String(FileHelper.getByteSource(file).read()));
scriptFile.data().put("rml_container", containerHolder);
list.add(scriptFile);
} catch (Exception e) {
ErrorHandler.error(
Objects.requireNonNull(module, "module").moduleType,
containerHolder, e, "Could not read file {}", key);
}
});
}
return list;
}

private static class ErrorHandler{
public static void runThrow(Throwable throwable, String msg, Object... args){
throw new RuntimeException(new FormattedMessage(msg, args).getFormattedMessage(), throwable);
}

public static boolean isForced(ContainerHolder containerHolder, ModuleType moduleType){
return containerHolder.hasModule(moduleType) && containerHolder.getModules().get(moduleType).forceLoaded;
}

public static void error(ModuleType moduleType, ContainerHolder containerHolder, Throwable throwable, String msg, Object... args){
if (isForced(containerHolder, moduleType)) runThrow(throwable, msg, args);
else ShotaASM.LOGGER.error(new FormattedMessage(msg, args).getFormattedMessage(), throwable);
}
}

}
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
mods.Hileb.shotaasm.impl.ShotaScriptLocator
mods.Hileb.shotaasm.impl.ShotaScriptLocator
mods.Hileb.shotaasm.impl.rml.ShotaRMLLocator
1 change: 0 additions & 1 deletion src/main/resources/modid_at.cfg
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
public net.minecraft.client.Minecraft fileResourcepacks # Example mcp name AT entry
7 changes: 7 additions & 0 deletions src/main/resources/rml.modules
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"name" : "shotaasm:shotaasm",
"isFile" : false,
"defaultLocation" : "mods/shotaasm"
}
]