use of net.minecraft.entity.EntityLivingBase 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);
}
}
use of net.minecraft.entity.EntityLivingBase in project ICBM-Classic by BuiltBrokenModding.
the class PoisonContagion method performEffect.
@Override
public void performEffect(EntityLivingBase entityLiving, int amplifier) {
if (!(entityLiving instanceof EntityZombie) && !(entityLiving instanceof EntityPigZombie)) {
entityLiving.attackEntityFrom(DamageSource.magic, 1);
}
if (entityLiving.worldObj.rand.nextFloat() > 0.8) {
ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(entityLiving.worldObj, entityLiving.posX, entityLiving.posY, entityLiving.posZ, ExplosiveType.ALL, Explosives.CHEMICAL.handler);
MinecraftForge.EVENT_BUS.post(evt);
// Poison things around it
if (!evt.isCanceled()) {
int r = 13;
AxisAlignedBB entitySurroundings = AxisAlignedBB.getBoundingBox(entityLiving.posX - r, entityLiving.posY - r, entityLiving.posZ - r, entityLiving.posX + r, entityLiving.posY + r, entityLiving.posZ + r);
List<EntityLivingBase> entities = entityLiving.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, entitySurroundings);
for (EntityLivingBase entity : entities) {
if (entity != null && entity != entityLiving) {
if (entity instanceof EntityPig) {
EntityPigZombie newEntity = new EntityPigZombie(entity.worldObj);
newEntity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
if (!entity.worldObj.isRemote) {
entity.worldObj.spawnEntityInWorld(newEntity);
}
entity.setDead();
} else if (entity instanceof EntityVillager) {
EntityZombie newEntity = new EntityZombie(entity.worldObj);
newEntity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
newEntity.setVillager(true);
if (!entity.worldObj.isRemote) {
entity.worldObj.spawnEntityInWorld(newEntity);
}
entity.setDead();
}
ICBMClassic.contagios_potion.poisonEntity(new Pos(entity), entity);
}
}
}
}
}
use of net.minecraft.entity.EntityLivingBase in project ConvenientAdditions by Necr0.
the class BlockBlastPad method neighborChanged.
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos from) {
float str = EntityLaunchingArrow.EnumLaunchingArrowVariant.slime.strength * (float) Math.log(worldIn.isBlockIndirectlyGettingPowered(pos) + 1) * .25f;
if (state.getValue(READY) && worldIn.isBlockIndirectlyGettingPowered(pos) > 0) {
List<EntityLivingBase> l = worldIn.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(pos.up()));
for (EntityLivingBase e : l) {
e.addVelocity(0, str, 0);
e.velocityChanged = true;
if (e.motionY > -.666)
e.fallDistance = 0;
}
worldIn.playSound(null, pos, SoundEvent.REGISTRY.getObject(new ResourceLocation("entity.generic.explode")), SoundCategory.BLOCKS, .15f, 1.25f);
ModNetworking.spawnParticle(worldIn, EnumParticleTypes.EXPLOSION_LARGE, pos.getX() + .5, pos.getY() + 1.1, pos.getZ() + .5, 1.3, 0, 0);
worldIn.setBlockState(pos, state.withProperty(READY, false), 6);
} else if (!state.getValue(READY).booleanValue() && worldIn.isBlockIndirectlyGettingPowered(pos) == 0) {
worldIn.setBlockState(pos, state.withProperty(READY, true), 6);
}
}
use of net.minecraft.entity.EntityLivingBase in project VoodooCraft by Mod-DevCafeTeam.
the class HexHandler method hurtEvent.
/**
* Protection Hex
*/
@SubscribeEvent
public static void hurtEvent(LivingHurtEvent event) {
EntityLivingBase entity = event.getEntityLiving();
ItemStack stack;
//Protection - Absorbs some damage, with a 10s cooldown
if (event.getSource().getSourceOfDamage() != null && (stack = getDollWithHex(entity, "protection")) != null) {
UUID uuid = entity.getUniqueID();
Long cooldownStart = protectionCooldowns.get(uuid);
long worldTime = entity.world.getTotalWorldTime();
//Check if hex is ready to protect
if (//200 ticks == 10 seconds
cooldownStart == null || (worldTime - cooldownStart) >= 200) {
//Protect from up to 5 hearts of damage
float protection = 10f;
float damage = event.getAmount();
event.setAmount(damage <= protection ? 0 : damage - protection);
//Sets the new cooldown start
protectionCooldowns.put(uuid, worldTime);
//Damage the doll
stack.damageItem(1, entity);
}
}
}
use of net.minecraft.entity.EntityLivingBase in project NetherEx by LogicTechCorp.
the class EventHandler method onLivingUpdate.
@SubscribeEvent
public static void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
World world = event.getEntityLiving().getEntityWorld();
BlockPos pos = new BlockPos(event.getEntityLiving());
EntityLivingBase entity = event.getEntityLiving();
boolean canFreeze = !(entity instanceof EntityPlayer) && !Arrays.asList(ConfigHandler.potionEffect.freeze.blacklist).contains(EntityList.getKey(entity).toString());
if (world.getBiomeForCoordsBody(pos) == NetherExBiomes.ARCTIC_ABYSS) {
if (canFreeze && !entity.isPotionActive(NetherExEffects.FREEZE) && world.rand.nextInt(ConfigHandler.biome.arcticAbyss.chanceOfFreezing) == 0) {
entity.addPotionEffect(new PotionEffect(NetherExEffects.FREEZE, 300, 0));
}
}
if (entity instanceof EntityLiving && canFreeze) {
if (!entity.isPotionActive(NetherExEffects.FREEZE)) {
if (((EntityLiving) entity).isAIDisabled()) {
((EntityLiving) entity).setNoAI(false);
entity.setSilent(false);
}
} else {
((EntityLiving) entity).setNoAI(true);
entity.setSilent(true);
if (world.rand.nextInt(ConfigHandler.potionEffect.freeze.chanceOfThawing) == 0) {
entity.removePotionEffect(NetherExEffects.FREEZE);
}
}
}
if (entity instanceof EntityPlayer && entity.isPotionActive(NetherExEffects.FREEZE)) {
entity.setPosition(entity.prevPosX, entity.posY, entity.prevPosZ);
}
boolean canSpawnSpore = entity instanceof EntityPlayer || !Arrays.asList(ConfigHandler.potionEffect.spore.blacklist).contains(EntityList.getKey(entity).toString());
if (canSpawnSpore && entity.isPotionActive(NetherExEffects.SPORE) && world.rand.nextInt(ConfigHandler.potionEffect.spore.chanceOfSporeSpawning) == 0) {
if (world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(pos).expand(1, 1, 1)).size() < 3) {
BlockPos newPos = pos.offset(EnumFacing.Plane.HORIZONTAL.random(world.rand));
if (!world.isRemote && world.isAirBlock(newPos) && world.getBlockState(newPos.down()).isSideSolid(world, newPos.down(), EnumFacing.UP)) {
EntitySpore spore = new EntitySpore(world, 0);
spore.setPosition(newPos.getX(), newPos.getY(), newPos.getZ());
world.spawnEntity(spore);
}
}
}
boolean canSpawnGhastling = entity instanceof EntityPlayer && world.provider.getDimension() == DimensionType.NETHER.getId();
if (canSpawnGhastling && entity.isPotionActive(NetherExEffects.LOST) && world.rand.nextInt(ConfigHandler.potionEffect.lost.chanceOfGhastlingSpawning) == 0) {
BlockPos newPos = pos.add(0, 5, 0).offset(entity.getHorizontalFacing().getOpposite(), 5);
if (!world.isRemote && world.isAirBlock(newPos)) {
EntityGhastling ghastling = new EntityGhastling(world);
ghastling.setPosition(newPos.getX(), newPos.getY(), newPos.getZ());
ghastling.setAttackTarget(entity);
world.spawnEntity(ghastling);
}
}
}
Aggregations