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!");
}
}
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);
}
}
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));
}
}
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;
}
}
Aggregations