From 5033217643b60f6dfcd889a2ad4b9b99fb7e0e58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sun, 3 Jul 2016 09:20:29 +0200 Subject: [PATCH] Moved ore generator to world.gen --- src/java/mmm/materials/ore/MOCassiterite.java | 10 +++++----- src/java/mmm/materials/ore/MOCopper.java | 14 +++++++------- src/java/mmm/materials/ore/MOCuprite.java | 10 +++++----- src/java/mmm/materials/ore/MOMalachite.java | 10 +++++----- src/java/mmm/materials/ore/MOSphalerite.java | 10 +++++----- src/java/mmm/materials/rock/MLimestone.java | 10 +++++----- src/java/mmm/proxy/PCommon.java | 4 ++-- .../mmm/utils/I_UOreGenerationRegistrar.java | 4 ++-- .../mmm/world/WOreGenerationCondition.java | 17 ----------------- .../{WOreGenerator.java => gen/WGOre.java} | 14 +++++++------- src/java/mmm/world/gen/WGOreCondition.java | 18 ++++++++++++++++++ .../WGOreParameters.java} | 12 ++++++------ 12 files changed, 67 insertions(+), 66 deletions(-) delete mode 100644 src/java/mmm/world/WOreGenerationCondition.java rename src/java/mmm/world/{WOreGenerator.java => gen/WGOre.java} (72%) create mode 100644 src/java/mmm/world/gen/WGOreCondition.java rename src/java/mmm/world/{WOreGenerationParameters.java => gen/WGOreParameters.java} (85%) diff --git a/src/java/mmm/materials/ore/MOCassiterite.java b/src/java/mmm/materials/ore/MOCassiterite.java index 25d1297..93c3f2a 100644 --- a/src/java/mmm/materials/ore/MOCassiterite.java +++ b/src/java/mmm/materials/ore/MOCassiterite.java @@ -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 ) ) ); } } diff --git a/src/java/mmm/materials/ore/MOCopper.java b/src/java/mmm/materials/ore/MOCopper.java index 936fd26..4f202fb 100644 --- a/src/java/mmm/materials/ore/MOCopper.java +++ b/src/java/mmm/materials/ore/MOCopper.java @@ -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 ) ) ); } } diff --git a/src/java/mmm/materials/ore/MOCuprite.java b/src/java/mmm/materials/ore/MOCuprite.java index cee151d..1db2b6f 100644 --- a/src/java/mmm/materials/ore/MOCuprite.java +++ b/src/java/mmm/materials/ore/MOCuprite.java @@ -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 ) ) ); } } diff --git a/src/java/mmm/materials/ore/MOMalachite.java b/src/java/mmm/materials/ore/MOMalachite.java index 4ae2255..84fdd31 100644 --- a/src/java/mmm/materials/ore/MOMalachite.java +++ b/src/java/mmm/materials/ore/MOMalachite.java @@ -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 ) ) ); } diff --git a/src/java/mmm/materials/ore/MOSphalerite.java b/src/java/mmm/materials/ore/MOSphalerite.java index 44b8fd6..af83c93 100644 --- a/src/java/mmm/materials/ore/MOSphalerite.java +++ b/src/java/mmm/materials/ore/MOSphalerite.java @@ -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 ) ) ); } } diff --git a/src/java/mmm/materials/rock/MLimestone.java b/src/java/mmm/materials/rock/MLimestone.java index d4ea0bc..7e2066b 100644 --- a/src/java/mmm/materials/rock/MLimestone.java +++ b/src/java/mmm/materials/rock/MLimestone.java @@ -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 ) ) ); } } diff --git a/src/java/mmm/proxy/PCommon.java b/src/java/mmm/proxy/PCommon.java index dbf5860..7ef1742 100644 --- a/src/java/mmm/proxy/PCommon.java +++ b/src/java/mmm/proxy/PCommon.java @@ -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( ); } } \ No newline at end of file diff --git a/src/java/mmm/utils/I_UOreGenerationRegistrar.java b/src/java/mmm/utils/I_UOreGenerationRegistrar.java index c7b737a..ce74d18 100644 --- a/src/java/mmm/utils/I_UOreGenerationRegistrar.java +++ b/src/java/mmm/utils/I_UOreGenerationRegistrar.java @@ -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 ); } diff --git a/src/java/mmm/world/WOreGenerationCondition.java b/src/java/mmm/world/WOreGenerationCondition.java deleted file mode 100644 index 889ea1c..0000000 --- a/src/java/mmm/world/WOreGenerationCondition.java +++ /dev/null @@ -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; - } - -} diff --git a/src/java/mmm/world/WOreGenerator.java b/src/java/mmm/world/gen/WGOre.java similarity index 72% rename from src/java/mmm/world/WOreGenerator.java rename to src/java/mmm/world/gen/WGOre.java index e9fe92a..64d587e 100644 --- a/src/java/mmm/world/WOreGenerator.java +++ b/src/java/mmm/world/gen/WGOre.java @@ -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 ); } diff --git a/src/java/mmm/world/gen/WGOreCondition.java b/src/java/mmm/world/gen/WGOreCondition.java new file mode 100644 index 0000000..817cc66 --- /dev/null +++ b/src/java/mmm/world/gen/WGOreCondition.java @@ -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; + } + +} diff --git a/src/java/mmm/world/WOreGenerationParameters.java b/src/java/mmm/world/gen/WGOreParameters.java similarity index 85% rename from src/java/mmm/world/WOreGenerationParameters.java rename to src/java/mmm/world/gen/WGOreParameters.java index 5c698a9..db80155 100644 --- a/src/java/mmm/world/WOreGenerationParameters.java +++ b/src/java/mmm/world/gen/WGOreParameters.java @@ -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 ) {