From 2b2e5ce1e49211007e29c6d53a73b94c2de1cee2 Mon Sep 17 00:00:00 2001 From: DuckyProgrammer Date: Tue, 17 Sep 2024 14:49:52 -0400 Subject: [PATCH] fix: fix solar panels not showing generation stats when blocked or full --- src/main/generated/assets/galacticraft/lang/en_us.json | 1 + .../client/gui/screen/ingame/AdvancedSolarPanelScreen.java | 7 ++++++- .../client/gui/screen/ingame/BasicSolarPanelScreen.java | 7 ++++++- .../dev/galacticraft/mod/data/GCTranslationProvider.java | 1 + src/main/java/dev/galacticraft/mod/util/Translations.java | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/generated/assets/galacticraft/lang/en_us.json b/src/main/generated/assets/galacticraft/lang/en_us.json index 7f9a310c6..5e184d255 100644 --- a/src/main/generated/assets/galacticraft/lang/en_us.json +++ b/src/main/generated/assets/galacticraft/lang/en_us.json @@ -590,6 +590,7 @@ "ui.galacticraft.machine.max_oxygen": "Maximum Oxygen: %s", "ui.galacticraft.machine.solar_panel.atmospheric_interference": "Atmospheric Interference: %s", "ui.galacticraft.machine.solar_panel.blocked": "Blocked", + "ui.galacticraft.machine.solar_panel.full": "Full", "ui.galacticraft.machine.solar_panel.day": "Day", "ui.galacticraft.machine.solar_panel.missing_source": "Missing Light Source", "ui.galacticraft.machine.solar_panel.night": "Night", diff --git a/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/AdvancedSolarPanelScreen.java b/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/AdvancedSolarPanelScreen.java index 1c0749400..d93f7885c 100644 --- a/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/AdvancedSolarPanelScreen.java +++ b/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/AdvancedSolarPanelScreen.java @@ -22,6 +22,7 @@ package dev.galacticraft.mod.client.gui.screen.ingame; +import dev.galacticraft.machinelib.api.machine.MachineStatus; import dev.galacticraft.mod.Constant; import dev.galacticraft.mod.content.block.entity.machine.AdvancedSolarPanelBlockEntity; import dev.galacticraft.mod.screen.SolarPanelMenu; @@ -41,8 +42,12 @@ public AdvancedSolarPanelScreen(SolarPanelMenu ha @Override public void appendEnergyTooltip(List list) { - if (this.menu.state.isActive()) { + if (this.menu.state.isActive() || this.menu.state.getStatus() == null) { // It never became null during testing, however when null it would crash games. Added as precaution. list.add(Component.translatable(Translations.Ui.GJT, this.menu.getCurrentEnergyGeneration()).setStyle(Constant.Text.Color.LIGHT_PURPLE_STYLE)); + } else if (this.menu.state.getStatus().getType().equals(MachineStatus.Type.OTHER)) { + list.add(Component.translatable(Translations.SolarPanel.BLOCKED).setStyle(Constant.Text.Color.DARK_RED_STYLE)); + } else if (this.menu.state.getStatus().getType().equals(MachineStatus.Type.OUTPUT_FULL)) { + list.add(Component.translatable(Translations.SolarPanel.FULL).setStyle(Constant.Text.Color.GREEN_STYLE)); } } } diff --git a/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/BasicSolarPanelScreen.java b/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/BasicSolarPanelScreen.java index 58a3333b0..84465ac21 100644 --- a/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/BasicSolarPanelScreen.java +++ b/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/BasicSolarPanelScreen.java @@ -22,6 +22,7 @@ package dev.galacticraft.mod.client.gui.screen.ingame; +import dev.galacticraft.machinelib.api.machine.MachineStatus; import dev.galacticraft.mod.Constant; import dev.galacticraft.mod.content.block.entity.machine.BasicSolarPanelBlockEntity; import dev.galacticraft.mod.screen.SolarPanelMenu; @@ -41,8 +42,12 @@ public BasicSolarPanelScreen(SolarPanelMenu handler, @Override public void appendEnergyTooltip(List list) { - if (this.menu.state.isActive()) { + if (this.menu.state.isActive() || this.menu.state.getStatus() == null) { // It never became null during testing, however when null it would crash games. Added as precaution. list.add(Component.translatable(Translations.Ui.GJT, this.menu.getCurrentEnergyGeneration()).setStyle(Constant.Text.Color.LIGHT_PURPLE_STYLE)); + } else if (this.menu.state.getStatus().getType().equals(MachineStatus.Type.OTHER)) { + list.add(Component.translatable(Translations.SolarPanel.BLOCKED).setStyle(Constant.Text.Color.DARK_RED_STYLE)); + } else if (this.menu.state.getStatus().getType().equals(MachineStatus.Type.OUTPUT_FULL)) { + list.add(Component.translatable(Translations.SolarPanel.FULL).setStyle(Constant.Text.Color.GREEN_STYLE)); } } } diff --git a/src/main/java/dev/galacticraft/mod/data/GCTranslationProvider.java b/src/main/java/dev/galacticraft/mod/data/GCTranslationProvider.java index d7604385b..29bc556f3 100644 --- a/src/main/java/dev/galacticraft/mod/data/GCTranslationProvider.java +++ b/src/main/java/dev/galacticraft/mod/data/GCTranslationProvider.java @@ -280,6 +280,7 @@ protected void generateTranslations(HolderLookup.@NotNull Provider registries) { this.add(SolarPanel.ATMOSPHERIC_INTERFERENCE, "Atmospheric Interference: %s"); this.add(SolarPanel.BLOCKED, "Blocked"); + this.add(SolarPanel.FULL, "Full"); this.add(SolarPanel.DAY, "Day"); this.add(SolarPanel.MISSING_SOURCE, "Missing Light Source"); this.add(SolarPanel.NIGHT, "Night"); diff --git a/src/main/java/dev/galacticraft/mod/util/Translations.java b/src/main/java/dev/galacticraft/mod/util/Translations.java index 85adfd927..1fb18459c 100644 --- a/src/main/java/dev/galacticraft/mod/util/Translations.java +++ b/src/main/java/dev/galacticraft/mod/util/Translations.java @@ -206,6 +206,7 @@ interface SpaceRace { interface SolarPanel { String ATMOSPHERIC_INTERFERENCE = "ui.galacticraft.machine.solar_panel.atmospheric_interference"; String BLOCKED = "ui.galacticraft.machine.solar_panel.blocked"; + String FULL = "ui.galacticraft.machine.solar_panel.full"; String DAY = "ui.galacticraft.machine.solar_panel.day"; String MISSING_SOURCE = "ui.galacticraft.machine.solar_panel.missing_source"; String NIGHT = "ui.galacticraft.machine.solar_panel.night";