init() test

This commit is contained in:
Anuken 2018-08-18 12:19:20 -04:00
parent e0eb227ce5
commit e9d03c179c

View File

@ -1,13 +1,12 @@
package io.anuke.mindustry.content; package io.anuke.mindustry.content;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.content.blocks.*; import io.anuke.mindustry.content.blocks.DebugBlocks;
import io.anuke.mindustry.game.Content; import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.game.GameMode;
import io.anuke.mindustry.type.*; import io.anuke.mindustry.type.*;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import static io.anuke.mindustry.type.Category.*; import static io.anuke.mindustry.type.Category.units;
public class Recipes implements ContentList{ public class Recipes implements ContentList{
@ -15,6 +14,7 @@ public class Recipes implements ContentList{
public void load(){ public void load(){
//WALLS //WALLS
/*
new Recipe(defense, DefenseBlocks.tungstenWall, new ItemStack(Items.tungsten, 12)); new Recipe(defense, DefenseBlocks.tungstenWall, new ItemStack(Items.tungsten, 12));
new Recipe(defense, DefenseBlocks.tungstenWallLarge, new ItemStack(Items.tungsten, 12 * 4)); new Recipe(defense, DefenseBlocks.tungstenWallLarge, new ItemStack(Items.tungsten, 12 * 4));
@ -164,7 +164,9 @@ public class Recipes implements ContentList{
new Recipe(units, DebugBlocks.itemVoid, new ItemStack(Items.carbide, 10)).setDebug(); new Recipe(units, DebugBlocks.itemVoid, new ItemStack(Items.carbide, 10)).setDebug();
new Recipe(units, DebugBlocks.liquidSource, new ItemStack(Items.carbide, 10)).setDebug(); new Recipe(units, DebugBlocks.liquidSource, new ItemStack(Items.carbide, 10)).setDebug();
new Recipe(units, DebugBlocks.powerVoid, new ItemStack(Items.carbide, 10)).setDebug(); new Recipe(units, DebugBlocks.powerVoid, new ItemStack(Items.carbide, 10)).setDebug();
new Recipe(units, DebugBlocks.powerInfinite, new ItemStack(Items.carbide, 10), new ItemStack(Items.surgealloy, 5)).setDebug(); new Recipe(units, DebugBlocks.powerInfinite, new ItemStack(Items.carbide, 10), new ItemStack(Items.surgealloy, 5)).setDebug();*/
init(units, DebugBlocks.itemSource, Items.carbide, 10);
} }
static void init(Object... objects){ static void init(Object... objects){
@ -172,34 +174,34 @@ public class Recipes implements ContentList{
Block block = null; Block block = null;
ItemStack stack = null; ItemStack stack = null;
Array<ItemStack> arr = new Array<>(); Array<ItemStack> arr = new Array<>();
for(int i = 0; i < objects.length; i++){ for(Object object : objects){
if(objects[i] instanceof Category){ if(object instanceof Category){
if(stack != null) throw new RuntimeException("Finish defining stack before beginning category"); if(stack != null) throw new RuntimeException("Finish defining stack before beginning category");
if(block != null && cat != null){ if(block != null){
new Recipe(cat, block, arr.toArray(ItemStack.class)); new Recipe(cat, block, arr.toArray(ItemStack.class));
block = null; block = null;
stack = null; stack = null;
arr.clear(); arr.clear();
} }
cat = (Category)objects[i]; cat = (Category) object;
}else if(objects[i] instanceof Block){ }else if(object instanceof Block){
if(cat == null) throw new RuntimeException("Finish defining category before beginning blocks"); if(cat == null) throw new RuntimeException("Finish defining category before beginning blocks");
if(block != null){ if(block != null){
new Recipe(cat, block, arr.toArray(ItemStack.class)); new Recipe(cat, block, arr.toArray(ItemStack.class));
stack = null; stack = null;
arr.clear(); arr.clear();
} }
block = (Block)objects[i]; block = (Block) object;
arr.clear(); arr.clear();
}else if(objects[i] instanceof Item){ }else if(object instanceof Item){
if(block == null) throw new RuntimeException("Finish defining block before defining item"); if(block == null) throw new RuntimeException("Finish defining block before defining item");
if(stack != null){ if(stack != null) throw new RuntimeException("Finish defining stack before defining another stack");
arr.add(stack); stack = new ItemStack((Item) object, 1);
} }else if(object instanceof Integer){
stack = new ItemStack((Item)objects[i], 1);
}else if(objects[i] instanceof Integer){
if(stack == null) throw new RuntimeException("Finish defining item before defining item amount"); if(stack == null) throw new RuntimeException("Finish defining item before defining item amount");
stack.amount = (Integer) objects[i]; stack.amount = (Integer) object;
arr.add(stack);
stack = null;
} }
} }
} }