Search in sources :

Example 31 with NNList

use of com.enderio.core.common.util.NNList in project EnderIO by SleepyTrousers.

the class DarkSteelRecipeManager method getRecipes.

public static NNList<ItemStack> getRecipes(@Nonnull Set<UpgradePath> list, @Nonnull NNList<ItemStack> input) {
    NNList<ItemStack> output = new NNList<ItemStack>();
    NNIterator<ItemStack> iterator = input.iterator();
    while (iterator.hasNext()) {
        ItemStack inputStack = iterator.next();
        if (inputStack.getItem() instanceof IDarkSteelItem) {
            for (IDarkSteelUpgrade upgrade : UpgradeRegistry.getUpgrades()) {
                if (upgrade.canAddToItem(inputStack, (IDarkSteelItem) inputStack.getItem())) {
                    ItemStack outputStack = inputStack.copy();
                    upgrade.addToItem(outputStack, (IDarkSteelItem) outputStack.getItem());
                    final UpgradePath path = new UpgradePath(inputStack, upgrade.getUpgradeItem(), outputStack);
                    if (!list.contains(path)) {
                        list.add(path);
                        output.add(outputStack);
                    }
                }
            }
        }
    }
    return output;
}
Also used : NNList(com.enderio.core.common.util.NNList) ItemStack(net.minecraft.item.ItemStack) IDarkSteelUpgrade(crazypants.enderio.api.upgrades.IDarkSteelUpgrade) IDarkSteelItem(crazypants.enderio.api.upgrades.IDarkSteelItem)

Example 32 with NNList

use of com.enderio.core.common.util.NNList in project EnderIO by SleepyTrousers.

the class StirlingRecipeCategory method register.

// -------------------------------------
public static void register(@Nonnull IModRegistry registry, @Nonnull IGuiHelper guiHelper) {
    registry.addRecipeCategories(new StirlingRecipeCategory(guiHelper));
    registry.addRecipeCategoryCraftingItem(new ItemStack(MachineObject.block_stirling_generator.getBlockNN(), 1, 0), StirlingRecipeCategory.UID);
    registry.addRecipeCategoryCraftingItem(new ItemStack(MachineObject.block_simple_stirling_generator.getBlockNN(), 1, 0), StirlingRecipeCategory.UID);
    registry.addRecipeClickArea(GuiStirlingGenerator.class, 155, 42, 16, 16, StirlingRecipeCategory.UID);
    registry.getRecipeTransferRegistry().addRecipeTransferHandler(ContainerStirlingGenerator.Normal.class, StirlingRecipeCategory.UID, 0, 1, 2, 4 * 9);
    registry.getRecipeTransferRegistry().addRecipeTransferHandler(ContainerStirlingGenerator.Simple.class, StirlingRecipeCategory.UID, 0, 1, 1, 4 * 9);
    long start = System.nanoTime();
    // Put valid fuel to "buckets" based on their burn time (energy production)
    NNMap<Integer, NNList<ItemStack>> recipeInputs = new NNMap.Brutal<>();
    List<ItemStack> validItems = registry.getIngredientRegistry().getIngredients(ItemStack.class);
    int fuelCount = 0;
    for (ItemStack stack : validItems) {
        int burntime = stack == null ? -1 : TileStirlingGenerator.getBurnTimeGeneric(stack);
        if (burntime <= 0)
            continue;
        ++fuelCount;
        if (recipeInputs.containsKey(burntime)) {
            recipeInputs.get(burntime).add(stack);
        } else {
            NNList<ItemStack> list = new NNList<>();
            list.add(stack);
            recipeInputs.put(burntime, list);
        }
    }
    List<StirlingRecipeWrapper> recipeList = new ArrayList<StirlingRecipeWrapper>();
    // Order recipes from best to worst
    TreeSet<Integer> recipeOrder = new TreeSet<Integer>(recipeInputs.keySet());
    Iterator<Integer> it = recipeOrder.descendingIterator();
    while (it.hasNext()) recipeList.add(new StirlingRecipeWrapper(recipeInputs.get(it.next()), guiHelper));
    registry.addRecipes(recipeList, UID);
    long end = System.nanoTime();
    Log.info(String.format("StirlingRecipeCategory: Added %d stirling generator recipes for %d solid fuel to JEI in %.3f seconds.", recipeList.size(), fuelCount, (end - start) / 1000000000d));
}
Also used : ArrayList(java.util.ArrayList) TreeSet(java.util.TreeSet) NNList(com.enderio.core.common.util.NNList) ContainerStirlingGenerator(crazypants.enderio.machines.machine.generator.stirling.ContainerStirlingGenerator) ItemStack(net.minecraft.item.ItemStack)

Example 33 with NNList

use of com.enderio.core.common.util.NNList in project EnderIO by SleepyTrousers.

the class BlockPaintedCarpet method getDrops.

@Override
public void getDrops(@Nonnull NonNullList<ItemStack> drops, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull IBlockState state, int fortune) {
    NNList<ItemStack> drops2 = new NNList<>();
    super.getDrops(drops2, world, pos, state, fortune);
    for (ItemStack drop : drops2) {
        PaintUtil.setSourceBlock(NullHelper.notnullM(drop, "null stack from getDrops()"), getPaintSource(state, world, pos));
    }
    drops.addAll(drops2);
}
Also used : NNList(com.enderio.core.common.util.NNList) ItemStack(net.minecraft.item.ItemStack)

Example 34 with NNList

use of com.enderio.core.common.util.NNList in project EnderIO by SleepyTrousers.

the class BlockPaintedFenceGate method getDrops.

@Override
public void getDrops(@Nonnull NonNullList<ItemStack> drops, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull IBlockState state, int fortune) {
    NNList<ItemStack> drops2 = new NNList<>();
    super.getDrops(drops2, world, pos, state, fortune);
    for (ItemStack drop : drops2) {
        PaintUtil.setSourceBlock(NullHelper.notnullM(drop, "null stack from getDrops()"), getPaintSource(state, world, pos));
    }
    drops.addAll(drops2);
}
Also used : NNList(com.enderio.core.common.util.NNList) ItemStack(net.minecraft.item.ItemStack)

Example 35 with NNList

use of com.enderio.core.common.util.NNList in project EnderIO by SleepyTrousers.

the class BlockPaintedStairs method getDrops.

@Override
public void getDrops(@Nonnull NonNullList<ItemStack> drops, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull IBlockState state, int fortune) {
    NNList<ItemStack> drops2 = new NNList<>();
    super.getDrops(drops2, world, pos, state, fortune);
    for (ItemStack drop : drops2) {
        PaintUtil.setSourceBlock(NullHelper.notnullM(drop, "null stack from getDrops()"), getPaintSource(state, world, pos));
    }
    drops.addAll(drops2);
}
Also used : NNList(com.enderio.core.common.util.NNList) ItemStack(net.minecraft.item.ItemStack)

Aggregations

NNList (com.enderio.core.common.util.NNList)53 ItemStack (net.minecraft.item.ItemStack)37 Nonnull (javax.annotation.Nonnull)12 BlockPos (net.minecraft.util.math.BlockPos)8 EntityItem (net.minecraft.entity.item.EntityItem)7 MachineRecipeInput (crazypants.enderio.base.recipe.MachineRecipeInput)5 Block (net.minecraft.block.Block)5 IBlockState (net.minecraft.block.state.IBlockState)5 IHarvestResult (crazypants.enderio.api.farm.IHarvestResult)4 ArrayList (java.util.ArrayList)4 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)4 GhostBackgroundItemSlot (com.enderio.core.client.gui.widget.GhostBackgroundItemSlot)3 Recipe (crazypants.enderio.base.recipe.Recipe)3 RecipeOutput (crazypants.enderio.base.recipe.RecipeOutput)3 ThingsRecipeInput (crazypants.enderio.base.recipe.ThingsRecipeInput)3 World (net.minecraft.world.World)3 Triple (org.apache.commons.lang3.tuple.Triple)3 IConduitBundle (crazypants.enderio.base.conduit.IConduitBundle)2 RaytraceResult (crazypants.enderio.base.conduit.RaytraceResult)2 IMachineRecipe (crazypants.enderio.base.recipe.IMachineRecipe)2