start working on error handling stuff

This commit is contained in:
dfsek
2025-12-29 22:18:44 -07:00
parent 9a16336f53
commit cb08401536
76 changed files with 212 additions and 165 deletions

View File

@@ -48,17 +48,17 @@ public final class AllayBlockState implements com.dfsek.terra.api.block.state.Bl
}
@Override
public BlockType getBlockType() {
public BlockType blockType() {
return new AllayBlockType(allayBlockState.getBlockType());
}
@Override
public String getAsString(boolean properties) {
public String asString(boolean properties) {
return jeBlockState.toString(properties);
}
@Override
public boolean isAir() {
public boolean air() {
return allayBlockState.getBlockType() == BlockTypes.AIR;
}

View File

@@ -12,17 +12,17 @@ import com.dfsek.terra.api.block.state.BlockState;
*/
public record AllayBlockType(BlockType<?> allayBlockType) implements com.dfsek.terra.api.block.BlockType {
@Override
public BlockState getDefaultState() {
public BlockState defaultState() {
return new AllayBlockState(allayBlockType.getDefaultState(), Mapping.blockStateBeToJe(allayBlockType.getDefaultState()));
}
@Override
public boolean isSolid() {
public boolean solid() {
return allayBlockType.getDefaultState().getBlockStateData().isSolid();
}
@Override
public boolean isWater() {
public boolean water() {
return allayBlockType.hasBlockTag(BlockTags.WATER);
}

View File

@@ -1,5 +1,8 @@
package com.dfsek.terra.allay.handle;
import com.dfsek.terra.api.error.Invalid;
import com.dfsek.terra.api.error.InvalidBlockStateError;
import com.dfsek.terra.api.util.generic.data.types.Either;
import org.jetbrains.annotations.NotNull;
import com.dfsek.terra.allay.JeBlockState;
@@ -16,9 +19,13 @@ import com.dfsek.terra.api.handle.WorldHandle;
public class AllayWorldHandle implements WorldHandle {
@Override
public @NotNull BlockState createBlockState(@NotNull String data) {
JeBlockState jeBlockState = JeBlockState.fromString(data);
return new AllayBlockState(Mapping.blockStateJeToBe(jeBlockState), jeBlockState);
public @NotNull Either<Invalid, BlockState> createBlockState(@NotNull String data) {
try {
JeBlockState jeBlockState = JeBlockState.fromString(data);
return Either.right(new AllayBlockState(Mapping.blockStateJeToBe(jeBlockState), jeBlockState));
} catch(Exception e) {
return new InvalidBlockStateError(e).left();
}
}
@Override