use of me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer in project Slimefun4 by Slimefun.
the class PostSetup method loadSmelteryRecipes.
private static void loadSmelteryRecipes() {
Smeltery smeltery = (Smeltery) SlimefunItems.SMELTERY.getItem();
if (smeltery != null && !smeltery.isDisabled()) {
MakeshiftSmeltery makeshiftSmeltery = ((MakeshiftSmeltery) SlimefunItems.MAKESHIFT_SMELTERY.getItem());
ItemStack[] input = null;
for (ItemStack[] output : smeltery.getRecipes()) {
if (input == null) {
input = output;
} else {
if (input[0] != null && output[0] != null) {
addSmelteryRecipe(input, output, makeshiftSmeltery);
}
input = null;
}
}
for (SlimefunItem item : Slimefun.getRegistry().getEnabledSlimefunItems()) {
if (item instanceof AContainer) {
AContainer machine = (AContainer) item;
if (machine.getMachineIdentifier().equals("ELECTRIC_SMELTERY")) {
List<MachineRecipe> recipes = machine.getMachineRecipes();
Collections.sort(recipes, Comparator.comparingInt(recipe -> recipe == null ? 0 : -recipe.getInput().length));
}
}
}
}
}
use of me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer 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 me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer in project SupplementalServiceableness by NCBPFluffyBear.
the class Voltmeter method consumerStatistics.
private void consumerStatistics(Player player, EnergyNet energyNet) {
Map<Location, EnergyNetComponent> consumers = null;
try {
Field consumersField = energyNet.getClass().getDeclaredField("consumers");
consumersField.setAccessible(true);
consumers = (Map<Location, EnergyNetComponent>) consumersField.get(energyNet);
} catch (NoSuchFieldException | IllegalAccessException ex) {
Bukkit.getLogger().log(Level.SEVERE, "An error has occurred while trying to access private fields: " + System.lineSeparator() + ex);
}
int numberOfConsumers = consumers.size();
int joulesPerSecConsumed = 0;
int minConsumption = Integer.MAX_VALUE;
int maxConsumption = 0;
EnergyNetComponent smallestConsumer = null;
EnergyNetComponent largestConsumer = null;
for (Location loc : consumers.keySet()) {
if (consumers.get(loc) instanceof AContainer) {
AContainer consumer = (AContainer) consumers.get(loc);
int consumption = consumer.getEnergyConsumption();
joulesPerSecConsumed += consumption;
if (consumption < minConsumption) {
minConsumption = consumption;
smallestConsumer = consumer;
}
if (consumption > maxConsumption) {
maxConsumption = consumption;
largestConsumer = consumer;
}
}
}
Utils.sendChatMsg(player, "&7========== &5Consumers &7==========");
Utils.sendChatMsg(player, "");
Utils.sendChatMsg(player, "&5Number of consumers: &7" + numberOfConsumers);
Utils.sendChatMsg(player, "&5Joules consumed: &7" + joulesPerSecConsumed + " J/s");
Utils.sendChatMsg(player, "&5Smallest consumer: &7" + (Objects.isNull(smallestConsumer) ? "None" : pretifyId(smallestConsumer.getId())) + " &5with &7" + (Objects.isNull(smallestConsumer) ? "0" : minConsumption) + " J/s");
Utils.sendChatMsg(player, "&5Largest consumer: &7" + (Objects.isNull(largestConsumer) ? "None" : pretifyId(largestConsumer.getId())) + " &5with &7" + maxConsumption + " J/s");
Utils.sendChatMsg(player, "");
Utils.sendChatMsg(player, "&7===============================");
}
Aggregations