下面列出了怎么用net.minecraftforge.common.BiomeDictionary.Type的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
if (world.getWorldType() == WorldType.FLAT ||
!world.provider.isSurfaceWorld()) {
return; //do not generate in flat worlds, or in non-surface worlds
}
BlockPos randomPos = new BlockPos(chunkX * 16 + 8, 0, chunkZ * 16 + 8);
Biome biome = world.getBiome(randomPos);
if (BiomeDictionary.hasType(biome, Type.COLD) ||
BiomeDictionary.hasType(biome, Type.HOT) ||
BiomeDictionary.hasType(biome, Type.DRY) ||
BiomeDictionary.hasType(biome, Type.DEAD) ||
BiomeDictionary.hasType(biome, Type.SPOOKY))
return; //do not generate in inappropriate biomes
int rubberTreeChance = 6;
if (BiomeDictionary.hasType(biome, Type.SWAMP) ||
BiomeDictionary.hasType(biome, Type.WET))
rubberTreeChance /= 2; //double chance of spawning in swamp or wet biomes
if (random.nextInt(rubberTreeChance) == 0) {
randomPos = world.getTopSolidOrLiquidBlock(randomPos).down();
IBlockState solidBlockState = world.getBlockState(randomPos);
BlockGregSapling sapling = MetaBlocks.SAPLING;
if (solidBlockState.getBlock().canSustainPlant(solidBlockState, world, randomPos, EnumFacing.UP, sapling)) {
BlockPos abovePos = randomPos.up();
IBlockState saplingState = sapling.getDefaultState()
.withProperty(BlockGregSapling.VARIANT, LogVariant.RUBBER_WOOD);
world.setBlockState(abovePos, saplingState);
sapling.generateTree(world, abovePos, saplingState, random);
}
}
}
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
IChunkProvider chunkProvider) {
Biome biomegenbase = world.getBiome(new BlockPos(chunkX * 16 + 16, 128, chunkZ * 16 + 16));
// Any Biome
GTOreGenerator.generateBasicVein(GTBlocks.oreIridium, GTConfig.generation.iridiumGenerate, GTConfig.generation.iridiumSize, GTConfig.generation.iridiumWeight, 0, 128, Blocks.STONE, world, random, chunkX, chunkZ);
// Jungle Biomes
if (BiomeDictionary.hasType(biomegenbase, Type.JUNGLE)) {
GTOreGenerator.generateBasicVein(GTBlocks.oreSheldonite, GTConfig.generation.sheldoniteGenerate, GTConfig.generation.sheldoniteSize, GTConfig.generation.sheldoniteWeight, 10, 30, Blocks.STONE, world, random, chunkX, chunkZ);
}
// Hot Biomes
if (BiomeDictionary.hasType(biomegenbase, Type.HOT)) {
GTOreGenerator.generateBasicVein(GTBlocks.oreRuby, GTConfig.generation.rubyGenerate, GTConfig.generation.rubySize, GTConfig.generation.rubyWeight, 0, 48, Blocks.STONE, world, random, chunkX, chunkZ);
}
// Ocean Biomes
if (BiomeDictionary.hasType(biomegenbase, Type.OCEAN) || BiomeDictionary.hasType(biomegenbase, Type.BEACH)) {
GTOreGenerator.generateBasicVein(GTBlocks.oreSapphire, GTConfig.generation.sapphireGenerate, GTConfig.generation.sapphireSize, GTConfig.generation.sapphireWeight, 0, 48, Blocks.STONE, world, random, chunkX, chunkZ);
}
// Forest or Plains Biomes
if (BiomeDictionary.hasType(biomegenbase, Type.FOREST)
|| (BiomeDictionary.hasType(biomegenbase, Type.PLAINS))) {
GTOreGenerator.generateBasicVein(GTBlocks.oreBauxite, GTConfig.generation.bauxiteGenerate, GTConfig.generation.bauxiteSize, GTConfig.generation.bauxiteWeight, 50, 120, Blocks.STONE, world, random, chunkX, chunkZ);
}
if (world.provider.getDimensionType().equals(DimensionType.OVERWORLD)) {
for (Block block : GTBedrockOreHandler.getBedrockOreMap().keySet()) {
if (GTBedrockOreHandler.shouldGTCHandleGeneration(block)) {
GTOreGenerator.generateBedrockVein(block, world, random, chunkX, chunkZ);
}
}
}
}
@Override
public boolean includesBiomeType(List<Type> biomeTypes) {
for(BiomeDictionary.Type type : biomeTypes){
if(biomeHasType(type)) return true;
}
return false;
}
@SubscribeEvent(priority = EventPriority.NORMAL)
public void onEvent(PopulateChunkEvent.Post event) {
if (!event.getWorld().provider.getDimensionType().equals(DimensionType.OVERWORLD)) {
return;
}
if (GTConfig.general.replaceOceanGravelWithSand) {
Chunk chunk = event.getWorld().getChunkFromChunkCoords(event.getChunkX(), event.getChunkZ());
for (int x = 0; x < 16; ++x) {
for (int z = 0; z < 16; ++z) {
Biome biomegenbase = event.getWorld().getBiome(new BlockPos(chunk.x * 16 + x, 128, chunk.z * 16
+ z));
if (BiomeDictionary.hasType(biomegenbase, Type.OCEAN)
|| BiomeDictionary.hasType(biomegenbase, Type.BEACH)) {
for (int y = 30; y < 60; ++y) {
if (chunk.getBlockState(x, y, z).getBlock() == BLOCK_GRAVEL) {
chunk.setBlockState(new BlockPos(x, y, z), BLOCK_SAND.getDefaultState());
}
}
}
}
}
chunk.markDirty();
}
// if (GTConfig.general.redSandInForestsAndPlains) {
// Chunk chunk = event.getWorld().getChunkFromChunkCoords(event.getChunkX(), event.getChunkZ());
// for (int x = 0; x < 16; ++x) {
// for (int z = 0; z < 16; ++z) {
// Biome biomegenbase = event.getWorld().getBiome(new BlockPos(chunk.x * 16 + x, 128, chunk.z * 16
// + z));
// if (BiomeDictionary.hasType(biomegenbase, Type.FOREST)
// || BiomeDictionary.hasType(biomegenbase, Type.PLAINS)) {
// for (int y = 30; y < 80; ++y) {
// if (chunk.getBlockState(x, y, z).getBlock() == BLOCK_SAND) {
// chunk.setBlockState(new BlockPos(x, y, z), BLOCKSTATE_RED_SAND);
// }
// }
// }
// }
// }
// chunk.markDirty();
// }
}
protected void registerWorldGen()
{
//GameRegistry.registerWorldGenerator(new WorldGenCliffNoise(), 1);
//GameRegistry.registerWorldGenerator(new WorldGenCliffRocks(), 1);
//GameRegistry.registerWorldGenerator(new WorldGenPortals(), 2);
GameRegistry.registerWorldGenerator(new WorldGenStalag(), 4);
HexGenRegistry.registerWorldGenerator(new WorldGenCliffRocksHex(), 1);
HexGenRegistry.registerWorldGenerator(new WorldGenPortalsHex(), 2);
HexGenRegistry.registerWorldGenerator(new WorldGenClayHex(), 5);
HexGenRegistry.registerWorldGenerator(new WorldGenLooseRockHex(), 5);
HexGenRegistry.registerWorldGenerator(new WorldGenTreesHex(), 10);
HexGenRegistry.registerWorldGenerator(new WorldGenSwampTreesHex(), 10);
HexGenRegistry.registerWorldGenerator(new WorldGenCatTailsHex(), 100);
HexGenRegistry.registerWorldGenerator(new WorldGenGrassHex(), 100);
HexGenRegistry.registerWorldGenerator(new WorldGenGrassDryHex(), 100);
HexGenRegistry.registerWorldGenerator(new WorldGenPamsGardensHex(), 25);
Biome.registerBiome(200, "BIOME_BARE", Global.BIOME_BARE);
Biome.registerBiome(201, "BIOME_BEACH", Global.BIOME_BEACH);
Biome.registerBiome(202, "BIOME_DECIDUOUS_FOREST", Global.BIOME_DECIDUOUS_FOREST);
Biome.registerBiome(203, "BIOME_DEEP_OCEAN", Global.BIOME_DEEP_OCEAN);
Biome.registerBiome(204, "BIOME_DRY_FOREST", Global.BIOME_DRY_FOREST);
Biome.registerBiome(205, "BIOME_GRASSLAND", Global.BIOME_GRASSLAND);
Biome.registerBiome(206, "BIOME_LAKE", Global.BIOME_LAKE);
Biome.registerBiome(207, "BIOME_MARSH", Global.BIOME_MARSH);
Biome.registerBiome(208, "BIOME_OCEAN", Global.BIOME_OCEAN);
Biome.registerBiome(209, "BIOME_POLAR_DESERT", Global.BIOME_POLAR_DESERT);
Biome.registerBiome(210, "BIOME_POND", Global.BIOME_POND);
Biome.registerBiome(211, "BIOME_RAIN_FOREST", Global.BIOME_RAIN_FOREST);
Biome.registerBiome(212, "BIOME_RIVER", Global.BIOME_RIVER);
Biome.registerBiome(213, "BIOME_SCORCHED", Global.BIOME_SCORCHED);
Biome.registerBiome(214, "BIOME_SHRUBLAND", Global.BIOME_SHRUBLAND);
Biome.registerBiome(215, "BIOME_SUBTROPICAL_DESERT", Global.BIOME_SUBTROPICAL_DESERT);
Biome.registerBiome(216, "BIOME_TAIGA", Global.BIOME_TAIGA);
Biome.registerBiome(217, "BIOME_TEMPERATE_DESERT", Global.BIOME_TEMPERATE_DESERT);
Biome.registerBiome(218, "BIOME_TROPICAL_DESERT", Global.BIOME_TROPICAL_DESERT);
Biome.registerBiome(219, "BIOME_TUNDRA", Global.BIOME_TUNDRA);
Biome.registerBiome(220, "BIOME_SWAMP", Global.BIOME_SWAMP);
BiomeDictionary.addTypes(Global.BIOME_BARE, Type.SPARSE, Type.DEAD, Type.WASTELAND);
BiomeDictionary.addTypes(Global.BIOME_BEACH, Type.BEACH);
BiomeDictionary.addTypes(Global.BIOME_DECIDUOUS_FOREST, Type.FOREST);
BiomeDictionary.addTypes(Global.BIOME_DEEP_OCEAN, Type.OCEAN);
BiomeDictionary.addTypes(Global.BIOME_DRY_FOREST, Type.DRY, Type.FOREST);
BiomeDictionary.addTypes(Global.BIOME_GRASSLAND, Type.PLAINS);
BiomeDictionary.addTypes(Global.BIOME_LAKE, Type.WATER);
BiomeDictionary.addTypes(Global.BIOME_MARSH, Type.WET, Type.LUSH, Type.SWAMP);
BiomeDictionary.addTypes(Global.BIOME_OCEAN, Type.OCEAN);
BiomeDictionary.addTypes(Global.BIOME_POLAR_DESERT, Type.COLD, Type.SPARSE, Type.DRY, Type.SANDY, Type.SNOWY);
BiomeDictionary.addTypes(Global.BIOME_POND, Type.WATER);
BiomeDictionary.addTypes(Global.BIOME_RAIN_FOREST, Type.HOT, Type.DENSE, Type.WET, Type.JUNGLE, Type.LUSH, Type.FOREST);
BiomeDictionary.addTypes(Global.BIOME_RIVER, Type.RIVER);
BiomeDictionary.addTypes(Global.BIOME_SCORCHED, Type.HOT, Type.SPARSE, Type.DRY, Type.DEAD, Type.WASTELAND);
BiomeDictionary.addTypes(Global.BIOME_SHRUBLAND, Type.DRY, Type.PLAINS);
BiomeDictionary.addTypes(Global.BIOME_SUBTROPICAL_DESERT, Type.HOT, Type.SPARSE, Type.DRY, Type.SANDY);
BiomeDictionary.addTypes(Global.BIOME_TAIGA, Type.COLD, Type.CONIFEROUS, Type.FOREST, Type.SNOWY);
BiomeDictionary.addTypes(Global.BIOME_TEMPERATE_DESERT, Type.SPARSE, Type.DRY, Type.SANDY);
BiomeDictionary.addTypes(Global.BIOME_TROPICAL_DESERT, Type.HOT, Type.SPARSE, Type.DRY, Type.SANDY);
BiomeDictionary.addTypes(Global.BIOME_TUNDRA, Type.COLD, Type.SPARSE, Type.SNOWY);
BiomeDictionary.addTypes(Global.BIOME_SWAMP, Type.WET, Type.SPOOKY, Type.LUSH, Type.SWAMP);
}
public BiomeDescriptor(Type type, boolean isExclude) {
name = null;
this.type = type;
this.isExclude = isExclude;
}
@Override
public BiomeDictionary.Type getType() {
return type;
}
@Override
public boolean biomeHasType(Type type) {
return BiomeDictionary.hasType(info.getBiome(), type);
}
/**
* Adds a crop nutrient biome bonus.
* <p/>
* +10/-10 0 indicates no bonus and negative values indicate a penalty.
*
* @param type Forge biome type to apply the bonus in
* @param nutrientsBonus Nutrient stat bonus
*/
public abstract void addBiomenutrientsBonus(Type type, int nutrientsBonus);
/**
* Adds a crop humidity biome bonus.
* <p/>
* +10/-10 0 indicates no bonus and negative values indicate a penalty.
*
* @param type Forge biome type to apply the bonus in
* @param humidityBonus Humidity stat bonus
*/
public abstract void addBiomehumidityBonus(Type type, int humidityBonus);
public boolean biomeHasType(BiomeDictionary.Type type);
public boolean includesBiomeType(List<Type> biomeTypes);