Java Code Examples for net.minecraft.entity.EntityLivingBase#isPotionActive()
The following examples show how to use
net.minecraft.entity.EntityLivingBase#isPotionActive() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PotionLowGrav.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void performEffect(@Nonnull EntityLivingBase entity, int amplifier) { if (!entity.isPotionActive(this)) return; double dist = -0.05; double shift = 0.175; World world = entity.world; if (world.containsAnyLiquid(entity.getEntityBoundingBox().offset(0.0, dist + shift, 0.0)) && entity.motionY < 0.5) { entity.motionY += 0.15; } else if (world.containsAnyLiquid(entity.getEntityBoundingBox().offset(0.0, dist, 0.0)) && entity.motionY < 0.0) { entity.motionY = 0.0; entity.onGround = true; } else if (world.containsAnyLiquid(entity.getEntityBoundingBox().offset(0.0, dist + entity.motionY - 0.05, 0.0)) && entity.motionY < 0.0) { entity.setPosition(entity.posX, Math.floor(entity.posY), entity.posZ); entity.motionY /= 5; entity.onGround = true; } else if (entity.motionY < 0) { entity.motionY = Math.max(entity.motionY, amplifier * -0.1); } entity.fallDistance = 0f; }
Example 2
Source File: PotionTimeSlow.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent(priority = EventPriority.HIGHEST) public void onTick(LivingEvent.LivingUpdateEvent event) { EntityLivingBase e = event.getEntityLiving(); if(e.isPotionActive(ModPotions.TIME_SLOW) && timeScale(e) == 0) { boolean shouldFreeze = true; if(e.isDead || e.getHealth() <= 0) { shouldFreeze = false; } if(e instanceof EntityDragon && ((EntityDragon) e).getPhaseManager().getCurrentPhase().getType() == PhaseList.DYING) { shouldFreeze = false; } if(shouldFreeze) { handleImportantEntityTicks(e); event.setCanceled(true); } } }
Example 3
Source File: EntityMage.java From ToroQuest with GNU General Public License v3.0 | 6 votes |
protected void attackWithPotion(EntityLivingBase target) { double targetY = target.posY + (double) target.getEyeHeight() - 1.100000023841858D; double targetX = target.posX + target.motionX - this.posX; double d2 = targetY - this.posY; double targetZ = target.posZ + target.motionZ - this.posZ; float f = MathHelper.sqrt(targetX * targetX + targetZ * targetZ); PotionType potiontype = PotionTypes.HARMING; if (f >= 8.0F && !target.isPotionActive(MobEffects.SLOWNESS)) { potiontype = PotionTypes.SLOWNESS; } else if (target.getHealth() >= 8.0F && !target.isPotionActive(MobEffects.POISON)) { potiontype = PotionTypes.POISON; } else if (f <= 3.0F && !target.isPotionActive(MobEffects.WEAKNESS) && this.rand.nextFloat() < 0.25F) { potiontype = PotionTypes.WEAKNESS; } EntityPotion entitypotion = new EntityPotion(this.world, this, PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype)); entitypotion.rotationPitch -= -20.0F; entitypotion.shoot(targetX, d2 + (double) (f * 0.2F), targetZ, 0.75F, 8.0F); this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F); this.world.spawnEntity(entitypotion); }
Example 4
Source File: EntityLingeringEffect.java From Et-Futurum with The Unlicense | 6 votes |
@Override public void applyEntityCollision(Entity e) { if (!(e instanceof EntityLivingBase)) return; EntityLivingBase entity = (EntityLivingBase) e; List<PotionEffect> effects = ((LingeringPotion) ModItems.lingering_potion).getEffects(stack); boolean addedEffect = false; for (PotionEffect effect : effects) { int effectID = effect.getPotionID(); if (Potion.potionTypes[effectID].isInstant()) { Potion.potionTypes[effectID].affectEntity(thrower, entity, effect.getAmplifier(), 0.25); addedEffect = true; } else if (!entity.isPotionActive(effectID)) { entity.addPotionEffect(effect); addedEffect = true; } } if (addedEffect) { int ticks = dataWatcher.getWatchableObjectInt(TICKS_DATA_WATCHER); if (setTickCount(ticks + 5 * 20)) // Add 5 seconds to the expiration time (decreasing radius by 0.5 blocks) return; } }
Example 5
Source File: BounceManager.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
private static boolean shouldBounce(EntityLivingBase entity) { if (entity.isPotionActive(ModPotions.BOUNCING)) { return true; } else { for (BouncyBlock block : INSTANCE.blocks) { if (block.doesMatch(entity)) { return true; } } } return false; }
Example 6
Source File: PotionLowGrav.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public void jump(LivingEvent.LivingJumpEvent event) { EntityLivingBase entity = event.getEntityLiving(); if (!entity.isPotionActive(this)) return; PotionEffect effect = entity.getActivePotionEffect(this); if (effect == null) return; entity.motionY = effect.getAmplifier() / 3.0; }
Example 7
Source File: PotionLowGrav.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public void fall(LivingFallEvent event) { EntityLivingBase entity = event.getEntityLiving(); if (!entity.isPotionActive(this)) return; PotionEffect effect = entity.getActivePotionEffect(this); if (effect == null) return; event.setDistance((float) (event.getDistance() / (effect.getAmplifier() + 0.5))); }
Example 8
Source File: PotionLowGrav.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public void flyableFall(PlayerFlyableFallEvent event) { EntityLivingBase entity = event.getEntityLiving(); if (!entity.isPotionActive(this)) return; PotionEffect effect = entity.getActivePotionEffect(this); if (effect == null) return; event.setDistance((float) (event.getDistance() / (effect.getAmplifier() + 0.5))); }
Example 9
Source File: PotionZachCorruption.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void performEffect(@Nonnull EntityLivingBase entity, int amplifier) { if (!entity.isPotionActive(this)) return; if (HEALTH_MAP.containsKey(entity.getUniqueID())) { // if (RandUtil.nextInt(500) == 0) { entity.setHealth(HEALTH_MAP.get(entity.getUniqueID())); // HEALTH_MAP.put(entity.getUniqueID(), entity.getHealth()); // } } }
Example 10
Source File: PotionTimeSlow.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
private static void handleImportantEntityTicks(EntityLivingBase e) { if (e.hurtTime > 0) { e.hurtTime--; } if (e.hurtResistantTime > 0) { e.hurtResistantTime--; } e.prevLimbSwingAmount = e.limbSwingAmount; e.prevRenderYawOffset = e.renderYawOffset; e.prevRotationPitch = e.rotationPitch; e.prevRotationYaw = e.rotationYaw; e.prevRotationYawHead = e.rotationYawHead; e.prevSwingProgress = e.swingProgress; e.prevDistanceWalkedModified = e.distanceWalkedModified; e.prevCameraPitch = e.cameraPitch; if(e.isPotionActive(ModPotions.TIME_SLOW) && timeScale(e) == 0) { PotionEffect pe = e.getActivePotionEffect(ModPotions.TIME_SLOW); if (!pe.onUpdate(e)) { if (!e.world.isRemote) { e.removePotionEffect(ModPotions.TIME_SLOW); } } } if(e instanceof EntityDragon) { IPhase phase = ((EntityDragon) e).getPhaseManager().getCurrentPhase(); if(phase.getType() != PhaseList.HOLDING_PATTERN && phase.getType() != PhaseList.DYING) { ((EntityDragon) e).getPhaseManager().setPhase(PhaseList.HOLDING_PATTERN); } } }
Example 11
Source File: ItemHeartUpgrade.java From Cyberware with MIT License | 5 votes |
protected float applyPotionDamageCalculations(EntityLivingBase e, DamageSource source, float damage) { if (source.isDamageAbsolute()) { return damage; } else { if (e.isPotionActive(MobEffects.RESISTANCE) && source != DamageSource.outOfWorld) { int i = (e.getActivePotionEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f = damage * (float)j; damage = f / 25.0F; } if (damage <= 0.0F) { return 0.0F; } else { int k = EnchantmentHelper.getEnchantmentModifierDamage(e.getArmorInventoryList(), source); if (k > 0) { damage = CombatRules.getDamageAfterMagicAbsorb(damage, (float)k); } return damage; } } }
Example 12
Source File: EventHandlerRedirect.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
public static int getFortuneLevel(EntityLivingBase entity) { int fortuneLevel = getRealEnchantmentLevel(Enchantment.fortune.effectId, entity.getHeldItem()); if(entity.isPotionActive(RegisteredPotions.POTION_LUCK)) { int lvl = entity.getActivePotionEffect(RegisteredPotions.POTION_LUCK).getAmplifier() + 1; //Amplifier 0-indexed fortuneLevel += lvl; } return fortuneLevel; }
Example 13
Source File: EventHandlerRedirect.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
public static int getLootingLevel(EntityLivingBase entity) { int lootingLevel = getRealEnchantmentLevel(Enchantment.looting.effectId, entity.getHeldItem()); if(entity.isPotionActive(RegisteredPotions.POTION_LUCK)) { int lvl = entity.getActivePotionEffect(RegisteredPotions.POTION_LUCK).getAmplifier() + 1; //Amplifier 0-indexed lootingLevel += lvl; } return lootingLevel; }
Example 14
Source File: PLPotion.java From Production-Line with MIT License | 5 votes |
public void applyPotion(EntityLivingBase entityLivingBase, int durationTime, int level) { if (entityLivingBase.isPotionActive(salty)) { level += ((PLEffect) entityLivingBase.getActivePotionEffect(salty)).level; } PLEffect effect = new PLEffect(this, durationTime, level); if (this == salty && FMLCommonHandler.instance().getSide() == Side.CLIENT) { effect.setPotionDurationMax(true); } effect.setCurativeItems(this.curativeItems); entityLivingBase.addPotionEffect(effect); }
Example 15
Source File: ItemSkinUpgrade.java From Cyberware with MIT License | 4 votes |
@SubscribeEvent(priority = EventPriority.HIGH) public void handleMissingEssentials(CyberwareUpdateEvent event) { EntityLivingBase e = event.getEntityLiving(); ItemStack test = new ItemStack(this, 1, 3); if (CyberwareAPI.isCyberwareInstalled(e, test)) { boolean last = lastImmuno(e); boolean powerUsed = e.ticksExisted % 20 == 0 ? CyberwareAPI.getCapability(e).usePower(test, getPowerConsumption(test)) : last; if (!powerUsed && e instanceof EntityPlayer && e.ticksExisted % 100 == 0 && !e.isPotionActive(CyberwareContent.neuropozyneEffect)) { e.attackEntityFrom(EssentialsMissingHandler.lowessence, 2F); } if (potions.containsKey(e.getEntityId())) { Collection<PotionEffect> potionsLastActive = potions.get(e.getEntityId()); Collection<PotionEffect> currentEffects = e.getActivePotionEffects(); for (PotionEffect cE : currentEffects) { if (cE.getPotion() == MobEffects.POISON || cE.getPotion() == MobEffects.HUNGER) { boolean found = false; for (PotionEffect lE : potionsLastActive) { if (lE.getPotion() == cE.getPotion() && lE.getAmplifier() == cE.getAmplifier()) { found = true; break; } } if (!found) { e.addPotionEffect(new PotionEffect(cE.getPotion(), (int) (cE.getDuration() * 1.8F), cE.getAmplifier(), cE.getIsAmbient(), cE.doesShowParticles())); } } } } potions.put(e.getEntityId(), e.getActivePotionEffects()); } else { lastImmuno.remove(e.getEntityId()); potions.remove(e.getEntityId()); } }