Search in sources :

Example 1 with ArcFurnaceRecipe

use of blusunrize.immersiveengineering.api.crafting.ArcFurnaceRecipe in project ImmersiveEngineering by BluSunrize.

the class ArcFurnace method addRecipe.

@ZenMethod
public static void addRecipe(IItemStack output, IIngredient input, IItemStack slag, int time, int energyPerTick, @Optional IIngredient[] additives, @Optional String specialRecipeType) {
    Object oInput = CraftTweakerHelper.toObject(input);
    if (oInput == null)
        return;
    Object[] adds = null;
    if (additives != null) {
        adds = new Object[additives.length];
        for (int i = 0; i < additives.length; i++) adds[i] = CraftTweakerHelper.toObject(additives[i]);
    }
    ArcFurnaceRecipe r = new ArcFurnaceRecipe(CraftTweakerHelper.toStack(output), oInput, CraftTweakerHelper.toStack(slag), time, energyPerTick, adds);
    if (specialRecipeType != null)
        r.setSpecialRecipeType(specialRecipeType);
    MineTweakerAPI.apply(new Add(r));
}
Also used : ArcFurnaceRecipe(blusunrize.immersiveengineering.api.crafting.ArcFurnaceRecipe) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 2 with ArcFurnaceRecipe

use of blusunrize.immersiveengineering.api.crafting.ArcFurnaceRecipe in project ImmersiveEngineering by BluSunrize.

the class TileEntityArcFurnace method update.

@Override
public void update() {
    super.update();
    if (!worldObj.isRemote && !isDummy() && !isRSDisabled() && energyStorage.getEnergyStored() > 0) {
        if (this.tickedProcesses > 0)
            for (int i = 23; i < 26; i++) if (this.inventory[i].attemptDamageItem(1, worldObj.rand)) {
                this.inventory[i] = null;
            //						updateClient = true;
            //						update = true;
            }
        if (this.processQueue.size() < this.getProcessQueueMaxLength()) {
            Set<Integer> usedInvSlots = new HashSet<Integer>();
            //			final int[] usedInvSlots = new int[8];
            for (MultiblockProcess<ArcFurnaceRecipe> process : processQueue) if (process instanceof MultiblockProcessInMachine)
                for (int i : ((MultiblockProcessInMachine<ArcFurnaceRecipe>) process).inputSlots) usedInvSlots.add(i);
            //			Integer[] preferredSlots = new Integer[]{0,1,2,3,4,5,6,7};
            //			Arrays.sort(preferredSlots, 0,8, new Comparator<Integer>(){
            //				@Override
            //				public int compare(Integer arg0, Integer arg1)
            //				{
            //					return Integer.compare(usedInvSlots[arg0],usedInvSlots[arg1]);
            //				}});
            ItemStack[] additives = new ItemStack[4];
            for (int i = 0; i < 4; i++) additives[i] = (inventory[12 + i] != null ? inventory[12 + i].copy() : null);
            for (int slot = 0; slot < 12; slot++) if (!usedInvSlots.contains(slot)) {
                ItemStack stack = this.getInventory()[slot];
                //				}
                if (stack != null && stack.stackSize > 0) {
                    ArcFurnaceRecipe recipe = ArcFurnaceRecipe.findRecipe(stack, additives);
                    if (recipe != null) {
                        MultiblockProcessArcFurnace process = new MultiblockProcessArcFurnace(recipe, slot, 12, 13, 14, 15);
                        if (this.addProcessToQueue(process, true)) {
                            this.addProcessToQueue(process, false);
                            usedInvSlots.add(slot);
                        //							update = true;
                        }
                    }
                }
            }
        }
        if (worldObj.getTotalWorldTime() % 8 == 0) {
            BlockPos outputPos = this.getBlockPosForPos(2).offset(facing, -1);
            TileEntity outputTile = this.worldObj.getTileEntity(outputPos);
            if (outputTile != null)
                for (int j = 16; j < 22; j++) if (inventory[j] != null) {
                    ItemStack stack = Utils.copyStackWithAmount(inventory[j], 1);
                    stack = Utils.insertStackIntoInventory(outputTile, stack, facing.getOpposite());
                    if (stack == null)
                        if ((--this.inventory[j].stackSize) <= 0)
                            this.inventory[j] = null;
                }
            outputPos = this.getBlockPosForPos(22).offset(facing);
            outputTile = this.worldObj.getTileEntity(outputPos);
            if (outputTile != null)
                if (inventory[22] != null) {
                    int out = Math.min(inventory[22].stackSize, 16);
                    ItemStack stack = Utils.copyStackWithAmount(inventory[22], out);
                    stack = Utils.insertStackIntoInventory(outputTile, stack, facing);
                    if (stack != null)
                        out -= stack.stackSize;
                    if ((this.inventory[22].stackSize -= out) <= 0)
                        this.inventory[22] = null;
                }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ArcFurnaceRecipe(blusunrize.immersiveengineering.api.crafting.ArcFurnaceRecipe) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) HashSet(java.util.HashSet)

Example 3 with ArcFurnaceRecipe

use of blusunrize.immersiveengineering.api.crafting.ArcFurnaceRecipe in project ImmersiveEngineering by BluSunrize.

the class DenseOresHelper method postInit.

@Override
public void postInit() {
    HashMap map = null;
    Field f_baseOreDictionary = null;
    try {
        Class c_DenseOresRegistry = Class.forName("com.rwtema.denseores.DenseOresRegistry");
        Class c_DenseOre = Class.forName("com.rwtema.denseores.DenseOre");
        f_baseOreDictionary = c_DenseOre.getField("baseOreDictionaryEntry");
        map = (HashMap) c_DenseOresRegistry.getField("ores").get(null);
    } catch (Exception e) {
    }
    if (map != null && f_baseOreDictionary != null) {
        ArrayList<CrusherRecipe> crushRecipes = new ArrayList<CrusherRecipe>();
        ArrayList<ArcFurnaceRecipe> arcRecipes = new ArrayList<ArcFurnaceRecipe>();
        for (Object o : map.values()) {
            try {
                String baseOre = (String) f_baseOreDictionary.get(o);
                String denseOre = "dense" + baseOre;
                boolean c = false;
                for (CrusherRecipe recipe : CrusherRecipe.recipeList) if (recipe.oreInputString != null && recipe.oreInputString.equals(baseOre)) {
                    ItemStack out = Utils.copyStackWithAmount(recipe.output, recipe.output.stackSize * 4);
                    CrusherRecipe r = new CrusherRecipe(out, denseOre, (int) (recipe.getTotalProcessEnergy() / CrusherRecipe.energyModifier) * 2);
                    if (recipe.secondaryOutput != null) {
                        Object[] newSec = new Object[recipe.secondaryOutput.length * 2];
                        for (int i = 0; i < recipe.secondaryOutput.length; i++) {
                            newSec[i * 2] = Utils.copyStackWithAmount(recipe.secondaryOutput[i], recipe.secondaryOutput[i].stackSize * 2);
                            newSec[i * 2 + 1] = recipe.secondaryChance[i] * 2;
                        }
                        r.addToSecondaryOutput(newSec);
                    }
                    crushRecipes.add(r);
                    c = true;
                }
                boolean a = false;
                for (ArcFurnaceRecipe recipe : ArcFurnaceRecipe.recipeList) if (recipe.oreInputString != null && recipe.oreInputString.equals(baseOre)) {
                    ItemStack out = Utils.copyStackWithAmount(recipe.output, recipe.output.stackSize * 4);
                    int time = (int) (recipe.getTotalProcessTime() / ArcFurnaceRecipe.timeModifier);
                    int perTick = (int) (recipe.getTotalProcessEnergy() / recipe.getTotalProcessTime() / ArcFurnaceRecipe.energyModifier);
                    ArcFurnaceRecipe r = new ArcFurnaceRecipe(out, denseOre, recipe.slag, time, perTick);
                    arcRecipes.add(r);
                    a = true;
                }
                IELogger.info("Supporting DenseOre: " + denseOre + "(" + baseOre + "), Crushing:" + (c ? "[X]" : "[ ]") + ", Arc Smelting:" + (a ? "[X]" : "[ ]"));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        CrusherRecipe.recipeList.addAll(crushRecipes);
        ArcFurnaceRecipe.recipeList.addAll(arcRecipes);
    }
}
Also used : HashMap(java.util.HashMap) ArcFurnaceRecipe(blusunrize.immersiveengineering.api.crafting.ArcFurnaceRecipe) ArrayList(java.util.ArrayList) CrusherRecipe(blusunrize.immersiveengineering.api.crafting.CrusherRecipe) Field(java.lang.reflect.Field) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ArcFurnaceRecipe (blusunrize.immersiveengineering.api.crafting.ArcFurnaceRecipe)3 ItemStack (net.minecraft.item.ItemStack)2 CrusherRecipe (blusunrize.immersiveengineering.api.crafting.CrusherRecipe)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1 ZenMethod (stanhebben.zenscript.annotations.ZenMethod)1