Revert "Added code formatter"

This reverts commit b9448d5d90.
This commit is contained in:
modmuss50 2016-03-24 00:41:47 +00:00
parent b9448d5d90
commit 33985f1a31
444 changed files with 26235 additions and 32364 deletions

View file

@ -1,105 +1,92 @@
package techreborn.api.recipe;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import java.util.ArrayList;
import java.util.List;
/**
* 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;
private ArrayList<ItemStack> outputs;
private ArrayList<ItemStack> outputs;
public String name;
public String name;
public int tickTime;
public int tickTime;
public int euPerTick;
public int euPerTick;
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 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 ItemStack getOutput(int i)
{
return outputs.get(i).copy();
}
@Override
public ItemStack getOutput(int i) {
return outputs.get(i).copy();
}
@Override
public int getOutputsSize()
{
return outputs.size();
}
@Override
public int getOutputsSize() {
return outputs.size();
}
public void addOutput(ItemStack stack)
{
outputs.add(stack);
}
public void addOutput(ItemStack stack) {
outputs.add(stack);
}
@Override
public List<ItemStack> getInputs()
{
return inputs;
}
@Override
public String getRecipeName()
{
return name;
}
@Override
public List<ItemStack> getInputs() {
return inputs;
}
@Override
public int tickTime()
{
return tickTime;
}
@Override
public String getRecipeName() {
return name;
}
@Override
public int euPerTick()
{
return euPerTick;
}
@Override
public int tickTime() {
return tickTime;
}
@Override
public boolean canCraft(TileEntity tile)
{
return true;
}
@Override
public int euPerTick() {
return euPerTick;
}
@Override
public boolean onCraft(TileEntity tile)
{
return true;
}
@Override
public boolean canCraft(TileEntity tile) {
return true;
}
@Override
public Object clone() throws CloneNotSupportedException
{
return super.clone();
}
@Override
public boolean onCraft(TileEntity tile) {
return true;
}
@Override
public boolean useOreDic()
{
return true;
}
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
@Override
public List<ItemStack> getOutputs()
{
return outputs;
}
@Override
public boolean useOreDic() {
return true;
}
@Override
public List<ItemStack> getOutputs() {
return outputs;
}
}

View file

@ -1,87 +1,81 @@
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,8 +2,7 @@ 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,7 +1,5 @@
package techreborn.api.recipe;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import reborncore.api.power.IEnergyInterfaceTile;
@ -10,421 +8,327 @@ 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;
/**
* 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;
}
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;
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 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;
/**
* 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;
int ticksSinceLastChange;
/**
* 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;
/**
* 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;
}
}
int ticksSinceLastChange;
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;
}
/**
* 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 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;
}
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 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;
}
}
}
}
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;
}
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 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;
}
}
}
}
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 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 readFromNBT(NBTTagCompound tag)
{
NBTTagCompound data = tag.getCompoundTag("Crater");
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);
}
}
}
if (data.hasKey("currentTickTime"))
currentTickTime = data.getInteger("currentTickTime");
public void readFromNBT(NBTTagCompound tag) {
NBTTagCompound data = tag.getCompoundTag("Crater");
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());
}
}
if (data.hasKey("currentTickTime"))
currentTickTime = data.getInteger("currentTickTime");
public void writeToNBT(NBTTagCompound tag)
{
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());
}
}
NBTTagCompound data = new NBTTagCompound();
public void writeToNBT(NBTTagCompound tag) {
data.setDouble("currentTickTime", currentTickTime);
NBTTagCompound data = new NBTTagCompound();
tag.setTag("Crater", data);
}
data.setDouble("currentTickTime", currentTickTime);
private boolean isActive()
{
return currentRecipe != null && energy.getEnergy() >= currentRecipe.euPerTick();
}
tag.setTag("Crater", data);
}
public void addSpeedMulti(double amount)
{
if (speedMultiplier + amount <= 0.99)
{
speedMultiplier += amount;
} else
{
speedMultiplier = 0.99;
}
}
public void resetSpeedMulti()
{
speedMultiplier = 0;
}
private boolean isActive() {
return currentRecipe != null && energy.getEnergy() >= currentRecipe.euPerTick();
}
public double getSpeedMultiplier()
{
return speedMultiplier;
}
public void addSpeedMulti(double amount) {
if (speedMultiplier + amount <= 0.99) {
speedMultiplier += amount;
} else {
speedMultiplier = 0.99;
}
}
public void addPowerMulti(double amount)
{
powerMultiplier += amount;
}
public void resetSpeedMulti() {
speedMultiplier = 0;
}
public void resetPowerMulti()
{
powerMultiplier = 1;
}
public double getSpeedMultiplier() {
return speedMultiplier;
}
public double getPowerMultiplier()
{
return powerMultiplier;
}
public void addPowerMulti(double amount) {
powerMultiplier += amount;
}
public double getEuPerTick()
{
return currentRecipe.euPerTick() * powerMultiplier;
}
public void resetPowerMulti() {
powerMultiplier = 1;
}
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 getPowerMultiplier() {
return powerMultiplier;
}
public void setCurrentRecipe(IBaseRecipeType recipe)
{
try
{
this.currentRecipe = (IBaseRecipeType) recipe.clone();
} catch (CloneNotSupportedException e)
{
e.printStackTrace();
}
}
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();
}
}
}

View file

@ -1,127 +1,103 @@
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;
import org.apache.commons.lang3.time.StopWatch;
public class RecipeHandler {
import reborncore.common.util.ItemUtils;
import techreborn.Core;
/**
* This is the array list of all of the recipes for all of the machines
*/
public static final ArrayList<IBaseRecipeType> recipeList = new ArrayList<IBaseRecipeType>();
public class RecipeHandler
{
/**
* This is the array list of all of the recipes for all of the machines
*/
public static final ArrayList<IBaseRecipeType> recipeList = new ArrayList<IBaseRecipeType>();
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 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>();
/**
* 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;
}
/**
* 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 String getUserFreindlyName(String name) {
for (IBaseRecipeType baseRecipe : recipeList) {
if (baseRecipe.getRecipeName().equals(name)) {
return baseRecipe.getUserFreindlyName();
}
}
return "";
}
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());
}
/**
* 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,21 +3,17 @@ 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 class RecyclerRecipe extends BaseRecipe {
public RecyclerRecipe(ItemStack input)
{
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,19 +4,16 @@ 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,23 +4,20 @@ 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,23 +4,20 @@ 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,47 +6,41 @@ 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 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 int neededHeat;
this.neededHeat = 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);
@Override
public String getUserFreindlyName()
{
return "Blast Furnace";
}
this.neededHeat = neededHeat;
}
@Override
public boolean canCraft(TileEntity tile)
{
if (tile instanceof TileBlastFurnace)
{
TileBlastFurnace blastFurnace = (TileBlastFurnace) tile;
return blastFurnace.getHeat() >= neededHeat;
}
return false;
}
@Override
public String getUserFreindlyName() {
return "Blast Furnace";
}
@Override
public boolean onCraft(TileEntity tile)
{
return super.onCraft(tile);
}
@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);
}
}

View file

@ -4,30 +4,26 @@ 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,23 +4,20 @@ 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,24 +1,22 @@
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,24 +1,22 @@
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,24 +1,22 @@
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,26 +4,22 @@ 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,38 +4,33 @@ 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);
}
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 String getUserFreindlyName()
{
return "Industrial Electrolyzer";
}
@Override
public String getUserFreindlyName() {
return "Industrial Electrolyzer";
}
@Override
public boolean useOreDic()
{
return useOreDictionary;
}
@Override
public boolean useOreDic() {
return useOreDictionary;
}
private boolean useOreDictionary = true;
private boolean useOreDictionary = true;
}

View file

@ -1,5 +1,6 @@
package techreborn.api.recipe.machines;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidStack;
@ -7,91 +8,72 @@ 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,115 +7,93 @@ 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,21 +4,18 @@ 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,34 +6,28 @@ 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,3 +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,2 +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,53 +1,46 @@
package techreborn.api.recipe.recipeConfig;
public class ConfigItem
{
String localName;
public class ConfigItem {
String itemName;
String localName;
int meta;
String itemName;
int stackSize;
int meta;
public String getItemName()
{
return itemName;
}
int stackSize;
public void setItemName(String itemName)
{
this.itemName = itemName;
}
public int getMeta()
{
return meta;
}
public String getItemName() {
return itemName;
}
public void setMeta(int meta)
{
this.meta = meta;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public int getStackSize()
{
return stackSize;
}
public int getMeta() {
return meta;
}
public void setStackSize(int stackSize)
{
this.stackSize = stackSize;
}
public void setMeta(int meta) {
this.meta = meta;
}
public String getLocalName()
{
return localName;
}
public int getStackSize() {
return stackSize;
}
public void setLocalName(String localName)
{
this.localName = localName;
}
public void setStackSize(int stackSize) {
this.stackSize = stackSize;
}
public String getLocalName() {
return localName;
}
public void setLocalName(String localName) {
this.localName = localName;
}
}

View file

@ -2,72 +2,59 @@ 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,75 +1,65 @@
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;
import net.minecraft.item.ItemStack;
import techreborn.api.recipe.IBaseRecipeType;
public class RecipeConfigManager {
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
public static ArrayList<RecipeConfig> configs = new ArrayList<RecipeConfig>();
public class RecipeConfigManager
{
static File configFile = null;
public static ArrayList<RecipeConfig> configs = new ArrayList<RecipeConfig>();
public static void load(File configDir) {
if (configFile == null) {
configFile = new File(configDir, "techRebornRecipes.json");
}
}
static File configFile = null;
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 void load(File configDir)
{
if (configFile == null)
{
configFile = new File(configDir, "techRebornRecipes.json");
}
}
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 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;
}
}