diff --git a/src/main/java/net/brokenmoon/redcontrol/RedControl.java b/src/main/java/net/brokenmoon/redcontrol/RedControl.java index c1d493d..f716d67 100644 --- a/src/main/java/net/brokenmoon/redcontrol/RedControl.java +++ b/src/main/java/net/brokenmoon/redcontrol/RedControl.java @@ -14,6 +14,7 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; import net.fabricmc.fabric.api.resource.ResourceManagerHelper; import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; +import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; @@ -109,6 +110,15 @@ public class RedControl implements ModInitializer { cpu.reset(); LOGGER.info("Resetting cpu at {}", blockPos); }))); + + ServerPlayNetworking.registerGlobalReceiver(RedControlNetworking.KEY_PRESS, ((server,player,handler,buf,responseSender) -> server.execute(() -> { + BlockPos blockPos = buf.readBlockPos(); + byte key = buf.readByte(); + BlockEntity term = player.getWorld().getBlockEntity(blockPos); + if (term instanceof TerminalEntity te) { + te.pushKey(key); + } + }))); } static Identifier modloc(String path) {return new Identifier("redcontrol",path);}