diff --git a/src/main/java/forestry/arboriculture/blocks/BlockPile.java b/src/main/java/forestry/arboriculture/blocks/BlockPile.java index 7060715b5..87533b56c 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockPile.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockPile.java @@ -2,6 +2,7 @@ package forestry.arboriculture.blocks; import com.google.common.collect.Lists; +import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.EnumMap; import java.util.List; @@ -18,9 +19,11 @@ import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.client.particle.ParticleManager; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.init.Enchantments; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -383,35 +386,49 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro @Override public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) { if (!world.isRemote) { - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof ICharcoalPileComponent) { - ICharcoalPileComponent pile = (ICharcoalPileComponent) tile; - ArrayList list = new ArrayList(); - if (getPileType() == EnumPileType.ASH) { - if(pile.getTree() != null){ - ItemStack charcoal = new ItemStack(PluginArboriculture.items.charcoal, pile.getTree().getGenome().getCarbonization(), pile.getTree().getGenome().getCombustibility()); - list.add(charcoal); - list.add(new ItemStack(PluginCore.items.ash, 3)); - }else{ - list.add(new ItemStack(Blocks.DIRT, 2)); - list.add(new ItemStack(PluginCore.items.ash, 2)); - } - } else if (getPileType() == EnumPileType.DIRT) { - list.add(new ItemStack(this)); - } else { - list.add(createWoodPile(pile.getTree())); - } - drop.set(list); - } + int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, player.getActiveItemStack()); + drop.set(getPileDrop(world, pos, state, fortune)); } } + @Nonnull @Override public List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { List drops = drop.get(); drop.remove(); + + // not harvested, get drops normally + if (drops == null) { + drops = getPileDrop(world, pos, state, fortune); + } + return drops; } + + @Nonnull + private List getPileDrop(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { + ArrayList list = new ArrayList(); + TileEntity tile = world.getTileEntity(pos); + if (tile instanceof ICharcoalPileComponent) { + ICharcoalPileComponent pile = (ICharcoalPileComponent) tile; + + if (getPileType() == EnumPileType.ASH) { + if (pile.getTree() != null) { + ItemStack charcoal = new ItemStack(PluginArboriculture.items.charcoal, pile.getTree().getGenome().getCarbonization(), pile.getTree().getGenome().getCombustibility()); + list.add(charcoal); + list.add(new ItemStack(PluginCore.items.ash, 3)); + } else { + list.add(new ItemStack(Blocks.DIRT, 2)); + list.add(new ItemStack(PluginCore.items.ash, 2)); + } + } else if (getPileType() == EnumPileType.DIRT) { + list.add(new ItemStack(this)); + } else { + list.add(createWoodPile(pile.getTree())); + } + } + return list; + } @Override public void breakBlock(World world, BlockPos pos, IBlockState state) {