Skip to content

Commit

Permalink
various cleanup, bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Midnight145 committed Jan 27, 2025
1 parent 9c810e8 commit 981331b
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 53 deletions.
67 changes: 33 additions & 34 deletions docs/research/schematic.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Research",
"description": "A Thaumcraft research to add or modify",
"description": "A Thaumcraft research to add or modify.",
"type": "object",
"properties": {
"key": {
"type": "string",
"description": "The unique key for this research. If this key already exists, the research will be updated"
"description": "The unique key for this research. If this key already exists, the research will be updated."
},
"category": {
"type": "string",
"description": "The category in the Thaumonomicon to place this research"
"description": "The category in the Thaumonomicon to place this research."
},
"name": {
"type": "string",
"description": "The localized name of this research"
"description": "The localized name of this research."
},
"tooltip": {
"type": "string",
"description": "The localized tooltip of this research"
"description": "The localized tooltip of this research."
},
"aspects": {
"type": "array",
Expand All @@ -28,40 +28,39 @@
"properties": {
"aspect": {
"type": "string",
"description": "The aspect itself"
"description": "The aspect itself."
},
"amount": {
"type": "integer",
"description": "The amount of the aspect"
"description": "The amount of the aspect."
}
}
},
"minItems": 1,
"uniqueItems": true
},
"parents": {
"type": "array",
"description": "The parent researches required for this research",
"description": "The parent researches required for this research.",
"items": {
"type": "string"
},
"uniqueItems": true
},
"siblings": {
"type": "array",
"description": "The sibling researches for this research",
"description": "The sibling researches for this research. Sibling research will be automatically completed upon completion of this research.",
"items": {
"type": "string"
},
"uniqueItems": true
},
"displayColumn": {
"type": "integer",
"description": "The column to display this research in"
"description": "The column to display this research in."
},
"displayRow": {
"type": "integer",
"description": "The row to display this research in"
"description": "The row to display this research in."
},
"icon_item": {
"type": "string",
Expand All @@ -73,71 +72,71 @@
},
"complexity": {
"type": "integer",
"description": "The complexity of this research. Used in creating research notes."
"description": "The complexity of this research. Used in determining the size of the research note minigame."
},
"isSpecial": {
"type": "boolean",
"description": "Whether this research is \"special\". Slightly changes the icon of the research. Mutually exclusive with isRound."
"description": "Whether this research is \"special\". Changes the icon to be the \"star\" shape. Mutually exclusive with isRound."
},
"isSecondary": {
"type": "boolean",
"description": "Whether this research is secondary"
"description": "Whether this research is secondary. Secondary researches are purchasable with aspects instead of being unlocked by the minigame."
},
"isRound": {
"type": "boolean",
"description": "Whether this research is round. Changes the icon of the research. Mutually exclusive with isSpecial."
},
"isStub": {
"type": "boolean",
"description": "Whether this research is a stub"
"description": "Whether this research should be auto-completed upon completion of parent research."
},
"isVirtual": {
"type": "boolean",
"description": "Whether this research is virtual. This will not be displayed in the Thaumonomicon, but can be used as a parent for other researches"
"description": "Whether this research is virtual. This will not be displayed in the Thaumonomicon, but can be used as a parent for other researches."
},
"isConcealed": {
"type": "boolean",
"description": "Whether this research is concealed until parents are completed."
"description": "Whether this research is concealed until parents are completed. The research will be invisible until all parent researches are completed."
},
"isHidden": {
"type": "boolean",
"description": "Whether this research is hidden until parents are completed."
"description": "Whether this research is hidden, which is required for itemTriggers, entityTriggers, or aspectTriggers to work."
},
"isLost": {
"type": "boolean",
"description": "Whether this research is \"lost\". Seems to have something to do with Eldritch research"
"description": "Whether this research is \"lost\". Seems to have something to do with Eldritch research."
},
"isAutoUnlock": {
"type": "boolean",
"description": "Whether this research is auto-unlocked on completion of parents"
"description": "Whether this research will always be unlocked. This will override all other unlock conditions and cause buggy behavior if there are parents."
},
"itemTriggers": {
"type": "array",
"description": "The item triggers for this research",
"description": "The item triggers for this research. These are items you must scan to unlock the research.",
"items": {
"type": "string"
},
"uniqueItems": true
},
"entityTriggers": {
"type": "array",
"description": "The entity triggers for this research",
"description": "The entity triggers for this research. These are entities you must scan to unlock the research.",
"items": {
"type": "string"
},
"uniqueItems": true
},
"aspectTriggers": {
"type": "array",
"description": "The aspect triggers for this research",
"description": "The aspect triggers for this research. These are aspects you must discover to unlock the research.",
"items": {
"type": "string"
},
"uniqueItems": true
},
"pages": {
"type": "array",
"description": "The pages for this research",
"description": "The pages for this research.",
"items": {
"type": "object",
"properties": {
Expand All @@ -148,50 +147,50 @@
},
"number": {
"type": "integer",
"description": "The page number. Must start at 0 and increase by 1 for each page",
"description": "The page number. Must start at 0 and increase by 1 for each page.",
"minimum": 0,
"uniqueItems": true
},
"text": {
"type": "string",
"description": "The text description on the page, if the page type is \"text\" or \"image\""
"description": "The text description on the page, if the page type is \"text\" or \"image\"."
},
"resource": {
"type": "string",
"description": "The resource of the image shown on the page, if the page type is \"image\""
"description": "The resource of the image shown on the page, if the page type is \"image\"."
},
"item": {
"type": "object",
"properties": {
"item": {
"type": "string",
"description": "The output of the recipe. Required for page types \"arcane\", \"recipe\", \"smelting\", \"crafting\", and \"infusion\""
"description": "The output of the recipe. Required for page types \"arcane\", \"recipe\", \"smelting\", \"crafting\", and \"infusion\"."
},
"meta": {
"type": "integer",
"description": "The meta of the item",
"description": "The meta of the item.",
"minimum": 0
},
"amount": {
"type": "integer",
"description": "The amount of the item",
"description": "The amount of the item.",
"minimum": 1
}
}
},
"aspects": {
"type": "array",
"description": "The aspects of the page. Required for page type \"aspect\"",
"description": "The aspects of the page. Required for page type \"aspect\".",
"items": {
"type": "object",
"properties": {
"aspect": {
"type": "string",
"description": "The aspect of the page"
"description": "The aspect of the page."
},
"amount": {
"type": "integer",
"description": "The amount of the aspect",
"description": "The amount of the aspect.",
"minimum": 1
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -45,12 +46,14 @@ public class CustomResearch {

public static void registerResearchFromFiles() {
if (FMLCommonHandler.instance()
.getSide()
.getEffectiveSide()
.isClient()) {
return;
}
List<ResearchEntry> researches = new ArrayList<>();
File researchPath = new File("config/salisarcana/research");

File researchPath = Paths.get("config", "salisarcana", "research")
.toFile();
if (researchPath.exists() && researchPath.isDirectory()) {
File[] files = researchPath.listFiles((dir, name) -> name.endsWith(".json"));
if (files == null) {
Expand Down Expand Up @@ -287,7 +290,7 @@ private static ResearchItem maybeRegister(CustomResearchSetting settings, Item p
.setParents(settings.parentResearches)
.setSpecial();
if (settings.autoUnlock) {
research.setAutoUnlock();
research.setStub();
}
final var pages = new ArrayList<ResearchPage>();
pages.add(new ResearchPage("tc.research_page." + fullKey + ".0"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import dev.rndmorris.salisarcana.common.commands.arguments.annotations.NamedArg;
import dev.rndmorris.salisarcana.common.commands.arguments.handlers.IArgumentHandler;
import dev.rndmorris.salisarcana.common.commands.arguments.handlers.ResearchHandler;
import dev.rndmorris.salisarcana.common.commands.arguments.handlers.ResearchKeyHandler;
import dev.rndmorris.salisarcana.common.commands.arguments.handlers.flag.FlagHandler;
import dev.rndmorris.salisarcana.config.ConfigModuleRoot;
import dev.rndmorris.salisarcana.config.settings.ResearchEntry;
import dev.rndmorris.salisarcana.lib.ResearchHelper;
import thaumcraft.api.research.ResearchItem;

Expand All @@ -35,7 +35,7 @@ public CommandExportResearch() {
return new ArgumentProcessor<>(
CommandExportResearch.Arguments.class,
CommandExportResearch.Arguments::new,
new IArgumentHandler[] { ResearchKeyHandler.INSTANCE, FlagHandler.INSTANCE });
new IArgumentHandler[] { ResearchHandler.INSTANCE, FlagHandler.INSTANCE });
}

@Override
Expand All @@ -45,7 +45,7 @@ protected int minimumRequiredArgs() {

@Override
protected void process(ICommandSender sender, CommandExportResearch.Arguments arguments, String[] args) {
Path path = Paths.get("config/salisarcana/research/export");
Path path = Paths.get("config", "salisarcana", "research", "export");
if (!Files.exists(path)) {
try {
Files.createDirectories(path);
Expand All @@ -57,13 +57,13 @@ protected void process(ICommandSender sender, CommandExportResearch.Arguments ar
}
for (ResearchItem research : arguments.researches) {
String researchKey = research.key;
File file = Paths.get("config/salisarcana/research/export/" + researchKey + ".json")
File file = Paths.get("config", "salisarcana", "research", "export", researchKey + ".json")
.toFile();
if (file.exists() && !arguments.overwrite) {
continue;
}
try {
ResearchHelper.exportResearchToJson(research, file);
ResearchHelper.exportResearchToJson(new ResearchEntry(research), file);
} catch (Exception e) {
sender.addChatMessage(
new ChatComponentTranslation("salisarcana:commands.export-research.failed", researchKey));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ public EnhancementsModule() {
thaumometerScanResearchEnabled,
ConfigPhase.EARLY,
"thaumometerScanContainersResearch",
"Research required to unlock the ability to scan the contents of inventories with the Thaumometer.", "salisarcana:CHESTSCAN")
.setCategory("thaumometer_container_scan"),
"Research required to unlock the ability to scan the contents of inventories with the Thaumometer.", "CHESTSCAN"),
levitatorShiftFix = new ToggleSetting(
this,
ConfigPhase.EARLY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;

import com.google.gson.annotations.SerializedName;

import cpw.mods.fml.common.registry.GameRegistry;
import dev.rndmorris.salisarcana.lib.AssetHelper;
import dev.rndmorris.salisarcana.lib.R;
Expand Down Expand Up @@ -207,12 +209,16 @@ public void updateResearchItem(ResearchItem research) {
ResearchCategories.researchCategories.get(research.category).research.remove(research.key);
ResearchCategories.researchCategories.get(research.category).research.put(research.key, research);
}
String name = research.getName();
String text = research.getText();
String parsed = name.substring(0, name.indexOf(key)) + name.substring(name.indexOf(key));
AssetHelper.addLangEntry(parsed + this.getKey(), this.getName());
parsed = text.substring(0, text.indexOf(key)) + text.substring(name.indexOf(key));
AssetHelper.addLangEntry(parsed + this.getKey(), this.getTooltip());
String key = AssetHelper.lookupLangEntryByValue(research.getName());
if (key == null) {
key = research.getName();
}
AssetHelper.addLangEntry(key, this.getName());
key = AssetHelper.lookupLangEntryByValue(research.getText());
if (key == null) {
key = research.getText();
}
AssetHelper.addLangEntry(key, this.getTooltip());

research.setParents(parents);
research.setParentsHidden(parentsHidden);
Expand Down Expand Up @@ -245,6 +251,7 @@ public void updateResearchItem(ResearchItem research) {
for (ResearchPageEntry entry : this.pages) {
if (entry.getType()
.equals("text")) {
AssetHelper.addLangEntry(AssetHelper.lookupLangEntryByValue(entry.getText()), entry.getText());
AssetHelper
.addLangEntry("tc_research_page." + this.getKey() + "." + entry.getNumber(), entry.getText());
pages.add(new ResearchPage(entry.getText()));
Expand Down Expand Up @@ -278,6 +285,7 @@ public int getAmount() {

class ResearchPageEntry {

@SerializedName("pageType")
public String type;
public int number;
public String text = "";
Expand Down
Loading

0 comments on commit 981331b

Please sign in to comment.