diff --git a/build.gradle b/build.gradle index bfceca683..4095a0e19 100755 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,9 @@ apply from: "https://raw.githubusercontent.com/refinedmods/refinedarchitect/v0.7.1/helper.gradle" +ext { + forgeVersion = "47.1.0" +} + repositories { maven { name = 'JEI' @@ -38,10 +42,7 @@ dependencies { compileOnly fg.deobf('curse.maven:crafting-tweaks-233071:4596466') - // TODO mixin issue - // runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:5.2.0-beta.3+1.20.1") - // can't depend on API due to Javadoc build error (CuriosApi imports stuff from common) - compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:5.2.0-beta.3+1.20.1") + implementation fg.deobf("top.theillusivec4.curios:curios-forge:5.2.0-beta.3+1.20.1") } minecraft { diff --git a/src/main/java/com/refinedmods/refinedstorage/block/CableBlock.java b/src/main/java/com/refinedmods/refinedstorage/block/CableBlock.java index 3ee9af354..21e6cd3a5 100644 --- a/src/main/java/com/refinedmods/refinedstorage/block/CableBlock.java +++ b/src/main/java/com/refinedmods/refinedstorage/block/CableBlock.java @@ -122,6 +122,7 @@ public class CableBlock extends NetworkNodeBlock implements SimpleWaterloggedBlo } @Override + @SuppressWarnings("deprecation") public boolean isPathfindable(BlockState state, BlockGetter worldIn, BlockPos pos, PathComputationType type) { return false; } @@ -197,8 +198,8 @@ public class CableBlock extends NetworkNodeBlock implements SimpleWaterloggedBlo } return blockEntity.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY, direction).isPresent() - && !isSideCovered(blockEntity, direction) - && !isSideCovered(world.getBlockEntity(pos.relative(direction)), direction.getOpposite()); + && !isSideCovered(blockEntity, direction) + && !isSideCovered(world.getBlockEntity(pos.relative(direction)), direction.getOpposite()); } private boolean isSideCovered(BlockEntity blockEntity, Direction direction) { @@ -229,12 +230,12 @@ public class CableBlock extends NetworkNodeBlock implements SimpleWaterloggedBlo boolean down = hasNodeConnection(world, pos.relative(Direction.DOWN), currentState, Direction.UP); return currentState - .setValue(NORTH, north) - .setValue(EAST, east) - .setValue(SOUTH, south) - .setValue(WEST, west) - .setValue(UP, up) - .setValue(DOWN, down); + .setValue(NORTH, north) + .setValue(EAST, east) + .setValue(SOUTH, south) + .setValue(WEST, west) + .setValue(UP, up) + .setValue(DOWN, down); } @Override diff --git a/src/main/java/com/refinedmods/refinedstorage/blockentity/CableBlockEntity.java b/src/main/java/com/refinedmods/refinedstorage/blockentity/CableBlockEntity.java index ce943c4a0..cbd13e6ed 100644 --- a/src/main/java/com/refinedmods/refinedstorage/blockentity/CableBlockEntity.java +++ b/src/main/java/com/refinedmods/refinedstorage/blockentity/CableBlockEntity.java @@ -27,7 +27,7 @@ public class CableBlockEntity extends NetworkNodeBlockEntity { .build(); public CableBlockEntity(BlockPos pos, BlockState state) { - super(RSBlockEntities.CABLE.get(), pos, state, SPEC); + super(RSBlockEntities.CABLE.get(), pos, state, SPEC, CableNetworkNode.class); } @Override diff --git a/src/main/java/com/refinedmods/refinedstorage/blockentity/ConstructorBlockEntity.java b/src/main/java/com/refinedmods/refinedstorage/blockentity/ConstructorBlockEntity.java index ab230dc1f..b673dd6e2 100644 --- a/src/main/java/com/refinedmods/refinedstorage/blockentity/ConstructorBlockEntity.java +++ b/src/main/java/com/refinedmods/refinedstorage/blockentity/ConstructorBlockEntity.java @@ -42,7 +42,7 @@ public class ConstructorBlockEntity extends NetworkNodeBlockEntity patternsCapability = LazyOptional.of(() -> getNode().getPatternInventory()); public CrafterBlockEntity(BlockPos pos, BlockState state) { - super(RSBlockEntities.CRAFTER.get(), pos, state, SPEC); + super(RSBlockEntities.CRAFTER.get(), pos, state, SPEC, CrafterNetworkNode.class); } @Override diff --git a/src/main/java/com/refinedmods/refinedstorage/blockentity/CrafterManagerBlockEntity.java b/src/main/java/com/refinedmods/refinedstorage/blockentity/CrafterManagerBlockEntity.java index 32bfa5d21..a95edd6c2 100644 --- a/src/main/java/com/refinedmods/refinedstorage/blockentity/CrafterManagerBlockEntity.java +++ b/src/main/java/com/refinedmods/refinedstorage/blockentity/CrafterManagerBlockEntity.java @@ -35,7 +35,7 @@ public class CrafterManagerBlockEntity extends NetworkNodeBlockEntity TANK_OUT = new BlockEntitySynchronizationParameter<>(new ResourceLocation(RS.ID, "fluid_interface_out"), RSSerializers.FLUID_STACK_SERIALIZER, FluidStack.EMPTY, t -> t.getNode().getTankOut().getFluid()); public static BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder() - .addWatchedParameter(REDSTONE_MODE) - .addParameter(TANK_IN) - .addParameter(TANK_OUT) - .build(); + .addWatchedParameter(REDSTONE_MODE) + .addParameter(TANK_IN) + .addParameter(TANK_OUT) + .build(); private final LazyOptional tankCapability = LazyOptional.of(() -> getNode().getTank()); private final LazyOptional inCapability = LazyOptional.of(() -> getNode().getIn()); public FluidInterfaceBlockEntity(BlockPos pos, BlockState state) { - super(RSBlockEntities.FLUID_INTERFACE.get(), pos, state, SPEC); + super(RSBlockEntities.FLUID_INTERFACE.get(), pos, state, SPEC, FluidInterfaceNetworkNode.class); } @Nonnull diff --git a/src/main/java/com/refinedmods/refinedstorage/blockentity/FluidStorageBlockEntity.java b/src/main/java/com/refinedmods/refinedstorage/blockentity/FluidStorageBlockEntity.java index 6aff898b4..4f8ab6dab 100644 --- a/src/main/java/com/refinedmods/refinedstorage/blockentity/FluidStorageBlockEntity.java +++ b/src/main/java/com/refinedmods/refinedstorage/blockentity/FluidStorageBlockEntity.java @@ -39,7 +39,7 @@ public class FluidStorageBlockEntity extends NetworkNodeBlockEntity itemsCapability = LazyOptional.of(() -> getNode().getItems()); public InterfaceBlockEntity(BlockPos pos, BlockState state) { - super(RSBlockEntities.INTERFACE.get(), pos, state, SPEC); + super(RSBlockEntities.INTERFACE.get(), pos, state, SPEC, InterfaceNetworkNode.class); } @Nonnull diff --git a/src/main/java/com/refinedmods/refinedstorage/blockentity/NetworkNodeBlockEntity.java b/src/main/java/com/refinedmods/refinedstorage/blockentity/NetworkNodeBlockEntity.java index ae1dbe24a..f37e4a9c5 100644 --- a/src/main/java/com/refinedmods/refinedstorage/blockentity/NetworkNodeBlockEntity.java +++ b/src/main/java/com/refinedmods/refinedstorage/blockentity/NetworkNodeBlockEntity.java @@ -28,16 +28,26 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public abstract class NetworkNodeBlockEntity extends BaseBlockEntity implements INetworkNodeProxy, IRedstoneConfigurable { - public static final BlockEntitySynchronizationParameter REDSTONE_MODE = RedstoneMode.createParameter(new ResourceLocation(RS.ID, "redstone_mode")); + public static final BlockEntitySynchronizationParameter> REDSTONE_MODE = RedstoneMode.createParameter(new ResourceLocation(RS.ID, "redstone_mode")); private final LazyOptional> networkNodeProxy = LazyOptional.of(() -> this); + private final Class networkNodeClass; private N clientNode; private N removedNode; private static final Logger LOGGER = LogManager.getLogger(); + // TODO: remove this ctor in 1.21 + @Deprecated protected NetworkNodeBlockEntity(BlockEntityType type, BlockPos pos, BlockState state, BlockEntitySynchronizationSpec syncSpec) { super(type, pos, state, syncSpec); + this.networkNodeClass = null; + } + + protected NetworkNodeBlockEntity(BlockEntityType type, BlockPos pos, BlockState state, BlockEntitySynchronizationSpec syncSpec, + Class networkNodeClass) { + super(type, pos, state, syncSpec); + this.networkNodeClass = networkNodeClass; } @Override @@ -72,13 +82,20 @@ public abstract class NetworkNodeBlockEntity extends Base node = createAndSetNode(manager); } - return (N) node; + return doCast(node); } catch (ClassCastException e) { LOGGER.warn("Node @ {} got desynced with it's block entity container, recreating", worldPosition, e); return (N) createAndSetNode(manager); } } + private N doCast(INetworkNode node) { + if (networkNodeClass == null) { + return (N) node; + } + return networkNodeClass.cast(node); + } + private INetworkNode createAndSetNode(INetworkNodeManager manager) { INetworkNode node = createNode(level, worldPosition); manager.setNode(worldPosition, node); @@ -110,7 +127,11 @@ public abstract class NetworkNodeBlockEntity extends Base INetworkNode node = manager.getNode(worldPosition); if (node != null) { - removedNode = (N) node; + try { + removedNode = doCast(node); + } catch (ClassCastException e) { + removedNode = null; + } } manager.removeNode(worldPosition); diff --git a/src/main/java/com/refinedmods/refinedstorage/blockentity/NetworkReceiverBlockEntity.java b/src/main/java/com/refinedmods/refinedstorage/blockentity/NetworkReceiverBlockEntity.java index cf0d2f045..41ec7dc59 100644 --- a/src/main/java/com/refinedmods/refinedstorage/blockentity/NetworkReceiverBlockEntity.java +++ b/src/main/java/com/refinedmods/refinedstorage/blockentity/NetworkReceiverBlockEntity.java @@ -15,7 +15,7 @@ public class NetworkReceiverBlockEntity extends NetworkNodeBlockEntity networkCardCapability = LazyOptional.of(() -> getNode().getNetworkCard()); public NetworkTransmitterBlockEntity(BlockPos pos, BlockState state) { - super(RSBlockEntities.NETWORK_TRANSMITTER.get(), pos, state, SPEC); + super(RSBlockEntities.NETWORK_TRANSMITTER.get(), pos, state, SPEC, NetworkTransmitterNetworkNode.class); } @Override diff --git a/src/main/java/com/refinedmods/refinedstorage/blockentity/RelayBlockEntity.java b/src/main/java/com/refinedmods/refinedstorage/blockentity/RelayBlockEntity.java index 5fb657c2c..6e9f44f2c 100644 --- a/src/main/java/com/refinedmods/refinedstorage/blockentity/RelayBlockEntity.java +++ b/src/main/java/com/refinedmods/refinedstorage/blockentity/RelayBlockEntity.java @@ -15,7 +15,7 @@ public class RelayBlockEntity extends NetworkNodeBlockEntity { .build(); public RelayBlockEntity(BlockPos pos, BlockState state) { - super(RSBlockEntities.RELAY.get(), pos, state, SPEC); + super(RSBlockEntities.RELAY.get(), pos, state, SPEC, RelayNetworkNode.class); } @Override diff --git a/src/main/java/com/refinedmods/refinedstorage/blockentity/SecurityManagerBlockEntity.java b/src/main/java/com/refinedmods/refinedstorage/blockentity/SecurityManagerBlockEntity.java index e270e0993..2c913bdc7 100644 --- a/src/main/java/com/refinedmods/refinedstorage/blockentity/SecurityManagerBlockEntity.java +++ b/src/main/java/com/refinedmods/refinedstorage/blockentity/SecurityManagerBlockEntity.java @@ -15,7 +15,7 @@ public class SecurityManagerBlockEntity extends NetworkNodeBlockEntity { private final LazyOptional diskCapability = LazyOptional.of(() -> getNode().getPatterns()); public GridBlockEntity(GridType type, BlockPos pos, BlockState state) { - super(getType(type), pos, state, SPEC); + super(getType(type), pos, state, SPEC, GridNetworkNode.class); this.type = type; }