Jump to content

[1.19.3, SOLVED] Make custom mob spawn high in the air


LeeCrafts

Recommended Posts

I want my custom mob to spawn high in the sky (like at y-level 192), as it's supposed to be a flying mob. I've noticed that my mob is able to spawn in the air, but only nearby solid blocks at the y-level where I want it to spawn.

Here is my code below that listens to the SpawnPlacementRegisterEvent:

@SubscribeEvent
public static void onSpawnPlacementRegisterEvent(SpawnPlacementRegisterEvent event) {
    event.register(ModEntityTypes.CUSTOM_MOB.get(),
            SpawnPlacements.Type.NO_RESTRICTIONS, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES,
            CustomMob::checkCustomMobSpawnRules, SpawnPlacementRegisterEvent.Operation.OR);
}
// (CustomMob::checkCustomMobSpawnRules checks if the BlockPos is in the air)
Edited by LeeCrafts
Link to comment
Share on other sites

First you are telling it to spawn on top of blocks that are not leaves "Heightmap.Types.MOTION_BLOCKING_NO_LEAVES".

 

But I don't think spawning in the air is possible for natural spawns.

Even if you wrote your own HeightMap.Types, the code is hardwired to ignore BlockState.isAir().

e.g. see NaturalSpawner.getTopNonCollidingPos() which determines the y location of spawns.

 

In vanilla. flying mobs naturally spawn on the ground. e.g. "slabbing your nether" stops ghast spawns.

It's only mob spawners or hardwired things like the dragon fight that can spawn in the air.

  • Like 1

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

  • LeeCrafts changed the title to [1.19.3, SOLVED] Make custom mob spawn high in the air

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.