protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) { if (!worldIn.isRemote) { player.addPotionEffect(new PotionEffect(Potion.absorption.id, 2400, 0)); } if (stack.getMetadata() > 0) { if (!worldIn.isRemote) { player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 600, 4)); player.addPotionEffect(new PotionEffect(Potion.resistance.id, 6000, 0)); player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 6000, 0)); } } else { super.onFoodEaten(stack, worldIn, player); } }
/** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound compound) { super.readEntityFromNBT(compound); if (compound.hasKey("Potion", 8)) { this.potion = PotionUtils.getPotionTypeFromNBT(compound); } for (PotionEffect potioneffect : PotionUtils.getFullEffectsFromTag(compound)) { this.addEffect(potioneffect); } if (this.potion != PotionTypes.EMPTY || !this.customPotionEffects.isEmpty()) { this.dataManager.set(COLOR, Integer.valueOf(PotionUtils.getPotionColorFromEffectList(PotionUtils.mergeEffects(this.potion, this.customPotionEffects)))); } }
public void applyEffects(EntityLivingBase target, EntityLivingBase source, EntityLivingBase indirectsource) { for (CaskPotionEffect effect : effects) { PotionEffect potioneffect = effect.potionEffect; PotionEffect currentStack = target.getActivePotionEffect(potioneffect.getPotion()); if (potioneffect.getPotion().isInstant()) { potioneffect.getPotion().affectEntity(source, indirectsource, target, potioneffect.getAmplifier(), 1.0D); } else { int amplifier = currentStack.getAmplifier(); int duration = currentStack.getDuration(); if(currentStack != null) { amplifier = Math.min(amplifier + currentStack.getAmplifier() + 1,effect.maxStack); if(amplifier != currentStack.getAmplifier()) duration += currentStack.getDuration(); } PotionEffect newStack = new PotionEffect(potioneffect.getPotion(),duration,amplifier,false,false); //TODO: curative item?? alchemical hangover cure??? target.addPotionEffect(newStack); } } }
@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; } }
/** * Convert this zombie into a villager. */ protected void convertToVillager() { EntityVillager entityvillager = new EntityVillager(this.worldObj); entityvillager.copyLocationAndAnglesFrom(this); entityvillager.onInitialSpawn(this.worldObj.getDifficultyForLocation(new BlockPos(entityvillager)), (IEntityLivingData)null); entityvillager.setLookingForHome(); if (this.isChild()) { entityvillager.setGrowingAge(-24000); } this.worldObj.removeEntity(this); entityvillager.setNoAI(this.isAIDisabled()); if (this.hasCustomName()) { entityvillager.setCustomNameTag(this.getCustomNameTag()); entityvillager.setAlwaysRenderNameTag(this.getAlwaysRenderNameTag()); } this.worldObj.spawnEntityInWorld(entityvillager); entityvillager.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 0)); this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1017, new BlockPos((int)this.posX, (int)this.posY, (int)this.posZ), 0); }
/** * moves provided player from overworld to nether or vice versa */ public void transferPlayerToDimension(EntityPlayerMP playerIn, int dimension) { int i = playerIn.dimension; WorldServer worldserver = this.mcServer.worldServerForDimension(playerIn.dimension); playerIn.dimension = dimension; WorldServer worldserver1 = this.mcServer.worldServerForDimension(playerIn.dimension); playerIn.playerNetServerHandler.sendPacket(new S07PacketRespawn(playerIn.dimension, playerIn.worldObj.getDifficulty(), playerIn.worldObj.getWorldInfo().getTerrainType(), playerIn.theItemInWorldManager.getGameType())); worldserver.removePlayerEntityDangerously(playerIn); playerIn.isDead = false; this.transferEntityToWorld(playerIn, i, worldserver, worldserver1); this.preparePlayer(playerIn, worldserver); playerIn.playerNetServerHandler.setPlayerLocation(playerIn.posX, playerIn.posY, playerIn.posZ, playerIn.rotationYaw, playerIn.rotationPitch); playerIn.theItemInWorldManager.setWorld(worldserver1); this.updateTimeAndWeatherForPlayer(playerIn, worldserver1); this.syncPlayerInventory(playerIn); for (PotionEffect potioneffect : playerIn.getActivePotionEffects()) { playerIn.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(playerIn.getEntityId(), potioneffect)); } }
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"); }
/** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound compound) { super.readEntityFromNBT(compound); if (compound.hasKey("Potion", 8)) { this.potion = PotionUtils.getPotionTypeFromNBT(compound); } for (PotionEffect potioneffect : PotionUtils.getFullEffectsFromTag(compound)) { this.addEffect(potioneffect); } if (compound.hasKey("Color", 99)) { this.func_191507_d(compound.getInteger("Color")); } else { this.func_190548_o(); } }
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)); } } }
public void fall(float distance, float damageMultiplier) { super.fall(distance, damageMultiplier); PotionEffect potioneffect = this.getActivePotionEffect(Potion.jump); float f = potioneffect != null ? (float)(potioneffect.getAmplifier() + 1) : 0.0F; int i = MathHelper.ceiling_float_int((distance - 3.0F - f) * damageMultiplier); if (i > 0) { this.playSound(this.getFallSoundString(i), 1.0F, 1.0F); this.attackEntityFrom(DamageSource.fall, (float)i); int j = MathHelper.floor_double(this.posX); int k = MathHelper.floor_double(this.posY - 0.20000000298023224D); int l = MathHelper.floor_double(this.posZ); Block block = this.worldObj.getBlockState(new BlockPos(j, k, l)).getBlock(); if (block.getMaterial() != Material.air) { Block.SoundType block$soundtype = block.stepSound; this.playSound(block$soundtype.getStepSound(), block$soundtype.getVolume() * 0.5F, block$soundtype.getFrequency() * 0.75F); } } }
@Override public void onExecutionStart(EntityPlayer player) { ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand(); EnumWeaponWeight weight = EnumWeaponWeight.getWeaponWeight(is); player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 1F); Vec3d look = player.getLookVec().scale(5); Vec3d pos = player.getPositionVector(); List<EntityLivingBase> targets = Helpers.rayTraceEntities(player.world, pos.addVector(0, player.getEyeHeight(), 0), look, Optional.of(e -> e != player), EntityLivingBase.class); EntityLivingBase assumedToBeLookedAt = Helpers.getClosest(targets, player); if (assumedToBeLookedAt != null) { if (!player.world.isRemote) { assumedToBeLookedAt.addPotionEffect(new PotionEffect(ExPPotions.stunned, weight == EnumWeaponWeight.NORMAL ? 20 : 30, 0, false, false)); } player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_KNOCKBACK, SoundCategory.PLAYERS, 1, 1F); Vec3d targetPos = assumedToBeLookedAt.getPositionVector(); assumedToBeLookedAt.knockBack(player, 1, pos.x - targetPos.x, pos.z - targetPos.z); for (int i = 0; i < 50; ++i) { player.world.spawnParticle(EnumParticleTypes.CRIT_MAGIC, targetPos.x + player.world.rand.nextDouble() - player.world.rand.nextDouble(), targetPos.z + assumedToBeLookedAt.getEyeHeight() + player.world.rand.nextDouble() - player.world.rand.nextDouble(), targetPos.z + player.world.rand.nextDouble() - player.world.rand.nextDouble(), 0, -0.1, 0); } } }
@Override public List<PotionEffect> getEffects(ItemStack stack) { if (stack.hasTagCompound() && stack.getTagCompound().hasKey("CustomPotionEffects", 9)) { List<PotionEffect> list = new ArrayList<PotionEffect>(); NBTTagList nbttaglist = stack.getTagCompound().getTagList("CustomPotionEffects", 10); for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbt = nbttaglist.getCompoundTagAt(i); PotionEffect potioneffect = PotionEffect.readCustomPotionEffectFromNBT(nbt); if (potioneffect != null) list.add(potioneffect); } return list; } else return getEffects(stack.getItemDamage()); }
@Override public String getItemStackDisplayName(ItemStack stack) { if (stack.getItemDamage() == 0) return StatCollector.translateToLocal("item.emptyPotion.name").trim(); else { String s = StatCollector.translateToLocal("potion.prefix.lingering").trim() + " "; List<PotionEffect> list = getEffects(stack); String s1; if (list != null && !list.isEmpty()) { s1 = list.get(0).getEffectName(); s1 = s1 + ".postfix"; return s + StatCollector.translateToLocal(s1).trim(); } else { s1 = PotionHelper.func_77905_c(stack.getItemDamage()); return StatCollector.translateToLocal(s1).trim() + " " + super.getItemStackDisplayName(stack); } } }
public boolean isEffectInstant(int meta) { List<PotionEffect> list = this.getEffects(meta); if (list != null && !list.isEmpty()) { for (PotionEffect potioneffect : list) { if (Potion.potionTypes[potioneffect.getPotionID()].isInstant()) { return true; } } return false; } else { return false; } }
@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); } }
private void func_190542_a(ItemStack p_190542_1_, PotionType p_190542_2_) { EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.posX, this.posY, this.posZ); entityareaeffectcloud.setOwner(this.getThrower()); entityareaeffectcloud.setRadius(3.0F); entityareaeffectcloud.setRadiusOnUse(-0.5F); entityareaeffectcloud.setWaitTime(10); entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / (float)entityareaeffectcloud.getDuration()); entityareaeffectcloud.setPotion(p_190542_2_); for (PotionEffect potioneffect : PotionUtils.getFullEffectsFromItem(p_190542_1_)) { entityareaeffectcloud.addEffect(new PotionEffect(potioneffect)); } NBTTagCompound nbttagcompound = p_190542_1_.getTagCompound(); if (nbttagcompound != null && nbttagcompound.hasKey("CustomPotionColor", 99)) { entityareaeffectcloud.setColor(nbttagcompound.getInteger("CustomPotionColor")); } this.world.spawnEntityInWorld(entityareaeffectcloud); }
@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); }
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 ItemStack getCraftingResult(InventoryCrafting inv) { ItemStack outputStack = ItemStack.EMPTY; if (countSlotsNotEmpty(inv) <= 1) return outputStack; Collection<PotionEffect> effects = new ArrayList<PotionEffect>(); for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); if (!stack.isEmpty()) { if (outputStack.isEmpty()) outputStack = getOutputStack(stack); if (outputStack.isEmpty()) return outputStack; effects.addAll(getEffectsFromStack(stack)); } } outputStack = PotionUtils.appendEffects(outputStack, effects); outputStack.setStackDisplayName(I18n.translateToLocal("item.combined_" + outputStack.getItem().getUnlocalizedName().substring(5) + ".name")); return outputStack; }
public void clearActivePotions() { Iterator<Integer> iterator = this.activePotionsMap.keySet().iterator(); while (iterator.hasNext()) { Integer integer = (Integer)iterator.next(); PotionEffect potioneffect = (PotionEffect)this.activePotionsMap.get(integer); if (!this.worldObj.isRemote) { iterator.remove(); this.onFinishedPotionEffect(potioneffect); } } }
@Override public void addPotionEffect(PotionEffect potioneffectIn) { if (m_realPlayer == null) { super.addPotionEffect(potioneffectIn); } else { m_realPlayer.addPotionEffect(potioneffectIn); } }
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) { if (!worldIn.isRemote && this.potionId > 0 && worldIn.rand.nextFloat() < this.potionEffectProbability) { player.addPotionEffect(new PotionEffect(this.potionId, this.potionDuration * 20, this.potionAmplifier)); } }
public List<PotionEffect> getEffects(int meta) { List<PotionEffect> list = (List)this.effectCache.get(Integer.valueOf(meta)); if (list == null) { list = PotionHelper.getPotionEffects(meta, false); this.effectCache.put(Integer.valueOf(meta), list); } return list; }
public EntityAreaEffectCloud(World worldIn) { super(worldIn); this.potion = PotionTypes.EMPTY; this.effects = Lists.<PotionEffect>newArrayList(); this.reapplicationDelayMap = Maps.<Entity, Integer>newHashMap(); this.duration = 600; this.waitTime = 20; this.reapplicationDelay = 20; this.noClip = true; this.isImmuneToFire = true; this.setRadius(3.0F); }
public boolean isPotionApplicable(PotionEffect potioneffectIn) { if (this.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD) { Potion potion = potioneffectIn.getPotion(); if (potion == MobEffects.REGENERATION || potion == MobEffects.POISON) { return false; } } return 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.WEAKNESS,MobUpkeepController.POTION_EFFECT_LENGTH,numChanges,false,true)); } }
@Override public void onEntityWalk(World world, BlockPos pos, Entity entity) { if (world.isRemote) return; if (entity instanceof EntityLivingBase) { EntityLivingBase living = (EntityLivingBase)entity; living.addPotionEffect(new PotionEffect(Thermionics.POTION_EFFORTLESS_SPEED, 20, level)); } }
@Override public void handleDamageEvent(LivingAttackEvent event) { super.handleDamageEvent(event); if(!(event.getEntity() instanceof EntityLivingBase)) return; EntityLivingBase hitEntity = (EntityLivingBase)event.getEntity(); EntityLiving cause = (EntityLiving)event.getSource().getTrueSource(); int level = MobNBTHandler.getModifierLevel(cause,identifier); hitEntity.addPotionEffect(new PotionEffect(effect, duration,level,false,false)); }
@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 void onFinishedPotionEffect(PotionEffect p_70688_1_) { this.potionsNeedUpdate = true; if (!this.worldObj.isRemote) { Potion.potionTypes[p_70688_1_.getPotionID()].removeAttributesModifiersFromEntity(this, this.getAttributeMap(), p_70688_1_.getAmplifier()); } }
@Override public PotionEffect removeActivePotionEffect(Potion potioneffectin) { if (m_realPlayer == null) { return super.removeActivePotionEffect(potioneffectin); } else { syncToRealPlayer(); return syncPublicFieldsFromRealAndReturn(m_realPlayer.removeActivePotionEffect(potioneffectin)); } }
public void handleEntityEffect(S1DPacketEntityEffect packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId()); if (entity instanceof EntityLivingBase) { PotionEffect potioneffect = new PotionEffect(packetIn.getEffectId(), packetIn.getDuration(), packetIn.getAmplifier(), false, packetIn.func_179707_f()); potioneffect.setPotionDurationMax(packetIn.func_149429_c()); ((EntityLivingBase)entity).addPotionEffect(potioneffect); } }
/** * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using * the Item before the action is complete. */ public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn) { if (!playerIn.capabilities.isCreativeMode) { --stack.stackSize; } if (!worldIn.isRemote) { List<PotionEffect> list = this.getEffects(stack); if (list != null) { for (PotionEffect potioneffect : list) { playerIn.addPotionEffect(new PotionEffect(potioneffect)); } } } playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]); if (!playerIn.capabilities.isCreativeMode) { if (stack.stackSize <= 0) { return new ItemStack(Items.glass_bottle); } playerIn.inventory.addItemStackToInventory(new ItemStack(Items.glass_bottle)); } return stack; }
@Override @SideOnly(Side.CLIENT) @SuppressWarnings({ "rawtypes", "unchecked" }) public void getSubItems(Item item, CreativeTabs tab, List list) { List<ItemStack> potions = new ArrayList<ItemStack>(); ModItems.lingering_potion.getSubItems(ModItems.lingering_potion, tab, potions); for (ItemStack potion : potions) { List<PotionEffect> effects = PotionHelper.getPotionEffects(potion.getItemDamage(), false); if (effects != null && !effects.isEmpty()) for (PotionEffect effect : effects) list.add(setEffect(new ItemStack(this), Potion.potionTypes[effect.getPotionID()], effect.getDuration() / 2)); } }
/** * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory */ public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) { livingdata = super.onInitialSpawn(difficulty, livingdata); if (this.worldObj.rand.nextInt(100) == 0) { EntitySkeleton entityskeleton = new EntitySkeleton(this.worldObj); entityskeleton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); entityskeleton.onInitialSpawn(difficulty, (IEntityLivingData)null); this.worldObj.spawnEntityInWorld(entityskeleton); entityskeleton.mountEntity(this); } if (livingdata == null) { livingdata = new EntitySpider.GroupData(); if (this.worldObj.getDifficulty() == EnumDifficulty.HARD && this.worldObj.rand.nextFloat() < 0.1F * difficulty.getClampedAdditionalDifficulty()) { ((EntitySpider.GroupData)livingdata).func_111104_a(this.worldObj.rand); } } if (livingdata instanceof EntitySpider.GroupData) { int i = ((EntitySpider.GroupData)livingdata).potionEffectId; if (i > 0 && Potion.potionTypes[i] != null) { this.addPotionEffect(new PotionEffect(i, Integer.MAX_VALUE)); } } return livingdata; }
@Override public void apply(World world, BlockPos pos, EntityLivingBase entity, int amplifier, int tick) { entity.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 400, 1)); entity.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 6000, 0)); entity.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 6000, 0)); entity.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 2400, 3)); }
@Override public void onArmorTick(World world, final EntityPlayer player, ItemStack itemStack) { if (!world.isRemote) { if (player.ticksExisted % 20 == 0) { float heal = TF2Attribute.getModifier("Health Regen", itemStack, 0, player); if(heal > 0) { int lastHitTime = player.ticksExisted - player.getEntityData().getInteger("lasthit"); if (lastHitTime >= 120) player.heal(heal); else if(lastHitTime >= 60) player.heal(TF2Util.lerp(heal, heal/4f, (lastHitTime-60)/60f)); else player.heal(heal/4f); } } if (player.ticksExisted % 5 == 0 && itemStack.getTagCompound().getBoolean("Active")) { itemStack.getTagCompound().setFloat("Rage", Math.max(0, itemStack.getTagCompound().getFloat("Rage") - 1 / (TF2Attribute.getModifier("Buff Duration", itemStack, getData(itemStack).getInt(PropertyType.DURATION), player) - 20))); if (itemStack.getTagCompound().getFloat("Rage") <= 0) itemStack.getTagCompound().setBoolean("Active", false); for (EntityLivingBase living : world.getEntitiesWithinAABB(EntityLivingBase.class, player.getEntityBoundingBox().grow(10, 10, 10), new Predicate<EntityLivingBase>() { @Override public boolean apply(EntityLivingBase input) { // TODO Auto-generated method stub return TF2Util.isOnSameTeam(player, input); } })) living.addPotionEffect(new PotionEffect(this.getBuff(itemStack), 25)); } if (player.isCreative()) itemStack.getTagCompound().setFloat("Rage", 1); } }
public static ItemStack setEffect(ItemStack stack, Potion potion, int duration) { stack.setTagCompound(new NBTTagCompound()); NBTTagCompound nbt = new NBTTagCompound(); stack.getTagCompound().setTag("Potion", nbt); PotionEffect effect = new PotionEffect(potion.getId(), potion.isInstant() ? 1 : duration); effect.writeCustomPotionEffectToNBT(nbt); return stack; }