Java Code Examples for net.minecraft.entity.EntityLivingBase#addPotionEffect()

The following examples show how to use net.minecraft.entity.EntityLivingBase#addPotionEffect() . 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: ComponentVision.java    From Artifacts with MIT License 6 votes vote down vote up
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean held) {
	//Check that the artifact is in a baubles slot if it should be
	if(DragonArtifacts.baublesLoaded && stack.stackTagCompound != null && 
			UtilsForComponents.equipableByBaubles(stack.stackTagCompound.getString("iconName")) && 
			DragonArtifacts.baublesMustBeEquipped && slot >= 0) {
		return;
	}
	
	if(!world.isRemote) {
		if(entity instanceof EntityLivingBase) {
			EntityLivingBase ent = (EntityLivingBase) entity;
			ent.addPotionEffect(new PotionEffect(16, 300, 0));
		}
	}
}
 
Example 2
Source File: ItemRidingCrop.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase victim, EntityLivingBase player) {
    stack.damageItem(1, player);
    if (victim instanceof EntityHorse || victim instanceof EntityPig)
        victim.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 200, 5));
    else if (victim instanceof EntityPlayer || victim instanceof EntityGolem) {
        victim.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 200, 1));
        victim.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 200, 1));
        victim.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 200, 1));
    }
    if (!player.worldObj.isRemote && !Config.noLust && player.worldObj.provider.dimensionId == -1 && player.worldObj.rand.nextInt(15) == 1) {
        EntityItem ent = victim.entityDropItem(new ItemStack(ForbiddenItems.deadlyShards, 1, 4), 1.0F);
        ent.motionY += player.worldObj.rand.nextFloat() * 0.05F;
        ent.motionX += (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.1F;
        ent.motionZ += (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.1F;
    }
    return true;
}
 
Example 3
Source File: ItemBloodRapier.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase victim, EntityLivingBase player) {
    stack.damageItem(1, player);
    victim.motionY *= 0.8;
    if (victim.hurtResistantTime > 18)
        victim.hurtResistantTime -= 5;
    if (Compat.bm & victim instanceof EntityPlayer) {
        String target = ((EntityPlayer) victim).getDisplayName();
        int lp = SoulNetworkHandler.getCurrentEssence(target);
        int damage = Math.max(4000, lp / 4);
        if (lp >= damage)
            lp -= damage;
        else
            lp = 0;
        SoulNetworkHandler.setCurrentEssence(target, lp);
        victim.addPotionEffect(new PotionEffect(DarkPotions.bloodSeal.getId(), 1200));
    }
    return true;
}
 
Example 4
Source File: ItemCybereyeUpgrade.java    From Cyberware with MIT License 6 votes vote down vote up
@SubscribeEvent
public void handleNightVision(CyberwareUpdateEvent event)
{
	EntityLivingBase e = event.getEntityLiving();
	ItemStack testItem = new ItemStack(this, 1, 0);
	if (CyberwareAPI.isCyberwareInstalled(e, testItem) && EnableDisableHelper.isEnabled(CyberwareAPI.getCyberware(e, testItem)))
	{

		e.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, Integer.MAX_VALUE, 53, true, false));
	}
	else
	{
		PotionEffect effect = e.getActivePotionEffect(MobEffects.NIGHT_VISION);
		if (effect != null && effect.getAmplifier() == 53)
		{
			e.removePotionEffect(MobEffects.NIGHT_VISION);
		}
	}
}
 
Example 5
Source File: BW_MetaGenerated_Items.java    From bartworks with MIT License 6 votes vote down vote up
@Override
public void onUpdate(ItemStack aStack, World aWorld, Entity aPlayer, int aTimer, boolean aIsInHand) {
    super.onUpdate(aStack, aWorld, aPlayer, aTimer, aIsInHand);
    if (aStack == null || aStack.getItem() == null || !(aPlayer instanceof EntityLivingBase))
        return;

    EntityLivingBase bPlayer = (EntityPlayer) aPlayer;
    Werkstoff w = werkstoffHashMap.get((short)aStack.getItemDamage());
    if (w == null || w.getStats() == null)
        return;

    if (w.getStats().isToxic() && !GT_Utility.isWearingFullBioHazmat(bPlayer)){
        bPlayer.addPotionEffect(new PotionEffect(Potion.poison.getId(),80,4));
    }

    if (w.getStats().isRadioactive() && !GT_Utility.isWearingFullRadioHazmat(bPlayer)){
        bPlayer.addPotionEffect(new PotionEffect(IC2Potion.radiation.id,80,4));
    }

}
 
Example 6
Source File: IPotionEffectExplodable.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
default void explode(Entity entityIn) {
	if (potions.isEmpty()) {
		potions.add(1);
		potions.add(3);
		potions.add(5);
		potions.add(8);
		potions.add(11);
		potions.add(12);
		potions.add(21);
	}

	Random rand = new Random();
	int range = 5;
	List<EntityLivingBase> entities = entityIn.world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(entityIn.posX - range, entityIn.posY - range, entityIn.posZ - range, entityIn.posX + range, entityIn.posY + range, entityIn.posZ + range));
	for (EntityLivingBase e : entities)
		e.addPotionEffect(new PotionEffect(Potion.getPotionById(potions.get(rand.nextInt(potions.size()))), rand.nextInt(30) * 20, rand.nextInt(2) + 1));

	ClientRunnable.run(new ClientRunnable() {
		@Override
		@SideOnly(Side.CLIENT)
		public void runIfClient() {
			LibParticles.FIZZING_EXPLOSION(entityIn.world, entityIn.getPositionVector());
		}
	});
}
 
Example 7
Source File: ComponentResistance.java    From Artifacts with MIT License 6 votes vote down vote up
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean held) {
	//Check that the artifact is in a baubles slot if it should be
	if(DragonArtifacts.baublesLoaded && stack.stackTagCompound != null && 
			UtilsForComponents.equipableByBaubles(stack.stackTagCompound.getString("iconName")) && 
			DragonArtifacts.baublesMustBeEquipped && slot >= 0) {
		return;
	}
	
	if(!world.isRemote) {
		if(entity instanceof EntityLivingBase) {
			EntityLivingBase ent = (EntityLivingBase) entity;
			ent.addPotionEffect(new PotionEffect(11, 10, 0));
		}
	}
}
 
Example 8
Source File: ComponentJumping.java    From Artifacts with MIT License 6 votes vote down vote up
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean held) {
	//Check that the artifact is in a baubles slot if it should be
	if(DragonArtifacts.baublesLoaded && stack.stackTagCompound != null && 
			UtilsForComponents.equipableByBaubles(stack.stackTagCompound.getString("iconName")) && 
			DragonArtifacts.baublesMustBeEquipped && slot >= 0) {
		return;
	}
	
	if(!world.isRemote) {
		if(entity instanceof EntityLivingBase) {
			EntityLivingBase ent = (EntityLivingBase) entity;
			ent.addPotionEffect(new PotionEffect(8, 10, 4));
		}
	}
}
 
Example 9
Source File: ItemSyringe.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onUsingTick(ItemStack stack, EntityLivingBase player, int count) {
	if (!(player instanceof EntityPlayer)) return;
	if (player.world.isRemote) return;

	if (count <= 1) {
		player.swingArm(player.getActiveHand());
		((EntityPlayer) player).getCooldownTracker().setCooldown(this, 30);

		if (stack.getItemDamage() == 2) {
			player.addPotionEffect(new PotionEffect(ModPotions.STEROID, 500, 0, true, false));
			stack.setItemDamage(0);
		} else if (stack.getItemDamage() == 1) {
			ManaManager.forObject(player)
					.addMana(ManaManager.getMaxMana(player))
					.close();
			player.attackEntityFrom(DamageSourceMana.INSTANCE, 2);
			stack.setItemDamage(0);
		} else if (stack.getItemDamage() == 0) {

			RayTraceResult raytraceresult = this.rayTrace(player.world, (EntityPlayer) player, true);

			if (raytraceresult != null && raytraceresult.typeOfHit != null && raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK) {
				BlockPos blockpos = raytraceresult.getBlockPos();
				if (raytraceresult.sideHit == null) raytraceresult.sideHit = EnumFacing.UP;

				if (player.world.isBlockModifiable((EntityPlayer) player, blockpos)
						&& ((EntityPlayer) player).canPlayerEdit(blockpos.offset(raytraceresult.sideHit), raytraceresult.sideHit, stack)) {

					IBlockState iblockstate = player.world.getBlockState(blockpos);

					Fluid fluid = FluidRegistry.lookupFluidForBlock(iblockstate.getBlock());
					if (fluid != null && fluid == ModFluids.MANA && iblockstate.getValue(BlockLiquid.LEVEL) == 0) {
						stack.setItemDamage(1);
					}
				}
			}
		}
	}
}
 
Example 10
Source File: PLPotion.java    From Production-Line with MIT License 5 votes vote down vote up
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 11
Source File: Minigun.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public boolean tryFireMinigun(EntityLivingBase target){
    boolean lastShotOfAmmo = false;
    if(ammo != null && (pressurizable == null || pressurizable.getPressure(stack) > 0)) {
        setMinigunTriggerTimeOut(Math.max(10, getMinigunSoundCounter()));
        if(getMinigunSpeed() == MAX_GUN_SPEED && (!requiresTarget || gunAimedAtTarget)) {
            if(!requiresTarget) target = raytraceTarget();
            lastShotOfAmmo = ammo.attemptDamageItem(1, rand);
            if(pressurizable != null) pressurizable.addAir(stack, -airUsage);
            if(target != null) {
                ItemStack potion = ItemGunAmmo.getPotion(ammo);
                if(potion != null) {
                    if(rand.nextInt(20) == 0) {
                        List<PotionEffect> effects = Items.potionitem.getEffects(potion);
                        if(effects != null) {
                            for(PotionEffect effect : effects) {
                                target.addPotionEffect(new PotionEffect(effect));
                            }
                        }
                    }
                } else {
                    target.attackEntityFrom(DamageSource.causePlayerDamage(player), Config.configMinigunDamage);
                }
            }
        }
    }
    return lastShotOfAmmo;
}
 
Example 12
Source File: AtmosphereHighPressure.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void onTick(EntityLivingBase player) {
	if(player.world.getTotalWorldTime() % 20  == 0 && !isImmune(player)) {
		if(!isImmune(player)) {
			player.addPotionEffect(new PotionEffect(Potion.getPotionById(2), 40, 3));
			player.addPotionEffect(new PotionEffect(Potion.getPotionById(4), 40, 3));
		}
	}
}
 
Example 13
Source File: ModuleEffectPoisonCloud.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean run(@NotNull World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	Vec3d position = spell.getTarget(world);
	BlockPos pos = spell.getTargetPos();

	if (position == null || pos == null) return true;

	if (!spellRing.taxCaster(world, spell, true)) return false;

	double potency = spellRing.getAttributeValue(world, AttributeRegistry.POTENCY, spell);

	double area = spellRing.getAttributeValue(world, AttributeRegistry.AREA, spell);

	if (world.getTotalWorldTime() % 2 == 0)
		world.playSound(null, pos, ModSounds.FIZZING_LOOP, SoundCategory.NEUTRAL, RandUtil.nextFloat(0.6f, 1f), RandUtil.nextFloat(0.1f, 4f));
	for (Entity entity : world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(new BlockPos(position)).grow(area, area, area))) {
		if (entity instanceof EntityLivingBase) {
			EntityLivingBase living = (EntityLivingBase) entity;
			if (potency >= 3) {
				living.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 100));
			}
			living.addPotionEffect(new PotionEffect(MobEffects.POISON, 60, (int) (potency / 3)));
		}
	}

	return true;
}
 
Example 14
Source File: SubTileBloodthorn.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
@Override
public void onUpdate() {
    super.onUpdate();
    if(redstoneSignal > 0)
        return;
    final int range = 6;
    final int cost = 40;
    List<EntityLivingBase> entities = supertile.getWorldObj().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - range, supertile.yCoord - range, supertile.zCoord - range, supertile.xCoord + range, supertile.yCoord + range, supertile.zCoord + range));
    for(EntityLivingBase entity : entities) {
        if(!(entity instanceof EntityPlayer) && entity.getActivePotionEffect(Potion.weakness) == null && mana >= cost && !entity.worldObj.isRemote) {
            entity.addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 2));
            mana -= cost;
        }
    }
}
 
Example 15
Source File: ComponentFoodie.java    From Artifacts with MIT License 5 votes vote down vote up
@Override
	public boolean hitEntity(ItemStack itemStack, EntityLivingBase entityLivingHit, EntityLivingBase entityLivingPlayer) {
		if(!entityLivingPlayer.worldObj.isRemote && entityLivingPlayer instanceof EntityPlayer) {
			entityLivingPlayer.addPotionEffect(new PotionEffect(23, 2, 0));
//			entityLivingPlayer.addPotionEffect(new PotionEffect(9, 200, 0));
			itemStack.damageItem(1, entityLivingPlayer);
		}
		return false;
	}
 
Example 16
Source File: ComponentResistance.java    From Artifacts with MIT License 5 votes vote down vote up
@Override
public boolean hitEntity(ItemStack itemStack, EntityLivingBase entityLivingHit, EntityLivingBase entityLivingPlayer) {
	if(!entityLivingPlayer.worldObj.isRemote) {
		entityLivingPlayer.addPotionEffect(new PotionEffect(11, 100, 0));
	}
	return false;
}
 
Example 17
Source File: ItemBaseBaubles.java    From Electro-Magic-Tools with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
	if (!player.worldObj.isRemote) {
		if (stack != null && stack.getItemDamage() == 0) {
			if (player instanceof EntityPlayer) {
				((EntityPlayer) player).capabilities.disableDamage = true;

				wornTick++;

				NBTTagCompound tag = new NBTTagCompound();
				tag.setInteger("MindCorruption", wornTick);
				((EntityPlayer) player).writeToNBT(tag);
				int corruption = tag.getInteger("MindCorruption");
				if (tag != null && corruption != wornTick) {
					wornTick = corruption;
				}

				if (corruption <= 0)
					((EntityPlayer) player).addChatMessage(new ChatComponentText(TextHelper.PURPLE + "You have worn the Ring. Your soul has now been forever " + TextHelper.PURPLE + "tainted. " + TextHelper.RED + TextHelper.ITALIC + "Beware of wearing the ring. The tainting will only " + TextHelper.RED + TextHelper.ITALIC + "increase, and strange things will start happening."));

				if (corruption > 6000 && corruption < 24000 && random.nextInt(2000) == 0)
					player.addPotionEffect(new PotionEffect(Potion.blindness.id, 500, 2, false));

				if (corruption >= 6000 && corruption < 24000 && random.nextInt(2000) == 0)
					player.addPotionEffect(new PotionEffect(Potion.confusion.id, 500, 2, false));

				if (corruption >= 24000 && corruption < 72000 && random.nextInt(2000) == 0) {
					for (int i = 0; i <= 5; i++)
						((EntityPlayer) player).capabilities.disableDamage = false;

					player.attackEntityFrom(DamageSource.magic, 5);
				}

				if (corruption >= 72000 && corruption < 120000 && random.nextInt(4000) == 0) {
					for (int i = 0; i <= 100; i++)
						((EntityPlayer) player).capabilities.disableDamage = false;

					player.motionY = 2;
				}

				if (corruption >= 120000 && random.nextInt(10000) == 0) {
					for (int i = 0; i <= 510; i++)
						((EntityPlayer) player).capabilities.disableDamage = false;

					player.addPotionEffect(new PotionEffect(Potion.wither.id, 5000, 4, false));
				}
			}
		}
	}
}
 
Example 18
Source File: BounceManager.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void forEntity(EntityLivingBase entity, int time) {
	entity.addPotionEffect(new PotionEffect(ModPotions.BOUNCING, time, 0, true, false));
}
 
Example 19
Source File: ItemElement.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void affectEntity(EntityLivingBase livingBase) {
    livingBase.addPotionEffect(new PotionEffect(Potion.blindness.getId(), 100, 0, true));
}
 
Example 20
Source File: EntityZundaArrow.java    From TofuCraftReload with MIT License 4 votes vote down vote up
protected void arrowHit(EntityLivingBase living) {
    super.arrowHit(living);
    PotionEffect potioneffect = new PotionEffect(MobEffects.REGENERATION, this.duration, 0);
    living.addPotionEffect(potioneffect);
}