/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Nov 3, 2014, 12:13:09 AM (GMT)]
*/
package vazkii.botania.common.brew.potion;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import vazkii.botania.common.brew.ModPotions;
import vazkii.botania.common.lib.LibPotionNames;
public class PotionBloodthirst extends PotionMod {
private static final int RANGE = 64;
public PotionBloodthirst() {
super(LibPotionNames.BLOODTHIRST, false, 0xC30000, 3);
MinecraftForge.EVENT_BUS.register(this);
setBeneficial();
}
@SubscribeEvent
public void onSpawn(LivingSpawnEvent.CheckSpawn event) {
if(event.getResult() != Result.ALLOW && event.getEntityLiving() instanceof IMob) {
AxisAlignedBB aabb = new AxisAlignedBB(event.getX() - RANGE, event.getY() - RANGE, event.getZ() - RANGE, event.getX() + RANGE, event.getY() + RANGE, event.getZ() + RANGE);
for(EntityPlayer player : event.getWorld().playerEntities) {
if(hasEffect(player) && !hasEffect(player, ModPotions.emptiness) && player.getEntityBoundingBox().intersectsWith(aabb)) {
event.setResult(Result.ALLOW);
return;
}
}
}
}
}