Entity SNBT Support and Cleanup

This commit is contained in:
Zoë Gidiere
2025-10-05 23:50:29 -06:00
parent 8d153998fa
commit 9ca7014344
14 changed files with 191 additions and 42 deletions

View File

@@ -1,8 +0,0 @@
package com.dfsek.terra.api.block;
import com.dfsek.terra.api.Handle;
public interface BlockData extends Handle {
String toString();
}

View File

@@ -12,12 +12,13 @@ import java.util.function.Consumer;
import com.dfsek.terra.api.Handle;
import com.dfsek.terra.api.block.BlockType;
import com.dfsek.terra.api.block.state.properties.Property;
import com.dfsek.terra.api.data.Extendable;
/**
* Contains basic data about a {@link BlockType} in the world
*/
public interface BlockState extends Handle {
public interface BlockState extends Handle, Extendable {
/**
* Whether this {@link BlockState} matches another.
@@ -115,12 +116,4 @@ public interface BlockState extends Handle {
* @return Whether this state is air
*/
boolean isAir();
/**
* Get whether this BlockState is an extended state.
* Extended states are states that contain extra data not normally present in a BlockState.
*
* @return Whether this state is extended.
*/
default boolean isExtended() { return false; }
}

View File

@@ -1,6 +1,6 @@
package com.dfsek.terra.api.block.state;
import com.dfsek.terra.api.block.BlockData;
import com.dfsek.terra.api.data.ExtendedData;
public interface BlockStateExtended extends BlockState {
@@ -9,7 +9,7 @@ public interface BlockStateExtended extends BlockState {
*
* @return BlockData of this BlockStateExtended
*/
BlockData getData();
ExtendedData getData();
/**
* Sets the BlockData.
@@ -18,7 +18,7 @@ public interface BlockStateExtended extends BlockState {
*
* @return New BlockStateExtended with the given BlockData
*/
BlockStateExtended setData(BlockData data);
BlockStateExtended setData(ExtendedData data);
/**
* Gets the BlockState.

View File

@@ -0,0 +1,11 @@
package com.dfsek.terra.api.data;
public interface Extendable {
/**
* Get whether this BlockState is an extended state.
* Extended states are states that contain extra data not normally present in a BlockState.
*
* @return Whether this state is extended.
*/
default boolean isExtended() { return false; }
}

View File

@@ -0,0 +1,8 @@
package com.dfsek.terra.api.data;
import com.dfsek.terra.api.Handle;
public interface ExtendedData extends Handle {
String toString();
}

View File

@@ -8,7 +8,8 @@
package com.dfsek.terra.api.entity;
import com.dfsek.terra.api.Handle;
import com.dfsek.terra.api.data.Extendable;
public interface EntityType extends Handle {
public interface EntityType extends Handle, Extendable {
}

View File

@@ -0,0 +1,32 @@
package com.dfsek.terra.api.entity;
import com.dfsek.terra.api.data.ExtendedData;
public interface EntityTypeExtended extends EntityType {
/**
* Gets the BlockData.
*
* @return BlockData of this EntityTypeExtended
*/
ExtendedData getData();
/**
* Sets the BlockData.
*
* @param data BlockData to set
*
* @return New EntityTypeExtended with the given BlockData
*/
EntityTypeExtended setData(ExtendedData data);
/**
* Gets the EntityType.
*
* @return Raw EntityType of this EntityTypeExtended
*/
EntityType getType();
@Override
default boolean isExtended() { return true; }
}