aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/recipe
diff options
context:
space:
mode:
authormiozune <miozune@gmail.com>2023-10-13 17:59:39 +0900
committerGitHub <noreply@github.com>2023-10-13 10:59:39 +0200
commit4c8b94dd91fa5e16534d48415d5a4f75ea0bbb6f (patch)
treeb9222d444b42514e265640aab7c3488816ddccd8 /src/main/java/gregtech/api/recipe
parentb43e65f3784a7978656a4e2a72a2734b37d7b735 (diff)
downloadGT5-Unofficial-4c8b94dd91fa5e16534d48415d5a4f75ea0bbb6f.tar.gz
GT5-Unofficial-4c8b94dd91fa5e16534d48415d5a4f75ea0bbb6f.tar.bz2
GT5-Unofficial-4c8b94dd91fa5e16534d48415d5a4f75ea0bbb6f.zip
Fix Stocking Bus bug (#2326)
* Shut down machine with message if stocking bus fail to extract items * Better way to handle message persistent on shutdown * Minor cleanup * Allow more localizations * Add network status display * Fix auto-pull mode accepting shift insert * Remove workaround for issue with multiple ME buses in a multiblock * Some tweak for appearance * Correct inconsistent variable naming in GT_UITextures * Update .gitignore * Fix typo * Remove isScheduledForResetCheckRecipeResult by using persistsOnShutdown * Apply "cannot set slot" tooltip for empty slots too
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);
}
}