Fixed Tree Feller dropping sideways log items

This commit is contained in:
bm01 2013-01-23 19:30:23 +01:00
parent de5110310f
commit bb2eb053da
2 changed files with 13 additions and 3 deletions

View File

@ -199,7 +199,7 @@ public abstract class TreeFeller {
Misc.dropItem(block.getLocation(), new ItemStack(Material.LOG, 1, block.getData())); Misc.dropItem(block.getLocation(), new ItemStack(Material.LOG, 1, block.getData()));
break; break;
case LEAVES: case LEAVES:
Misc.randomDropItem(block.getLocation(), new ItemStack(Material.SAPLING, 1, (short) (block.getData() & 3)), 10); Misc.randomDropItem(block.getLocation(), new ItemStack(Material.SAPLING, 1, Woodcutting.extractLogItemData(block.getData())), 10);
break; break;
default: default:
if (ModChecks.isCustomLogBlock(block)) { if (ModChecks.isCustomLogBlock(block)) {

View File

@ -84,7 +84,7 @@ public abstract class Woodcutting {
* @throws IllegalArgumentException if 'log' is invalid * @throws IllegalArgumentException if 'log' is invalid
*/ */
protected static int getExperienceFromLog(Block log) { protected static int getExperienceFromLog(Block log) {
TreeSpecies logType = TreeSpecies.getByData((byte) (log.getData() & 0x3)); TreeSpecies logType = TreeSpecies.getByData(extractLogItemData(log.getData()));
// Apparently species can be null in certain cases (custom server mods?) // Apparently species can be null in certain cases (custom server mods?)
// https://github.com/mcMMO-Dev/mcMMO/issues/229 // https://github.com/mcMMO-Dev/mcMMO/issues/229
@ -146,7 +146,7 @@ public abstract class Woodcutting {
Location location = block.getLocation(); Location location = block.getLocation();
ItemStack item = new ItemStack(Material.LOG, 1, blockData); ItemStack item = new ItemStack(Material.LOG, 1, blockData);
switch (TreeSpecies.getByData((byte) (blockData & 0x3))) { switch (TreeSpecies.getByData(extractLogItemData(blockData))) {
case GENERIC: case GENERIC:
if (Config.getInstance().getOakDoubleDropsEnabled()) { if (Config.getInstance().getOakDoubleDropsEnabled()) {
Misc.dropItem(location, item); Misc.dropItem(location, item);
@ -172,4 +172,14 @@ public abstract class Woodcutting {
} }
} }
} }
/**
* Extract the log type from the block data (remove rotation)
*
* @param data Original block data
* @return Extracted log type
*/
protected static byte extractLogItemData(byte data) {
return (byte) (data & 0x3);
}
} }