diff --git a/graphics/bamboo-culm.xcf b/graphics/bamboo-culm.xcf new file mode 100644 index 0000000..7f1eadb Binary files /dev/null and b/graphics/bamboo-culm.xcf differ diff --git a/graphics/bamboo-leaves.xcf b/graphics/bamboo-leaves.xcf new file mode 100644 index 0000000..8ea675a Binary files /dev/null and b/graphics/bamboo-leaves.xcf differ diff --git a/graphics/bamboo-log.xcf b/graphics/bamboo-log.xcf new file mode 100644 index 0000000..43d961b Binary files /dev/null and b/graphics/bamboo-log.xcf differ diff --git a/src/java/mmm/materials/MLog.java b/src/java/mmm/materials/MLog.java index 3638964..9924426 100644 --- a/src/java/mmm/materials/MLog.java +++ b/src/java/mmm/materials/MLog.java @@ -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; + } + } diff --git a/src/java/mmm/materials/MTree.java b/src/java/mmm/materials/MTree.java index adf4730..f00e1a0 100644 --- a/src/java/mmm/materials/MTree.java +++ b/src/java/mmm/materials/MTree.java @@ -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 ) ); } + } diff --git a/src/java/mmm/materials/MTrees.java b/src/java/mmm/materials/MTrees.java index 02931e7..e49f11e 100644 --- a/src/java/mmm/materials/MTrees.java +++ b/src/java/mmm/materials/MTrees.java @@ -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( ); } } diff --git a/src/java/mmm/world/trees/A_MTreeGenerator.java b/src/java/mmm/world/trees/A_MTreeGenerator.java index 2b17ff0..c5f4fc5 100644 --- a/src/java/mmm/world/trees/A_MTreeGenerator.java +++ b/src/java/mmm/world/trees/A_MTreeGenerator.java @@ -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 ); + } } } } diff --git a/src/java/mmm/world/trees/WTBambooGenerator.java b/src/java/mmm/world/trees/WTBambooGenerator.java new file mode 100644 index 0000000..981c4ae --- /dev/null +++ b/src/java/mmm/world/trees/WTBambooGenerator.java @@ -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 ); + } + } + } + +} diff --git a/src/resources/assets/mmm/blockstates/materials/leaves/bamboo.json b/src/resources/assets/mmm/blockstates/materials/leaves/bamboo.json new file mode 100644 index 0000000..4ea2bfc --- /dev/null +++ b/src/resources/assets/mmm/blockstates/materials/leaves/bamboo.json @@ -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" } + } +} diff --git a/src/resources/assets/mmm/blockstates/materials/log/bamboo.json b/src/resources/assets/mmm/blockstates/materials/log/bamboo.json new file mode 100644 index 0000000..d08d37c --- /dev/null +++ b/src/resources/assets/mmm/blockstates/materials/log/bamboo.json @@ -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" + } + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/blockstates/materials/sapling/bamboo.json b/src/resources/assets/mmm/blockstates/materials/sapling/bamboo.json new file mode 100644 index 0000000..3c0aab0 --- /dev/null +++ b/src/resources/assets/mmm/blockstates/materials/sapling/bamboo.json @@ -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" } + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/block/materials/bark/bamboo.json b/src/resources/assets/mmm/models/block/materials/bark/bamboo.json new file mode 100644 index 0000000..7cb9c2d --- /dev/null +++ b/src/resources/assets/mmm/models/block/materials/bark/bamboo.json @@ -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" } + } + } + ] +} diff --git a/src/resources/assets/mmm/models/block/materials/leaves/bamboo.json b/src/resources/assets/mmm/models/block/materials/leaves/bamboo.json new file mode 100644 index 0000000..4ed9535 --- /dev/null +++ b/src/resources/assets/mmm/models/block/materials/leaves/bamboo.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/leaves", + "textures": { + "all": "mmm:blocks/materials/leaves/bamboo" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/block/materials/log/bamboo.json b/src/resources/assets/mmm/models/block/materials/log/bamboo.json new file mode 100644 index 0000000..9db653a --- /dev/null +++ b/src/resources/assets/mmm/models/block/materials/log/bamboo.json @@ -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" } + } + } + ] +} diff --git a/src/resources/assets/mmm/models/block/materials/sapling/bamboo.json b/src/resources/assets/mmm/models/block/materials/sapling/bamboo.json new file mode 100644 index 0000000..2af58e8 --- /dev/null +++ b/src/resources/assets/mmm/models/block/materials/sapling/bamboo.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cross", + "textures": { + "cross": "mmm:blocks/materials/sapling/bamboo" + } +} diff --git a/src/resources/assets/mmm/models/item/materials/leaves/bamboo.json b/src/resources/assets/mmm/models/item/materials/leaves/bamboo.json new file mode 100644 index 0000000..f88a338 --- /dev/null +++ b/src/resources/assets/mmm/models/item/materials/leaves/bamboo.json @@ -0,0 +1,3 @@ +{ + "parent": "mmm:block/materials/leaves/bamboo" +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/materials/log/bamboo.json b/src/resources/assets/mmm/models/item/materials/log/bamboo.json new file mode 100644 index 0000000..1fe10cc --- /dev/null +++ b/src/resources/assets/mmm/models/item/materials/log/bamboo.json @@ -0,0 +1,3 @@ +{ + "parent": "mmm:block/materials/log/bamboo" +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/materials/sapling/bamboo.json b/src/resources/assets/mmm/models/item/materials/sapling/bamboo.json new file mode 100644 index 0000000..22306e5 --- /dev/null +++ b/src/resources/assets/mmm/models/item/materials/sapling/bamboo.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "mmm:blocks/materials/sapling/bamboo" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/textures/blocks/materials/leaves/bamboo.png b/src/resources/assets/mmm/textures/blocks/materials/leaves/bamboo.png new file mode 100644 index 0000000..19c1662 Binary files /dev/null and b/src/resources/assets/mmm/textures/blocks/materials/leaves/bamboo.png differ diff --git a/src/resources/assets/mmm/textures/blocks/materials/log/end/bamboo.png b/src/resources/assets/mmm/textures/blocks/materials/log/end/bamboo.png new file mode 100644 index 0000000..cb24276 Binary files /dev/null and b/src/resources/assets/mmm/textures/blocks/materials/log/end/bamboo.png differ diff --git a/src/resources/assets/mmm/textures/blocks/materials/log/side/bamboo.png b/src/resources/assets/mmm/textures/blocks/materials/log/side/bamboo.png new file mode 100644 index 0000000..6869aea Binary files /dev/null and b/src/resources/assets/mmm/textures/blocks/materials/log/side/bamboo.png differ diff --git a/src/resources/assets/mmm/textures/blocks/materials/sapling/bamboo.png b/src/resources/assets/mmm/textures/blocks/materials/sapling/bamboo.png new file mode 100644 index 0000000..6bb2142 Binary files /dev/null and b/src/resources/assets/mmm/textures/blocks/materials/sapling/bamboo.png differ