Java Code Examples for net.minecraft.world.gen.ChunkProviderFlat

The following are top voted examples for showing how to use net.minecraft.world.gen.ChunkProviderFlat. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: muon   File: MuonUtils.java   Source Code and License 6 votes vote down vote up
public static int getGroundLevel(World worldin, int xpos, int zpos) {
    int chunkX = xpos >> 4;
    int chunkZ = zpos >> 4;
    IChunkProvider provider = worldin.getChunkProvider();
    ChunkPrimer primer = new ChunkPrimer();
    if (chunkX == cachedChunkX && chunkZ == cachedChunkZ && cachedChunk != null) {
        primer = cachedChunk;
    } else {
        if (provider instanceof ChunkProviderOverworld) {
            ((ChunkProviderOverworld)provider).setBlocksInChunk(chunkX, chunkZ, primer);
        } else if (provider instanceof ChunkProviderEnd) {
            ((ChunkProviderEnd) provider).setBlocksInChunk(chunkX, chunkZ, primer);
        } else if (provider instanceof ChunkProviderFlat) {
            return worldin.getSeaLevel();
        } else {
            return -1; // unhandled dimension.
        }
        cachedChunk = primer;
        cachedChunkX = chunkX;
        cachedChunkZ = chunkZ;
    }
    return primer.findGroundBlockIdx(xpos & 15, zpos & 15);
}
 
Example 2
Project: NeptuneMod   File: MixinWorldProvider.java   Source Code and License 6 votes vote down vote up
/**
 * @author jamierocks - 24th October 2016
 * @reason To use custom ChunkProviders where necessary
 */
@Overwrite
public IChunkProvider createChunkGenerator() {
    final IChunkProvider chunkProvider = this.terrainType == WorldType.FLAT ?
            new ChunkProviderFlat(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(),
                    this.generatorSettings) :
            (this.terrainType == WorldType.DEBUG_WORLD ?
                    new ChunkProviderDebug(this.worldObj) :
                    (this.terrainType == WorldType.CUSTOMIZED ?
                            new ChunkProviderGenerate(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(),
                                    this.generatorSettings) :
                            new ChunkProviderGenerate(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(),
                                    this.generatorSettings)));

    if (this.dimensionType.hasChunkProvider()) {
        final ChunkProviderCustom chunkProviderCustom = this.dimensionType.getChunkProvider();
        chunkProviderCustom.setWorld((net.canarymod.api.world.World) this.worldObj);
        return new NeptuneChunkProviderCustom(chunkProviderCustom, chunkProvider);
    } else {
        return chunkProvider;
    }
}
 
Example 3
Project: MinesweeperMod   File: WorldGeneratorMinesweeper.java   Source Code and License 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider){
    if(!(chunkGenerator instanceof ChunkProviderFlat)) { //don't generate on flatworlds
        switch(world.provider.dimensionId){
            case 0:
                generateSurface(world, random, chunkX * 16, chunkZ * 16);
                break;
            case -1:
                generateNether(world, random, chunkX * 16, chunkZ * 16);
                break;
            case 1:
                generateEnd(world, random, chunkX * 16, chunkZ * 16);
            default:
                generateSurface(world, random, chunkX * 16, chunkZ * 16);
                break;
        }
    }
}
 
Example 4
Project: PneumaticCraft   File: WorldGeneratorPneumaticCraft.java   Source Code and License 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider){
    if(!(chunkGenerator instanceof ChunkProviderFlat)) { //don't generate on flatworlds
        switch(world.provider.dimensionId){
            case 0:
                generateSurface(world, random, chunkX * 16, chunkZ * 16);
                break;
            case -1:
                generateNether(world, random, chunkX * 16, chunkZ * 16);
                break;
            case 1:
                generateEnd(world, random, chunkX * 16, chunkZ * 16);
                break;
            default:
                generateSurface(world, random, chunkX * 16, chunkZ * 16);
        }
    }
}
 
Example 5
Project: TechnicalDimensions   File: CustomChunkProvider.java   Source Code and License 5 votes vote down vote up
public static IChunkGenerator getGenForWorld(DimData data, World worldIn, long seed, boolean mapFeaturesEnabledIn, String settings) {
    if (data.falt) {
        return new ChunkProviderFlat(worldIn, seed, mapFeaturesEnabledIn, "3;minecraft:bedrock,60*minecraft:stone,2*minecraft:dirt,minecraft:grass;3;village(size=50 distance=50),mineshaft(chance=0.5),biome_1,dungeon,decoration,lake,lava_lake");
    }
    //TODO get custom shit
    return new ChunkProviderOverworld(worldIn, seed, mapFeaturesEnabledIn, settings);
}
 
Example 6
Project: geomastery   File: WorldGenerator.java   Source Code and License 5 votes vote down vote up
@Override
public void generate(Random rand, int chunkScaleX, int chunkScaleZ,
        World world, IChunkGenerator chunkGenerator,
        IChunkProvider chunkProvider) {

    if (world.provider.getDimension() == 0) {

        if (!(chunkGenerator instanceof ChunkProviderFlat)) {
            
            generateOverworldChunk(world, rand, chunkScaleX * 16,
                chunkScaleZ * 16);
        }
    }
}
 
Example 7
Project: MineChess   File: WorldGeneratorMineChess.java   Source Code and License 5 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider){
    if(MineChess.DEBUG || !(chunkGenerator instanceof ChunkProviderFlat)) { //don't generate on flatworlds (unless testing)
        switch(world.provider.getDimensionId()){
            case 0:
                generateSurface(world, random, chunkX * 16, chunkZ * 16);
                break;
            case -1:
                generateNether(world, random, chunkX * 16, chunkZ * 16);
                break;
            case 1:
                generateEnd(world, random, chunkX * 16, chunkZ * 16);
        }
    }
}
 
Example 8
Project: spellbound   File: WorldGenMushrooms.java   Source Code and License 5 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) 
{
	if (!(chunkGenerator instanceof ChunkProviderFlat))
	{
		for (int loop = 0; loop < 20; loop++)
		{
			final int genX = chunkX * 16 + random.nextInt(16);
			final int genY = random.nextInt(90);
			final int genZ = chunkZ * 16 + random.nextInt(16);

			int spawnId = SpellboundCore.getInstance().blockPrimaryMushroomRedOrange.blockID;

			if (random.nextBoolean())
			{
				spawnId = SpellboundCore.getInstance().blockPrimaryMushroomPinkOrange.blockID;
			}

			else if (random.nextBoolean())
			{
				spawnId = SpellboundCore.getInstance().blockPrimaryMushroomBlueGrey.blockID;
			}

			if (world.getBlockId(genX, genY, genZ) == Block.grass.blockID)
			{
				world.setBlock(genX, genY + 1, genZ, spawnId);
			}
		}
	}
}
 
Example 9
Project: DecompiledMinecraft   File: WorldProvider.java   Source Code and License 4 votes vote down vote up
/**
 * Returns a new chunk provider which generates chunks for this world
 */
public IChunkProvider createChunkGenerator()
{
    return (IChunkProvider)(this.terrainType == WorldType.FLAT ? new ChunkProviderFlat(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.generatorSettings) : (this.terrainType == WorldType.DEBUG_WORLD ? new ChunkProviderDebug(this.worldObj) : (this.terrainType == WorldType.CUSTOMIZED ? new ChunkProviderGenerate(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.generatorSettings) : new ChunkProviderGenerate(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.generatorSettings))));
}
 
Example 10
Project: DecompiledMinecraft   File: WorldProvider.java   Source Code and License 4 votes vote down vote up
/**
 * Returns a new chunk provider which generates chunks for this world
 */
public IChunkProvider createChunkGenerator()
{
    return (IChunkProvider)(this.terrainType == WorldType.FLAT ? new ChunkProviderFlat(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.generatorSettings) : (this.terrainType == WorldType.DEBUG_WORLD ? new ChunkProviderDebug(this.worldObj) : (this.terrainType == WorldType.CUSTOMIZED ? new ChunkProviderGenerate(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.generatorSettings) : new ChunkProviderGenerate(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.generatorSettings))));
}
 
Example 11
Project: BaseClient   File: WorldProvider.java   Source Code and License 4 votes vote down vote up
/**
 * Returns a new chunk provider which generates chunks for this world
 */
public IChunkProvider createChunkGenerator()
{
    return (IChunkProvider)(this.terrainType == WorldType.FLAT ? new ChunkProviderFlat(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.generatorSettings) : (this.terrainType == WorldType.DEBUG_WORLD ? new ChunkProviderDebug(this.worldObj) : (this.terrainType == WorldType.CUSTOMIZED ? new ChunkProviderGenerate(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.generatorSettings) : new ChunkProviderGenerate(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.generatorSettings))));
}
 
Example 12
Project: BaseClient   File: WorldProvider.java   Source Code and License 4 votes vote down vote up
/**
 * Returns a new chunk provider which generates chunks for this world
 */
public IChunkProvider createChunkGenerator()
{
    return (IChunkProvider)(this.terrainType == WorldType.FLAT ? new ChunkProviderFlat(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.generatorSettings) : (this.terrainType == WorldType.DEBUG_WORLD ? new ChunkProviderDebug(this.worldObj) : (this.terrainType == WorldType.CUSTOMIZED ? new ChunkProviderGenerate(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.generatorSettings) : new ChunkProviderGenerate(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.generatorSettings))));
}
 
Example 13
Project: Zombe-Modpack   File: WorldProvider.java   Source Code and License 4 votes vote down vote up
public IChunkGenerator createChunkGenerator()
{
    return (IChunkGenerator)(this.terrainType == WorldType.FLAT ? new ChunkProviderFlat(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.generatorSettings) : (this.terrainType == WorldType.DEBUG_WORLD ? new ChunkProviderDebug(this.worldObj) : (this.terrainType == WorldType.CUSTOMIZED ? new ChunkProviderOverworld(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.generatorSettings) : new ChunkProviderOverworld(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.generatorSettings))));
}
 
Example 14
Project: Backmemed   File: WorldProvider.java   Source Code and License 4 votes vote down vote up
public IChunkGenerator createChunkGenerator()
{
    return (IChunkGenerator)(this.terrainType == WorldType.FLAT ? new ChunkProviderFlat(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.generatorSettings) : (this.terrainType == WorldType.DEBUG_WORLD ? new ChunkProviderDebug(this.worldObj) : (this.terrainType == WorldType.CUSTOMIZED ? new ChunkProviderOverworld(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.generatorSettings) : new ChunkProviderOverworld(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.generatorSettings))));
}
 
Example 15
Project: witchery   File: EntitySpirit.java   Source Code and License 4 votes vote down vote up
public void setTarget(String target, int type) {
   this.timeToLive = TimeUtil.secsToTicks(10);
   this.spiritType = type;

   try {
      if(target.equals("Village")) {
         IChunkProvider ex;
         for(ex = super.worldObj.getChunkProvider(); ex != null && ex instanceof ChunkProviderServer; ex = ((ChunkProviderServer)ex).currentChunkProvider) {
            ;
         }

         if(ex != null) {
            if(ex instanceof ChunkProviderFlat) {
               if(fieldStructureGenerators == null) {
                  fieldStructureGenerators = ReflectionHelper.findField(ChunkProviderFlat.class, new String[]{"structureGenerators", "field_82696_f", "f"});
               }

               Iterator iterator = ((List)fieldStructureGenerators.get((ChunkProviderFlat)ex)).iterator();

               while(iterator.hasNext()) {
                  if(this.setWaypointTo(iterator.next(), MapGenVillage.class)) {
                     return;
                  }
               }
            } else if(ex instanceof ChunkProviderGenerate) {
               if(fieldVillageGenerator == null) {
                  fieldVillageGenerator = ReflectionHelper.findField(ChunkProviderGenerate.class, new String[]{"villageGenerator", "field_73224_v", "v"});
               }

               if(fieldVillageGenerator != null) {
                  this.setWaypointTo(fieldVillageGenerator.get((ChunkProviderGenerate)ex), MapGenVillage.class);
               }
            } else if(ex instanceof ChunkProviderHell) {
               this.setWaypointTo(((ChunkProviderHell)ex).genNetherBridge);
            }
         }
      }
   } catch (IllegalAccessException var5) {
      ;
   }

}
 
Example 16
Project: muon   File: MuonHeightMap.java   Source Code and License 4 votes vote down vote up
public static MuonHeightMap defaultHeights(World worldIn, StructureBoundingBox bb) {
    MuonHeightMap hm = new MuonHeightMap(worldIn, bb);
    // try to load default map heights from terrain generator
    IChunkProvider provider = worldIn.getChunkProvider();
    IChunkGenerator gen = null;
    try {
        gen = ((ChunkProviderServer) provider).chunkGenerator;
    } catch (Exception e) { e.printStackTrace(); }
    hm.seaLevel =  worldIn.getSeaLevel() - 1; // set sea level.
    int defaultlevel = -1;
    if (gen instanceof ChunkProviderFlat) {
        defaultlevel = worldIn.getSeaLevel() - 1;
    }
    for (int chunkX = (hm.mapbb.minX>>4); chunkX <= (hm.mapbb.maxX>>4); ++chunkX) {
        for (int chunkZ = (hm.mapbb.minZ>>4); chunkZ <= (hm.mapbb.maxZ>>4); ++chunkZ) {
            ChunkPrimer primer = new ChunkPrimer();
            if (gen instanceof ChunkProviderOverworld) {
                ((ChunkProviderOverworld) gen).setBlocksInChunk(chunkX, chunkZ, primer);
            } else if (gen instanceof ChunkProviderEnd) {
                ((ChunkProviderEnd) gen).setBlocksInChunk(chunkX, chunkZ, primer);
            } else {
                primer = null;
            }
            for (int i = 0; i < 16; ++i) {
                for (int j = 0; j < 16; ++j) {
                    int groundlevel = defaultlevel;
                    if (primer != null) {
                        //BUGGY if we do it with groundlevel = primer.findGroundBlockIdx(i, j);
                        for (int k = 255; k >= 0; --k) {
                            IBlockState state = primer.getBlockState(i,k,j);
                            if (state != Blocks.AIR.getDefaultState()) {
                                groundlevel = k;
                                break;
                            }
                        }
                    }
                    hm.setHeight((chunkX<<4)+i, (chunkZ<<4)+j, groundlevel);
                }
            }
        }
    }
    return hm;
}
 
Example 17
Project: Resilience-Client-Source   File: WorldProvider.java   Source Code and License 4 votes vote down vote up
/**
 * Returns a new chunk provider which generates chunks for this world
 */
public IChunkProvider createChunkGenerator()
{
    return (IChunkProvider)(this.terrainType == WorldType.FLAT ? new ChunkProviderFlat(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled(), this.field_82913_c) : new ChunkProviderGenerate(this.worldObj, this.worldObj.getSeed(), this.worldObj.getWorldInfo().isMapFeaturesEnabled()));
}
 
Example 18
Project: Cauldron   File: WorldType.java   Source Code and License 4 votes vote down vote up
public IChunkProvider getChunkGenerator(World world, String generatorOptions)
{
    return (this == FLAT ? new ChunkProviderFlat(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled(), generatorOptions) : new ChunkProviderGenerate(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled()));
}
 
Example 19
Project: Cauldron   File: WorldType.java   Source Code and License 4 votes vote down vote up
public IChunkProvider getChunkGenerator(World world, String generatorOptions)
{
    return (this == FLAT ? new ChunkProviderFlat(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled(), generatorOptions) : new ChunkProviderGenerate(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled()));
}
 
Example 20
Project: RuneCraftery   File: WorldProvider.java   Source Code and License 4 votes vote down vote up
public IChunkProvider func_76555_c() {
   return (IChunkProvider)(this.field_76577_b == WorldType.field_77138_c?new ChunkProviderFlat(this.field_76579_a, this.field_76579_a.func_72905_C(), this.field_76579_a.func_72912_H().func_76089_r(), this.field_82913_c):new ChunkProviderGenerate(this.field_76579_a, this.field_76579_a.func_72905_C(), this.field_76579_a.func_72912_H().func_76089_r()));
}
 
Example 21
Project: CustomOreGen   File: WorldConfig.java   Source Code and License 4 votes vote down vote up
private static void populateWorldProperties(Map<String,Object> properties, World world, WorldInfo worldInfo)
{
    properties.put("world", worldInfo == null ? "" : worldInfo.getWorldName());
    properties.put("world.seed", worldInfo == null ? 0L : worldInfo.getSeed());
    properties.put("world.version", worldInfo == null ? 0 : worldInfo.getSaveVersion());
    properties.put("world.isHardcore", worldInfo == null ? false : worldInfo.isHardcoreModeEnabled());
    properties.put("world.hasFeatures", worldInfo == null ? false : worldInfo.isMapFeaturesEnabled());
    properties.put("world.hasCheats", worldInfo == null ? false : worldInfo.areCommandsAllowed());
    properties.put("world.gameMode", worldInfo == null ? "" : worldInfo.getGameType().getName());
    properties.put("world.gameMode.id", worldInfo == null ? 0 : worldInfo.getGameType().getID());
    properties.put("world.type", worldInfo == null ? "" : worldInfo.getTerrainType().getName());
    properties.put("world.type.version", worldInfo == null ? 0 : worldInfo.getTerrainType().getGeneratorVersion());
    String genName = "RandomLevelSource";
    String genClass = "ChunkProviderOverworld";

    if (world != null)
    {
        IChunkGenerator chunkGenerator = world.provider.createChunkGenerator();
        genName = chunkGenerator.toString();
        genClass = chunkGenerator.getClass().getSimpleName();

        if (chunkGenerator instanceof ChunkProviderOverworld)
        {
            genClass = "ChunkProviderOverworld";
        }
        else if (chunkGenerator instanceof ChunkProviderFlat)
        {
            genClass = "ChunkProviderFlat";
        }
        else if (chunkGenerator instanceof ChunkProviderHell)
        {
            genClass = "ChunkProviderHell";
        }
        else if (chunkGenerator instanceof ChunkProviderEnd)
        {
            genName = "EndRandomLevelSource";
            genClass = "ChunkProviderEnd";
        }
    }

    properties.put("dimension.generator", genName);
    properties.put("dimension.generator.class", genClass);
    properties.put("dimension", world == null ? "" : world.provider.getDimensionType().getName());
    properties.put("dimension.id", world == null ? 0 : world.provider.getDimension());
    properties.put("dimension.isSurface", world == null ? false : world.provider.isSurfaceWorld());
    properties.put("dimension.hasNoSky", world == null ? false : world.provider.hasNoSky());
    properties.put("dimension.groundLevel", world == null ? 0 : world.provider.getAverageGroundLevel());
    properties.put("dimension.actualHeight", world == null ? 0 : world.getActualHeight());
    properties.put("dimension.height", world == null ? 0 : world.getHeight());
    properties.put("age", false);
}