From 5dbc2c2895df7294a47ddfa32221121116c6fc32 Mon Sep 17 00:00:00 2001 From: dfsek Date: Tue, 21 Dec 2021 13:09:40 -0700 Subject: [PATCH] implement BlockState with mixin on Fabric --- .../addons/flora/flora/gen/TerraFlora.java | 15 +- .../script/functions/BlockFunction.java | 4 +- .../script/functions/PullFunction.java | 3 +- .../terra/api/block/state/BlockState.java | 20 ++- .../dfsek/terra/api/util/RotationUtil.java | 4 +- .../world/block/data/BukkitBlockState.java | 21 +-- .../terra/fabric/block/FabricBlockState.java | 157 ------------------ .../FabricChunkGeneratorWrapper.java | 6 +- .../fabric/handle/FabricWorldHandle.java | 16 +- .../HandleImplementationMixin.java | 2 + .../implementations/block/BlockMixin.java | 2 +- .../block/{ => entity}/BlockEntityMixin.java | 4 +- .../LootableContainerBlockEntityMixin.java | 4 +- .../MobSpawnerBlockEntityMixin.java | 2 +- .../SignBlockEntityMixin.java | 2 +- .../block/state/BlockStateMixin.java | 92 ++++++++++ .../block/state/PropertyMixin.java | 39 +++++ .../chunk/ChunkRegionMixin.java | 8 +- .../chunk/WorldChunkMixin.java | 8 +- .../chunk/data/ProtoChunkMixin.java | 6 +- .../world/ChunkRegionMixin.java | 12 +- .../world/ServerWorldMixin.java | 6 +- .../terra/fabric/util/FabricAdapter.java | 6 - .../src/main/resources/terra.mixins.json | 10 +- .../terra/sponge/block/SpongeBlockState.java | 8 +- 25 files changed, 204 insertions(+), 253 deletions(-) delete mode 100644 platforms/fabric/src/main/java/com/dfsek/terra/fabric/block/FabricBlockState.java rename platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/{ => entity}/BlockEntityMixin.java (93%) rename platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/{state => entity}/LootableContainerBlockEntityMixin.java (87%) rename platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/{state => entity}/MobSpawnerBlockEntityMixin.java (98%) rename platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/{state => entity}/SignBlockEntityMixin.java (97%) create mode 100644 platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/state/BlockStateMixin.java create mode 100644 platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/state/PropertyMixin.java diff --git a/common/addons/config-flora/src/main/java/com/dfsek/terra/addons/flora/flora/gen/TerraFlora.java b/common/addons/config-flora/src/main/java/com/dfsek/terra/addons/flora/flora/gen/TerraFlora.java index cb64acbc3..9582ba6a1 100644 --- a/common/addons/config-flora/src/main/java/com/dfsek/terra/addons/flora/flora/gen/TerraFlora.java +++ b/common/addons/config-flora/src/main/java/com/dfsek/terra/addons/flora/flora/gen/TerraFlora.java @@ -85,22 +85,23 @@ public class TerraFlora implements Structure { int size = layers.size(); int c = ceiling ? -1 : 1; - EnumSet faces = doRotation ? getFaces(location.mutable().add(0, c, 0).immutable(), world) : EnumSet.noneOf(Direction.class); + EnumSet faces = doRotation ? getFaces(location.mutable().add(0, c, 0).immutable(), world) : EnumSet.noneOf( + Direction.class); if(doRotation && faces.size() == 0) return false; // Don't plant if no faces are valid. for(int i = 0; FastMath.abs(i) < size; i += c) { // Down if ceiling, up if floor int lvl = (FastMath.abs(i)); BlockState data = getStateCollection((ceiling ? lvl : size - lvl - 1)).get(distribution, location.getX(), location.getY(), - location.getZ(), world.getSeed()).clone(); + location.getZ(), world.getSeed()); if(doRotation) { Direction oneFace = new ArrayList<>(faces).get( new Random(location.getX() ^ location.getZ()).nextInt(faces.size())); // Get random face. - data.setIfPresent(Properties.DIRECTION, oneFace.opposite()) - .setIfPresent(Properties.NORTH, faces.contains(Direction.NORTH)) - .setIfPresent(Properties.SOUTH, faces.contains(Direction.SOUTH)) - .setIfPresent(Properties.EAST, faces.contains(Direction.EAST)) - .setIfPresent(Properties.WEST, faces.contains(Direction.WEST)); + data = data.setIfPresent(Properties.DIRECTION, oneFace.opposite()) + .setIfPresent(Properties.NORTH, faces.contains(Direction.NORTH)) + .setIfPresent(Properties.SOUTH, faces.contains(Direction.SOUTH)) + .setIfPresent(Properties.EAST, faces.contains(Direction.EAST)) + .setIfPresent(Properties.WEST, faces.contains(Direction.WEST)); } world.setBlockState(location.mutable().add(0, i + c, 0).immutable(), data, physics); } diff --git a/common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/script/functions/BlockFunction.java b/common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/script/functions/BlockFunction.java index 8f9061d13..dde0c98cb 100644 --- a/common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/script/functions/BlockFunction.java +++ b/common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/script/functions/BlockFunction.java @@ -54,7 +54,7 @@ public class BlockFunction implements Function { @Override public Void apply(ImplementationArguments implementationArguments, Map> variableMap) { TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments; - BlockState rot = getBlockState(implementationArguments, variableMap).clone(); + BlockState rot = getBlockState(implementationArguments, variableMap); setBlock(implementationArguments, variableMap, arguments, rot); return null; } @@ -75,7 +75,7 @@ public class BlockFunction implements Function { z.apply(implementationArguments, variableMap).doubleValue()), arguments.getRotation()); - RotationUtil.rotateBlockData(rot, arguments.getRotation().inverse()); + rot = RotationUtil.rotateBlockData(rot, arguments.getRotation().inverse()); try { Vector3.Mutable set = Vector3.of(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).doubleValue(), diff --git a/common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/script/functions/PullFunction.java b/common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/script/functions/PullFunction.java index b146096f0..e0042ff20 100644 --- a/common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/script/functions/PullFunction.java +++ b/common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/script/functions/PullFunction.java @@ -48,8 +48,7 @@ public class PullFunction implements Function { Vector2 xz = RotationUtil.rotateVector(Vector2.of(x.apply(implementationArguments, variableMap).doubleValue(), z.apply(implementationArguments, variableMap).doubleValue()), arguments.getRotation()); - BlockState rot = data.clone(); - RotationUtil.rotateBlockData(rot, arguments.getRotation().inverse()); + BlockState rot = RotationUtil.rotateBlockData(data, arguments.getRotation().inverse()); Vector3.Mutable mutable = Vector3.of(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).intValue(), FastMath.roundToInt(xz.getZ())).mutable().add(arguments.getOrigin()); diff --git a/common/api/core/src/main/java/com/dfsek/terra/api/block/state/BlockState.java b/common/api/core/src/main/java/com/dfsek/terra/api/block/state/BlockState.java index cdfba3c93..47a286aa9 100644 --- a/common/api/core/src/main/java/com/dfsek/terra/api/block/state/BlockState.java +++ b/common/api/core/src/main/java/com/dfsek/terra/api/block/state/BlockState.java @@ -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(); + > boolean has(Property property); - boolean has(Property property); + > T get(Property property); - T get(Property property); + > BlockState set(Property property, T value); - BlockState set(Property property, T value); - - default BlockState ifProperty(Property property, Consumer action) { + default > BlockState ifProperty(Property property, Consumer action) { if(has(property)) action.accept(this); return this; } - default BlockState setIfPresent(Property property, T value) { + default > BlockState setIfPresent(Property 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(); } diff --git a/common/api/core/src/main/java/com/dfsek/terra/api/util/RotationUtil.java b/common/api/core/src/main/java/com/dfsek/terra/api/util/RotationUtil.java index ddf5255a3..8e69a2804 100644 --- a/common/api/core/src/main/java/com/dfsek/terra/api/util/RotationUtil.java +++ b/common/api/core/src/main/java/com/dfsek/terra/api/util/RotationUtil.java @@ -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))) diff --git a/platforms/bukkit/src/main/java/com/dfsek/terra/bukkit/world/block/data/BukkitBlockState.java b/platforms/bukkit/src/main/java/com/dfsek/terra/bukkit/world/block/data/BukkitBlockState.java index 90d58b10d..f670d4f03 100644 --- a/platforms/bukkit/src/main/java/com/dfsek/terra/bukkit/world/block/data/BukkitBlockState.java +++ b/platforms/bukkit/src/main/java/com/dfsek/terra/bukkit/world/block/data/BukkitBlockState.java @@ -46,17 +46,17 @@ public class BukkitBlockState implements BlockState { } @Override - public boolean has(Property property) { + public > boolean has(Property property) { return false; } @Override - public T get(Property property) { + public > T get(Property property) { return null; } @Override - public BlockState set(Property property, T value) { + public > BlockState set(Property property, T value) { return null; } @@ -66,23 +66,12 @@ public class BukkitBlockState implements BlockState { } @Override - public String getAsString() { - return delegate.getAsString(false); + public String getAsString(boolean properties) { + return delegate.getAsString(!properties); } @Override public boolean isAir() { return delegate.getMaterial().isAir(); } - - @Override - public BukkitBlockState clone() { - try { - BukkitBlockState n = (BukkitBlockState) super.clone(); - n.delegate = delegate.clone(); - return n; - } catch(CloneNotSupportedException e) { - throw new Error(e); - } - } } diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/block/FabricBlockState.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/block/FabricBlockState.java deleted file mode 100644 index 7ac47e46f..000000000 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/block/FabricBlockState.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * This file is part of Terra. - * - * Terra is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Terra is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Terra. If not, see . - */ - -package com.dfsek.terra.fabric.block; - -import net.minecraft.block.enums.BlockHalf; -import net.minecraft.block.enums.RailShape; -import net.minecraft.block.enums.WallShape; -import net.minecraft.block.enums.WireConnection; -import net.minecraft.util.math.Direction; -import net.minecraft.util.registry.Registry; - -import java.util.HashMap; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; - -import com.dfsek.terra.api.block.BlockType; -import com.dfsek.terra.api.block.state.BlockState; -import com.dfsek.terra.api.block.state.properties.Property; -import com.dfsek.terra.api.block.state.properties.base.Properties; -import com.dfsek.terra.api.util.generic.Construct; -import com.dfsek.terra.api.util.generic.pair.Pair; -import com.dfsek.terra.fabric.mixin.access.StateAccessor; -import com.dfsek.terra.fabric.util.FabricAdapter; - - -public class FabricBlockState implements BlockState { - private static final Map, Pair, Function>> - PROPERTY_DELEGATES_T2M = Construct.construct(() -> { - Map, Pair, Function>> map = new HashMap<>(); - map.put(Properties.AXIS, Pair.of(net.minecraft.state.property.Properties.AXIS, - a -> FabricAdapter.adapt((net.minecraft.util.math.Direction.Axis) a))); - - map.put(Properties.NORTH, Pair.of(net.minecraft.state.property.Properties.NORTH, Function.identity())); - map.put(Properties.SOUTH, Pair.of(net.minecraft.state.property.Properties.SOUTH, Function.identity())); - map.put(Properties.EAST, Pair.of(net.minecraft.state.property.Properties.EAST, Function.identity())); - map.put(Properties.WEST, Pair.of(net.minecraft.state.property.Properties.WEST, Function.identity())); - - map.put(Properties.NORTH_CONNECTION, Pair.of(net.minecraft.state.property.Properties.NORTH_WIRE_CONNECTION, - c -> FabricAdapter.adapt((WireConnection) c))); - map.put(Properties.SOUTH_CONNECTION, Pair.of(net.minecraft.state.property.Properties.SOUTH_WIRE_CONNECTION, - c -> FabricAdapter.adapt((WireConnection) c))); - map.put(Properties.EAST_CONNECTION, Pair.of(net.minecraft.state.property.Properties.EAST_WIRE_CONNECTION, - c -> FabricAdapter.adapt((WireConnection) c))); - map.put(Properties.WEST_CONNECTION, Pair.of(net.minecraft.state.property.Properties.WEST_WIRE_CONNECTION, - c -> FabricAdapter.adapt((WireConnection) c))); - - - map.put(Properties.NORTH_HEIGHT, - Pair.of(net.minecraft.state.property.Properties.NORTH_WALL_SHAPE, h -> FabricAdapter.adapt((WallShape) h))); - map.put(Properties.SOUTH_HEIGHT, - Pair.of(net.minecraft.state.property.Properties.SOUTH_WALL_SHAPE, h -> FabricAdapter.adapt((WallShape) h))); - map.put(Properties.EAST_HEIGHT, - Pair.of(net.minecraft.state.property.Properties.EAST_WALL_SHAPE, h -> FabricAdapter.adapt((WallShape) h))); - map.put(Properties.WEST_HEIGHT, - Pair.of(net.minecraft.state.property.Properties.WEST_WALL_SHAPE, h -> FabricAdapter.adapt((WallShape) h))); - - map.put(Properties.DIRECTION, - Pair.of(net.minecraft.state.property.Properties.FACING, d -> FabricAdapter.adapt((Direction) d))); - - map.put(Properties.WATERLOGGED, Pair.of(net.minecraft.state.property.Properties.WATERLOGGED, Function.identity())); - - map.put(Properties.RAIL_SHAPE, - Pair.of(net.minecraft.state.property.Properties.RAIL_SHAPE, s -> FabricAdapter.adapt((RailShape) s))); - - map.put(Properties.HALF, - Pair.of(net.minecraft.state.property.Properties.BLOCK_HALF, h -> FabricAdapter.adapt((BlockHalf) h))); - - return map; - }); - - private static final Map, Property> PROPERTY_DELEGATES_M2T = Construct.construct(() -> { - Map, Property> map = new HashMap<>(); - PROPERTY_DELEGATES_T2M.forEach((p, p2) -> map.put(p2.getLeft(), p)); - return map; - }); - - protected net.minecraft.block.BlockState delegate; - - public FabricBlockState(net.minecraft.block.BlockState delegate) { - this.delegate = delegate; - } - - @Override - public boolean matches(BlockState other) { - return delegate.getBlock() == ((FabricBlockState) other).delegate.getBlock(); - } - - @Override - public boolean has(Property property) { - return delegate.getProperties().contains(PROPERTY_DELEGATES_T2M.get(property).getLeft()); - } - - @SuppressWarnings("unchecked") - @Override - public T get(Property property) { - Pair, Function> pair = PROPERTY_DELEGATES_T2M.get(property); - return (T) pair.getRight().apply(delegate.get(pair.getLeft())); - } - - @Override - public BlockState set(Property property, T value) { - //return delegate = delegate.with(PROPERTY_DELEGATES_T2M.get(property), v); - return this; - } - - @Override - public BlockType getBlockType() { - return (BlockType) delegate.getBlock(); - } - - @Override - public String getAsString() { - StringBuilder data = new StringBuilder(Registry.BLOCK.getId(delegate.getBlock()).toString()); - if(!delegate.getEntries().isEmpty()) { - data.append('['); - data.append( - delegate.getEntries().entrySet().stream().map(StateAccessor.getPropertyMapPrinter()).collect(Collectors.joining(","))); - data.append(']'); - } - return data.toString(); - } - - @Override - public boolean isAir() { - return delegate.isAir(); - } - - @Override - public BlockState clone() { - try { - return (FabricBlockState) super.clone(); - } catch(CloneNotSupportedException e) { - throw new Error(e); - } - } - - @Override - public net.minecraft.block.BlockState getHandle() { - return delegate; - } -} diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/generation/FabricChunkGeneratorWrapper.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/generation/FabricChunkGeneratorWrapper.java index 707be7ae1..3c4e8eead 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/generation/FabricChunkGeneratorWrapper.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/generation/FabricChunkGeneratorWrapper.java @@ -25,7 +25,6 @@ import com.dfsek.terra.api.world.chunk.generation.ProtoWorld; import com.dfsek.terra.api.world.chunk.generation.stage.Chunkified; import com.dfsek.terra.api.world.chunk.generation.util.GeneratorWrapper; import com.dfsek.terra.fabric.FabricEntryPoint; -import com.dfsek.terra.fabric.block.FabricBlockState; import com.dfsek.terra.fabric.mixin.access.StructureAccessorAccessor; import com.mojang.serialization.Codec; @@ -207,7 +206,7 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C public int getHeight(int x, int z, Heightmap.Type heightmap, HeightLimitView heightmapType) { int height = ((ServerWorld) world).getMaxHeight(); while(height >= ((ServerWorld) world).getMinHeight() && !heightmap.getBlockPredicate().test( - ((FabricBlockState) ((ServerWorld) world).getGenerator().getBlock((ServerWorld) world, x, height - 1, z)).getHandle())) { + (BlockState) ((ServerWorld) world).getGenerator().getBlock((ServerWorld) world, x, height - 1, z))) { height--; } return height; @@ -217,8 +216,7 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C public VerticalBlockSample getColumnSample(int x, int z, HeightLimitView view) { BlockState[] array = new BlockState[view.getHeight()]; for(int y = view.getTopY() - 1; y >= view.getBottomY(); y--) { - array[y - view.getBottomY()] = ((FabricBlockState) ((ServerWorld) world).getGenerator().getBlock((ServerWorld) world, x, y, - z)).getHandle(); + array[y - view.getBottomY()] = (BlockState) ((ServerWorld) world).getGenerator().getBlock((ServerWorld) world, x, y, z); } return new VerticalBlockSample(view.getBottomY(), array); } diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/handle/FabricWorldHandle.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/handle/FabricWorldHandle.java index 95d5164cf..0d4c07ade 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/handle/FabricWorldHandle.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/handle/FabricWorldHandle.java @@ -17,9 +17,11 @@ package com.dfsek.terra.fabric.handle; +import com.dfsek.terra.api.block.state.BlockState; + import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import net.minecraft.block.BlockState; + import net.minecraft.block.Blocks; import net.minecraft.command.argument.BlockArgumentParser; import net.minecraft.util.Identifier; @@ -28,28 +30,27 @@ import org.jetbrains.annotations.NotNull; import com.dfsek.terra.api.entity.EntityType; import com.dfsek.terra.api.handle.WorldHandle; -import com.dfsek.terra.fabric.block.FabricBlockState; import com.dfsek.terra.fabric.util.FabricAdapter; public class FabricWorldHandle implements WorldHandle { - private static final com.dfsek.terra.api.block.state.BlockState AIR = FabricAdapter.adapt(Blocks.AIR.getDefaultState()); + private static final BlockState AIR = (BlockState) Blocks.AIR.getDefaultState(); @Override - public @NotNull FabricBlockState createBlockState(@NotNull String data) { + public @NotNull BlockState createBlockState(@NotNull String data) { BlockArgumentParser parser = new BlockArgumentParser(new StringReader(data), true); try { - BlockState state = parser.parse(true).getBlockState(); + net.minecraft.block.BlockState state = parser.parse(true).getBlockState(); if(state == null) throw new IllegalArgumentException("Invalid data: " + data); - return FabricAdapter.adapt(state); + return (BlockState) state; } catch(CommandSyntaxException e) { throw new IllegalArgumentException(e); } } @Override - public com.dfsek.terra.api.block.state.@NotNull BlockState air() { + public @NotNull BlockState air() { return AIR; } @@ -59,5 +60,4 @@ public class FabricWorldHandle implements WorldHandle { if(identifier == null) identifier = Identifier.tryParse(id); return (EntityType) Registry.ENTITY_TYPE.get(identifier); } - } diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/HandleImplementationMixin.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/HandleImplementationMixin.java index 394e56201..0b3e71440 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/HandleImplementationMixin.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/HandleImplementationMixin.java @@ -3,6 +3,7 @@ package com.dfsek.terra.fabric.mixin.implementations; import com.dfsek.terra.api.Handle; import net.minecraft.block.Block; +import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.LockableContainerBlockEntity; import net.minecraft.block.entity.LootableContainerBlockEntity; @@ -31,6 +32,7 @@ import org.spongepowered.asm.mixin.Mixin; ChunkRegion.class, Block.class, + BlockState.class, BlockEntity.class, LootableContainerBlockEntity.class, diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/BlockMixin.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/BlockMixin.java index 5e746dd83..98879d9c5 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/BlockMixin.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/BlockMixin.java @@ -34,7 +34,7 @@ import com.dfsek.terra.fabric.util.FabricAdapter; @Implements(@Interface(iface = BlockType.class, prefix = "terra$", remap = Interface.Remap.NONE)) public abstract class BlockMixin { public com.dfsek.terra.api.block.state.BlockState terra$getDefaultState() { - return FabricAdapter.adapt(((Block) (Object) this).getDefaultState()); + return (com.dfsek.terra.api.block.state.BlockState) ((Block) (Object) this).getDefaultState(); } public boolean terra$isSolid() { diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/BlockEntityMixin.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/entity/BlockEntityMixin.java similarity index 93% rename from platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/BlockEntityMixin.java rename to platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/entity/BlockEntityMixin.java index 1d66412f1..5c00b08c6 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/BlockEntityMixin.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/entity/BlockEntityMixin.java @@ -15,7 +15,7 @@ * along with Terra. If not, see . */ -package com.dfsek.terra.fabric.mixin.implementations.block; +package com.dfsek.terra.fabric.mixin.implementations.block.entity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -54,6 +54,6 @@ public abstract class BlockEntityMixin { } public BlockState terra$getBlockState() { - return FabricAdapter.adapt(((net.minecraft.block.entity.BlockEntity) (Object) this).getCachedState()); + return (BlockState) ((net.minecraft.block.entity.BlockEntity) (Object) this).getCachedState(); } } diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/state/LootableContainerBlockEntityMixin.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/entity/LootableContainerBlockEntityMixin.java similarity index 87% rename from platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/state/LootableContainerBlockEntityMixin.java rename to platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/entity/LootableContainerBlockEntityMixin.java index 5964ce9ed..4752b8ded 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/state/LootableContainerBlockEntityMixin.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/entity/LootableContainerBlockEntityMixin.java @@ -15,17 +15,15 @@ * along with Terra. If not, see . */ -package com.dfsek.terra.fabric.mixin.implementations.block.state; +package com.dfsek.terra.fabric.mixin.implementations.block.entity; import net.minecraft.block.entity.LootableContainerBlockEntity; import org.spongepowered.asm.mixin.Implements; import org.spongepowered.asm.mixin.Interface; -import org.spongepowered.asm.mixin.Intrinsic; import org.spongepowered.asm.mixin.Mixin; import com.dfsek.terra.api.block.entity.Container; import com.dfsek.terra.api.inventory.Inventory; -import com.dfsek.terra.fabric.mixin.implementations.block.BlockEntityMixin; @Mixin(LootableContainerBlockEntity.class) diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/state/MobSpawnerBlockEntityMixin.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/entity/MobSpawnerBlockEntityMixin.java similarity index 98% rename from platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/state/MobSpawnerBlockEntityMixin.java rename to platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/entity/MobSpawnerBlockEntityMixin.java index 4e260f0bf..34ae9ea0d 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/state/MobSpawnerBlockEntityMixin.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/entity/MobSpawnerBlockEntityMixin.java @@ -15,7 +15,7 @@ * along with Terra. If not, see . */ -package com.dfsek.terra.fabric.mixin.implementations.block.state; +package com.dfsek.terra.fabric.mixin.implementations.block.entity; import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/state/SignBlockEntityMixin.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/entity/SignBlockEntityMixin.java similarity index 97% rename from platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/state/SignBlockEntityMixin.java rename to platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/entity/SignBlockEntityMixin.java index 07eeffe49..efd755006 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/state/SignBlockEntityMixin.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/entity/SignBlockEntityMixin.java @@ -15,7 +15,7 @@ * along with Terra. If not, see . */ -package com.dfsek.terra.fabric.mixin.implementations.block.state; +package com.dfsek.terra.fabric.mixin.implementations.block.entity; import net.minecraft.block.entity.SignBlockEntity; import net.minecraft.text.LiteralText; diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/state/BlockStateMixin.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/state/BlockStateMixin.java new file mode 100644 index 000000000..f690200ad --- /dev/null +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/state/BlockStateMixin.java @@ -0,0 +1,92 @@ +package com.dfsek.terra.fabric.mixin.implementations.block.state; + + + +import com.dfsek.terra.api.block.BlockType; +import com.dfsek.terra.api.block.state.BlockState; + +import com.dfsek.terra.api.block.state.properties.Property; + +import com.dfsek.terra.fabric.mixin.access.StateAccessor; + +import com.google.common.collect.ImmutableMap; +import com.mojang.serialization.MapCodec; +import net.minecraft.block.AbstractBlock.AbstractBlockState; +import net.minecraft.block.Block; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.state.State; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.registry.Registry; +import org.spongepowered.asm.mixin.Implements; +import org.spongepowered.asm.mixin.Interface; +import org.spongepowered.asm.mixin.Intrinsic; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +import java.util.Random; +import java.util.stream.Collectors; + + +@Mixin(AbstractBlockState.class) +@Implements(@Interface(iface = BlockState.class, prefix = "terra$", remap = Interface.Remap.NONE)) +public abstract class BlockStateMixin extends State { + private BlockStateMixin(Block owner, ImmutableMap, Comparable> entries, + MapCodec codec) { + super(owner, entries, codec); + } + + @Shadow + public abstract Block getBlock(); + + @Shadow + public abstract boolean isAir(); + + @Shadow + public abstract void randomTick(ServerWorld world, BlockPos pos, Random random); + + public boolean terra$matches(BlockState other) { + return getBlock() == ((net.minecraft.block.BlockState) other).getBlock(); + } + + @Intrinsic + public > boolean terra$has(Property property) { + if(property instanceof net.minecraft.state.property.Property minecraftProperty) { + return contains(minecraftProperty); + } + return false; + } + + @SuppressWarnings("unchecked") + @Intrinsic + public > T terra$get(Property property) { + return get((net.minecraft.state.property.Property) property); + } + + @SuppressWarnings("unchecked") + @Intrinsic + public > BlockState terra$set(Property property, T value) { + return (BlockState) with((net.minecraft.state.property.Property) property, value); + } + + @Intrinsic + public BlockType terra$getBlockType() { + return (BlockType) getBlock(); + } + + @Intrinsic + public String terra$getAsString(boolean properties) { + StringBuilder data = new StringBuilder(Registry.BLOCK.getId(getBlock()).toString()); + if(properties && !getEntries().isEmpty()) { + data.append('['); + data.append( + getEntries().entrySet().stream().map(StateAccessor.getPropertyMapPrinter()).collect(Collectors.joining(","))); + data.append(']'); + } + return data.toString(); + } + + @Intrinsic + public boolean terra$isAir() { + return isAir(); + } +} diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/state/PropertyMixin.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/state/PropertyMixin.java new file mode 100644 index 000000000..64d34be12 --- /dev/null +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/block/state/PropertyMixin.java @@ -0,0 +1,39 @@ +package com.dfsek.terra.fabric.mixin.implementations.block.state; + +import com.dfsek.terra.api.block.state.properties.Property; + +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +import java.util.Collection; + + +@Mixin(net.minecraft.state.property.Property.class) +public abstract class PropertyMixin implements Property { + @Shadow + @Final + private Class type; + + @Shadow + public abstract Collection getValues(); + + @Shadow + @Final + private String name; + + @Override + public Collection values() { + return getValues(); + } + + @Override + public Class getType() { + return type; + } + + @Override + public String getName() { + return name; + } +} diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/chunk/ChunkRegionMixin.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/chunk/ChunkRegionMixin.java index 11821765b..a26334ac8 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/chunk/ChunkRegionMixin.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/chunk/ChunkRegionMixin.java @@ -28,7 +28,6 @@ import org.spongepowered.asm.mixin.Shadow; import com.dfsek.terra.api.block.state.BlockState; import com.dfsek.terra.api.world.chunk.Chunk; -import com.dfsek.terra.fabric.block.FabricBlockState; @Mixin(ChunkRegion.class) @@ -41,13 +40,12 @@ public abstract class ChunkRegionMixin { public void terraChunk$setBlock(int x, int y, int z, @NotNull BlockState blockState, boolean physics) { ((ChunkRegion) (Object) this).setBlockState(new BlockPos(x + (centerPos.getPos().x << 4), y, z + (centerPos.getPos().z << 4)), - ((FabricBlockState) blockState).getHandle(), 0); + (net.minecraft.block.BlockState) blockState, 0); } public @NotNull BlockState terraChunk$getBlock(int x, int y, int z) { - return new FabricBlockState( - ((ChunkRegion) (Object) this).getBlockState( - new BlockPos(x + (centerPos.getPos().x << 4), y, z + (centerPos.getPos().z << 4)))); + return (BlockState) ((ChunkRegion) (Object) this).getBlockState( + new BlockPos(x + (centerPos.getPos().x << 4), y, z + (centerPos.getPos().z << 4))); } public int terraChunk$getX() { diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/chunk/WorldChunkMixin.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/chunk/WorldChunkMixin.java index 256cd20a8..9e6d921e8 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/chunk/WorldChunkMixin.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/chunk/WorldChunkMixin.java @@ -31,7 +31,6 @@ import org.spongepowered.asm.mixin.Shadow; import com.dfsek.terra.api.block.state.BlockState; import com.dfsek.terra.api.world.ServerWorld; import com.dfsek.terra.api.world.chunk.Chunk; -import com.dfsek.terra.fabric.block.FabricBlockState; @Mixin(WorldChunk.class) @@ -49,16 +48,17 @@ public abstract class WorldChunkMixin { public abstract net.minecraft.block.BlockState setBlockState(BlockPos pos, net.minecraft.block.BlockState state, boolean moved); public void terra$setBlock(int x, int y, int z, BlockState data, boolean physics) { - setBlockState(new BlockPos(x, y, z), ((FabricBlockState) data).getHandle(), false); + setBlockState(new BlockPos(x, y, z), (net.minecraft.block.BlockState) data, false); } public void terra$setBlock(int x, int y, int z, @NotNull BlockState blockState) { - ((net.minecraft.world.chunk.Chunk) (Object) this).setBlockState(new BlockPos(x, y, z), ((FabricBlockState) blockState).getHandle(), + ((net.minecraft.world.chunk.Chunk) (Object) this).setBlockState(new BlockPos(x, y, z), (net.minecraft.block.BlockState) blockState, false); } + @Intrinsic public @NotNull BlockState terra$getBlock(int x, int y, int z) { - return new FabricBlockState(getBlockState(new BlockPos(x, y, z))); + return (BlockState) getBlockState(new BlockPos(x, y, z)); } public int terra$getX() { diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/chunk/data/ProtoChunkMixin.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/chunk/data/ProtoChunkMixin.java index a80e048e3..f46bea874 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/chunk/data/ProtoChunkMixin.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/chunk/data/ProtoChunkMixin.java @@ -21,13 +21,11 @@ import net.minecraft.util.math.BlockPos; import org.jetbrains.annotations.NotNull; import org.spongepowered.asm.mixin.Implements; import org.spongepowered.asm.mixin.Interface; -import org.spongepowered.asm.mixin.Intrinsic; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import com.dfsek.terra.api.block.state.BlockState; import com.dfsek.terra.api.world.chunk.generation.ProtoChunk; -import com.dfsek.terra.fabric.block.FabricBlockState; @Mixin(net.minecraft.world.chunk.ProtoChunk.class) @@ -37,12 +35,12 @@ public abstract class ProtoChunkMixin { public abstract net.minecraft.block.BlockState getBlockState(BlockPos pos); public void terra$setBlock(int x, int y, int z, @NotNull BlockState blockState) { - ((net.minecraft.world.chunk.Chunk) (Object) this).setBlockState(new BlockPos(x, y, z), ((FabricBlockState) blockState).getHandle(), + ((net.minecraft.world.chunk.Chunk) (Object) this).setBlockState(new BlockPos(x, y, z), (net.minecraft.block.BlockState) blockState, false); } public @NotNull BlockState terra$getBlock(int x, int y, int z) { - return new FabricBlockState(getBlockState(new BlockPos(x, y, z))); + return (BlockState) getBlockState(new BlockPos(x, y, z)); } public int terra$getMaxHeight() { diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/world/ChunkRegionMixin.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/world/ChunkRegionMixin.java index 139bb1ee2..b6da02518 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/world/ChunkRegionMixin.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/world/ChunkRegionMixin.java @@ -21,7 +21,6 @@ import net.minecraft.block.FluidBlock; import net.minecraft.fluid.Fluid; import net.minecraft.util.math.BlockPos; import net.minecraft.world.ChunkRegion; -import net.minecraft.world.ServerWorldAccess; import net.minecraft.world.WorldAccess; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.ChunkStatus; @@ -49,7 +48,6 @@ import com.dfsek.terra.api.world.ServerWorld; import com.dfsek.terra.api.world.biome.generation.BiomeProvider; import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator; import com.dfsek.terra.api.world.chunk.generation.ProtoWorld; -import com.dfsek.terra.fabric.block.FabricBlockState; import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper; import com.dfsek.terra.fabric.generation.TerraBiomeSource; import com.dfsek.terra.fabric.util.FabricUtil; @@ -94,11 +92,11 @@ public abstract class ChunkRegionMixin { @Intrinsic(displace = true) public void terraWorld$setBlockState(int x, int y, int z, BlockState data, boolean physics) { BlockPos pos = new BlockPos(x, y, z); - ((ChunkRegion) (Object) this).setBlockState(pos, ((FabricBlockState) data).getHandle(), physics ? 3 : 1042); - if(physics && ((FabricBlockState) data).getHandle().getBlock() instanceof FluidBlock) { + ((ChunkRegion) (Object) this).setBlockState(pos, (net.minecraft.block.BlockState) data, physics ? 3 : 1042); + if(physics && ((net.minecraft.block.BlockState) data).getBlock() instanceof FluidBlock) { getFluidTickScheduler().scheduleTick( - OrderedTick.create(((FluidBlock) ((FabricBlockState) data).getHandle().getBlock()).getFluidState( - ((FabricBlockState) data).getHandle()).getFluid(), pos)); + OrderedTick.create(((FluidBlock) ((net.minecraft.block.BlockState) data).getBlock()).getFluidState( + (net.minecraft.block.BlockState) data).getFluid(), pos)); } } @@ -114,7 +112,7 @@ public abstract class ChunkRegionMixin { @Intrinsic(displace = true) public BlockState terraWorld$getBlockState(int x, int y, int z) { BlockPos pos = new BlockPos(x, y, z); - return new FabricBlockState(((ChunkRegion) (Object) this).getBlockState(pos)); + return (BlockState) ((ChunkRegion) (Object) this).getBlockState(pos); } public BlockEntity terraWorld$getBlockEntity(int x, int y, int z) { diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/world/ServerWorldMixin.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/world/ServerWorldMixin.java index b219d6d9e..e7706f52c 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/world/ServerWorldMixin.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/implementations/world/ServerWorldMixin.java @@ -22,7 +22,6 @@ import net.minecraft.server.WorldGenerationProgressListener; import net.minecraft.server.world.ServerChunkManager; import net.minecraft.util.math.BlockPos; import net.minecraft.util.registry.RegistryKey; -import net.minecraft.world.ServerWorldAccess; import net.minecraft.world.WorldAccess; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.gen.Spawner; @@ -51,7 +50,6 @@ import com.dfsek.terra.api.world.ServerWorld; import com.dfsek.terra.api.world.biome.generation.BiomeProvider; import com.dfsek.terra.api.world.chunk.Chunk; import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator; -import com.dfsek.terra.fabric.block.FabricBlockState; import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper; import com.dfsek.terra.fabric.generation.TerraBiomeSource; import com.dfsek.terra.fabric.util.FabricUtil; @@ -94,7 +92,7 @@ public abstract class ServerWorldMixin { public void terra$setBlockState(int x, int y, int z, BlockState data, boolean physics) { BlockPos pos = new BlockPos(x, y, z); - ((net.minecraft.server.world.ServerWorld) (Object) this).setBlockState(pos, ((FabricBlockState) data).getHandle(), + ((net.minecraft.server.world.ServerWorld) (Object) this).setBlockState(pos, (net.minecraft.block.BlockState) data, physics ? 3 : 1042); } @@ -113,7 +111,7 @@ public abstract class ServerWorldMixin { } public BlockState terra$getBlockState(int x, int y, int z) { - return new FabricBlockState(((net.minecraft.server.world.ServerWorld) (Object) this).getBlockState(new BlockPos(x, y, z))); + return (BlockState) ((net.minecraft.server.world.ServerWorld) (Object) this).getBlockState(new BlockPos(x, y, z)); } public BlockEntity terra$getBlockEntity(int x, int y, int z) { diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/util/FabricAdapter.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/util/FabricAdapter.java index c951655b0..6f732ff16 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/util/FabricAdapter.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/util/FabricAdapter.java @@ -17,7 +17,6 @@ package com.dfsek.terra.fabric.util; -import net.minecraft.block.BlockState; import net.minecraft.block.enums.BlockHalf; import net.minecraft.block.enums.WallShape; import net.minecraft.block.enums.WireConnection; @@ -30,7 +29,6 @@ import com.dfsek.terra.api.block.state.properties.enums.RailShape; import com.dfsek.terra.api.block.state.properties.enums.RedstoneConnection; import com.dfsek.terra.api.block.state.properties.enums.WallHeight; import com.dfsek.terra.api.util.vector.Vector3; -import com.dfsek.terra.fabric.block.FabricBlockState; public final class FabricAdapter { @@ -42,10 +40,6 @@ public final class FabricAdapter { return Vector3.of(pos.getX(), pos.getY(), pos.getZ()); } - public static FabricBlockState adapt(BlockState state) { - return new FabricBlockState(state); - } - public static Direction adapt(com.dfsek.terra.api.block.state.properties.enums.Direction direction) { return switch(direction) { case SOUTH -> Direction.SOUTH; diff --git a/platforms/fabric/src/main/resources/terra.mixins.json b/platforms/fabric/src/main/resources/terra.mixins.json index 75351cea3..d84ed267b 100644 --- a/platforms/fabric/src/main/resources/terra.mixins.json +++ b/platforms/fabric/src/main/resources/terra.mixins.json @@ -12,11 +12,13 @@ "access.StructureAccessorAccessor", "implementations.BiomeMixin", "implementations.HandleImplementationMixin", - "implementations.block.BlockEntityMixin", "implementations.block.BlockMixin", - "implementations.block.state.LootableContainerBlockEntityMixin", - "implementations.block.state.MobSpawnerBlockEntityMixin", - "implementations.block.state.SignBlockEntityMixin", + "implementations.block.entity.BlockEntityMixin", + "implementations.block.entity.LootableContainerBlockEntityMixin", + "implementations.block.entity.MobSpawnerBlockEntityMixin", + "implementations.block.entity.SignBlockEntityMixin", + "implementations.block.state.BlockStateMixin", + "implementations.block.state.PropertyMixin", "implementations.chunk.ChunkRegionMixin", "implementations.chunk.WorldChunkMixin", "implementations.chunk.data.ProtoChunkMixin", diff --git a/platforms/sponge/src/main/java/com/dfsek/terra/sponge/block/SpongeBlockState.java b/platforms/sponge/src/main/java/com/dfsek/terra/sponge/block/SpongeBlockState.java index 5181d8504..dbf1f8500 100644 --- a/platforms/sponge/src/main/java/com/dfsek/terra/sponge/block/SpongeBlockState.java +++ b/platforms/sponge/src/main/java/com/dfsek/terra/sponge/block/SpongeBlockState.java @@ -42,17 +42,17 @@ public class SpongeBlockState implements BlockState { } @Override - public boolean has(Property property) { + public > boolean has(Property property) { return false; } @Override - public T get(Property property) { + public > T get(Property property) { return null; } @Override - public BlockState set(Property property, T value) { + public > BlockState set(Property property, T value) { return this; } @@ -62,7 +62,7 @@ public class SpongeBlockState implements BlockState { } @Override - public String getAsString() { + public String getAsString(boolean verbose) { return delegate.toString(); }