下面列出了怎么用net.minecraft.world.WorldType的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public void populateChunk(World world, int chunkX, int chunkZ, Random random, OreDepositDefinition definition, GridEntryInfo gridEntryInfo) {
int stonesCount = random.nextInt(2);
if (world.getWorldType() != WorldType.FLAT && stonesCount > 0) {
Set<Material> undergroundMaterials = findUndergroundMaterials(gridEntryInfo.getGeneratedBlocks(definition, chunkX, chunkZ));
if (undergroundMaterials.isEmpty())
return;
for (int i = 0; i < stonesCount; i++) {
int randomX = chunkX * 16 + random.nextInt(16);
int randomZ = chunkZ * 16 + random.nextInt(16);
BlockPos topBlockPos = new BlockPos(randomX, 0, randomZ);
topBlockPos = world.getTopSolidOrLiquidBlock(topBlockPos).down();
IBlockState blockState = world.getBlockState(topBlockPos);
if (blockState.getBlockFaceShape(world, topBlockPos, EnumFacing.UP) != BlockFaceShape.SOLID ||
!blockState.isOpaqueCube() || !blockState.isFullBlock())
continue;
BlockPos surfaceRockPos = topBlockPos.up();
setStoneBlock(world, surfaceRockPos, undergroundMaterials);
}
}
}
@Override
public void populateChunk(World world, int chunkX, int chunkZ, Random random, OreDepositDefinition definition, GridEntryInfo gridEntryInfo) {
if (world.getWorldType() != WorldType.FLAT) {
int stonesCount = minIndicatorAmount + (minIndicatorAmount >= maxIndicatorAmount ? 0 : random.nextInt(maxIndicatorAmount - minIndicatorAmount));
for (int i = 0; i < stonesCount; i++) {
int randomX = chunkX * 16 + random.nextInt(16);
int randomZ = chunkZ * 16 + random.nextInt(16);
BlockPos topBlockPos = new BlockPos(randomX, 0, randomZ);
topBlockPos = world.getTopSolidOrLiquidBlock(topBlockPos).down();
IBlockState blockState = world.getBlockState(topBlockPos);
if (blockState.getBlockFaceShape(world, topBlockPos, EnumFacing.UP) != BlockFaceShape.SOLID ||
!blockState.isOpaqueCube() || !blockState.isFullBlock())
continue;
BlockPos surfaceRockPos = topBlockPos.up();
world.setBlockState(surfaceRockPos, this.blockState, 16);
}
}
}
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
if (ConfigHolder.abandonedBaseRarity == 0 ||
world.getWorldType() == WorldType.FLAT ||
world.provider.getDimensionType() != DimensionType.OVERWORLD ||
!world.getWorldInfo().isMapFeaturesEnabled()) {
return; //do not generate in flat worlds, or in non-surface worlds
}
BlockPos randomPos = new BlockPos(chunkX * 16 + 8, 0, chunkZ * 16 + 8);
if (random.nextInt(ConfigHolder.abandonedBaseRarity) == 0) {
int variantNumber = random.nextInt(3);
Rotation rotation = Rotation.values()[random.nextInt(Rotation.values().length)];
ResourceLocation templateId = new ResourceLocation(GTValues.MODID, "abandoned_base/abandoned_base_1_" + variantNumber);
Template template = TemplateManager.getBuiltinTemplate(world, templateId);
BlockPos originPos = template.getZeroPositionWithTransform(randomPos, Mirror.NONE, rotation);
originPos = TemplateManager.calculateAverageGroundLevel(world, originPos, template.getSize());
template.addBlocksToWorld(world, originPos, new PlacementSettings().setRotation(rotation));
}
}
public ChunkManagerPlanet(long seed, WorldType default1, String str, DimensionProperties properties) {
this.biomeCache = new BiomeCache(this);//new BiomeCacheExtended(this);
//TODO: more biomes
//TODO: remove rivers
GenLayer[] agenlayer = initializeAllBiomeGenerators(seed, default1, str, properties);//GenLayer.initializeAllBiomeGenerators(seed, default1); //;
agenlayer = getModdedBiomeGenerators(default1, seed, agenlayer);
this.genBiomes = agenlayer[0];
this.biomeIndexLayer = agenlayer[1];
ReflectionHelper.setPrivateValue(BiomeProvider.class, this, this.genBiomes, "genBiomes", "field_76944_d");
ReflectionHelper.setPrivateValue(BiomeProvider.class, this, this.biomeIndexLayer, "biomeIndexLayer", "field_76945_e");
fBiomeCache = ReflectionHelper.findField(BiomeCache.class, "cache", "field_76841_d");
fBiomeCache.setAccessible(true);
fBiomeCacheMap = ReflectionHelper.findField(BiomeCache.class, "cacheMap", "field_76843_c");
fBiomeCacheMap.setAccessible(true);
}
public static GenLayerTofu getBiomeLayer(long worldSeed, GenLayerTofu parentLayer, WorldType worldType)
{
GenLayerTofu ret = new GenLayerBiome(200L, parentLayer, worldType);
ret = GenLayerZoom.magnify(1000L, ret, 2);
ret = new GenLayerBiomeEdge(1000L, ret);
return ret;
}
public BiomeProviderTofu(long seed, WorldType worldType)
{
this();
GenLayer agenlayer[] = GenLayerTofu.initializeAllBiomeGeneratorsTofu(seed, worldType);
this.genBiomes = agenlayer[0];
this.biomeIndexLayer = agenlayer[1];
}
@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);
}
}
}
private MaterialCache()
{
WorldSettings settings = new WorldSettings(0L, GameType.CREATIVE, false, false, WorldType.FLAT);
this.tempWorld = new WorldSchematic(null, settings, -1, EnumDifficulty.PEACEFUL, Minecraft.getMinecraft().profiler);
this.checkPos = new BlockPos(8, 0, 8);
WorldUtils.loadChunksClientWorld(this.tempWorld, this.checkPos, new Vec3i(1, 1, 1));
}
@Override
public boolean createWorld(MissionInit missionInit)
{
long seed = getWorldSeedFromString(this.dwparams.getSeed());
WorldType.WORLD_TYPES[0].onGUICreateWorldPress();
WorldSettings worldsettings = new WorldSettings(seed, GameType.SURVIVAL, true, false, WorldType.WORLD_TYPES[0]);
worldsettings.enableCommands();
// Create a filename for this map - we use the time stamp to make sure it is different from other worlds, otherwise no new world
// will be created, it will simply load the old one.
return MapFileHelper.createAndLaunchWorld(worldsettings, this.dwparams.isDestroyAfterUse());
}
@Override
public boolean createWorld(MissionInit missionInit)
{
long seed = DefaultWorldGeneratorImplementation.getWorldSeedFromString(this.fwparams.getSeed());
WorldSettings worldsettings = new WorldSettings(seed, GameType.SURVIVAL, false, false, WorldType.FLAT);
// This call to setWorldName allows us to specify the layers of our world, and also the features that will be created.
// This website provides a handy way to generate these strings: http://chunkbase.com/apps/superflat-generator
worldsettings.setGeneratorOptions(this.fwparams.getGeneratorString());
worldsettings.enableCommands(); // Enables cheat commands.
// Create a filename for this map - we use the time stamp to make sure it is different from other worlds, otherwise no new world
// will be created, it will simply load the old one.
return MapFileHelper.createAndLaunchWorld(worldsettings, this.fwparams.isDestroyAfterUse());
}
@Override
public boolean createWorld(MissionInit missionInit) {
long seed = getWorldSeedFromString();
WorldType.WORLD_TYPES[0].onGUICreateWorldPress();
WorldSettings worldsettings = new WorldSettings(seed, GameType.SURVIVAL, true, false, WorldType.WORLD_TYPES[0]);
worldsettings.enableCommands();
// Create a filename for this map - we use the time stamp to make sure
// it is different from other worlds, otherwise no new world
// will be created, it will simply load the old one.
return MapFileHelper.createAndLaunchWorld(worldsettings, this.bparams.isDestroyAfterUse());
}
@Override
public void generate( Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider )
{
if( !world.provider.isHellWorld && world.provider.terrainType != WorldType.FLAT )
{
generateSurface( world, random, chunkX * 16, chunkZ * 16 );
}
}
public ChunkGeneratorFlatVoid(World world)
{
super(world, world.getSeed(), false, null);
this.world = world;
if (this.world.getWorldType() != WorldType.FLAT)
this.world.setSeaLevel(63); //Fixup sea level as they now calculate it in flat worlds.
}
/**
* the first array item is a linked list of the bioms, the second is the zoom function, the third is the same as the
* first.
*/
public static GenLayer[] initializeAllBiomeGeneratorsTofu(long seed, WorldType worldType)
{
byte biomeSize = getModdedBiomeSize(worldType, (byte) (worldType == WorldType.LARGE_BIOMES ? 7 : 5));
GenLayerIsland genlayerisland = new GenLayerIsland(1L);
GenLayerFuzzyZoom genlayerfuzzyzoom = new GenLayerFuzzyZoom(2000L, genlayerisland);
GenLayerAddIsland genlayeraddisland = new GenLayerAddIsland(1L, genlayerfuzzyzoom);
GenLayerZoom genlayerzoom = new GenLayerZoom(2001L, genlayeraddisland);
genlayeraddisland = new GenLayerAddIsland(2L, genlayerzoom);
genlayeraddisland = new GenLayerAddIsland(50L, genlayeraddisland);
genlayeraddisland = new GenLayerAddIsland(70L, genlayeraddisland);
genlayeraddisland = new GenLayerAddIsland(3L, genlayeraddisland);
genlayeraddisland = new GenLayerAddIsland(2L, genlayeraddisland);
GenLayerEdge genlayeredge = new GenLayerEdge(2L, genlayeraddisland, GenLayerEdge.Mode.COOL_WARM);
genlayeredge = new GenLayerEdge(2L, genlayeredge, GenLayerEdge.Mode.HEAT_ICE);
genlayeredge = new GenLayerEdge(3L, genlayeredge, GenLayerEdge.Mode.SPECIAL);
genlayerzoom = new GenLayerZoom(2002L, genlayeredge);
genlayerzoom = new GenLayerZoom(2003L, genlayerzoom);
genlayeraddisland = new GenLayerAddIsland(4L, genlayerzoom);
GenLayerTofu genlayer3 = GenLayerZoom.magnify(1000L, genlayeraddisland, 0);
GenLayerTofu genlayer = GenLayerZoom.magnify(1000L, genlayer3, 0);
GenLayerRiverInit genlayerriverinit = new GenLayerRiverInit(100L, genlayer);
Object object = GenLayerTofu.getBiomeLayer(seed, genlayer3, worldType);
GenLayerTofu genlayer1 = GenLayerZoom.magnify(1000L, genlayerriverinit, 2);
GenLayerHills genlayerhills = new GenLayerHills(1000L, (GenLayerTofu)object, genlayer1);
genlayer = GenLayerZoom.magnify(1000L, genlayerriverinit, 2);
genlayer = GenLayerZoom.magnify(1000L, genlayer, biomeSize);
GenLayerRiver genlayerriver = new GenLayerRiver(1L, genlayer);
GenLayerSmooth genlayersmooth = new GenLayerSmooth(1000L, genlayerriver);
object = GenLayerZoom.magnify(1000L, genlayerhills, 2);
for (int j = 0; j < biomeSize; ++j)
{
object = new GenLayerZoom((long)(1000 + j), (GenLayerTofu)object);
if (j == 0)
{
object = new GenLayerAddIsland(3L, (GenLayerTofu)object);
}
if (j == 1)
{
object = new GenLayerShore(1000L, (GenLayerTofu)object);
}
}
GenLayerSmooth genlayersmooth1 = new GenLayerSmooth(1000L, (GenLayerTofu)object);
GenLayerRiverMix genlayerrivermix = new GenLayerRiverMix(100L, genlayersmooth1, genlayersmooth);
GenLayerTofu layerVoronoi = new GenLayerTofuVoronoiZoom(10L, genlayerrivermix);
genlayerrivermix.initWorldGenSeed(seed);
layerVoronoi.initWorldGenSeed(seed);
return new GenLayer[] {genlayerrivermix, layerVoronoi};
}
public GenLayerBiome(long par1, GenLayerTofu par3GenLayer, WorldType par4WorldType)
{
super(par1);
this.allowedBiomes = TofuBiomes.decorationBiomes;
this.parent = par3GenLayer;
}
@Override
public GenLayer[] getModdedBiomeGenerators(WorldType worldType, long seed, GenLayer[] original)
{
return original;
}
@Override
public WorldType getWorldType() {
return WorldType.DEFAULT;
}
@Override
public WorldType getWorldType() {
return world.getWorldType();
}
public WrapperWorldType(WorldType var1) {
this.real = var1;
}
public static WrapperWorldType parseWorldType(String var0) {
return new WrapperWorldType(WorldType.parseWorldType(var0));
}
public WorldType unwrap() {
return this.real;
}
public WorldType[] getWorldTypes() {
return WorldType.worldTypes;
}
public WrapperWorldType getDEFAULT() {
return new WrapperWorldType(WorldType.DEFAULT);
}
public WrapperWorldType getFLAT() {
return new WrapperWorldType(WorldType.FLAT);
}
public WrapperWorldType getLARGE_BIOMES() {
return new WrapperWorldType(WorldType.LARGE_BIOMES);
}
public WrapperWorldType getAMPLIFIED() {
return new WrapperWorldType(WorldType.AMPLIFIED);
}
public WrapperWorldType getCUSTOMIZED() {
return new WrapperWorldType(WorldType.CUSTOMIZED);
}
public WrapperWorldType getDEBUG_WORLD() {
return new WrapperWorldType(WorldType.DEBUG_WORLD);
}
public WrapperWorldType getDEFAULT_1_1() {
return new WrapperWorldType(WorldType.DEFAULT_1_1);
}
public double getHorizon(WorldInfo worldInfo) {
return Settings.VOID_FLICKER_FIX ? 0.0 : worldInfo.getTerrainType() == WorldType.FLAT ? 0.0D : 63.0D;
}