Skip to content

Commit 2b48d81

Browse files
authored
Config Option for Ore Variant Unification with Silk Touch Override (#16)
Added a configuration option that unifies broken stone-variant ores to the basic stone type, unless you are holding a Silk Touch tool (disabled by default).
1 parent 8a0c4e2 commit 2b48d81

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/main/java/gregtech/common/ConfigHolder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ public class ConfigHolder {
112112
@Config.Comment("If false, machines will not make noise. Default: true")
113113
public static boolean doMachinesHaveSounds = true;
114114

115+
@Config.Comment("If true, all rock variants of ores will drop the stone variant unless the player uses Silk Touch. Default: false")
116+
public static boolean requireSilkTouchForRockVariants = false;
117+
115118
public static class VanillaRecipes {
116119

117120
@Config.Comment("Whether to nerf the paper crafting recipe. Default: true")

src/main/java/gregtech/common/blocks/BlockOre.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
55
import gregtech.api.unification.ore.StoneType;
66
import gregtech.api.util.IBlockOre;
77
import gregtech.common.blocks.properties.PropertyStoneType;
8+
import gregtech.common.ConfigHolder;
89
import net.minecraft.block.Block;
910
import net.minecraft.block.BlockFalling;
1011
import net.minecraft.block.SoundType;
1112
import net.minecraft.block.material.Material;
1213
import net.minecraft.block.state.BlockStateContainer;
1314
import net.minecraft.block.state.IBlockState;
1415
import net.minecraft.creativetab.CreativeTabs;
16+
import net.minecraft.enchantment.EnchantmentHelper;
1517
import net.minecraft.entity.Entity;
18+
import net.minecraft.entity.player.EntityPlayer;
19+
import net.minecraft.init.Enchantments;
1620
import net.minecraft.item.ItemStack;
1721
import net.minecraft.util.BlockRenderLayer;
1822
import net.minecraft.util.NonNullList;
@@ -65,7 +69,18 @@ protected void initBlockState() {
6569

6670
@Override
6771
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;
6984
}
7085

7186
@Override

0 commit comments

Comments
 (0)