@SubscribeEvent public static void onCheckSpawn(@Nonnull CheckSpawn evt) { if (evt.isSpawner()) { return; } final EntityLivingBase entityLiving = evt.getEntityLiving(); if (entityLiving == null) { return; } ResourceLocation resourceLocation = EntityList.getKey(entityLiving); if (resourceLocation == null) { return; } for (ISpawnEntry ent : MobSpawns.instance.getEntries()) { if (resourceLocation.toString().equals(ent.getMobName())) { if (!ent.canSpawnInDimension(evt.getWorld())) { // Log.debug(resourceLocation, " may not spawn in dimension ", evt.getWorld().provider.getDimensionType().getName()); evt.setResult(Result.DENY); return; } else { // Log.debug(resourceLocation, " is allowed to spawn in dimension ", evt.getWorld().provider.getDimensionType().getName()); } } } }
@SubscribeEvent public void onEntitySpawn(LivingSpawnEvent.CheckSpawn evt) { if (evt.getResult() == Result.DENY || evt.isSpawner()) { return; } if (InhibitorConfig.stopAllSlimes.get() && evt.getEntity() instanceof EntitySlime) { evt.setResult(Result.DENY); return; } if (InhibitorConfig.stopAllSquid.get() && evt.getEntity().getClass() == EntitySquid.class) { evt.setResult(Result.DENY); return; } Map<BlockPos, ISpawnCallback> guards = getGuardsForWorld(evt.getWorld()); for (ISpawnCallback guard : guards.values()) { ISpawnCallback.Result result = guard.isSpawnPrevented(evt.getEntityLiving()); if (result == ISpawnCallback.Result.DENY) { evt.setResult(Result.DENY); return; } else if (result == ISpawnCallback.Result.DONE) { return; } } }
@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); } } }