aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-02-15 15:32:09 +0800
committershedaniel <daniel@shedaniel.me>2022-02-15 15:32:09 +0800
commit77f0859404d10f60643de6ec5ed42bc8f090be08 (patch)
treecc89ba5a722c0ecab500572600dc07de1d5664d3 /runtime
parent75e2b26669d5960aac8626f879b0943224ac4814 (diff)
downloadRoughlyEnoughItems-77f0859404d10f60643de6ec5ed42bc8f090be08.tar.gz
RoughlyEnoughItems-77f0859404d10f60643de6ec5ed42bc8f090be08.tar.bz2
RoughlyEnoughItems-77f0859404d10f60643de6ec5ed42bc8f090be08.zip
Close #768
Diffstat (limited to 'runtime')
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java16
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java17
-rwxr-xr-xruntime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json1
3 files changed, 30 insertions, 4 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java
index 9357313c5..6f9c5a085 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java
@@ -51,6 +51,7 @@ import me.shedaniel.rei.api.client.REIRuntime;
import me.shedaniel.rei.api.client.config.ConfigManager;
import me.shedaniel.rei.api.client.config.entry.EntryStackProvider;
import me.shedaniel.rei.api.client.favorites.FavoriteEntry;
+import me.shedaniel.rei.api.client.gui.config.CheatingMode;
import me.shedaniel.rei.api.client.gui.config.DisplayScreenType;
import me.shedaniel.rei.api.client.gui.config.SyntaxHighlightingMode;
import me.shedaniel.rei.api.client.overlay.ScreenOverlay;
@@ -135,6 +136,21 @@ public class ConfigManagerImpl implements ConfigManager {
}
private static Jankson buildJankson(Jankson.Builder builder) {
+ // CheatingMode
+ builder.registerSerializer(CheatingMode.class, (value, marshaller) -> {
+ if (value == CheatingMode.WHEN_CREATIVE) {
+ return new JsonPrimitive("WHEN_CREATIVE");
+ } else {
+ return new JsonPrimitive(value == CheatingMode.ON);
+ }
+ });
+ builder.registerDeserializer(Boolean.class, CheatingMode.class, (value, unmarshaller) -> {
+ return value ? CheatingMode.ON : CheatingMode.OFF;
+ });
+ builder.registerDeserializer(String.class, CheatingMode.class, (value, unmarshaller) -> {
+ return CheatingMode.valueOf(value.toUpperCase(Locale.ROOT));
+ });
+
// InputConstants.Key
builder.registerSerializer(InputConstants.Key.class, (value, marshaller) -> {
return new JsonPrimitive(value.getName());
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java
index 01c92b70d..76c7e269c 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java
@@ -38,7 +38,9 @@ import me.shedaniel.rei.api.client.gui.config.*;
import me.shedaniel.rei.impl.client.entry.filtering.FilteringRule;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import net.minecraft.client.Minecraft;
import net.minecraft.util.Mth;
+import net.minecraft.world.level.GameType;
import org.jetbrains.annotations.ApiStatus;
import java.lang.annotation.ElementType;
@@ -73,12 +75,18 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
@Override
public boolean isCheating() {
- return basics.cheating;
+ return basics.cheating == CheatingMode.ON || (basics.cheating == CheatingMode.WHEN_CREATIVE && Minecraft.getInstance().gameMode != null
+ && Minecraft.getInstance().gameMode.getPlayerMode() == GameType.CREATIVE);
}
@Override
public void setCheating(boolean cheating) {
- basics.cheating = cheating;
+ basics.cheating = cheating ? CheatingMode.ON : CheatingMode.OFF;
+ }
+
+ @Override
+ public CheatingMode getCheatingMode() {
+ return basics.cheating;
}
@Override
@@ -513,7 +521,7 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
public static class Basics {
@ConfigEntry.Gui.Excluded public List<FavoriteEntry> favorites = new ArrayList<>();
- @Comment("Declares whether cheating mode is on.") private boolean cheating = false;
+ @Comment("Declares whether cheating mode is on.") @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) private CheatingMode cheating = CheatingMode.OFF;
private boolean favoritesEnabled = true;
@ConfigEntry.Gui.CollapsibleObject(startExpanded = true)
private KeyBindings keyBindings = new KeyBindings();
@@ -574,7 +582,8 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData {
@Comment("Declares whether mob effects should be on the left side instead of the right side.") private boolean leftSideMobEffects = false;
@Comment("Declares whether subsets is enabled.") private boolean isSubsetsEnabled = false;
private boolean allowInventoryHighlighting = true;
- @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) private ItemCheatingMode itemCheatingMode = ItemCheatingMode.REI_LIKE;
+ @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
+ private ItemCheatingMode itemCheatingMode = ItemCheatingMode.REI_LIKE;
}
public static class Advanced {
diff --git a/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json b/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json
index 99f039e67..866d202bd 100755
--- a/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json
+++ b/runtime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json
@@ -158,6 +158,7 @@
"config.roughlyenoughitems.functionality": "Functionality",
"config.roughlyenoughitems.advanced": "Advanced",
"config.roughlyenoughitems.cheating": "Cheating:",
+ "config.roughlyenoughitems.cheating.when_creative": "During Creative Mode",
"config.roughlyenoughitems.favoritesEnabled": "Favorites Enabled:",
"config.roughlyenoughitems.keyBindings": "Keybindings",
"config.roughlyenoughitems.keyBindings.recipeKeybind": "Show Recipe:",