Jump to content

[1.14.4] How to add dimension checks to my mob spawning conditions?


Recommended Posts

Posted

As the title says, how would I go about checking the dimension and not just the biome from scratch ? I've had some users of my mod say a sky dimension was spawning my monsters in it because it used vanilla biomes in its generator, so I wanted to add a an additional check to my mob spawning conditions to make sure that its only the overworld/end/nether variants of the biomes and not random dimensions!

 

My Entity Registration/Spawning Code

public class ExplorerEntities {
    private static List<EntityType> entities = Lists.newArrayList();
    private static List<Item> spawnEggs = Lists.newArrayList();

   
    public static final EntityType<EnderreeperEntity> ENDERREEPER = createEntity(EnderreeperEntity.class, EnderreeperEntity::new, EntityClassification.MONSTER, "enderreeper", 0.6F, 1.99F, 3801171, 7078066);

  	/* Unneeded Code Redacted */

    @SubscribeEvent
    public static void registerEntities(RegistryEvent.Register<EntityType<?>> event) {
        for (EntityType entity : entities) {
            event.getRegistry().register(entity);
        }

        EntitySpawnPlacementRegistry.register(ENDERREEPER, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::func_223325_c);


  

    private static void registerEntityWorldSpawn(EntityType<?> type, int weight, int minCount, int maxCount, Biome... biomes) {
        for(Biome biome : biomes) {
            if(biome != null) {
                biome.getSpawns(type.getClassification()).add(new Biome.SpawnListEntry(type, weight, minCount, maxCount));
            }
        }
    }

    public static void registerEntityWorldSpawns() {

        if(EntityConfig.enderreeper_enabled.get()) {
            registerEntityWorldSpawn(ENDERREEPER, 5, 1, 2, Biomes.THE_END);
            registerEntityWorldSpawn(ENDERREEPER, 8, 1, 2, Biomes.END_BARRENS, Biomes.SMALL_END_ISLANDS, Biomes.END_HIGHLANDS, Biomes.END_MIDLANDS);
        }
        //&& DimensionType.getById(0) == DimensionType.OVERWORLD
        if(EntityConfig.enderreeper_overworld_spawn_enabled.get()) {
            EnderreeperEntity.addSpawn();
        }

        if(EntityConfig.enderreeper_nether_spawn_enabled.get()) {
            registerEntityWorldSpawn(ENDERREEPER, 5, 1, 2, Biomes.NETHER);
        }
    }
}

 

My Enderreeper addSpawn() code:

 //==== Spawning ====//
public static void addSpawn() {
  ForgeRegistries.BIOMES.getValues().stream().forEach(EnderreeperEntity::processSpawning);
}

private static void processSpawning(Biome biome) {

  if (biome != Biomes.MUSHROOM_FIELDS || biome != Biomes.MUSHROOM_FIELD_SHORE || biome != Biomes.NETHER) {
    biome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(ExplorerEntities.ENDERREEPER, 2, 1, 1));
  }

}

 

How would I go about this? unfortunately i've been away from modding for a good few months and i'm rusty as hell, so any help regarding this would be massively appreciative! Many Thanks

Posted

How does vanilla do it for Zombie Pigmen?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted (edited)

The zombie pigmen are just spawned as a spawn condition on the nether biome, aren't they? I'm not having a problem spawning them in the dimension, its adding additional checks to make sure that it is a particular dimension, so my mobs don't randomly spawn in say, a birch forest biome on a sky island in the sky dimension mod.

 

this.addSpawn(EntityClassification.MONSTER, new SpawnListEntry(EntityType.ZOMBIE_PIGMAN, 100, 4, 4));

 

I'm basically, trying to clean up some of the bugs in my 1.14 version to make it more polished before working on my 1.15 version, so hopefully, someone can help me figure this out :P

Edited by Zathrox
Posted (edited)
On 2/8/2020 at 3:54 PM, Zathrox said:

MonsterEntity::func_223325_c

Check that method out, then write your own and replace this in the EntitySpawnPlacementRegistry call.

Edited by Ugdhar

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.