diff --git a/paper-api/src/main/java/org/bukkit/block/BlockType.java b/paper-api/src/main/java/org/bukkit/block/BlockType.java index 6e24b05c90f3..271a453e63de 100644 --- a/paper-api/src/main/java/org/bukkit/block/BlockType.java +++ b/paper-api/src/main/java/org/bukkit/block/BlockType.java @@ -1,5 +1,6 @@ package org.bukkit.block; +import java.util.Set; import java.util.function.Consumer; import org.bukkit.Keyed; import org.bukkit.Material; @@ -169,6 +170,16 @@ interface Typed extends BlockType { @Override B createBlockData(); + /** + * Creates a set of {@link BlockData} instances for this block type, with all + * possible combinations of properties values. + * + * @return new block data set + */ + @NotNull + @Override + Set createBlockDataStates(); + /** * Creates a new {@link BlockData} instance for this block type, with all * properties initialized to unspecified defaults, except for those provided @@ -3480,6 +3491,15 @@ private static B getBlockType(@NotNull String key) { @NotNull BlockData createBlockData(); + /** + * Creates a set of {@link BlockData} instances for this block type, with all + * possible combinations of properties values. + * + * @return new block data set + */ + @NotNull + Set createBlockDataStates(); + /** * Creates a new {@link BlockData} instance for this block type, with all * properties initialized to unspecified defaults, except for those provided diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java index 90fe14f10b7e..20c3073fa8ef 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockType.java @@ -3,7 +3,10 @@ import com.google.common.base.Preconditions; import java.lang.reflect.Method; import java.util.Arrays; +import java.util.Set; import java.util.function.Consumer; +import java.util.stream.Collectors; +import com.google.common.collect.ImmutableSet; import net.minecraft.core.BlockPos; import net.minecraft.core.registries.Registries; import net.minecraft.world.InteractionHand; @@ -147,6 +150,16 @@ public B createBlockData() { return this.createBlockData((String) null); } + @Override + public @NotNull Set createBlockDataStates() { + return this.block.getStateDefinition() + .getPossibleStates() + .stream() + .map(BlockState::createCraftBlockData) + .map(this.blockDataClass::cast) + .collect(ImmutableSet.toImmutableSet()); + } + @Override public B createBlockData(Consumer consumer) { B data = this.createBlockData();