private static int getSpawnMode(Chunk chunk, int x, int y, int z) { World world = chunk.getWorld(); BlockPos pos = new BlockPos(x, y, z); if (!SpawnerAnimals.canCreatureTypeSpawnAtLocation(SpawnPlacementType.ON_GROUND, world, pos) || chunk.getLightFor(EnumSkyBlock.BLOCK, pos) >= 8) return 0; c.set(x+0.2, y+0.01, z+0.2, x+0.8, y+1.8, z+0.8); AxisAlignedBB aabb = c.aabb(); if (!world.checkNoEntityCollision(aabb) || !world.getCollidingBoundingBoxes(dummyEntity, aabb).isEmpty() || world.isAnyLiquid(aabb)) return 0; if (chunk.getLightFor(EnumSkyBlock.SKY, pos) >= 8) return 1; return 2; }
private static int getSpawnMode(Chunk chunk, int x, int y, int z) { World world = chunk.getWorld(); BlockPos pos = new BlockPos(x, y, z); if (!WorldEntitySpawner.canCreatureTypeSpawnAtLocation(SpawnPlacementType.ON_GROUND, world, pos) || chunk.getLightFor(EnumSkyBlock.BLOCK, pos) >= 8) { return 0; } c.set(x + 0.2, y + 0.01, z + 0.2, x + 0.8, y + 1.8, z + 0.8); AxisAlignedBB aabb = c.aabb(); if (!world.checkNoEntityCollision(aabb) || !world.getEntitiesWithinAABBExcludingEntity(null, aabb).isEmpty() || world.containsAnyLiquid(aabb)) { return 0; } if (chunk.getLightFor(EnumSkyBlock.SKY, pos) >= 8) { return 1; } return 2; }
/** * Returns whether or not the specified creature type can spawn at the specified location. */ public static boolean canCreatureTypeSpawnAtLocation(EnumCreatureType creatureType, World world, BlockPos pos) { Block block = world.getBlockState(pos).getBlock(); Block belowblock = world.getBlockState(pos.down(1)).getBlock(); Block aboveblock = world.getBlockState(pos.up(1)).getBlock(); if (creatureType.getCreatureClass() == EntityWaterMob.class) { return block.getMaterial().isLiquid() && belowblock.getMaterial().isLiquid() && !aboveblock.isNormalCube(); } boolean spawnBlock = block != null && canCreatureSpawn(belowblock, world, pos.down(1), SpawnPlacementType.ON_GROUND); //System.out.println("tests: " + spawnBlock); return spawnBlock && block != Blocks.bedrock && !block.isNormalCube() && !block.getMaterial().isLiquid() && !aboveblock.isNormalCube(); }
public static void init() { int endermanEggColor1 = new Color(254, 85, 176).getRGB(); int endermanEggColor2 = new Color(97, 230, 150).getRGB(); EntityRegistry.registerModEntity(new ResourceLocation(ModGlobals.MODID, "enderman_evolved"), EntityEvolvedEnderman.class, "evolved_enderman", 0, EndermanEvolution.INSTANCE, 80, 3, false, 0, endermanEggColor2); EntityRegistry.registerModEntity(new ResourceLocation(ModGlobals.MODID, "frienderman"), EntityFrienderman.class, "frienderman", 1, EndermanEvolution.INSTANCE, 80, 3, false, 0, endermanEggColor1); EntityRegistry.registerModEntity(new ResourceLocation(ModGlobals.MODID, "friender_pearl"), EntityFrienderPearl.class, "friender_pearl", 2, EndermanEvolution.INSTANCE, 80, 3, true); EntityRegistry.registerModEntity(new ResourceLocation(ModGlobals.MODID, "evolved_endermite"), EntityEvolvedEndermite.class, "evolved_endermite", 4, EndermanEvolution.INSTANCE, 80, 3, false, new Color(1, 66, 16).getRGB(), endermanEggColor2); EntitySpawnPlacementRegistry.setPlacementType(EntityEvolvedEnderman.class, SpawnPlacementType.ON_GROUND); EntitySpawnPlacementRegistry.setPlacementType(EntityFrienderman.class, SpawnPlacementType.ON_GROUND); EntityRegistry.addSpawn(EntityEvolvedEnderman.class, ConfigOptions.ENDERMAN_PROBABILITY, 1, ConfigOptions.ENDERMAN_MAX_SPAWN, EnumCreatureType.MONSTER, getBiomeList()); EntityRegistry.addSpawn(EntityFrienderman.class, ConfigOptions.FRIENDERMAN_PROBABILITY, 1, ConfigOptions.FRIENDERMAN_MAX_SPAWN, EnumCreatureType.CREATURE, Biomes.SKY, Biomes.DESERT, Biomes.HELL); }
public static boolean canCreatureSpawn(Block block, IBlockAccess world, BlockPos pos, net.minecraft.entity.EntityLiving.SpawnPlacementType type) { IBlockState state = world.getBlockState(pos); if (block instanceof BlockSlab) { return (block.isFullBlock() || state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP); } else if (block instanceof BlockStairs) { return state.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP; } return block.isSideSolid(world, pos, EnumFacing.UP); }
@Override public boolean canCreatureSpawn(IBlockState state, IBlockAccess world, BlockPos pos, SpawnPlacementType type) { return super.canCreatureSpawn(state, world, pos, type); }
public static void init(){ ResourceLocation pigzombie = addEntity(EntityCrystalPigZombie.class, "crystalpigzombie"); EntityRegistry.registerEgg(pigzombie, /*PINK*/ 15373203, 0x6CE5F8); EntitySpawnPlacementRegistry.setPlacementType(EntityCrystalPigZombie.class, SpawnPlacementType.ON_GROUND); ResourceLocation cow = addEntity(EntityCrystalCow.class, "crystalcow"); EntityRegistry.registerEgg(cow, /*BROWN*/ 4470310, 0x6CE5F8); EntitySpawnPlacementRegistry.setPlacementType(EntityCrystalCow.class, SpawnPlacementType.ON_GROUND); ResourceLocation enderman = addEntity(EntityCrystalEnderman.class, "crystalenderman"); EntityRegistry.registerEgg(enderman, /*BLACK*/ 0, 0x6CE5F8); EntitySpawnPlacementRegistry.setPlacementType(EntityCrystalEnderman.class, SpawnPlacementType.ON_GROUND); addEntity(EntityMinionWorker.class, "minionworker"); addEntity(EntityMinionWarrior.class, "minionwarrior"); EntityCrystalChestMinecartBase.register(EntityCrystalChestMinecartBlue.class, CrystalChestType.BLUE); EntityCrystalChestMinecartBase.register(EntityCrystalChestMinecartRed.class, CrystalChestType.RED); EntityCrystalChestMinecartBase.register(EntityCrystalChestMinecartGreen.class, CrystalChestType.GREEN); EntityCrystalChestMinecartBase.register(EntityCrystalChestMinecartDark.class, CrystalChestType.DARK); EntityCrystalChestMinecartBase.register(EntityCrystalChestMinecartPure.class, CrystalChestType.PURE); EntityCrystalChestMinecartBase.register(EntityCrystalChestMinecartDarkIron.class, CrystalChestType.DARKIRON); for(Entry<CrystalChestType, Class<? extends EntityCrystalChestMinecartBase>> entry : EntityCrystalChestMinecartBase.minecarts.entrySet()){ addEntity(entry.getValue(), "minecart_chest_"+entry.getKey().name().toLowerCase(), 64, 1, true); } addEntity(EntityBombomb.class, "bombomb"); addEntity(EntityWirelessChestMinecart.class, "minecart_wirelesschest", 64, 1, true); addEntity(EntityEnderChestMinecart.class, "minecart_enderchest", 64, 1, true); addEntity(EntityGrapplingHook.class, "grapplinghook", 900, 1, true); addEntity(EntityCustomFallingBlock.class, "customfallingblock", 160, 20, true); ResourceLocation angel = addEntity(EntityAngel.class, "pureangel"); EntityRegistry.registerEgg(angel, 0xFFFFFF, 0xFFFF00); EntitySpawnPlacementRegistry.setPlacementType(EntityAngel.class, SpawnPlacementType.IN_AIR); ResourceLocation devil = addEntity(EntityDevil.class, "darkdevil"); EntityRegistry.registerEgg(devil, 0, 0xFFFF00); EntitySpawnPlacementRegistry.setPlacementType(EntityDevil.class, SpawnPlacementType.IN_AIR); addEntity(EntityDarkarang.class, "darkarang", 160, 20, true); addEntity(EntityDagger.class, "dagger", 160, 20, true); ResourceLocation tamedPolarBear = addEntity(EntityTamedPolarBear.class, "polarbear_tamed"); EntityRegistry.registerEgg(tamedPolarBear, 15921906, 9803152); addEntity(EntityBambooBoat.class, "bambooboat", 80, 3, true); addEntity(EntityDart.class, "dart", 64, 24, false); addEntity(EntityCrystalModPainting.class, "crystalmodpainting", 160, Integer.MAX_VALUE, false); }
protected static boolean canMobSpawn(@Nonnull final BlockPos pos) { return WorldEntitySpawner.canCreatureTypeSpawnAtLocation(SpawnPlacementType.ON_GROUND, EnvironState.getWorld(), pos); }
@Override public SpawnPlacementType getPlacementType() { return SpawnPlacementType.ON_GROUND; }
/** * {@inheritDoc} <br><br> * Mobs can't spawn on hypermatter. */ @Override public boolean canCreatureSpawn(IBlockState state, IBlockAccess world, BlockPos pos, SpawnPlacementType type) { return !this.isHypermatter() && super.canCreatureSpawn(state, world, pos, type); }
@Override public boolean canCreatureSpawn(IBlockState state, IBlockAccess world, BlockPos pos, SpawnPlacementType type) { return false; }
private static void registerEntities() { int modEntityIndex = 0; // PROJECTILES EntityRegistry.registerModEntity(EntityArrowBomb.class, "arrow_bomb", ++modEntityIndex, ZSSMain.instance, 64, 20, true); EntityRegistry.registerModEntity(EntityArrowCustom.class, "arrow_custom", ++modEntityIndex, ZSSMain.instance, 64, 20, true); EntityRegistry.registerModEntity(EntityArrowElemental.class, "arrow_elemental", ++modEntityIndex, ZSSMain.instance, 64, 20, true); EntityRegistry.registerModEntity(EntityBomb.class, "bomb", ++modEntityIndex, ZSSMain.instance, 64, 10, true); EntityRegistry.registerModEntity(EntityBombosFireball.class, "bombos_fireball", ++modEntityIndex, ZSSMain.instance, 64, 10, true); EntityRegistry.registerModEntity(EntityBoomerang.class, "boomerang", ++modEntityIndex, ZSSMain.instance, 64, 10, true); EntityRegistry.registerModEntity(EntityCeramicJar.class, "jar", ++modEntityIndex, ZSSMain.instance, 64, 10, true); EntityRegistry.registerModEntity(EntityCyclone.class, "cyclone", ++modEntityIndex, ZSSMain.instance, 64, 10, true); EntityRegistry.registerModEntity(EntityHookShot.class, "hookshot", ++modEntityIndex, ZSSMain.instance, 64, 10, true); EntityRegistry.registerModEntity(EntityLeapingBlow.class, "leaping_blow", ++modEntityIndex, ZSSMain.instance, 64, 10, true); EntityRegistry.registerModEntity(EntityMagicSpell.class, "magic_spell", ++modEntityIndex, ZSSMain.instance, 64, 10, true); EntityRegistry.registerModEntity(EntitySeedShot.class, "seedshot", ++modEntityIndex, ZSSMain.instance, 64, 10, true); EntityRegistry.registerModEntity(EntitySwordBeam.class, "sword_beam", ++modEntityIndex, ZSSMain.instance, 64, 10, true); EntityRegistry.registerModEntity(EntityThrowingRock.class, "rock", ++modEntityIndex, ZSSMain.instance, 64, 10, true); EntityRegistry.registerModEntity(EntityWhip.class, "whip", ++modEntityIndex, ZSSMain.instance, 64, 10, true); // NATURALLY SPAWNING MOBS EntityRegistry.registerModEntity(EntityDarknut.class, "darknut", ++modEntityIndex, ZSSMain.instance, 80, 3, true); CustomEntityList.addMapping(EntityDarknut.class, "darknut", 0x1E1E1E, 0x8B2500, 0x1E1E1E, 0xFB2500); EntitySpawnPlacementRegistry.setPlacementType(EntityDarknut.class, SpawnPlacementType.ON_GROUND); registerEntity(EntityFairy.class, "fairy", ++modEntityIndex, 80, 0xADFF2F, 0xFFFF00); EntitySpawnPlacementRegistry.setPlacementType(EntityFairy.class, SpawnPlacementType.ON_GROUND); EntityRegistry.registerModEntity(EntityNavi.class, "navi", ++modEntityIndex, ZSSMain.instance, 80, 3, true); EntityRegistry.registerModEntity(EntityChu.class, "chu", ++modEntityIndex, ZSSMain.instance, 80, 3, true); CustomEntityList.addMapping(EntityChu.class, "chu", 0x008000, 0xDC143C, 0x008000, 0x00EE00, 0x008000, 0x3A5FCD, 0x008000, 0xFFFF00); EntitySpawnPlacementRegistry.setPlacementType(EntityChu.class, SpawnPlacementType.ON_GROUND); registerEntity(EntityDekuBaba.class, "baba_deku", ++modEntityIndex, 80, 0x33CC33, 0x0000FF); registerEntity(EntityDekuFire.class, "baba_fire", ++modEntityIndex, 80, 0xFF0000, 0x0000FF); registerEntity(EntityDekuWithered.class, "baba_withered", ++modEntityIndex, 80, 0x8B5A00, 0x0000FF); EntityRegistry.registerModEntity(EntityKeese.class, "keese", ++modEntityIndex, ZSSMain.instance, 80, 3, true); CustomEntityList.addMapping(EntityKeese.class, "keese", 0x000000, 0x555555, 0x000000, 0xFF4500, 0x000000, 0x40E0D0, 0x000000, 0xFFD700, 0x000000, 0x800080); EntitySpawnPlacementRegistry.setPlacementType(EntityKeese.class, SpawnPlacementType.ON_GROUND); EntityRegistry.registerModEntity(EntityOctorok.class, "octorok", ++modEntityIndex, ZSSMain.instance, 80, 3, true); CustomEntityList.addMapping(EntityOctorok.class, "octorok", 0x68228B, 0xBA55D3, 0x68228B, 0xFF00FF); EntitySpawnPlacementRegistry.setPlacementType(EntityOctorok.class, SpawnPlacementType.IN_WATER); EntityRegistry.registerModEntity(EntitySkulltula.class, "skulltula", ++modEntityIndex, ZSSMain.instance, 80, 3, true); CustomEntityList.addMapping(EntitySkulltula.class, "skulltula", 0x080808, 0xFFFF00, 0x080808, 0xE68A00); EntitySpawnPlacementRegistry.setPlacementType(EntitySkulltula.class, SpawnPlacementType.ON_GROUND); EntityRegistry.registerModEntity(EntityWizzrobe.class, "wizzrobe", ++modEntityIndex, ZSSMain.instance, 80, 3, true); CustomEntityList.addMapping(EntityWizzrobe.class, "wizzrobe", 0x8B2500, 0xFF0000, 0x8B2500, 0x00B2EE, 0x8B2500, 0xEEEE00, 0x8B2500, 0x00EE76); EntitySpawnPlacementRegistry.setPlacementType(EntityWizzrobe.class, SpawnPlacementType.ON_GROUND); // BOSSES registerEntity(EntityBlackKnight.class, "darknut_boss", ++modEntityIndex, 80, 0x1E1E1E, 0x000000); registerEntity(EntityGrandWizzrobe.class, "wizzrobe_grand", ++modEntityIndex, 80, 0x8B2500, 0x1E1E1E); // NPCS registerEntity(EntityGoron.class, "goron", ++modEntityIndex, 80, 0xB8860B, 0x8B5A00); EntitySpawnPlacementRegistry.setPlacementType(EntityGoron.class, SpawnPlacementType.ON_GROUND); registerEntity(EntityNpcBarnes.class, "npc.barnes", ++modEntityIndex, 80, 0x8B8378, 0xED9121); registerEntity(EntityNpcMaskTrader.class, "npc.mask_trader", ++modEntityIndex, 80, 0x0000EE, 0x00C957); registerEntity(EntityNpcOrca.class, "npc.orca", ++modEntityIndex, 80, 0x0000EE, 0x9A32CD); registerEntity(EntityNpcZelda.class, "npc.zelda", ++modEntityIndex, 80, 0xCC0099, 0xFFFFFF); }
@Override public boolean canCreatureSpawn(IBlockAccess world, BlockPos pos, SpawnPlacementType type) { return false; }
@Override public boolean canCreatureSpawn(IBlockAccess world, BlockPos pos, SpawnPlacementType type) { return type == type.ON_GROUND ? false : true; }
public SpawnPlacementType getPlacementType();