Search in sources :

Example 1 with EntityTNTPrimed

use of net.minecraft.entity.item.EntityTNTPrimed in project ICBM-Classic by BuiltBrokenModding.

the class ItemDefuser method onLeftClickEntity.

/**
     * Called when the player Left Clicks (attacks) an entity. Processed before damage is done, if
     * return value is true further processing is canceled and the entity is not attacked.
     *
     * @param itemStack The Item being used
     * @param player    The player that is attacking
     * @param entity    The entity being attacked
     * @return True to cancel the rest of the interaction.
     */
@Override
public boolean onLeftClickEntity(ItemStack itemStack, EntityPlayer player, Entity entity) {
    if (this.getEnergy(itemStack) >= ENERGY_COST) {
        if (entity instanceof EntityExplosive) {
            if (!entity.worldObj.isRemote) {
                EntityExplosive entityTNT = (EntityExplosive) entity;
                EntityItem entityItem = new EntityItem(entity.worldObj, entity.posX, entity.posY, entity.posZ, new ItemStack(ICBMClassic.blockExplosive, 1, entityTNT.explosiveID.ordinal()));
                float var13 = 0.05F;
                Random random = new Random();
                entityItem.motionX = ((float) random.nextGaussian() * var13);
                entityItem.motionY = ((float) random.nextGaussian() * var13 + 0.2F);
                entityItem.motionZ = ((float) random.nextGaussian() * var13);
                entity.worldObj.spawnEntityInWorld(entityItem);
            }
            entity.setDead();
        } else if (entity instanceof EntityTNTPrimed) {
            if (!entity.worldObj.isRemote) {
                EntityItem entityItem = new EntityItem(entity.worldObj, entity.posX, entity.posY, entity.posZ, new ItemStack(Blocks.tnt));
                float var13 = 0.05F;
                Random random = new Random();
                entityItem.motionX = ((float) random.nextGaussian() * var13);
                entityItem.motionY = ((float) random.nextGaussian() * var13 + 0.2F);
                entityItem.motionZ = ((float) random.nextGaussian() * var13);
                entity.worldObj.spawnEntityInWorld(entityItem);
            }
            entity.setDead();
        } else if (entity instanceof EntityBombCart) {
            ((EntityBombCart) entity).killMinecart(DamageSource.generic);
        }
        this.discharge(itemStack, ENERGY_COST, true);
        return true;
    } else {
        player.addChatMessage(new ChatComponentText(LanguageUtility.getLocal("message.defuser.nopower")));
    }
    return false;
}
Also used : EntityBombCart(icbm.classic.content.entity.EntityBombCart) Random(java.util.Random) EntityTNTPrimed(net.minecraft.entity.item.EntityTNTPrimed) EntityExplosive(icbm.classic.content.entity.EntityExplosive) ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText) EntityItem(net.minecraft.entity.item.EntityItem)

Example 2 with EntityTNTPrimed

use of net.minecraft.entity.item.EntityTNTPrimed in project PneumaticCraft by MineMaarten.

the class HackableTNT method onHackFinished.

@Override
public void onHackFinished(World world, int x, int y, int z, EntityPlayer player) {
    if (!world.isRemote) {
        world.setBlockToAir(x, y, z);
        EntityTNTPrimed tnt = new EntityTNTPrimed(world, x + 0.5, y + 0.5, z + 0.5, player);
        tnt.fuse = 1;
        world.spawnEntityInWorld(tnt);
    }
}
Also used : EntityTNTPrimed(net.minecraft.entity.item.EntityTNTPrimed)

Example 3 with EntityTNTPrimed

use of net.minecraft.entity.item.EntityTNTPrimed in project PneumaticCraft by MineMaarten.

the class TileEntityAirCannon method getPayloadEntity.

// warning: no null-check for inventory slot 0
private Entity getPayloadEntity() {
    if (getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE, getUpgradeSlots()) > 0) {
        Item item = inventory[0].getItem();
        if (item == Item.getItemFromBlock(Blocks.tnt)) {
            EntityTNTPrimed tnt = new EntityTNTPrimed(worldObj);
            tnt.fuse = 80;
            return tnt;
        } else if (item == Items.experience_bottle)
            return new EntityExpBottle(worldObj);
        else if (item == Items.potionitem) {
            EntityPotion potion = new EntityPotion(worldObj);
            potion.setPotionDamage(inventory[0].getItemDamage());
            return potion;
        } else if (item == Items.arrow)
            return new EntityArrow(worldObj);
        else if (item == Items.egg)
            return new EntityEgg(worldObj);
        else // EntitySmallFireball(worldObj);
        if (item == Items.snowball)
            return new EntitySnowball(worldObj);
        else if (item == Items.spawn_egg)
            return ItemMonsterPlacer.spawnCreature(worldObj, inventory[0].getItemDamage(), 0, 0, 0);
        else if (item == Items.minecart)
            return new EntityMinecartEmpty(worldObj);
        else if (item == Items.chest_minecart)
            return new EntityMinecartChest(worldObj);
        else if (item == Items.furnace_minecart)
            return new EntityMinecartFurnace(worldObj);
        else if (item == Items.hopper_minecart)
            return new EntityMinecartHopper(worldObj);
        else if (item == Items.tnt_minecart)
            return new EntityMinecartTNT(worldObj);
        else if (item == Items.boat)
            return new EntityBoat(worldObj);
    }
    EntityItem item = new EntityItem(worldObj);
    item.setEntityItemStack(inventory[0].copy());
    // 1200 ticks left to live, = 60s.
    item.age = 4800;
    // add
    item.lifespan += Math.min(getUpgrades(ItemMachineUpgrade.UPGRADE_ITEM_LIFE, getUpgradeSlots()) * 600, 4800);
    // min.
    return item;
}
Also used : EntityArrow(net.minecraft.entity.projectile.EntityArrow) EntityMinecartChest(net.minecraft.entity.item.EntityMinecartChest) EntityTNTPrimed(net.minecraft.entity.item.EntityTNTPrimed) EntityMinecartTNT(net.minecraft.entity.item.EntityMinecartTNT) EntityBoat(net.minecraft.entity.item.EntityBoat) EntityMinecartFurnace(net.minecraft.entity.item.EntityMinecartFurnace) EntityMinecartHopper(net.minecraft.entity.item.EntityMinecartHopper) EntityExpBottle(net.minecraft.entity.item.EntityExpBottle) EntityEgg(net.minecraft.entity.projectile.EntityEgg) Item(net.minecraft.item.Item) EntityItem(net.minecraft.entity.item.EntityItem) EntitySnowball(net.minecraft.entity.projectile.EntitySnowball) EntityPotion(net.minecraft.entity.projectile.EntityPotion) EntityMinecartEmpty(net.minecraft.entity.item.EntityMinecartEmpty) EntityItem(net.minecraft.entity.item.EntityItem)

Example 4 with EntityTNTPrimed

use of net.minecraft.entity.item.EntityTNTPrimed in project MineFactoryReloaded by powercrystals.

the class VanillaMobProvider method getRandomMobs.

@Override
public List<RandomMob> getRandomMobs(World world) {
    List<RandomMob> mobs = new ArrayList<RandomMob>();
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityMooshroom.class, world), 20));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntitySlime.class, world), 20));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityCow.class, world), 100));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityChicken.class, world), 100));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntitySheep.class, world), 100));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityWitch.class, world), 10));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityGhast.class, world), 15));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityPig.class, world), 100));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityCreeper.class, world), 25));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntitySquid.class, world), 30));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityMinecartHopper.class, world), 15));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityOcelot.class, world), 20));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityWolf.class, world), 20));
    mobs.add(new RandomMob(MFRUtil.prepareMob(EntityBat.class, world), 35));
    EntityCreeper chargedCreeper = (EntityCreeper) MFRUtil.prepareMob(EntityCreeper.class, world);
    NBTTagCompound creeperNBT = new NBTTagCompound();
    chargedCreeper.writeToNBT(creeperNBT);
    creeperNBT.setBoolean("powered", true);
    creeperNBT.setShort("Fuse", (short) 120);
    chargedCreeper.readFromNBT(creeperNBT);
    mobs.add(new RandomMob(chargedCreeper, 5));
    EntityTNTPrimed armedTNT = (EntityTNTPrimed) MFRUtil.prepareMob(EntityTNTPrimed.class, world);
    armedTNT.fuse = 120;
    mobs.add(new RandomMob(armedTNT, 5));
    EntitySlime invisislime = (EntitySlime) MFRUtil.prepareMob(EntitySlime.class, world);
    invisislime.addPotionEffect(new PotionEffect(Potion.invisibility.id, 120 * 20));
    mobs.add(new RandomMob(invisislime, 5));
    EntityMooshroom invisishroom = (EntityMooshroom) MFRUtil.prepareMob(EntityMooshroom.class, world);
    invisishroom.addPotionEffect(new PotionEffect(Potion.invisibility.id, 120 * 20));
    mobs.add(new RandomMob(invisishroom, 5));
    EntitySkeleton skeleton1 = (EntitySkeleton) MFRUtil.prepareMob(EntitySkeleton.class, world);
    EntitySkeleton skeleton2 = (EntitySkeleton) MFRUtil.prepareMob(EntitySkeleton.class, world);
    EntitySkeleton skeleton3 = (EntitySkeleton) MFRUtil.prepareMob(EntitySkeleton.class, world);
    EntitySkeleton skeleton4 = (EntitySkeleton) MFRUtil.prepareMob(EntitySkeleton.class, world);
    skeleton4.mountEntity(skeleton3);
    skeleton3.mountEntity(skeleton2);
    skeleton2.mountEntity(skeleton1);
    mobs.add(new RandomMob(skeleton1, 2));
    EntityBlaze blazeJockey = (EntityBlaze) MFRUtil.prepareMob(EntityBlaze.class, world);
    EntityGhast blazeMount = (EntityGhast) MFRUtil.prepareMob(EntityGhast.class, world);
    blazeJockey.mountEntity(blazeMount);
    mobs.add(new RandomMob(blazeMount, 2));
    EntityCreeper creeperJockey = (EntityCreeper) MFRUtil.prepareMob(EntityCreeper.class, world);
    EntityCaveSpider creeperMount = (EntityCaveSpider) MFRUtil.prepareMob(EntityCaveSpider.class, world);
    creeperJockey.mountEntity(creeperMount);
    mobs.add(new RandomMob(creeperMount, 2));
    return mobs;
}
Also used : EntityMooshroom(net.minecraft.entity.passive.EntityMooshroom) RandomMob(powercrystals.minefactoryreloaded.api.RandomMob) EntityCaveSpider(net.minecraft.entity.monster.EntityCaveSpider) PotionEffect(net.minecraft.potion.PotionEffect) EntityTNTPrimed(net.minecraft.entity.item.EntityTNTPrimed) EntitySlime(net.minecraft.entity.monster.EntitySlime) EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityGhast(net.minecraft.entity.monster.EntityGhast) EntityBlaze(net.minecraft.entity.monster.EntityBlaze) EntityCreeper(net.minecraft.entity.monster.EntityCreeper)

Aggregations

EntityTNTPrimed (net.minecraft.entity.item.EntityTNTPrimed)4 EntityItem (net.minecraft.entity.item.EntityItem)2 EntityBombCart (icbm.classic.content.entity.EntityBombCart)1 EntityExplosive (icbm.classic.content.entity.EntityExplosive)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 EntityBoat (net.minecraft.entity.item.EntityBoat)1 EntityExpBottle (net.minecraft.entity.item.EntityExpBottle)1 EntityMinecartChest (net.minecraft.entity.item.EntityMinecartChest)1 EntityMinecartEmpty (net.minecraft.entity.item.EntityMinecartEmpty)1 EntityMinecartFurnace (net.minecraft.entity.item.EntityMinecartFurnace)1 EntityMinecartHopper (net.minecraft.entity.item.EntityMinecartHopper)1 EntityMinecartTNT (net.minecraft.entity.item.EntityMinecartTNT)1 EntityBlaze (net.minecraft.entity.monster.EntityBlaze)1 EntityCaveSpider (net.minecraft.entity.monster.EntityCaveSpider)1 EntityCreeper (net.minecraft.entity.monster.EntityCreeper)1 EntityGhast (net.minecraft.entity.monster.EntityGhast)1 EntitySkeleton (net.minecraft.entity.monster.EntitySkeleton)1 EntitySlime (net.minecraft.entity.monster.EntitySlime)1 EntityMooshroom (net.minecraft.entity.passive.EntityMooshroom)1