package net.glowstone.block.blocktype;

import net.glowstone.block.GlowBlock;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

public class BlockLeaves extends BlockType {

    @Override
    public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
        int data = block.getData() % 4; //ignore "non-decay" and "check-decay" data.

        if (tool != null && tool.getType() == Material.SHEARS) {
            return Collections.unmodifiableList(Arrays.asList(
                    new ItemStack(block.getType(), 1, (short) data)
            ));
        }

        if (block.getType() == Material.LEAVES_2) {
            data += 4;
        }

        List<ItemStack> drops = new ArrayList<>();

        if (random.nextFloat() < (block.getData() == 3 ? .025f : .05f)) { //jungle leaves drop with 2.5% chance, others drop with 5%
            drops.add(new ItemStack(Material.SAPLING, 1, (short) data));
        }
        if (data == 0 && random.nextFloat() < .005) { //oak leaves have a .5% chance to drop an apple
            drops.add(new ItemStack(Material.APPLE));
        }
        return Collections.unmodifiableList(drops);
    }
}

@@ -82,27 +82,145 @@
 ort 
-org.bukkit.Material
+net.glowstone.block.GlowBlockState;%0Aimport net.glowstone.entity.GlowPlayer;%0Aimport org.bukkit.Material;%0Aimport org.bukkit.block.BlockFace
 ;%0Aim
@@ -255,16 +255,47 @@
 emStack;
+%0Aimport org.bukkit.util.Vector;
 %0A%0Aimport
@@ -424,16 +424,16 @@
 .List;%0A%0A
-
 public c
@@ -470,16 +470,291 @@
 Type %7B%0A%0A
+    @Override%0A    public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face, ItemStack holding, Vector clickedLoc) %7B%0A        super.placeBlock(player, state, face, holding, clickedLoc);%0A        state.setRawData((byte) (state.getRawData() %7C 0x04));%0A    %7D%0A%0A
     @Ove

Mark player placed leaves blocks as non decayable