Search in sources :

Example 1 with BlastFurnaceRecipe

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

the class BlastFurnace method addRecipe.

@ZenMethod
public static void addRecipe(IItemStack output, IIngredient input, int time, @Optional IItemStack slag) {
    Object oInput = CraftTweakerHelper.toObject(input);
    if (oInput == null)
        return;
    BlastFurnaceRecipe r = new BlastFurnaceRecipe(CraftTweakerHelper.toStack(output), oInput, time, CraftTweakerHelper.toStack(slag));
    CraftTweakerAPI.apply(new Add(r));
}
Also used : BlastFurnaceRecipe(blusunrize.immersiveengineering.api.crafting.BlastFurnaceRecipe) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 2 with BlastFurnaceRecipe

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

the class TileEntityBlastFurnace method update.

@Override
public void update() {
    ApiUtils.checkForNeedlessTicking(this);
    if (!world.isRemote && formed && !isDummy()) {
        boolean a = active;
        if (burnTime > 0) {
            int processSpeed = 1;
            if (process > 0)
                processSpeed = getProcessSpeed();
            burnTime -= processSpeed;
            if (process > 0) {
                if (inventory.get(0).isEmpty()) {
                    process = 0;
                    processMax = 0;
                } else {
                    BlastFurnaceRecipe recipe = getRecipe();
                    if (recipe != null && recipe.time != processMax) {
                        processMax = 0;
                        process = 0;
                        active = false;
                    } else {
                        process -= processSpeed;
                        // Process speed is "used up"
                        processSpeed = 0;
                        if (!active)
                            active = true;
                    }
                }
                markContainingBlockForUpdate(null);
            }
            if (process <= 0) {
                if (processMax > 0) {
                    BlastFurnaceRecipe recipe = getRecipe();
                    if (recipe != null) {
                        Utils.modifyInvStackSize(inventory, 0, -(recipe.input instanceof ItemStack ? ((ItemStack) recipe.input).getCount() : 1));
                        if (!inventory.get(2).isEmpty())
                            inventory.get(2).grow(recipe.output.copy().getCount());
                        else
                            inventory.set(2, recipe.output.copy());
                        if (!recipe.slag.isEmpty()) {
                            if (!inventory.get(3).isEmpty())
                                inventory.get(3).grow(recipe.slag.copy().getCount());
                            else
                                inventory.set(3, recipe.slag.copy());
                        }
                    }
                    processMax = 0;
                    burnTime -= process;
                }
                BlastFurnaceRecipe recipe = getRecipe();
                if (recipe != null) {
                    this.process = recipe.time - processSpeed;
                    this.processMax = recipe.time;
                    this.active = true;
                }
            }
        } else {
            if (active)
                active = false;
        }
        if (burnTime <= 0 && getRecipe() != null) {
            if (BlastFurnaceRecipe.isValidBlastFuel(inventory.get(1))) {
                lastBurnTime = BlastFurnaceRecipe.getBlastFuelTime(inventory.get(1));
                burnTime += lastBurnTime;
                Utils.modifyInvStackSize(inventory, 1, -1);
                markContainingBlockForUpdate(null);
            }
        }
        if (a != active) {
            this.markDirty();
            TileEntity tileEntity;
            for (int yy = -1; yy <= 1; yy++) for (int xx = -1; xx <= 1; xx++) for (int zz = -1; zz <= 1; zz++) {
                tileEntity = Utils.getExistingTileEntity(world, getPos().add(xx, yy, zz));
                if (tileEntity != null)
                    tileEntity.markDirty();
                markBlockForUpdate(getPos().add(xx, yy, zz), null);
                world.addBlockEvent(getPos().add(xx, yy, zz), IEContent.blockStoneDevice, 1, active ? 1 : 0);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlastFurnaceRecipe(blusunrize.immersiveengineering.api.crafting.BlastFurnaceRecipe) ItemStack(net.minecraft.item.ItemStack)

Aggregations

BlastFurnaceRecipe (blusunrize.immersiveengineering.api.crafting.BlastFurnaceRecipe)2 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 ZenMethod (stanhebben.zenscript.annotations.ZenMethod)1