mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-24 05:21:16 +00:00
start working on error handling stuff
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -28,7 +28,7 @@ public class BukkitAddon implements BaseAddon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
public Version version() {
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ public class CloudCommandSender implements CommandSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Maybe<Entity> getEntity() {
|
||||
public Maybe<Entity> entity() {
|
||||
if(delegate instanceof org.bukkit.entity.Entity entity) {
|
||||
return Maybe.just(BukkitAdapter.adapt(entity));
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class CloudCommandSender implements CommandSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Maybe<Player> getPlayer() {
|
||||
public Maybe<Player> player() {
|
||||
if(delegate instanceof org.bukkit.entity.Player player) {
|
||||
return Maybe.just(BukkitAdapter.adapt(player));
|
||||
}
|
||||
|
||||
+11
-4
@@ -17,6 +17,9 @@
|
||||
|
||||
package com.dfsek.terra.bukkit.handles;
|
||||
|
||||
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.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -39,10 +42,14 @@ public class BukkitWorldHandle implements WorldHandle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized @NotNull BlockState createBlockState(@NotNull String data) {
|
||||
org.bukkit.block.data.BlockData bukkitData = Bukkit.createBlockData(
|
||||
data); // somehow bukkit managed to make this not thread safe! :)
|
||||
return BukkitBlockState.newInstance(bukkitData);
|
||||
public synchronized @NotNull Either<Invalid, BlockState> createBlockState(@NotNull String data) {
|
||||
try {
|
||||
org.bukkit.block.data.BlockData bukkitData = Bukkit.createBlockData(
|
||||
data); // somehow bukkit managed to make this not thread safe! :)
|
||||
return Either.right(BukkitBlockState.newInstance(bukkitData));
|
||||
} catch(Exception e) {
|
||||
return new InvalidBlockStateError(e).left();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -39,17 +39,17 @@ public class BukkitBlockTypeAndItem implements BlockType, Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getDefaultState() {
|
||||
public BlockState defaultState() {
|
||||
return BukkitAdapter.adapt(delegate.createBlockData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSolid() {
|
||||
public boolean solid() {
|
||||
return delegate.isOccluding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWater() {
|
||||
public boolean water() {
|
||||
return delegate == Material.WATER;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -61,17 +61,17 @@ public class BukkitBlockState implements BlockState {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockType getBlockType() {
|
||||
public BlockType blockType() {
|
||||
return BukkitAdapter.adapt(delegate.getMaterial());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsString(boolean properties) {
|
||||
public String asString(boolean properties) {
|
||||
return delegate.getAsString(!properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAir() {
|
||||
public boolean air() {
|
||||
return delegate.getMaterial().isAir();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +98,6 @@ public class NMSBiomeInjector {
|
||||
|
||||
public static String createBiomeID(ConfigPack pack, com.dfsek.terra.api.registry.key.RegistryKey biomeID) {
|
||||
return pack.getID()
|
||||
.toLowerCase() + "/" + biomeID.getNamespace().toLowerCase(Locale.ROOT) + "/" + biomeID.getID().toLowerCase(Locale.ROOT);
|
||||
.toLowerCase() + "/" + biomeID.namespace().toLowerCase(Locale.ROOT) + "/" + biomeID.getID().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,17 +64,17 @@ public class CLIBlockState implements BlockState {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockType getBlockType() {
|
||||
public BlockType blockType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsString(boolean properties) {
|
||||
public String asString(boolean properties) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAir() {
|
||||
public boolean air() {
|
||||
return isAir;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,17 +25,17 @@ public class CLIBlockType implements BlockType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getDefaultState() {
|
||||
public BlockState defaultState() {
|
||||
return defaultState.value();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSolid() {
|
||||
public boolean solid() {
|
||||
return solid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWater() {
|
||||
public boolean water() {
|
||||
return water;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.cli.handle;
|
||||
|
||||
import com.dfsek.terra.api.error.Invalid;
|
||||
import com.dfsek.terra.api.util.generic.data.types.Either;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
@@ -16,8 +18,8 @@ public class CLIWorldHandle implements WorldHandle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull BlockState createBlockState(@NotNull String data) {
|
||||
return new CLIBlockState(data);
|
||||
public @NotNull Either<Invalid, BlockState> createBlockState(@NotNull String data) {
|
||||
return Either.right(new CLIBlockState(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,7 +36,7 @@ public class MinestomAddon implements BaseAddon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() { return VERSION; }
|
||||
public Version version() { return VERSION; }
|
||||
|
||||
@Override
|
||||
public String getID() { return "terra-minestom"; }
|
||||
|
||||
+3
-3
@@ -114,12 +114,12 @@ public record MinestomBlockState(Block block) implements BlockState {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockType getBlockType() {
|
||||
public BlockType blockType() {
|
||||
return new MinestomBlockType(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsString(boolean properties) {
|
||||
public String asString(boolean properties) {
|
||||
String name = block.key().asString();
|
||||
if(!properties || block.properties().isEmpty()) {
|
||||
return name;
|
||||
@@ -132,7 +132,7 @@ public record MinestomBlockState(Block block) implements BlockState {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAir() {
|
||||
public boolean air() {
|
||||
return block.isAir();
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -14,17 +14,17 @@ public class MinestomBlockType implements BlockType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getDefaultState() {
|
||||
public BlockState defaultState() {
|
||||
return new MinestomBlockState(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSolid() {
|
||||
public boolean solid() {
|
||||
return block.isSolid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWater() {
|
||||
public boolean water() {
|
||||
return block.isLiquid();
|
||||
}
|
||||
|
||||
|
||||
+9
-2
@@ -1,5 +1,8 @@
|
||||
package com.dfsek.terra.minestom.world;
|
||||
|
||||
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 net.minestom.server.instance.block.Block;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -14,8 +17,12 @@ public class MinestomWorldHandle implements WorldHandle {
|
||||
private static final MinestomBlockState AIR = new MinestomBlockState(Block.AIR);
|
||||
|
||||
@Override
|
||||
public @NotNull BlockState createBlockState(@NotNull String data) {
|
||||
return MinestomBlockState.fromStateId(data);
|
||||
public @NotNull Either<Invalid, BlockState> createBlockState(@NotNull String data) {
|
||||
try {
|
||||
return Either.right(MinestomBlockState.fromStateId(data));
|
||||
} catch(Exception e) {
|
||||
return new InvalidBlockStateError(e).left();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -76,7 +76,7 @@ public abstract class MinecraftAddon implements BaseAddon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
public Version version() {
|
||||
return VERSION;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public final class Codecs {
|
||||
public static final Codec<RegistryKey> TERRA_REGISTRY_KEY = RecordCodecBuilder
|
||||
.create(registryKey -> registryKey.group(Codec.STRING.fieldOf("namespace")
|
||||
.stable()
|
||||
.forGetter(RegistryKey::getNamespace),
|
||||
.forGetter(RegistryKey::namespace),
|
||||
Codec.STRING.fieldOf("id")
|
||||
.stable()
|
||||
.forGetter(RegistryKey::getID))
|
||||
|
||||
+4
-4
@@ -138,11 +138,11 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
||||
com.dfsek.terra.api.block.state.BlockState data = delegate.getPalette(x + xi, y, z + zi, world, biomeProvider).get(
|
||||
depth, x + xi, y, z + zi, world.getSeed());
|
||||
BlockPos blockPos = new BlockPos(x, y, z);
|
||||
boolean isExtended = data.isExtended() && data.getClass().equals(BlockStateArgument.class);
|
||||
boolean isExtended = data.extended() && data.getClass().equals(BlockStateArgument.class);
|
||||
if(isExtended) {
|
||||
BlockStateExtended blockStateExtended = (BlockStateExtended) data;
|
||||
|
||||
net.minecraft.block.BlockState blockState = (net.minecraft.block.BlockState) blockStateExtended.getState();
|
||||
net.minecraft.block.BlockState blockState = (net.minecraft.block.BlockState) blockStateExtended.state();
|
||||
chunk.setBlockState(blockPos, blockState, 0);
|
||||
} else {
|
||||
chunk.setBlockState(blockPos, (net.minecraft.block.BlockState) data, 0);
|
||||
@@ -196,7 +196,7 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
||||
for(int y = height.getTopYInclusive() - 1; y >= min; y--) {
|
||||
com.dfsek.terra.api.block.state.BlockState terraBlockState = delegate.getBlock(properties, x, y, z, biomeProvider);
|
||||
BlockState blockState =
|
||||
(BlockState) (terraBlockState.isExtended() ? ((BlockStateExtended) terraBlockState).getState() : terraBlockState);
|
||||
(BlockState) (terraBlockState.extended() ? ((BlockStateExtended) terraBlockState).state() : terraBlockState);
|
||||
if(heightmap
|
||||
.getBlockPredicate()
|
||||
.test(blockState)) return y + 1;
|
||||
@@ -212,7 +212,7 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
||||
for(int y = height.getTopYInclusive() - 1; y >= height.getBottomY(); y--) {
|
||||
com.dfsek.terra.api.block.state.BlockState terraBlockState = delegate.getBlock(properties, x, y, z, biomeProvider);
|
||||
BlockState blockState =
|
||||
(BlockState) (terraBlockState.isExtended() ? ((BlockStateExtended) terraBlockState).getState() : terraBlockState);
|
||||
(BlockState) (terraBlockState.extended() ? ((BlockStateExtended) terraBlockState).state() : terraBlockState);
|
||||
array[y - height.getBottomY()] = blockState;
|
||||
}
|
||||
return new VerticalBlockSample(height.getBottomY(), array);
|
||||
|
||||
+7
-4
@@ -17,6 +17,9 @@
|
||||
|
||||
package com.dfsek.terra.mod.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 com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
@@ -51,7 +54,7 @@ public class MinecraftWorldHandle implements WorldHandle {
|
||||
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
@Override
|
||||
public @NotNull BlockState createBlockState(@NotNull String data) {
|
||||
public @NotNull Either<Invalid, BlockState> createBlockState(@NotNull String data) {
|
||||
try {
|
||||
BlockResult blockResult = BlockArgumentParser.block(Registries.BLOCK, data, true);
|
||||
BlockState blockState;
|
||||
@@ -76,10 +79,10 @@ public class MinecraftWorldHandle implements WorldHandle {
|
||||
blockState = (BlockState) blockResult.blockState();
|
||||
}
|
||||
|
||||
if(blockState == null) throw new IllegalArgumentException("Invalid data: " + data);
|
||||
return blockState;
|
||||
if(blockState == null) return new InvalidBlockStateError(new IllegalArgumentException("Invalid data: " + data)).left();
|
||||
return Either.right(blockState);
|
||||
} catch(CommandSyntaxException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
return new InvalidBlockStateError(e).left();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -29,16 +29,16 @@ import com.dfsek.terra.api.block.BlockType;
|
||||
@Mixin(Block.class)
|
||||
@Implements(@Interface(iface = BlockType.class, prefix = "terra$"))
|
||||
public abstract class BlockMixin {
|
||||
public com.dfsek.terra.api.block.state.BlockState terra$getDefaultState() {
|
||||
public com.dfsek.terra.api.block.state.BlockState terra$defaultState() {
|
||||
return (com.dfsek.terra.api.block.state.BlockState) ((Block) (Object) this).getDefaultState();
|
||||
}
|
||||
|
||||
public boolean terra$isSolid() {
|
||||
public boolean terra$solid() {
|
||||
return ((Block) (Object) this).getDefaultState().isOpaque();
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public boolean terra$isWater() {
|
||||
public boolean terra$water() {
|
||||
return ((Object) this) == Blocks.WATER;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
|
||||
rand = Random.create();
|
||||
}
|
||||
net.minecraft.entity.EntityType<?> entityType =
|
||||
(((net.minecraft.entity.EntityType<?>) (creatureType.isExtended() && creatureType.getClass().equals(
|
||||
(((net.minecraft.entity.EntityType<?>) (creatureType.extended() && creatureType.getClass().equals(
|
||||
MinecraftEntityTypeExtended.class) ? ((MinecraftEntityTypeExtended) creatureType).getType() : creatureType)));
|
||||
setEntityType(entityType, rand);
|
||||
}
|
||||
|
||||
+5
-5
@@ -57,17 +57,17 @@ public abstract class BlockStateArgumentMixin implements Predicate<CachedBlockPo
|
||||
|
||||
@Intrinsic
|
||||
public BlockType terra$getBlockType() {
|
||||
return ((com.dfsek.terra.api.block.state.BlockState) getBlockState()).getBlockType();
|
||||
return ((com.dfsek.terra.api.block.state.BlockState) getBlockState()).blockType();
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
public String terra$getAsString(boolean properties) {
|
||||
return ((com.dfsek.terra.api.block.state.BlockState) getBlockState()).getAsString(properties);
|
||||
return ((com.dfsek.terra.api.block.state.BlockState) getBlockState()).asString(properties);
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
public boolean terra$isAir() {
|
||||
return ((com.dfsek.terra.api.block.state.BlockState) getBlockState()).isAir();
|
||||
return ((com.dfsek.terra.api.block.state.BlockState) getBlockState()).air();
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "ConstantValue", "DataFlowIssue", "EqualsBetweenInconvertibleTypes" })
|
||||
@@ -79,12 +79,12 @@ public abstract class BlockStateArgumentMixin implements Predicate<CachedBlockPo
|
||||
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
@Intrinsic
|
||||
public ExtendedData terra$getData() {
|
||||
public ExtendedData terra$data() {
|
||||
return ((ExtendedData) ((Object) data));
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
public com.dfsek.terra.api.block.state.BlockState terra$getState() {
|
||||
public com.dfsek.terra.api.block.state.BlockState terra$state() {
|
||||
return (com.dfsek.terra.api.block.state.BlockState) getBlockState();
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -60,12 +60,12 @@ public abstract class BlockStateMixin extends State<Block, net.minecraft.block.B
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
public BlockType terra$getBlockType() {
|
||||
public BlockType terra$blockType() {
|
||||
return (BlockType) getBlock();
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
public String terra$getAsString(boolean properties) {
|
||||
public String terra$asString(boolean properties) {
|
||||
StringBuilder data = new StringBuilder(Registries.BLOCK.getId(getBlock()).toString());
|
||||
if(properties && !getEntries().isEmpty()) {
|
||||
data.append('[');
|
||||
@@ -77,7 +77,7 @@ public abstract class BlockStateMixin extends State<Block, net.minecraft.block.B
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
public boolean terra$isAir() {
|
||||
public boolean terra$air() {
|
||||
return isAir();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ public abstract class ChunkRegionMixin implements StructureWorldAccess {
|
||||
state = arg.getBlockState();
|
||||
setBlockState(blockPos, state, 0, 512);
|
||||
net.minecraft.world.chunk.Chunk chunk = getChunk(blockPos);
|
||||
NbtCompound nbt = ((NbtCompound) (Object) ((BlockStateExtended) data).getData());
|
||||
NbtCompound nbt = ((NbtCompound) (Object) ((BlockStateExtended) data).data());
|
||||
MinecraftUtil.loadBlockEntity(chunk, world, blockPos, state, nbt);
|
||||
} else {
|
||||
state = (net.minecraft.block.BlockState) data;
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ public abstract class WorldChunkMixin {
|
||||
BlockStateArgument arg = ((BlockStateArgument) data);
|
||||
state = arg.getBlockState();
|
||||
setBlockState(blockPos, state, 0);
|
||||
loadBlockEntity(blockPos, ((NbtCompound) (Object) ((BlockStateExtended) data).getData()));
|
||||
loadBlockEntity(blockPos, ((NbtCompound) (Object) ((BlockStateExtended) data).data()));
|
||||
} else {
|
||||
state = (net.minecraft.block.BlockState) data;
|
||||
setBlockState(blockPos, state, 0);
|
||||
|
||||
+2
-2
@@ -54,11 +54,11 @@ public abstract class ProtoChunkMixin extends Chunk {
|
||||
|
||||
public void terra$setBlock(int x, int y, int z, @NotNull BlockState data) {
|
||||
BlockPos blockPos = new BlockPos(x, y, z);
|
||||
boolean isExtended = data.isExtended() && data.getClass().equals(BlockStateArgument.class);
|
||||
boolean isExtended = data.extended() && data.getClass().equals(BlockStateArgument.class);
|
||||
if(isExtended) {
|
||||
BlockStateExtended blockStateExtended = (BlockStateExtended) data;
|
||||
|
||||
net.minecraft.block.BlockState blockState = (net.minecraft.block.BlockState) blockStateExtended.getState();
|
||||
net.minecraft.block.BlockState blockState = (net.minecraft.block.BlockState) blockStateExtended.state();
|
||||
this.setBlockState(blockPos, blockState, 0);
|
||||
} else {
|
||||
this.setBlockState(blockPos, (net.minecraft.block.BlockState) data, 0);
|
||||
|
||||
+7
-7
@@ -17,6 +17,8 @@
|
||||
|
||||
package com.dfsek.terra.mod.mixin.implementations.terra.entity;
|
||||
|
||||
import com.dfsek.terra.api.util.generic.data.types.Maybe;
|
||||
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
@@ -27,8 +29,6 @@ import org.spongepowered.asm.mixin.Interface;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.dfsek.terra.api.command.CommandSender;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
@@ -52,15 +52,15 @@ public abstract class ServerCommandSourceMixin {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Optional<Entity> terra$getEntity() {
|
||||
return Optional.ofNullable((Entity) getEntity());
|
||||
public Maybe<Entity> terra$entity() {
|
||||
return Maybe.ofNullable((Entity) getEntity());
|
||||
}
|
||||
|
||||
public Optional<Player> terra$getPlayer() {
|
||||
public Maybe<Player> terra$player() {
|
||||
try {
|
||||
return Optional.ofNullable((Player) getPlayer());
|
||||
return Maybe.ofNullable((Player) getPlayer());
|
||||
} catch(CommandSyntaxException e) {
|
||||
return Optional.empty();
|
||||
return Maybe.nothing();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ public abstract class ChunkRegionMixin implements StructureWorldAccess {
|
||||
state = arg.getBlockState();
|
||||
setBlockState(blockPos, state, flags);
|
||||
net.minecraft.world.chunk.Chunk chunk = getChunk(blockPos);
|
||||
NbtCompound nbt = ((NbtCompound) (Object) ((BlockStateExtended) data).getData());
|
||||
NbtCompound nbt = ((NbtCompound) (Object) ((BlockStateExtended) data).data());
|
||||
MinecraftUtil.loadBlockEntity(chunk, world, blockPos, state, nbt);
|
||||
} else {
|
||||
state = (net.minecraft.block.BlockState) data;
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ public abstract class ServerWorldMixin extends World {
|
||||
state = arg.getBlockState();
|
||||
setBlockState(blockPos, state, flags);
|
||||
net.minecraft.world.chunk.Chunk chunk = getWorldChunk(blockPos);
|
||||
((WorldChunkAccessor) chunk).invokeLoadBlockEntity(blockPos, ((NbtCompound) (Object) ((BlockStateExtended) data).getData()));
|
||||
((WorldChunkAccessor) chunk).invokeLoadBlockEntity(blockPos, ((NbtCompound) (Object) ((BlockStateExtended) data).data()));
|
||||
} else {
|
||||
state = (net.minecraft.block.BlockState) data;
|
||||
setBlockState(blockPos, state, flags);
|
||||
|
||||
@@ -103,7 +103,7 @@ public class BiomeUtil {
|
||||
|
||||
public static String createBiomeID(ConfigPack pack, com.dfsek.terra.api.registry.key.RegistryKey biomeID) {
|
||||
return pack.getID()
|
||||
.toLowerCase() + "/" + biomeID.getNamespace().toLowerCase(Locale.ROOT) + "/" + biomeID.getID().toLowerCase(Locale.ROOT);
|
||||
.toLowerCase() + "/" + biomeID.namespace().toLowerCase(Locale.ROOT) + "/" + biomeID.getID().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
public static Map<Identifier, List<Identifier>> getTerraBiomeMap() {
|
||||
|
||||
@@ -80,7 +80,7 @@ public final class MinecraftUtil {
|
||||
}
|
||||
|
||||
public static boolean isCompatibleBlockStateExtended(com.dfsek.terra.api.block.state.BlockState blockState) {
|
||||
return blockState.isExtended() && BlockStateArgument.class.isAssignableFrom(blockState.getClass());
|
||||
return blockState.extended() && BlockStateArgument.class.isAssignableFrom(blockState.getClass());
|
||||
}
|
||||
|
||||
//[Vanilla Copy]
|
||||
@@ -103,7 +103,7 @@ public final class MinecraftUtil {
|
||||
}
|
||||
|
||||
public static boolean isCompatibleEntityTypeExtended(EntityType entityType) {
|
||||
return entityType.isExtended() && MinecraftEntityTypeExtended.class.isAssignableFrom(entityType.getClass());
|
||||
return entityType.extended() && MinecraftEntityTypeExtended.class.isAssignableFrom(entityType.getClass());
|
||||
}
|
||||
|
||||
public static void registerIntProviderTypes() {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class PresetUtil {
|
||||
|
||||
|
||||
Identifier generatorID = Identifier.tryParse(
|
||||
"terra:" + pack.getID().toLowerCase(Locale.ROOT) + "/" + pack.getNamespace().toLowerCase(
|
||||
"terra:" + pack.getID().toLowerCase(Locale.ROOT) + "/" + pack.namespace().toLowerCase(
|
||||
Locale.ROOT));
|
||||
|
||||
PRESETS.add(Pair.of(generatorID, extended));
|
||||
@@ -74,7 +74,7 @@ public class PresetUtil {
|
||||
platform.multiNoiseBiomeSourceParameterListRegistry();
|
||||
|
||||
Identifier generatorID = Identifier.of("terra",
|
||||
metaPack.getID().toLowerCase(Locale.ROOT) + "/" + metaPack.getNamespace().toLowerCase(
|
||||
metaPack.getID().toLowerCase(Locale.ROOT) + "/" + metaPack.namespace().toLowerCase(
|
||||
Locale.ROOT));
|
||||
|
||||
PRESETS.add(Pair.of(generatorID, extended));
|
||||
|
||||
Reference in New Issue
Block a user