diff --git a/src/main/java/com/legacy/aether/server/blocks/BlockAetherSapling.java b/src/main/java/com/legacy/aether/server/blocks/BlockAetherSapling.java index b3d0b5b..eab2c23 100644 --- a/src/main/java/com/legacy/aether/server/blocks/BlockAetherSapling.java +++ b/src/main/java/com/legacy/aether/server/blocks/BlockAetherSapling.java @@ -2,9 +2,15 @@ package com.legacy.aether.server.blocks; import java.util.Random; -import net.minecraft.block.IGrowable; +import javax.annotation.Nullable; + import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -12,12 +18,12 @@ import net.minecraft.world.gen.feature.WorldGenerator; import com.legacy.aether.server.blocks.natural.BlockAetherFlower; -public class BlockAetherSapling extends BlockAetherFlower implements IGrowable +public class BlockAetherSapling extends BlockAetherFlower { - private Object treeGenObject = null; + public WorldGenerator treeGenObject = null; - public BlockAetherSapling(Object treeGen) + public BlockAetherSapling(WorldGenerator treeGen) { super(); float f = 0.4F; @@ -28,42 +34,43 @@ public class BlockAetherSapling extends BlockAetherFlower implements IGrowable @Override public void updateTick(World world, BlockPos pos, IBlockState state, Random random) { - if (world.isRemote) - { - return; - } - super.updateTick(world, pos, state, random); - if (world.getLight(pos.up()) >= 9 && random.nextInt(30) == 0) + if (!world.isRemote) { - this.grow(world, random, pos, state); + if (world.getLight(pos.up()) >= 9 && random.nextInt(30) == 0) + { + this.growTree(world, pos, random); + } } } @Override - public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) - { - return true; - } - - @Override - public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) - { - return worldIn.rand.nextFloat() < 0.45D; - } - - @Override - public void grow(World world, Random rand, BlockPos pos, IBlockState state) - { - if (world.isRemote) + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) + { + if (heldItem != null && heldItem.getItem() == Items.DYE && heldItem.getMetadata() == 15) { - return; + if (!worldIn.isRemote) + { + worldIn.playEvent(2005, pos, 0); + } + + if (worldIn.rand.nextFloat() < 0.45D) + { + this.growTree(worldIn, pos, worldIn.rand); + } + + return true; } + return false; + } + + public void growTree(World world, BlockPos pos, Random rand) + { world.setBlockState(pos, Blocks.AIR.getDefaultState()); - if (!((WorldGenerator) this.treeGenObject).generate(world, rand, pos)) + if (!this.treeGenObject.generate(world, world.rand, pos)) { world.setBlockState(pos, this.getDefaultState()); } diff --git a/src/main/java/com/legacy/aether/server/blocks/decorative/BlockPresent.java b/src/main/java/com/legacy/aether/server/blocks/decorative/BlockPresent.java index 0293ea5..f0a8f22 100644 --- a/src/main/java/com/legacy/aether/server/blocks/decorative/BlockPresent.java +++ b/src/main/java/com/legacy/aether/server/blocks/decorative/BlockPresent.java @@ -3,6 +3,7 @@ package com.legacy.aether.server.blocks.decorative; import javax.annotation.Nullable; import net.minecraft.block.Block; +import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityXPOrb; @@ -23,7 +24,9 @@ public class BlockPresent extends Block public BlockPresent() { super(Material.GRASS); + this.setHardness(0.6F); + this.setSoundType(SoundType.PLANT); } @Override