Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for finding lua resources of the form "__base__/..." #35

Merged
merged 1 commit into from Dec 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions FactorioDataWrapper/src/com/demod/factorio/FactorioData.java
Expand Up @@ -241,6 +241,19 @@ private static DataTable initializeDataTable() throws JSONException, IOException
globals.finder = new ResourceFinder() {
@Override
public InputStream findResource(String filename) {
String firstSegment = filename.split("\\/")[0];
if (firstSegment.startsWith("__") && firstSegment.endsWith("__")) {
String modName = firstSegment.substring(2, firstSegment.length() - 2);
Optional<Mod> mod = modLoader.getMod(modName);
if(mod.isPresent()) {
try {
return mod.get().getResource(filename.replace(firstSegment, "")).orElse(null);
} catch (Exception e) {
e.printStackTrace();
throw new InternalError(e);
}
}
}
if (filename.startsWith(SEARCH_MOD) && currentMod.get() != null) {
try {
return currentMod.get().getResource(filename.replace(SEARCH_MOD, "")).orElse(null);
Expand Down