From 0e8242eabdbd712a2645bbd66e3465c102334391 Mon Sep 17 00:00:00 2001 From: Thomas Couchoud Date: Wed, 9 Sep 2020 19:39:23 +0200 Subject: [PATCH] Do not take into account "minimumLeavesAroundRequired" when using shift down mode --- CHANGELOG.md | 3 +++ changes.md | 2 +- gradle.properties | 2 +- .../fr/raksrinana/fallingtree/config/BreakMode.java | 11 ++++++++++- .../fallingtree/config/TreeConfiguration.java | 3 ++- .../fr/raksrinana/fallingtree/tree/TreeHandler.java | 12 ++++++++---- 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b94784e7..44f10db4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [Fabric-1.16.2-2.3.2] - 2020-09-09 +* Do not take into account "minimumLeavesAroundRequired" when using shift down mode + ## [Fabric-1.16.2-2.3.1] - 2020-09-04 * Set minimum required fabric api (#22) diff --git a/changes.md b/changes.md index f4399c0f..958fe132 100644 --- a/changes.md +++ b/changes.md @@ -1 +1 @@ -* Set minimum required fabric api (#22) \ No newline at end of file +* Do not take into account "minimumLeavesAroundRequired" when using shift down mode \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 55474de6..39aedb04 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ org.gradle.daemon=false group=fr.raksrinana loader=Fabric mod_id=falling_tree -version=2.3.1 +version=2.3.2 repoName=FallingTree name=FallingTree diff --git a/src/main/java/fr/raksrinana/fallingtree/config/BreakMode.java b/src/main/java/fr/raksrinana/fallingtree/config/BreakMode.java index 440a9329..d1bf7e52 100644 --- a/src/main/java/fr/raksrinana/fallingtree/config/BreakMode.java +++ b/src/main/java/fr/raksrinana/fallingtree/config/BreakMode.java @@ -1,5 +1,14 @@ package fr.raksrinana.fallingtree.config; public enum BreakMode{ - INSTANTANEOUS, SHIFT_DOWN + INSTANTANEOUS(true), SHIFT_DOWN(false); + private final boolean checkLeavesAround; + + BreakMode(boolean checkLeavesAround){ + this.checkLeavesAround = checkLeavesAround; + } + + public boolean shouldCheckLeavesAround(){ + return this.checkLeavesAround; + } } diff --git a/src/main/java/fr/raksrinana/fallingtree/config/TreeConfiguration.java b/src/main/java/fr/raksrinana/fallingtree/config/TreeConfiguration.java index bfc86b52..eb730497 100644 --- a/src/main/java/fr/raksrinana/fallingtree/config/TreeConfiguration.java +++ b/src/main/java/fr/raksrinana/fallingtree/config/TreeConfiguration.java @@ -33,7 +33,8 @@ public class TreeConfiguration{ "INFO: Only in INSTANTANEOUS mode.") @Min(1) public int maxSize = 100; - @Comment("The minimum amount of leaves that needs to be around the top most log in order for the mod to consider it a tree.") + @Comment("The minimum amount of leaves that needs to be around the top most log in order for the mod to consider it a tree. " + + "INFO: Only in INSTANTANEOUS mode.") @Min(0) @Max(5) public int minimumLeavesAroundRequired = 3; diff --git a/src/main/java/fr/raksrinana/fallingtree/tree/TreeHandler.java b/src/main/java/fr/raksrinana/fallingtree/tree/TreeHandler.java index f5df00a6..ccd41c9a 100644 --- a/src/main/java/fr/raksrinana/fallingtree/tree/TreeHandler.java +++ b/src/main/java/fr/raksrinana/fallingtree/tree/TreeHandler.java @@ -34,12 +34,16 @@ public static Optional getTree(World world, BlockPos blockPos){ toAnalyzePos.addAll(nearbyPos.stream().filter(pos -> !toAnalyzePos.contains(pos)).collect(Collectors.toList())); } - int aroundRequired = FallingTree.config.getTreesConfiguration().getMinimumLeavesAroundRequired(); - if(tree.getTopMostLog().map(topLog -> getLeavesAround(world, topLog) >= aroundRequired).orElseGet(() -> aroundRequired == 0)){ - return Optional.of(tree); + if(FallingTree.config.getTreesConfiguration().getBreakMode().shouldCheckLeavesAround()){ + int aroundRequired = FallingTree.config.getTreesConfiguration().getMinimumLeavesAroundRequired(); + if(tree.getTopMostLog() + .map(topLog -> getLeavesAround(world, topLog) < aroundRequired) + .orElse(true)){ + return Optional.empty(); + } } - return Optional.empty(); + return Optional.of(tree); } private static Collection neighborLogs(World world, Block logBlock, BlockPos blockPos, Collection analyzedPos){