Modded consumers
This commit is contained in:
@@ -258,7 +258,7 @@ public class Vars implements Loadable{
|
||||
public static void loadSettings(){
|
||||
Core.settings.setAppName(appName);
|
||||
|
||||
if(steam){
|
||||
if(steam || Version.modifier.equals("steam")){
|
||||
Core.settings.setDataDirectory(Core.files.local("saves/"));
|
||||
}
|
||||
|
||||
|
||||
@@ -92,9 +92,6 @@ public class Control implements ApplicationListener, Loadable{
|
||||
world.getMap().setHighScore(state.wave);
|
||||
}
|
||||
|
||||
if(world.isZone()){
|
||||
world.getZone().updateWave(state.wave);
|
||||
}
|
||||
Sounds.wave.play();
|
||||
});
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@ public class Logic implements ApplicationListener{
|
||||
for(Player p : playerGroup.all()){
|
||||
p.respawns = state.rules.respawns;
|
||||
}
|
||||
|
||||
if(world.isZone()){
|
||||
world.getZone().updateWave(state.wave);
|
||||
}
|
||||
});
|
||||
|
||||
Events.on(BlockDestroyEvent.class, event -> {
|
||||
|
||||
@@ -22,7 +22,7 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
}
|
||||
|
||||
public void createIcons(){
|
||||
//TODO implement.
|
||||
//TODO implement; generate special icons, like mech icons or ores w/ pixmaps
|
||||
}
|
||||
|
||||
/** Returns a specific content icon, or the region {contentType}-{name} if not found.*/
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.mod;
|
||||
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.function.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.util.ArcAnnotate.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.reflect.*;
|
||||
@@ -24,6 +25,8 @@ public class ContentParser{
|
||||
private ObjectMap<Class<?>, FieldParser> classParsers = new ObjectMap<Class<?>, FieldParser>(){{
|
||||
put(BulletType.class, (type, data) -> field(Bullets.class, data));
|
||||
put(Effect.class, (type, data) -> field(Fx.class, data));
|
||||
put(StatusEffect.class, (type, data) -> field(StatusEffects.class, data));
|
||||
put(Color.class, (type, data) -> Color.valueOf(data.asString()));
|
||||
}};
|
||||
/** Stores things that need to be parsed fully, e.g. reading fields of content.
|
||||
* This is done to accomodate binding of content names first.*/
|
||||
@@ -69,6 +72,31 @@ public class ContentParser{
|
||||
|
||||
Block block = type.getDeclaredConstructor(String.class).newInstance(mod + "-" + name);
|
||||
read(() -> {
|
||||
if(value.has("consumes")){
|
||||
for(JsonValue child : value.get("consumes")){
|
||||
if(child.name.equals("item")){
|
||||
if(child.isString()){
|
||||
block.consumes.item(Vars.content.getByName(ContentType.item, child.asString()));
|
||||
}else{
|
||||
ItemStack stack = parser.readValue(ItemStack.class, child);
|
||||
block.consumes.item(stack.item, stack.amount);
|
||||
}
|
||||
}else if(child.name.equals("items")){
|
||||
block.consumes.items(parser.readValue(ItemStack[].class, child));
|
||||
}else if(child.name.equals("liquid")){
|
||||
LiquidStack stack = parser.readValue(LiquidStack.class, child);
|
||||
block.consumes.liquid(stack.liquid, stack.amount);
|
||||
}else if(child.name.equals("power")){
|
||||
block.consumes.power(child.asFloat());
|
||||
}else if(child.name.equals("powerBuffered")){
|
||||
block.consumes.powerBuffered(child.asFloat());
|
||||
}else{
|
||||
throw new IllegalArgumentException("Unknown consumption type: '" + child.name + "' for block '" + block.name + "'.");
|
||||
}
|
||||
}
|
||||
value.remove("consumes");
|
||||
}
|
||||
|
||||
readFields(block, value, true);
|
||||
|
||||
//add research tech node
|
||||
|
||||
@@ -276,8 +276,8 @@ public class Mods implements Loadable{
|
||||
//make sure the main class exists before loading it; if it doesn't just don't put it there
|
||||
if(mainFile.exists()){
|
||||
//other platforms don't have standard java class loaders
|
||||
if(mobile){
|
||||
throw new IllegalArgumentException("This mod is not compatible with " + (ios ? "iOS" : "Android") + ".");
|
||||
if(!headless && Version.build != -1){
|
||||
throw new IllegalArgumentException("Java class mods are currently unsupported outside of custom builds.");
|
||||
}
|
||||
|
||||
URLClassLoader classLoader = new URLClassLoader(new URL[]{sourceFile.file().toURI().toURL()}, ClassLoader.getSystemClassLoader());
|
||||
|
||||
@@ -5,7 +5,7 @@ import io.anuke.mindustry.content.Items;
|
||||
|
||||
public class ItemStack implements Comparable<ItemStack>{
|
||||
public Item item;
|
||||
public int amount;
|
||||
public int amount = 1;
|
||||
|
||||
public ItemStack(Item item, int amount){
|
||||
if(item == null) item = Items.copper;
|
||||
|
||||
@@ -9,6 +9,11 @@ public class LiquidStack{
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
/** serialization only*/
|
||||
protected LiquidStack(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "LiquidStack{" +
|
||||
|
||||
Reference in New Issue
Block a user