Some work on the new api

This commit is contained in:
modmuss50 2016-04-03 14:07:45 +01:00
parent 3d819967be
commit df61729d6f
69 changed files with 1380 additions and 1413 deletions

View file

@ -79,6 +79,7 @@ public class Core
recipeCompact = new RecipeCompact();
TechRebornAPI.recipeCompact = recipeCompact;
TechRebornAPI.subItemRetriever = new SubItemRetriever();
for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules)
{

View file

@ -0,0 +1,61 @@
package techreborn.api;
import net.minecraft.item.ItemStack;
public interface ISubItemRetriever {
ItemStack getCellByName(String name);
ItemStack getCellByName(String name, int count);
ItemStack getCellByName(String name, int count, boolean lookForIC2);
ItemStack getCrushedOreByName(String name);
ItemStack getCrushedOreByName(String name, int count);
ItemStack getDustByName(String name);
ItemStack getDustByName(String name, int count);
ItemStack getSmallDustByName(String name);
ItemStack getSmallDustByName(String name, int count);
ItemStack getGemByName(String name);
ItemStack getGemByName(String name, int count);
ItemStack getIngotByName(String name);
ItemStack getIngotByName(String name, int count);
ItemStack getNuggetByName(String name);
ItemStack getNuggetByName(String name, int count);
ItemStack getPartByName(String name);
ItemStack getPartByName(String name, int count);
ItemStack getPlateByName(String name);
ItemStack getPlateByName(String name, int count);
ItemStack getPurifiedCrushedOreByName(String name);
ItemStack getPurifiedCrushedOreByName(String name, int count);
ItemStack getUpgradeByName(String name);
ItemStack getUpgradeByName(String name, int count);
ItemStack getOreByName(String name);
ItemStack getOreByName(String name, int count);
ItemStack getStorageBlockByName(String name);
ItemStack getStorageBlockByName(String name, int count);
}

View file

@ -0,0 +1,47 @@
package techreborn.api;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.util.text.translation.I18n;
import net.minecraftforge.common.util.EnumHelper;
import techreborn.lib.ModInfo;
/**
* This contains some static stuff used in recipes and other things
*/
public class Reference {
public static ToolMaterial BRONZE = EnumHelper.addToolMaterial("BRONZE", 2, 375, 6.0F, 2.25F, 8);
public static ArmorMaterial BRONZE_ARMOUR = EnumHelper.addArmorMaterial("BRONZE", ModInfo.MOD_ID + ":bronze", 17,
new int[]{3, 6, 5, 2}, 8, null/* TODO: SoundEvent */);
public static ToolMaterial RUBY = EnumHelper.addToolMaterial("RUBY", 2, 320, 6.2F, 2.7F, 10);
public static ArmorMaterial RUBY_ARMOUR = EnumHelper.addArmorMaterial("RUBY", ModInfo.MOD_ID + ":ruby", 16,
new int[]{2, 7, 5, 2}, 10, null/* TODO: SoundEvent */);
public static ToolMaterial SAPPHIRE = EnumHelper.addToolMaterial("SAPPHIRE", 2, 620, 5.0F, 2F, 8);
public static ArmorMaterial SAPPHIRE_ARMOUR = EnumHelper.addArmorMaterial("SAPPHIRE", ModInfo.MOD_ID + ":sapphire",
19, new int[]{4, 4, 4, 4}, 8, null/* TODO: SoundEvent */);
public static ToolMaterial PERIDOT = EnumHelper.addToolMaterial("PERIDOT", 2, 400, 7.0F, 2.4F, 16);
public static ArmorMaterial PERIDOT_ARMOUR = EnumHelper.addArmorMaterial("PERIDOT", ModInfo.MOD_ID + ":peridot", 17,
new int[]{3, 8, 3, 2}, 16, null/* TODO: SoundEvent */);
public static String alloySmelteRecipe = I18n.translateToLocal("techreborn.recipe.alloysmelter");
public static String assemblingMachineRecipe = I18n.translateToLocal("techreborn.recipe.assemblingmachine");
public static String blastFurnaceRecipe = I18n.translateToLocal("techreborn.recipe.blastfurnace");
public static String centrifugeRecipe = I18n.translateToLocal("techreborn.recipe.centrifuge");
public static String chemicalReactorRecipe = I18n.translateToLocal("techreborn.recipe.chemicalReactor");
public static String industrialGrinderRecipe = I18n.translateToLocal("techreborn.recipe.grinder");
public static String implosionCompressorRecipe = I18n.translateToLocal("techreborn.recipe.implosioncompressor");
public static String industrialElectrolyzerRecipe = I18n
.translateToLocal("techreborn.recipe.industrialelectrolyzer");
public static String industrialSawmillRecipe = I18n.translateToLocal("techreborn.recipe.industrialsawmill");
public static String latheRecipe = I18n.translateToLocal("techreborn.recipe.lathe");
public static String plateCuttingMachineRecipe = I18n.translateToLocal("techreborn.recipe.platecuttingmachine");
public static String vacuumFreezerRecipe = I18n.translateToLocal("tile.techreborn.vacuumfreezer.name");
public static String grinderRecipe = I18n.translateToLocal("tile.techreborn.grinder.name");
public static String extractorRecipe = I18n.translateToLocal("tile.techreborn.extractor.name");
public static String compressorRecipe = I18n.translateToLocal("tile.techreborn.compressor.name");
public static String recyclerRecipe = I18n.translateToLocal("tile.techreborn.recycler.name");
public static String scrapboxRecipe = I18n.translateToLocal("techreborn.recipe.scrapbox");
}

View file

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

View file

@ -1,31 +1,42 @@
package techreborn.api;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import techreborn.Core;
/**
* Use this to add items to the scrap box and to check if an item is present
* there
*/
public class ScrapboxList {
public class ScrapboxList
{
/**
* This full list of items that is registered with this api
*/
public static List<ItemStack> stacks = new ArrayList<>();
public static List<ItemStack> stacks = new ArrayList<>();
/**
* Use this to add an item stack to the list
*
* @param stack the itemstack you want to add
*/
public static void addItemStackToList(ItemStack stack) {
if (!hasItems(stack)) {
stacks.add(stack);
}
}
public static void addItemStackToList(ItemStack stack)
{
if (!hasItems(stack))
{
stacks.add(stack);
}
}
private static boolean hasItems(ItemStack stack)
{
for (ItemStack s : stacks)
{
if (stack.getDisplayName().equals(s.getDisplayName()))
return true;
}
return false;
}
/**
* @param stack the itemstack you want to test
* @return if the scrapbox can output this this item
*/
private static boolean hasItems(ItemStack stack) {
for (ItemStack s : stacks) {
// TODO why do this!!!!!!!!!
if (stack.getDisplayName().equals(s.getDisplayName()))
return true;
}
return false;
}
}

View file

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

View file

@ -1,39 +1,81 @@
package techreborn.api;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import techreborn.api.recipe.IRecipeCompact;
public final class TechRebornAPI
{
public final class TechRebornAPI {
public static IRecipeCompact recipeCompact;
/**
* Use this to get the instance of IRecipeCompat
*/
public static IRecipeCompact recipeCompact;
public static void addRollingOreMachinceRecipe(ItemStack output, Object... components)
{
RollingMachineRecipe.instance.addShapedOreRecipe(output, components);
}
public static ISubItemRetriever subItemRetriever;
public static void addShapelessOreRollingMachinceRecipe(ItemStack output, Object... components)
{
RollingMachineRecipe.instance.addShapelessOreRecipe(output, components);
}
public static void addRollingOreMachinceRecipe(ItemStack output, Object... components) {
RollingMachineRecipe.instance.addShapedOreRecipe(output, components);
}
public static void addRollingMachinceRecipe(ItemStack output, Object... components)
{
RollingMachineRecipe.instance.addRecipe(output, components);
}
public static void addShapelessOreRollingMachinceRecipe(ItemStack output, Object... components) {
RollingMachineRecipe.instance.addShapelessOreRecipe(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);
}
/**
* Use this to get an item from techrebonrn, @see <a href=
* "https://github.com/TechReborn/TechReborn/blob/1.9/src/main/java/techreborn/init/ModItems.java">
* ModItems.java</a> for the full list
*
* @param name
* @return
*/
public static Item getItem(String name) {
try {
Object e = Class.forName("techreborn.init.ModItems").getField(name).get(null);
return e instanceof Item ? (Item) e : null;
} catch (NoSuchFieldException e1) {
e1.printStackTrace();
return null;
} catch (IllegalAccessException e) {
e.printStackTrace();
return null;
} catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}
/**
* Use this to get an block from techrebonrn, @see <a href=
* "https://github.com/TechReborn/TechReborn/blob/1.9/src/main/java/techreborn/init/ModBlocks.java">
* ModBlocks.java</a> for the full list
*
* @param name
* @return
*/
public static Block getBlock(String name) {
try {
Object e = Class.forName("techreborn.init.ModBlocks").getField(name).get(null);
return e instanceof Block ? (Block) e : null;
} catch (NoSuchFieldException e1) {
e1.printStackTrace();
return null;
} catch (IllegalAccessException e) {
e.printStackTrace();
return null;
} catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}
}
class RegisteredItemRecipe extends Exception
{
public RegisteredItemRecipe(String message)
{
super(message);
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,101 +1,87 @@
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 String name;
public int tickTime;
public int euPerTick;
private ArrayList<ItemStack> outputs;
public ArrayList<ItemStack> inputs;
public String name;
public int tickTime;
public int euPerTick;
private ArrayList<ItemStack> outputs;
public BaseRecipe(String name, int tickTime, int euPerTick)
{
inputs = new ArrayList<ItemStack>();
outputs = new ArrayList<ItemStack>();
this.name = name;
// This adds all new recipes
this.tickTime = tickTime;
this.euPerTick = euPerTick;
}
public BaseRecipe(String name, int tickTime, int euPerTick) {
inputs = new ArrayList<>();
outputs = new ArrayList<>();
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 List<ItemStack> getInputs() {
return inputs;
}
@Override
public String getRecipeName()
{
return name;
}
@Override
public String getRecipeName() {
return name;
}
@Override
public int tickTime()
{
return tickTime;
}
@Override
public int tickTime() {
return tickTime;
}
@Override
public int euPerTick()
{
return euPerTick;
}
@Override
public int euPerTick() {
return euPerTick;
}
@Override
public boolean canCraft(TileEntity tile)
{
return true;
}
@Override
public boolean canCraft(TileEntity tile) {
return true;
}
@Override
public boolean onCraft(TileEntity tile)
{
return true;
}
@Override
public boolean onCraft(TileEntity tile) {
return true;
}
@Override
public Object clone() throws CloneNotSupportedException
{
return super.clone();
}
@Override
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;
}
}

View file

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

View file

@ -1,23 +1,20 @@
package techreborn.api.recipe;
import net.minecraft.item.ItemStack;
import techreborn.api.Reference;
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)
{
super(Reference.recyclerRecipe, 0, 0);
inputs.add(input);
addOutput(ItemParts.getPartByName("scrap"));
}
public RecyclerRecipe(ItemStack input) {
super(Reference.recyclerRecipe, 0, 0);
inputs.add(input);
addOutput(ItemParts.getPartByName("scrap"));
}
@Override
public String getUserFreindlyName()
{
return "Recycler";
}
@Override
public String getUserFreindlyName() {
return "Recycler";
}
}

View file

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

View file

@ -1,26 +1,23 @@
package techreborn.api.recipe.machines;
import net.minecraft.item.ItemStack;
import techreborn.api.Reference;
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

@ -1,26 +1,23 @@
package techreborn.api.recipe.machines;
import net.minecraft.item.ItemStack;
import techreborn.api.Reference;
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

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

View file

@ -1,47 +1,43 @@
package techreborn.api.recipe.machines;
import net.minecraft.item.ItemStack;
import techreborn.api.Reference;
import techreborn.api.recipe.BaseRecipe;
import techreborn.lib.Reference;
public class CentrifugeRecipe extends BaseRecipe
{
public class CentrifugeRecipe extends BaseRecipe {
boolean useOreDic = false;
boolean useOreDic = false;
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, boolean useOreDic)
{
this(input1, input2, output1, output2, output3, output4, tickTime, euPerTick);
this.useOreDic = useOreDic;
}
@Override
public String getUserFreindlyName()
{
return "Centrifuge";
}
@Override
public boolean useOreDic() {
return useOreDic;
}
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, boolean useOreDic) {
this(input1, input2, output1, output2, output3, output4, tickTime, euPerTick);
this.useOreDic = useOreDic;
}
@Override
public String getUserFreindlyName() {
return "Centrifuge";
}
@Override
public boolean useOreDic() {
return useOreDic;
}
}

View file

@ -1,26 +1,23 @@
package techreborn.api.recipe.machines;
import net.minecraft.item.ItemStack;
import techreborn.api.Reference;
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,21 @@
package techreborn.api.recipe.machines;
import net.minecraft.item.ItemStack;
import techreborn.api.Reference;
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,21 @@
package techreborn.api.recipe.machines;
import net.minecraft.item.ItemStack;
import techreborn.api.Reference;
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,21 @@
package techreborn.api.recipe.machines;
import net.minecraft.item.ItemStack;
import techreborn.api.Reference;
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

@ -1,29 +1,26 @@
package techreborn.api.recipe.machines;
import net.minecraft.item.ItemStack;
import techreborn.api.Reference;
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

@ -1,41 +1,37 @@
package techreborn.api.recipe.machines;
import net.minecraft.item.ItemStack;
import techreborn.api.Reference;
import techreborn.api.recipe.BaseRecipe;
import techreborn.lib.Reference;
public class IndustrialElectrolyzerRecipe extends BaseRecipe
{
public class IndustrialElectrolyzerRecipe extends BaseRecipe {
private boolean useOreDictionary = true;
private boolean useOreDictionary = true;
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;
}
}

View file

@ -3,95 +3,78 @@ package techreborn.api.recipe.machines;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidStack;
import techreborn.api.Reference;
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

@ -3,119 +3,100 @@ package techreborn.api.recipe.machines;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidStack;
import techreborn.api.Reference;
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

@ -1,24 +1,21 @@
package techreborn.api.recipe.machines;
import net.minecraft.item.ItemStack;
import techreborn.api.Reference;
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

@ -2,38 +2,32 @@ package techreborn.api.recipe.machines;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import techreborn.api.Reference;
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,53 +1,44 @@
package techreborn.api.recipe.recipeConfig;
public class ConfigItem
{
public class ConfigItem {
String localName;
String localName;
String itemName;
String itemName;
int meta;
int meta;
int stackSize;
int stackSize;
public String getItemName()
{
return itemName;
}
public String getItemName() {
return itemName;
}
public void setItemName(String itemName)
{
this.itemName = itemName;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public int getMeta()
{
return meta;
}
public int getMeta() {
return meta;
}
public void setMeta(int meta)
{
this.meta = meta;
}
public void setMeta(int meta) {
this.meta = meta;
}
public int getStackSize()
{
return stackSize;
}
public int getStackSize() {
return stackSize;
}
public void setStackSize(int stackSize)
{
this.stackSize = stackSize;
}
public void setStackSize(int stackSize) {
this.stackSize = stackSize;
}
public String getLocalName()
{
return localName;
}
public String getLocalName() {
return localName;
}
public void setLocalName(String localName)
{
this.localName = 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,63 @@
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 boolean canLoadRecipe(IBaseRecipeType recipeType) {
RecipeConfig config = new RecipeConfig();
for (ItemStack stack : recipeType.getInputs()) {
config.addInputs(itemToConfig(stack));
}
for (ItemStack stack : recipeType.getOutputs()) {
config.addOutputs(itemToConfig(stack));
}
config.enabled = true;
config.setMachine(recipeType.getRecipeName());
configs.add(config);
return config.enabled;
}
public static void save()
{
if (configFile.exists())
{
configFile.delete();
}
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String json = gson.toJson(configs);
try
{
FileWriter writer = new FileWriter(configFile);
writer.write(json);
writer.close();
} catch (IOException e)
{
e.printStackTrace();
}
}
public static boolean canLoadRecipe(IBaseRecipeType recipeType)
{
RecipeConfig config = new RecipeConfig();
for (ItemStack stack : recipeType.getInputs())
{
config.addInputs(itemToConfig(stack));
}
for (ItemStack stack : recipeType.getOutputs())
{
config.addOutputs(itemToConfig(stack));
}
config.enabled = true;
config.setMachine(recipeType.getRecipeName());
configs.add(config);
return config.enabled;
}
public static ConfigItem itemToConfig(ItemStack stack)
{
ConfigItem newItem = new ConfigItem();
newItem.setItemName(stack.getItem().getUnlocalizedName());
newItem.setMeta(stack.getItemDamage());
newItem.setStackSize(stack.stackSize);
newItem.setLocalName(stack.getDisplayName());
return newItem;
}
public static ConfigItem itemToConfig(ItemStack stack) {
ConfigItem newItem = new ConfigItem();
newItem.setItemName(stack.getItem().getUnlocalizedName());
newItem.setMeta(stack.getItemDamage());
newItem.setStackSize(stack.stackSize);
newItem.setLocalName(stack.getDisplayName());
return newItem;
}
}

View file

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

View file

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

View file

@ -59,7 +59,7 @@ public class BlockOre extends BaseBlock implements ITexturedBlock, IOreNameProvi
return new ItemStack(ModBlocks.ore, count, i);
}
}
throw new InvalidParameterException("The ore block " + name + " could not be found.");
return BlockOre2.getOreByName(name, count);
}
public static ItemStack getOreByName(String name)

View file

@ -3,7 +3,7 @@ package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot;
import reborncore.client.gui.SlotOutput;
import techreborn.api.SlotUpgrade;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.TileAlloySmelter;
public class ContainerAlloySmelter extends ContainerCrafting

View file

@ -3,7 +3,7 @@ package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot;
import reborncore.client.gui.SlotOutput;
import techreborn.api.SlotUpgrade;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.TileAssemblingMachine;
public class ContainerAssemblingMachine extends ContainerCrafting

View file

@ -3,7 +3,7 @@ package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot;
import reborncore.client.gui.SlotOutput;
import techreborn.api.SlotUpgrade;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.TileCentrifuge;
public class ContainerCentrifuge extends ContainerCrafting

View file

@ -3,7 +3,7 @@ package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot;
import reborncore.client.gui.SlotOutput;
import techreborn.api.SlotUpgrade;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.TileChemicalReactor;
public class ContainerChemicalReactor extends ContainerCrafting

View file

@ -3,7 +3,7 @@ package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot;
import reborncore.client.gui.SlotOutput;
import techreborn.api.SlotUpgrade;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.teir1.TileCompressor;
public class ContainerCompressor extends ContainerCrafting

View file

@ -4,7 +4,7 @@ import net.minecraft.inventory.ICrafting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.common.container.RebornContainer;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.utils.RecipeCrafter;
public abstract class ContainerCrafting extends RebornContainer
{

View file

@ -6,7 +6,7 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.client.gui.SlotOutput;
import reborncore.common.container.RebornContainer;
import techreborn.api.SlotUpgrade;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.teir1.TileElectricFurnace;
public class ContainerElectricFurnace extends RebornContainer

View file

@ -3,7 +3,7 @@ package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot;
import reborncore.client.gui.SlotOutput;
import techreborn.api.SlotUpgrade;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.teir1.TileExtractor;
public class ContainerExtractor extends ContainerCrafting

View file

@ -3,7 +3,7 @@ package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot;
import reborncore.client.gui.SlotOutput;
import techreborn.api.SlotUpgrade;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.teir1.TileGrinder;
public class ContainerGrinder extends ContainerCrafting

View file

@ -6,7 +6,7 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.client.gui.SlotOutput;
import reborncore.common.container.RebornContainer;
import techreborn.api.SlotUpgrade;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.teir1.TileRecycler;
public class ContainerRecycler extends RebornContainer

View file

@ -6,7 +6,7 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.client.gui.SlotOutput;
import reborncore.common.container.RebornContainer;
import techreborn.api.SlotUpgrade;
import techreborn.api.gui.SlotUpgrade;
import techreborn.tiles.TileScrapboxinator;
public class ContainerScrapboxinator extends RebornContainer

View file

@ -19,8 +19,7 @@ import techreborn.items.armor.ItemLapotronPack;
import techreborn.items.armor.ItemLithiumBatpack;
import techreborn.items.armor.ItemTRArmour;
import techreborn.items.tools.*;
import techreborn.lib.Reference;
import techreborn.parts.ItemStandaloneCables;
import techreborn.api.Reference;
public class ModItems
{

View file

@ -0,0 +1,157 @@
package techreborn.init;
import net.minecraft.item.ItemStack;
import techreborn.api.ISubItemRetriever;
import techreborn.blocks.BlockOre;
import techreborn.blocks.BlockStorage;
import techreborn.items.ItemCells;
import techreborn.items.ItemCrushedOre;
import techreborn.items.ItemDusts;
import techreborn.items.ItemDustsSmall;
import techreborn.items.ItemGems;
import techreborn.items.ItemIngots;
import techreborn.items.ItemNuggets;
import techreborn.items.ItemParts;
import techreborn.items.ItemPlates;
import techreborn.items.ItemPurifiedCrushedOre;
import techreborn.items.ItemUpgrades;
/**
* Created by Mark on 03/04/2016.
*/
public class SubItemRetriever implements ISubItemRetriever {
@Override
public ItemStack getCellByName(String name) {
return ItemCells.getCellByName(name);
}
@Override
public ItemStack getCellByName(String name, int count) {
return ItemCells.getCellByName(name, count);
}
@Override
public ItemStack getCellByName(String name, int count, boolean lookForIC2) {
return ItemCells.getCellByName(name, count, lookForIC2);
}
@Override
public ItemStack getCrushedOreByName(String name) {
return ItemCrushedOre.getCrushedOreByName(name);
}
@Override
public ItemStack getCrushedOreByName(String name, int count) {
return ItemCrushedOre.getCrushedOreByName(name, count);
}
@Override
public ItemStack getDustByName(String name) {
return ItemDusts.getDustByName(name);
}
@Override
public ItemStack getDustByName(String name, int count) {
return ItemDusts.getDustByName(name, count);
}
@Override
public ItemStack getSmallDustByName(String name) {
return ItemDustsSmall.getSmallDustByName(name);
}
@Override
public ItemStack getSmallDustByName(String name, int count) {
return ItemDustsSmall.getSmallDustByName(name, count);
}
@Override
public ItemStack getGemByName(String name) {
return ItemGems.getGemByName(name);
}
@Override
public ItemStack getGemByName(String name, int count) {
return ItemGems.getGemByName(name, count);
}
@Override
public ItemStack getIngotByName(String name) {
return ItemIngots.getIngotByName(name);
}
@Override
public ItemStack getIngotByName(String name, int count) {
return ItemIngots.getIngotByName(name, count);
}
@Override
public ItemStack getNuggetByName(String name) {
return ItemNuggets.getNuggetByName(name);
}
@Override
public ItemStack getNuggetByName(String name, int count) {
return ItemNuggets.getNuggetByName(name, count);
}
@Override
public ItemStack getPartByName(String name) {
return ItemParts.getPartByName(name);
}
@Override
public ItemStack getPartByName(String name, int count) {
return ItemParts.getPartByName(name, count);
}
@Override
public ItemStack getPlateByName(String name) {
return ItemPlates.getPlateByName(name);
}
@Override
public ItemStack getPlateByName(String name, int count) {
return ItemPlates.getPlateByName(name, count);
}
@Override
public ItemStack getPurifiedCrushedOreByName(String name) {
return ItemPurifiedCrushedOre.getPurifiedCrushedOreByName(name);
}
@Override
public ItemStack getPurifiedCrushedOreByName(String name, int count) {
return ItemPurifiedCrushedOre.getPurifiedCrushedOreByName(name, count);
}
@Override
public ItemStack getUpgradeByName(String name) {
return ItemUpgrades.getUpgradeByName(name);
}
@Override
public ItemStack getUpgradeByName(String name, int count) {
return ItemUpgrades.getUpgradeByName(name, count);
}
@Override
public ItemStack getOreByName(String name) {
return BlockOre.getOreByName(name);
}
@Override
public ItemStack getOreByName(String name, int count) {
return BlockOre.getOreByName(name, count);
}
@Override
public ItemStack getStorageBlockByName(String name) {
return BlockStorage.getStorageBlockByName(name);
}
@Override
public ItemStack getStorageBlockByName(String name, int count) {
return BlockStorage.getStorageBlockByName(name, count);
}
}

View file

@ -4,13 +4,12 @@ import java.security.InvalidParameterException;
import java.util.List;
import me.modmuss50.jsonDestroyer.api.ITexturedItem;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.utils.RecipeCrafter;
import techreborn.api.upgrade.IMachineUpgrade;
import techreborn.client.TechRebornCreativeTabMisc;
import techreborn.init.ModItems;

View file

@ -1,43 +0,0 @@
package techreborn.lib;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.util.text.translation.I18n;
import net.minecraftforge.common.util.EnumHelper;
public class Reference {
public static ToolMaterial BRONZE = EnumHelper.addToolMaterial("BRONZE", 2, 375, 6.0F, 2.25F, 8);
public static ArmorMaterial BRONZE_ARMOUR = EnumHelper.addArmorMaterial("BRONZE", ModInfo.MOD_ID + ":bronze", 17,
new int[] { 3, 6, 5, 2 }, 8, null/* TODO: SoundEvent */);
public static ToolMaterial RUBY = EnumHelper.addToolMaterial("RUBY", 2, 320, 6.2F, 2.7F, 10);
public static ArmorMaterial RUBY_ARMOUR = EnumHelper.addArmorMaterial("RUBY", ModInfo.MOD_ID + ":ruby", 16,
new int[] { 2, 7, 5, 2 }, 10, null/* TODO: SoundEvent */);
public static ToolMaterial SAPPHIRE = EnumHelper.addToolMaterial("SAPPHIRE", 2, 620, 5.0F, 2F, 8);
public static ArmorMaterial SAPPHIRE_ARMOUR = EnumHelper.addArmorMaterial("SAPPHIRE", ModInfo.MOD_ID + ":sapphire",
19, new int[] { 4, 4, 4, 4 }, 8, null/* TODO: SoundEvent */);
public static ToolMaterial PERIDOT = EnumHelper.addToolMaterial("PERIDOT", 2, 400, 7.0F, 2.4F, 16);
public static ArmorMaterial PERIDOT_ARMOUR = EnumHelper.addArmorMaterial("PERIDOT", ModInfo.MOD_ID + ":peridot", 17,
new int[] { 3, 8, 3, 2 }, 16, null/* TODO: SoundEvent */);
public static String alloySmelteRecipe = I18n.translateToLocal("techreborn.recipe.alloysmelter");
public static String assemblingMachineRecipe = I18n.translateToLocal("techreborn.recipe.assemblingmachine");
public static String blastFurnaceRecipe = I18n.translateToLocal("techreborn.recipe.blastfurnace");
public static String centrifugeRecipe = I18n.translateToLocal("techreborn.recipe.centrifuge");
public static String chemicalReactorRecipe = I18n.translateToLocal("techreborn.recipe.chemicalReactor");
public static String industrialGrinderRecipe = I18n.translateToLocal("techreborn.recipe.grinder");
public static String implosionCompressorRecipe = I18n.translateToLocal("techreborn.recipe.implosioncompressor");
public static String industrialElectrolyzerRecipe = I18n
.translateToLocal("techreborn.recipe.industrialelectrolyzer");
public static String industrialSawmillRecipe = I18n.translateToLocal("techreborn.recipe.industrialsawmill");
public static String latheRecipe = I18n.translateToLocal("techreborn.recipe.lathe");
public static String plateCuttingMachineRecipe = I18n.translateToLocal("techreborn.recipe.platecuttingmachine");
public static String vacuumFreezerRecipe = I18n.translateToLocal("tile.techreborn.vacuumfreezer.name");
public static String grinderRecipe = I18n.translateToLocal("tile.techreborn.grinder.name");
public static String extractorRecipe = I18n.translateToLocal("tile.techreborn.extractor.name");
public static String compressorRecipe = I18n.translateToLocal("tile.techreborn.compressor.name");
public static String recyclerRecipe = I18n.translateToLocal("tile.techreborn.recycler.name");
public static String scrapboxRecipe = I18n.translateToLocal("techreborn.recipe.scrapbox");
}

View file

@ -21,7 +21,7 @@ import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.api.recipe.RecipeHandler;
import techreborn.init.ModBlocks;
import techreborn.lib.Reference;
import techreborn.api.Reference;
import ic2.api.tile.IWrenchable;
public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, IInventory

View file

@ -10,10 +10,10 @@ import net.minecraft.util.text.ITextComponent;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.utils.RecipeCrafter;
import techreborn.api.upgrade.UpgradeHandler;
import techreborn.init.ModBlocks;
import techreborn.lib.Reference;
import techreborn.api.Reference;
import ic2.api.tile.IWrenchable;
public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable, IInventory, ISidedInventory

View file

@ -10,9 +10,9 @@ import net.minecraft.util.text.ITextComponent;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.utils.RecipeCrafter;
import techreborn.init.ModBlocks;
import techreborn.lib.Reference;
import techreborn.api.Reference;
import ic2.api.tile.IWrenchable;
public class TileAssemblingMachine extends TilePowerAcceptor implements IWrenchable, IInventory, ISidedInventory

View file

@ -17,11 +17,11 @@ import reborncore.common.misc.Location;
import reborncore.common.multiblock.IMultiblockPart;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.utils.RecipeCrafter;
import techreborn.blocks.BlockMachineCasing;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.lib.Reference;
import techreborn.api.Reference;
import techreborn.multiblocks.MultiBlockCasing;
import ic2.api.tile.IWrenchable;

View file

@ -13,10 +13,10 @@ import reborncore.api.power.IEnergyItemInfo;
import reborncore.common.powerSystem.PoweredItem;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.utils.RecipeCrafter;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.lib.Reference;
import techreborn.api.Reference;
import java.util.List;

View file

@ -10,9 +10,9 @@ import net.minecraft.util.text.ITextComponent;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.utils.RecipeCrafter;
import techreborn.init.ModBlocks;
import techreborn.lib.Reference;
import techreborn.api.Reference;
import ic2.api.tile.IWrenchable;
public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchable, IInventory, ISidedInventory

View file

@ -13,10 +13,10 @@ import reborncore.api.power.EnumPowerTier;
import reborncore.common.misc.Location;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.utils.RecipeCrafter;
import techreborn.blocks.BlockMachineCasing;
import techreborn.init.ModBlocks;
import techreborn.lib.Reference;
import techreborn.api.Reference;
import ic2.api.tile.IWrenchable;
public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenchable, IInventory, ISidedInventory

View file

@ -10,9 +10,9 @@ import net.minecraft.util.text.ITextComponent;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.utils.RecipeCrafter;
import techreborn.init.ModBlocks;
import techreborn.lib.Reference;
import techreborn.api.Reference;
import ic2.api.tile.IWrenchable;
public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWrenchable, IInventory, ISidedInventory

View file

@ -19,11 +19,11 @@ import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory;
import reborncore.common.util.Tank;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.utils.RecipeCrafter;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.init.ModFluids;
import techreborn.lib.Reference;
import techreborn.api.Reference;
import ic2.api.tile.IWrenchable;
public class TileIndustrialGrinder extends TilePowerAcceptor

View file

@ -21,11 +21,11 @@ import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory;
import reborncore.common.util.Tank;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.utils.RecipeCrafter;
import techreborn.blocks.BlockMachineCasing;
import techreborn.init.ModBlocks;
import techreborn.init.ModFluids;
import techreborn.lib.Reference;
import techreborn.api.Reference;
import ic2.api.tile.IWrenchable;
public class TileIndustrialSawmill extends TilePowerAcceptor

View file

@ -11,10 +11,10 @@ import net.minecraft.util.text.ITextComponent;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.utils.RecipeCrafter;
import techreborn.blocks.BlockMachineCasing;
import techreborn.init.ModBlocks;
import techreborn.lib.Reference;
import techreborn.api.Reference;
import ic2.api.tile.IWrenchable;
public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable, IInventory

View file

@ -10,9 +10,9 @@ import net.minecraft.util.text.ITextComponent;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.utils.RecipeCrafter;
import techreborn.init.ModBlocks;
import techreborn.lib.Reference;
import techreborn.api.Reference;
import ic2.api.tile.IWrenchable;
public class TileCompressor extends TilePowerAcceptor implements IWrenchable, IInventory, ISidedInventory

View file

@ -10,9 +10,9 @@ import net.minecraft.util.text.ITextComponent;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.utils.RecipeCrafter;
import techreborn.init.ModBlocks;
import techreborn.lib.Reference;
import techreborn.api.Reference;
import ic2.api.tile.IWrenchable;
public class TileExtractor extends TilePowerAcceptor implements IWrenchable, IInventory, ISidedInventory

View file

@ -11,9 +11,9 @@ import reborncore.api.IListInfoProvider;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.utils.RecipeCrafter;
import techreborn.init.ModBlocks;
import techreborn.lib.Reference;
import techreborn.api.Reference;
import ic2.api.tile.IWrenchable;
import java.util.List;

View file

@ -1,4 +1,4 @@
package techreborn.api.recipe;
package techreborn.utils;
import java.util.ArrayList;
@ -9,6 +9,8 @@ import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.tile.TileMachineBase;
import reborncore.common.util.Inventory;
import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.api.recipe.RecipeHandler;
/**
* Use this in your tile entity to craft things