Skip to content

Commit

Permalink
Do not take into account "minimumLeavesAroundRequired" when using shi…
Browse files Browse the repository at this point in the history
…ft down mode
  • Loading branch information
Rakambda committed Sep 9, 2020
1 parent e7d6ca0 commit 0e8242e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion changes.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* Set minimum required fabric api (#22)
* Do not take into account "minimumLeavesAroundRequired" when using shift down mode
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/fr/raksrinana/fallingtree/config/BreakMode.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/fr/raksrinana/fallingtree/tree/TreeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ public static Optional<Tree> 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<BlockPos> neighborLogs(World world, Block logBlock, BlockPos blockPos, Collection<BlockPos> analyzedPos){
Expand Down

0 comments on commit 0e8242e

Please sign in to comment.