mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-30 00:56:47 +01:00
Workaround for ClassCastException: MaterialData cannot be cast to Tree
This commit is contained in:
parent
23502635b0
commit
daee3daf5f
@ -56,7 +56,12 @@ public final class Woodcutting {
|
|||||||
return mcMMO.getModManager().getBlock(blockState).getXpGain();
|
return mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeSpecies species = ((Tree) blockState.getData()).getSpecies();
|
//TODO Remove this workaround when casting to Tree works again
|
||||||
|
TreeSpecies species = TreeSpecies.GENERIC;
|
||||||
|
if (blockState.getData() instanceof Tree) {
|
||||||
|
species = ((Tree) blockState.getData()).getSpecies();
|
||||||
|
}
|
||||||
|
|
||||||
int xp = ExperienceConfig.getInstance().getWoodcuttingTreeXP(species);
|
int xp = ExperienceConfig.getInstance().getWoodcuttingTreeXP(species);
|
||||||
|
|
||||||
if (species == TreeSpecies.JUNGLE && experienceGainMethod == ExperienceGainMethod.TREE_FELLER) {
|
if (species == TreeSpecies.JUNGLE && experienceGainMethod == ExperienceGainMethod.TREE_FELLER) {
|
||||||
@ -75,10 +80,18 @@ public final class Woodcutting {
|
|||||||
if (mcMMO.getModManager().isCustomLog(blockState) && mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) {
|
if (mcMMO.getModManager().isCustomLog(blockState) && mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) {
|
||||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||||
}
|
}
|
||||||
else if (Config.getInstance().getWoodcuttingDoubleDropsEnabled(((Tree) blockState.getData()).getSpecies())) {
|
else {
|
||||||
|
//TODO Remove this workaround when casting to Tree works again
|
||||||
|
TreeSpecies species = TreeSpecies.GENERIC;
|
||||||
|
if (blockState.getData() instanceof Tree) {
|
||||||
|
species = ((Tree) blockState.getData()).getSpecies();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config.getInstance().getWoodcuttingDoubleDropsEnabled(species)) {
|
||||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The x/y differences to the blocks in a flat cylinder around the center
|
* The x/y differences to the blocks in a flat cylinder around the center
|
||||||
|
@ -140,11 +140,15 @@ public class WoodcuttingManager extends SkillManager {
|
|||||||
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
//TODO Remove this workaround when casting to Tree works again
|
||||||
|
if (blockState.getData() instanceof Tree) {
|
||||||
Tree tree = (Tree) blockState.getData();
|
Tree tree = (Tree) blockState.getData();
|
||||||
tree.setDirection(BlockFace.UP);
|
tree.setDirection(BlockFace.UP);
|
||||||
|
}
|
||||||
|
|
||||||
switch (material) {
|
switch (material) {
|
||||||
case LOG:
|
case LOG:
|
||||||
|
case LOG_2:
|
||||||
if (canGetDoubleDrops()) {
|
if (canGetDoubleDrops()) {
|
||||||
Woodcutting.checkForDoubleDrop(blockState);
|
Woodcutting.checkForDoubleDrop(blockState);
|
||||||
}
|
}
|
||||||
@ -153,6 +157,7 @@ public class WoodcuttingManager extends SkillManager {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LEAVES:
|
case LEAVES:
|
||||||
|
case LEAVES_2:
|
||||||
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user