Block tech tree mods
This commit is contained in:
@@ -31,7 +31,7 @@ import static io.anuke.arc.Core.*;
|
||||
public class Vars implements Loadable{
|
||||
/** Whether to load locales.*/
|
||||
public static boolean loadLocales = true;
|
||||
/** Maximum number of broken blocks.*/
|
||||
/** Maximum number of broken blocks. TODO implement or remove.*/
|
||||
public static final int maxBrokenBlocks = 256;
|
||||
/** IO buffer size. */
|
||||
public static final int bufferSize = 8192;
|
||||
|
||||
@@ -13,6 +13,7 @@ public class TechTree implements ContentList{
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
TechNode.context = null;
|
||||
all = new Array<>();
|
||||
|
||||
root = node(coreShard, () -> {
|
||||
@@ -302,7 +303,7 @@ public class TechTree implements ContentList{
|
||||
});
|
||||
}
|
||||
|
||||
private TechNode node(Block block, Runnable children){
|
||||
private static TechNode node(Block block, Runnable children){
|
||||
ItemStack[] requirements = new ItemStack[block.requirements.length];
|
||||
for(int i = 0; i < requirements.length; i++){
|
||||
requirements[i] = new ItemStack(block.requirements[i].item, 30 + block.requirements[i].amount * 6);
|
||||
@@ -311,10 +312,15 @@ public class TechTree implements ContentList{
|
||||
return new TechNode(block, requirements, children);
|
||||
}
|
||||
|
||||
private TechNode node(Block block){
|
||||
private static TechNode node(Block block){
|
||||
return node(block, () -> {});
|
||||
}
|
||||
|
||||
public static void create(Block parent, Block block){
|
||||
TechNode.context = all.find(t -> t.block == parent);
|
||||
node(block, () -> {});
|
||||
}
|
||||
|
||||
public static class TechNode{
|
||||
static TechNode context;
|
||||
|
||||
@@ -322,19 +328,22 @@ public class TechTree implements ContentList{
|
||||
public final ItemStack[] requirements;
|
||||
public final Array<TechNode> children = new Array<>();
|
||||
|
||||
TechNode(Block block, ItemStack[] requirements, Runnable children){
|
||||
if(context != null){
|
||||
context.children.add(this);
|
||||
TechNode(TechNode ccontext, Block block, ItemStack[] requirements, Runnable children){
|
||||
if(ccontext != null){
|
||||
ccontext.children.add(this);
|
||||
}
|
||||
|
||||
this.block = block;
|
||||
this.requirements = requirements;
|
||||
|
||||
TechNode last = context;
|
||||
context = this;
|
||||
children.run();
|
||||
context = last;
|
||||
context = ccontext;
|
||||
all.add(this);
|
||||
}
|
||||
|
||||
TechNode(Block block, ItemStack[] requirements, Runnable children){
|
||||
this(context, block, requirements, children);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,9 @@ public class ContentParser{
|
||||
Block block = type.getDeclaredConstructor(String.class).newInstance(mod + "-" + name);
|
||||
read(() -> {
|
||||
readFields(block, value, true);
|
||||
if(value.has("research")){
|
||||
TechTree.create(Vars.content.getByName(ContentType.block, value.get("research").asString()), block);
|
||||
}
|
||||
|
||||
//make block visible
|
||||
if(block.requirements != null){
|
||||
|
||||
Reference in New Issue
Block a user