Moved ore generator to world.gen
This commit is contained in:
parent
0b2e45d2a2
commit
5033217643
12 changed files with 67 additions and 66 deletions
|
@ -8,8 +8,8 @@ import mmm.materials.MOre;
|
||||||
import mmm.materials.Materials;
|
import mmm.materials.Materials;
|
||||||
import mmm.utils.I_UOreGenerationRegistrar;
|
import mmm.utils.I_UOreGenerationRegistrar;
|
||||||
import mmm.world.WLocation;
|
import mmm.world.WLocation;
|
||||||
import mmm.world.WOreGenerationCondition;
|
import mmm.world.gen.WGOreCondition;
|
||||||
import mmm.world.WOreGenerationParameters;
|
import mmm.world.gen.WGOreParameters;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,10 +28,10 @@ public class MOCassiterite
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addConditions( final List< WOreGenerationCondition > conditions )
|
public void addConditions( final List< WGOreCondition > conditions )
|
||||||
{
|
{
|
||||||
conditions.add( new WOreGenerationCondition( WLocation.inOverworld( ) ,
|
conditions.add( new WGOreCondition( WLocation.inOverworld( ) ,
|
||||||
new WOreGenerationParameters( this.getDefaultState( ) , 10 , 9 , 45 , 80 ) ) );
|
new WGOreParameters( this.getDefaultState( ) , 10 , 9 , 45 , 80 ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@ import mmm.materials.MOre;
|
||||||
import mmm.materials.Materials;
|
import mmm.materials.Materials;
|
||||||
import mmm.utils.I_UOreGenerationRegistrar;
|
import mmm.utils.I_UOreGenerationRegistrar;
|
||||||
import mmm.world.WLocation;
|
import mmm.world.WLocation;
|
||||||
import mmm.world.WOreGenerationCondition;
|
import mmm.world.gen.WGOreCondition;
|
||||||
import mmm.world.WOreGenerationParameters;
|
import mmm.world.gen.WGOreParameters;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,12 +25,12 @@ public class MOCopper
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addConditions( final List< WOreGenerationCondition > conditions )
|
public void addConditions( final List< WGOreCondition > conditions )
|
||||||
{
|
{
|
||||||
conditions.add( new WOreGenerationCondition( WLocation.inOverworld( ) ,
|
conditions.add( new WGOreCondition( WLocation.inOverworld( ) ,
|
||||||
new WOreGenerationParameters( this.getDefaultState( ) , 20 , 9 , 0 , 128 ) ) );
|
new WGOreParameters( this.getDefaultState( ) , 20 , 9 , 0 , 128 ) ) );
|
||||||
conditions.add( new WOreGenerationCondition( WLocation.inOverworld( ) ,
|
conditions.add( new WGOreCondition( WLocation.inOverworld( ) ,
|
||||||
new WOreGenerationParameters( this.getDefaultState( ) , 10 , 17 , 40 , 60 ) ) );
|
new WGOreParameters( this.getDefaultState( ) , 10 , 17 , 40 , 60 ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@ import mmm.materials.MOre;
|
||||||
import mmm.materials.Materials;
|
import mmm.materials.Materials;
|
||||||
import mmm.utils.I_UOreGenerationRegistrar;
|
import mmm.utils.I_UOreGenerationRegistrar;
|
||||||
import mmm.world.WLocation;
|
import mmm.world.WLocation;
|
||||||
import mmm.world.WOreGenerationCondition;
|
import mmm.world.gen.WGOreCondition;
|
||||||
import mmm.world.WOreGenerationParameters;
|
import mmm.world.gen.WGOreParameters;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,10 +27,10 @@ public class MOCuprite
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addConditions( final List< WOreGenerationCondition > conditions )
|
public void addConditions( final List< WGOreCondition > conditions )
|
||||||
{
|
{
|
||||||
conditions.add( new WOreGenerationCondition( WLocation.inOverworld( ) ,
|
conditions.add( new WGOreCondition( WLocation.inOverworld( ) ,
|
||||||
new WOreGenerationParameters( this.getDefaultState( ) , 10 , 9 , 0 , 60 ) ) );
|
new WGOreParameters( this.getDefaultState( ) , 10 , 9 , 0 , 60 ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@ import mmm.materials.MOre;
|
||||||
import mmm.materials.Materials;
|
import mmm.materials.Materials;
|
||||||
import mmm.utils.I_UOreGenerationRegistrar;
|
import mmm.utils.I_UOreGenerationRegistrar;
|
||||||
import mmm.world.WLocation;
|
import mmm.world.WLocation;
|
||||||
import mmm.world.WOreGenerationCondition;
|
import mmm.world.gen.WGOreCondition;
|
||||||
import mmm.world.WOreGenerationParameters;
|
import mmm.world.gen.WGOreParameters;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||||
|
@ -30,10 +30,10 @@ public class MOMalachite
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addConditions( final List< WOreGenerationCondition > conditions )
|
public void addConditions( final List< WGOreCondition > conditions )
|
||||||
{
|
{
|
||||||
conditions.add( new WOreGenerationCondition( WLocation.inOverworld( ) ,
|
conditions.add( new WGOreCondition( WLocation.inOverworld( ) ,
|
||||||
new WOreGenerationParameters( this.getDefaultState( ) , 5 , 9 , 80 , 255 ) ) );
|
new WGOreParameters( this.getDefaultState( ) , 5 , 9 , 80 , 255 ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ import mmm.materials.MOre;
|
||||||
import mmm.materials.Materials;
|
import mmm.materials.Materials;
|
||||||
import mmm.utils.I_UOreGenerationRegistrar;
|
import mmm.utils.I_UOreGenerationRegistrar;
|
||||||
import mmm.world.WLocation;
|
import mmm.world.WLocation;
|
||||||
import mmm.world.WOreGenerationCondition;
|
import mmm.world.gen.WGOreCondition;
|
||||||
import mmm.world.WOreGenerationParameters;
|
import mmm.world.gen.WGOreParameters;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,10 +27,10 @@ public class MOSphalerite
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addConditions( final List< WOreGenerationCondition > conditions )
|
public void addConditions( final List< WGOreCondition > conditions )
|
||||||
{
|
{
|
||||||
conditions.add( new WOreGenerationCondition( WLocation.inOverworld( ) ,
|
conditions.add( new WGOreCondition( WLocation.inOverworld( ) ,
|
||||||
new WOreGenerationParameters( this.getDefaultState( ) , 15 , 15 ) ) );
|
new WGOreParameters( this.getDefaultState( ) , 15 , 15 ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ import java.util.List;
|
||||||
import mmm.utils.I_UOreGenerationRegistrar;
|
import mmm.utils.I_UOreGenerationRegistrar;
|
||||||
import mmm.utils.URegistry;
|
import mmm.utils.URegistry;
|
||||||
import mmm.world.WLocation;
|
import mmm.world.WLocation;
|
||||||
import mmm.world.WOreGenerationCondition;
|
import mmm.world.gen.WGOreCondition;
|
||||||
import mmm.world.WOreGenerationParameters;
|
import mmm.world.gen.WGOreParameters;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.MapColor;
|
import net.minecraft.block.material.MapColor;
|
||||||
|
@ -34,10 +34,10 @@ public class MLimestone
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addConditions( final List< WOreGenerationCondition > conditions )
|
public void addConditions( final List< WGOreCondition > conditions )
|
||||||
{
|
{
|
||||||
conditions.add( new WOreGenerationCondition( WLocation.inOverworld( ) ,
|
conditions.add( new WGOreCondition( WLocation.inOverworld( ) ,
|
||||||
new WOreGenerationParameters( this.getDefaultState( ) , 15 , 40 ) ) );
|
new WGOreParameters( this.getDefaultState( ) , 15 , 40 ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,8 @@ import mmm.tech.Tech;
|
||||||
import mmm.utils.UAccessors;
|
import mmm.utils.UAccessors;
|
||||||
import mmm.utils.URegistry;
|
import mmm.utils.URegistry;
|
||||||
import mmm.utils.USeat;
|
import mmm.utils.USeat;
|
||||||
import mmm.world.WOreGenerator;
|
|
||||||
import mmm.world.World;
|
import mmm.world.World;
|
||||||
|
import mmm.world.gen.WGOre;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
|
||||||
|
@ -36,6 +36,6 @@ public abstract class PCommon
|
||||||
public void init( final FMLInitializationEvent event )
|
public void init( final FMLInitializationEvent event )
|
||||||
{
|
{
|
||||||
USeat.register( Mmm.get( ) );
|
USeat.register( Mmm.get( ) );
|
||||||
WOreGenerator.init( );
|
WGOre.init( );
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,13 +3,13 @@ package mmm.utils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import mmm.world.WOreGenerationCondition;
|
import mmm.world.gen.WGOreCondition;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public interface I_UOreGenerationRegistrar
|
public interface I_UOreGenerationRegistrar
|
||||||
{
|
{
|
||||||
|
|
||||||
public void addConditions( List< WOreGenerationCondition > conditions );
|
public void addConditions( List< WGOreCondition > conditions );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
package mmm.world;
|
package mmm.world.gen;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -14,23 +14,23 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class WOreGenerator
|
public class WGOre
|
||||||
implements IWorldGenerator
|
implements IWorldGenerator
|
||||||
{
|
{
|
||||||
|
|
||||||
public static void init( )
|
public static void init( )
|
||||||
{
|
{
|
||||||
final ArrayList< WOreGenerationCondition > conditions = new ArrayList<>( );
|
final ArrayList< WGOreCondition > conditions = new ArrayList<>( );
|
||||||
for ( final I_UOreGenerationRegistrar registrar : URegistry.getOreGenerationRegistrars( ) ) {
|
for ( final I_UOreGenerationRegistrar registrar : URegistry.getOreGenerationRegistrars( ) ) {
|
||||||
registrar.addConditions( conditions );
|
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;
|
this.conditions = conditions;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class WOreGenerator
|
||||||
{
|
{
|
||||||
final int n = this.conditions.size( );
|
final int n = this.conditions.size( );
|
||||||
for ( int i = 0 ; i < n ; i++ ) {
|
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 ) ) {
|
if ( cond.conditions.checkLocation( world , chunkX , chunkZ , chunkProvider ) ) {
|
||||||
cond.parameters.generate( world , random , chunkX , chunkZ );
|
cond.parameters.generate( world , random , chunkX , chunkZ );
|
||||||
}
|
}
|
18
src/java/mmm/world/gen/WGOreCondition.java
Normal file
18
src/java/mmm/world/gen/WGOreCondition.java
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package mmm.world;
|
package mmm.world.gen;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Random;
|
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;
|
public final IBlockState ore;
|
||||||
|
@ -28,28 +28,28 @@ public class WOreGenerationParameters
|
||||||
private WorldGenMinable generator;
|
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 ,
|
this( ore , clusters , clusterSize , Integer.MIN_VALUE , Integer.MIN_VALUE ,
|
||||||
BlockMatcher.forBlock( Blocks.STONE ) );
|
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 )
|
final int minHeight , final int maxHeight )
|
||||||
{
|
{
|
||||||
this( ore , clusters , clusterSize , minHeight , maxHeight , BlockMatcher.forBlock( Blocks.STONE ) );
|
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 )
|
final Predicate< IBlockState > matcher )
|
||||||
{
|
{
|
||||||
this( ore , clusters , clusterSize , Integer.MIN_VALUE , Integer.MIN_VALUE , 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 )
|
int minHeight , int maxHeight , final Predicate< IBlockState > matcher )
|
||||||
{
|
{
|
||||||
if ( clusters < 1 ) {
|
if ( clusters < 1 ) {
|
Reference in a new issue