Search in sources :

Example 1 with CraftingOperation

use of io.github.thebusybiscuit.slimefun4.implementation.operations.CraftingOperation in project GlobalWarming by poma123.

the class PollutionListener method onMachineOperationComplete.

@EventHandler
public void onMachineOperationComplete(AsyncMachineOperationFinishEvent e) {
    World world = e.getPosition().getWorld();
    if (!GlobalWarmingPlugin.getRegistry().isWorldEnabled(world.getName())) {
        return;
    }
    if (e.getProcessor() == null) {
        return;
    }
    String id = null;
    ItemStack[] inputs = new ItemStack[] {};
    if ((e.getProcessor().getOwner() instanceof Reactor || e.getProcessor().getOwner() instanceof AGenerator) && e.getOperation() instanceof FuelOperation) {
        id = e.getProcessor().getOwner().getId();
        FuelOperation operation = (FuelOperation) e.getOperation();
        inputs = new ItemStack[] { operation.getIngredient() };
    } else if (e.getProcessor().getOwner() instanceof AContainer && e.getOperation() instanceof CraftingOperation) {
        id = e.getProcessor().getOwner().getId();
        CraftingOperation operation = (CraftingOperation) e.getOperation();
        inputs = operation.getIngredients();
    }
    if (id != null) {
        risePollutionTry(world, id, inputs);
        descendPollutionTry(world, id);
    }
}
Also used : AGenerator(me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator) CraftingOperation(io.github.thebusybiscuit.slimefun4.implementation.operations.CraftingOperation) FuelOperation(io.github.thebusybiscuit.slimefun4.implementation.operations.FuelOperation) AContainer(me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer) World(org.bukkit.World) ItemStack(org.bukkit.inventory.ItemStack) Reactor(io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor) EventHandler(org.bukkit.event.EventHandler)

Example 2 with CraftingOperation

use of io.github.thebusybiscuit.slimefun4.implementation.operations.CraftingOperation in project FN-FAL-s-Amplifications by FN-FAL113.

the class CMachine method tick.

public void tick(Block b) {
    BlockMenu inv = BlockStorage.getInventory(b);
    CraftingOperation currentOperation = processor.getOperation(b);
    if (currentOperation != null) {
        if (takeCharge(b.getLocation())) {
            if (!currentOperation.isFinished()) {
                processor.updateProgressBar(inv, 22, currentOperation);
                currentOperation.addProgress(1);
            } else {
                inv.replaceExistingItem(22, new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " "));
                for (ItemStack output : currentOperation.getResults()) {
                    inv.pushItem(output.clone(), getOutputSlots());
                }
                processor.endOperation(b);
            }
        }
    } else {
        MachineRecipe next = findNextRecipe(inv);
        if (next != null) {
            processor.startOperation(b, new CraftingOperation(next));
        }
    }
}
Also used : CraftingOperation(io.github.thebusybiscuit.slimefun4.implementation.operations.CraftingOperation) BlockMenu(me.mrCookieSlime.Slimefun.api.inventory.BlockMenu) MachineRecipe(me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe) CustomItemStack(io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack) CustomItemStack(io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack) ItemStack(org.bukkit.inventory.ItemStack) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack)

Example 3 with CraftingOperation

use of io.github.thebusybiscuit.slimefun4.implementation.operations.CraftingOperation in project Slimefun4 by Slimefun.

the class AContainer method tick.

protected void tick(Block b) {
    BlockMenu inv = BlockStorage.getInventory(b);
    CraftingOperation currentOperation = processor.getOperation(b);
    if (currentOperation != null) {
        if (takeCharge(b.getLocation())) {
            if (!currentOperation.isFinished()) {
                processor.updateProgressBar(inv, 22, currentOperation);
                currentOperation.addProgress(1);
            } else {
                inv.replaceExistingItem(22, new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " "));
                for (ItemStack output : currentOperation.getResults()) {
                    inv.pushItem(output.clone(), getOutputSlots());
                }
                processor.endOperation(b);
            }
        }
    } else {
        MachineRecipe next = findNextRecipe(inv);
        if (next != null) {
            processor.startOperation(b, new CraftingOperation(next));
        }
    }
}
Also used : CraftingOperation(io.github.thebusybiscuit.slimefun4.implementation.operations.CraftingOperation) BlockMenu(me.mrCookieSlime.Slimefun.api.inventory.BlockMenu) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) ItemStack(org.bukkit.inventory.ItemStack) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack)

Example 4 with CraftingOperation

use of io.github.thebusybiscuit.slimefun4.implementation.operations.CraftingOperation in project DynaTech by ProfElements.

the class AbstractMachine method tick.

protected void tick(Block b) {
    BlockMenu inv = BlockStorage.getInventory(b);
    CraftingOperation craftingOp = processor.getOperation(b);
    if (craftingOp != null) {
        if (!craftingOp.isFinished()) {
            processor.updateProgressBar(inv, getProgressSlot(), craftingOp);
            craftingOp.addProgress(1);
        } else {
            inv.replaceExistingItem(getProgressSlot(), new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " "));
            for (ItemStack output : craftingOp.getResults()) {
                inv.pushItem(output.clone(), getOutputSlots());
            }
            processor.endOperation(b);
        }
    } else {
        MachineRecipe recipe = findRecipe(inv);
        if (recipe != null) {
            processor.startOperation(b, new CraftingOperation(recipe));
        }
    }
}
Also used : CraftingOperation(io.github.thebusybiscuit.slimefun4.implementation.operations.CraftingOperation) BlockMenu(me.mrCookieSlime.Slimefun.api.inventory.BlockMenu) MachineRecipe(me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe) CustomItemStack(io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack) CustomItemStack(io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack) ItemStack(org.bukkit.inventory.ItemStack) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack)

Example 5 with CraftingOperation

use of io.github.thebusybiscuit.slimefun4.implementation.operations.CraftingOperation in project FN-FAL-s-Amplifications by FN-FAL113.

the class ElectricMachineDowngrader method tick.

@Override
public void tick(Block b) {
    BlockMenu inv = BlockStorage.getInventory(b);
    CraftingOperation currentOperation = processor.getOperation(b);
    if (currentOperation != null) {
        if (takeCharge(b.getLocation())) {
            if (!currentOperation.isFinished()) {
                processor.updateProgressBar(inv, 22, currentOperation);
                currentOperation.addProgress(1);
            } else {
                inv.replaceExistingItem(22, new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " "));
                for (ItemStack output : currentOperation.getResults()) {
                    if (ThreadLocalRandom.current().nextInt(100) < 25 && inv.hasViewer()) {
                        inv.pushItem(output.clone(), getOutputSlots());
                        inv.pushItem(new CustomItemStack(FNAmpItems.FN_METAL_SCRAPS.clone(), 1), getOutputSlots());
                    } else {
                        inv.pushItem(output.clone(), getOutputSlots());
                    }
                }
                processor.endOperation(b);
            }
        }
    } else {
        MachineRecipe next = findNextRecipe(inv);
        if (next != null) {
            getMachineProcessor().startOperation(b, new CraftingOperation(next));
        }
    }
}
Also used : CraftingOperation(io.github.thebusybiscuit.slimefun4.implementation.operations.CraftingOperation) BlockMenu(me.mrCookieSlime.Slimefun.api.inventory.BlockMenu) MachineRecipe(me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe) CustomItemStack(io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack) CustomItemStack(io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack) ItemStack(org.bukkit.inventory.ItemStack) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack)

Aggregations

CraftingOperation (io.github.thebusybiscuit.slimefun4.implementation.operations.CraftingOperation)7 BlockMenu (me.mrCookieSlime.Slimefun.api.inventory.BlockMenu)6 ItemStack (org.bukkit.inventory.ItemStack)6 SlimefunItemStack (io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack)5 CustomItemStack (io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack)5 MachineRecipe (me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe)4 CustomItemStack (io.github.bakedlibs.dough.items.CustomItemStack)1 Reactor (io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor)1 FuelOperation (io.github.thebusybiscuit.slimefun4.implementation.operations.FuelOperation)1 AContainer (me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer)1 AGenerator (me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator)1 World (org.bukkit.World)1 EventHandler (org.bukkit.event.EventHandler)1