Code formatter take 2
This commit is contained in:
parent
33985f1a31
commit
5eed5b161d
450 changed files with 32768 additions and 26684 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue