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;
}
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);
}
}
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;
}
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;
}
Aggregations