Search in sources :

Example 1 with EntityCreeper

use of net.minecraft.entity.monster.EntityCreeper in project BluePower by Qmunity.

the class BPEventHandler method dropHeads.

private void dropHeads(LivingDeathEvent event) {
    if (event.entityLiving instanceof EntityCreeper) {
        event.entityLiving.entityDropItem(new ItemStack(Items.skull, 1, 4), 0.0F);
    }
    if (event.entityLiving instanceof EntityPlayer) {
        ItemStack drop = new ItemStack(Items.skull, 1, 3);
        drop.stackTagCompound = new NBTTagCompound();
        drop.stackTagCompound.setString("SkullOwner", ((EntityPlayer) event.entityLiving).getDisplayName());
        event.entityLiving.entityDropItem(drop, 0.0F);
    }
    if (event.entityLiving instanceof EntitySkeleton) {
        EntitySkeleton sk = (EntitySkeleton) event.entityLiving;
        if (sk.getSkeletonType() == 0) {
            event.entityLiving.entityDropItem(new ItemStack(Items.skull, 1, 0), 0.0F);
        } else {
            event.entityLiving.entityDropItem(new ItemStack(Items.skull, 1, 1), 0.0F);
        }
    }
    if (event.entityLiving instanceof EntityZombie) {
        event.entityLiving.entityDropItem(new ItemStack(Items.skull, 1, 2), 0.0F);
    }
}
Also used : EntityCreeper(net.minecraft.entity.monster.EntityCreeper) EntityZombie(net.minecraft.entity.monster.EntityZombie) EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 2 with EntityCreeper

use of net.minecraft.entity.monster.EntityCreeper in project ICBM-Classic by BuiltBrokenModding.

the class BlastEMP method doExplode.

@Override
public void doExplode() {
    if (!world().isRemote) {
        if (this.effectBlocks) {
            for (int x = (int) -this.getRadius(); x < (int) this.getRadius(); x++) {
                for (int y = (int) -this.getRadius(); y < (int) this.getRadius(); y++) {
                    for (int z = (int) -this.getRadius(); z < (int) this.getRadius(); z++) {
                        double dist = MathHelper.sqrt_double((x * x + y * y + z * z));
                        Pos searchPosition = new Pos(x, y, z).add(position);
                        if (dist > this.getRadius()) {
                            continue;
                        }
                        if (Math.round(position.x() + y) == position.yi()) {
                            world().spawnParticle("largesmoke", searchPosition.x(), searchPosition.y(), searchPosition.z(), 0, 0, 0);
                        }
                        Block block = searchPosition.getBlock(world());
                        TileEntity tileEntity = searchPosition.getTileEntity(world());
                        //TODO more EMP effect to UniversalEnergySystem to better support cross mod support
                        if (block != null) {
                            //}
                            if (block instanceof IEMPBlock) {
                                ((IEMPBlock) block).onEMP(world(), searchPosition.xi(), searchPosition.yi(), searchPosition.zi(), this);
                            }
                        }
                        if (tileEntity != null) {
                            //if (tileEntity instanceof IFortronStorage)
                            //{
                            //    ((IFortronStorage) tileEntity).provideFortron((int) world().rand.nextFloat() * ((IFortronStorage) tileEntity).getFortronCapacity(), true);
                            //}
                            UniversalEnergySystem.clearEnergy(tileEntity, true);
                        }
                    }
                }
            }
        }
        if (this.effectEntities) {
            // Drop all missiles
            List<Entity> entitiesNearby = RadarRegistry.getAllLivingObjectsWithin(world(), new Cube(position.sub(getRadius()), position.add(getRadius())), null);
            for (Entity entity : entitiesNearby) {
                if (entity instanceof IMissile && !entity.isEntityEqual(this.controller)) {
                    if (((IMissile) entity).getTicksInAir() > -1) {
                        ((IMissile) entity).dropMissileAsItem();
                    }
                }
            }
            int maxFx = 10;
            AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(position.x() - this.getRadius(), position.y() - this.getRadius(), position.z() - this.getRadius(), position.x() + this.getRadius(), position.y() + this.getRadius(), position.z() + this.getRadius());
            List<Entity> entities = world().getEntitiesWithinAABB(Entity.class, bounds);
            for (Entity entity : entities) {
                if (entity instanceof EntityLivingBase) {
                    if (this.world().isRemote && maxFx > 0) {
                        ICBMClassic.proxy.spawnShock(this.world(), this.position, new Pos(entity), 20);
                        maxFx--;
                    }
                    if (entity instanceof EntityCreeper) {
                        if (!this.world().isRemote) {
                            try {
                                ((EntityCreeper) entity).getDataWatcher().updateObject(17, (byte) 1);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                    if (entity instanceof EntityPlayer) {
                        IInventory inventory = ((EntityPlayer) entity).inventory;
                        for (int i = 0; i < inventory.getSizeInventory(); i++) {
                            ItemStack itemStack = inventory.getStackInSlot(i);
                            if (itemStack != null) {
                                if (itemStack.getItem() instanceof IEMPItem) {
                                    ((IEMPItem) itemStack.getItem()).onEMP(itemStack, entity, this);
                                }
                                UniversalEnergySystem.clearEnergy(itemStack, true);
                            }
                        }
                    }
                } else if (entity instanceof EntityExplosive) {
                    entity.setDead();
                }
            }
        }
        VEProviderShockWave.spawnEffect(world(), position.x(), position.y(), position.z(), 0, 0, 0, 0, 0, 255, 1, 3);
        VEProviderShockWave.spawnEffect(world(), position.x(), position.y(), position.z(), 0, 0, 0, 0, 0, 255, 3, 3);
        VEProviderShockWave.spawnEffect(world(), position.x(), position.y(), position.z(), 0, 0, 0, 0, 0, 255, 5, 3);
        this.world().playSoundEffect(position.x(), position.y(), position.z(), ICBMClassic.PREFIX + "emp", 4.0F, (1.0F + (world().rand.nextFloat() - world().rand.nextFloat()) * 0.2F) * 0.7F);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) IInventory(net.minecraft.inventory.IInventory) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) IEMPItem(resonant.api.explosion.IEMPItem) IEMPBlock(resonant.api.explosion.IEMPBlock) TileEntity(net.minecraft.tileentity.TileEntity) IMissile(resonant.api.explosion.IMissile) EntityCreeper(net.minecraft.entity.monster.EntityCreeper) Pos(com.builtbroken.mc.imp.transform.vector.Pos) Cube(com.builtbroken.mc.imp.transform.region.Cube) EntityLivingBase(net.minecraft.entity.EntityLivingBase) IEMPBlock(resonant.api.explosion.IEMPBlock) Block(net.minecraft.block.Block) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityExplosive(icbm.classic.content.entity.EntityExplosive) ItemStack(net.minecraft.item.ItemStack)

Example 3 with EntityCreeper

use of net.minecraft.entity.monster.EntityCreeper in project BetterWithAddons by DaedalusGame.

the class TerratorialHandler method spawnLiving.

@SubscribeEvent
public void spawnLiving(LivingSpawnEvent.CheckSpawn spawnEvent) {
    World world = spawnEvent.getWorld();
    EntityLivingBase entity = spawnEvent.getEntityLiving();
    Chunk chunk = world.getChunkFromBlockCoords(new BlockPos(spawnEvent.getX(), spawnEvent.getY(), spawnEvent.getZ()));
    if (!chunk.isLoaded())
        return;
    if (entity instanceof EntityZombie || entity instanceof EntitySkeleton || entity instanceof EntityCreeper)
        spawnEvent.setResult(Event.Result.DENY);
}
Also used : EntityCreeper(net.minecraft.entity.monster.EntityCreeper) EntityZombie(net.minecraft.entity.monster.EntityZombie) EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) EntityLivingBase(net.minecraft.entity.EntityLivingBase) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) Chunk(net.minecraft.world.chunk.Chunk) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 4 with EntityCreeper

use of net.minecraft.entity.monster.EntityCreeper in project SecurityCraft by Geforce132.

the class BlockIronFence method onEntityCollidedWithBlock.

public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
    //so dropped items don't get destroyed
    if (entity instanceof EntityItem)
        return;
    else //owner check
    if (entity instanceof EntityPlayer) {
        if (((TileEntityOwnable) world.getTileEntity(x, y, z)).getOwner().isOwner((EntityPlayer) entity))
            return;
    } else if (entity instanceof EntityCreeper) {
        EntityCreeper creeper = (EntityCreeper) entity;
        EntityLightningBolt lightning = new EntityLightningBolt(world, x, y, z);
        creeper.onStruckByLightning(lightning);
        creeper.extinguish();
        return;
    }
    //3 hearts per attack
    entity.attackEntityFrom(CustomDamageSources.electricity, 6.0F);
}
Also used : EntityCreeper(net.minecraft.entity.monster.EntityCreeper) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) EntityItem(net.minecraft.entity.item.EntityItem) TileEntityOwnable(net.geforcemods.securitycraft.tileentity.TileEntityOwnable)

Example 5 with EntityCreeper

use of net.minecraft.entity.monster.EntityCreeper in project SecurityCraft by Geforce132.

the class BlockIronFence method onEntityIntersected.

@Override
public void onEntityIntersected(World world, BlockPos pos, Entity entity) {
    //so dropped items don't get destroyed
    if (entity instanceof EntityItem)
        return;
    else //owner check
    if (entity instanceof EntityPlayer) {
        if (((TileEntityOwnable) world.getTileEntity(pos)).getOwner().isOwner((EntityPlayer) entity))
            ;
        return;
    } else if (entity instanceof EntityCreeper) {
        EntityCreeper creeper = (EntityCreeper) entity;
        EntityLightningBolt lightning = new EntityLightningBolt(world, pos.getX(), pos.getY(), pos.getZ(), true);
        creeper.onStruckByLightning(lightning);
        creeper.extinguish();
        return;
    }
    //3 hearts per attack
    entity.attackEntityFrom(CustomDamageSources.electricity, 6.0F);
}
Also used : EntityCreeper(net.minecraft.entity.monster.EntityCreeper) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) EntityItem(net.minecraft.entity.item.EntityItem) TileEntityOwnable(net.geforcemods.securitycraft.tileentity.TileEntityOwnable)

Aggregations

EntityCreeper (net.minecraft.entity.monster.EntityCreeper)12 EntityPlayer (net.minecraft.entity.player.EntityPlayer)9 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)5 TileEntityOwnable (net.geforcemods.securitycraft.tileentity.TileEntityOwnable)4 EntityLivingBase (net.minecraft.entity.EntityLivingBase)4 EntityItem (net.minecraft.entity.item.EntityItem)4 EntitySkeleton (net.minecraft.entity.monster.EntitySkeleton)3 ItemStack (net.minecraft.item.ItemStack)3 Block (net.minecraft.block.Block)2 EntityZombie (net.minecraft.entity.monster.EntityZombie)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 PotionEffect (net.minecraft.potion.PotionEffect)2 World (net.minecraft.world.World)2 ChemthrowerEffect_Damage (blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Damage)1 ChemthrowerEffect_Potion (blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Potion)1 ChemthrowerEffect_RandomTeleport (blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_RandomTeleport)1 Cube (com.builtbroken.mc.imp.transform.region.Cube)1 Pos (com.builtbroken.mc.imp.transform.vector.Pos)1 EntityExplosive (icbm.classic.content.entity.EntityExplosive)1 Field (java.lang.reflect.Field)1