Moved ore generator to world.gen

This commit is contained in:
Emmanuel BENOîT 2016-07-03 09:20:29 +02:00
parent 0b2e45d2a2
commit 5033217643
12 changed files with 67 additions and 66 deletions

View file

@ -8,8 +8,8 @@ import mmm.materials.MOre;
import mmm.materials.Materials;
import mmm.utils.I_UOreGenerationRegistrar;
import mmm.world.WLocation;
import mmm.world.WOreGenerationCondition;
import mmm.world.WOreGenerationParameters;
import mmm.world.gen.WGOreCondition;
import mmm.world.gen.WGOreParameters;
@ -28,10 +28,10 @@ public class MOCassiterite
@Override
public void addConditions( final List< WOreGenerationCondition > conditions )
public void addConditions( final List< WGOreCondition > conditions )
{
conditions.add( new WOreGenerationCondition( WLocation.inOverworld( ) ,
new WOreGenerationParameters( this.getDefaultState( ) , 10 , 9 , 45 , 80 ) ) );
conditions.add( new WGOreCondition( WLocation.inOverworld( ) ,
new WGOreParameters( this.getDefaultState( ) , 10 , 9 , 45 , 80 ) ) );
}
}

View file

@ -7,8 +7,8 @@ import mmm.materials.MOre;
import mmm.materials.Materials;
import mmm.utils.I_UOreGenerationRegistrar;
import mmm.world.WLocation;
import mmm.world.WOreGenerationCondition;
import mmm.world.WOreGenerationParameters;
import mmm.world.gen.WGOreCondition;
import mmm.world.gen.WGOreParameters;
@ -25,12 +25,12 @@ public class MOCopper
@Override
public void addConditions( final List< WOreGenerationCondition > conditions )
public void addConditions( final List< WGOreCondition > conditions )
{
conditions.add( new WOreGenerationCondition( WLocation.inOverworld( ) ,
new WOreGenerationParameters( this.getDefaultState( ) , 20 , 9 , 0 , 128 ) ) );
conditions.add( new WOreGenerationCondition( WLocation.inOverworld( ) ,
new WOreGenerationParameters( this.getDefaultState( ) , 10 , 17 , 40 , 60 ) ) );
conditions.add( new WGOreCondition( WLocation.inOverworld( ) ,
new WGOreParameters( this.getDefaultState( ) , 20 , 9 , 0 , 128 ) ) );
conditions.add( new WGOreCondition( WLocation.inOverworld( ) ,
new WGOreParameters( this.getDefaultState( ) , 10 , 17 , 40 , 60 ) ) );
}
}

View file

@ -7,8 +7,8 @@ import mmm.materials.MOre;
import mmm.materials.Materials;
import mmm.utils.I_UOreGenerationRegistrar;
import mmm.world.WLocation;
import mmm.world.WOreGenerationCondition;
import mmm.world.WOreGenerationParameters;
import mmm.world.gen.WGOreCondition;
import mmm.world.gen.WGOreParameters;
@ -27,10 +27,10 @@ public class MOCuprite
@Override
public void addConditions( final List< WOreGenerationCondition > conditions )
public void addConditions( final List< WGOreCondition > conditions )
{
conditions.add( new WOreGenerationCondition( WLocation.inOverworld( ) ,
new WOreGenerationParameters( this.getDefaultState( ) , 10 , 9 , 0 , 60 ) ) );
conditions.add( new WGOreCondition( WLocation.inOverworld( ) ,
new WGOreParameters( this.getDefaultState( ) , 10 , 9 , 0 , 60 ) ) );
}
}

View file

@ -7,8 +7,8 @@ import mmm.materials.MOre;
import mmm.materials.Materials;
import mmm.utils.I_UOreGenerationRegistrar;
import mmm.world.WLocation;
import mmm.world.WOreGenerationCondition;
import mmm.world.WOreGenerationParameters;
import mmm.world.gen.WGOreCondition;
import mmm.world.gen.WGOreParameters;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.GameRegistry;
@ -30,10 +30,10 @@ public class MOMalachite
@Override
public void addConditions( final List< WOreGenerationCondition > conditions )
public void addConditions( final List< WGOreCondition > conditions )
{
conditions.add( new WOreGenerationCondition( WLocation.inOverworld( ) ,
new WOreGenerationParameters( this.getDefaultState( ) , 5 , 9 , 80 , 255 ) ) );
conditions.add( new WGOreCondition( WLocation.inOverworld( ) ,
new WGOreParameters( this.getDefaultState( ) , 5 , 9 , 80 , 255 ) ) );
}

View file

@ -7,8 +7,8 @@ import mmm.materials.MOre;
import mmm.materials.Materials;
import mmm.utils.I_UOreGenerationRegistrar;
import mmm.world.WLocation;
import mmm.world.WOreGenerationCondition;
import mmm.world.WOreGenerationParameters;
import mmm.world.gen.WGOreCondition;
import mmm.world.gen.WGOreParameters;
@ -27,10 +27,10 @@ public class MOSphalerite
@Override
public void addConditions( final List< WOreGenerationCondition > conditions )
public void addConditions( final List< WGOreCondition > conditions )
{
conditions.add( new WOreGenerationCondition( WLocation.inOverworld( ) ,
new WOreGenerationParameters( this.getDefaultState( ) , 15 , 15 ) ) );
conditions.add( new WGOreCondition( WLocation.inOverworld( ) ,
new WGOreParameters( this.getDefaultState( ) , 15 , 15 ) ) );
}
}

View file

@ -6,8 +6,8 @@ import java.util.List;
import mmm.utils.I_UOreGenerationRegistrar;
import mmm.utils.URegistry;
import mmm.world.WLocation;
import mmm.world.WOreGenerationCondition;
import mmm.world.WOreGenerationParameters;
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;
@ -34,10 +34,10 @@ public class MLimestone
@Override
public void addConditions( final List< WOreGenerationCondition > conditions )
public void addConditions( final List< WGOreCondition > conditions )
{
conditions.add( new WOreGenerationCondition( WLocation.inOverworld( ) ,
new WOreGenerationParameters( this.getDefaultState( ) , 15 , 40 ) ) );
conditions.add( new WGOreCondition( WLocation.inOverworld( ) ,
new WGOreParameters( this.getDefaultState( ) , 15 , 40 ) ) );
}
}

View file

@ -9,8 +9,8 @@ import mmm.tech.Tech;
import mmm.utils.UAccessors;
import mmm.utils.URegistry;
import mmm.utils.USeat;
import mmm.world.WOreGenerator;
import mmm.world.World;
import mmm.world.gen.WGOre;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
@ -36,6 +36,6 @@ public abstract class PCommon
public void init( final FMLInitializationEvent event )
{
USeat.register( Mmm.get( ) );
WOreGenerator.init( );
WGOre.init( );
}
}

View file

@ -3,13 +3,13 @@ package mmm.utils;
import java.util.List;
import mmm.world.WOreGenerationCondition;
import mmm.world.gen.WGOreCondition;
public interface I_UOreGenerationRegistrar
{
public void addConditions( List< WOreGenerationCondition > conditions );
public void addConditions( List< WGOreCondition > conditions );
}

View file

@ -1,17 +0,0 @@
package mmm.world;
public class WOreGenerationCondition
{
public final I_WLocationCheck conditions;
public final WOreGenerationParameters parameters;
public WOreGenerationCondition( final I_WLocationCheck conditions , final WOreGenerationParameters parameters )
{
this.conditions = conditions;
this.parameters = parameters;
}
}

View file

@ -1,4 +1,4 @@
package mmm.world;
package mmm.world.gen;
import java.util.ArrayList;
@ -14,23 +14,23 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
public class WOreGenerator
public class WGOre
implements IWorldGenerator
{
public static void init( )
{
final ArrayList< WOreGenerationCondition > conditions = new ArrayList<>( );
final ArrayList< WGOreCondition > conditions = new ArrayList<>( );
for ( final I_UOreGenerationRegistrar registrar : URegistry.getOreGenerationRegistrars( ) ) {
registrar.addConditions( conditions );
}
GameRegistry.registerWorldGenerator( new WOreGenerator( conditions ) , 0 );
GameRegistry.registerWorldGenerator( new WGOre( conditions ) , 0 );
}
private final ArrayList< WOreGenerationCondition > conditions;
private final ArrayList< WGOreCondition > conditions;
private WOreGenerator( final ArrayList< WOreGenerationCondition > conditions )
private WGOre( final ArrayList< WGOreCondition > conditions )
{
this.conditions = conditions;
}
@ -42,7 +42,7 @@ public class WOreGenerator
{
final int n = this.conditions.size( );
for ( int i = 0 ; i < n ; i++ ) {
final WOreGenerationCondition cond = this.conditions.get( i );
final WGOreCondition cond = this.conditions.get( i );
if ( cond.conditions.checkLocation( world , chunkX , chunkZ , chunkProvider ) ) {
cond.parameters.generate( world , random , chunkX , chunkZ );
}

View file

@ -0,0 +1,18 @@
package mmm.world.gen;
import mmm.world.I_WLocationCheck;
public class WGOreCondition
{
public final I_WLocationCheck conditions;
public final WGOreParameters parameters;
public WGOreCondition( final I_WLocationCheck conditions , final WGOreParameters parameters )
{
this.conditions = conditions;
this.parameters = parameters;
}
}

View file

@ -1,4 +1,4 @@
package mmm.world;
package mmm.world.gen;
import java.util.Random;
@ -15,7 +15,7 @@ import net.minecraft.world.gen.feature.WorldGenMinable;
public class WOreGenerationParameters
public class WGOreParameters
{
public final IBlockState ore;
@ -28,28 +28,28 @@ public class WOreGenerationParameters
private WorldGenMinable generator;
public WOreGenerationParameters( final IBlockState ore , final int clusters , final int clusterSize )
public WGOreParameters( final IBlockState ore , final int clusters , final int clusterSize )
{
this( ore , clusters , clusterSize , Integer.MIN_VALUE , Integer.MIN_VALUE ,
BlockMatcher.forBlock( Blocks.STONE ) );
}
public WOreGenerationParameters( final IBlockState ore , final int clusters , final int clusterSize ,
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 ) );
}
public WOreGenerationParameters( final IBlockState ore , final int clusters , final int clusterSize ,
public WGOreParameters( final IBlockState ore , final int clusters , final int clusterSize ,
final Predicate< IBlockState > matcher )
{
this( ore , clusters , clusterSize , Integer.MIN_VALUE , Integer.MIN_VALUE , matcher );
}
public WOreGenerationParameters( final IBlockState ore , final int clusters , final int clusterSize ,
public WGOreParameters( final IBlockState ore , final int clusters , final int clusterSize ,
int minHeight , int maxHeight , final Predicate< IBlockState > matcher )
{
if ( clusters < 1 ) {