Basalt + better custom rocks

Avoid having classes for each type of rock, add generation conditions
from the Materials directly.
This commit is contained in:
Emmanuel BENOîT 2016-07-08 09:09:38 +02:00
parent c390ed74f2
commit bb88579c9f
14 changed files with 205 additions and 137 deletions

View file

@ -0,0 +1,7 @@
package mmm.materials;
public interface I_MRock
{
// EMPTY
}

View file

@ -0,0 +1,66 @@
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;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
public class MRock
extends Block
implements I_MRock , I_UOreGenerationRegistrar
{
private WGOreCondition[] genConditions;
public MRock( final String name , final MapColor mapColor )
{
this( name , mapColor , 0 , 1.5f , 10f );
}
public MRock( final String name , final MapColor mapColor , final int harvestLevel )
{
this( name , mapColor , harvestLevel , 1.5f , 10f );
}
public MRock( final String name , final MapColor mapColor , final int harvestLevel , final float hardness ,
final float resistance )
{
super( Material.ROCK , mapColor );
this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS );
this.setHardness( hardness );
this.setResistance( resistance );
this.setSoundType( SoundType.STONE );
this.setHarvestLevel( "pickaxe" , harvestLevel );
URegistry.setIdentifiers( this , "materials" , "rock" , name );
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 ] );
}
}
}

View file

@ -1,6 +1,8 @@
package mmm.materials;
import java.util.List;
import mmm.materials.ore.MOBauxite;
import mmm.materials.ore.MOCassiterite;
import mmm.materials.ore.MOCinnabar;
@ -10,25 +12,33 @@ import mmm.materials.ore.MOGalena;
import mmm.materials.ore.MOMalachite;
import mmm.materials.ore.MORockSalt;
import mmm.materials.ore.MOSphalerite;
import mmm.materials.rock.MRChalk;
import mmm.materials.rock.MRLimestone;
import mmm.materials.rock.MRSlate;
import mmm.utils.I_UOreGenerationRegistrar;
import mmm.utils.I_URecipeRegistrar;
import mmm.utils.URegistry;
import mmm.world.WLocation;
import mmm.world.WLocationInBiome;
import mmm.world.gen.WGOreCondition;
import mmm.world.gen.WGOreParameters;
import net.minecraft.block.Block;
import net.minecraft.block.BlockStone;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.world.biome.BiomePlains;
import net.minecraft.world.biome.BiomeSwamp;
public class Materials
implements I_URecipeRegistrar
implements I_URecipeRegistrar , I_UOreGenerationRegistrar
{
public static final MRLimestone ROCK_LIMESTONE;
public static final MRChalk ROCK_CHALK;
public static final MRSlate ROCK_SLATE;
public static final MRock ROCK_LIMESTONE;
public static final MRock ROCK_CHALK;
public static final MRock ROCK_SLATE;
public static final MRock ROCK_BASALT;
public static final MMetal GOLD;
public static final MMetal IRON;
@ -61,9 +71,10 @@ public class Materials
static {
// Rocks
URegistry.addBlock( ROCK_LIMESTONE = new MRLimestone( ) );
URegistry.addBlock( ROCK_CHALK = new MRChalk( ) );
URegistry.addBlock( ROCK_SLATE = new MRSlate( ) );
ROCK_LIMESTONE = new MRock( "limestone" , MapColor.SNOW , 0 , 1f , 7.5f );
ROCK_CHALK = new MRock( "chalk" , MapColor.SNOW , 0 , 1f , 5f );
ROCK_SLATE = new MRock( "slate" , MapColor.BLACK );
ROCK_BASALT = new MRock( "basalt" , MapColor.BLACK );
// Vanilla metals
GOLD = new MMetal( Blocks.GOLD_BLOCK , Items.GOLD_INGOT , Items.GOLD_NUGGET );
@ -105,8 +116,9 @@ public class Materials
ORE_GALENA = new MOGalena( );
ORE_CINNABAR = new MOCinnabar( );
// Other recipes
URegistry.addRecipeRegistrar( new Materials( ) );
// Other recipes, ore generation parameters, etc.
final Materials materials = new Materials( );
URegistry.addRecipeRegistrar( materials );
}
@ -134,6 +146,21 @@ public class Materials
}
public static boolean isRock( final IBlockState bs )
{
final Block block = bs.getBlock( );
if ( block instanceof BlockStone ) {
final BlockStone.EnumType variant = bs.getValue( BlockStone.VARIANT );
return variant == BlockStone.EnumType.ANDESITE || variant == BlockStone.EnumType.DIORITE
|| variant == BlockStone.EnumType.GRANITE || variant == BlockStone.EnumType.STONE;
}
if ( block == Blocks.COBBLESTONE ) {
return true;
}
return block instanceof I_MRock;
}
private Materials( )
{
// EMPTY
@ -187,4 +214,21 @@ public class Materials
.setOutput( Materials.ITEM_COKE ).setSlag( 1 ).register( );
}
@Override
public void addConditions( final List< WGOreCondition > conditions )
{
conditions.add( new WGOreCondition( //
WLocation.inOverworld( ) , //
new WGOreParameters( Materials.ROCK_LIMESTONE , 15 , 40 ) ) );
conditions.add( new WGOreCondition( //
new WLocationInBiome<>( BiomePlains.class ) , //
new WGOreParameters( Materials.ROCK_SLATE , 15 , 40 ) ) );
conditions.add( new WGOreCondition( //
new WLocationInBiome<>( BiomeSwamp.class ) , //
new WGOreParameters( Materials.ROCK_SLATE , 20 , 60 ) ) );
}
}

View file

@ -3,6 +3,7 @@ package mmm.materials.ore;
import java.util.List;
import mmm.materials.I_MRock;
import mmm.materials.MOre;
import mmm.utils.I_UOreGenerationRegistrar;
import mmm.world.WLocation;
@ -13,7 +14,7 @@ import mmm.world.gen.WGOreParameters;
public class MOCinnabar
extends MOre
implements I_UOreGenerationRegistrar
implements I_UOreGenerationRegistrar , I_MRock
{
public MOCinnabar( )

View file

@ -1,28 +0,0 @@
package mmm.materials.rock;
import mmm.utils.URegistry;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
public class MRChalk
extends Block
{
public MRChalk( )
{
super( Material.ROCK , MapColor.SNOW );
this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS );
this.setHardness( 1f );
this.setResistance( 5f );
this.setSoundType( SoundType.STONE );
this.setHarvestLevel( "pickaxe" , 0 );
URegistry.setIdentifiers( this , "materials" , "rock" , "chalk" );
}
}

View file

@ -1,43 +0,0 @@
package mmm.materials.rock;
import java.util.List;
import mmm.utils.I_UOreGenerationRegistrar;
import mmm.utils.URegistry;
import mmm.world.WLocation;
import mmm.world.gen.WGOreCondition;
import mmm.world.gen.WGOreParameters;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
public class MRLimestone
extends Block
implements I_UOreGenerationRegistrar
{
public MRLimestone( )
{
super( Material.ROCK , MapColor.SNOW );
this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS );
this.setHardness( 1f );
this.setResistance( 7.5f );
this.setSoundType( SoundType.STONE );
this.setHarvestLevel( "pickaxe" , 0 );
URegistry.setIdentifiers( this , "materials" , "rock" , "limestone" );
}
@Override
public void addConditions( final List< WGOreCondition > conditions )
{
conditions.add( new WGOreCondition( WLocation.inOverworld( ) ,
new WGOreParameters( this.getDefaultState( ) , 15 , 40 ) ) );
}
}

View file

@ -1,49 +0,0 @@
package mmm.materials.rock;
import java.util.List;
import mmm.utils.I_UOreGenerationRegistrar;
import mmm.utils.URegistry;
import mmm.world.WLocationInBiome;
import mmm.world.gen.WGOreCondition;
import mmm.world.gen.WGOreParameters;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.world.biome.BiomePlains;
import net.minecraft.world.biome.BiomeSwamp;
public class MRSlate
extends Block
implements I_UOreGenerationRegistrar
{
public MRSlate( )
{
super( Material.ROCK , MapColor.BLACK );
this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS );
this.setHardness( 1.5f );
this.setResistance( 10f );
this.setSoundType( SoundType.STONE );
this.setHarvestLevel( "pickaxe" , 0 );
URegistry.setIdentifiers( this , "materials" , "rock" , "slate" );
}
@Override
public void addConditions( final List< WGOreCondition > conditions )
{
conditions.add( new WGOreCondition( //
new WLocationInBiome<>( BiomePlains.class ) ,
new WGOreParameters( this.getDefaultState( ) , 15 , 40 ) ) );
conditions.add( new WGOreCondition( //
new WLocationInBiome<>( BiomeSwamp.class ) ,
new WGOreParameters( this.getDefaultState( ) , 20 , 60 ) ) );
}
}

View file

@ -0,0 +1,25 @@
package mmm.world.gen;
import java.util.Random;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraftforge.fml.common.IWorldGenerator;
public class WGBasalt
implements IWorldGenerator
{
@Override
public void generate( final Random random , final int chunkX , final int chunkZ , final World world ,
final IChunkGenerator chunkGenerator , final IChunkProvider chunkProvider )
{
// TODO: prevent basalt from generating in some biomes
}
}

View file

@ -5,6 +5,7 @@ import java.util.Random;
import com.google.common.base.Predicate;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.pattern.BlockMatcher;
import net.minecraft.init.Blocks;
@ -28,6 +29,35 @@ public class WGOreParameters
private WorldGenMinable generator;
public WGOreParameters( final Block ore , final int clusters , final int clusterSize )
{
this( ore.getDefaultState( ) , clusters , clusterSize , Integer.MIN_VALUE , Integer.MIN_VALUE ,
BlockMatcher.forBlock( Blocks.STONE ) );
}
public WGOreParameters( final Block ore , final int clusters , final int clusterSize , final int minHeight ,
final int maxHeight )
{
this( ore.getDefaultState( ) , clusters , clusterSize , minHeight , maxHeight ,
BlockMatcher.forBlock( Blocks.STONE ) );
}
public WGOreParameters( final Block ore , final int clusters , final int clusterSize ,
final Predicate< IBlockState > matcher )
{
this( ore.getDefaultState( ) , clusters , clusterSize , Integer.MIN_VALUE , Integer.MIN_VALUE , matcher );
}
public WGOreParameters( final Block ore , final int clusters , final int clusterSize , final int minHeight ,
final int maxHeight , final Predicate< IBlockState > matcher )
{
this( ore.getDefaultState( ) , clusters , clusterSize , minHeight , maxHeight , matcher );
}
public WGOreParameters( final IBlockState ore , final int clusters , final int clusterSize )
{
this( ore , clusters , clusterSize , Integer.MIN_VALUE , Integer.MIN_VALUE ,
@ -35,8 +65,8 @@ public class WGOreParameters
}
public WGOreParameters( final IBlockState ore , final int clusters , final int clusterSize ,
final int minHeight , final int maxHeight )
public WGOreParameters( final IBlockState ore , final int clusters , final int clusterSize , final int minHeight ,
final int maxHeight )
{
this( ore , clusters , clusterSize , minHeight , maxHeight , BlockMatcher.forBlock( Blocks.STONE ) );
}
@ -49,8 +79,8 @@ public class WGOreParameters
}
public WGOreParameters( final IBlockState ore , final int clusters , final int clusterSize ,
int minHeight , int maxHeight , final Predicate< IBlockState > matcher )
public WGOreParameters( final IBlockState ore , final int clusters , final int clusterSize , int minHeight ,
int maxHeight , final Predicate< IBlockState > matcher )
{
if ( clusters < 1 ) {
throw new IllegalArgumentException( "cluster count should be at least 1" );

View file

@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "mmm:materials/rock/basalt" }
}
}

View file

@ -11,6 +11,7 @@ gui.mmm.tech.base.am.disabled=Deactivated
tile.mmm.materials.rock.limestone.name=Limestone
tile.mmm.materials.rock.chalk.name=Chalk
tile.mmm.materials.rock.slate.name=Slate
tile.mmm.materials.rock.basalt.name=Basalt
tile.mmm.materials.ore.rock_salt.name=Rock Salt
item.mmm.materials.stone.rock_salt.name=Salt Crystals

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "mmm:blocks/materials/rock/basalt"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "mmm:block/materials/rock/basalt"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B