Search in sources :

Example 26 with NNList

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

the class BlockPaintedDoor 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 27 with NNList

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

the class BlockPaintedFence 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 28 with NNList

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

the class BlockInfinity method updateTick.

@Override
public void updateTick(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull Random rnd) {
    if (!world.isRemote) {
        if (world.canBlockSeeSky(pos)) {
            // exposed to the sky?
            world.setBlockToAir(pos);
            world.addWeatherEffect(new EntityLightningBolt(world, pos.getX(), pos.getY(), pos.getZ(), true));
            return;
        }
        IBlockState newState = rnd.nextFloat() < .165f ? state.cycleProperty(AGE) : state;
        final Boolean isHarmless = state.getValue(HARMLESS);
        if (newState.getValue(AGE) == 7) {
            // die of old age
            world.setBlockToAir(pos);
            if (!isHarmless) {
                if (rnd.nextFloat() < .165f) {
                    spawnResult(world, pos, rnd);
                }
                if (rnd.nextFloat() < .33f) {
                    spawnResult(world, pos, rnd);
                }
                spawnResult(world, pos, rnd);
                if (rnd.nextFloat() < .05f) {
                    spawnAsEntity(world, pos, new ItemStack(this));
                }
            }
            return;
        } else {
            if (rnd.nextFloat() < .33f) {
                NNList<BlockPos> airs = new NNList<>();
                for (NNIterator<EnumFacing> itr = NNList.FACING.fastIterator(); itr.hasNext(); ) {
                    BlockPos neighbor = pos.offset(itr.next());
                    if (world.isAirBlock(neighbor)) {
                        airs.add(neighbor);
                    } else {
                        IBlockState neighborState = world.getBlockState(neighbor);
                        if (neighborState.getBlock() == this && neighborState.getValue(HARMLESS)) {
                            airs.add(neighbor);
                        }
                    }
                }
                if (airs.size() >= 2) {
                    if (!isHarmless && airs.size() >= 3 && rnd.nextFloat() < .025f) {
                        // split
                        BlockPos targetPos1 = airs.remove(rand.nextInt(airs.size()));
                        BlockPos targetPos2 = airs.remove(rand.nextInt(airs.size()));
                        world.setBlockState(targetPos1, newState);
                        world.scheduleBlockUpdate(targetPos1, this, rand.nextInt(40), 0);
                        world.setBlockState(targetPos2, newState);
                        world.scheduleBlockUpdate(targetPos2, this, rand.nextInt(40), 0);
                        world.setBlockToAir(pos);
                        return;
                    } else if (!isHarmless && rnd.nextFloat() < .025f) {
                        // spawn
                        BlockPos targetPos1 = airs.remove(rand.nextInt(airs.size()));
                        world.setBlockState(targetPos1, state.withProperty(AGE, 0));
                        world.scheduleBlockUpdate(targetPos1, this, rand.nextInt(40), 0);
                        world.setBlockState(pos, newState);
                        world.scheduleBlockUpdate(pos, this, rand.nextInt(40), 0);
                        return;
                    } else if (rnd.nextFloat() < .50f) {
                        // move
                        BlockPos targetPos1 = airs.remove(rand.nextInt(airs.size()));
                        world.setBlockState(targetPos1, newState);
                        world.scheduleBlockUpdate(targetPos1, this, rand.nextInt(40), 0);
                        world.setBlockToAir(pos);
                        return;
                    } else if (!isHarmless) {
                        // spawn harmless
                        BlockPos targetPos1 = airs.remove(rand.nextInt(airs.size()));
                        world.setBlockState(targetPos1, state.withProperty(AGE, 0).withProperty(HARMLESS, true));
                        world.scheduleBlockUpdate(targetPos1, this, rand.nextInt(40), 0);
                    }
                } else if (!isHarmless) {
                    // caged in? no thank you!
                    world.setBlockToAir(pos);
                    world.createExplosion(null, pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5, .1f, true);
                    return;
                }
            }
            if (state != newState) {
                world.setBlockState(pos, newState);
            }
            world.scheduleBlockUpdate(pos, this, rand.nextInt(40), 0);
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) NNList(com.enderio.core.common.util.NNList) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) ItemStack(net.minecraft.item.ItemStack)

Example 29 with NNList

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

the class Attackera method onUpdate.

@Override
public void onUpdate() {
    ItemStack prev = prevWeapon;
    ItemStack cur = getHeldItemMainhand();
    if (!ItemStack.areItemStacksEqual(cur, prev)) {
        if (!prev.isEmpty()) {
            getAttributeMap().removeAttributeModifiers(prev.getAttributeModifiers(EntityEquipmentSlot.MAINHAND));
        }
        if (!cur.isEmpty()) {
            getAttributeMap().applyAttributeModifiers(cur.getAttributeModifiers(EntityEquipmentSlot.MAINHAND));
        }
        prevWeapon = cur.copy();
    }
    if (chargedLocation != null && chargedLocation.chargeItems(new NNList<>(cur))) {
        killerJoe.markDirty();
    }
    ticksSinceLastSwing++;
}
Also used : NNList(com.enderio.core.common.util.NNList) ItemStack(net.minecraft.item.ItemStack)

Example 30 with NNList

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

the class ContainerStirlingGenerator method addGhostslots.

public void addGhostslots(NNList<GhostSlot> ghostSlots) {
    NNList<ItemStack> fuels = new NNList<>();
    ItemHelper.getValidItems().apply(new Callback<ItemStack>() {

        @Override
        public void apply(@Nonnull ItemStack e) {
            if (getTe().isMachineItemValidForSlot(0, e)) {
                fuels.add(e);
                if (e.getItem() == Items.LAVA_BUCKET || e.getItem() == Items.COAL) {
                    // put an emphasis on the common fuels, especially the lava bucket---many players don't know about that one
                    for (int i = 0; i < 30; i++) {
                        fuels.add(e);
                    }
                }
            }
        }
    });
    ghostSlots.add(new GhostBackgroundItemSlot(fuels, getSlotFromInventory(0)));
}
Also used : GhostBackgroundItemSlot(com.enderio.core.client.gui.widget.GhostBackgroundItemSlot) 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