Bamboo, initial version
This commit is contained in:
parent
76e75957f5
commit
967017631c
22 changed files with 295 additions and 1 deletions
BIN
graphics/bamboo-culm.xcf
Normal file
BIN
graphics/bamboo-culm.xcf
Normal file
Binary file not shown.
BIN
graphics/bamboo-leaves.xcf
Normal file
BIN
graphics/bamboo-leaves.xcf
Normal file
Binary file not shown.
BIN
graphics/bamboo-log.xcf
Normal file
BIN
graphics/bamboo-log.xcf
Normal file
Binary file not shown.
|
@ -2,11 +2,18 @@ package mmm.materials;
|
|||
|
||||
|
||||
import mmm.utils.URegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.material.MapColor;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
|
||||
|
@ -90,4 +97,44 @@ public class MLog
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox( final IBlockState state , final IBlockAccess source , final BlockPos pos )
|
||||
{
|
||||
final AxisAlignedBB bb = this.wood.getLogBoundingBox( state.getValue( BlockLog.LOG_AXIS ) );
|
||||
if ( bb != null ) {
|
||||
return bb;
|
||||
}
|
||||
return Block.FULL_BLOCK_AABB;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube( final IBlockState state )
|
||||
{
|
||||
return this.wood != null && !this.wood.hasLogBoundingBox( );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isFullCube( final IBlockState state )
|
||||
{
|
||||
return !this.wood.hasLogBoundingBox( );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isFullBlock( final IBlockState state )
|
||||
{
|
||||
return !this.wood.hasLogBoundingBox( );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public BlockRenderLayer getBlockLayer( )
|
||||
{
|
||||
return this.wood.hasLogBoundingBox( ) ? BlockRenderLayer.CUTOUT : BlockRenderLayer.SOLID;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import mmm.utils.I_URecipeRegistrar;
|
|||
import mmm.utils.URegistry;
|
||||
import mmm.world.trees.A_MTreeGenerator;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.material.MapColor;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
@ -14,6 +15,7 @@ import net.minecraft.init.Items;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
|
||||
|
@ -39,6 +41,10 @@ public class MTree
|
|||
private MapColor barkColor = MapColor.WOOD;
|
||||
private MapColor plankColor = MapColor.WOOD;
|
||||
|
||||
private AxisAlignedBB logBoundingBoxX = null;
|
||||
private AxisAlignedBB logBoundingBoxY = null;
|
||||
private AxisAlignedBB logBoundingBoxZ = null;
|
||||
|
||||
private int baseFireEncouragement = 5;
|
||||
private int baseFlammability = 5;
|
||||
|
||||
|
@ -94,6 +100,15 @@ public class MTree
|
|||
}
|
||||
|
||||
|
||||
public MTree setLogBoundingBox( final AxisAlignedBB box )
|
||||
{
|
||||
this.logBoundingBoxY = box;
|
||||
this.logBoundingBoxX = new AxisAlignedBB( box.minY , box.minX , box.minZ , box.maxY , box.maxX , box.maxZ );
|
||||
this.logBoundingBoxZ = new AxisAlignedBB( box.minX , box.minZ , box.minY , box.maxX , box.maxZ , box.maxY );
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public MTree setSaplingDropChance( final int chance )
|
||||
{
|
||||
this.saplingDropChance = chance;
|
||||
|
@ -222,6 +237,24 @@ public class MTree
|
|||
}
|
||||
|
||||
|
||||
public AxisAlignedBB getLogBoundingBox( final BlockLog.EnumAxis axis )
|
||||
{
|
||||
switch ( axis ) {
|
||||
case X:
|
||||
return this.logBoundingBoxX;
|
||||
case Z:
|
||||
return this.logBoundingBoxZ;
|
||||
default:
|
||||
return this.logBoundingBoxY;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasLogBoundingBox( )
|
||||
{
|
||||
return this.logBoundingBoxX != null;
|
||||
}
|
||||
|
||||
|
||||
public int getSaplingDropChance( )
|
||||
{
|
||||
return this.saplingDropChance;
|
||||
|
@ -474,4 +507,5 @@ public class MTree
|
|||
'I' , new ItemStack( Items.IRON_INGOT ) );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package mmm.materials;
|
||||
|
||||
|
||||
import mmm.utils.UMaths;
|
||||
import mmm.world.trees.MHeveaGenerator;
|
||||
import mmm.world.trees.WTBambooGenerator;
|
||||
import net.minecraft.block.material.MapColor;
|
||||
|
||||
|
||||
|
@ -10,6 +12,7 @@ public class MTrees
|
|||
{
|
||||
|
||||
public final MTree HEVEA;
|
||||
public final MTree BAMBOO;
|
||||
|
||||
|
||||
MTrees( )
|
||||
|
@ -19,5 +22,14 @@ public class MTrees
|
|||
.setBaseFireInfo( 5 , 8 ) //
|
||||
.setTreeGenerator( new MHeveaGenerator( true ) ) //
|
||||
.register( );
|
||||
|
||||
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 ) //
|
||||
.register( );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,6 +89,12 @@ public abstract class A_MTreeGenerator
|
|||
}
|
||||
|
||||
|
||||
public void setEmptyRequirement( final int i , final int j , final int k , final boolean empty )
|
||||
{
|
||||
this.mustBeEmpty[ this.getOffset( i , j , k ) ] = empty;
|
||||
}
|
||||
|
||||
|
||||
public void removeCornerLeaves( final Random rand , final IBlockState leaves , final int startY ,
|
||||
final int endY , final float chance )
|
||||
{
|
||||
|
@ -182,7 +188,10 @@ public abstract class A_MTreeGenerator
|
|||
final IBlockState state = rtd.getBlockState( i , j , k );
|
||||
if ( state != null ) {
|
||||
final BlockPos blockPos = rtd.corner.add( i , j , k );
|
||||
this.setBlockAndNotifyAdequately( worldIn , blockPos , state );
|
||||
if ( rtd.mustBeEmpty( i , j , k )
|
||||
|| worldIn.getBlockState( blockPos ).getMaterial( ) == Material.AIR ) {
|
||||
this.setBlockAndNotifyAdequately( worldIn , blockPos , state );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
70
src/java/mmm/world/trees/WTBambooGenerator.java
Normal file
70
src/java/mmm/world/trees/WTBambooGenerator.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package mmm.world.trees;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
|
||||
|
||||
public class WTBambooGenerator
|
||||
extends A_MTreeGenerator
|
||||
{
|
||||
|
||||
private final int minHeight;
|
||||
private final int randomHeight;
|
||||
private final int maxRingRadius;
|
||||
|
||||
|
||||
public WTBambooGenerator( final boolean big , final boolean notify )
|
||||
{
|
||||
super( notify );
|
||||
this.minHeight = big ? 13 : 5;
|
||||
this.randomHeight = big ? 15 : 8;
|
||||
this.maxRingRadius = big ? 2 : 1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected RuntimeData determineTreeSize( final BlockPos position , final Random rand )
|
||||
{
|
||||
return new RuntimeData( position , 2 , this.minHeight + rand.nextInt( this.randomHeight ) );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void generateTreeBlocks( final RuntimeData rtd , final Random rand )
|
||||
{
|
||||
// Trunk
|
||||
for ( int y = 0 ; y < rtd.height ; y++ ) {
|
||||
rtd.setBlock( 2 , y , 2 , this.getWood( ).LOG , true );
|
||||
}
|
||||
|
||||
// Leaves
|
||||
final IBlockState leaves = this.getWood( ).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 );
|
||||
final int sqRadius = radius * radius;
|
||||
for ( int x = -2 ; x <= 2 ; x++ ) {
|
||||
for ( int z = -2 ; z <= 2 ; z++ ) {
|
||||
if ( ( x != 0 || z != 0 ) && x * x + z * z <= sqRadius + rand.nextInt( 2 ) ) {
|
||||
rtd.setBlock( x + 2 , ringY , z + 2 , leaves , false );
|
||||
}
|
||||
}
|
||||
}
|
||||
ringY += 1 + rand.nextInt( 3 );
|
||||
}
|
||||
|
||||
// Don't share the top space
|
||||
for ( int x = 1 ; x <= 3 ; x++ ) {
|
||||
for ( int z = 1 ; z <= 3 ; z++ ) {
|
||||
rtd.setEmptyRequirement( x , rtd.height - 1 , z , true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"variants": {
|
||||
"check_decay=false,decayable=false": { "model": "mmm:materials/leaves/bamboo" } ,
|
||||
"check_decay=false,decayable=true": { "model": "mmm:materials/leaves/bamboo" } ,
|
||||
"check_decay=true,decayable=false": { "model": "mmm:materials/leaves/bamboo" } ,
|
||||
"check_decay=true,decayable=true": { "model": "mmm:materials/leaves/bamboo" }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"variants":
|
||||
{
|
||||
"axis=y":
|
||||
{
|
||||
"model": "mmm:materials/log/bamboo"
|
||||
},
|
||||
|
||||
"axis=z":
|
||||
{
|
||||
"model": "mmm:materials/log/bamboo",
|
||||
"x": 90
|
||||
},
|
||||
|
||||
"axis=x":
|
||||
{
|
||||
"model": "mmm:materials/log/bamboo",
|
||||
"x": 90,
|
||||
"y": 90
|
||||
},
|
||||
|
||||
"axis=none":
|
||||
{
|
||||
"model": "mmm:materials/bark/bamboo"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"variants": {
|
||||
"stage=0": { "model": "mmm:materials/sapling/bamboo" },
|
||||
"stage=1": { "model": "mmm:materials/sapling/bamboo" },
|
||||
"stage=2": { "model": "mmm:materials/sapling/bamboo" },
|
||||
"stage=3": { "model": "mmm:materials/sapling/bamboo" },
|
||||
"stage=4": { "model": "mmm:materials/sapling/bamboo" },
|
||||
"stage=5": { "model": "mmm:materials/sapling/bamboo" },
|
||||
"stage=6": { "model": "mmm:materials/sapling/bamboo" },
|
||||
"stage=7": { "model": "mmm:materials/sapling/bamboo" },
|
||||
"stage=8": { "model": "mmm:materials/sapling/bamboo" },
|
||||
"stage=9": { "model": "mmm:materials/sapling/bamboo" },
|
||||
"stage=10": { "model": "mmm:materials/sapling/bamboo" },
|
||||
"stage=11": { "model": "mmm:materials/sapling/bamboo" },
|
||||
"stage=12": { "model": "mmm:materials/sapling/bamboo" },
|
||||
"stage=13": { "model": "mmm:materials/sapling/bamboo" },
|
||||
"stage=14": { "model": "mmm:materials/sapling/bamboo" },
|
||||
"stage=15": { "model": "mmm:materials/sapling/bamboo" }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"textures": {
|
||||
"particle": "mmm:blocks/materials/log/side/bamboo",
|
||||
"end": "mmm:blocks/materials/log/end/bamboo"
|
||||
} ,
|
||||
|
||||
"elements": [
|
||||
{
|
||||
"from": [ 4 , 4 , 4 ] ,
|
||||
"to": [ 12 , 12 , 12 ] ,
|
||||
"faces": {
|
||||
"down": { "texture": "#end" },
|
||||
"up": { "texture": "#end" },
|
||||
"north": { "texture": "#end" } ,
|
||||
"east": { "texture": "#end" } ,
|
||||
"south": { "texture": "#end" } ,
|
||||
"west": { "texture": "#end" }
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:block/leaves",
|
||||
"textures": {
|
||||
"all": "mmm:blocks/materials/leaves/bamboo"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"textures": {
|
||||
"particle": "mmm:blocks/materials/log/side/bamboo",
|
||||
"side": "mmm:blocks/materials/log/side/bamboo" ,
|
||||
"end": "mmm:blocks/materials/log/end/bamboo"
|
||||
} ,
|
||||
|
||||
"elements": [
|
||||
{
|
||||
"from": [ 4 , 0 , 4 ] ,
|
||||
"to": [ 12 , 16 , 12 ] ,
|
||||
"faces": {
|
||||
"down": { "texture": "#end", "cullface": "down" },
|
||||
"up": { "texture": "#end", "cullface": "up" },
|
||||
"north": { "texture": "#side" } ,
|
||||
"east": { "texture": "#side" } ,
|
||||
"south": { "texture": "#side" } ,
|
||||
"west": { "texture": "#side" }
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:block/cross",
|
||||
"textures": {
|
||||
"cross": "mmm:blocks/materials/sapling/bamboo"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "mmm:block/materials/leaves/bamboo"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "mmm:block/materials/log/bamboo"
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "mmm:blocks/materials/sapling/bamboo"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 544 B |
Binary file not shown.
After Width: | Height: | Size: 376 B |
Binary file not shown.
After Width: | Height: | Size: 477 B |
Binary file not shown.
After Width: | Height: | Size: 535 B |
Reference in a new issue