Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Help applying potion effects to mobs

Recommended Posts

Hello everyone.

First of all I'm junior modder but I have some time programming on Java so everything is ok.


Now, here is my question.

How can I apply potion effects to entities(mobs and players)? I'm using 1.12.2


I made an enchantment for the sword, and I want to apply slowness to every entity I hit.

I tried a lot of things and I've researched a lot before come here so, here is my "subscribeEvent" method



	public static void enchantAttack(LivingAttackEvent event) {
		Object attacker = event.getSource().getTrueSource();		
		if(attacker instanceof EntityLivingBase ) {
			EntityLivingBase entityAttacker = (EntityLivingBase)attacker; 
			EntityAnimal picha = (EntityAnimal)attacker;
			int leve = EnchantmentHelper.getEnchantmentLevel(DAMAGE_HEAL, entityAttacker.getHeldItemMainhand());
			if(leve > 0) {
				picha.addPotionEffect(Potion.getPotionById(2), 100, 0);


Thanks :c







Link to post
Share on other sites
This topic is now closed to further replies.

  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.