mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-27 15:33:03 +00:00
Adds dropping experiance when breaking blocks, example Coal and Lappis
This commit is contained in:
1 parent
efc9208abf
commit
d76117d559
6 files changed
+64
-1
No files matched your search
@@ -3,6 +3,7 @@ package tconstruct.library.tools;
|
||||
import mantle.world.WorldHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -84,6 +85,12 @@ public abstract class HarvestTool extends ToolCore
|
||||
{
|
||||
localBlock.onBlockDestroyedByPlayer(world, x, y, z, localMeta);
|
||||
}
|
||||
|
||||
// Workaround for dropping experience
|
||||
int fortune = EnchantmentHelper.getFortuneModifier(player);
|
||||
int exp = localBlock.getExpDrop(world, localMeta, fortune);
|
||||
localBlock.dropXpOnBlockBreak(world, x, y, z, exp);
|
||||
|
||||
localBlock.harvestBlock(world, player, x, y, z, localMeta);
|
||||
localBlock.onBlockHarvested(world, x, y, z, localMeta, player);
|
||||
if (blockHardness > 0f)
|
||||
@@ -288,4 +295,17 @@ public abstract class HarvestTool extends ToolCore
|
||||
|
||||
return used;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel (ItemStack stack, String toolClass)
|
||||
{
|
||||
if (!(stack.getItem() instanceof HarvestTool) || !getHarvestType().equals(toolClass))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
int harvestLvl = tags.getInteger("HarvestLevel");
|
||||
return harvestLvl;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user