use of net.minecraft.potion.PotionEffect 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);
}
}
}
use of net.minecraft.potion.PotionEffect in project RFToolsDimensions by McJty.
the class DimensionTickEvent method handleLowPower.
private void handleLowPower(Integer id, int power, boolean doEffects, int phasedCost) {
getPotions();
if (power <= 0) {
// We ran out of power!
WorldServer world = DimensionManager.getWorld(id);
if (world != null) {
List<EntityPlayer> players = new ArrayList<EntityPlayer>(world.playerEntities);
if (PowerConfiguration.dimensionDifficulty >= 1) {
for (EntityPlayer player : players) {
if (!RfToolsDimensionManager.checkValidPhasedFieldGenerator(player, true, phasedCost)) {
player.attackEntityFrom(new DamageSourcePowerLow("powerLow"), 1000000.0f);
} else {
if (doEffects && PowerConfiguration.phasedFieldGeneratorDebuf) {
player.addPotionEffect(new PotionEffect(moveSlowdown, EFFECTS_MAX * MAXTICKS, 4, true, true));
player.addPotionEffect(new PotionEffect(digSlowdown, EFFECTS_MAX * MAXTICKS, 2, true, true));
player.addPotionEffect(new PotionEffect(hunger, EFFECTS_MAX * MAXTICKS, 2, true, true));
}
}
}
} else {
Random random = new Random();
for (EntityPlayer player : players) {
if (!RfToolsDimensionManager.checkValidPhasedFieldGenerator(player, true, phasedCost)) {
WorldServer worldServerForDimension = player.getEntityWorld().getMinecraftServer().worldServerForDimension(GeneralConfiguration.spawnDimension);
int x = random.nextInt(2000) - 1000;
int z = random.nextInt(2000) - 1000;
int y = worldServerForDimension.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z)).getY();
if (y == -1) {
y = 63;
}
RFToolsDim.teleportationManager.teleportPlayer(player, GeneralConfiguration.spawnDimension, new BlockPos(x, y, z));
} else {
if (doEffects) {
player.addPotionEffect(new PotionEffect(moveSlowdown, EFFECTS_MAX * MAXTICKS, 4, true, true));
player.addPotionEffect(new PotionEffect(digSlowdown, EFFECTS_MAX * MAXTICKS, 4, true, true));
player.addPotionEffect(new PotionEffect(hunger, EFFECTS_MAX * MAXTICKS, 2, true, true));
}
}
}
}
}
}
}
use of net.minecraft.potion.PotionEffect in project RFToolsDimensions by McJty.
the class DimensionTickEvent method handleEffectsForDimension.
private void handleEffectsForDimension(int power, int id, DimensionInformation information) {
getPotions();
WorldServer world = DimensionManager.getWorld(id);
if (world != null) {
Set<EffectType> effects = information.getEffectTypes();
List<EntityPlayer> players = new ArrayList<EntityPlayer>(world.playerEntities);
for (EntityPlayer player : players) {
for (EffectType effect : effects) {
Potion potionEffect = effectsMap.get(effect);
if (potionEffect != null) {
Integer amplifier = effectAmplifierMap.get(effect);
if (amplifier == null) {
amplifier = 0;
}
player.addPotionEffect(new PotionEffect(potionEffect, EFFECTS_MAX * MAXTICKS * 3, amplifier, true, true));
} else if (effect == EffectType.EFFECT_FLIGHT) {
// BuffProperties.addBuff(player, PlayerBuff.BUFF_FLIGHT, EFFECTS_MAX * MAXTICKS * 2);
// @todo
}
}
if (power < PowerConfiguration.DIMPOWER_WARN3) {
// We are VERY low on power. Start bad effects.
player.addPotionEffect(new PotionEffect(moveSlowdown, EFFECTS_MAX * MAXTICKS, 4, true, true));
player.addPotionEffect(new PotionEffect(digSlowdown, EFFECTS_MAX * MAXTICKS, 4, true, true));
player.addPotionEffect(new PotionEffect(poison, EFFECTS_MAX * MAXTICKS, 2, true, true));
player.addPotionEffect(new PotionEffect(hunger, EFFECTS_MAX * MAXTICKS, 2, true, true));
} else if (power < PowerConfiguration.DIMPOWER_WARN2) {
player.addPotionEffect(new PotionEffect(moveSlowdown, EFFECTS_MAX * MAXTICKS, 2, true, true));
player.addPotionEffect(new PotionEffect(digSlowdown, EFFECTS_MAX * MAXTICKS, 2, true, true));
player.addPotionEffect(new PotionEffect(hunger, EFFECTS_MAX * MAXTICKS, 1, true, true));
} else if (power < PowerConfiguration.DIMPOWER_WARN1) {
player.addPotionEffect(new PotionEffect(moveSlowdown, EFFECTS_MAX * MAXTICKS, 0, true, true));
player.addPotionEffect(new PotionEffect(digSlowdown, EFFECTS_MAX * MAXTICKS, 0, true, true));
}
}
}
}
use of net.minecraft.potion.PotionEffect in project Pearcel-Mod by MiningMark48.
the class ItemPearcelJuiceBottle method onItemUseFinish.
@Nullable
public ItemStack onItemUseFinish(ItemStack item, World world, EntityLivingBase entityLiving) {
if (entityLiving instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entityLiving;
if (!player.capabilities.isCreativeMode) {
--item.stackSize;
}
if (!world.isRemote) {
player.addPotionEffect(new PotionEffect(MobEffects.JUMP_BOOST, 1500, 3));
player.addPotionEffect(new PotionEffect(MobEffects.SPEED, 1500, 2));
player.heal(5.0F);
}
}
return item.stackSize <= 0 ? new ItemStack((Items.GLASS_BOTTLE)) : item;
}
use of net.minecraft.potion.PotionEffect in project ArsMagica2 by Mithion.
the class EntityAIManaDrainBolt method doRangedAttack.
/**
* Performs a ranged attack according to the AI's rangedAttackID.
*/
private void doRangedAttack() {
//43% chance to "miss"
int chanceToMiss = entityHost.isPotionActive(Potion.moveSpeed) ? 10 : 43;
if (worldObj.rand.nextInt(100) < chanceToMiss) {
AMCore.instance.proxy.particleManager.BoltFromPointToPoint(worldObj, entityHost.posX, entityHost.posY + entityHost.getEyeHeight(), entityHost.posZ, attackTarget.posX + worldObj.rand.nextFloat() - 0.5f, attackTarget.posY + attackTarget.getEyeHeight() + worldObj.rand.nextFloat() - 0.5f, attackTarget.posZ + worldObj.rand.nextFloat() - 0.5f, 2, -1);
} else {
AMCore.instance.proxy.particleManager.BoltFromEntityToEntity(worldObj, entityHost, entityHost, attackTarget, this.damage, 2, -1);
float manaDrained = this.manaDrainedPerCasterLevel * ExtendedProperties.For(attackTarget).getMagicLevel();
ExtendedProperties.For(attackTarget).setCurrentMana(ExtendedProperties.For(attackTarget).getCurrentMana() - (manaDrained));
ExtendedProperties.For(attackTarget).forceSync();
attackTarget.attackEntityFrom(DamageSource.causeIndirectMagicDamage(entityHost, entityHost), this.damage);
if (manaDrained > 100) {
entityHost.heal(1);
if (entityHost.worldObj.difficultySetting == EnumDifficulty.HARD) {
attackTarget.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 40, 1, true));
entityHost.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 40, 3, true));
}
}
}
}
Aggregations