Modded techtree bugfixes
This commit is contained in:
@@ -121,6 +121,11 @@ public class ContentParser{
|
||||
return sound;
|
||||
});
|
||||
put(Objectives.Objective.class, (type, data) -> {
|
||||
if(data.isString()){
|
||||
var cont = locateAny(data.asString());
|
||||
if(cont == null) throw new IllegalArgumentException("Unknown objective content: " + data.asString());
|
||||
return new Research((UnlockableContent)cont);
|
||||
}
|
||||
var oc = resolve(data.getString("type", ""), SectorComplete.class);
|
||||
data.remove("type");
|
||||
Objectives.Objective obj = make(oc);
|
||||
@@ -544,6 +549,16 @@ public class ContentParser{
|
||||
return first != null ? first : Vars.content.getByName(type, currentMod.name + "-" + name);
|
||||
}
|
||||
|
||||
private <T extends MappableContent> T locateAny(String name){
|
||||
for(ContentType t : ContentType.all){
|
||||
var out = locate(t, name);
|
||||
if(out != null){
|
||||
return (T)out;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
<T> T make(Class<T> type){
|
||||
try{
|
||||
Constructor<T> cons = type.getDeclaredConstructor();
|
||||
@@ -680,18 +695,26 @@ public class ContentParser{
|
||||
lastNode.remove();
|
||||
}
|
||||
|
||||
TechNode node = new TechNode(null, unlock, customRequirements == null ? unlock.researchRequirements() : customRequirements);
|
||||
TechNode node = new TechNode(null, unlock, customRequirements == null ? ItemStack.empty : customRequirements);
|
||||
LoadedMod cur = currentMod;
|
||||
|
||||
postreads.add(() -> {
|
||||
currentContent = unlock;
|
||||
currentMod = cur;
|
||||
|
||||
//add custom objectives
|
||||
if(research.has("objectives")){
|
||||
node.objectives.addAll(parser.readValue(Objective[].class, research.get("objectives")));
|
||||
}
|
||||
|
||||
//remove old node from parent
|
||||
if(node.parent != null){
|
||||
node.parent.children.remove(node);
|
||||
}
|
||||
|
||||
if(customRequirements == null){
|
||||
node.setupRequirements(unlock.researchRequirements());
|
||||
}
|
||||
|
||||
//find parent node.
|
||||
TechNode parent = TechTree.all.find(t -> t.content.name.equals(researchName) || t.content.name.equals(currentMod.name + "-" + researchName));
|
||||
|
||||
Reference in New Issue
Block a user