From da44fe3dafe1f79f20a8cebce13623ed98073c90 Mon Sep 17 00:00:00 2001 From: Walker Fowlkes Date: Sat, 13 Apr 2024 16:08:07 -0700 Subject: [PATCH] okay fixed --- .../java/net/brokenmoon/redcontrol/screen/CpuScreen.java | 8 ++------ .../java/net/brokenmoon/redcontrol/api/CpuControl.java | 5 +++++ src/main/java/net/brokenmoon/redcontrol/api/CpuState.java | 7 +++++++ .../brokenmoon/redcontrol/blockentities/CpuEntity.java | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 src/main/java/net/brokenmoon/redcontrol/api/CpuControl.java create mode 100644 src/main/java/net/brokenmoon/redcontrol/api/CpuState.java diff --git a/src/client/java/net/brokenmoon/redcontrol/screen/CpuScreen.java b/src/client/java/net/brokenmoon/redcontrol/screen/CpuScreen.java index db740f2..6d3e39b 100644 --- a/src/client/java/net/brokenmoon/redcontrol/screen/CpuScreen.java +++ b/src/client/java/net/brokenmoon/redcontrol/screen/CpuScreen.java @@ -2,6 +2,7 @@ package net.brokenmoon.redcontrol.screen; import net.brokenmoon.redcontrol.RedControl; import net.brokenmoon.redcontrol.RedControlNetworking; +import net.brokenmoon.redcontrol.api.CpuState; import net.brokenmoon.redcontrol.blockentities.CpuEntity; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; @@ -64,12 +65,7 @@ public class CpuScreen extends Screen { @Override public void render(DrawContext context, int mouseX, int mouseY, float delta) { super.render(context, mouseX, mouseY, delta); - int buttonPos = 7; - if(cpu.isRunning){ - buttonPos = 0; - } else if(cpu.isResetting || cpu.isReset){ - buttonPos = 14; - } + int buttonPos = cpu.getCpuState().offset; int x = (width - 176) / 2; int y = (height - 166) / 2; context.drawTexture(cpuTexture,x,y,0,0,176,166); diff --git a/src/main/java/net/brokenmoon/redcontrol/api/CpuControl.java b/src/main/java/net/brokenmoon/redcontrol/api/CpuControl.java new file mode 100644 index 0000000..8ddd3d4 --- /dev/null +++ b/src/main/java/net/brokenmoon/redcontrol/api/CpuControl.java @@ -0,0 +1,5 @@ +package net.brokenmoon.redcontrol.api; + +public interface CpuControl { + CpuState getCpuState(); +} diff --git a/src/main/java/net/brokenmoon/redcontrol/api/CpuState.java b/src/main/java/net/brokenmoon/redcontrol/api/CpuState.java new file mode 100644 index 0000000..9455a14 --- /dev/null +++ b/src/main/java/net/brokenmoon/redcontrol/api/CpuState.java @@ -0,0 +1,7 @@ +package net.brokenmoon.redcontrol.api; + +public enum CpuState { + RUNNING(0), STOPPED(7), RESET(14); + public final int offset; + CpuState(int off){offset = off;} +} diff --git a/src/main/java/net/brokenmoon/redcontrol/blockentities/CpuEntity.java b/src/main/java/net/brokenmoon/redcontrol/blockentities/CpuEntity.java index 27ddd1c..952e695 100644 --- a/src/main/java/net/brokenmoon/redcontrol/blockentities/CpuEntity.java +++ b/src/main/java/net/brokenmoon/redcontrol/blockentities/CpuEntity.java @@ -24,7 +24,7 @@ public class CpuEntity extends Peripheral implements CpuControl { private int defaultMonitorId = 1; private int defaultDriveId = 2; - private CpuState state; + private CpuState state = CpuState.STOPPED; @Override public CpuState getCpuState() {return state;}