aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/recipe
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api/recipe')
-rw-r--r--src/main/java/gregtech/api/recipe/check/CheckRecipeResult.java7
-rw-r--r--src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java4
-rw-r--r--src/main/java/gregtech/api/recipe/check/SimpleCheckRecipeResult.java30
3 files changed, 33 insertions, 8 deletions
diff --git a/src/main/java/gregtech/api/recipe/check/CheckRecipeResult.java b/src/main/java/gregtech/api/recipe/check/CheckRecipeResult.java
index ab1db6ecd2..eeb01077de 100644
--- a/src/main/java/gregtech/api/recipe/check/CheckRecipeResult.java
+++ b/src/main/java/gregtech/api/recipe/check/CheckRecipeResult.java
@@ -39,4 +39,11 @@ public interface CheckRecipeResult {
* Decode synced value.
*/
void decode(PacketBuffer buffer);
+
+ /**
+ * @return If this message should stay on GUI when the machine is shut down.
+ */
+ default boolean persistsOnShutdown() {
+ return false;
+ }
}
diff --git a/src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java b/src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java
index ad0d56708e..f162c892ee 100644
--- a/src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java
+++ b/src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java
@@ -59,7 +59,7 @@ public final class CheckRecipeResultRegistry {
/**
* Code crashed.
*/
- public static final CheckRecipeResult CRASH = SimpleCheckRecipeResult.ofFailure("crash");
+ public static final CheckRecipeResult CRASH = SimpleCheckRecipeResult.ofFailurePersistOnShutdown("crash");
/**
* Cannot find valid fuel for generator.
*/
@@ -121,7 +121,7 @@ public final class CheckRecipeResultRegistry {
}
static {
- register(new SimpleCheckRecipeResult(false, ""));
+ register(new SimpleCheckRecipeResult(false, "", false));
register(new ResultInsufficientPower(0));
register(new ResultInsufficientHeat(0));
register(new ResultInsufficientMachineTier(0));
diff --git a/src/main/java/gregtech/api/recipe/check/SimpleCheckRecipeResult.java b/src/main/java/gregtech/api/recipe/check/SimpleCheckRecipeResult.java
index 767a168125..ed4c95f880 100644
--- a/src/main/java/gregtech/api/recipe/check/SimpleCheckRecipeResult.java
+++ b/src/main/java/gregtech/api/recipe/check/SimpleCheckRecipeResult.java
@@ -14,10 +14,12 @@ public class SimpleCheckRecipeResult implements CheckRecipeResult {
private boolean success;
private String key;
+ private boolean persistsOnShutdown;
- SimpleCheckRecipeResult(boolean success, String key) {
+ SimpleCheckRecipeResult(boolean success, String key, boolean persistsOnShutdown) {
this.success = success;
this.key = key;
+ this.persistsOnShutdown = persistsOnShutdown;
}
@Override
@@ -37,19 +39,26 @@ public class SimpleCheckRecipeResult implements CheckRecipeResult {
@Override
public CheckRecipeResult newInstance() {
- return new SimpleCheckRecipeResult(false, "");
+ return new SimpleCheckRecipeResult(false, "", false);
}
@Override
public void encode(PacketBuffer buffer) {
buffer.writeBoolean(success);
NetworkUtils.writeStringSafe(buffer, key);
+ buffer.writeBoolean(persistsOnShutdown);
}
@Override
public void decode(PacketBuffer buffer) {
success = buffer.readBoolean();
key = NetworkUtils.readStringSafe(buffer);
+ persistsOnShutdown = buffer.readBoolean();
+ }
+
+ @Override
+ public boolean persistsOnShutdown() {
+ return persistsOnShutdown;
}
@Override
@@ -57,7 +66,8 @@ public class SimpleCheckRecipeResult implements CheckRecipeResult {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SimpleCheckRecipeResult that = (SimpleCheckRecipeResult) o;
- return success == that.success && Objects.equals(key, that.key);
+ return success == that.success && Objects.equals(key, that.key)
+ && persistsOnShutdown == that.persistsOnShutdown;
}
/**
@@ -65,14 +75,22 @@ public class SimpleCheckRecipeResult implements CheckRecipeResult {
* This is already registered to registry.
*/
public static CheckRecipeResult ofSuccess(String key) {
- return new SimpleCheckRecipeResult(true, key);
+ return new SimpleCheckRecipeResult(true, key, false);
}
/**
- * Creates new result object with failed state. Add your localized description with `GT5U.gui.text.{key}`.
+ * Creates new result with failed state. Add your localized description with `GT5U.gui.text.{key}`.
* This is already registered to registry.
*/
public static CheckRecipeResult ofFailure(String key) {
- return new SimpleCheckRecipeResult(false, key);
+ return new SimpleCheckRecipeResult(false, key, false);
+ }
+
+ /**
+ * Creates new result object with failed state that does not get reset on shutdown. Add your localized description
+ * with `GT5U.gui.text.{key}`. This is already registered to registry.
+ */
+ public static CheckRecipeResult ofFailurePersistOnShutdown(String key) {
+ return new SimpleCheckRecipeResult(false, key, true);
}
}