Block mod overwrite
This commit is contained in:
@@ -4,14 +4,12 @@ import io.anuke.arc.*;
|
||||
import io.anuke.arc.assets.loaders.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.util.*;
|
||||
|
||||
/** Handles files in a modded context. */
|
||||
public class FileTree implements FileHandleResolver{
|
||||
private ObjectMap<String, FileHandle> files = new ObjectMap<>();
|
||||
|
||||
public void addFile(String path, FileHandle f){
|
||||
Log.info("Add " + path);
|
||||
files.put(path, f);
|
||||
}
|
||||
|
||||
|
||||
@@ -107,22 +107,33 @@ public class ContentParser{
|
||||
ContentType.block, (TypeParser<Block>)(mod, name, value) -> {
|
||||
readBundle(ContentType.block, name, value);
|
||||
|
||||
//TODO generate dynamically instead of doing.. this
|
||||
Class<? extends Block> type = resolve(value.getString("type"),
|
||||
"io.anuke.mindustry.world",
|
||||
"io.anuke.mindustry.world.blocks",
|
||||
"io.anuke.mindustry.world.blocks.defense",
|
||||
"io.anuke.mindustry.world.blocks.defense.turrets",
|
||||
"io.anuke.mindustry.world.blocks.distribution",
|
||||
"io.anuke.mindustry.world.blocks.logic",
|
||||
"io.anuke.mindustry.world.blocks.power",
|
||||
"io.anuke.mindustry.world.blocks.production",
|
||||
"io.anuke.mindustry.world.blocks.sandbox",
|
||||
"io.anuke.mindustry.world.blocks.storage",
|
||||
"io.anuke.mindustry.world.blocks.units"
|
||||
);
|
||||
Block block;
|
||||
|
||||
if(Vars.content.getByName(ContentType.block, name) != null){
|
||||
block = Vars.content.getByName(ContentType.block, name);
|
||||
|
||||
if(value.has("type")){
|
||||
throw new IllegalArgumentException("When overwriting an existing block, you may not declared its type. The original type will be used. Block: " + name);
|
||||
}
|
||||
}else{
|
||||
//TODO generate dynamically instead of doing.. this
|
||||
Class<? extends Block> type = resolve(value.getString("type"),
|
||||
"io.anuke.mindustry.world",
|
||||
"io.anuke.mindustry.world.blocks",
|
||||
"io.anuke.mindustry.world.blocks.defense",
|
||||
"io.anuke.mindustry.world.blocks.defense.turrets",
|
||||
"io.anuke.mindustry.world.blocks.distribution",
|
||||
"io.anuke.mindustry.world.blocks.logic",
|
||||
"io.anuke.mindustry.world.blocks.power",
|
||||
"io.anuke.mindustry.world.blocks.production",
|
||||
"io.anuke.mindustry.world.blocks.sandbox",
|
||||
"io.anuke.mindustry.world.blocks.storage",
|
||||
"io.anuke.mindustry.world.blocks.units"
|
||||
);
|
||||
|
||||
block = type.getDeclaredConstructor(String.class).newInstance(mod + "-" + name);
|
||||
}
|
||||
|
||||
Block block = type.getDeclaredConstructor(String.class).newInstance(mod + "-" + name);
|
||||
currentContent = block;
|
||||
read(() -> {
|
||||
if(value.has("consumes")){
|
||||
|
||||
Reference in New Issue
Block a user