From c9dea491de5ec56364c4581919732775fb039866 Mon Sep 17 00:00:00 2001 From: Walker Fowlkes Date: Fri, 12 Apr 2024 18:56:40 -0700 Subject: [PATCH] unholy creature of steel has been born --- .../java/net/brokenmoon/redcontrol/RedControl.java | 10 ++++++++++ 1 file changed, 10 insertions(+) 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);}