|
5 | 5 | import gregtech.api.unification.ore.StoneType; |
6 | 6 | import gregtech.api.util.IBlockOre; |
7 | 7 | import gregtech.common.blocks.properties.PropertyStoneType; |
| 8 | +import gregtech.common.ConfigHolder; |
8 | 9 | import net.minecraft.block.Block; |
9 | 10 | import net.minecraft.block.BlockFalling; |
10 | 11 | import net.minecraft.block.SoundType; |
11 | 12 | import net.minecraft.block.material.Material; |
12 | 13 | import net.minecraft.block.state.BlockStateContainer; |
13 | 14 | import net.minecraft.block.state.IBlockState; |
14 | 15 | import net.minecraft.creativetab.CreativeTabs; |
| 16 | +import net.minecraft.enchantment.EnchantmentHelper; |
15 | 17 | import net.minecraft.entity.Entity; |
| 18 | +import net.minecraft.entity.player.EntityPlayer; |
| 19 | +import net.minecraft.init.Enchantments; |
16 | 20 | import net.minecraft.item.ItemStack; |
17 | 21 | import net.minecraft.util.BlockRenderLayer; |
18 | 22 | import net.minecraft.util.NonNullList; |
@@ -65,7 +69,18 @@ protected void initBlockState() { |
65 | 69 |
|
66 | 70 | @Override |
67 | 71 | public int damageDropped(IBlockState state) { |
68 | | - return getMetaFromState(state); |
| 72 | + // Only drop the variants meta ID if: |
| 73 | + // - The config option for requiring silk touch is disabled |
| 74 | + // - OR The function was called without a harvester (needed for mod compatibility) |
| 75 | + // - OR The harvester has an item with silk touch in their main hand |
| 76 | + if (!ConfigHolder.requireSilkTouchForRockVariants || |
| 77 | + harvesters.get() == null || |
| 78 | + EnchantmentHelper.getEnchantments(harvesters.get().getHeldItemMainhand()) |
| 79 | + .containsKey(Enchantments.SILK_TOUCH)) |
| 80 | + return getMetaFromState(state); |
| 81 | + |
| 82 | + // otherwise, return the id of StoneType.STONE |
| 83 | + return 0; |
69 | 84 | } |
70 | 85 |
|
71 | 86 | @Override |
|
0 commit comments