diff --git a/projects/common/src/main/java/dan200/computercraft/shared/ModRegistry.java b/projects/common/src/main/java/dan200/computercraft/shared/ModRegistry.java index bcbfb775d..8c9f64b78 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/ModRegistry.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/ModRegistry.java @@ -24,7 +24,6 @@ import dan200.computercraft.shared.common.ColourableRecipe; import dan200.computercraft.shared.common.DefaultBundledRedstoneProvider; import dan200.computercraft.shared.common.HeldItemMenu; import dan200.computercraft.shared.computer.blocks.CommandComputerBlock; -import dan200.computercraft.shared.computer.blocks.CommandComputerBlockEntity; import dan200.computercraft.shared.computer.blocks.ComputerBlock; import dan200.computercraft.shared.computer.blocks.ComputerBlockEntity; import dan200.computercraft.shared.computer.core.ComputerFamily; @@ -141,8 +140,7 @@ public final class ModRegistry { () -> new ComputerBlock<>(computerProperties().mapColor(MapColor.STONE), BlockEntities.COMPUTER_NORMAL)); public static final RegistryEntry> COMPUTER_ADVANCED = REGISTRY.register("computer_advanced", () -> new ComputerBlock<>(computerProperties().mapColor(MapColor.GOLD), BlockEntities.COMPUTER_ADVANCED)); - - public static final RegistryEntry> COMPUTER_COMMAND = REGISTRY.register("computer_command", + public static final RegistryEntry> COMPUTER_COMMAND = REGISTRY.register("computer_command", () -> new CommandComputerBlock<>(computerProperties().strength(-1, 6000000.0F), BlockEntities.COMPUTER_COMMAND)); public static final RegistryEntry TURTLE_NORMAL = REGISTRY.register("turtle_normal", @@ -185,8 +183,8 @@ public final class ModRegistry { ofBlock(Blocks.COMPUTER_NORMAL, (p, s) -> new ComputerBlockEntity(BlockEntities.COMPUTER_NORMAL.get(), p, s, ComputerFamily.NORMAL)); public static final RegistryEntry> COMPUTER_ADVANCED = ofBlock(Blocks.COMPUTER_ADVANCED, (p, s) -> new ComputerBlockEntity(BlockEntities.COMPUTER_ADVANCED.get(), p, s, ComputerFamily.ADVANCED)); - public static final RegistryEntry> COMPUTER_COMMAND = - ofBlock(Blocks.COMPUTER_COMMAND, (p, s) -> new CommandComputerBlockEntity(BlockEntities.COMPUTER_COMMAND.get(), p, s)); + public static final RegistryEntry> COMPUTER_COMMAND = + ofBlock(Blocks.COMPUTER_COMMAND, (p, s) -> new ComputerBlockEntity(BlockEntities.COMPUTER_COMMAND.get(), p, s, ComputerFamily.COMMAND)); public static final RegistryEntry> TURTLE_NORMAL = ofBlock(Blocks.TURTLE_NORMAL, (p, s) -> new TurtleBlockEntity(BlockEntities.TURTLE_NORMAL.get(), p, s, () -> Config.turtleFuelLimit, ComputerFamily.NORMAL)); diff --git a/projects/common/src/main/java/dan200/computercraft/shared/computer/blocks/CommandComputerBlock.java b/projects/common/src/main/java/dan200/computercraft/shared/computer/blocks/CommandComputerBlock.java index 4e8ad3535..7eec0f82a 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/computer/blocks/CommandComputerBlock.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/computer/blocks/CommandComputerBlock.java @@ -15,7 +15,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType; * @param The type of the computer block entity. * @see dan200.computercraft.shared.computer.items.CommandComputerItem */ -public class CommandComputerBlock extends ComputerBlock implements GameMasterBlock { +public class CommandComputerBlock extends ComputerBlock implements GameMasterBlock { public CommandComputerBlock(Properties settings, RegistryEntry> type) { super(settings, type); } diff --git a/projects/common/src/main/java/dan200/computercraft/shared/computer/blocks/CommandComputerBlockEntity.java b/projects/common/src/main/java/dan200/computercraft/shared/computer/blocks/CommandComputerBlockEntity.java deleted file mode 100644 index 6c090f081..000000000 --- a/projects/common/src/main/java/dan200/computercraft/shared/computer/blocks/CommandComputerBlockEntity.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission. -// -// SPDX-License-Identifier: LicenseRef-CCPL - -package dan200.computercraft.shared.computer.blocks; - -import dan200.computercraft.shared.computer.apis.CommandAPI; -import dan200.computercraft.shared.computer.core.ComputerFamily; -import dan200.computercraft.shared.computer.core.ServerComputer; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.state.BlockState; - -public class CommandComputerBlockEntity extends ComputerBlockEntity { - public CommandComputerBlockEntity(BlockEntityType type, BlockPos pos, BlockState state) { - super(type, pos, state, ComputerFamily.COMMAND); - } - - @Override - protected ServerComputer createComputer(int id) { - var computer = super.createComputer(id); - computer.addAPI(new CommandAPI(computer)); - return computer; - } -} diff --git a/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java b/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java index b8ffba7fc..02c0d0ac3 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java @@ -13,6 +13,7 @@ import dan200.computercraft.core.computer.Computer; import dan200.computercraft.core.computer.ComputerEnvironment; import dan200.computercraft.core.computer.ComputerSide; import dan200.computercraft.core.metrics.MetricsObserver; +import dan200.computercraft.shared.computer.apis.CommandAPI; import dan200.computercraft.shared.computer.menu.ComputerMenu; import dan200.computercraft.shared.computer.terminal.NetworkedTerminal; import dan200.computercraft.shared.computer.terminal.TerminalState; @@ -61,6 +62,8 @@ public class ServerComputer implements InputHandler, ComputerEnvironment { computer = new Computer(context.computerContext(), this, terminal, computerID); computer.setLabel(label); + + if (family == ComputerFamily.COMMAND) addAPI(new CommandAPI(this)); } public ComputerFamily getFamily() {