Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix solar panels not showing generation stats when blocked or full #356

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/generated/assets/galacticraft/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -41,8 +42,12 @@ public AdvancedSolarPanelScreen(SolarPanelMenu<AdvancedSolarPanelBlockEntity> ha

@Override
public void appendEnergyTooltip(List<Component> 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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -41,8 +42,12 @@ public BasicSolarPanelScreen(SolarPanelMenu<BasicSolarPanelBlockEntity> handler,

@Override
public void appendEnergyTooltip(List<Component> 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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions src/main/java/dev/galacticraft/mod/util/Translations.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down