Example usage for net.minecraftforge.event.entity.living LivingSpawnEvent.CheckSpawn getWorld

List of usage examples for net.minecraftforge.event.entity.living LivingSpawnEvent.CheckSpawn getWorld

Introduction

In this page you can find the example usage for net.minecraftforge.event.entity.living LivingSpawnEvent.CheckSpawn getWorld.

Prototype

public IWorld getWorld() 

Source Link

Usage

From source file:vazkii.quark.world.feature.Wraiths.java

License:Creative Commons License

@SubscribeEvent
public void onSpawn(LivingSpawnEvent.CheckSpawn event) {
    if (event.getResult() != Result.ALLOW && event.getEntityLiving() instanceof IMob
            && event.getWorld() instanceof WorldServer) {
        List<EntityPlayer> players = ((WorldServer) event.getWorld()).playerEntities;
        for (EntityPlayer player : players)
            if (player.getActivePotionEffect(curse) != null
                    && player.getDistanceSq(event.getEntity()) < curseRange * curseRange) {
                if (!(event.getEntity() instanceof EntityCreeper))
                    event.getEntityLiving().addPotionEffect(
                            new PotionEffect(MobEffects.FIRE_RESISTANCE, Integer.MAX_VALUE, 0, false, false));
                event.setResult(Result.ALLOW);
                return;
            }//w w  w  . java 2 s . c om
    }
}