Modded consumers
This commit is contained in:
@@ -1,20 +1,17 @@
|
|||||||
package io.anuke.annotations;
|
package io.anuke.annotations;
|
||||||
|
|
||||||
import com.sun.source.util.TreePath;
|
import com.sun.source.util.*;
|
||||||
import com.sun.source.util.Trees;
|
import com.sun.tools.javac.tree.*;
|
||||||
import com.sun.tools.javac.tree.JCTree;
|
import com.sun.tools.javac.tree.JCTree.*;
|
||||||
import com.sun.tools.javac.tree.JCTree.JCExpressionStatement;
|
import io.anuke.annotations.Annotations.*;
|
||||||
import io.anuke.annotations.Annotations.OverrideCallSuper;
|
|
||||||
|
|
||||||
import javax.annotation.processing.*;
|
import javax.annotation.processing.*;
|
||||||
import javax.lang.model.SourceVersion;
|
import javax.lang.model.*;
|
||||||
import javax.lang.model.element.Element;
|
import javax.lang.model.element.*;
|
||||||
import javax.lang.model.element.TypeElement;
|
import javax.tools.Diagnostic.*;
|
||||||
import javax.tools.Diagnostic.Kind;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@SupportedAnnotationTypes("java.lang.Override")
|
@SupportedAnnotationTypes({"java.lang.Override"})
|
||||||
public class CallSuperAnnotationProcessor extends AbstractProcessor{
|
public class CallSuperAnnotationProcessor extends AbstractProcessor{
|
||||||
private Trees trees;
|
private Trees trees;
|
||||||
|
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ public class Vars implements Loadable{
|
|||||||
public static void loadSettings(){
|
public static void loadSettings(){
|
||||||
Core.settings.setAppName(appName);
|
Core.settings.setAppName(appName);
|
||||||
|
|
||||||
if(steam){
|
if(steam || Version.modifier.equals("steam")){
|
||||||
Core.settings.setDataDirectory(Core.files.local("saves/"));
|
Core.settings.setDataDirectory(Core.files.local("saves/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,9 +92,6 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
world.getMap().setHighScore(state.wave);
|
world.getMap().setHighScore(state.wave);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(world.isZone()){
|
|
||||||
world.getZone().updateWave(state.wave);
|
|
||||||
}
|
|
||||||
Sounds.wave.play();
|
Sounds.wave.play();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ public class Logic implements ApplicationListener{
|
|||||||
for(Player p : playerGroup.all()){
|
for(Player p : playerGroup.all()){
|
||||||
p.respawns = state.rules.respawns;
|
p.respawns = state.rules.respawns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(world.isZone()){
|
||||||
|
world.getZone().updateWave(state.wave);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.on(BlockDestroyEvent.class, event -> {
|
Events.on(BlockDestroyEvent.class, event -> {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public abstract class UnlockableContent extends MappableContent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void createIcons(){
|
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.*/
|
/** 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.collection.*;
|
||||||
import io.anuke.arc.function.*;
|
import io.anuke.arc.function.*;
|
||||||
|
import io.anuke.arc.graphics.*;
|
||||||
import io.anuke.arc.util.ArcAnnotate.*;
|
import io.anuke.arc.util.ArcAnnotate.*;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.arc.util.reflect.*;
|
import io.anuke.arc.util.reflect.*;
|
||||||
@@ -24,6 +25,8 @@ public class ContentParser{
|
|||||||
private ObjectMap<Class<?>, FieldParser> classParsers = new ObjectMap<Class<?>, FieldParser>(){{
|
private ObjectMap<Class<?>, FieldParser> classParsers = new ObjectMap<Class<?>, FieldParser>(){{
|
||||||
put(BulletType.class, (type, data) -> field(Bullets.class, data));
|
put(BulletType.class, (type, data) -> field(Bullets.class, data));
|
||||||
put(Effect.class, (type, data) -> field(Fx.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.
|
/** Stores things that need to be parsed fully, e.g. reading fields of content.
|
||||||
* This is done to accomodate binding of content names first.*/
|
* 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);
|
Block block = type.getDeclaredConstructor(String.class).newInstance(mod + "-" + name);
|
||||||
read(() -> {
|
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);
|
readFields(block, value, true);
|
||||||
|
|
||||||
//add research tech node
|
//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
|
//make sure the main class exists before loading it; if it doesn't just don't put it there
|
||||||
if(mainFile.exists()){
|
if(mainFile.exists()){
|
||||||
//other platforms don't have standard java class loaders
|
//other platforms don't have standard java class loaders
|
||||||
if(mobile){
|
if(!headless && Version.build != -1){
|
||||||
throw new IllegalArgumentException("This mod is not compatible with " + (ios ? "iOS" : "Android") + ".");
|
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());
|
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 class ItemStack implements Comparable<ItemStack>{
|
||||||
public Item item;
|
public Item item;
|
||||||
public int amount;
|
public int amount = 1;
|
||||||
|
|
||||||
public ItemStack(Item item, int amount){
|
public ItemStack(Item item, int amount){
|
||||||
if(item == null) item = Items.copper;
|
if(item == null) item = Items.copper;
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ public class LiquidStack{
|
|||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** serialization only*/
|
||||||
|
protected LiquidStack(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return "LiquidStack{" +
|
return "LiquidStack{" +
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public class DesktopLauncher extends ClientLauncher{
|
|||||||
}catch(Throwable e){
|
}catch(Throwable e){
|
||||||
steam = false;
|
steam = false;
|
||||||
Log.err("Failed to load Steam native libraries.");
|
Log.err("Failed to load Steam native libraries.");
|
||||||
e.printStackTrace();
|
Log.err(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import io.anuke.arc.util.*;
|
|||||||
import io.anuke.mindustry.*;
|
import io.anuke.mindustry.*;
|
||||||
import io.anuke.mindustry.content.*;
|
import io.anuke.mindustry.content.*;
|
||||||
import io.anuke.mindustry.core.*;
|
import io.anuke.mindustry.core.*;
|
||||||
|
import io.anuke.mindustry.game.*;
|
||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
import io.anuke.mindustry.world.blocks.*;
|
import io.anuke.mindustry.world.blocks.*;
|
||||||
import io.anuke.mindustry.world.blocks.power.*;
|
import io.anuke.mindustry.world.blocks.power.*;
|
||||||
@@ -26,7 +27,12 @@ public class PowerTestFixture{
|
|||||||
@BeforeAll
|
@BeforeAll
|
||||||
static void initializeDependencies(){
|
static void initializeDependencies(){
|
||||||
Core.graphics = new FakeGraphics();
|
Core.graphics = new FakeGraphics();
|
||||||
Vars.content = new ContentLoader();
|
Vars.content = new ContentLoader(){
|
||||||
|
@Override
|
||||||
|
public void handleMappableContent(MappableContent content){
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
content.createContent();
|
content.createContent();
|
||||||
Log.setUseColors(false);
|
Log.setUseColors(false);
|
||||||
Time.setDeltaProvider(() -> 0.5f);
|
Time.setDeltaProvider(() -> 0.5f);
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
package power;
|
package power;
|
||||||
|
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.*;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.*;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.*;
|
||||||
import io.anuke.mindustry.world.blocks.power.PowerGenerator;
|
import io.anuke.mindustry.world.blocks.power.*;
|
||||||
import io.anuke.mindustry.world.blocks.power.PowerGraph;
|
import io.anuke.mindustry.world.consumers.*;
|
||||||
import io.anuke.mindustry.world.consumers.ConsumePower;
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.*;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
||||||
import static org.junit.jupiter.api.DynamicTest.dynamicTest;
|
import static org.junit.jupiter.api.DynamicTest.dynamicTest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user