Skip to content

Commit

Permalink
fix: Starve spell applies slowness, weakness and hunger on non-player…
Browse files Browse the repository at this point in the history
… targets. Hunger spell applies hunger and weakness on non-player targets. Fixes #209
  • Loading branch information
WinDanesz committed Jun 7, 2024
1 parent 575e548 commit 544567f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntityDispenser;
Expand All @@ -31,6 +32,9 @@ protected boolean onEntityHit(World world, Entity target, Vec3d hit,

EntityLivingBase targetEntity = (EntityLivingBase) target;
targetEntity.addPotionEffect(new PotionEffect(MobEffects.HUNGER, getProperty(EFFECT_DURATION).intValue(), getProperty(EFFECT_STRENGTH).intValue()));
if (!(targetEntity instanceof EntityPlayer)) {
targetEntity.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, getProperty(EFFECT_DURATION).intValue(), getProperty(EFFECT_STRENGTH).intValue()));
}
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.tileentity.TileEntityDispenser;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
Expand Down Expand Up @@ -36,6 +37,11 @@ protected boolean onEntityHit(World world, Entity target, Vec3d hit,
targetPlayer.getFoodStats().addExhaustion((int) (saturation / 2));

return true;
} else if (target instanceof EntityLivingBase) {
EntityLivingBase entityLivingBase = (EntityLivingBase) target;
entityLivingBase.addPotionEffect(new net.minecraft.potion.PotionEffect(net.minecraft.init.MobEffects.HUNGER, 200, 2));
entityLivingBase.addPotionEffect(new net.minecraft.potion.PotionEffect(MobEffects.SLOWNESS, 200, 1));
entityLivingBase.addPotionEffect(new net.minecraft.potion.PotionEffect(MobEffects.WEAKNESS, 200, 1));
}
return false;
}
Expand Down

0 comments on commit 544567f

Please sign in to comment.