From 64aa0d9c601794178f09d366c4d9a61d891dcec3 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Wed, 12 Jan 2022 10:52:28 +1100 Subject: [PATCH] #704: Add generateTree method with a predicate By: DerFrZocker --- .../main/java/org/bukkit/RegionAccessor.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/RegionAccessor.java b/paper-api/src/main/java/org/bukkit/RegionAccessor.java index e285d54450..a89fff5c16 100644 --- a/paper-api/src/main/java/org/bukkit/RegionAccessor.java +++ b/paper-api/src/main/java/org/bukkit/RegionAccessor.java @@ -3,6 +3,7 @@ package org.bukkit; import java.util.Collection; import java.util.List; import java.util.Random; +import java.util.function.Predicate; import org.bukkit.block.Biome; import org.bukkit.block.BlockState; import org.bukkit.block.data.BlockData; @@ -183,6 +184,26 @@ public interface RegionAccessor { */ boolean generateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type, @Nullable Consumer stateConsumer); + /** + * Creates a tree at the given {@link Location} + *

+ * The provided predicate gets called for every block which gets changed + * as a result of the tree generation. When the predicate gets called no + * modifications to the world are done yet. Which means, that calling + * {@link #getBlockState(Location)} in the predicate will return the state + * of the block before the generation. + *

+ * If the predicate returns {@code true} the block gets set in the world. + * If it returns {@code false} the block won't get set in the world. + * + * @param location Location to spawn the tree + * @param random Random to use to generated the tree + * @param type Type of the tree to create + * @param statePredicate The predicate which should get used to test if a block should be set or not. + * @return true if the tree was created successfully, otherwise false + */ + boolean generateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type, @Nullable Predicate statePredicate); + /** * Creates a entity at the given {@link Location} *