@Override public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if (entityIn instanceof EntityLivingBase) { EntityLivingBase entity = (EntityLivingBase) entityIn; if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; if (entity.isInWater()) { entity.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 20 , 5 , false, false)); entity.addPotionEffect(new PotionEffect(MobEffects.WATER_BREATHING, 20 , 5 , false, false)); player.capabilities.disableDamage = true; } else { player.capabilities.disableDamage = false; } } } }
public boolean processInteract(EntityPlayer player, EnumHand hand) { ItemStack itemstack = player.getHeldItem(hand); if (itemstack.getItem() == Items.GOLDEN_APPLE && itemstack.getMetadata() == 0 && this.isPotionActive(MobEffects.WEAKNESS)) { if (!player.capabilities.isCreativeMode) { itemstack.func_190918_g(1); } if (!this.world.isRemote) { this.func_190734_b(this.rand.nextInt(2401) + 3600); } return true; } else { return false; } }
@Override public void onWornTick(ItemStack itemstack, EntityLivingBase player) { if (player.ticksExisted % 40 == 0 && player instanceof EntityPlayer) { EntityPlayer p = (EntityPlayer) player; boolean flag = p.getActivePotionEffect(MobEffects.POISON) != null || p.getActivePotionEffect(MobEffects.NAUSEA) != null || p.getActivePotionEffect(MobEffects.WITHER) != null || p.getActivePotionEffect(MobEffects.BLINDNESS) != null || p.getActivePotionEffect(MobEffects.WEAKNESS) != null; p.removePotionEffect(MobEffects.NAUSEA); p.removePotionEffect(MobEffects.WITHER); p.removePotionEffect(MobEffects.BLINDNESS); p.removePotionEffect(MobEffects.POISON); p.removePotionEffect(MobEffects.WEAKNESS); if (flag) { itemstack.setItemDamage(itemstack.getItemDamage() + 1); if (itemstack.getItemDamage() >= itemstack.getMaxDamage()) { itemstack.setCount(0); } } } }
public boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack) { if (stack != null && stack.getItem() == Items.GOLDEN_APPLE && stack.getMetadata() == 0 && this.isVillager() && this.isPotionActive(MobEffects.WEAKNESS)) { if (!player.capabilities.isCreativeMode) { --stack.stackSize; } if (!this.worldObj.isRemote) { this.startConversion(this.rand.nextInt(2401) + 3600); } return true; } else { return false; } }
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) { if (!worldIn.isRemote) { if (stack.getMetadata() > 0) { player.addStat(AchievementList.OVERPOWERED); player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 400, 1)); player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 6000, 0)); player.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 6000, 0)); player.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 2400, 3)); } else { player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 100, 1)); player.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 2400, 0)); } } }
@Override public void apply(World world, BlockPos pos, EntityLivingBase entity, int amplifier, int tick) { if (amplifier >= 3) { if (entity instanceof EntityWitch) { entity.setFire(500); entity.attackEntityFrom(DamageSource.MAGIC, 20); } else if (entity.getCreatureAttribute() == EnumCreatureAttribute.ILLAGER) { entity.addPotionEffect(new PotionEffect(MobEffects.WITHER, 1500, 0)); entity.attackEntityFrom(DamageSource.MAGIC, 20); } } else if (amplifier == 2 && entity.getCreatureAttribute() == EnumCreatureAttribute.ILLAGER || entity instanceof EntityWitch) { entity.attackEntityFrom(DamageSource.MAGIC, 16); } else if (entity.getCreatureAttribute() == EnumCreatureAttribute.ILLAGER) { entity.attackEntityFrom(DamageSource.MAGIC, 10); } }
/** * Clears potion metadata values if the entity has no potion effects. Otherwise, updates potion effect color, * ambience, and invisibility metadata values */ protected void updatePotionMetadata() { if (this.activePotionsMap.isEmpty()) { this.resetPotionEffectMetadata(); this.setInvisible(false); } else { Collection<PotionEffect> collection = this.activePotionsMap.values(); this.dataManager.set(HIDE_PARTICLES, Boolean.valueOf(areAllPotionsAmbient(collection))); this.dataManager.set(POTION_EFFECTS, Integer.valueOf(PotionUtils.getPotionColorFromEffectList(collection))); this.setInvisible(this.isPotionActive(MobEffects.INVISIBILITY)); } }
public void affectEntity(@Nullable Entity source, @Nullable Entity indirectSource, EntityLivingBase entityLivingBaseIn, int amplifier, double health) { if ((this != MobEffects.INSTANT_HEALTH || entityLivingBaseIn.isEntityUndead()) && (this != MobEffects.INSTANT_DAMAGE || !entityLivingBaseIn.isEntityUndead())) { if (this == MobEffects.INSTANT_DAMAGE && !entityLivingBaseIn.isEntityUndead() || this == MobEffects.INSTANT_HEALTH && entityLivingBaseIn.isEntityUndead()) { int j = (int)(health * (double)(6 << amplifier) + 0.5D); if (source == null) { entityLivingBaseIn.attackEntityFrom(DamageSource.magic, (float)j); } else { entityLivingBaseIn.attackEntityFrom(DamageSource.causeIndirectMagicDamage(source, indirectSource), (float)j); } } } else { int i = (int)(health * (double)(4 << amplifier) + 0.5D); entityLivingBaseIn.heal((float)i); } }
@SubscribeEvent public void attackEntity(LivingHurtEvent event) { try { if((event.getSource() instanceof EntityDamageSource && ((EntityDamageSource)event.getSource()).getTrueSource() instanceof EntityLivingBase && (((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof BaseHarshenSword || ((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof HarshenProps) &&!(Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(3).getItem() == HarshenArmors.harshen_jaguar_armor_helmet && Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(2).getItem() == HarshenArmors.harshen_jaguar_armor_chestplate && Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(1).getItem() == HarshenArmors.harshen_jaguar_armor_leggings && Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(0).getItem() == HarshenArmors.harshen_jaguar_armor_boots))) event.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.WITHER, 150, 1)); } catch (ClassCastException clazz){} }
public boolean attackEntityAsMob(Entity entityIn) { if (super.attackEntityAsMob(entityIn)) { if (this.getSkeletonType() == SkeletonType.WITHER && entityIn instanceof EntityLivingBase) { ((EntityLivingBase)entityIn).addPotionEffect(new PotionEffect(MobEffects.WITHER, 200)); } return true; } else { return false; } }
@HarshenEvent public void PlayerDeath(LivingDeathEvent event) { EntityPlayer player = (EntityPlayer) event.getEntity(); event.setCanceled(true); if (player instanceof EntityPlayerMP) { EntityPlayerMP entityplayermp = (EntityPlayerMP)player; entityplayermp.addStat(StatList.getObjectUseStats(Items.TOTEM_OF_UNDYING)); CriteriaTriggers.USED_TOTEM.trigger(entityplayermp, HarshenUtils.getFirstOccuringItem(player, Items.TOTEM_OF_UNDYING)); } HarshenUtils.setStackInSlot(player, Items.TOTEM_OF_UNDYING, ItemStack.EMPTY); player.setHealth(1.0F); player.clearActivePotions(); player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 900, 1)); player.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 100, 1)); player.world.setEntityState(player, (byte)35); }
public void setRandomEffect(Random rand) { int i = rand.nextInt(5); if (i <= 1) { this.effect = MobEffects.SPEED; } else if (i <= 2) { this.effect = MobEffects.STRENGTH; } else if (i <= 3) { this.effect = MobEffects.REGENERATION; } else if (i <= 4) { this.effect = MobEffects.INVISIBILITY; } }
@Override protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer playerIn) { if (!worldIn.isRemote && worldIn.rand.nextFloat() < 0.75F) { int foodAdditions = getFoodAdditions(stack); int durationTicks = (10 + foodAdditions) * 20; playerIn.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, durationTicks)); if (foodAdditions >= 2) { playerIn.addPotionEffect(new PotionEffect(MobEffects.POISON, durationTicks)); } if (foodAdditions >= 4) { playerIn.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, durationTicks)); } if (foodAdditions >= 6) { playerIn.addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, durationTicks)); } } }
@Override public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean par5) { if (hasChest(stack) && entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; if (player.capabilities.isCreativeMode) return; if (ChestTransporter.debuffSlowness) addEffect(player, MobEffects.SLOWNESS, 2); if (ChestTransporter.debuffMiningFatigue) addEffect(player, MobEffects.MINING_FATIGUE, 3); if (ChestTransporter.debuffJump) addEffect(player, MobEffects.JUMP_BOOST, -2); if (ChestTransporter.debuffHunger) addEffect(player, MobEffects.HUNGER, 0); } }
public static void tweakVanilla() { ((ItemFood) Items.BEEF).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 20, 0), 20); ((ItemFood) Items.PORKCHOP).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 25, 0), 25); ((ItemFood) Items.FISH).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 30, 1), 60); // Both fish types here ((ItemFood) Items.MUTTON).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 20, 0), 25); ((ItemFood) Items.RABBIT).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 25, 0), 30); if(BBConfig.makeStuffStackable) { // Let's face it, the vanilla stack sizes for these suck. Items.MINECART.setMaxStackSize(16); // Strangely enough the oak one doesn't change name. Items.OAK_DOOR.setMaxStackSize(16); Items.SPRUCE_DOOR.setMaxStackSize(16); Items.BIRCH_DOOR.setMaxStackSize(16); Items.ACACIA_DOOR.setMaxStackSize(16); Items.DARK_OAK_DOOR.setMaxStackSize(16); Items.IRON_DOOR.setMaxStackSize(16); } if(BBConfig.moduleFurnaces) Items.FURNACE_MINECART.setUnlocalizedName(ModMain.MODID + ".kilnCart"); }
@Override protected void onFoodEaten(ItemStack stack, World world, EntityPlayer player) { if (!world.isRemote) { if (stack.getItem() == UCItems.teriyaki) player.addPotionEffect(new PotionEffect(MobEffects.SATURATION, 3600)); if (stack.getItem() == UCItems.largeplum) player.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 40)); if (stack.getItem() == UCItems.potionreverse) { PotionBehavior.reverseEffects(player); player.inventory.addItemStackToInventory(new ItemStack(Items.GLASS_BOTTLE)); } if (stack.getItem() == UCItems.goldenbread) player.addPotionEffect(new PotionEffect(MobEffects.LUCK, 2400)); if (stack.getItem() == UCItems.heart) player.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 1200, 4)); } }
/** * checks if Potion effect is ready to be applied this tick. */ public boolean isReady(int duration, int amplifier) { if (this == MobEffects.REGENERATION) { int k = 50 >> amplifier; return k > 0 ? duration % k == 0 : true; } else if (this == MobEffects.POISON) { int j = 25 >> amplifier; return j > 0 ? duration % j == 0 : true; } else if (this == MobEffects.WITHER) { int i = 40 >> amplifier; return i > 0 ? duration % i == 0 : true; } else { return this == MobEffects.HUNGER; } }
public boolean attackEntityAsMob(Entity entityIn) { boolean flag = super.attackEntityAsMob(entityIn); if (flag) { float f = this.worldObj.getDifficultyForLocation(new BlockPos(this)).getAdditionalDifficulty(); if (this.getHeldItemMainhand() == null) { if (this.isBurning() && this.rand.nextFloat() < f * 0.3F) { entityIn.setFire(2 * (int)f); } if (this.getZombieType() == ZombieType.HUSK && entityIn instanceof EntityLivingBase) { ((EntityLivingBase)entityIn).addPotionEffect(new PotionEffect(MobEffects.HUNGER, 140 * (int)f)); } } } return flag; }
@Override protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) { if(!player.capabilities.isCreativeMode) { if(OinkConfig.pEffects) { player.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, OinkConfig.mEffectTime, 0, false, false)); player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, OinkConfig.mEffectTime, 0, false, false)); player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, OinkConfig.mEffectTime, 0, false, false)); player.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, OinkConfig.mEffectTime, 0, false, false)); player.addPotionEffect(new PotionEffect(MobEffects.HASTE, OinkConfig.mEffectTime, 0, false, false)); player.addPotionEffect(new PotionEffect(MobEffects.SPEED, OinkConfig.mEffectTime, 0, false, false)); player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, OinkConfig.mEffectTime, 0, false, false)); } if(OinkConfig.oFly){ player.addPotionEffect(new PotionEffect(TheOink.oinkFly, OinkConfig.ofTime)); } } }
@Nullable /** * Removes the given potion effect from the active potion map and returns it. Does not call cleanup callbacks for * the end of the potion effect. */ public PotionEffect removeActivePotionEffect(@Nullable Potion potioneffectin) { if (potioneffectin == MobEffects.NAUSEA) { this.prevTimeInPortal = 0.0F; this.timeInPortal = 0.0F; } return super.removeActivePotionEffect(potioneffectin); }
/** * Causes this entity to do an upwards motion (jumping). */ protected void jump() { this.motionY = (double)this.getJumpUpwardsMotion(); if (this.isPotionActive(MobEffects.JUMP_BOOST)) { this.motionY += (double)((float)(this.getActivePotionEffect(MobEffects.JUMP_BOOST).getAmplifier() + 1) * 0.1F); } if (this.isSprinting()) { float f = this.rotationYaw * 0.017453292F; this.motionX -= (double)(MathHelper.sin(f) * 0.2F); this.motionZ += (double)(MathHelper.cos(f) * 0.2F); } this.isAirBorne = true; net.minecraftforge.common.ForgeHooks.onLivingJump(this); }
protected void bulletHit(RayTraceResult result) { if (result.entityHit == null) { ((WorldServer)this.world).spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 2, 0.2D, 0.2D, 0.2D, 0.0D, new int[0]); this.playSound(SoundEvents.ENTITY_SHULKER_BULLET_HIT, 1.0F, 1.0F); } else { boolean flag = result.entityHit.attackEntityFrom(DamageSource.causeIndirectDamage(this, this.owner).setProjectile(), 4.0F); if (flag) { this.applyEnchantments(this.owner, result.entityHit); if (result.entityHit instanceof EntityLivingBase) { ((EntityLivingBase)result.entityHit).addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 200)); } } } this.setDead(); }
@Override public void onImpact(RayTraceResult result) { super.onImpact(result); if (!this.getEntityWorld().isRemote) { if (result.entityHit != null && result.entityHit instanceof EntityLivingBase) { ((EntityLivingBase) result.entityHit).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 20 * seconds, 1)); } this.setDead(); } }
public static void registerCaskLiquids() { CaskManager.register(new CaskLiquid(BOILING_WORT,1,0xFF898516)); CaskManager.register(new CaskLiquid(BOILING_POTATO_JUICE,1,0xFFECEAA7)); CaskManager.register(new CaskLiquid(BOILING_WORMWOOD,1,0xFFAFFF8D).addEffect(new PotionEffect(MobEffects.POISON,1200,0),2).addEffect(new PotionEffect(MobEffects.BLINDNESS,1200,0),0)); CaskManager.register(new CaskLiquid(BOILING_BEETROOT_SOUP,1,0xFFC62E00)); CaskManager.register(new CaskLiquid(ALE,2,0xFFE1862C).addEffect(new PotionEffect(POTION_ALE,1200,0),4)); CaskManager.register(new CaskLiquid(VODKA,1,0xFFC8EFEF).addEffect(new PotionEffect(POTION_STOUTNESS,1600,0),4)); CaskManager.register(new CaskLiquid(INNER_FIRE,2,0xFFFF4D00).addEffect(new PotionEffect(POTION_INNER_FIRE,1000,0),2)); CaskManager.register(new CaskLiquid(UMBER_ALE,2,0xFF473216)); CaskManager.register(new CaskLiquid(ABSINTHE,1,0xFF58FF2E)); CaskManager.register(new CaskLiquid(METHANOL,1,0xFF666633).addEffect(new PotionEffect(POTION_FIRE_LUNG,200,0),2)); }
@Override public void performEffect(EntityLivingBase living, int amplifier) { PotionEffect effect = living.getActivePotionEffect(this); if(effect != null) //Why are you here? { if(effect.getDuration() == 1) { living.addPotionEffect(new PotionEffect(MobEffects.NAUSEA,1000)); } } super.performEffect(living, amplifier); }
@Override public void handleUpkeepEvent(int numChanges, EntityLiving entity) { if(entity.getAttackTarget() instanceof EntityPlayer && entity.canEntityBeSeen(entity.getAttackTarget())){ EntityPlayer player = (EntityPlayer)entity.getAttackTarget(); player.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS,MobUpkeepController.POTION_EFFECT_LENGTH,numChanges,false,true)); } }
@Override public void handleUpkeepEvent(int numChanges, EntityLiving entity) { PotionEffect existingEffect = entity.getActivePotionEffect(MobEffects.REGENERATION); if(existingEffect==null) { entity.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 50, numChanges, false, true)); } }
@Override public void handleUpkeepEvent(int numChanges, EntityLiving entity) { if(entity.getAttackTarget() instanceof EntityPlayer && entity.canEntityBeSeen(entity.getAttackTarget())){ EntityPlayer player = (EntityPlayer)entity.getAttackTarget(); player.addPotionEffect(new PotionEffect(MobEffects.MINING_FATIGUE,MobUpkeepController.POTION_EFFECT_LENGTH,numChanges,false,true)); } }
@Override public void handleUpkeepEvent(int numChanges, EntityLiving entity) { if(entity.getAttackTarget() instanceof EntityPlayer && entity.canEntityBeSeen(entity.getAttackTarget())){ EntityPlayer player = (EntityPlayer)entity.getAttackTarget(); player.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS,MobUpkeepController.POTION_EFFECT_LENGTH,numChanges,false,true)); } }
protected EntityArrow func_190726_a(float p_190726_1_) { EntityArrow entityarrow = super.func_190726_a(p_190726_1_); if (entityarrow instanceof EntityTippedArrow) { ((EntityTippedArrow)entityarrow).addEffect(new PotionEffect(MobEffects.SLOWNESS, 600)); } return entityarrow; }
@SubscribeEvent public void register(RegistryEvent.Register<StrawHandler> event) { IForgeRegistry<StrawHandler> registry = event.getRegistry(); registry.registerAll(new WaterStrawHandler(), new LavaStrawHandler(), new MilkStrawHandler(), new EssenceStrawHandler()); registry.register(new PotionStrawHandler(FluidsRegistry.BIOFUEL) .addPotion(MobEffects.SPEED, 800, 0) .addPotion(MobEffects.HASTE, 800, 0) .setRegistryName("biofuel")); registry.register(new PotionStrawHandler(FluidsRegistry.SLUDGE) .addPotion(MobEffects.WITHER, 600, 0) .addPotion(MobEffects.BLINDNESS, 1000, 0) .addPotion(MobEffects.SLOWNESS, 1200, 1) .setRegistryName("sludge")); registry.register(new PotionStrawHandler(FluidsRegistry.SEWAGE) .addPotion(MobEffects.NAUSEA, 1200, 0) .addPotion(MobEffects.SLOWNESS, 1200, 0) .setRegistryName("sewage")); registry.register(new PotionStrawHandler(FluidsRegistry.MEAT) .addPotion(MobEffects.ABSORPTION, 100, 2) .addPotion(MobEffects.SATURATION, 300, 2) .setRegistryName("meat")); registry.register(new PotionStrawHandler(FluidsRegistry.PROTEIN) .addPotion(MobEffects.ABSORPTION, 100, 3) .addPotion(MobEffects.SATURATION, 300, 3) .setRegistryName("protein")); registry.register(new PotionStrawHandler(FluidsRegistry.LATEX) .addPotion(MobEffects.POISON, 1000, 2) .addPotion(MobEffects.SLOWNESS, 1000, 2) .setRegistryName("latex")); }
/** * Called when this EntityFireball hits a block or entity. */ protected void onImpact(RayTraceResult result) { if (!this.worldObj.isRemote) { List<EntityLivingBase> list = this.worldObj.<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, this.getEntityBoundingBox().expand(4.0D, 2.0D, 4.0D)); EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.worldObj, this.posX, this.posY, this.posZ); entityareaeffectcloud.setOwner(this.shootingEntity); entityareaeffectcloud.setParticle(EnumParticleTypes.DRAGON_BREATH); entityareaeffectcloud.setRadius(3.0F); entityareaeffectcloud.setDuration(2400); entityareaeffectcloud.setRadiusPerTick((7.0F - entityareaeffectcloud.getRadius()) / (float)entityareaeffectcloud.getDuration()); entityareaeffectcloud.addEffect(new PotionEffect(MobEffects.INSTANT_DAMAGE, 1, 1)); if (!list.isEmpty()) { for (EntityLivingBase entitylivingbase : list) { double d0 = this.getDistanceSqToEntity(entitylivingbase); if (d0 < 16.0D) { entityareaeffectcloud.setPosition(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ); break; } } } this.worldObj.playEvent(2006, new BlockPos(this.posX, this.posY, this.posZ), 0); this.worldObj.spawnEntityInWorld(entityareaeffectcloud); this.setDead(); } }
protected void updateAITasks() { super.updateAITasks(); if (this.isElder()) { int i = 1200; int j = 1200; int k = 6000; int l = 2; if ((this.ticksExisted + this.getEntityId()) % 1200 == 0) { Potion potion = MobEffects.MINING_FATIGUE; for (EntityPlayerMP entityplayermp : this.worldObj.getPlayers(EntityPlayerMP.class, new Predicate<EntityPlayerMP>() { public boolean apply(@Nullable EntityPlayerMP p_apply_1_) { return EntityGuardian.this.getDistanceSqToEntity(p_apply_1_) < 2500.0D && p_apply_1_.interactionManager.survivalOrAdventure(); } })) { if (!entityplayermp.isPotionActive(potion) || entityplayermp.getActivePotionEffect(potion).getAmplifier() < 2 || entityplayermp.getActivePotionEffect(potion).getDuration() < 1200) { entityplayermp.connection.sendPacket(new SPacketChangeGameState(10, 0.0F)); entityplayermp.addPotionEffect(new PotionEffect(potion, 6000, 2)); } } } if (!this.hasHome()) { this.setHomePosAndDistance(new BlockPos(this), 16); } } }
protected void updateAITasks() { super.updateAITasks(); int i = 1200; if ((this.ticksExisted + this.getEntityId()) % 1200 == 0) { Potion potion = MobEffects.MINING_FATIGUE; List<EntityPlayerMP> list = this.world.<EntityPlayerMP>getPlayers(EntityPlayerMP.class, new Predicate<EntityPlayerMP>() { public boolean apply(@Nullable EntityPlayerMP p_apply_1_) { return EntityElderGuardian.this.getDistanceSqToEntity(p_apply_1_) < 2500.0D && p_apply_1_.interactionManager.survivalOrAdventure(); } }); int j = 2; int k = 6000; int l = 1200; for (EntityPlayerMP entityplayermp : list) { if (!entityplayermp.isPotionActive(potion) || entityplayermp.getActivePotionEffect(potion).getAmplifier() < 2 || entityplayermp.getActivePotionEffect(potion).getDuration() < 1200) { entityplayermp.connection.sendPacket(new SPacketChangeGameState(10, 0.0F)); entityplayermp.addPotionEffect(new PotionEffect(potion, 6000, 2)); } } } if (!this.hasHome()) { this.setHomePosAndDistance(new BlockPos(this), 16); } }
@Override public void onWornTick(ItemStack itemstack, EntityLivingBase player) { if (itemstack.getItemDamage() == 0 && player.ticksExisted % 40 == 0) { player.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 120, 0, true, true)); player.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 120, 0, true, true)); } }
/** * Removes the given potion effect from the active potion map and returns it. Does not call cleanup callbacks for * the end of the potion effect. */ @Nullable public PotionEffect removeActivePotionEffect(@Nullable Potion potioneffectin) { if (potioneffectin == MobEffects.NAUSEA) { this.prevTimeInPortal = 0.0F; this.timeInPortal = 0.0F; } return super.removeActivePotionEffect(potioneffectin); }
@Override public void onFinish(EntityPlayer player, IRitualHandler tile, World world, BlockPos pos, NBTTagCompound data) { if (!world.isRemote) { EntityWitch witch = new EntityWitch(world); witch.setLocationAndAngles(pos.getX(), pos.getY(), pos.getZ(), (float) (Math.random() * 360), 0); witch.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(witch)), (IEntityLivingData) null); world.spawnEntity(witch); if (Math.random() < 0.1) witch.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 6000, 2, false, false)); } }
@SuppressWarnings("ConstantConditions") @Override public void cast(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { final EntityLivingBase entity = (EntityLivingBase) sender.getCommandSenderEntity(); if (entity.isEntityAlive() && entity.getHealth() < entity.getMaxHealth()) { entity.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 80, 0)); } }
@SuppressWarnings("ConstantConditions") @Override public void cast(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { final EntityLivingBase entity = (EntityLivingBase) sender.getCommandSenderEntity(); if (entity.isEntityAlive()) { entity.addPotionEffect(new PotionEffect(MobEffects.WATER_BREATHING, 275, 0)); entity.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, 275, 0)); EnergyHandler.addEnergy((EntityPlayer) sender, 800); } }