Code formatter take 2

This commit is contained in:
modmuss50 2016-03-25 09:47:34 +00:00
parent 33985f1a31
commit 5eed5b161d
450 changed files with 32768 additions and 26684 deletions

View file

@ -1,5 +1,9 @@
package techreborn.api;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
@ -11,111 +15,127 @@ import net.minecraft.world.World;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class RollingMachineRecipe
{
public class RollingMachineRecipe {
public static final RollingMachineRecipe instance = new RollingMachineRecipe();
private final List<IRecipe> recipes = new ArrayList<IRecipe>();
private final List<IRecipe> recipes = new ArrayList<IRecipe>();
public void addShapedOreRecipe(ItemStack outputItemStack, Object... objectInputs)
{
recipes.add(new ShapedOreRecipe(outputItemStack, objectInputs));
}
public static final RollingMachineRecipe instance = new RollingMachineRecipe();
public void addShapelessOreRecipe(ItemStack outputItemStack, Object... objectInputs)
{
recipes.add(new ShapelessOreRecipe(outputItemStack, objectInputs));
}
public void addShapedOreRecipe(ItemStack outputItemStack,
Object... objectInputs) {
recipes.add(new ShapedOreRecipe(outputItemStack, objectInputs));
}
public void addRecipe(ItemStack output, Object... components)
{
String s = "";
int i = 0;
int j = 0;
int k = 0;
if (components[i] instanceof String[])
{
String as[] = (String[]) components[i++];
for (int l = 0; l < as.length; l++)
{
String s2 = as[l];
k++;
j = s2.length();
s = (new StringBuilder()).append(s).append(s2).toString();
}
} else
{
while (components[i] instanceof String)
{
String s1 = (String) components[i++];
k++;
j = s1.length();
s = (new StringBuilder()).append(s).append(s1).toString();
}
}
HashMap hashmap = new HashMap();
for (; i < components.length; i += 2)
{
Character character = (Character) components[i];
ItemStack itemstack1 = null;
if (components[i + 1] instanceof Item)
{
itemstack1 = new ItemStack((Item) components[i + 1]);
} else if (components[i + 1] instanceof Block)
{
itemstack1 = new ItemStack((Block) components[i + 1], 1, -1);
} else if (components[i + 1] instanceof ItemStack)
{
itemstack1 = (ItemStack) components[i + 1];
}
hashmap.put(character, itemstack1);
}
public void addShapelessOreRecipe(ItemStack outputItemStack,
Object... objectInputs) {
recipes
.add(new ShapelessOreRecipe(outputItemStack, objectInputs));
}
ItemStack recipeArray[] = new ItemStack[j * k];
for (int i1 = 0; i1 < j * k; i1++)
{
char c = s.charAt(i1);
if (hashmap.containsKey(Character.valueOf(c)))
{
recipeArray[i1] = ((ItemStack) hashmap.get(Character.valueOf(c))).copy();
} else
{
recipeArray[i1] = null;
}
}
public void addRecipe(ItemStack output, Object... components) {
String s = "";
int i = 0;
int j = 0;
int k = 0;
if (components[i] instanceof String[]) {
String as[] = (String[]) components[i++];
for (int l = 0; l < as.length; l++) {
String s2 = as[l];
k++;
j = s2.length();
s = (new StringBuilder()).append(s).append(s2).toString();
}
} else {
while (components[i] instanceof String) {
String s1 = (String) components[i++];
k++;
j = s1.length();
s = (new StringBuilder()).append(s).append(s1).toString();
}
}
HashMap hashmap = new HashMap();
for (; i < components.length; i += 2) {
Character character = (Character) components[i];
ItemStack itemstack1 = null;
if (components[i + 1] instanceof Item) {
itemstack1 = new ItemStack((Item) components[i + 1]);
} else if (components[i + 1] instanceof Block) {
itemstack1 = new ItemStack((Block) components[i + 1], 1, -1);
} else if (components[i + 1] instanceof ItemStack) {
itemstack1 = (ItemStack) components[i + 1];
}
hashmap.put(character, itemstack1);
}
recipes.add(new ShapedRecipes(j, k, recipeArray, output));
}
ItemStack recipeArray[] = new ItemStack[j * k];
for (int i1 = 0; i1 < j * k; i1++) {
char c = s.charAt(i1);
if (hashmap.containsKey(Character.valueOf(c))) {
recipeArray[i1] = ((ItemStack) hashmap
.get(Character.valueOf(c))).copy();
} else {
recipeArray[i1] = null;
}
}
public void addShapelessRecipe(ItemStack output, Object... components)
{
List<ItemStack> ingredients = new ArrayList<ItemStack>();
for (int j = 0; j < components.length; j++)
{
Object obj = components[j];
if (obj instanceof ItemStack)
{
ingredients.add(((ItemStack) obj).copy());
continue;
}
if (obj instanceof Item)
{
ingredients.add(new ItemStack((Item) obj));
continue;
}
if (obj instanceof Block)
{
ingredients.add(new ItemStack((Block) obj));
} else
{
throw new RuntimeException("Invalid shapeless recipe!");
}
}
recipes.add(new ShapedRecipes(j, k, recipeArray, output));
}
recipes.add(new ShapelessRecipes(output, ingredients));
}
public void addShapelessRecipe(ItemStack output, Object... components) {
List<ItemStack> ingredients = new ArrayList<ItemStack>();
for (int j = 0; j < components.length; j++) {
Object obj = components[j];
if (obj instanceof ItemStack) {
ingredients.add(((ItemStack) obj).copy());
continue;
}
if (obj instanceof Item) {
ingredients.add(new ItemStack((Item) obj));
continue;
}
if (obj instanceof Block) {
ingredients.add(new ItemStack((Block) obj));
} else {
throw new RuntimeException("Invalid shapeless recipe!");
}
}
public ItemStack findMatchingRecipe(InventoryCrafting inv, World world)
{
for (int k = 0; k < recipes.size(); k++)
{
IRecipe irecipe = (IRecipe) recipes.get(k);
if (irecipe.matches(inv, world))
{
return irecipe.getCraftingResult(inv);
}
}
recipes.add(new ShapelessRecipes(output, ingredients));
}
return null;
}
public ItemStack findMatchingRecipe(InventoryCrafting inv, World world) {
for (int k = 0; k < recipes.size(); k++) {
IRecipe irecipe = (IRecipe) recipes.get(k);
if (irecipe.matches(inv, world)) {
return irecipe.getCraftingResult(inv);
}
}
return null;
}
public List<IRecipe> getRecipeList() {
return recipes;
}
public List<IRecipe> getRecipeList()
{
return recipes;
}
}

View file

@ -1,15 +1,17 @@
package techreborn.api;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.List;
public class ScrapboxList {
import net.minecraft.item.ItemStack;
public class ScrapboxList
{
public static List<ItemStack> stacks = new ArrayList<ItemStack>();
public static void addItemStackToList(ItemStack stack){
public static void addItemStackToList(ItemStack stack)
{
stacks.add(stack);
}
}

View file

@ -5,17 +5,21 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import techreborn.api.upgrade.IMachineUpgrade;
public class SlotUpgrade extends Slot{
public class SlotUpgrade extends Slot
{
public SlotUpgrade(IInventory inventoryIn, int index, int xPosition, int yPosition) {
public SlotUpgrade(IInventory inventoryIn, int index, int xPosition, int yPosition)
{
super(inventoryIn, index, xPosition, yPosition);
}
@Override
public boolean isItemValid(ItemStack stack) {
if(stack.getItem() instanceof IMachineUpgrade){
public boolean isItemValid(ItemStack stack)
{
if (stack.getItem() instanceof IMachineUpgrade)
{
return true;
}
else return false;
} else
return false;
}
}

View file

@ -3,34 +3,37 @@ package techreborn.api;
import net.minecraft.item.ItemStack;
import techreborn.api.recipe.IRecipeCompact;
public final class TechRebornAPI {
public final class TechRebornAPI
{
public static IRecipeCompact recipeCompact;
public static IRecipeCompact recipeCompact;
public static void addRollingOreMachinceRecipe(ItemStack output,
Object... components) {
RollingMachineRecipe.instance.addShapedOreRecipe(output, components);
}
public static void addRollingOreMachinceRecipe(ItemStack output, Object... components)
{
RollingMachineRecipe.instance.addShapedOreRecipe(output, components);
}
public static void addShapelessOreRollingMachinceRecipe(ItemStack output,
Object... components) {
RollingMachineRecipe.instance.addShapelessOreRecipe(output, components);
}
public static void addShapelessOreRollingMachinceRecipe(ItemStack output, Object... components)
{
RollingMachineRecipe.instance.addShapelessOreRecipe(output, components);
}
public static void addRollingMachinceRecipe(ItemStack output,
Object... components) {
RollingMachineRecipe.instance.addRecipe(output, components);
}
public static void addRollingMachinceRecipe(ItemStack output, Object... components)
{
RollingMachineRecipe.instance.addRecipe(output, components);
}
public static void addShapelessRollingMachinceRecipe(ItemStack output,
Object... components) {
RollingMachineRecipe.instance.addShapelessRecipe(output, components);
}
public static void addShapelessRollingMachinceRecipe(ItemStack output, Object... components)
{
RollingMachineRecipe.instance.addShapelessRecipe(output, components);
}
}
class RegisteredItemRecipe extends Exception {
public RegisteredItemRecipe(String message) {
super(message);
}
class RegisteredItemRecipe extends Exception
{
public RegisteredItemRecipe(String message)
{
super(message);
}
}

View file

@ -1,82 +1,49 @@
package techreborn.api;
import net.minecraft.block.Block;
public class TechRebornBlocks {
public class TechRebornBlocks
{
public static Block getBlock(String name) {
try {
Object e = Class.forName("techreborn.init.ModBlocks").getField(name).get(null);
return e instanceof Block ? (Block) e : null;
} catch (NoSuchFieldException e1) {
e1.printStackTrace();
return null;
} catch (IllegalAccessException e) {
e.printStackTrace();
return null;
} catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}
public static Block getBlock(String name)
{
try
{
Object e = Class.forName("techreborn.init.ModBlocks").getField(name).get(null);
return e instanceof Block ? (Block) e : null;
} catch (NoSuchFieldException e1)
{
e1.printStackTrace();
return null;
} catch (IllegalAccessException e)
{
e.printStackTrace();
return null;
} catch (ClassNotFoundException e)
{
e.printStackTrace();
return null;
}
}
/**
Full list of blocks.
thermalGenerator
quantumTank
quantumChest
digitalChest
centrifuge
RollingMachine
MachineCasing
BlastFurnace
AlloySmelter
Grinder
ImplosionCompressor
MatterFabricator
ChunkLoader
HighAdvancedMachineBlock
Dragoneggenergysiphoner
Magicenergeyconverter
AssemblyMachine
DieselGenerator
IndustrialElectrolyzer
MagicalAbsorber
Semifluidgenerator
Gasturbine
AlloyFurnace
ChemicalReactor
lathe
platecuttingmachine
Idsu
Aesu
Lesu
Supercondensator
Woodenshelf
Metalshelf
LesuStorage
Distillationtower
ElectricCraftingTable
VacuumFreezer
PlasmaGenerator
FusionControlComputer
ComputerCube
FusionCoil
LightningRod
heatGenerator
industrialSawmill
chargeBench
farm
ore
storage
storage2
machineframe
*/
/**
*
* Full list of blocks.
*
* thermalGenerator quantumTank quantumChest digitalChest centrifuge
* RollingMachine MachineCasing BlastFurnace AlloySmelter Grinder
* ImplosionCompressor MatterFabricator ChunkLoader HighAdvancedMachineBlock
* Dragoneggenergysiphoner Magicenergeyconverter AssemblyMachine
* DieselGenerator IndustrialElectrolyzer MagicalAbsorber Semifluidgenerator
* Gasturbine AlloyFurnace ChemicalReactor lathe platecuttingmachine Idsu
* Aesu Lesu Supercondensator Woodenshelf Metalshelf LesuStorage
* Distillationtower ElectricCraftingTable VacuumFreezer PlasmaGenerator
* FusionControlComputer ComputerCube FusionCoil LightningRod heatGenerator
* industrialSawmill chargeBench farm
*
* ore storage storage2 machineframe
*
*
*/
}

View file

@ -2,79 +2,47 @@ package techreborn.api;
import net.minecraft.item.Item;
public class TechRebornItems {
public class TechRebornItems
{
public static Item getItem(String name) {
try {
Object e = Class.forName("techreborn.init.ModItems").getField(name).get(null);
return e instanceof Item ? (Item) e : null;
} catch (NoSuchFieldException e1) {
e1.printStackTrace();
return null;
} catch (IllegalAccessException e) {
e.printStackTrace();
return null;
} catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}
/*
Items
gems
ingots
nuggets
dusts
smallDusts
tinyDusts
parts
cells
rockCutter
lithiumBatpack
lapotronpack
omniTool
advancedDrill
lapotronicOrb
manuel
uuMatter
plate
rods
crushedOre
purifiedCrushedOre
cloakingDevice
public static Item getItem(String name)
{
try
{
Object e = Class.forName("techreborn.init.ModItems").getField(name).get(null);
return e instanceof Item ? (Item) e : null;
} catch (NoSuchFieldException e1)
{
e1.printStackTrace();
return null;
} catch (IllegalAccessException e)
{
e.printStackTrace();
return null;
} catch (ClassNotFoundException e)
{
e.printStackTrace();
return null;
}
}
bucketBerylium
bucketcalcium
bucketcalciumcarbonate
bucketChlorite
bucketDeuterium
bucketGlyceryl
bucketHelium
bucketHelium3
bucketHeliumplasma
bucketHydrogen
bucketLithium
bucketMercury
bucketMethane
bucketNitrocoalfuel
bucketNitrofuel
bucketNitrogen
bucketNitrogendioxide
bucketPotassium
bucketSilicon
bucketSodium
bucketSodiumpersulfate
bucketTritium
bucketWolframium
hammerIron
hammerDiamond
upgrades
farmPatten
*/
/*
*
* Items
*
* gems ingots nuggets dusts smallDusts tinyDusts parts cells rockCutter
* lithiumBatpack lapotronpack omniTool advancedDrill lapotronicOrb manuel
* uuMatter plate rods crushedOre purifiedCrushedOre cloakingDevice
*
* bucketBerylium bucketcalcium bucketcalciumcarbonate bucketChlorite
* bucketDeuterium bucketGlyceryl bucketHelium bucketHelium3
* bucketHeliumplasma bucketHydrogen bucketLithium bucketMercury
* bucketMethane bucketNitrocoalfuel bucketNitrofuel bucketNitrogen
* bucketNitrogendioxide bucketPotassium bucketSilicon bucketSodium
* bucketSodiumpersulfate bucketTritium bucketWolframium
*
* hammerIron hammerDiamond upgrades farmPatten
*
*/
}

View file

@ -1,4 +1,4 @@
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") package techreborn.api;
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI")
package techreborn.api;
import net.minecraftforge.fml.common.API;

View file

@ -1,86 +1,100 @@
package techreborn.api.reactor;
import net.minecraft.item.ItemStack;
public class FusionReactorRecipe {
public class FusionReactorRecipe
{
/**
* This is the item stack that is required in the top slot
*
* This cannot be null
*/
ItemStack topInput;
/**
* This is the item stack that is required in the top slot
*
* This cannot be null
*/
ItemStack topInput;
/**
* This is the item stack that is required in the bottom slot
*
* This can be null
*/
ItemStack bottomInput;
/**
* This is the item stack that is required in the bottom slot
*
* This can be null
*/
ItemStack bottomInput;
/**
* This is the output stack
*
* This cannot be null
*/
ItemStack output;
/**
* This is the output stack
*
* This cannot be null
*/
ItemStack output;
/**
* This is the required eu that has to be in the rector for the reaction to
* start
*/
double startEU;
/**
* This is the eu that changes every tick, set as a minus number to use
* power and a positive number to gen power.
*/
double euTick;
/**
* This is the required eu that has to be in the rector for the reaction to start
*/
double startEU;
/**
* This is the eu that changes every tick, set as a minus number to use power and a positive number to gen power.
*/
double euTick;
/**
* This is the time in ticks that the reaction takes to complete
*/
int tickTime;
/**
* This is the time in ticks that the reaction takes to complete
*/
int tickTime;
/**
*
* @param topInput
* This is the top slot stack
* @param bottomInput
* This is the bottom slot stack
* @param output
* This is the output stack
* @param startEU
* This is the inital EU amount
* @param euTick
* This is the eu that is transfured every tick
* @param tickTime
* This is the time the recipe takes to process
*/
public FusionReactorRecipe(ItemStack topInput, ItemStack bottomInput, ItemStack output, double startEU,
double euTick, int tickTime)
{
this.topInput = topInput;
this.bottomInput = bottomInput;
this.output = output;
this.startEU = startEU;
this.euTick = euTick;
this.tickTime = tickTime;
}
/**
*
* @param topInput This is the top slot stack
* @param bottomInput This is the bottom slot stack
* @param output This is the output stack
* @param startEU This is the inital EU amount
* @param euTick This is the eu that is transfured every tick
* @param tickTime This is the time the recipe takes to process
*/
public FusionReactorRecipe(ItemStack topInput, ItemStack bottomInput, ItemStack output, double startEU, double euTick, int tickTime) {
this.topInput = topInput;
this.bottomInput = bottomInput;
this.output = output;
this.startEU = startEU;
this.euTick = euTick;
this.tickTime = tickTime;
}
public ItemStack getTopInput()
{
return topInput;
}
public ItemStack getBottomInput()
{
return bottomInput;
}
public ItemStack getTopInput() {
return topInput;
}
public ItemStack getOutput()
{
return output;
}
public ItemStack getBottomInput() {
return bottomInput;
}
public double getStartEU()
{
return startEU;
}
public ItemStack getOutput() {
return output;
}
public double getEuTick()
{
return euTick;
}
public double getStartEU() {
return startEU;
}
public double getEuTick() {
return euTick;
}
public int getTickTime() {
return tickTime;
}
public int getTickTime()
{
return tickTime;
}
}

View file

@ -1,21 +1,23 @@
package techreborn.api.reactor;
import java.util.ArrayList;
public class FusionReactorRecipeHelper {
public class FusionReactorRecipeHelper
{
/**
* This is the list of all the recipes
*/
public static ArrayList<FusionReactorRecipe> reactorRecipes = new ArrayList<FusionReactorRecipe>();
/**
* This is the list of all the recipes
*/
public static ArrayList<FusionReactorRecipe> reactorRecipes = new ArrayList<FusionReactorRecipe>();
/**
* Register your reactor recipe here
*
* @param reactorRecipe the recipe you want to add
*/
public static void registerRecipe(FusionReactorRecipe reactorRecipe){
reactorRecipes.add(reactorRecipe);
}
/**
* Register your reactor recipe here
*
* @param reactorRecipe
* the recipe you want to add
*/
public static void registerRecipe(FusionReactorRecipe reactorRecipe)
{
reactorRecipes.add(reactorRecipe);
}
}

View file

@ -1,4 +1,4 @@
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") package techreborn.api.reactor;
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI")
package techreborn.api.reactor;
import net.minecraftforge.fml.common.API;

View file

@ -1,92 +1,101 @@
package techreborn.api.recipe;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
/**
* Extend this to add a recipe
*/
public abstract class BaseRecipe implements IBaseRecipeType, Cloneable {
public abstract class BaseRecipe implements IBaseRecipeType, Cloneable
{
public ArrayList<ItemStack> inputs;
public ArrayList<ItemStack> inputs;
public String name;
public int tickTime;
public int euPerTick;
private ArrayList<ItemStack> outputs;
private ArrayList<ItemStack> outputs;
public BaseRecipe(String name, int tickTime, int euPerTick)
{
inputs = new ArrayList<ItemStack>();
outputs = new ArrayList<ItemStack>();
this.name = name;
// This adds all new recipes
this.tickTime = tickTime;
this.euPerTick = euPerTick;
}
public String name;
@Override
public ItemStack getOutput(int i)
{
return outputs.get(i).copy();
}
public int tickTime;
@Override
public int getOutputsSize()
{
return outputs.size();
}
public int euPerTick;
public void addOutput(ItemStack stack)
{
outputs.add(stack);
}
public BaseRecipe(String name, int tickTime, int euPerTick) {
inputs = new ArrayList<ItemStack>();
outputs = new ArrayList<ItemStack>();
this.name = name;
//This adds all new recipes
this.tickTime = tickTime;
this.euPerTick = euPerTick;
}
@Override
public List<ItemStack> getInputs()
{
return inputs;
}
@Override
public ItemStack getOutput(int i) {
return outputs.get(i).copy();
}
@Override
public String getRecipeName()
{
return name;
}
@Override
public int getOutputsSize() {
return outputs.size();
}
@Override
public int tickTime()
{
return tickTime;
}
public void addOutput(ItemStack stack) {
outputs.add(stack);
}
@Override
public int euPerTick()
{
return euPerTick;
}
@Override
public boolean canCraft(TileEntity tile)
{
return true;
}
@Override
public List<ItemStack> getInputs() {
return inputs;
}
@Override
public boolean onCraft(TileEntity tile)
{
return true;
}
@Override
public String getRecipeName() {
return name;
}
@Override
public Object clone() throws CloneNotSupportedException
{
return super.clone();
}
@Override
public int tickTime() {
return tickTime;
}
@Override
public boolean useOreDic()
{
return true;
}
@Override
public int euPerTick() {
return euPerTick;
}
@Override
public boolean canCraft(TileEntity tile) {
return true;
}
@Override
public boolean onCraft(TileEntity tile) {
return true;
}
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
@Override
public boolean useOreDic() {
return true;
}
@Override
public List<ItemStack> getOutputs() {
return outputs;
}
@Override
public List<ItemStack> getOutputs()
{
return outputs;
}
}

View file

@ -1,81 +1,87 @@
package techreborn.api.recipe;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import java.util.List;
/**
* This is the base recipe class implement this to make a recipe handler
*/
public interface IBaseRecipeType {
public interface IBaseRecipeType
{
/**
* Use this to get all of the inputs
*
* @return the List of inputs
*/
public List<ItemStack> getInputs();
/**
* Use this to get all of the inputs
*
* @return the List of inputs
*/
public List<ItemStack> getInputs();
/**
* This gets the output form the array list
* @param i get output form position in arraylist
* @return the output
*/
public ItemStack getOutput(int i);
/**
* This gets the output form the array list
*
* @param i
* get output form position in arraylist
* @return the output
*/
public ItemStack getOutput(int i);
/**
* @return The ammount of outputs
*/
public int getOutputsSize();
/**
* @return The ammount of outputs
*/
public int getOutputsSize();
/**
* @return get outputs
*/
public List<ItemStack> getOutputs();
/**
* @return get outputs
*/
public List<ItemStack> getOutputs();
/**
* This is the name to check that the recipe is the one that should be used in
* the tile entity that is set up to process this recipe.
*
* @return The recipeName
*/
public String getRecipeName();
/**
* This is the name to check that the recipe is the one that should be used
* in the tile entity that is set up to process this recipe.
*
* @return The recipeName
*/
public String getRecipeName();
/**
* This should be a user friendly name
*
* @return The user friendly name of the recipe.
*/
public String getUserFreindlyName();
/**
* This should be a user friendly name
*
* @return The user friendly name of the recipe.
*/
public String getUserFreindlyName();
/**
* This is how long the recipe needs to tick for the crafting operation to complete
*
* @return tick length
*/
public int tickTime();
/**
* This is how long the recipe needs to tick for the crafting operation to
* complete
*
* @return tick length
*/
public int tickTime();
/**
* This is how much eu Per tick the machine should use
*
* @return the amount of eu to be used per tick.
*/
public int euPerTick();
/**
* This is how much eu Per tick the machine should use
*
* @return the amount of eu to be used per tick.
*/
public int euPerTick();
/**
* @param tile the tile that is doing the crafting
* @return if true the recipe will craft, if false it will not
*/
public boolean canCraft(TileEntity tile);
/**
* @param tile
* the tile that is doing the crafting
* @return if true the recipe will craft, if false it will not
*/
public boolean canCraft(TileEntity tile);
/**
* @param tile the tile that is doing the crafting
* @return return true if fluid was taken and should craft
*/
public boolean onCraft(TileEntity tile);
/**
* @param tile
* the tile that is doing the crafting
* @return return true if fluid was taken and should craft
*/
public boolean onCraft(TileEntity tile);
public Object clone() throws CloneNotSupportedException;
public Object clone() throws CloneNotSupportedException;
public boolean useOreDic();
public boolean useOreDic();
}

View file

@ -2,7 +2,8 @@ package techreborn.api.recipe;
import net.minecraft.item.ItemStack;
public interface IRecipeCompact {
public interface IRecipeCompact
{
ItemStack getItem(String name);
ItemStack getItem(String name);
}

View file

@ -1,5 +1,7 @@
package techreborn.api.recipe;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import reborncore.api.power.IEnergyInterfaceTile;
@ -8,327 +10,417 @@ import reborncore.common.tile.TileMachineBase;
import reborncore.common.util.Inventory;
import reborncore.common.util.ItemUtils;
import java.util.ArrayList;
/**
* Use this in your tile entity to craft things
*/
public class RecipeCrafter {
public class RecipeCrafter
{
/**
* This is the recipe type to use
*/
public String recipeName;
/**
* This is the recipe type to use
*/
public String recipeName;
/**
* This is the parent tile
*/
public TileMachineBase parentTile;
/**
* This is the parent tile
*/
public TileMachineBase parentTile;
/**
* This is the place to use the power from
*/
public IEnergyInterfaceTile energy;
/**
* This is the place to use the power from
*/
public IEnergyInterfaceTile energy;
/**
* This is the amount of inputs that the setRecipe has
*/
public int inputs;
/**
* This is the amount of inputs that the setRecipe has
*/
public int inputs;
/**
* This is the amount of outputs that the recipe has
*/
public int outputs;
/**
* This is the amount of outputs that the recipe has
*/
public int outputs;
/**
* This is the inventory to use for the crafting
*/
public Inventory inventory;
/**
* This is the inventory to use for the crafting
*/
public Inventory inventory;
/**
* This is the list of the slots that the crafting logic should look for the input item stacks.
*/
public int[] inputSlots;
/**
* This is the list of the slots that the crafting logic should look for the
* input item stacks.
*/
public int[] inputSlots;
/**
* This is the list for the slots that the crafting logic should look fot the output item stacks.
*/
public int[] outputSlots;
/**
* This is the list for the slots that the crafting logic should look fot
* the output item stacks.
*/
public int[] outputSlots;
public IBaseRecipeType currentRecipe;
public int currentTickTime = 0;
public int currentNeededTicks = 1;// Set to 1 to stop rare crashes
double lastEnergy;
/**
* This is used to change the speed of the crafting operation.
* <p/>
* 0 = none; 0.2 = 20% speed increase 0.75 = 75% increase
*/
double speedMultiplier = 0;
/**
* This is used to change the power of the crafting operation.
* <p/>
* 1 = none; 1.2 = 20% speed increase 1.75 = 75% increase 5 = uses 5 times
* more power
*/
double powerMultiplier = 1;
int ticksSinceLastChange;
/**
* This is the constructor, not a lot to say here :P
*
* @param recipeName The recipe name that should be crafted
* @param parentTile The tile that wil be using this recipe crafter
* @param inputs The amount of input slots
* @param outputs The amount of output slots
* @param inventory The inventory of the machine
* @param inputSlots A list of the input slot ids
* @param outputSlots A list of output slot ids
*/
public RecipeCrafter(String recipeName, TileMachineBase parentTile, int inputs, int outputs, Inventory inventory, int[] inputSlots, int[] outputSlots) {
this.recipeName = recipeName;
this.parentTile = parentTile;
if (parentTile instanceof IEnergyInterfaceTile) {
energy = (IEnergyInterfaceTile) parentTile;
}
this.inputs = inputs;
this.outputs = outputs;
this.inventory = inventory;
this.inputSlots = inputSlots;
this.outputSlots = outputSlots;
}
/**
* This is the constructor, not a lot to say here :P
*
* @param recipeName
* The recipe name that should be crafted
* @param parentTile
* The tile that wil be using this recipe crafter
* @param inputs
* The amount of input slots
* @param outputs
* The amount of output slots
* @param inventory
* The inventory of the machine
* @param inputSlots
* A list of the input slot ids
* @param outputSlots
* A list of output slot ids
*/
public RecipeCrafter(String recipeName, TileMachineBase parentTile, int inputs, int outputs, Inventory inventory,
int[] inputSlots, int[] outputSlots)
{
this.recipeName = recipeName;
this.parentTile = parentTile;
if (parentTile instanceof IEnergyInterfaceTile)
{
energy = (IEnergyInterfaceTile) parentTile;
}
this.inputs = inputs;
this.outputs = outputs;
this.inventory = inventory;
this.inputSlots = inputSlots;
this.outputSlots = outputSlots;
}
/**
* Call this on the tile tick
*/
public void updateEntity()
{
if (parentTile.getWorld().isRemote)
{
return;
}
ticksSinceLastChange++;
if (ticksSinceLastChange == 20)
{// Force a has chanced every second
inventory.hasChanged = true;
ticksSinceLastChange = 0;
}
if (currentRecipe == null && inventory.hasChanged)
{// It will now look for new recipes.
currentTickTime = 0;
for (IBaseRecipeType recipe : RecipeHandler.getRecipeClassFromName(recipeName))
{
if (recipe.canCraft(parentTile) && hasAllInputs(recipe))
{// This checks to see if it has all of the inputs
boolean canGiveInvAll = true;
for (int i = 0; i < recipe.getOutputsSize(); i++)
{// This checks to see if it can fit all of the outputs
if (!canFitStack(recipe.getOutput(i), outputSlots[i], recipe.useOreDic()))
{
canGiveInvAll = false;
return;
}
}
if (canGiveInvAll)
{
setCurrentRecipe(recipe);// Sets the current recipe then
// syncs
this.currentNeededTicks = (int) (currentRecipe.tickTime() * (1.0 - speedMultiplier));
this.currentTickTime = -1;
setIsActive();
} else
{
this.currentTickTime = -1;
}
}
}
} else
{
if (inventory.hasChanged && !hasAllInputs())
{// If it doesn't have all the inputs reset
currentRecipe = null;
currentTickTime = -1;
setIsActive();
}
if (currentRecipe != null && currentTickTime >= currentNeededTicks)
{// If it has reached the recipe tick time
boolean canGiveInvAll = true;
for (int i = 0; i < currentRecipe.getOutputsSize(); i++)
{// Checks to see if it can fit the output
if (!canFitStack(currentRecipe.getOutput(i), outputSlots[i], currentRecipe.useOreDic()))
{
canGiveInvAll = false;
}
}
ArrayList<Integer> filledSlots = new ArrayList<Integer>();// The
// slots
// that
// have
// been
// filled
if (canGiveInvAll && currentRecipe.onCraft(parentTile))
{
for (int i = 0; i < currentRecipe.getOutputsSize(); i++)
{
if (!filledSlots.contains(outputSlots[i]))
{// checks it has not been filled
fitStack(currentRecipe.getOutput(i).copy(), outputSlots[i]);// fills
// the
// slot
// with
// the
// output
// stack
filledSlots.add(outputSlots[i]);
}
}
useAllInputs();// this uses all the inputs
currentRecipe = null;// resets
currentTickTime = -1;
setIsActive();
}
} else if (currentRecipe != null && currentTickTime < currentNeededTicks)
{
if (energy.canUseEnergy(getEuPerTick()))
{// This uses the power
energy.useEnergy(getEuPerTick());
currentTickTime++;// increase the ticktime
}
}
}
if (inventory.hasChanged)
{
inventory.hasChanged = false;
}
}
public IBaseRecipeType currentRecipe;
public int currentTickTime = 0;
public int currentNeededTicks = 1;//Set to 1 to stop rare crashes
double lastEnergy;
public boolean hasAllInputs()
{
if (currentRecipe == null)
{
return false;
}
for (ItemStack input : currentRecipe.getInputs())
{
Boolean hasItem = false;
for (int inputSlot : inputSlots)
{// Checks to see if it can find the input
if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputSlot), true, true,
currentRecipe.useOreDic()) && inventory.getStackInSlot(inputSlot).stackSize >= input.stackSize)
{
hasItem = true;
}
}
if (!hasItem)
return false;
}
return true;
}
/**
* This is used to change the speed of the crafting operation.
* <p/>
* 0 = none;
* 0.2 = 20% speed increase
* 0.75 = 75% increase
*/
double speedMultiplier = 0;
public boolean hasAllInputs(IBaseRecipeType recipeType)
{
if (recipeType == null)
{
return false;
}
for (ItemStack input : recipeType.getInputs())
{
Boolean hasItem = false;
for (int inputslot : inputSlots)
{
if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputslot), true, true,
recipeType.useOreDic()) && inventory.getStackInSlot(inputslot).stackSize >= input.stackSize)
{
hasItem = true;
}
}
if (!hasItem)
return false;
}
return true;
}
/**
* This is used to change the power of the crafting operation.
* <p/>
* 1 = none;
* 1.2 = 20% speed increase
* 1.75 = 75% increase
* 5 = uses 5 times more power
*/
double powerMultiplier = 1;
public void useAllInputs()
{
if (currentRecipe == null)
{
return;
}
for (ItemStack input : currentRecipe.getInputs())
{
for (int inputSlot : inputSlots)
{// Uses all of the inputs
if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputSlot), true, true,
currentRecipe.useOreDic()))
{
inventory.decrStackSize(inputSlot, input.stackSize);
break;
}
}
}
}
int ticksSinceLastChange;
public boolean canFitStack(ItemStack stack, int slot, boolean oreDic)
{// Checks to see if it can fit the stack
if (stack == null)
{
return true;
}
if (inventory.getStackInSlot(slot) == null)
{
return true;
}
if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, oreDic))
{
if (stack.stackSize + inventory.getStackInSlot(slot).stackSize <= stack.getMaxStackSize())
{
return true;
}
}
return false;
}
/**
* Call this on the tile tick
*/
public void updateEntity() {
if (parentTile.getWorld().isRemote) {
return;
}
ticksSinceLastChange++;
if (ticksSinceLastChange == 20) {//Force a has chanced every second
inventory.hasChanged = true;
ticksSinceLastChange = 0;
}
if (currentRecipe == null && inventory.hasChanged) {//It will now look for new recipes.
currentTickTime = 0;
for (IBaseRecipeType recipe : RecipeHandler.getRecipeClassFromName(recipeName)) {
if (recipe.canCraft(parentTile) && hasAllInputs(recipe)) {//This checks to see if it has all of the inputs
boolean canGiveInvAll = true;
for (int i = 0; i < recipe.getOutputsSize(); i++) {//This checks to see if it can fit all of the outputs
if (!canFitStack(recipe.getOutput(i), outputSlots[i], recipe.useOreDic())) {
canGiveInvAll = false;
return;
}
}
if (canGiveInvAll) {
setCurrentRecipe(recipe);//Sets the current recipe then syncs
this.currentNeededTicks = (int) (currentRecipe.tickTime() * (1.0 - speedMultiplier));
this.currentTickTime = -1;
setIsActive();
} else {
this.currentTickTime = -1;
}
}
}
} else {
if (inventory.hasChanged && !hasAllInputs()) {//If it doesn't have all the inputs reset
currentRecipe = null;
currentTickTime = -1;
setIsActive();
}
if (currentRecipe != null && currentTickTime >= currentNeededTicks) {//If it has reached the recipe tick time
boolean canGiveInvAll = true;
for (int i = 0; i < currentRecipe.getOutputsSize(); i++) {//Checks to see if it can fit the output
if (!canFitStack(currentRecipe.getOutput(i), outputSlots[i], currentRecipe.useOreDic())) {
canGiveInvAll = false;
}
}
ArrayList<Integer> filledSlots = new ArrayList<Integer>();//The slots that have been filled
if (canGiveInvAll && currentRecipe.onCraft(parentTile)) {
for (int i = 0; i < currentRecipe.getOutputsSize(); i++) {
if (!filledSlots.contains(outputSlots[i])) {//checks it has not been filled
fitStack(currentRecipe.getOutput(i).copy(), outputSlots[i]);//fills the slot with the output stack
filledSlots.add(outputSlots[i]);
}
}
useAllInputs();//this uses all the inputs
currentRecipe = null;//resets
currentTickTime = -1;
setIsActive();
}
} else if (currentRecipe != null && currentTickTime < currentNeededTicks) {
if (energy.canUseEnergy(getEuPerTick())) {//This uses the power
energy.useEnergy(getEuPerTick());
currentTickTime++;//increase the ticktime
}
}
}
if (inventory.hasChanged) {
inventory.hasChanged = false;
}
}
public void fitStack(ItemStack stack, int slot)
{// This fits a stack into a slot
if (stack == null)
{
return;
}
if (inventory.getStackInSlot(slot) == null)
{// If the slot is empty set the contents
inventory.setInventorySlotContents(slot, stack);
return;
}
if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, currentRecipe.useOreDic()))
{// If the slot has stuff in
if (stack.stackSize + inventory.getStackInSlot(slot).stackSize <= stack.getMaxStackSize())
{// Check to see if it fits
ItemStack newStack = stack.copy();
newStack.stackSize = inventory.getStackInSlot(slot).stackSize + stack.stackSize;// Sets
// the
// new
// stack
// size
inventory.setInventorySlotContents(slot, newStack);
}
}
}
public boolean hasAllInputs() {
if (currentRecipe == null) {
return false;
}
for (ItemStack input : currentRecipe.getInputs()) {
Boolean hasItem = false;
for (int inputSlot : inputSlots) {//Checks to see if it can find the input
if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputSlot), true, true, currentRecipe.useOreDic()) && inventory.getStackInSlot(inputSlot).stackSize >= input.stackSize) {
hasItem = true;
}
}
if (!hasItem)
return false;
}
return true;
}
public void readFromNBT(NBTTagCompound tag)
{
NBTTagCompound data = tag.getCompoundTag("Crater");
public boolean hasAllInputs(IBaseRecipeType recipeType) {
if (recipeType == null) {
return false;
}
for (ItemStack input : recipeType.getInputs()) {
Boolean hasItem = false;
for (int inputslot : inputSlots) {
if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputslot), true, true, recipeType.useOreDic()) && inventory.getStackInSlot(inputslot).stackSize >= input.stackSize) {
hasItem = true;
}
}
if (!hasItem)
return false;
}
return true;
}
if (data.hasKey("currentTickTime"))
currentTickTime = data.getInteger("currentTickTime");
public void useAllInputs() {
if (currentRecipe == null) {
return;
}
for (ItemStack input : currentRecipe.getInputs()) {
for (int inputSlot : inputSlots) {//Uses all of the inputs
if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputSlot), true, true, currentRecipe.useOreDic())) {
inventory.decrStackSize(inputSlot, input.stackSize);
break;
}
}
}
}
if (parentTile != null && parentTile.getWorld() != null && parentTile.getWorld().isRemote)
{
parentTile.getWorld().notifyBlockUpdate(parentTile.getPos(),
parentTile.getWorld().getBlockState(parentTile.getPos()),
parentTile.getWorld().getBlockState(parentTile.getPos()), 3);
parentTile.getWorld().markBlockRangeForRenderUpdate(parentTile.getPos().getX(), parentTile.getPos().getY(),
parentTile.getPos().getZ(), parentTile.getPos().getX(), parentTile.getPos().getY(),
parentTile.getPos().getZ());
}
}
public boolean canFitStack(ItemStack stack, int slot, boolean oreDic) {//Checks to see if it can fit the stack
if (stack == null) {
return true;
}
if (inventory.getStackInSlot(slot) == null) {
return true;
}
if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, oreDic)) {
if (stack.stackSize + inventory.getStackInSlot(slot).stackSize <= stack.getMaxStackSize()) {
return true;
}
}
return false;
}
public void writeToNBT(NBTTagCompound tag)
{
public void fitStack(ItemStack stack, int slot) {//This fits a stack into a slot
if (stack == null) {
return;
}
if (inventory.getStackInSlot(slot) == null) {//If the slot is empty set the contents
inventory.setInventorySlotContents(slot, stack);
return;
}
if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, currentRecipe.useOreDic())) {//If the slot has stuff in
if (stack.stackSize + inventory.getStackInSlot(slot).stackSize <= stack.getMaxStackSize()) {//Check to see if it fits
ItemStack newStack = stack.copy();
newStack.stackSize = inventory.getStackInSlot(slot).stackSize + stack.stackSize;//Sets the new stack size
inventory.setInventorySlotContents(slot, newStack);
}
}
}
NBTTagCompound data = new NBTTagCompound();
public void readFromNBT(NBTTagCompound tag) {
NBTTagCompound data = tag.getCompoundTag("Crater");
data.setDouble("currentTickTime", currentTickTime);
if (data.hasKey("currentTickTime"))
currentTickTime = data.getInteger("currentTickTime");
tag.setTag("Crater", data);
}
if (parentTile != null && parentTile.getWorld() != null && parentTile.getWorld().isRemote) {
parentTile.getWorld().notifyBlockUpdate(parentTile.getPos(), parentTile.getWorld().getBlockState(parentTile.getPos()), parentTile.getWorld().getBlockState(parentTile.getPos()), 3);
parentTile.getWorld().markBlockRangeForRenderUpdate(parentTile.getPos().getX(), parentTile.getPos().getY(), parentTile.getPos().getZ(), parentTile.getPos().getX(), parentTile.getPos().getY(), parentTile.getPos().getZ());
}
}
private boolean isActive()
{
return currentRecipe != null && energy.getEnergy() >= currentRecipe.euPerTick();
}
public void writeToNBT(NBTTagCompound tag) {
public void addSpeedMulti(double amount)
{
if (speedMultiplier + amount <= 0.99)
{
speedMultiplier += amount;
} else
{
speedMultiplier = 0.99;
}
}
NBTTagCompound data = new NBTTagCompound();
public void resetSpeedMulti()
{
speedMultiplier = 0;
}
data.setDouble("currentTickTime", currentTickTime);
public double getSpeedMultiplier()
{
return speedMultiplier;
}
tag.setTag("Crater", data);
}
public void addPowerMulti(double amount)
{
powerMultiplier += amount;
}
public void resetPowerMulti()
{
powerMultiplier = 1;
}
private boolean isActive() {
return currentRecipe != null && energy.getEnergy() >= currentRecipe.euPerTick();
}
public double getPowerMultiplier()
{
return powerMultiplier;
}
public void addSpeedMulti(double amount) {
if (speedMultiplier + amount <= 0.99) {
speedMultiplier += amount;
} else {
speedMultiplier = 0.99;
}
}
public double getEuPerTick()
{
return currentRecipe.euPerTick() * powerMultiplier;
}
public void resetSpeedMulti() {
speedMultiplier = 0;
}
public void setIsActive()
{
if (parentTile.getWorld().getBlockState(parentTile.getPos()).getBlock() instanceof BlockMachineBase)
{
BlockMachineBase blockMachineBase = (BlockMachineBase) parentTile.getWorld()
.getBlockState(parentTile.getPos()).getBlock();
blockMachineBase.setActive(isActive(), parentTile.getWorld(), parentTile.getPos());
}
parentTile.getWorld().notifyBlockUpdate(parentTile.getPos(),
parentTile.getWorld().getBlockState(parentTile.getPos()),
parentTile.getWorld().getBlockState(parentTile.getPos()), 3);
}
public double getSpeedMultiplier() {
return speedMultiplier;
}
public void addPowerMulti(double amount) {
powerMultiplier += amount;
}
public void resetPowerMulti() {
powerMultiplier = 1;
}
public double getPowerMultiplier() {
return powerMultiplier;
}
public double getEuPerTick() {
return currentRecipe.euPerTick() * powerMultiplier;
}
public void setIsActive() {
if(parentTile.getWorld().getBlockState(parentTile.getPos()).getBlock() instanceof BlockMachineBase){
BlockMachineBase blockMachineBase = (BlockMachineBase) parentTile.getWorld().getBlockState(parentTile.getPos()).getBlock();
blockMachineBase.setActive(isActive(), parentTile.getWorld(), parentTile.getPos());
}
parentTile.getWorld().notifyBlockUpdate(parentTile.getPos(), parentTile.getWorld().getBlockState(parentTile.getPos()), parentTile.getWorld().getBlockState(parentTile.getPos()), 3);
}
public void setCurrentRecipe(IBaseRecipeType recipe) {
try {
this.currentRecipe = (IBaseRecipeType) recipe.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
}
public void setCurrentRecipe(IBaseRecipeType recipe)
{
try
{
this.currentRecipe = (IBaseRecipeType) recipe.clone();
} catch (CloneNotSupportedException e)
{
e.printStackTrace();
}
}
}

View file

@ -1,103 +1,127 @@
package techreborn.api.recipe;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.time.StopWatch;
import reborncore.common.util.ItemUtils;
import techreborn.Core;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.item.ItemStack;
public class RecipeHandler {
import org.apache.commons.lang3.time.StopWatch;
/**
* This is the array list of all of the recipes for all of the machines
*/
public static final ArrayList<IBaseRecipeType> recipeList = new ArrayList<IBaseRecipeType>();
import reborncore.common.util.ItemUtils;
import techreborn.Core;
public class RecipeHandler
{
public static HashMap<IBaseRecipeType, String> stackMap = new HashMap<IBaseRecipeType, String>();
/**
* This is a list of all the registered machine names.
*/
public static ArrayList<String> machineNames = new ArrayList<String>();
/**
* This is the array list of all of the recipes for all of the machines
*/
public static final ArrayList<IBaseRecipeType> recipeList = new ArrayList<IBaseRecipeType>();
/**
* Use this to get all of the recipes form a recipe name
*
* @param name the name that the recipe was resisted as.
* @return A list of all the recipes of a given name.
*/
public static List<IBaseRecipeType> getRecipeClassFromName(String name) {
List<IBaseRecipeType> baseRecipeList = new ArrayList<IBaseRecipeType>();
for (IBaseRecipeType baseRecipe : recipeList) {
if (baseRecipe.getRecipeName().equals(name)) {
baseRecipeList.add(baseRecipe);
}
}
return baseRecipeList;
}
public static HashMap<IBaseRecipeType, String> stackMap = new HashMap<IBaseRecipeType, String>();
/**
* This is a list of all the registered machine names.
*/
public static ArrayList<String> machineNames = new ArrayList<String>();
public static String getUserFreindlyName(String name) {
for (IBaseRecipeType baseRecipe : recipeList) {
if (baseRecipe.getRecipeName().equals(name)) {
return baseRecipe.getUserFreindlyName();
}
}
return "";
}
/**
* Use this to get all of the recipes form a recipe name
*
* @param name
* the name that the recipe was resisted as.
* @return A list of all the recipes of a given name.
*/
public static List<IBaseRecipeType> getRecipeClassFromName(String name)
{
List<IBaseRecipeType> baseRecipeList = new ArrayList<IBaseRecipeType>();
for (IBaseRecipeType baseRecipe : recipeList)
{
if (baseRecipe.getRecipeName().equals(name))
{
baseRecipeList.add(baseRecipe);
}
}
return baseRecipeList;
}
/**
* Add a recipe to the system
*
* @param recipe The recipe to add to the system.
*/
public static void addRecipe(IBaseRecipeType recipe) {
if (recipe == null) {
return;
}
if (recipeList.contains(recipe)) {
return;
}
// if (!RecipeConfigManager.canLoadRecipe(recipe)) {
// return;
// }
if (!machineNames.contains(recipe.getRecipeName())) {
machineNames.add(recipe.getRecipeName());
}
recipeList.add(recipe);
StringBuffer buffer = new StringBuffer();
for (StackTraceElement ste : Thread.currentThread().getStackTrace()) {
buffer.append(ste);
}
stackMap.put(recipe, buffer.toString());
}
public static String getUserFreindlyName(String name)
{
for (IBaseRecipeType baseRecipe : recipeList)
{
if (baseRecipe.getRecipeName().equals(name))
{
return baseRecipe.getUserFreindlyName();
}
}
return "";
}
/**
* Add a recipe to the system
*
* @param recipe
* The recipe to add to the system.
*/
public static void addRecipe(IBaseRecipeType recipe)
{
if (recipe == null)
{
return;
}
if (recipeList.contains(recipe))
{
return;
}
// if (!RecipeConfigManager.canLoadRecipe(recipe)) {
// return;
// }
if (!machineNames.contains(recipe.getRecipeName()))
{
machineNames.add(recipe.getRecipeName());
}
recipeList.add(recipe);
StringBuffer buffer = new StringBuffer();
for (StackTraceElement ste : Thread.currentThread().getStackTrace())
{
buffer.append(ste);
}
stackMap.put(recipe, buffer.toString());
}
public static void scanForDupeRecipes() throws Exception {
StopWatch watch = new StopWatch();
watch.start();
for (IBaseRecipeType baseRecipeType : recipeList) {
for (IBaseRecipeType recipe : recipeList) {
if (baseRecipeType != recipe && baseRecipeType.getRecipeName().equals(recipe.getRecipeName())) {
for (int i = 0; i < baseRecipeType.getInputs().size(); i++) {
if (ItemUtils.isItemEqual(baseRecipeType.getInputs().get(i), recipe.getInputs().get(i), true, false, false)) {
StringBuffer itemInfo = new StringBuffer();
for (ItemStack inputs : baseRecipeType.getInputs()) {
itemInfo.append(":" + inputs.getItem().getUnlocalizedName() + "," + inputs.getDisplayName() + "," + inputs.stackSize);
}
Core.logHelper.all(stackMap.get(baseRecipeType));
// throw new Exception("Found a duplicate recipe for " + baseRecipeType.getRecipeName() + " with inputs " + itemInfo.toString());
}
}
}
}
}
Core.logHelper.all(watch + " : Scanning dupe recipes");
watch.stop();
public static void scanForDupeRecipes() throws Exception
{
StopWatch watch = new StopWatch();
watch.start();
for (IBaseRecipeType baseRecipeType : recipeList)
{
for (IBaseRecipeType recipe : recipeList)
{
if (baseRecipeType != recipe && baseRecipeType.getRecipeName().equals(recipe.getRecipeName()))
{
for (int i = 0; i < baseRecipeType.getInputs().size(); i++)
{
if (ItemUtils.isItemEqual(baseRecipeType.getInputs().get(i), recipe.getInputs().get(i), true,
false, false))
{
StringBuffer itemInfo = new StringBuffer();
for (ItemStack inputs : baseRecipeType.getInputs())
{
itemInfo.append(":" + inputs.getItem().getUnlocalizedName() + ","
+ inputs.getDisplayName() + "," + inputs.stackSize);
}
Core.logHelper.all(stackMap.get(baseRecipeType));
// throw new Exception("Found a duplicate recipe for
// " + baseRecipeType.getRecipeName() + " with
// inputs " + itemInfo.toString());
}
}
}
}
}
Core.logHelper.all(watch + " : Scanning dupe recipes");
watch.stop();
}
}
}

View file

@ -3,17 +3,21 @@ package techreborn.api.recipe;
import net.minecraft.item.ItemStack;
import techreborn.items.ItemParts;
import techreborn.lib.Reference;
//THIS is only here to trick JEI into showing recipes for the recycler
public class RecyclerRecipe extends BaseRecipe {
public RecyclerRecipe(ItemStack input) {
//THIS is only here to trick JEI into showing recipes for the recycler
public class RecyclerRecipe extends BaseRecipe
{
public RecyclerRecipe(ItemStack input)
{
super(Reference.recyclerRecipe, 0, 0);
inputs.add(input);
addOutput(ItemParts.getPartByName("scrap"));
}
@Override
public String getUserFreindlyName() {
public String getUserFreindlyName()
{
return "Recycler";
}
}

View file

@ -4,16 +4,19 @@ import net.minecraft.item.ItemStack;
import techreborn.init.ModItems;
import techreborn.lib.Reference;
public class ScrapboxRecipe extends BaseRecipe {
public class ScrapboxRecipe extends BaseRecipe
{
public ScrapboxRecipe(ItemStack output) {
public ScrapboxRecipe(ItemStack output)
{
super(Reference.scrapboxRecipe, 0, 0);
inputs.add(new ItemStack(ModItems.scrapBox));
addOutput(output);
}
@Override
public String getUserFreindlyName() {
public String getUserFreindlyName()
{
return "Scrapbox";
}
}

View file

@ -4,20 +4,23 @@ import net.minecraft.item.ItemStack;
import techreborn.api.recipe.BaseRecipe;
import techreborn.lib.Reference;
public class AlloySmelterRecipe extends BaseRecipe {
public class AlloySmelterRecipe extends BaseRecipe
{
public AlloySmelterRecipe(ItemStack input1, ItemStack input2, ItemStack output1, int tickTime, int euPerTick) {
super(Reference.alloySmelteRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
}
public AlloySmelterRecipe(ItemStack input1, ItemStack input2, ItemStack output1, int tickTime, int euPerTick)
{
super(Reference.alloySmelteRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
}
@Override
public String getUserFreindlyName() {
return "Alloy Smelter";
}
@Override
public String getUserFreindlyName()
{
return "Alloy Smelter";
}
}

View file

@ -4,20 +4,23 @@ import net.minecraft.item.ItemStack;
import techreborn.api.recipe.BaseRecipe;
import techreborn.lib.Reference;
public class AssemblingMachineRecipe extends BaseRecipe {
public class AssemblingMachineRecipe extends BaseRecipe
{
public AssemblingMachineRecipe(ItemStack input1, ItemStack input2, ItemStack output1, int tickTime, int euPerTick) {
super(Reference.assemblingMachineRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
}
public AssemblingMachineRecipe(ItemStack input1, ItemStack input2, ItemStack output1, int tickTime, int euPerTick)
{
super(Reference.assemblingMachineRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
}
@Override
public String getUserFreindlyName() {
return "Assembling Machine";
}
@Override
public String getUserFreindlyName()
{
return "Assembling Machine";
}
}

View file

@ -6,41 +6,47 @@ import techreborn.api.recipe.BaseRecipe;
import techreborn.lib.Reference;
import techreborn.tiles.TileBlastFurnace;
public class BlastFurnaceRecipe extends BaseRecipe {
public class BlastFurnaceRecipe extends BaseRecipe
{
public int neededHeat;
public int neededHeat;
public BlastFurnaceRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, int tickTime,
int euPerTick, int neededHeat)
{
super(Reference.blastFurnaceRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
if (output2 != null)
addOutput(output2);
public BlastFurnaceRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, int tickTime, int euPerTick, int neededHeat) {
super(Reference.blastFurnaceRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
if (output2 != null)
addOutput(output2);
this.neededHeat = neededHeat;
}
this.neededHeat = neededHeat;
}
@Override
public String getUserFreindlyName()
{
return "Blast Furnace";
}
@Override
public String getUserFreindlyName() {
return "Blast Furnace";
}
@Override
public boolean canCraft(TileEntity tile)
{
if (tile instanceof TileBlastFurnace)
{
TileBlastFurnace blastFurnace = (TileBlastFurnace) tile;
return blastFurnace.getHeat() >= neededHeat;
}
return false;
}
@Override
public boolean canCraft(TileEntity tile) {
if (tile instanceof TileBlastFurnace) {
TileBlastFurnace blastFurnace = (TileBlastFurnace) tile;
return blastFurnace.getHeat() >= neededHeat;
}
return false;
}
@Override
public boolean onCraft(TileEntity tile) {
return super.onCraft(tile);
}
@Override
public boolean onCraft(TileEntity tile)
{
return super.onCraft(tile);
}
}

View file

@ -4,26 +4,30 @@ import net.minecraft.item.ItemStack;
import techreborn.api.recipe.BaseRecipe;
import techreborn.lib.Reference;
public class CentrifugeRecipe extends BaseRecipe {
public class CentrifugeRecipe extends BaseRecipe
{
public CentrifugeRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int euPerTick) {
super(Reference.centrifugeRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
if (output2 != null)
addOutput(output2);
if (output3 != null)
addOutput(output3);
if (output4 != null)
addOutput(output4);
}
public CentrifugeRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, ItemStack output3,
ItemStack output4, int tickTime, int euPerTick)
{
super(Reference.centrifugeRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
if (output2 != null)
addOutput(output2);
if (output3 != null)
addOutput(output3);
if (output4 != null)
addOutput(output4);
}
@Override
public String getUserFreindlyName() {
return "Centrifuge";
}
@Override
public String getUserFreindlyName()
{
return "Centrifuge";
}
}

View file

@ -4,20 +4,23 @@ import net.minecraft.item.ItemStack;
import techreborn.api.recipe.BaseRecipe;
import techreborn.lib.Reference;
public class ChemicalReactorRecipe extends BaseRecipe {
public class ChemicalReactorRecipe extends BaseRecipe
{
public ChemicalReactorRecipe(ItemStack input1, ItemStack input2, ItemStack output1, int tickTime, int euPerTick) {
super(Reference.chemicalReactorRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
}
public ChemicalReactorRecipe(ItemStack input1, ItemStack input2, ItemStack output1, int tickTime, int euPerTick)
{
super(Reference.chemicalReactorRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
}
@Override
public String getUserFreindlyName() {
return "Chemical Reactor";
}
@Override
public String getUserFreindlyName()
{
return "Chemical Reactor";
}
}

View file

@ -1,22 +1,24 @@
package techreborn.api.recipe.machines;
import net.minecraft.item.ItemStack;
import techreborn.api.recipe.BaseRecipe;
import techreborn.lib.Reference;
public class CompressorRecipe extends BaseRecipe {
public class CompressorRecipe extends BaseRecipe
{
public CompressorRecipe(ItemStack input1, ItemStack output1, int tickTime, int euPerTick) {
super(Reference.compressorRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (output1 != null)
addOutput(output1);
}
public CompressorRecipe(ItemStack input1, ItemStack output1, int tickTime, int euPerTick)
{
super(Reference.compressorRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (output1 != null)
addOutput(output1);
}
@Override
public String getUserFreindlyName() {
return "Compressor";
}
@Override
public String getUserFreindlyName()
{
return "Compressor";
}
}

View file

@ -1,22 +1,24 @@
package techreborn.api.recipe.machines;
import net.minecraft.item.ItemStack;
import techreborn.api.recipe.BaseRecipe;
import techreborn.lib.Reference;
public class ExtractorRecipe extends BaseRecipe {
public class ExtractorRecipe extends BaseRecipe
{
public ExtractorRecipe(ItemStack input1, ItemStack output1, int tickTime, int euPerTick) {
super(Reference.extractorRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (output1 != null)
addOutput(output1);
}
public ExtractorRecipe(ItemStack input1, ItemStack output1, int tickTime, int euPerTick)
{
super(Reference.extractorRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (output1 != null)
addOutput(output1);
}
@Override
public String getUserFreindlyName() {
return "Extractor";
}
@Override
public String getUserFreindlyName()
{
return "Extractor";
}
}

View file

@ -1,22 +1,24 @@
package techreborn.api.recipe.machines;
import net.minecraft.item.ItemStack;
import techreborn.api.recipe.BaseRecipe;
import techreborn.lib.Reference;
public class GrinderRecipe extends BaseRecipe {
public class GrinderRecipe extends BaseRecipe
{
public GrinderRecipe(ItemStack input1, ItemStack output1, int tickTime, int euPerTick) {
super(Reference.grinderRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (output1 != null)
addOutput(output1);
}
public GrinderRecipe(ItemStack input1, ItemStack output1, int tickTime, int euPerTick)
{
super(Reference.grinderRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (output1 != null)
addOutput(output1);
}
@Override
public String getUserFreindlyName() {
return "Grinder";
}
@Override
public String getUserFreindlyName()
{
return "Grinder";
}
}

View file

@ -4,22 +4,26 @@ import net.minecraft.item.ItemStack;
import techreborn.api.recipe.BaseRecipe;
import techreborn.lib.Reference;
public class ImplosionCompressorRecipe extends BaseRecipe {
public class ImplosionCompressorRecipe extends BaseRecipe
{
public ImplosionCompressorRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, int tickTime, int euPerTick) {
super(Reference.implosionCompressorRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
if (output2 != null)
addOutput(output2);
}
public ImplosionCompressorRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2,
int tickTime, int euPerTick)
{
super(Reference.implosionCompressorRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
if (output2 != null)
addOutput(output2);
}
@Override
public String getUserFreindlyName() {
return "Implosion Compressor";
}
@Override
public String getUserFreindlyName()
{
return "Implosion Compressor";
}
}

View file

@ -4,33 +4,38 @@ import net.minecraft.item.ItemStack;
import techreborn.api.recipe.BaseRecipe;
import techreborn.lib.Reference;
public class IndustrialElectrolyzerRecipe extends BaseRecipe {
public class IndustrialElectrolyzerRecipe extends BaseRecipe
{
public IndustrialElectrolyzerRecipe(ItemStack inputCells, ItemStack input2, ItemStack output1, ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int euPerTick) {
super(Reference.industrialElectrolyzerRecipe, tickTime, euPerTick);
if (inputCells != null)
inputs.add(inputCells);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
if (output2 != null)
addOutput(output2);
if (output3 != null)
addOutput(output3);
if (output4 != null)
addOutput(output4);
}
private boolean useOreDictionary = true;
@Override
public String getUserFreindlyName() {
return "Industrial Electrolyzer";
}
public IndustrialElectrolyzerRecipe(ItemStack inputCells, ItemStack input2, ItemStack output1, ItemStack output2,
ItemStack output3, ItemStack output4, int tickTime, int euPerTick)
{
super(Reference.industrialElectrolyzerRecipe, tickTime, euPerTick);
if (inputCells != null)
inputs.add(inputCells);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
if (output2 != null)
addOutput(output2);
if (output3 != null)
addOutput(output3);
if (output4 != null)
addOutput(output4);
}
@Override
public boolean useOreDic() {
return useOreDictionary;
}
@Override
public String getUserFreindlyName()
{
return "Industrial Electrolyzer";
}
private boolean useOreDictionary = true;
@Override
public boolean useOreDic()
{
return useOreDictionary;
}
}

View file

@ -1,6 +1,5 @@
package techreborn.api.recipe.machines;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidStack;
@ -8,72 +7,91 @@ import techreborn.api.recipe.BaseRecipe;
import techreborn.lib.Reference;
import techreborn.tiles.TileIndustrialGrinder;
public class IndustrialGrinderRecipe extends BaseRecipe {
public class IndustrialGrinderRecipe extends BaseRecipe
{
public FluidStack fluidStack;
public FluidStack fluidStack;
public IndustrialGrinderRecipe(ItemStack input1, ItemStack input2, FluidStack fluidStack, ItemStack output1, ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int euPerTick) {
super(Reference.industrialGrinderRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
if (output2 != null)
addOutput(output2);
if (output3 != null)
addOutput(output3);
if (output4 != null)
addOutput(output4);
this.fluidStack = fluidStack;
}
public IndustrialGrinderRecipe(ItemStack input1, ItemStack input2, FluidStack fluidStack, ItemStack output1,
ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int euPerTick)
{
super(Reference.industrialGrinderRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
if (output2 != null)
addOutput(output2);
if (output3 != null)
addOutput(output3);
if (output4 != null)
addOutput(output4);
this.fluidStack = fluidStack;
}
@Override
public String getUserFreindlyName() {
return "IndustrialGrinder";
}
@Override
public String getUserFreindlyName()
{
return "IndustrialGrinder";
}
@Override
public boolean canCraft(TileEntity tile) {
if (fluidStack == null) {
return true;
}
if (tile instanceof TileIndustrialGrinder) {
TileIndustrialGrinder grinder = (TileIndustrialGrinder) tile;
if (grinder.tank.getFluid() == null) {
return false;
}
if (grinder.tank.getFluid() == fluidStack) {
if (grinder.tank.getFluidAmount() >= fluidStack.amount) {
return true;
}
}
}
return false;
}
@Override
public boolean canCraft(TileEntity tile)
{
if (fluidStack == null)
{
return true;
}
if (tile instanceof TileIndustrialGrinder)
{
TileIndustrialGrinder grinder = (TileIndustrialGrinder) tile;
if (grinder.tank.getFluid() == null)
{
return false;
}
if (grinder.tank.getFluid() == fluidStack)
{
if (grinder.tank.getFluidAmount() >= fluidStack.amount)
{
return true;
}
}
}
return false;
}
@Override
public boolean onCraft(TileEntity tile) {
if (fluidStack == null) {
return true;
}
if (tile instanceof TileIndustrialGrinder) {
TileIndustrialGrinder grinder = (TileIndustrialGrinder) tile;
if (grinder.tank.getFluid() == null) {
return false;
}
if (grinder.tank.getFluid() == fluidStack) {
if (grinder.tank.getFluidAmount() >= fluidStack.amount) {
if (grinder.tank.getFluidAmount() > 0) {
grinder.tank.setFluid(new FluidStack(fluidStack.getFluid(), grinder.tank.getFluidAmount() - fluidStack.amount));
} else {
grinder.tank.setFluid(null);
}
return true;
}
}
}
return false;
}
@Override
public boolean onCraft(TileEntity tile)
{
if (fluidStack == null)
{
return true;
}
if (tile instanceof TileIndustrialGrinder)
{
TileIndustrialGrinder grinder = (TileIndustrialGrinder) tile;
if (grinder.tank.getFluid() == null)
{
return false;
}
if (grinder.tank.getFluid() == fluidStack)
{
if (grinder.tank.getFluidAmount() >= fluidStack.amount)
{
if (grinder.tank.getFluidAmount() > 0)
{
grinder.tank.setFluid(new FluidStack(fluidStack.getFluid(),
grinder.tank.getFluidAmount() - fluidStack.amount));
} else
{
grinder.tank.setFluid(null);
}
return true;
}
}
}
return false;
}
}

View file

@ -7,93 +7,115 @@ import techreborn.api.recipe.BaseRecipe;
import techreborn.lib.Reference;
import techreborn.tiles.TileIndustrialSawmill;
public class IndustrialSawmillRecipe extends BaseRecipe {
public class IndustrialSawmillRecipe extends BaseRecipe
{
public FluidStack fluidStack;
public FluidStack fluidStack;
public boolean canUseOreDict = false;
public boolean canUseOreDict = false;
public IndustrialSawmillRecipe(ItemStack input1, ItemStack input2, FluidStack fluidStack, ItemStack output1, ItemStack output2, ItemStack output3, int tickTime, int euPerTick) {
super(Reference.industrialSawmillRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
if (output2 != null)
addOutput(output2);
if (output3 != null)
addOutput(output3);
this.fluidStack = fluidStack;
}
public IndustrialSawmillRecipe(ItemStack input1, ItemStack input2, FluidStack fluidStack, ItemStack output1,
ItemStack output2, ItemStack output3, int tickTime, int euPerTick)
{
super(Reference.industrialSawmillRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
if (output2 != null)
addOutput(output2);
if (output3 != null)
addOutput(output3);
this.fluidStack = fluidStack;
}
public IndustrialSawmillRecipe(ItemStack input1, ItemStack input2, FluidStack fluidStack, ItemStack output1, ItemStack output2, ItemStack output3, int tickTime, int euPerTick, boolean canUseOreDict) {
super(Reference.industrialSawmillRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
if (output2 != null)
addOutput(output2);
if (output3 != null)
addOutput(output3);
this.fluidStack = fluidStack;
this.canUseOreDict = canUseOreDict;
}
public IndustrialSawmillRecipe(ItemStack input1, ItemStack input2, FluidStack fluidStack, ItemStack output1,
ItemStack output2, ItemStack output3, int tickTime, int euPerTick, boolean canUseOreDict)
{
super(Reference.industrialSawmillRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
if (output2 != null)
addOutput(output2);
if (output3 != null)
addOutput(output3);
this.fluidStack = fluidStack;
this.canUseOreDict = canUseOreDict;
}
@Override
public String getUserFreindlyName() {
return "Industrial Sawmill";
}
@Override
public String getUserFreindlyName()
{
return "Industrial Sawmill";
}
@Override
public boolean canCraft(TileEntity tile) {
if (fluidStack == null) {
return true;
}
if (tile instanceof TileIndustrialSawmill) {
TileIndustrialSawmill sawmill = (TileIndustrialSawmill) tile;
if (sawmill.tank.getFluid() == null) {
return false;
}
if (sawmill.tank.getFluid()== fluidStack) {
if (sawmill.tank.getFluidAmount() >= fluidStack.amount) {
return true;
}
}
}
return false;
}
@Override
public boolean canCraft(TileEntity tile)
{
if (fluidStack == null)
{
return true;
}
if (tile instanceof TileIndustrialSawmill)
{
TileIndustrialSawmill sawmill = (TileIndustrialSawmill) tile;
if (sawmill.tank.getFluid() == null)
{
return false;
}
if (sawmill.tank.getFluid() == fluidStack)
{
if (sawmill.tank.getFluidAmount() >= fluidStack.amount)
{
return true;
}
}
}
return false;
}
@Override
public boolean onCraft(TileEntity tile) {
if (fluidStack == null) {
return true;
}
if (tile instanceof TileIndustrialSawmill) {
TileIndustrialSawmill sawmill = (TileIndustrialSawmill) tile;
if (sawmill.tank.getFluid() == null) {
return false;
}
if (sawmill.tank.getFluid() == fluidStack) {
if (sawmill.tank.getFluidAmount() >= fluidStack.amount) {
if (sawmill.tank.getFluidAmount() > 0) {
sawmill.tank.setFluid(new FluidStack(fluidStack.getFluid(), sawmill.tank.getFluidAmount() - fluidStack.amount));
} else {
sawmill.tank.setFluid(null);
}
return true;
}
}
}
return false;
}
@Override
public boolean onCraft(TileEntity tile)
{
if (fluidStack == null)
{
return true;
}
if (tile instanceof TileIndustrialSawmill)
{
TileIndustrialSawmill sawmill = (TileIndustrialSawmill) tile;
if (sawmill.tank.getFluid() == null)
{
return false;
}
if (sawmill.tank.getFluid() == fluidStack)
{
if (sawmill.tank.getFluidAmount() >= fluidStack.amount)
{
if (sawmill.tank.getFluidAmount() > 0)
{
sawmill.tank.setFluid(new FluidStack(fluidStack.getFluid(),
sawmill.tank.getFluidAmount() - fluidStack.amount));
} else
{
sawmill.tank.setFluid(null);
}
return true;
}
}
}
return false;
}
@Override
public boolean useOreDic() {
return canUseOreDict;
}
@Override
public boolean useOreDic()
{
return canUseOreDict;
}
}

View file

@ -4,18 +4,21 @@ import net.minecraft.item.ItemStack;
import techreborn.api.recipe.BaseRecipe;
import techreborn.lib.Reference;
public class PlateCuttingMachineRecipe extends BaseRecipe {
public class PlateCuttingMachineRecipe extends BaseRecipe
{
public PlateCuttingMachineRecipe(ItemStack input1, ItemStack output1, int tickTime, int euPerTick) {
super(Reference.plateCuttingMachineRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (output1 != null)
addOutput(output1);
}
public PlateCuttingMachineRecipe(ItemStack input1, ItemStack output1, int tickTime, int euPerTick)
{
super(Reference.plateCuttingMachineRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (output1 != null)
addOutput(output1);
}
@Override
public String getUserFreindlyName() {
return "Plate Cutting Machine";
}
@Override
public String getUserFreindlyName()
{
return "Plate Cutting Machine";
}
}

View file

@ -6,28 +6,34 @@ import techreborn.api.recipe.BaseRecipe;
import techreborn.lib.Reference;
import techreborn.tiles.TileVacuumFreezer;
public class VacuumFreezerRecipe extends BaseRecipe {
public class VacuumFreezerRecipe extends BaseRecipe
{
public VacuumFreezerRecipe(ItemStack input, ItemStack output, int tickTime, int euPerTick) {
super(Reference.vacuumFreezerRecipe, tickTime, euPerTick);
if (input != null)
inputs.add(input);
if (output != null)
addOutput(output);
}
public VacuumFreezerRecipe(ItemStack input, ItemStack output, int tickTime, int euPerTick)
{
super(Reference.vacuumFreezerRecipe, tickTime, euPerTick);
if (input != null)
inputs.add(input);
if (output != null)
addOutput(output);
}
@Override
public String getUserFreindlyName() {
return "Vacuum Freezer";
}
@Override
public String getUserFreindlyName()
{
return "Vacuum Freezer";
}
@Override
public boolean canCraft(TileEntity tile) {
if(tile instanceof TileVacuumFreezer){
if(((TileVacuumFreezer) tile).multiBlockStatus == 1){
return true;
}
}
return false;
}
@Override
public boolean canCraft(TileEntity tile)
{
if (tile instanceof TileVacuumFreezer)
{
if (((TileVacuumFreezer) tile).multiBlockStatus == 1)
{
return true;
}
}
return false;
}
}

View file

@ -1,4 +1,4 @@
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") package techreborn.api.recipe.machines;
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI")
package techreborn.api.recipe.machines;
import net.minecraftforge.fml.common.API;

View file

@ -1,4 +1,4 @@
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") package techreborn.api.recipe;
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI")
package techreborn.api.recipe;
import net.minecraftforge.fml.common.API;

View file

@ -1,46 +1,53 @@
package techreborn.api.recipe.recipeConfig;
public class ConfigItem
{
public class ConfigItem {
String localName;
String localName;
String itemName;
String itemName;
int meta;
int meta;
int stackSize;
int stackSize;
public String getItemName()
{
return itemName;
}
public void setItemName(String itemName)
{
this.itemName = itemName;
}
public String getItemName() {
return itemName;
}
public int getMeta()
{
return meta;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public void setMeta(int meta)
{
this.meta = meta;
}
public int getMeta() {
return meta;
}
public int getStackSize()
{
return stackSize;
}
public void setMeta(int meta) {
this.meta = meta;
}
public void setStackSize(int stackSize)
{
this.stackSize = stackSize;
}
public int getStackSize() {
return stackSize;
}
public String getLocalName()
{
return localName;
}
public void setStackSize(int stackSize) {
this.stackSize = stackSize;
}
public String getLocalName() {
return localName;
}
public void setLocalName(String localName) {
this.localName = localName;
}
public void setLocalName(String localName)
{
this.localName = localName;
}
}

View file

@ -2,59 +2,72 @@ package techreborn.api.recipe.recipeConfig;
import java.util.ArrayList;
public class RecipeConfig {
public class RecipeConfig
{
ArrayList<ConfigItem> inputs;
ArrayList<ConfigItem> inputs;
ArrayList<ConfigItem> outputs;
ArrayList<ConfigItem> outputs;
Boolean enabled;
Boolean enabled;
String machine;
String machine;
public ArrayList<ConfigItem> getInputs() {
return inputs;
}
public ArrayList<ConfigItem> getInputs()
{
return inputs;
}
public void setInputs(ArrayList<ConfigItem> inputs) {
this.inputs = inputs;
}
public void setInputs(ArrayList<ConfigItem> inputs)
{
this.inputs = inputs;
}
public ArrayList<ConfigItem> getOutputs() {
return outputs;
}
public ArrayList<ConfigItem> getOutputs()
{
return outputs;
}
public void setOutputs(ArrayList<ConfigItem> outputs) {
this.outputs = outputs;
}
public void setOutputs(ArrayList<ConfigItem> outputs)
{
this.outputs = outputs;
}
public Boolean getEnabled() {
return enabled;
}
public Boolean getEnabled()
{
return enabled;
}
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
public void setEnabled(Boolean enabled)
{
this.enabled = enabled;
}
public String getMachine() {
return machine;
}
public String getMachine()
{
return machine;
}
public void setMachine(String machine) {
this.machine = machine;
}
public void setMachine(String machine)
{
this.machine = machine;
}
public void addInputs(ConfigItem item) {
if (inputs == null) {
inputs = new ArrayList<ConfigItem>();
}
inputs.add(item);
}
public void addInputs(ConfigItem item)
{
if (inputs == null)
{
inputs = new ArrayList<ConfigItem>();
}
inputs.add(item);
}
public void addOutputs(ConfigItem item) {
if (outputs == null) {
outputs = new ArrayList<ConfigItem>();
}
outputs.add(item);
}
public void addOutputs(ConfigItem item)
{
if (outputs == null)
{
outputs = new ArrayList<ConfigItem>();
}
outputs.add(item);
}
}

View file

@ -1,65 +1,75 @@
package techreborn.api.recipe.recipeConfig;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.minecraft.item.ItemStack;
import techreborn.api.recipe.IBaseRecipeType;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
public class RecipeConfigManager {
import net.minecraft.item.ItemStack;
import techreborn.api.recipe.IBaseRecipeType;
public static ArrayList<RecipeConfig> configs = new ArrayList<RecipeConfig>();
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
static File configFile = null;
public class RecipeConfigManager
{
public static void load(File configDir) {
if (configFile == null) {
configFile = new File(configDir, "techRebornRecipes.json");
}
}
public static ArrayList<RecipeConfig> configs = new ArrayList<RecipeConfig>();
public static void save() {
if (configFile.exists()) {
configFile.delete();
}
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String json = gson.toJson(configs);
try {
FileWriter writer = new FileWriter(configFile);
writer.write(json);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
static File configFile = null;
public static void load(File configDir)
{
if (configFile == null)
{
configFile = new File(configDir, "techRebornRecipes.json");
}
}
public static boolean canLoadRecipe(IBaseRecipeType recipeType) {
RecipeConfig config = new RecipeConfig();
for (ItemStack stack : recipeType.getInputs()) {
config.addInputs(itemToConfig(stack));
}
for (ItemStack stack : recipeType.getOutputs()) {
config.addOutputs(itemToConfig(stack));
}
config.enabled = true;
config.setMachine(recipeType.getRecipeName());
configs.add(config);
return config.enabled;
}
public static void save()
{
if (configFile.exists())
{
configFile.delete();
}
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String json = gson.toJson(configs);
try
{
FileWriter writer = new FileWriter(configFile);
writer.write(json);
writer.close();
} catch (IOException e)
{
e.printStackTrace();
}
}
public static boolean canLoadRecipe(IBaseRecipeType recipeType)
{
RecipeConfig config = new RecipeConfig();
for (ItemStack stack : recipeType.getInputs())
{
config.addInputs(itemToConfig(stack));
}
for (ItemStack stack : recipeType.getOutputs())
{
config.addOutputs(itemToConfig(stack));
}
config.enabled = true;
config.setMachine(recipeType.getRecipeName());
configs.add(config);
return config.enabled;
}
public static ConfigItem itemToConfig(ItemStack stack) {
ConfigItem newItem = new ConfigItem();
newItem.setItemName(stack.getItem().getUnlocalizedName());
newItem.setMeta(stack.getItemDamage());
newItem.setStackSize(stack.stackSize);
newItem.setLocalName(stack.getDisplayName());
return newItem;
}
public static ConfigItem itemToConfig(ItemStack stack)
{
ConfigItem newItem = new ConfigItem();
newItem.setItemName(stack.getItem().getUnlocalizedName());
newItem.setMeta(stack.getItemDamage());
newItem.setStackSize(stack.stackSize);
newItem.setLocalName(stack.getDisplayName());
return newItem;
}
}

View file

@ -3,7 +3,8 @@ package techreborn.api.upgrade;
import net.minecraft.item.ItemStack;
import techreborn.api.recipe.RecipeCrafter;
public interface IMachineUpgrade {
public interface IMachineUpgrade
{
public void processUpgrade(RecipeCrafter crafter, ItemStack stack);
public void processUpgrade(RecipeCrafter crafter, ItemStack stack);
}

View file

@ -1,39 +1,46 @@
package techreborn.api.upgrade;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import reborncore.common.util.Inventory;
import techreborn.api.recipe.RecipeCrafter;
import java.util.ArrayList;
public class UpgradeHandler
{
public class UpgradeHandler {
RecipeCrafter crafter;
RecipeCrafter crafter;
Inventory inventory;
Inventory inventory;
ArrayList<Integer> slots = new ArrayList<Integer>();
ArrayList<Integer> slots = new ArrayList<Integer>();
public UpgradeHandler(RecipeCrafter crafter, Inventory inventory, int... slots)
{
this.crafter = crafter;
this.inventory = inventory;
for (int slot : slots)
{
this.slots.add(slot);
}
}
public UpgradeHandler(RecipeCrafter crafter, Inventory inventory, int... slots) {
this.crafter = crafter;
this.inventory = inventory;
for (int slot : slots) {
this.slots.add(slot);
}
}
public void tick() {
if (crafter.parentTile.getWorld().isRemote)
return;
crafter.resetPowerMulti();
crafter.resetSpeedMulti();
for (int slot : this.slots) {
ItemStack stack = inventory.getStackInSlot(slot);
if (stack != null && stack.getItem() instanceof IMachineUpgrade) {
((IMachineUpgrade) stack.getItem()).processUpgrade(crafter, stack);
}
}
if (crafter.currentRecipe != null)
crafter.currentNeededTicks = (int) (crafter.currentRecipe.tickTime() * (1.0 - crafter.getSpeedMultiplier()));
}
public void tick()
{
if (crafter.parentTile.getWorld().isRemote)
return;
crafter.resetPowerMulti();
crafter.resetSpeedMulti();
for (int slot : this.slots)
{
ItemStack stack = inventory.getStackInSlot(slot);
if (stack != null && stack.getItem() instanceof IMachineUpgrade)
{
((IMachineUpgrade) stack.getItem()).processUpgrade(crafter, stack);
}
}
if (crafter.currentRecipe != null)
crafter.currentNeededTicks = (int) (crafter.currentRecipe.tickTime()
* (1.0 - crafter.getSpeedMultiplier()));
}
}

View file

@ -1,4 +1,4 @@
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") package techreborn.api.upgrade;
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI")
package techreborn.api.upgrade;
import net.minecraftforge.fml.common.API;