mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-14 11:46:06 +00:00
implement BlockState with mixin on Fabric
This commit is contained in:
@@ -14,31 +14,33 @@ import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.block.state.properties.Property;
|
||||
|
||||
|
||||
public interface BlockState extends Cloneable, Handle {
|
||||
public interface BlockState extends Handle {
|
||||
|
||||
boolean matches(BlockState other);
|
||||
|
||||
BlockState clone();
|
||||
<T extends Comparable<T>> boolean has(Property<T> property);
|
||||
|
||||
<T> boolean has(Property<T> property);
|
||||
<T extends Comparable<T>> T get(Property<T> property);
|
||||
|
||||
<T> T get(Property<T> property);
|
||||
<T extends Comparable<T>> BlockState set(Property<T> property, T value);
|
||||
|
||||
<T> BlockState set(Property<T> property, T value);
|
||||
|
||||
default <T> BlockState ifProperty(Property<T> property, Consumer<BlockState> action) {
|
||||
default <T extends Comparable<T>> BlockState ifProperty(Property<T> property, Consumer<BlockState> action) {
|
||||
if(has(property)) action.accept(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
default <T> BlockState setIfPresent(Property<T> property, T value) {
|
||||
default <T extends Comparable<T>> BlockState setIfPresent(Property<T> property, T value) {
|
||||
if(has(property)) set(property, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
BlockType getBlockType();
|
||||
|
||||
String getAsString();
|
||||
default String getAsString() {
|
||||
return getAsString(true);
|
||||
}
|
||||
|
||||
String getAsString(boolean properties);
|
||||
|
||||
boolean isAir();
|
||||
}
|
||||
|
||||
@@ -104,8 +104,8 @@ public final class RotationUtil {
|
||||
};
|
||||
}
|
||||
|
||||
public static void rotateBlockData(BlockState data, Rotation r) {
|
||||
data
|
||||
public static BlockState rotateBlockData(BlockState data, Rotation r) {
|
||||
return data
|
||||
.ifProperty(Properties.NORTH, state -> state.set(rotateCardinal(Properties.NORTH, r), state.get(Properties.NORTH)))
|
||||
.ifProperty(Properties.SOUTH, state -> state.set(rotateCardinal(Properties.SOUTH, r), state.get(Properties.SOUTH)))
|
||||
.ifProperty(Properties.EAST, state -> state.set(rotateCardinal(Properties.EAST, r), state.get(Properties.EAST)))
|
||||
|
||||
Reference in New Issue
Block a user