Skip to content

Commit 4ef4d4c

Browse files
committed
Make it a config option.
1 parent b299c02 commit 4ef4d4c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/main/java/mods/timberjack/common/TimberjackConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class TimberjackConfig {
2525
private static int maxLogsProcessed = 2000;
2626
private static boolean canFellLargeTrees;
2727
private static boolean aggressiveHouseProtection = true;
28+
private static boolean sneakingPreventsFelling = true;
2829
private static String[] logBlacklistArray = {
2930
"natura:redwood_logs",
3031
"biomesoplenty:log_0#4",
@@ -45,6 +46,10 @@ public static boolean aggressiveHouseProtection() {
4546
return aggressiveHouseProtection;
4647
}
4748

49+
public static boolean sneakingPreventsFelling() {
50+
return sneakingPreventsFelling;
51+
}
52+
4853
public static boolean canFellLog(IBlockState state) {
4954
String name = state.getBlock().getRegistryName().toString();
5055
if (logBlacklist.contains(name))
@@ -60,6 +65,7 @@ public static void load(File configDir) {
6065
maxLogsProcessed = config.getInt("maxLogsProcessed", Configuration.CATEGORY_GENERAL, maxLogsProcessed, 0, 10_0000, "How many logs the tree scanning algorithm should look at before giving up");
6166
canFellLargeTrees = config.getBoolean("canFellLargeTrees", Configuration.CATEGORY_GENERAL, canFellLargeTrees, "What should happen when maxLogsProcessed is hit?");
6267
aggressiveHouseProtection = config.getBoolean("aggressiveHouseProtection", Configuration.CATEGORY_GENERAL, aggressiveHouseProtection, "If doors, glass, bed, workbench, signs, furnaces, carpets, etc are detected near the tree it will terminate the felling, protecting the house");
68+
sneakingPreventsFelling = config.getBoolean("sneakingPreventsFelling", Configuration.CATEGORY_GENERAL, sneakingPreventsFelling, "Suppresses the felling event if the player is sneaking while chopping.");
6369
logBlacklistArray = config.getStringList("logBlacklist", Configuration.CATEGORY_GENERAL, logBlacklistArray, "Log types that should never be felled. Format: <resourceId/modId>:<blockName>[#<meta>]");
6470

6571
logBlacklist = Arrays.stream(logBlacklistArray).collect(Collectors.toSet());

src/main/java/mods/timberjack/common/felling/TimberjackEventHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package mods.timberjack.common.felling;
99

10+
import mods.timberjack.common.TimberjackConfig;
1011
import net.minecraft.block.BlockLog;
1112
import net.minecraft.block.BlockPistonBase;
1213
import net.minecraft.block.material.Material;
@@ -68,7 +69,7 @@ public void entityJoin(EntityJoinWorldEvent event) {
6869
@SubscribeEvent
6970
public void chopEvent(BlockEvent.BreakEvent event) {
7071
World world = event.getWorld();
71-
if (!event.getPlayer().isSneaking() && TimberjackUtils.isWood(event.getState(), world, event.getPos())) {
72+
if ((!event.getPlayer().isSneaking() || !TimberjackConfig.sneakingPreventsFelling()) && TimberjackUtils.isWood(event.getState(), world, event.getPos())) {
7273
EnumFacing fellingDirection;
7374
if (world.rand.nextFloat() < 0.1) {
7475
fellingDirection = EnumFacing.HORIZONTALS[new Random().nextInt(EnumFacing.HORIZONTALS.length)];

0 commit comments

Comments
 (0)