Giving a potion effect to the player who killed a mob

Started by Toffeekukki on

Topic category: Help with Minecraft modding (Java Edition)

Joined Oct 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Giving a potion effect to the player who killed a mob
Wed, 11/01/2017 - 09:02 (edited)

I wanted my item to give the player mining fatuge if used to kill a mob, the mob got the mining fatuge.
so to test if i did something wrong i changed the effct to speed 50 then level 10 and jump boost 40 and level 20 although this did make me laugh alot it is not what i wanted. 
how do i correct this so it gives the player a bad potion effect rather than the mob that is killed?

Edited by Toffeekukki on Wed, 11/01/2017 - 09:02
Joined Sep 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
use this code;
Thu, 10/26/2017 - 21:13

use this code;

[spoiler]

@Override public boolean hitEntity(ItemStack itemstack, EntityLivingBase entity, EntityLivingBase entity2) { int i = (int) entity.posX; int j = (int) entity.posY; int k = (int) entity.posZ; World world = entity.world; if (true) { if (entity instanceof EntityLivingBase) ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.MINING_FATIGUE, 20, 0)); }   return true; }

[/spoiler]

and import all of these

[spoiler]import net.minecraft.init.MobEffects;[/spoiler]

[spoiler]import net.minecraft.entity.EntityLivingBase;[/spoiler]

[spoiler]import net.minecraft.potion.PotionEffect;[/spoiler]

 

 

 

 

Joined Sep 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sorry, I read your post wrong
Thu, 10/26/2017 - 21:21

Sorry, I read your post wrong, I thought you said you wanted to give the mob a potion effect, my bad