Hey, im trying to add a features to a plugin that i will be releasing soon and i need to check just if the leaves are from an oak tree, not birch, not spruce, i'd try to check if the Block.getData() == (short) 0 but it dosnt work. Code (Text): //Apple rate bellow checking if shears are enabled or not if (Block.getType() == Material.LEAVES && Block.getData() == (short) 1) { if(this.plugin.getConfig().getBoolean("Features.ShearsForApples")) { Block.setType(Material.AIR); if ((r <= (this.plugin.getConfig().getDouble("Rates.Applerate")) * 0.01D)) { Block.setType(Material.AIR); Block.getWorld().dropItemNaturally(loc, new ItemStack(Material.APPLE)); } } else { if ((r <= (this.plugin.getConfig().getDouble("Rates.Applerate")) * 0.01D)) { Block.setType(Material.AIR); Block.getWorld().dropItemNaturally(loc, new ItemStack(Material.APPLE)); } } }
If i remove the block data, all the types of Leaves drop apples, not just oak, it will include birch, spruce, jungle and oak
Leaves that are decaying have a different data value. Spawn a tree in, break the logs and use the //info worldedit tool to check the data values of the leaves. I believe from memory its 5 for oak leaves but I'm not able to get on a computer to check.
Im not cheking it on LeafDecay, it is on BlockBreakEvent, but ima try, how do i check that with world edit?
Hmm, guys there's a problem, it works now, but, it works for oak and for spruce idk why, any solution just to make it works on oak and dark oak?
-chuckles to self while reading about what the data values are- Block.getData() is deprecated because it gives 'magic' values. The correct way is to use MaterialData to get the TreeSpecies. Code (Java): MaterialData materialData = block.getState().getData(); if(materialData instanceof Leaves){ if(((Leaves)materialData).getSpecies()==TreeSpecies.GENERIC){ //Leaf type is Oak } }