List of usage examples for net.minecraftforge.event.entity.living LivingSpawnEvent.CheckSpawn getEntityLiving
public LivingEntity getEntityLiving()
From source file:hellfirepvp.astralsorcery.common.event.listener.EventHandlerEntity.java
License:Open Source License
@SubscribeEvent public void onSpawnTest(LivingSpawnEvent.CheckSpawn event) { if (event.getResult() == Event.Result.DENY) return; //Already denied anyway. EntityLivingBase toTest = event.getEntityLiving(); Vector3 at = Vector3.atEntityCorner(toTest); boolean mayDeny = Config.doesMobSpawnDenyDenyEverything || toTest.isCreatureType(EnumCreatureType.MONSTER, false); if (mayDeny) { for (Map.Entry<WorldBlockPos, TickTokenizedMap.SimpleTickToken<Double>> entry : spawnDenyRegions .entrySet()) {//from w ww. j a v a 2s . c o m if (!entry.getKey().getWorld().equals(toTest.getEntityWorld())) continue; if (at.distance(entry.getKey()) <= entry.getValue().getValue()) { event.setResult(Event.Result.DENY); return; } } } }
From source file:hellfirepvp.astralsorcery.common.event.listener.EventHandlerServer.java
License:Open Source License
@SubscribeEvent public void onSpawnTest(LivingSpawnEvent.CheckSpawn event) { if (event.getResult() == Event.Result.DENY) return; //Already denied anyway. EntityLivingBase toTest = event.getEntityLiving(); Vector3 at = new Vector3(toTest); boolean mayDeny = Config.doesMobSpawnDenyDenyEverything || toTest.isCreatureType(EnumCreatureType.MONSTER, false); if (mayDeny) { for (Map.Entry<WorldBlockPos, TickTokenizedMap.SimpleTickToken<Double>> entry : spawnDenyRegions .entrySet()) {/*from w w w. j a v a 2s . co m*/ if (!entry.getKey().getWorld().equals(toTest.getEntityWorld())) continue; if (at.distance(entry.getKey()) <= entry.getValue().getValue()) { event.setResult(Event.Result.DENY); return; } } } }
From source file:vazkii.quark.world.feature.NaturalBlazesInNether.java
License:Creative Commons License
@SubscribeEvent public void onSpawn(LivingSpawnEvent.CheckSpawn event) { if (restrictToNetherrack && !event.isSpawner() && event.getEntityLiving() instanceof EntityBlaze && event.getResult() != Result.DENY && event.getEntityLiving().world instanceof WorldServer) { EntityBlaze blaze = (EntityBlaze) event.getEntityLiving(); WorldServer world = (WorldServer) blaze.world; BlockPos pos = blaze.getPosition(); Block block = world.getBlockState(pos.down()).getBlock(); ResourceLocation res = block.getRegistryName(); if (res != null) { boolean allowedBlock = allowedBlocks.contains(res.toString()); boolean fortress = world.getChunkProvider().isInsideStructure(world, "Fortress", pos); if (!fortress && !allowedBlock) event.setResult(Result.DENY); }//www . j a v a2 s.c om } }
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; }/*from www. j av a2s . c o m*/ } }