Jump to content

[1.16] Steve spawns in the custom biome if though it isn't set as valid spawn


Recommended Posts

Posted (edited)

The title is very explanatory, I'd like to know if I'm mistaken about the isValidSpawnBiomeForPlayer(), or if there's something wrong with the code:

@Mod.EventBusSubscriber(modid = TutorialMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModBiomes {

    public static final DeferredRegister<Biome> BIOMES = DeferredRegister.create(ForgeRegistries.BIOMES, TutorialMod.MOD_ID);

    public static final RegistryObject<Biome> TEST_BIOME = BIOMES.register("test_biome", () -> Maker.TestBiome());

    @SubscribeEvent
    public static void setupBiomes(FMLCommonSetupEvent event) {
        event.enqueueWork(() ->
            setupBiome(TEST_BIOME.get(), BiomeManager.BiomeType.WARM, 1500,
                Type.FOREST, Type.COLD, Type.OVERWORLD, Type.WET)
        );
    }

    private static void setupBiome(Biome biome, BiomeManager.BiomeType biomeType, int weight, BiomeDictionary.Type... types) {
        RegistryKey<Biome> key = RegistryKey.getOrCreateKey(
            ForgeRegistries.Keys.BIOMES,
            Objects.requireNonNull(ForgeRegistries.BIOMES.getKey(biome), "Biome registry name was null"));

        BiomeDictionary.addTypes(key, types);
        BiomeManager.addBiome(biomeType, new BiomeManager.BiomeEntry(key, weight));
    }

    private static class Maker {

        private static MobSpawnInfo.Builder getStandardMobSpawnBuilder() {
            MobSpawnInfo.Builder mobspawninfo$builder = new MobSpawnInfo.Builder();
            DefaultBiomeFeatures.withPassiveMobs(mobspawninfo$builder);
            DefaultBiomeFeatures.withBatsAndHostiles(mobspawninfo$builder);
            return mobspawninfo$builder;
        }

        private static Biome TestBiome() {
            BiomeGenerationSettings genset = new BiomeGenerationSettings.Builder()
                .withCarver(GenerationStage.Carving.AIR, ConfiguredCarvers.field_243767_a)
                .withCarver(GenerationStage.Carving.AIR, ConfiguredCarvers.field_243768_b)
                .withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Features.FANCY_OAK)
                .withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Features.ORE_COAL)
                .withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Features.ORE_GOLD)
                .withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Features.ORE_IRON)
                .withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Features.ORE_DIAMOND)
                .withStructure(StructureFeatures.END_CITY)
                .withSurfaceBuilder(ConfiguredSurfaceBuilders.field_244178_j)
                .build();

            MobSpawnInfo mobSpawn = getStandardMobSpawnBuilder().copy();

            BiomeAmbience ambience = new BiomeAmbience.Builder()
                .withGrassColor(0xDA67C1)
                .setFogColor(0xEEEEEE)
                .setWaterColor(0xCF21B8)
                .setWaterFogColor(0xCF78C5)
                .withSkyColor(0xE83452)
                .withFoliageColor(0xCA57C1)
                .build();

            return new Biome.Builder()
                .category(Biome.Category.FOREST)
                .withTemperatureModifier(Biome.TemperatureModifier.NONE)
                .withGenerationSettings(genset)
                .withMobSpawnSettings(mobSpawn)
                .depth(0.123f)
                .scale(0.4f)
                .downfall(.4f)
                .precipitation(Biome.RainType.SNOW)
                .temperature(.8f)
                .setEffects(ambience)
                .build();
        }
    }
}

 

Edited by kiou.23

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.