1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-26 19:37:39 +00:00

Fix command computers being exposed as peripherals

- Check whether the computer is a command computer before registering
   the capability.

 - Add tests to check what is/isn't a peripheral. See also #2020, where
   we forgot to register a peripheral on NeoForge 1.21.1.

Fixes #2070.
This commit is contained in:
Jonathan Coates
2025-01-26 11:13:52 +00:00
parent f212861370
commit 03388149b1
8 changed files with 93 additions and 160 deletions

View File

@@ -124,7 +124,7 @@ public class ForgeCommonHooks {
@SubscribeEvent
public static void onCapability(AttachCapabilitiesEvent<BlockEntity> event) {
var blockEntity = event.getObject();
if (blockEntity instanceof ComputerBlockEntity computer) {
if (blockEntity instanceof ComputerBlockEntity computer && !computer.isAdminOnly()) {
CapabilityProvider.attach(event, PERIPHERAL, CAPABILITY_PERIPHERAL, computer::peripheral);
} else if (blockEntity instanceof TurtleBlockEntity turtle) {
CapabilityProvider.attach(event, INVENTORY, ITEM_HANDLER, () -> new InvWrapper(turtle));