Imperfect but mostly working basalt generator
Generates near lava, but has trouble with chunk boundaries Also fixed MRock
This commit is contained in:
parent
bb88579c9f
commit
b7995fa4a1
4 changed files with 86 additions and 25 deletions
8
TODO.txt
8
TODO.txt
|
@ -11,6 +11,9 @@ deco No Limestone...
|
|||
deco No Slate...
|
||||
...stairs
|
||||
...slabs
|
||||
deco No Basalt...
|
||||
...stairs
|
||||
...slabs
|
||||
-------------------------------------------------------------------------------------------------------
|
||||
plants No? Tomatoes
|
||||
plants No? Turnips
|
||||
|
@ -51,7 +54,7 @@ materials No Liquids
|
|||
-------------------------------------------------------------------------------------------------------
|
||||
materials.rock No Smooth limestone
|
||||
materials.rock No Smooth slate
|
||||
materials.rock No Basalt
|
||||
materials.rock No Smooth basalt
|
||||
-------------------------------------------------------------------------------------------------------
|
||||
materials.ore No Silver (native, horn silver)
|
||||
materials.ore No Olivine
|
||||
|
@ -68,9 +71,12 @@ tech.tools No Pan (for e.g. panning gold)
|
|||
-> limit it per chunk
|
||||
-> depend on chunk minerals
|
||||
-------------------------------------------------------------------------------------------------------
|
||||
tech.blackboard ??? AUGUSTIN WANTS IT!
|
||||
-------------------------------------------------------------------------------------------------------
|
||||
animals ??? Goats
|
||||
-------------------------------------------------------------------------------------------------------
|
||||
world ??? Improved system to handle neighbouring biomes BF
|
||||
world.gen ??? Make basalt gen behave correctly at chunk boundaries BF
|
||||
world ??? Volcanos
|
||||
-------------------------------------------------------------------------------------------------------
|
||||
??? ??? Sub-blocks
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
package mmm.materials;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mmm.utils.I_UOreGenerationRegistrar;
|
||||
import mmm.utils.URegistry;
|
||||
import mmm.world.gen.WGOreCondition;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.MapColor;
|
||||
|
@ -16,12 +12,9 @@ import net.minecraft.creativetab.CreativeTabs;
|
|||
|
||||
public class MRock
|
||||
extends Block
|
||||
implements I_MRock , I_UOreGenerationRegistrar
|
||||
implements I_MRock
|
||||
{
|
||||
|
||||
private WGOreCondition[] genConditions;
|
||||
|
||||
|
||||
public MRock( final String name , final MapColor mapColor )
|
||||
{
|
||||
this( name , mapColor , 0 , 1.5f , 10f );
|
||||
|
@ -47,20 +40,4 @@ public class MRock
|
|||
URegistry.addBlock( this );
|
||||
}
|
||||
|
||||
|
||||
public MRock setConditions( final WGOreCondition... genConditions )
|
||||
{
|
||||
this.genConditions = genConditions.clone( );
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addConditions( final List< WGOreCondition > conditions )
|
||||
{
|
||||
for ( int i = 0 ; i < this.genConditions.length ; i++ ) {
|
||||
conditions.add( this.genConditions[ i ] );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import mmm.utils.I_UOreGenerationRegistrar;
|
|||
import mmm.utils.URegistry;
|
||||
import mmm.world.biome.WBLimestoneMountains;
|
||||
import mmm.world.biome.WBLimestonePlateau;
|
||||
import mmm.world.gen.WGBasalt;
|
||||
import mmm.world.gen.WGOre;
|
||||
import mmm.world.gen.WGOreCondition;
|
||||
import net.minecraftforge.common.BiomeManager.BiomeType;
|
||||
|
@ -79,6 +80,7 @@ public class World
|
|||
registrar.addConditions( conditions );
|
||||
}
|
||||
GameRegistry.registerWorldGenerator( new WGOre( conditions ) , 0 );
|
||||
GameRegistry.registerWorldGenerator( new WGBasalt( ) , 1000 );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,11 @@ package mmm.world.gen;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import mmm.materials.Materials;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkGenerator;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
|
@ -13,13 +18,84 @@ import net.minecraftforge.fml.common.IWorldGenerator;
|
|||
public class WGBasalt
|
||||
implements IWorldGenerator
|
||||
{
|
||||
private static final IBlockState BS_BASALT = Materials.ROCK_BASALT.getDefaultState( );
|
||||
|
||||
|
||||
@Override
|
||||
public void generate( final Random random , final int chunkX , final int chunkZ , final World world ,
|
||||
final IChunkGenerator chunkGenerator , final IChunkProvider chunkProvider )
|
||||
{
|
||||
if ( world.provider.getDimensionType( ) != DimensionType.OVERWORLD ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: prevent basalt from generating in some biomes
|
||||
|
||||
// Find all rock blocks that are close to some lava
|
||||
final boolean rockNearLava[] = new boolean[ 16 * 16 * 256 ];
|
||||
final BlockPos.MutableBlockPos mbp = new BlockPos.MutableBlockPos( );
|
||||
for ( int x = 0 ; x < 16 ; x++ ) {
|
||||
for ( int z = 0 ; z < 16 ; z++ ) {
|
||||
mbp.setPos( chunkX * 16 + x , 0 , chunkZ * 16 + z );
|
||||
for ( int y = 0 ; y < 256 ; y++ ) {
|
||||
mbp.setY( y );
|
||||
final IBlockState bs = world.getBlockState( mbp );
|
||||
if ( bs.getBlock( ) != Blocks.LAVA ) {
|
||||
continue;
|
||||
}
|
||||
this.scanForRocksAround( world , rockNearLava , mbp , x , y , z );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Replace some of them with basalt
|
||||
int offset = 0;
|
||||
for ( int x = 0 ; x < 16 ; x++ ) {
|
||||
for ( int z = 0 ; z < 16 ; z++ ) {
|
||||
mbp.setPos( chunkX * 16 + x , 0 , chunkZ * 16 + z );
|
||||
for ( int y = 0 ; y < 256 ; y++ ) {
|
||||
if ( rockNearLava[ offset++ ] && random.nextInt( 5 ) != 4 ) {
|
||||
mbp.setY( y );
|
||||
world.setBlockState( mbp , WGBasalt.BS_BASALT );
|
||||
if ( y >= 40 ) {
|
||||
System.err.println( "BASALT at " + mbp );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void scanForRocksAround( final World world , final boolean[] rockNearLava ,
|
||||
final BlockPos.MutableBlockPos mbp , final int x , final int y , final int z )
|
||||
{
|
||||
final BlockPos.MutableBlockPos mbps = new BlockPos.MutableBlockPos( );
|
||||
for ( int i = -2 ; i <= 2 ; i++ ) {
|
||||
final int xb = x + i;
|
||||
|
||||
for ( int j = -2 ; j <= 2 ; j++ ) {
|
||||
final int zb = z + j;
|
||||
|
||||
for ( int k = -2 ; k <= 2 ; k++ ) {
|
||||
final int yb = y + k;
|
||||
if ( i == 0 && j == 0 && k == 0 || xb < 0 || xb > 15 || zb < 0 || zb > 15 || yb < 0 || yb > 255 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final int offset = ( xb * 16 + zb ) * 256 + yb;
|
||||
if ( rockNearLava[ offset ] ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mbps.setPos( mbp.getX( ) + i , yb , mbp.getZ( ) + j );
|
||||
// System.err.println( "pos = " + mbps );
|
||||
if ( Materials.isRock( world.getBlockState( mbps ) ) ) {
|
||||
rockNearLava[ offset ] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue