Search in sources :

Example 1 with NNList

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

the class SmartModelAttacher method registerColoredBlocksAndItems.

@SideOnly(Side.CLIENT)
public static void registerColoredBlocksAndItems() {
    NNList<Block> blocklist = new NNList<Block>();
    NNList<Item> itemlist = new NNList<Item>();
    for (RegistrationHolder<?, ?> holder : blocks) {
        Block block = holder.block;
        Item item = Item.getItemFromBlock(block);
        if (block instanceof IPaintable || block instanceof ITintedBlock || block instanceof ITintedItem || item instanceof ITintedItem) {
            blocklist.add(block);
            if (item != Items.AIR) {
                itemlist.add(item);
            }
        } else {
            if (block instanceof IBlockColor) {
                Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler((IBlockColor) block, block);
            }
            if (item instanceof IItemColor) {
                Minecraft.getMinecraft().getItemColors().registerItemColorHandler((IItemColor) item, item);
            }
        }
    }
    PaintTintHandler handler = new PaintTintHandler();
    Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(handler, blocklist.toArray(new Block[0]));
    Minecraft.getMinecraft().getItemColors().registerItemColorHandler(handler, itemlist.toArray(new Item[0]));
}
Also used : IItemColor(net.minecraft.client.renderer.color.IItemColor) Item(net.minecraft.item.Item) ITintedItem(crazypants.enderio.base.render.ITintedItem) IBlockColor(net.minecraft.client.renderer.color.IBlockColor) ITintedItem(crazypants.enderio.base.render.ITintedItem) IPaintable(crazypants.enderio.base.paint.IPaintable) NNList(com.enderio.core.common.util.NNList) ITintedBlock(crazypants.enderio.base.render.ITintedBlock) Block(net.minecraft.block.Block) ITintedBlock(crazypants.enderio.base.render.ITintedBlock) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with NNList

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

the class PoweredTask method readFromNBT.

@Nullable
public static IPoweredTask readFromNBT(@Nonnull NBTTagCompound nbtRoot) {
    IMachineRecipe recipe;
    float usedEnergy = nbtRoot.getFloat(KEY_USED_ENERGY);
    long seed = nbtRoot.getLong(KEY_SEED);
    float outputMultiplier = nbtRoot.getFloat(KEY_CHANCE_OUTPUT);
    float chanceMultiplier = nbtRoot.getFloat(KEY_CHANCE_MULTI);
    NBTTagList inputItems = (NBTTagList) nbtRoot.getTag(KEY_INPUT_STACKS);
    NNList<MachineRecipeInput> ins = new NNList<MachineRecipeInput>();
    for (int i = 0; i < inputItems.tagCount(); i++) {
        NBTTagCompound stackTag = inputItems.getCompoundTagAt(i);
        MachineRecipeInput mi = MachineRecipeInput.readFromNBT(stackTag);
        ins.add(mi);
    }
    String uid = nbtRoot.getString(KEY_RECIPE);
    recipe = MachineRecipeRegistry.instance.getRecipeForUid(uid);
    if (recipe != null) {
        return new PoweredTask(recipe, usedEnergy, seed, outputMultiplier, chanceMultiplier, ins);
    }
    return null;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NNList(com.enderio.core.common.util.NNList) IPoweredTask(crazypants.enderio.base.machine.interfaces.IPoweredTask) MachineRecipeInput(crazypants.enderio.base.recipe.MachineRecipeInput) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IMachineRecipe(crazypants.enderio.base.recipe.IMachineRecipe) Nullable(javax.annotation.Nullable)

Example 3 with NNList

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

the class ExternalConnectionContainer method createGhostSlots.

public void createGhostSlots(@Nonnull List<GhostSlot> ghostSlots) {
    if (itemConduit != null) {
        ghostSlots.add(new GhostBackgroundItemSlot(ModObject.itemBasicItemFilter.getItemNN(), slotOutputFilter));
        ghostSlots.add(new GhostBackgroundItemSlot(ModObject.itemBasicItemFilter.getItemNN(), slotInputFilter));
        NNList<ItemStack> ghostSlotIcons = new NNList<>(new ItemStack(ConduitObject.item_extract_speed_upgrade.getItemNN()), new ItemStack(ConduitObject.item_extract_speed_downgrade.getItemNN()));
        ghostSlots.add(new GhostBackgroundItemSlot(ghostSlotIcons, slotFunctionUpgrade));
    }
}
Also used : GhostBackgroundItemSlot(com.enderio.core.client.gui.widget.GhostBackgroundItemSlot) NNList(com.enderio.core.common.util.NNList) ItemStack(net.minecraft.item.ItemStack)

Example 4 with NNList

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

the class ItemDarkSteelAxe method onBlockStartBreak.

@Override
public boolean onBlockStartBreak(@Nonnull ItemStack itemstack, @Nonnull BlockPos pos, @Nonnull EntityPlayer player) {
    if (!player.world.isRemote && !player.isSneaking() && EnergyUpgradeManager.itemHasAnyPowerUpgrade(itemstack)) {
        IBlockState bs = player.world.getBlockState(pos);
        Block block = bs.getBlock();
        if (FarmersRegistry.isLog(block)) {
            int powerStored = EnergyUpgradeManager.getEnergyStored(itemstack);
            HarvestResult res = new HarvestResult();
            final IHarvestingTarget target = new AxeHarvestingTarget(bs, pos);
            TreeHarvester.harvest(player.world, pos, res, target);
            NNList<BlockPos> sortedTargets = new NNList<BlockPos>(res.getHarvestedBlocks());
            harvestComparator.refPoint = pos;
            Collections.sort(sortedTargets, harvestComparator);
            int maxBlocks = powerStored / Config.darkSteelAxePowerUsePerDamagePointMultiHarvest;
            int numUsedPower = 0;
            for (int i = 0; numUsedPower < maxBlocks && i < sortedTargets.size(); i++) {
                if (doMultiHarvest(player, player.world, sortedTargets.get(i), block)) {
                    numUsedPower++;
                }
            }
            return numUsedPower != 0;
        }
    }
    return false;
}
Also used : HarvestResult(crazypants.enderio.base.farming.farmers.HarvestResult) IBlockState(net.minecraft.block.state.IBlockState) AxeHarvestingTarget(crazypants.enderio.base.farming.harvesters.AxeHarvestingTarget) IHarvestingTarget(crazypants.enderio.base.farming.harvesters.IHarvestingTarget) NNList(com.enderio.core.common.util.NNList) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos)

Example 5 with NNList

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

the class InfinityRecipeCategory method setRecipe.

@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull InfinityRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) {
    IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
    itemStacks.init(0, false, 85, 30);
    itemStacks.set(ingredients);
    this.recipeLayout = recipeLayout;
    bsr = new BlockSceneRenderer(new NNList<>(Pair.of(new BlockPos(0, 0, 0), Blocks.BEDROCK.getDefaultState()), Pair.of(new BlockPos(0, 1, 0), Blocks.FIRE.getDefaultState())));
}
Also used : BlockSceneRenderer(crazypants.enderio.base.gui.BlockSceneRenderer) NNList(com.enderio.core.common.util.NNList) IGuiItemStackGroup(mezz.jei.api.gui.IGuiItemStackGroup) BlockPos(net.minecraft.util.math.BlockPos)

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