mirror of
https://github.com/songoda/UltimateTimber.git
synced 2025-03-02 10:31:10 +01:00
Fix bug with entire tree base setting
This commit is contained in:
parent
f9cac11d7a
commit
b9389137cf
@ -1,6 +1,7 @@
|
|||||||
package com.songoda.ultimatetimber.treefall;
|
package com.songoda.ultimatetimber.treefall;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -163,14 +164,19 @@ public class TreeChecker {
|
|||||||
if (!this.isMushroom && this.treeBlocks.stream().filter(x -> this.isValidLeafType(x.getType())).count() < this.numLeavesRequiredForTree)
|
if (!this.isMushroom && this.treeBlocks.stream().filter(x -> this.isValidLeafType(x.getType())).count() < this.numLeavesRequiredForTree)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// All logs must not have a plantable surface below them (if enabled)
|
// The lowest logs of the tree must not have a plantable surface below them
|
||||||
if (this.entireTreeBase) {
|
if (this.entireTreeBase) { // TODO: Refactor this
|
||||||
boolean isTreeGrounded = this.treeBlocks.stream().anyMatch(x -> {
|
int lowestY = this.treeBlocks.stream().min(new Comparator<Block>() {
|
||||||
|
public int compare(Block b1, Block b2) {
|
||||||
|
return b1.getY() - b2.getY();
|
||||||
|
}}).get().getY();
|
||||||
|
boolean isTreeGrounded = this.treeBlocks.stream().filter(x -> x.getY() == lowestY).anyMatch(x -> {
|
||||||
Material typeBelow = x.getRelative(BlockFace.DOWN).getType();
|
Material typeBelow = x.getRelative(BlockFace.DOWN).getType();
|
||||||
return (typeBelow.equals(Material.DIRT) ||
|
return (typeBelow.equals(Material.DIRT) ||
|
||||||
typeBelow.equals(Material.COARSE_DIRT) ||
|
typeBelow.equals(Material.COARSE_DIRT) ||
|
||||||
typeBelow.equals(Material.PODZOL) ||
|
typeBelow.equals(Material.PODZOL) ||
|
||||||
typeBelow.equals(Material.GRASS_BLOCK)) &&
|
typeBelow.equals(Material.GRASS_BLOCK) ||
|
||||||
|
isValidLogType(typeBelow)) &&
|
||||||
!x.equals(block) &&
|
!x.equals(block) &&
|
||||||
isValidLogType(x.getType());
|
isValidLogType(x.getType());
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user