Reformatted all the code using the default intelji formatting options.
This commit is contained in:
parent
2f63a24070
commit
e0ab0af822
363 changed files with 20524 additions and 23016 deletions
|
@ -1,6 +1,5 @@
|
|||
package techreborn.api;
|
||||
|
||||
public interface IpdaItem
|
||||
{
|
||||
//TODO
|
||||
public interface IpdaItem {
|
||||
//TODO
|
||||
}
|
||||
|
|
|
@ -15,116 +15,94 @@ import java.util.List;
|
|||
|
||||
public class RollingMachineRecipe {
|
||||
|
||||
private final List<IRecipe> recipes = new ArrayList<IRecipe>();
|
||||
private final List<IRecipe> recipes = new ArrayList<IRecipe>();
|
||||
|
||||
public static final RollingMachineRecipe instance = new RollingMachineRecipe();
|
||||
public static final RollingMachineRecipe instance = new RollingMachineRecipe();
|
||||
|
||||
public void addRecipe(ItemStack output, Object... components)
|
||||
{
|
||||
String s = "";
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
if (components[i] instanceof String[])
|
||||
{
|
||||
String as[] = (String[]) components[i++];
|
||||
for (int l = 0; l < as.length; l++)
|
||||
{
|
||||
String s2 = as[l];
|
||||
k++;
|
||||
j = s2.length();
|
||||
s = (new StringBuilder()).append(s).append(s2).toString();
|
||||
}
|
||||
} else
|
||||
{
|
||||
while (components[i] instanceof String)
|
||||
{
|
||||
String s1 = (String) components[i++];
|
||||
k++;
|
||||
j = s1.length();
|
||||
s = (new StringBuilder()).append(s).append(s1).toString();
|
||||
}
|
||||
}
|
||||
HashMap hashmap = new HashMap();
|
||||
for (; i < components.length; i += 2)
|
||||
{
|
||||
Character character = (Character) components[i];
|
||||
ItemStack itemstack1 = null;
|
||||
if (components[i + 1] instanceof Item)
|
||||
{
|
||||
itemstack1 = new ItemStack((Item) components[i + 1]);
|
||||
} else if (components[i + 1] instanceof Block)
|
||||
{
|
||||
itemstack1 = new ItemStack((Block) components[i + 1], 1, -1);
|
||||
} else if (components[i + 1] instanceof ItemStack)
|
||||
{
|
||||
itemstack1 = (ItemStack) components[i + 1];
|
||||
}
|
||||
hashmap.put(character, itemstack1);
|
||||
}
|
||||
public void addRecipe(ItemStack output, Object... components) {
|
||||
String s = "";
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
if (components[i] instanceof String[]) {
|
||||
String as[] = (String[]) components[i++];
|
||||
for (int l = 0; l < as.length; l++) {
|
||||
String s2 = as[l];
|
||||
k++;
|
||||
j = s2.length();
|
||||
s = (new StringBuilder()).append(s).append(s2).toString();
|
||||
}
|
||||
} else {
|
||||
while (components[i] instanceof String) {
|
||||
String s1 = (String) components[i++];
|
||||
k++;
|
||||
j = s1.length();
|
||||
s = (new StringBuilder()).append(s).append(s1).toString();
|
||||
}
|
||||
}
|
||||
HashMap hashmap = new HashMap();
|
||||
for (; i < components.length; i += 2) {
|
||||
Character character = (Character) components[i];
|
||||
ItemStack itemstack1 = null;
|
||||
if (components[i + 1] instanceof Item) {
|
||||
itemstack1 = new ItemStack((Item) components[i + 1]);
|
||||
} else if (components[i + 1] instanceof Block) {
|
||||
itemstack1 = new ItemStack((Block) components[i + 1], 1, -1);
|
||||
} else if (components[i + 1] instanceof ItemStack) {
|
||||
itemstack1 = (ItemStack) components[i + 1];
|
||||
}
|
||||
hashmap.put(character, itemstack1);
|
||||
}
|
||||
|
||||
ItemStack recipeArray[] = new ItemStack[j * k];
|
||||
for (int i1 = 0; i1 < j * k; i1++)
|
||||
{
|
||||
char c = s.charAt(i1);
|
||||
if (hashmap.containsKey(Character.valueOf(c)))
|
||||
{
|
||||
recipeArray[i1] = ((ItemStack) hashmap
|
||||
.get(Character.valueOf(c))).copy();
|
||||
} else
|
||||
{
|
||||
recipeArray[i1] = null;
|
||||
}
|
||||
}
|
||||
ItemStack recipeArray[] = new ItemStack[j * k];
|
||||
for (int i1 = 0; i1 < j * k; i1++) {
|
||||
char c = s.charAt(i1);
|
||||
if (hashmap.containsKey(Character.valueOf(c))) {
|
||||
recipeArray[i1] = ((ItemStack) hashmap
|
||||
.get(Character.valueOf(c))).copy();
|
||||
} else {
|
||||
recipeArray[i1] = null;
|
||||
}
|
||||
}
|
||||
|
||||
recipes.add(new ShapedRecipes(j, k, recipeArray, output));
|
||||
}
|
||||
recipes.add(new ShapedRecipes(j, k, recipeArray, output));
|
||||
}
|
||||
|
||||
public void addShapelessRecipe(ItemStack output, Object... components)
|
||||
{
|
||||
List<ItemStack> ingredients = new ArrayList<ItemStack>();
|
||||
for (int j = 0; j < components.length; j++)
|
||||
{
|
||||
Object obj = components[j];
|
||||
if (obj instanceof ItemStack)
|
||||
{
|
||||
ingredients.add(((ItemStack) obj).copy());
|
||||
continue;
|
||||
}
|
||||
if (obj instanceof Item)
|
||||
{
|
||||
ingredients.add(new ItemStack((Item) obj));
|
||||
continue;
|
||||
}
|
||||
if (obj instanceof Block)
|
||||
{
|
||||
ingredients.add(new ItemStack((Block) obj));
|
||||
} else
|
||||
{
|
||||
throw new RuntimeException("Invalid shapeless recipe!");
|
||||
}
|
||||
}
|
||||
public void addShapelessRecipe(ItemStack output, Object... components) {
|
||||
List<ItemStack> ingredients = new ArrayList<ItemStack>();
|
||||
for (int j = 0; j < components.length; j++) {
|
||||
Object obj = components[j];
|
||||
if (obj instanceof ItemStack) {
|
||||
ingredients.add(((ItemStack) obj).copy());
|
||||
continue;
|
||||
}
|
||||
if (obj instanceof Item) {
|
||||
ingredients.add(new ItemStack((Item) obj));
|
||||
continue;
|
||||
}
|
||||
if (obj instanceof Block) {
|
||||
ingredients.add(new ItemStack((Block) obj));
|
||||
} else {
|
||||
throw new RuntimeException("Invalid shapeless recipe!");
|
||||
}
|
||||
}
|
||||
|
||||
recipes.add(new ShapelessRecipes(output, ingredients));
|
||||
}
|
||||
recipes.add(new ShapelessRecipes(output, ingredients));
|
||||
}
|
||||
|
||||
public ItemStack findMatchingRecipe(InventoryCrafting inv, World world)
|
||||
{
|
||||
for (int k = 0; k < recipes.size(); k++)
|
||||
{
|
||||
IRecipe irecipe = (IRecipe) recipes.get(k);
|
||||
if (irecipe.matches(inv, world))
|
||||
{
|
||||
return irecipe.getCraftingResult(inv);
|
||||
}
|
||||
}
|
||||
public ItemStack findMatchingRecipe(InventoryCrafting inv, World world) {
|
||||
for (int k = 0; k < recipes.size(); k++) {
|
||||
IRecipe irecipe = (IRecipe) recipes.get(k);
|
||||
if (irecipe.matches(inv, world)) {
|
||||
return irecipe.getCraftingResult(inv);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<IRecipe> getRecipeList()
|
||||
{
|
||||
return recipes;
|
||||
}
|
||||
public List<IRecipe> getRecipeList() {
|
||||
return recipes;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,24 +3,21 @@ package techreborn.api;
|
|||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public final class TechRebornAPI {
|
||||
|
||||
public static void addRollingMachinceRecipe(ItemStack output,
|
||||
Object... components)
|
||||
{
|
||||
RollingMachineRecipe.instance.addRecipe(output, components);
|
||||
}
|
||||
|
||||
public static void addShapelessRollingMachinceRecipe(ItemStack output,
|
||||
Object... components)
|
||||
{
|
||||
RollingMachineRecipe.instance.addShapelessRecipe(output, components);
|
||||
}
|
||||
public static void addRollingMachinceRecipe(ItemStack output,
|
||||
Object... components) {
|
||||
RollingMachineRecipe.instance.addRecipe(output, components);
|
||||
}
|
||||
|
||||
public static void addShapelessRollingMachinceRecipe(ItemStack output,
|
||||
Object... components) {
|
||||
RollingMachineRecipe.instance.addShapelessRecipe(output, components);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class RegisteredItemRecipe extends Exception {
|
||||
public RegisteredItemRecipe(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
public RegisteredItemRecipe(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI")
|
||||
package techreborn.api.farm;
|
||||
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") package techreborn.api.farm;
|
||||
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI")
|
||||
package techreborn.api;
|
||||
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") package techreborn.api;
|
||||
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
|
|
|
@ -4,108 +4,96 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
|
||||
public interface IEnergyInterfaceTile {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Amount of energy in the tile
|
||||
*/
|
||||
public double getEnergy();
|
||||
/**
|
||||
* @return Amount of energy in the tile
|
||||
*/
|
||||
public double getEnergy();
|
||||
|
||||
/**
|
||||
* Sets the energy in the tile
|
||||
*
|
||||
* @param energy the amount of energy to set.
|
||||
*/
|
||||
public void setEnergy(double energy);
|
||||
/**
|
||||
* Sets the energy in the tile
|
||||
*
|
||||
* @param energy the amount of energy to set.
|
||||
*/
|
||||
public void setEnergy(double energy);
|
||||
|
||||
/**
|
||||
* Gets the max stored energy in the tile
|
||||
* @return The max energy
|
||||
*/
|
||||
public double getMaxPower();
|
||||
/**
|
||||
* Gets the max stored energy in the tile
|
||||
*
|
||||
* @return The max energy
|
||||
*/
|
||||
public double getMaxPower();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param energy amount of energy to add to the tile
|
||||
*
|
||||
* @return will return true if can fit all
|
||||
*/
|
||||
public boolean canAddEnergy(double energy);
|
||||
/**
|
||||
* @param energy amount of energy to add to the tile
|
||||
* @return will return true if can fit all
|
||||
*/
|
||||
public boolean canAddEnergy(double energy);
|
||||
|
||||
/**
|
||||
*
|
||||
* Will try add add the full amount of energy.
|
||||
*
|
||||
* @param energy amount to add
|
||||
*
|
||||
* @return The amount of energy that was added.
|
||||
*/
|
||||
public double addEnergy(double energy);
|
||||
/**
|
||||
* Will try add add the full amount of energy.
|
||||
*
|
||||
* @param energy amount to add
|
||||
* @return The amount of energy that was added.
|
||||
*/
|
||||
public double addEnergy(double energy);
|
||||
|
||||
/**
|
||||
*
|
||||
* Will try add add the full amount of energy, if simulate is true it wont add the energy
|
||||
*
|
||||
* @param energy amount to add
|
||||
*
|
||||
* @return The amount of energy that was added.
|
||||
*/
|
||||
public double addEnergy(double energy, boolean simulate);
|
||||
/**
|
||||
* Will try add add the full amount of energy, if simulate is true it wont add the energy
|
||||
*
|
||||
* @param energy amount to add
|
||||
* @return The amount of energy that was added.
|
||||
*/
|
||||
public double addEnergy(double energy, boolean simulate);
|
||||
|
||||
/**
|
||||
* Returns true if it can use the full amount of energy
|
||||
*
|
||||
* @param energy amount of energy to use from the tile.
|
||||
*
|
||||
* @return if all the energy can be used.
|
||||
*/
|
||||
public boolean canUseEnergy(double energy);
|
||||
/**
|
||||
* Returns true if it can use the full amount of energy
|
||||
*
|
||||
* @param energy amount of energy to use from the tile.
|
||||
* @return if all the energy can be used.
|
||||
*/
|
||||
public boolean canUseEnergy(double energy);
|
||||
|
||||
/**
|
||||
* Will try and use the full amount of energy
|
||||
*
|
||||
* @param energy energy to use
|
||||
*
|
||||
* @return the amount of energy used
|
||||
*/
|
||||
public double useEnergy(double energy);
|
||||
/**
|
||||
* Will try and use the full amount of energy
|
||||
*
|
||||
* @param energy energy to use
|
||||
* @return the amount of energy used
|
||||
*/
|
||||
public double useEnergy(double energy);
|
||||
|
||||
|
||||
/**
|
||||
* Will try and use the full amount of energy, if simulate is true it wont add the energy
|
||||
*
|
||||
* @param energy energy to use
|
||||
*
|
||||
* @return the amount of energy used
|
||||
*/
|
||||
public double useEnergy(double energy, boolean simulate);
|
||||
/**
|
||||
* Will try and use the full amount of energy, if simulate is true it wont add the energy
|
||||
*
|
||||
* @param energy energy to use
|
||||
* @return the amount of energy used
|
||||
*/
|
||||
public double useEnergy(double energy, boolean simulate);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param direction The direction to insert energy into
|
||||
*
|
||||
* @return if the tile can accept energy from the direction
|
||||
*/
|
||||
public boolean canAcceptEnergy(ForgeDirection direction);
|
||||
/**
|
||||
* @param direction The direction to insert energy into
|
||||
* @return if the tile can accept energy from the direction
|
||||
*/
|
||||
public boolean canAcceptEnergy(ForgeDirection direction);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param direction The direction to provide energy from
|
||||
* @return
|
||||
*/
|
||||
public boolean canProvideEnergy(ForgeDirection direction);
|
||||
/**
|
||||
* @param direction The direction to provide energy from
|
||||
* @return
|
||||
*/
|
||||
public boolean canProvideEnergy(ForgeDirection direction);
|
||||
|
||||
/**
|
||||
* Gets the max output, set to -1 if you don't want the tile to provide energy
|
||||
*
|
||||
* @return the max amount of energy outputted per tick.
|
||||
*/
|
||||
public double getMaxOutput();
|
||||
/**
|
||||
* Gets the max output, set to -1 if you don't want the tile to provide energy
|
||||
*
|
||||
* @return the max amount of energy outputted per tick.
|
||||
*/
|
||||
public double getMaxOutput();
|
||||
|
||||
/**
|
||||
* Return -1 if you don't want to accept power ever.
|
||||
*
|
||||
* @return The max amount of energy that can be added to the tile in one tick.
|
||||
*/
|
||||
public double getMaxInput();
|
||||
/**
|
||||
* Return -1 if you don't want to accept power ever.
|
||||
*
|
||||
* @return The max amount of energy that can be added to the tile in one tick.
|
||||
*/
|
||||
public double getMaxInput();
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ 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;
|
||||
|
||||
|
@ -35,17 +35,17 @@ public abstract class BaseRecipe implements IBaseRecipeType , Cloneable {
|
|||
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
|
||||
@Override
|
||||
public List<ItemStack> getInputs() {
|
||||
return inputs;
|
||||
}
|
||||
|
@ -76,17 +76,17 @@ public abstract class BaseRecipe implements IBaseRecipeType , Cloneable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object clone()throws CloneNotSupportedException{
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useOreDic() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean useOreDic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getOutputs() {
|
||||
return outputs;
|
||||
}
|
||||
@Override
|
||||
public List<ItemStack> getOutputs() {
|
||||
return outputs;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,17 +24,15 @@ public interface IBaseRecipeType {
|
|||
*/
|
||||
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
|
||||
|
@ -44,12 +42,12 @@ public interface IBaseRecipeType {
|
|||
*/
|
||||
public String getRecipeName();
|
||||
|
||||
/**
|
||||
* This should be a user friendly name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getUserFreindlyName();
|
||||
/**
|
||||
* This should be a user friendly name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getUserFreindlyName();
|
||||
|
||||
/**
|
||||
* This is how long the recipe needs to tick for the crafting operation to complete
|
||||
|
@ -77,7 +75,7 @@ public interface IBaseRecipeType {
|
|||
*/
|
||||
public boolean onCraft(TileEntity tile);
|
||||
|
||||
public Object clone()throws CloneNotSupportedException;
|
||||
public Object clone() throws CloneNotSupportedException;
|
||||
|
||||
public boolean useOreDic();
|
||||
public boolean useOreDic();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package techreborn.api.recipe;
|
||||
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.Packet;
|
||||
|
@ -72,7 +71,7 @@ public class RecipeCrafter {
|
|||
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){
|
||||
if (parentTile instanceof IEnergyInterfaceTile) {
|
||||
energy = (IEnergyInterfaceTile) parentTile;
|
||||
}
|
||||
this.inputs = inputs;
|
||||
|
@ -91,7 +90,7 @@ public class RecipeCrafter {
|
|||
|
||||
/**
|
||||
* This is used to change the speed of the crafting operation.
|
||||
*
|
||||
* <p/>
|
||||
* 0 = none;
|
||||
* 0.2 = 20% speed increase
|
||||
* 0.75 = 75% increase
|
||||
|
@ -100,7 +99,7 @@ public class RecipeCrafter {
|
|||
|
||||
/**
|
||||
* This is used to change the power of the crafting operation.
|
||||
*
|
||||
* <p/>
|
||||
* 1 = none;
|
||||
* 1.2 = 20% speed increase
|
||||
* 1.75 = 75% increase
|
||||
|
@ -108,20 +107,20 @@ public class RecipeCrafter {
|
|||
*/
|
||||
double powerMultiplier = 1;
|
||||
|
||||
int ticksSinceLastChange;
|
||||
int ticksSinceLastChange;
|
||||
|
||||
/**
|
||||
* Call this on the tile tick
|
||||
*/
|
||||
public void updateEntity() {
|
||||
if(parentTile.getWorldObj().isRemote){
|
||||
if (parentTile.getWorldObj().isRemote) {
|
||||
return;
|
||||
}
|
||||
ticksSinceLastChange ++;
|
||||
if(ticksSinceLastChange == 20){//Force a has chanced every second
|
||||
inventory.hasChanged = true;
|
||||
ticksSinceLastChange = 0;
|
||||
}
|
||||
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)) {
|
||||
|
@ -135,9 +134,9 @@ public class RecipeCrafter {
|
|||
}
|
||||
if (canGiveInvAll) {
|
||||
setCurrentRecipe(recipe);//Sets the current recipe then syncs
|
||||
this.currentNeededTicks = (int)(currentRecipe.tickTime() * (1.0 - speedMultiplier));
|
||||
this.currentNeededTicks = (int) (currentRecipe.tickTime() * (1.0 - speedMultiplier));
|
||||
this.currentTickTime = -1;
|
||||
syncIsActive();
|
||||
syncIsActive();
|
||||
} else {
|
||||
this.currentTickTime = -0;
|
||||
}
|
||||
|
@ -147,7 +146,7 @@ public class RecipeCrafter {
|
|||
if (inventory.hasChanged && !hasAllInputs()) {//If it doesn't have all the inputs reset
|
||||
currentRecipe = null;
|
||||
currentTickTime = 0;
|
||||
syncIsActive();
|
||||
syncIsActive();
|
||||
}
|
||||
if (currentRecipe != null && currentTickTime >= currentNeededTicks) {//If it has reached the recipe tick time
|
||||
boolean canGiveInvAll = true;
|
||||
|
@ -167,7 +166,7 @@ public class RecipeCrafter {
|
|||
useAllInputs();//this uses all the inputs
|
||||
currentRecipe = null;//resets
|
||||
currentTickTime = 0;
|
||||
syncIsActive();
|
||||
syncIsActive();
|
||||
}
|
||||
} else if (currentRecipe != null && currentTickTime < currentNeededTicks) {
|
||||
if (energy.canUseEnergy(getEuPerTick())) {//This uses the power
|
||||
|
@ -176,9 +175,9 @@ public class RecipeCrafter {
|
|||
}
|
||||
}
|
||||
}
|
||||
if(inventory.hasChanged){
|
||||
inventory.hasChanged = false;
|
||||
}
|
||||
if (inventory.hasChanged) {
|
||||
inventory.hasChanged = false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasAllInputs() {
|
||||
|
@ -264,14 +263,14 @@ public class RecipeCrafter {
|
|||
public void readFromNBT(NBTTagCompound tag) {
|
||||
NBTTagCompound data = tag.getCompoundTag("Crater");
|
||||
|
||||
if(data.hasKey("currentTickTime"))
|
||||
currentTickTime = data.getInteger("currentTickTime");
|
||||
if (data.hasKey("currentTickTime"))
|
||||
currentTickTime = data.getInteger("currentTickTime");
|
||||
|
||||
isactive = data.getBoolean("isActive");
|
||||
if(parentTile != null && parentTile.getWorldObj() != null && parentTile.getWorldObj().isRemote){
|
||||
parentTile.getWorldObj().markBlockForUpdate(parentTile.xCoord, parentTile.yCoord, parentTile.zCoord);
|
||||
parentTile.getWorldObj().markBlockRangeForRenderUpdate(parentTile.xCoord, parentTile.yCoord, parentTile.zCoord, parentTile.xCoord, parentTile.yCoord, parentTile.zCoord);
|
||||
}
|
||||
if (parentTile != null && parentTile.getWorldObj() != null && parentTile.getWorldObj().isRemote) {
|
||||
parentTile.getWorldObj().markBlockForUpdate(parentTile.xCoord, parentTile.yCoord, parentTile.zCoord);
|
||||
parentTile.getWorldObj().markBlockRangeForRenderUpdate(parentTile.xCoord, parentTile.yCoord, parentTile.zCoord, parentTile.xCoord, parentTile.yCoord, parentTile.zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
|
@ -293,54 +292,54 @@ public class RecipeCrafter {
|
|||
return isactive;
|
||||
}
|
||||
|
||||
public void addSpeedMulti(double amount){
|
||||
if(speedMultiplier + amount <= 0.99){
|
||||
speedMultiplier += amount;
|
||||
} else {
|
||||
speedMultiplier = 0.99;
|
||||
}
|
||||
public void addSpeedMulti(double amount) {
|
||||
if (speedMultiplier + amount <= 0.99) {
|
||||
speedMultiplier += amount;
|
||||
} else {
|
||||
speedMultiplier = 0.99;
|
||||
}
|
||||
}
|
||||
|
||||
public void resetSpeedMulti(){
|
||||
public void resetSpeedMulti() {
|
||||
speedMultiplier = 0;
|
||||
}
|
||||
|
||||
public double getSpeedMultiplier(){
|
||||
public double getSpeedMultiplier() {
|
||||
return speedMultiplier;
|
||||
}
|
||||
|
||||
public void addPowerMulti(double amount){
|
||||
public void addPowerMulti(double amount) {
|
||||
powerMultiplier += amount;
|
||||
}
|
||||
|
||||
public void resetPowerMulti(){
|
||||
public void resetPowerMulti() {
|
||||
powerMultiplier = 1;
|
||||
}
|
||||
|
||||
public double getPowerMultiplier(){
|
||||
public double getPowerMultiplier() {
|
||||
return powerMultiplier;
|
||||
}
|
||||
|
||||
public double getEuPerTick(){
|
||||
public double getEuPerTick() {
|
||||
return currentRecipe.euPerTick() * powerMultiplier;
|
||||
}
|
||||
|
||||
|
||||
public void syncIsActive() {
|
||||
if (!parentTile.getWorldObj().isRemote) {
|
||||
PacketHandler.sendPacketToAllPlayers(getSyncPacket(),
|
||||
parentTile.getWorldObj());
|
||||
}
|
||||
}
|
||||
public void syncIsActive() {
|
||||
if (!parentTile.getWorldObj().isRemote) {
|
||||
PacketHandler.sendPacketToAllPlayers(getSyncPacket(),
|
||||
parentTile.getWorldObj());
|
||||
}
|
||||
}
|
||||
|
||||
public Packet getSyncPacket() {
|
||||
NBTTagCompound nbtTag = new NBTTagCompound();
|
||||
writeToNBT(nbtTag);
|
||||
return new S35PacketUpdateTileEntity(this.parentTile.xCoord, this.parentTile.yCoord,
|
||||
this.parentTile.zCoord, 1, nbtTag);
|
||||
}
|
||||
public Packet getSyncPacket() {
|
||||
NBTTagCompound nbtTag = new NBTTagCompound();
|
||||
writeToNBT(nbtTag);
|
||||
return new S35PacketUpdateTileEntity(this.parentTile.xCoord, this.parentTile.yCoord,
|
||||
this.parentTile.zCoord, 1, nbtTag);
|
||||
}
|
||||
|
||||
public void setCurrentRecipe(IBaseRecipeType recipe){
|
||||
public void setCurrentRecipe(IBaseRecipeType recipe) {
|
||||
try {
|
||||
this.currentRecipe = (IBaseRecipeType) recipe.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
|
|
|
@ -62,7 +62,7 @@ public class RecipeHandler {
|
|||
if (recipeList.contains(recipe)) {
|
||||
return;
|
||||
}
|
||||
if(!RecipeConfigManager.canLoadRecipe(recipe)){
|
||||
if (!RecipeConfigManager.canLoadRecipe(recipe)) {
|
||||
return;
|
||||
}
|
||||
if (!machineNames.contains(recipe.getRecipeName())) {
|
||||
|
@ -86,11 +86,11 @@ public class RecipeHandler {
|
|||
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()){
|
||||
for (ItemStack inputs : baseRecipeType.getInputs()) {
|
||||
itemInfo.append(":" + inputs.getItem().getUnlocalizedName() + "," + inputs.getDisplayName() + "," + inputs.stackSize);
|
||||
}
|
||||
LogHelper.all(stackMap.get(baseRecipeType));
|
||||
// throw new Exception("Found a duplicate recipe for " + baseRecipeType.getRecipeName() + " with inputs " + itemInfo.toString());
|
||||
// throw new Exception("Found a duplicate recipe for " + baseRecipeType.getRecipeName() + " with inputs " + itemInfo.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ public class AlloySmelterRecipe extends BaseRecipe {
|
|||
addOutput(output1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Alloy Smelter";
|
||||
}
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Alloy Smelter";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ public class AssemblingMachineRecipe extends BaseRecipe {
|
|||
addOutput(output1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Assembling Machine";
|
||||
}
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Assembling Machine";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ import techreborn.tiles.TileBlastFurnace;
|
|||
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) {
|
||||
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);
|
||||
|
@ -22,25 +22,25 @@ public class BlastFurnaceRecipe extends BaseRecipe {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@ public class CentrifugeRecipe extends BaseRecipe {
|
|||
addOutput(output4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Centrifuge";
|
||||
}
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Centrifuge";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ public class ChemicalReactorRecipe extends BaseRecipe {
|
|||
addOutput(output1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Chemical Reactor";
|
||||
}
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Chemical Reactor";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class GrinderRecipe extends BaseRecipe {
|
|||
super(Reference.grinderRecipe, tickTime, euPerTick);
|
||||
if (input1 != null)
|
||||
inputs.add(input1);
|
||||
if( input2 != null)
|
||||
if (input2 != null)
|
||||
inputs.add(input2);
|
||||
if (output1 != null)
|
||||
addOutput(output1);
|
||||
|
@ -29,12 +29,12 @@ public class GrinderRecipe extends BaseRecipe {
|
|||
this.fluidStack = fluidStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Grinder";
|
||||
}
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Grinder";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean canCraft(TileEntity tile) {
|
||||
if (fluidStack == null) {
|
||||
return true;
|
||||
|
|
|
@ -18,8 +18,8 @@ public class ImplosionCompressorRecipe extends BaseRecipe {
|
|||
addOutput(output2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Implosion Compressor";
|
||||
}
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Implosion Compressor";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,41 +1,36 @@
|
|||
package techreborn.api.recipe.machines;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import techreborn.api.recipe.BaseRecipe;
|
||||
import techreborn.lib.Reference;
|
||||
import techreborn.tiles.TileIndustrialElectrolyzer;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
private boolean useOreDictionary = true;
|
||||
}
|
||||
|
|
|
@ -44,12 +44,12 @@ public class IndustrialSawmillRecipe extends BaseRecipe {
|
|||
this.canUseOreDict = canUseOreDict;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Industrial Sawmill";
|
||||
}
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Industrial Sawmill";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean canCraft(TileEntity tile) {
|
||||
if (fluidStack == null) {
|
||||
return true;
|
||||
|
@ -92,8 +92,8 @@ public class IndustrialSawmillRecipe extends BaseRecipe {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useOreDic() {
|
||||
return canUseOreDict;
|
||||
}
|
||||
@Override
|
||||
public boolean useOreDic() {
|
||||
return canUseOreDict;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ public class LatheRecipe extends BaseRecipe {
|
|||
addOutput(output1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Lathe";
|
||||
}
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Lathe";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,11 +11,11 @@ public class PlateCuttingMachineRecipe extends BaseRecipe {
|
|||
if (input1 != null)
|
||||
inputs.add(input1);
|
||||
if (output1 != null)
|
||||
addOutput(output1);
|
||||
addOutput(output1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Plate Cutting Machine";
|
||||
}
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Plate Cutting Machine";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,15 +44,15 @@ public class RecipeConfig {
|
|||
this.machine = machine;
|
||||
}
|
||||
|
||||
public void addInputs(ConfigItem item){
|
||||
if(inputs == null){
|
||||
public void addInputs(ConfigItem item) {
|
||||
if (inputs == null) {
|
||||
inputs = new ArrayList<ConfigItem>();
|
||||
}
|
||||
inputs.add(item);
|
||||
}
|
||||
|
||||
public void addOutputs(ConfigItem item){
|
||||
if(outputs == null){
|
||||
public void addOutputs(ConfigItem item) {
|
||||
if (outputs == null) {
|
||||
outputs = new ArrayList<ConfigItem>();
|
||||
}
|
||||
outputs.add(item);
|
||||
|
|
|
@ -16,14 +16,14 @@ public class RecipeConfigManager {
|
|||
|
||||
static File configFile = null;
|
||||
|
||||
public static void load(File configDir){
|
||||
if(configFile == null){
|
||||
public static void load(File configDir) {
|
||||
if (configFile == null) {
|
||||
configFile = new File(configDir, "techRebornRecipes.json");
|
||||
}
|
||||
}
|
||||
|
||||
public static void save(){
|
||||
if(configFile.exists()){
|
||||
public static void save() {
|
||||
if (configFile.exists()) {
|
||||
configFile.delete();
|
||||
}
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
@ -38,12 +38,12 @@ public class RecipeConfigManager {
|
|||
}
|
||||
|
||||
|
||||
public static boolean canLoadRecipe(IBaseRecipeType recipeType){
|
||||
public static boolean canLoadRecipe(IBaseRecipeType recipeType) {
|
||||
RecipeConfig config = new RecipeConfig();
|
||||
for(ItemStack stack : recipeType.getInputs()){
|
||||
for (ItemStack stack : recipeType.getInputs()) {
|
||||
config.addInputs(itemToConfig(stack));
|
||||
}
|
||||
for(ItemStack stack : recipeType.getOutputs()){
|
||||
for (ItemStack stack : recipeType.getOutputs()) {
|
||||
config.addOutputs(itemToConfig(stack));
|
||||
}
|
||||
config.enabled = true;
|
||||
|
@ -53,7 +53,7 @@ public class RecipeConfigManager {
|
|||
}
|
||||
|
||||
|
||||
public static ConfigItem itemToConfig(ItemStack stack){
|
||||
public static ConfigItem itemToConfig(ItemStack stack) {
|
||||
ConfigItem newItem = new ConfigItem();
|
||||
newItem.setItemName(stack.getItem().getUnlocalizedName());
|
||||
newItem.setMeta(stack.getItemDamage());
|
||||
|
|
|
@ -5,5 +5,5 @@ import techreborn.api.recipe.RecipeCrafter;
|
|||
|
||||
public interface IMachineUpgrade {
|
||||
|
||||
public void processUpgrade(RecipeCrafter crafter, ItemStack stack);
|
||||
public void processUpgrade(RecipeCrafter crafter, ItemStack stack);
|
||||
}
|
||||
|
|
|
@ -8,32 +8,32 @@ import java.util.ArrayList;
|
|||
|
||||
public class UpgradeHandler {
|
||||
|
||||
RecipeCrafter crafter;
|
||||
RecipeCrafter crafter;
|
||||
|
||||
Inventory inventory;
|
||||
Inventory inventory;
|
||||
|
||||
ArrayList<Integer> slots = new ArrayList<Integer>();
|
||||
ArrayList<Integer> slots = new ArrayList<Integer>();
|
||||
|
||||
public UpgradeHandler(RecipeCrafter crafter, Inventory inventory, int... slots) {
|
||||
this.crafter = crafter;
|
||||
this.inventory = inventory;
|
||||
for(int slot : slots){
|
||||
this.slots.add(slot);
|
||||
}
|
||||
}
|
||||
public UpgradeHandler(RecipeCrafter crafter, Inventory inventory, int... slots) {
|
||||
this.crafter = crafter;
|
||||
this.inventory = inventory;
|
||||
for (int slot : slots) {
|
||||
this.slots.add(slot);
|
||||
}
|
||||
}
|
||||
|
||||
public void tick(){
|
||||
if(crafter.parentTile.getWorldObj().isRemote)
|
||||
return;
|
||||
crafter.resetPowerMulti();
|
||||
crafter.resetSpeedMulti();
|
||||
for(int slot : this.slots){
|
||||
ItemStack stack = inventory.getStackInSlot(slot);
|
||||
if(stack != null && stack.getItem() instanceof IMachineUpgrade){
|
||||
((IMachineUpgrade) stack.getItem()).processUpgrade(crafter, stack);
|
||||
}
|
||||
}
|
||||
if(crafter.currentRecipe != null)
|
||||
crafter.currentNeededTicks = (int)(crafter.currentRecipe.tickTime() * (1.0 - crafter.getSpeedMultiplier()));
|
||||
}
|
||||
public void tick() {
|
||||
if (crafter.parentTile.getWorldObj().isRemote)
|
||||
return;
|
||||
crafter.resetPowerMulti();
|
||||
crafter.resetSpeedMulti();
|
||||
for (int slot : this.slots) {
|
||||
ItemStack stack = inventory.getStackInSlot(slot);
|
||||
if (stack != null && stack.getItem() instanceof IMachineUpgrade) {
|
||||
((IMachineUpgrade) stack.getItem()).processUpgrade(crafter, stack);
|
||||
}
|
||||
}
|
||||
if (crafter.currentRecipe != null)
|
||||
crafter.currentNeededTicks = (int) (crafter.currentRecipe.tickTime() * (1.0 - crafter.getSpeedMultiplier()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI")
|
||||
package techreborn.api.upgrade;
|
||||
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") package techreborn.api.upgrade;
|
||||
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue