Search in sources :

Example 1 with BiomeType

use of net.minecraftforge.common.BiomeManager.BiomeType in project MinecraftForge by MinecraftForge.

the class EnumPlantTypeTest method onInit.

@Mod.EventHandler
public void onInit(FMLInitializationEvent event) {
    BiomeType biomeType = null;
    try {
        biomeType = BiomeType.getType("FAKE");
    } catch (NullPointerException npe) {
        LOGGER.warn("EnumHelper in BiomeType is working incorrectly!", npe);
    } finally {
        if (biomeType == null || !biomeType.name().equals("FAKE"))
            LOGGER.warn("EnumHelper in BiomeType is working incorrectly!");
    }
    EnumPlantType plantType = null;
    if (plantType == null || !plantType.name().equals("FAKE"))
        ;
    try {
        plantType = EnumPlantType.getPlantType("FAKE");
    } catch (NullPointerException npe) {
        LOGGER.warn("EnumHelper in EnumPlantType is working incorrectly!", npe);
    } finally {
        if (plantType == null || !plantType.name().equals("FAKE"))
            LOGGER.warn("EnumHelper in EnumPlantType is working incorrectly!");
    }
}
Also used : BiomeType(net.minecraftforge.common.BiomeManager.BiomeType) EnumPlantType(net.minecraftforge.common.EnumPlantType)

Example 2 with BiomeType

use of net.minecraftforge.common.BiomeManager.BiomeType in project BiomeTweaker by superckl.

the class PropertyGenWeight method set.

@Override
public void set(final Object obj, final Integer val) throws IllegalStateException, IllegalArgumentException {
    if (!(obj instanceof Biome))
        throw new IllegalArgumentException("Passed object is not an instance of Biome!");
    final int weight = val;
    final int id = Biome.getIdForBiome((Biome) obj);
    for (final BiomeType type : BiomeType.values()) {
        final List<BiomeEntry> entries = BiomeManager.getBiomes(type);
        for (final BiomeEntry entry : entries) if (Biome.getIdForBiome(entry.biome) == id)
            entry.itemWeight = weight;
        if ((type != BiomeManager.BiomeType.DESERT) && !PropertyGenWeight.logged.contains(type) && (WeightedRandom.getTotalWeight(entries) <= 0)) {
            APIInfo.log.warn("Sum of biome generation weights for type " + type + " is zero! This will cause Vanilla generation to crash! You have been warned!");
            PropertyGenWeight.logged.add(type);
        }
    }
    try {
        BiomeHelper.modTypeLists();
    } catch (final Exception e) {
        throw new IllegalStateException("Failed to set type lists as modded!", e);
    }
}
Also used : BiomeType(net.minecraftforge.common.BiomeManager.BiomeType) BiomeEntry(net.minecraftforge.common.BiomeManager.BiomeEntry) Biome(net.minecraft.world.biome.Biome)

Example 3 with BiomeType

use of net.minecraftforge.common.BiomeManager.BiomeType in project BiomeTweaker by superckl.

the class ScriptCommandRemoveBiome method perform.

@Override
public void perform() throws Exception {
    final Iterator<Biome> it = this.pack.getIterator();
    while (it.hasNext()) {
        final Biome gen = it.next();
        for (final BiomeType type : BiomeType.values()) for (final BiomeEntry entry : BiomeManager.getBiomes(type)) if (Biome.getIdForBiome(entry.biome) == Biome.getIdForBiome(gen))
            if (!MinecraftForge.EVENT_BUS.post(new BiomeTweakEvent.Remove(this, entry.biome, entry))) {
                BiomeManager.removeBiome(type, entry);
                if (BiomeManager.getBiomes(type).isEmpty())
                    LogHelper.warn("Viable generation biomes for type " + type + " is empty! This will cause Vanilla generation to crash! You've been warned!");
            }
        BiomeTweaker.getInstance().onTweak(Biome.getIdForBiome(gen));
    }
}
Also used : BiomeType(net.minecraftforge.common.BiomeManager.BiomeType) BiomeEntry(net.minecraftforge.common.BiomeManager.BiomeEntry) BiomeTweakEvent(me.superckl.api.biometweaker.event.BiomeTweakEvent) Biome(net.minecraft.world.biome.Biome)

Example 4 with BiomeType

use of net.minecraftforge.common.BiomeManager.BiomeType in project BiomesOPlenty by Glitchfiend.

the class ModCompatibility method copyModBiomeWeights.

private static void copyModBiomeWeights() {
    try {
        // An array containing lists of default biome entries for only standard BiomeTypes
        List<BiomeEntry>[] vanillaBiomes = (List<BiomeEntry>[]) ReflectionHelper.findMethod(BiomeManager.class, "setupBiomes", "setupBiomes").invoke(null);
        for (BiomeType type : BiomeManager.BiomeType.values()) {
            // Creates a mutable version of the current biome type's biome array and wraps entries to support .equals()
            List<WrappedBiomeEntry> entries = Lists.transform(Lists.newArrayList(BiomeManager.getBiomes(type)), WRAP_BIOME_ENTRIES);
            // Custom types may have been added, we only want the vanilla ones
            final List<WrappedBiomeEntry> vanillaEntries = type.ordinal() < vanillaBiomes.length ? Lists.transform(vanillaBiomes[type.ordinal()], WRAP_BIOME_ENTRIES) : Lists.newArrayList();
            // Remove all default biomes from the entries list
            entries.removeAll(vanillaEntries);
            for (WrappedBiomeEntry wrappedEntry : entries) {
                remapBiomeToBoP(wrappedEntry.biomeEntry.biome, type, wrappedEntry.biomeEntry.itemWeight);
            }
        }
    } catch (Exception e) {
        BiomesOPlenty.logger.error("An error has occurred whilst copying mod biomes");
        e.printStackTrace();
        return;
    }
}
Also used : BiomeEntry(net.minecraftforge.common.BiomeManager.BiomeEntry) BiomeType(net.minecraftforge.common.BiomeManager.BiomeType) List(java.util.List)

Aggregations

BiomeType (net.minecraftforge.common.BiomeManager.BiomeType)4 BiomeEntry (net.minecraftforge.common.BiomeManager.BiomeEntry)3 Biome (net.minecraft.world.biome.Biome)2 List (java.util.List)1 BiomeTweakEvent (me.superckl.api.biometweaker.event.BiomeTweakEvent)1 EnumPlantType (net.minecraftforge.common.EnumPlantType)1