Jump to content

Recommended Posts

Posted (edited)

Hello there! I am rewriting my old topic, just to make it more clear. I have a problem - I've got custom dimension with custom biomes, and I cannot make custom mob spawns working. Whenever I add a new mob spawn to my custom biome - it doesn't work - it is not spawned. The weird thing is some of the mobs actually work (in my case it's mystic bird and two common butterflies, but it's only 2 working out of... many).
I've been trying to learn and do some debugging - everything seems correct - the mobs are added to the new biomes spawns lists, and in debugging code seems like they are actually spawned.
So here are my important code parts:

ModEntities

Spoiler

public class ModEntities {

    public static EntityType<?> COMMON_BUTTERFLY1 = _null();
    public static EntityType<?> COMMON_BUTTERFLY2 = _null();
    public static EntityType<?> CLOUD_SHIMMER = _null();
    public static EntityType<?> ILLUKINI = _null();
    public static EntityType<?> RUBY_SILE = _null();
    public static EntityType<?> SKYLIGHT = _null();
    public static EntityType<?> BIG_TURTLE = _null();
    public static EntityType<?> BISON = _null();
    public static EntityType<?> CACTI_SPORE = _null();
    public static EntityType<?> CAMEL = _null();
    public static EntityType<?> CLOUD_OISTER = _null();
    public static EntityType<?> CLOUDY_SLIME = _null();
    public static EntityType<?> FLYING_SQUID = _null();
    public static EntityType<?> FUNGITE = _null();
    public static EntityType<?> GAZNOWEL = _null();
    public static EntityType<?> GECKO = _null();
    public static EntityType<?> HOWLER = _null();
    public static EntityType<?> JELLY_FISH = _null();
    public static EntityType<?> LIVING_FLOWER = _null();
    public static EntityType<?> MYSTIC_BIRD = _null();
    public static EntityType<?> PHASM = _null();
    public static EntityType<?> POISONOUS_SCORPION = _null();
    public static EntityType<?> SKYRAY = _null();
    public static EntityType<?> STRANGE_WANDERER = _null();
    public static EntityType<?> MYSTIC_WAND_SHOOT = _null();

    public static void initEntitiesFromRegistry(){
        COMMON_BUTTERFLY1 = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"common_butterfly1"));
        COMMON_BUTTERFLY2 = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"common_butterfly2"));
        CLOUD_SHIMMER = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"cloud_shimmer"));
        ILLUKINI = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"illukini"));
        RUBY_SILE = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"ruby_sile"));
        SKYLIGHT = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"skylight"));
        BIG_TURTLE = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"big_turtle"));
        BISON = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"bison"));
        CACTI_SPORE = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"cacti_spore"));
        CAMEL = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"camel"));
        CLOUD_OISTER = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"cloud_oister"));
        CLOUDY_SLIME = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"cloudy_slime"));
        FLYING_SQUID = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"flying_squid"));
        FUNGITE = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"fungite"));
        GAZNOWEL = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"gaznowel"));
        GECKO = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"gecko"));
        HOWLER = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"howler"));
        JELLY_FISH = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"jelly_fish"));
        LIVING_FLOWER = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"living_flower"));
        MYSTIC_BIRD = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"mystic_bird"));
        PHASM = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"phasm"));
        POISONOUS_SCORPION = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"poisonous_scorpion"));
        SKYRAY = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"skyray"));
        STRANGE_WANDERER = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"strange_wanderer"));
        MYSTIC_WAND_SHOOT = IRegistry.ENTITY_TYPE.get(new ResourceLocation(MOD_ID,"mystic_wand_shoot"));

    }

    public static void registerPlacementType(EntityType<?> type,EntitySpawnPlacementRegistry.SpawnPlacementType spawnType){
        EntitySpawnPlacementRegistry.register(type, spawnType, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES,null);
    }

    public static void registerPlacementTypes(){
        registerPlacementType(COMMON_BUTTERFLY1, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(COMMON_BUTTERFLY2, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(CLOUD_SHIMMER, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(ILLUKINI, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(RUBY_SILE, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(SKYLIGHT, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(BIG_TURTLE, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(BISON, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(CACTI_SPORE, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(CAMEL, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(CLOUD_OISTER, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(CLOUDY_SLIME, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(FLYING_SQUID, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(FUNGITE, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(GAZNOWEL, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(GECKO, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(HOWLER, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(JELLY_FISH, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(LIVING_FLOWER, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(MYSTIC_BIRD, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(PHASM, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(POISONOUS_SCORPION, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(SKYRAY, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);
        registerPlacementType(STRANGE_WANDERER, EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND);

    }

    private static void registerEntitySpawn(EntityType<? extends EntityLiving> type,EnumCreatureType creatureType, EntitySpawnPlacementRegistry.SpawnPlacementType spawnType,Biome[] biomes, int weight, int min, int max) {
        for (Biome biome : biomes) {
            if (biome != null) {
                if(biome instanceof BiomeKatharianBiomeBase){
                    ((BiomeKatharianBiomeBase) biome).addSpawn(creatureType,new Biome.SpawnListEntry( type, weight, min, max));
                }
            }
        }
    }

    public static void registerEntitySpawns(){
        EntitySpawnPlacementRegistry.SpawnPlacementType ON_GROUND = EntitySpawnPlacementRegistry.SpawnPlacementType.ON_GROUND;
        ((BiomeKatharianBiomeBase)(ModBiomes.KATHARIAN_DESERT)).addSpawn(EnumCreatureType.CREATURE,new Biome.SpawnListEntry((EntityType<? extends EntityLiving>) ModEntities.BIG_TURTLE,12,1,1));
        ModBiomes.KATHARIAN_DESERT.getSpawns(EnumCreatureType.CREATURE).add(
          new Biome.SpawnListEntry((EntityType<? extends EntityLiving>)ModEntities.BIG_TURTLE,12,1,1)
        );
        ModBiomes.KATHARIAN_DESERT_EDGE.getSpawns(EnumCreatureType.CREATURE).add(
                new Biome.SpawnListEntry((EntityType<? extends EntityLiving>)ModEntities.BIG_TURTLE,12,1,1)
        );
        ModBiomes.SOFT_SAND_LAKES.getSpawns(EnumCreatureType.CREATURE).add(
                new Biome.SpawnListEntry((EntityType<? extends EntityLiving>)ModEntities.BIG_TURTLE,12,1,1)
        );
        ModBiomes.KATHARIAN_FOREST.getSpawns(EnumCreatureType.CREATURE).add(
                new Biome.SpawnListEntry((EntityType<? extends EntityLiving>)ModEntities.MYSTIC_BIRD,12,1,3)
        );
        ModBiomes.KATHARIAN_SWAMP.getSpawns(EnumCreatureType.CREATURE).add(
                new Biome.SpawnListEntry((EntityType<? extends EntityLiving>)ModEntities.MYSTIC_BIRD,12,1,3)
        );
        ModBiomes.KATHARIAN_DENSE_FOREST.getSpawns(EnumCreatureType.CREATURE).add(
                new Biome.SpawnListEntry((EntityType<? extends EntityLiving>)ModEntities.MYSTIC_BIRD,12,1,3)
        );
        ModBiomes.PLAIN_FIELDS.getSpawns(EnumCreatureType.CREATURE).add(
                new Biome.SpawnListEntry((EntityType<? extends EntityLiving>)ModEntities.MYSTIC_BIRD,12,1,3)
        );
        registerEntitySpawn((EntityType<? extends EntityLiving>)POISONOUS_SCORPION,EnumCreatureType.MONSTER,ON_GROUND,new Biome[]{ModBiomes.KATHARIAN_DESERT,ModBiomes.KATHARIAN_DESERT_EDGE,ModBiomes.SOFT_SAND_LAKES},3,1,1);
        registerEntitySpawn((EntityType<? extends EntityLiving>)CAMEL,EnumCreatureType.CREATURE,ON_GROUND,new Biome[]{ModBiomes.KATHARIAN_DESERT,ModBiomes.KATHARIAN_DESERT_EDGE,ModBiomes.SOFT_SAND_LAKES},6,1,1);
        registerEntitySpawn((EntityType<? extends EntityLiving>)GECKO,EnumCreatureType.CREATURE,ON_GROUND,new Biome[]{ModBiomes.KATHARIAN_FOREST},4,1,1);
        registerEntitySpawn((EntityType<? extends EntityLiving>)LIVING_FLOWER,EnumCreatureType.CREATURE,ON_GROUND,new Biome[]{ModBiomes.KATHARIAN_FOREST},8,1,1);
        registerEntitySpawn((EntityType<? extends EntityLiving>)HOWLER,EnumCreatureType.MONSTER,ON_GROUND,new Biome[]{ModBiomes.KATHARIAN_FOREST},5,1,1);
        //registerEntitySpawn(ModEntities.FUNGITE,EnumCreatureType.MONSTER,ON_GROUND,new Biome[]{ModBiomes.KATHARIAN_FOREST},2,1,1);
        //registerEntitySpawn(ModEntities.CACTI_SPORE,EnumCreatureType.CREATURE,ON_GROUND,new Biome[]{ModBiomes.KATHARIAN_FOREST},4,1,1);
        //registerEntitySpawn(ModEntities.JELLY_FISH,EnumCreatureType.CREATURE,ON_GROUND,new Biome[]{ModBiomes.PLAIN_FIELDS},10,1,2);
        //registerEntitySpawn(ModEntities.BISON,EnumCreatureType.CREATURE,ON_GROUND,new Biome[]{ModBiomes.PLAIN_FIELDS},8,2,4);
        registerEntitySpawn((EntityType<? extends EntityLiving>)COMMON_BUTTERFLY1,EnumCreatureType.CREATURE,ON_GROUND,new Biome[]{ModBiomes.PLAIN_FIELDS},10,1,1);
        registerEntitySpawn((EntityType<? extends EntityLiving>)COMMON_BUTTERFLY2,EnumCreatureType.CREATURE,ON_GROUND,new Biome[]{ModBiomes.PLAIN_FIELDS},10,1,1);
        registerEntitySpawn((EntityType<? extends EntityLiving>)PHASM,EnumCreatureType.MONSTER,ON_GROUND,new Biome[]{ModBiomes.KATHARIAN_SWAMP},2,1,1);
    }
}

 


My ModSubscriber (register things and such):

Spoiler

	@SubscribeEvent
	public static void onRegisterEntityTypes(final RegistryEvent.Register<EntityType<?>> event){
		event.getRegistry().registerAll(
				setup(EntityType.Builder.create(EntityButterfly.class, EntityButterfly::new).build("kathairis:common_butterfly1"),"common_butterfly1"),
				setup(EntityType.Builder.create(EntityButterfly1.class, EntityButterfly1::new).build("kathairis:common_butterfly2"),"common_butterfly2"),
				setup(EntityType.Builder.create(EntityCloudShimmer.class, EntityCloudShimmer::new).build("kathairis:cloud_shimmer"),"cloud_shimmer"),
				setup(EntityType.Builder.create(EntityIllukini.class, EntityIllukini::new).tracker(200, 1, true).build("kathairis:illukini"),"illukini"),
				setup(EntityType.Builder.create(EntityRubySile.class, EntityRubySile::new).tracker(200, 1, true).build("kathairis:ruby_sile"),"ruby_sile"),
				setup(EntityType.Builder.create(EntitySkylight.class, EntitySkylight::new).tracker(200, 1, true).build("kathairis:skylight"),"skylight"),
				setup(EntityType.Builder.create(EntityBigTurtle.class, EntityBigTurtle::new).tracker(200, 1, true).build("kathairis:big_turtle"),"big_turtle"),
				setup(EntityType.Builder.create(EntityBison.class, EntityBison::new).tracker(32, 1, true).build("kathairis:bison"),"bison"),
				setup(EntityType.Builder.create(EntityCactiSpore.class, EntityCactiSpore::new).tracker(32, 1, true).build("kathairis:cacti_spore"),"cacti_spore"),
				setup(EntityType.Builder.create(EntityCamel.class, EntityCamel::new).tracker(32, 1, true).build("kathairis:camel"),"camel"),
				setup(EntityType.Builder.create(EntityCloudOister.class, EntityCloudOister::new).tracker(32, 1, true).build("kathairis:cloud_oister"),"cloud_oister"),
				setup(EntityType.Builder.create(EntityCloudySlime.class, EntityCloudySlime::new).tracker(32, 1, true).build("kathairis:cloudy_slime"),"cloudy_slime"),
				setup(EntityType.Builder.create(EntityFlyingSquid.class, EntityFlyingSquid::new).tracker(32, 1, true).build("kathairis:flying_squid"),"flying_squid"),
				setup(EntityType.Builder.create(EntityFungite.class, EntityFungite::new).tracker(32, 1, true).build("kathairis:fungite"),"fungite"),
				setup(EntityType.Builder.create(EntityGaznowel.class, EntityGaznowel::new).tracker(32, 1, true).build("kathairis:gaznowel"),"gaznowel"),
				setup(EntityType.Builder.create(EntityGecko.class, EntityGecko::new).tracker(32, 1, true).build("kathairis:gecko"),"gecko"),
				setup(EntityType.Builder.create(EntityHowler.class, EntityHowler::new).tracker(32, 1, true).build("kathairis:howler"),"howler"),
				setup(EntityType.Builder.create(EntityJellyFish.class, EntityJellyFish::new).tracker(32, 1, true).build("kathairis:jelly_fish"),"jelly_fish"),
				setup(EntityType.Builder.create(EntityLivingFlower.class, EntityLivingFlower::new).tracker(32, 1, true).build("kathairis:living_flower"),"living_flower"),
				setup(EntityType.Builder.create(EntityMysticBird.class, EntityMysticBird::new).tracker(32, 1, true).build("kathairis:mystic_bird"),"mystic_bird"),
				setup(EntityType.Builder.create(EntityPhasm.class, EntityPhasm::new).tracker(32, 1, true).build("kathairis:phasm"),"phasm"),
				setup(EntityType.Builder.create(EntityPoisonousScorpion.class, EntityPoisonousScorpion::new).tracker(32, 1, true).build("kathairis:poisonous_scorpion"),"poisonous_scorpion"),
				setup(EntityType.Builder.create(EntitySkyray.class, EntitySkyray::new).tracker(200, 1, true).build("kathairis:skyray"),"skyray"),
				setup(EntityType.Builder.create(EntityStrangeWanderer.class, EntityStrangeWanderer::new).tracker(200, 1, true).build("kathairis:strange_wanderer"),"strange_wanderer"),
				setup(EntityType.Builder.create(EntityMysticWandShoot.class, EntityMysticWandShoot::new).tracker(200, 1, true).build("kathairis:mystic_wand_shoot"),"mystic_wand_shoot")
		);
		ModEntities.initEntitiesFromRegistry();
		ModEntities.registerPlacementTypes();
		ModEntities.registerEntitySpawns();
	}

 


I've got also spawn eggs and the mobs can be normally spawned using these eggs. Also I can spawn these mobs with command properly. I know the code is not made in the proper way, but trust me I am trying to deal with the problem for few weeks actually, and I were trying ... a lot of combinations, ways, etc....

Edited by Krevik
Posted (edited)
1 hour ago, diesieben07 said:

Like I told you in your last post already: You need to go into the code in WorldEntitySpawner and check where it stops spawning. There are many checks that are done before a spawn succeeds (e.g.: WorldServer#canCreatureTypeSpawnHere, WorldEntitySpawner.canCreatureTypeSpawnAtLocation [which in turn calls into Block#canCreatureSpawn eventually, which checks a predefined list of blocks (!)] and more). If any of these return false, the entity will silently just not spawn.

Well the code goes properly to worldIn.spawnEntity, the only thing I am actually thinking of is that just before calling worldIn.spawnEntity there is such line of code in

public static void performWorldGenSpawning(IWorld worldIn, Biome biomeIn, int centerX, int centerZ, Random diameterX)

:

                        ientitylivingdata = entityliving.onInitialSpawn(worldIn.getDifficultyForLocation(new BlockPos(entityliving)), ientitylivingdata, (NBTTagCompound)null);

and it is null, however as far as I am concerned entity living data actually can be null, so I guess it's not a problem. So at the end worldIn.spawnEntity is called, but there's no mob visible on the map. So it goes through all the checks.

Edited by Krevik
Posted
6 hours ago, diesieben07 said:

Does the entity receive updates? Have you checked with the debugger what happens in spawnEntity?

Finally got it working.... Seems that I am complete debugging dumb and I cannot even properly read debugger. So: The problem was, that spawnable Block is set to grass block in canSpawn() method in EntityAnimal class. It was enough to change the canSpawn() method to accept also other blocks. Thank you @diesieben07 for your patience and help - maybe I cannot debug but after all I learned something.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.