Improved basalt around lava

This commit is contained in:
Emmanuel BENOîT 2016-07-10 21:10:28 +02:00
parent d0df8a3941
commit b90b53cbe0
4 changed files with 26 additions and 20 deletions

View file

@ -1,7 +1,10 @@
package mmm.world; package mmm.world;
import java.util.Random;
import mmm.world.biome.I_WBTrappedBiome; import mmm.world.biome.I_WBTrappedBiome;
import mmm.world.gen.WGBasalt;
import mmm.world.gen.WGTrapBlocks; import mmm.world.gen.WGTrapBlocks;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@ -37,9 +40,12 @@ public class WDefaultGenWatcher
final BlockPos bp = new BlockPos( event.getChunkX( ) * 16 , 0 , event.getChunkZ( ) * 16 ); final BlockPos bp = new BlockPos( event.getChunkX( ) * 16 , 0 , event.getChunkZ( ) * 16 );
final net.minecraft.world.World world = event.getWorld( ); final net.minecraft.world.World world = event.getWorld( );
final Random rand = event.getRand( );
new WGBasalt( false ).generate( world , rand , bp );
final Biome biome = world.getBiomeGenForCoords( bp ); final Biome biome = world.getBiomeGenForCoords( bp );
// FIXME hardcoding is bad // FIXME hardcoding is bad
final WGTrapBlocks traps; final WGTrapBlocks traps;
if ( biome instanceof BiomeDesert ) { if ( biome instanceof BiomeDesert ) {
traps = new WGTrapBlocks( false , .05f ); traps = new WGTrapBlocks( false , .05f );
@ -51,7 +57,7 @@ public class WDefaultGenWatcher
return; return;
} }
traps.generate( world , event.getRand( ) , bp ); traps.generate( world , rand , bp );
} }
} }

View file

@ -9,7 +9,6 @@ import mmm.world.biome.WBBambooForest;
import mmm.world.biome.WBLimestoneMountains; import mmm.world.biome.WBLimestoneMountains;
import mmm.world.biome.WBLimestonePlateau; import mmm.world.biome.WBLimestonePlateau;
import mmm.world.biome.WBTropicalSwamp; import mmm.world.biome.WBTropicalSwamp;
import mmm.world.gen.WGBasalt;
import mmm.world.gen.WGOre; import mmm.world.gen.WGOre;
import mmm.world.gen.WGOreCondition; import mmm.world.gen.WGOreCondition;
import net.minecraftforge.common.BiomeManager.BiomeType; import net.minecraftforge.common.BiomeManager.BiomeType;
@ -22,7 +21,7 @@ public class World
{ {
static { static {
WDefaultGenWatcher dgw = new WDefaultGenWatcher( ); final WDefaultGenWatcher dgw = new WDefaultGenWatcher( );
MinecraftForge.TERRAIN_GEN_BUS.register( dgw ); MinecraftForge.TERRAIN_GEN_BUS.register( dgw );
MinecraftForge.EVENT_BUS.register( dgw ); MinecraftForge.EVENT_BUS.register( dgw );
@ -87,8 +86,7 @@ public class World
helper.startMutation( ); helper.startMutation( );
helper.setNames( "Dense Bamboo Forest" , "forest/bamboo/dense" ) // helper.setNames( "Dense Bamboo Forest" , "forest/bamboo/dense" ) //
.setType( BiomeType.WARM , 1 ) // .setType( BiomeType.WARM , 1 ) //
.setExtraProperty( "Dense" ) .setExtraProperty( "Dense" ).register( );
.register( );
} }
@ -105,7 +103,6 @@ public class World
registrar.addConditions( conditions ); registrar.addConditions( conditions );
} }
GameRegistry.registerWorldGenerator( new WGOre( conditions ) , 0 ); GameRegistry.registerWorldGenerator( new WGOre( conditions ) , 0 );
GameRegistry.registerWorldGenerator( new WGBasalt( ) , 1000 );
} }
} }

View file

@ -80,7 +80,6 @@ public class WBBambooForest
@Override @Override
public void decorate( final World worldIn , final Random rand , final BlockPos pos ) public void decorate( final World worldIn , final Random rand , final BlockPos pos )
{ {
System.err.println( pos.toString( ) );
for ( int cx = pos.getX( ) ; cx < pos.getX( ) + 16 ; cx++ ) { for ( int cx = pos.getX( ) ; cx < pos.getX( ) + 16 ; cx++ ) {
for ( int cz = pos.getZ( ) ; cz < pos.getZ( ) + 16 ; cz++ ) { for ( int cz = pos.getZ( ) ; cz < pos.getZ( ) + 16 ; cz++ ) {
final double noise = Biome.GRASS_COLOR_NOISE.getValue( cz * 0.25D , cx * 0.25D ); final double noise = Biome.GRASS_COLOR_NOISE.getValue( cz * 0.25D , cx * 0.25D );

View file

@ -9,24 +9,27 @@ import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.DimensionType; import net.minecraft.world.DimensionType;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkGenerator; import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraftforge.fml.common.IWorldGenerator;
public class WGBasalt public class WGBasalt
implements IWorldGenerator extends WorldGenerator
{ {
private static final IBlockState BS_BASALT = Materials.ROCK.BASALT.getDefaultState( ); private static final IBlockState BS_BASALT = Materials.ROCK.BASALT.getDefaultState( );
public WGBasalt( final boolean notify )
{
super( notify );
}
@Override @Override
public void generate( final Random random , final int chunkX , final int chunkZ , final World world , public boolean generate( final World world , final Random rand , final BlockPos position )
final IChunkGenerator chunkGenerator , final IChunkProvider chunkProvider )
{ {
if ( world.provider.getDimensionType( ) != DimensionType.OVERWORLD ) { if ( world.provider.getDimensionType( ) != DimensionType.OVERWORLD ) {
return; return false;
} }
// TODO: prevent basalt from generating in some biomes // TODO: prevent basalt from generating in some biomes
@ -36,7 +39,7 @@ public class WGBasalt
final BlockPos.MutableBlockPos mbp = new BlockPos.MutableBlockPos( ); final BlockPos.MutableBlockPos mbp = new BlockPos.MutableBlockPos( );
for ( int x = 0 ; x < 16 ; x++ ) { for ( int x = 0 ; x < 16 ; x++ ) {
for ( int z = 0 ; z < 16 ; z++ ) { for ( int z = 0 ; z < 16 ; z++ ) {
mbp.setPos( chunkX * 16 + x , 0 , chunkZ * 16 + z ); mbp.setPos( position.getX( ) + x , 0 , position.getZ( ) + z );
for ( int y = 0 ; y < 256 ; y++ ) { for ( int y = 0 ; y < 256 ; y++ ) {
mbp.setY( y ); mbp.setY( y );
final IBlockState bs = world.getBlockState( mbp ); final IBlockState bs = world.getBlockState( mbp );
@ -52,15 +55,17 @@ public class WGBasalt
int offset = 0; int offset = 0;
for ( int x = 0 ; x < 16 ; x++ ) { for ( int x = 0 ; x < 16 ; x++ ) {
for ( int z = 0 ; z < 16 ; z++ ) { for ( int z = 0 ; z < 16 ; z++ ) {
mbp.setPos( chunkX * 16 + x , 0 , chunkZ * 16 + z ); mbp.setPos( position.getX( ) + x , 0 , position.getZ( ) + z );
for ( int y = 0 ; y < 256 ; y++ ) { for ( int y = 0 ; y < 256 ; y++ ) {
if ( rockNearLava[ offset++ ] && random.nextInt( 5 ) != 4 ) { if ( rockNearLava[ offset++ ] && rand.nextInt( 5 ) != 4 ) {
mbp.setY( y ); mbp.setY( y );
world.setBlockState( mbp , WGBasalt.BS_BASALT ); world.setBlockState( mbp , WGBasalt.BS_BASALT );
} }
} }
} }
} }
return true;
} }
@ -94,5 +99,4 @@ public class WGBasalt
} }
} }
} }
} }