Started by
Toffeekukki
on
Topic category: Help with Minecraft modding (Java Edition)
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
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]
Sorry, I read your post wrong, I thought you said you wanted to give the mob a potion effect, my bad