Some clean-up on the new tree stuff

This commit is contained in:
Emmanuel BENOîT 2016-07-10 00:58:56 +02:00
parent e24b927f1d
commit 81148c7c0a
7 changed files with 74 additions and 50 deletions

View file

@ -172,7 +172,7 @@ public class MTree
{
this.genNormal = generator;
if ( generator != null ) {
generator.setWood( this );
generator.setTreeMaterials( this );
}
return this;
}
@ -189,7 +189,7 @@ public class MTree
this.genBig = generator;
this.genBigChance = chance;
if ( generator != null ) {
generator.setWood( this );
generator.setTreeMaterials( this );
}
return this;
}
@ -199,7 +199,7 @@ public class MTree
{
this.genMega = generator;
if ( generator != null ) {
generator.setWood( this );
generator.setTreeMaterials( this );
}
return this;
}

View file

@ -2,8 +2,8 @@ package mmm.materials;
import mmm.utils.UMaths;
import mmm.world.trees.WTHeveaGenerator;
import mmm.world.trees.WTBambooGenerator;
import mmm.world.trees.WTHeveaGenerator;
import net.minecraft.block.material.MapColor;
@ -17,19 +17,18 @@ public class MTrees
MTrees( )
{
HEVEA = new MTree( "hevea" ) //
this.HEVEA = new MTree( "hevea" ) //
.setBarkColor( MapColor.GRAY ) //
.setBaseFireInfo( 5 , 8 ) //
.setTreeGenerator( new WTHeveaGenerator( true ) ) //
.setTreeGenerator( WTHeveaGenerator.createSaplingGen( ) ) //
.register( );
BAMBOO = new MTree( "bamboo" ) //
this.BAMBOO = new MTree( "bamboo" ) //
.setBarkColor( MapColor.FOLIAGE ) //
.setLogBoundingBox( UMaths.makeBlockAABB( 4 , 0 , 4 , 12 , 16 , 12 ) ) //
.setGrowthChance( .3f ) //
.setSaplingGrowthStages( 1 ) //
.setTreeGenerator( new WTBambooGenerator( false , true ) ) //
.setBigTreeGenerator( new WTBambooGenerator( true , true ) , .15f ) //
.setTreeGenerator( WTBambooGenerator.createSaplingGen( false ) ) //
.setBigTreeGenerator( WTBambooGenerator.createSaplingGen( true ) , .15f ) //
.register( );
}
}

View file

@ -46,14 +46,12 @@ public class WBTropicalSwamp
private static final IBlockState WATER_LILY = Blocks.WATERLILY.getDefaultState( );
private static final A_WTTreeGenerator TG_BAMBOO_BIG = new WTBambooGenerator( true , false ) //
.setWood( Materials.TREE.BAMBOO );
private static final A_WTTreeGenerator TG_BAMBOO = new WTBambooGenerator( false , false ) //
.setWood( Materials.TREE.BAMBOO );
private static final A_WTTreeGenerator TG_HEVEA = new WTHeveaGenerator( false ) //
.setWood( Materials.TREE.HEVEA );
private static final WorldGenShrub TG_SHRUB = new WorldGenShrub( WBTropicalSwamp.OAK_LOG ,
WBTropicalSwamp.OAK_LEAF );
private static final A_WTTreeGenerator TG_BAMBOO_BIG = new WTBambooGenerator( true , false );
private static final A_WTTreeGenerator TG_BAMBOO = new WTBambooGenerator( false , false );
private static final A_WTTreeGenerator TG_HEVEA = new WTHeveaGenerator( false );
private static final WorldGenShrub TG_SHRUB = new WorldGenShrub( //
WBTropicalSwamp.OAK_LOG , WBTropicalSwamp.OAK_LEAF );
public WBTropicalSwamp( final WBiomeHelper helper )

View file

@ -160,24 +160,25 @@ public abstract class A_WTTreeGenerator
}
private MTree wood;
private MTree materials;
public A_WTTreeGenerator( final boolean notify )
public A_WTTreeGenerator( final boolean notify , MTree materials )
{
super( notify );
this.materials = materials;
}
public MTree getWood( )
public MTree getTreeMaterials( )
{
return this.wood;
return this.materials;
}
public A_WTTreeGenerator setWood( final MTree wood )
public A_WTTreeGenerator setTreeMaterials( final MTree materials )
{
this.wood = wood;
this.materials = materials;
return this;
}
@ -185,7 +186,7 @@ public abstract class A_WTTreeGenerator
@Override
public boolean generate( final World worldIn , final Random rand , final BlockPos position )
{
if ( position.getY( ) < 1 || !this.wood.canSaplingStay( worldIn , position ) ) {
if ( position.getY( ) < 1 || !this.materials.canSaplingStay( worldIn , position ) ) {
return false;
}

View file

@ -3,6 +3,8 @@ package mmm.world.trees;
import java.util.Random;
import mmm.materials.MTree;
import mmm.materials.Materials;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
@ -12,6 +14,10 @@ import net.minecraft.util.math.BlockPos;
public class WTBambooGenerator
extends A_WTTreeGenerator
{
public static WTBambooGenerator createSaplingGen( final boolean big )
{
return new WTBambooGenerator( big , true , null );
}
private final int minHeight;
private final int randomHeight;
@ -20,7 +26,13 @@ public class WTBambooGenerator
public WTBambooGenerator( final boolean big , final boolean notify )
{
super( notify );
this( big , notify , Materials.TREE.BAMBOO );
}
private WTBambooGenerator( final boolean big , final boolean notify , MTree materials )
{
super( notify , materials );
this.minHeight = big ? 13 : 5;
this.randomHeight = big ? 15 : 8;
this.maxRingRadius = big ? 2 : 1;
@ -39,7 +51,7 @@ public class WTBambooGenerator
{
// Trunk
for ( int y = 0 ; y < rtd.height ; y++ ) {
rtd.setBlock( 2 , y , 2 , this.getWood( ).LOG , E_BlockRequirement.VANILLA );
rtd.setBlock( 2 , y , 2 , this.getTreeMaterials( ).LOG , E_BlockRequirement.VANILLA );
rtd.setRequirement( 2 , y , 2 , E_BlockRequirement.VANILLA );
}
@ -51,8 +63,8 @@ public class WTBambooGenerator
}
// Leaves
final IBlockState leaves = this.getWood( ).LEAVES.getDefaultState( ).withProperty( BlockLeaves.CHECK_DECAY ,
false );
final IBlockState leaves = this.getTreeMaterials( ).LEAVES.getDefaultState( ) //
.withProperty( BlockLeaves.CHECK_DECAY , false );
int ringY = 1 + rand.nextInt( 3 );
while ( ringY < rtd.height ) {
final int radius = 1 + rand.nextInt( this.maxRingRadius );

View file

@ -4,6 +4,7 @@ package mmm.world.trees;
import java.util.Random;
import mmm.materials.MLeaves;
import mmm.materials.Materials;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
@ -13,9 +14,22 @@ public class WTHeveaGenerator
extends A_WTTreeGenerator
{
public static WTHeveaGenerator createSaplingGen( )
{
return new WTHeveaGenerator( );
}
public WTHeveaGenerator( final boolean notify )
{
super( notify );
super( notify , Materials.TREE.HEVEA );
}
// Used for sapling gen
private WTHeveaGenerator( )
{
super( true , null );
}
@ -39,7 +53,8 @@ public class WTHeveaGenerator
final int trunkHeight = Math.max( trunkBottom + 1 , rtd.height - ( 1 + rand.nextInt( leavesHeight ) ) );
// Lower part of the leaves
IBlockState leaves = this.getWood( ).LEAVES.getDefaultState( ).withProperty( MLeaves.CHECK_DECAY , false );
IBlockState leaves = this.getTreeMaterials( ).LEAVES.getDefaultState( )//
.withProperty( MLeaves.CHECK_DECAY , false );
for ( int y = trunkBottom , i = 0 ; y < lowerPart ; y++ , i++ ) {
final int radius = ( i >> 1 ) + 1;
final int rSquare = radius * radius + ( i & 1 );
@ -72,7 +87,7 @@ public class WTHeveaGenerator
// Trunk
for ( int y = 0 ; y < trunkHeight ; y++ ) {
rtd.setBlock( centre , y , centre , this.getWood( ).LOG , E_BlockRequirement.VANILLA );
rtd.setBlock( centre , y , centre , this.getTreeMaterials( ).LOG , E_BlockRequirement.VANILLA );
rtd.setRequirement( centre , y , centre , E_BlockRequirement.VANILLA );
}
}