diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.java b/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.java index 44eadad2b..b9782a413 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.java @@ -34,13 +34,11 @@ public class PotionBloodthirst extends PotionMod { @SubscribeEvent public void onSpawn(LivingSpawnEvent.CheckSpawn event) { - if(event.getResult() != Result.ALLOW && event.entityLiving instanceof IMob) { - List players = event.world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(event.x - RANGE, event.y - RANGE, event.z - RANGE, event.x + RANGE, event.y + RANGE, event.z + RANGE)); - for(EntityPlayer player : players) - if(hasEffect(player) && !hasEffect(player, ModPotions.emptiness)) { - event.setResult(Result.ALLOW); - return; - } + if (event.getResult() != Result.ALLOW && event.entityLiving instanceof IMob) { + EntityPlayer player = event.world.getClosestPlayerToEntity(event.entityLiving, RANGE); + if (player != null && hasEffect(player) && !hasEffect(player, ModPotions.emptiness)) { + event.setResult(Result.ALLOW); + } } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java b/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java index 6d2b77ea0..da19ccb9a 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java @@ -33,13 +33,11 @@ public class PotionEmptiness extends PotionMod { @SubscribeEvent public void onSpawn(LivingSpawnEvent.CheckSpawn event) { - if(event.getResult() != Result.ALLOW && event.entityLiving instanceof IMob) { - List players = event.world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(event.x - RANGE, event.y - RANGE, event.z - RANGE, event.x + RANGE, event.y + RANGE, event.z + RANGE)); - for(EntityPlayer player : players) - if(hasEffect(player)) { - event.setResult(Result.DENY); - return; - } + if (event.getResult() != Result.ALLOW && event.entityLiving instanceof IMob) { + EntityPlayer player = event.world.getClosestPlayerToEntity(event.entityLiving, RANGE); + if (player != null && hasEffect(player)) { + event.setResult(Result.DENY); + } } }