From ee91ed8708047be6fadf86e2c11844608aa8118d Mon Sep 17 00:00:00 2001 From: bm01 Date: Tue, 22 Jan 2013 23:44:53 +0100 Subject: [PATCH] Fixed sideway logs handling --- .../gmail/nossr50/skills/woodcutting/TreeFeller.java | 4 +--- .../nossr50/skills/woodcutting/Woodcutting.java | 12 ++++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java index 16e19138b..47eb876ff 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java @@ -188,8 +188,6 @@ public abstract class TreeFeller { case LOG: Woodcutting.checkDoubleDrop(player, block); - byte extraData = block.getData(); - try { xp += Woodcutting.getExperienceFromLog(block); } @@ -199,7 +197,7 @@ public abstract class TreeFeller { // TODO: Nerf XP from jungle trees, as it was done previously - Misc.dropItem(block.getLocation(), new ItemStack(Material.LOG, 1, extraData)); + Misc.dropItem(block.getLocation(), new ItemStack(Material.LOG, 1, block.getData())); break; case LEAVES: Misc.randomDropItem(block.getLocation(), new ItemStack(Material.LOG, 1, (short) (block.getData() & 3)), 10); diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java index b68cdfe32..fd00d7f4e 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.skills.woodcutting; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.TreeSpecies; @@ -84,7 +85,10 @@ public abstract class Woodcutting { * @throws IllegalArgumentException if 'log' is invalid */ protected static int getExperienceFromLog(Block log) { - TreeSpecies logType = TreeSpecies.getByData(log.getData()); + byte data = log.getData(); + Bukkit.getLogger().info(Integer.toHexString(data)); + + TreeSpecies logType = TreeSpecies.getByData((byte) (log.getData() & 0x3)); // Apparently species can be null in certain cases (custom server mods?) // https://github.com/mcMMO-Dev/mcMMO/issues/229 @@ -142,11 +146,11 @@ public abstract class Woodcutting { } } else { - byte extraData = block.getData(); + byte blockData = block.getData(); Location location = block.getLocation(); - ItemStack item = new ItemStack(Material.LOG, 1, extraData); + ItemStack item = new ItemStack(Material.LOG, 1, blockData); - switch (TreeSpecies.getByData(extraData)) { + switch (TreeSpecies.getByData((byte) (blockData & 0x3))) { case GENERIC: if (Config.getInstance().getOakDoubleDropsEnabled()) { Misc.dropItem(location, item);