right click ripe apple to harvest
@@ -10,9 +10,12 @@ import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
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.NonNullList;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
@@ -42,6 +45,7 @@ public class BlockFruit extends Block implements IGrowable {
setRegistryName(name);
setUnlocalizedName(name);
this.setTickRandomly(true);
+ this.setHardness(0.3f);
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
@@ -64,6 +68,16 @@ public class BlockFruit extends Block implements IGrowable {
}
}
+ @Override
+ public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
+ if ( ((Integer)state.getValue(AGE)).intValue() >= 3 ) {
+ this.dropBlock(worldIn, pos, state);
+ return true;
+ }
+
+ return false;
+ }
+
private void dropBlock(World worldIn, BlockPos pos, IBlockState state) {
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 3);
this.dropBlockAsItem(worldIn, pos, state, 0);
