Make BlockStateHolder extend Pattern.

Removes the need for wrapping them in BlockPattern.
This commit is contained in:
wizjany
2019-07-28 18:20:00 -04:00
parent f4c238c3da
commit 6631b6bdf0
17 changed files with 59 additions and 53 deletions

View File

@ -20,13 +20,15 @@
package com.sk89q.worldedit.world.block;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;
public interface BlockStateHolder<B extends BlockStateHolder<B>> {
public interface BlockStateHolder<B extends BlockStateHolder<B>> extends Pattern {
/**
* Get the block type
@ -89,6 +91,11 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> {
*/
BaseBlock toBaseBlock(CompoundTag compoundTag);
@Override
default BaseBlock apply(BlockVector3 position) {
return toBaseBlock();
}
default String getAsString() {
if (getStates().isEmpty()) {
return this.getBlockType().getId();