diff --git a/graphics/hevea_leaves.xcf b/graphics/hevea_leaves.xcf new file mode 100644 index 0000000..591d205 Binary files /dev/null and b/graphics/hevea_leaves.xcf differ diff --git a/src/java/mmm/materials/MLeaves.java b/src/java/mmm/materials/MLeaves.java new file mode 100644 index 0000000..6fd3d7f --- /dev/null +++ b/src/java/mmm/materials/MLeaves.java @@ -0,0 +1,112 @@ +package mmm.materials; + + +import java.util.Arrays; +import java.util.List; +import java.util.Random; + +import mmm.utils.URegistry; +import net.minecraft.block.Block; +import net.minecraft.block.BlockLeaves; +import net.minecraft.block.BlockPlanks; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + + + +public class MLeaves + extends BlockLeaves +{ + + private final MWood wood; + + + public MLeaves( final MWood wood ) + { + this.wood = wood; + URegistry.setIdentifiers( this , "materials" , "leaves" , wood.NAME ); + } + + + @Override + public Item getItemDropped( final IBlockState state , final Random rand , final int fortune ) + { + // LOL NO FIXME + // Should be + // return Item.getItemFromBlock( this.wood.SAPLING ); + return Item.getItemFromBlock( Blocks.SAPLING ); + } + + + @Override + protected void dropApple( final World worldIn , final BlockPos pos , final IBlockState state , final int chance ) + { + final Item fruit = this.wood.getFruit( ); + if ( fruit != null && worldIn.rand.nextInt( chance ) < this.wood.getFruitDropChance( ) ) { + Block.spawnAsEntity( worldIn , pos , new ItemStack( fruit ) ); + } + } + + + @Override + protected int getSaplingDropChance( final IBlockState state ) + { + return this.wood.getSaplingDropChance( ); + } + + + @Override + public List< ItemStack > onSheared( final ItemStack item , final IBlockAccess world , final BlockPos pos , + final int fortune ) + { + return Arrays.asList( new ItemStack( this ) ); + } + + + @Override + public BlockPlanks.EnumType getWoodType( final int meta ) + { + // Fuck you and fuck this useless fuckery. For fuck's sake. + return null; + } + + + @Override + protected BlockStateContainer createBlockState( ) + { + return new BlockStateContainer( this , new IProperty[] { + BlockLeaves.CHECK_DECAY , BlockLeaves.DECAYABLE + } ); + } + + + @Override + public IBlockState getStateFromMeta( final int meta ) + { + return this.getDefaultState( ) // + .withProperty( BlockLeaves.DECAYABLE , Boolean.valueOf( ( meta & 4 ) == 0 ) ) // + .withProperty( BlockLeaves.CHECK_DECAY , Boolean.valueOf( ( meta & 8 ) > 0 ) ); + } + + + @Override + public int getMetaFromState( final IBlockState state ) + { + int meta = 0; + if ( !state.getValue( BlockLeaves.DECAYABLE ) ) { + meta |= 4; + } + if ( state.getValue( BlockLeaves.CHECK_DECAY ) ) { + meta |= 8; + } + return meta; + } + +} diff --git a/src/java/mmm/materials/MWoodLog.java b/src/java/mmm/materials/MLog.java similarity index 95% rename from src/java/mmm/materials/MWoodLog.java rename to src/java/mmm/materials/MLog.java index ce8a817..e68e885 100644 --- a/src/java/mmm/materials/MWoodLog.java +++ b/src/java/mmm/materials/MLog.java @@ -10,14 +10,14 @@ import net.minecraft.block.state.IBlockState; -public class MWoodLog +public class MLog extends BlockLog { - private final MWood wood; + public final MWood wood; - public MWoodLog( final MWood wood ) + public MLog( final MWood wood ) { super( ); this.wood = wood; diff --git a/src/java/mmm/materials/MWoodPlanks.java b/src/java/mmm/materials/MPlanks.java similarity index 88% rename from src/java/mmm/materials/MWoodPlanks.java rename to src/java/mmm/materials/MPlanks.java index 4ed71e6..9a4b079 100644 --- a/src/java/mmm/materials/MWoodPlanks.java +++ b/src/java/mmm/materials/MPlanks.java @@ -10,14 +10,14 @@ import net.minecraft.creativetab.CreativeTabs; -public class MWoodPlanks +public class MPlanks extends Block { - private MWood wood; + public final MWood wood; - public MWoodPlanks( MWood wood ) + public MPlanks( final MWood wood ) { super( Material.WOOD ); this.wood = wood; diff --git a/src/java/mmm/materials/MWood.java b/src/java/mmm/materials/MWood.java index 3e5a243..50f5aac 100644 --- a/src/java/mmm/materials/MWood.java +++ b/src/java/mmm/materials/MWood.java @@ -6,6 +6,7 @@ import mmm.utils.URegistry; import net.minecraft.block.material.MapColor; import net.minecraft.init.Blocks; import net.minecraft.init.Items; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.registry.GameRegistry; @@ -16,20 +17,25 @@ public class MWood { public final String NAME; - public final MWoodLog LOG; - public final MWoodPlanks PLANKS; + public final MLeaves LEAVES; + public final MLog LOG; + public final MPlanks PLANKS; private MapColor barkColor = MapColor.WOOD; private MapColor plankColor = MapColor.WOOD; private int baseFireEncouragement = 5; private int baseFlammability = 5; + private int saplingDropChance = 20; + private int fruitDropChance = 0; + private Item fruit = null; public MWood( final String name ) { this.NAME = name; - this.LOG = new MWoodLog( this ); - this.PLANKS = new MWoodPlanks( this ); + this.LEAVES = new MLeaves( this ); + this.LOG = new MLog( this ); + this.PLANKS = new MPlanks( this ); } @@ -47,6 +53,21 @@ public class MWood } + public MWood setSaplingDropChance( final int chance ) + { + this.saplingDropChance = chance; + return this; + } + + + public MWood setFruit( final Item fruit , final float dropChance ) + { + this.fruit = fruit; + this.fruitDropChance = (int) ( 200 * dropChance ); + return this; + } + + public MWood setBaseFireInfo( final int encouragement , final int flammability ) { this.baseFireEncouragement = encouragement; @@ -61,6 +82,8 @@ public class MWood Blocks.FIRE.setFireInfo( this.LOG , this.baseFireEncouragement , this.baseFlammability ); URegistry.addBlock( this.PLANKS ); Blocks.FIRE.setFireInfo( this.PLANKS , this.baseFireEncouragement , this.baseFlammability * 4 ); + URegistry.addBlock( this.LEAVES ); + Blocks.FIRE.setFireInfo( this.LEAVES , this.baseFireEncouragement * 6 , this.baseFlammability * 12 ); URegistry.addRecipeRegistrar( this ); return this; @@ -79,6 +102,24 @@ public class MWood } + public int getSaplingDropChance( ) + { + return this.saplingDropChance; + } + + + public int getFruitDropChance( ) + { + return this.fruitDropChance; + } + + + public Item getFruit( ) + { + return this.fruit; + } + + @Override public void registerRecipes( ) { diff --git a/src/resources/assets/mmm/blockstates/materials/leaves/hevea.json b/src/resources/assets/mmm/blockstates/materials/leaves/hevea.json new file mode 100644 index 0000000..80839a8 --- /dev/null +++ b/src/resources/assets/mmm/blockstates/materials/leaves/hevea.json @@ -0,0 +1,8 @@ +{ + "variants": { + "check_decay=false,decayable=false": { "model": "mmm:materials/leaves/hevea" } , + "check_decay=false,decayable=true": { "model": "mmm:materials/leaves/hevea" } , + "check_decay=true,decayable=false": { "model": "mmm:materials/leaves/hevea" } , + "check_decay=true,decayable=true": { "model": "mmm:materials/leaves/hevea" } + } +} diff --git a/src/resources/assets/mmm/models/block/materials/leaves/hevea.json b/src/resources/assets/mmm/models/block/materials/leaves/hevea.json new file mode 100644 index 0000000..a724ebd --- /dev/null +++ b/src/resources/assets/mmm/models/block/materials/leaves/hevea.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/leaves", + "textures": { + "all": "mmm:blocks/materials/leaves/hevea" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/materials/leaves/hevea.json b/src/resources/assets/mmm/models/item/materials/leaves/hevea.json new file mode 100644 index 0000000..654fd44 --- /dev/null +++ b/src/resources/assets/mmm/models/item/materials/leaves/hevea.json @@ -0,0 +1,3 @@ +{ + "parent": "mmm:block/materials/leaves/hevea" +} \ No newline at end of file diff --git a/src/resources/assets/mmm/textures/blocks/materials/leaves/hevea.png b/src/resources/assets/mmm/textures/blocks/materials/leaves/hevea.png new file mode 100644 index 0000000..a954864 Binary files /dev/null and b/src/resources/assets/mmm/textures/blocks/materials/leaves/hevea.png differ