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);
}
}
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));
}
}
}
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));
}
}
}
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));
}
}
}
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));
}
}
}
Aggregations