Skip to content

Commit

Permalink
Update neoforge
Browse files Browse the repository at this point in the history
To use builtin config screen
  • Loading branch information
dima-dencep committed Jul 19, 2024
1 parent 559424b commit af07f91
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 23 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ jobs:
game-versions: |
${{ steps.read_property.outputs.minecraft_version }}
dependencies: |
recs(optional){modrinth:VbyJLvvb}{curseforge:457570}
java: |
21
Expand Down Expand Up @@ -107,10 +104,9 @@ jobs:
game-version-filter: none
game-versions: |
${{ steps.read_property.outputs.minecraft_version }}
dependencies: |
cloth-config
modmenu(optional)
java: |
21
Expand Down
3 changes: 1 addition & 2 deletions common/src/main/resources/assets/rrls/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"text.autoconfig.rrls.option.removeOverlayAtEnd": "Hide the overlay after the end",
"text.autoconfig.rrls.option.removeOverlayAtEnd.@Tooltip": "Infinite (re)loading?",
"text.autoconfig.rrls.option.earlyPackStatusSend": "Early sending of status about server resourcepack",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip[0]": "Some servers specifically wait for the player to load resources, because of this the game may be displayed incorrectly",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip[1]": "Example: You were underground while reloading resources",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip": "Some servers specifically wait for the player to load resources, because of this the game may be displayed incorrectly\nExample: You were underground while reloading resources",
"text.autoconfig.rrls.option.animationSpeed": "Splash animation speed",
"text.autoconfig.rrls.option.animationSpeed.@Tooltip": "In milliseconds",
"text.autoconfig.rrls.option.doubleLoad": "Reload resources again if an error occurs",
Expand Down
3 changes: 1 addition & 2 deletions common/src/main/resources/assets/rrls/lang/es_mx.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"text.autoconfig.rrls.option.removeOverlayAtEnd": "Ocultar la superposición al final",
"text.autoconfig.rrls.option.removeOverlayAtEnd.@Tooltip": "¿Carga infinita?",
"text.autoconfig.rrls.option.earlyPackStatusSend": "Envío temprano del estado del paquete de recursos del servidor",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip[0]": "Algunos servidores esperan específicamente a que el jugador cargue los recursos, debido a esto, el juego puede mostrarse incorrectamente",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip[1]": "Ejemplo: Estabas bajo tierra mientras se recargaban los recursos",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip": "Algunos servidores esperan específicamente a que el jugador cargue los recursos, debido a esto, el juego puede mostrarse incorrectamente\nEjemplo: Estabas bajo tierra mientras se recargaban los recursos",
"text.autoconfig.rrls.option.animationSpeed": "Velocidad de animación de la pantalla de inicio",
"text.autoconfig.rrls.option.animationSpeed.@Tooltip": "En milisegundos",
"text.autoconfig.rrls.option.doubleLoad": "Volver a cargar los recursos si ocurre un error",
Expand Down
3 changes: 1 addition & 2 deletions common/src/main/resources/assets/rrls/lang/ru_ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
"text.autoconfig.rrls.option.removeOverlayAtEnd": "Скрытие оверлея после окончания",
"text.autoconfig.rrls.option.removeOverlayAtEnd.@Tooltip": "Бесконечная (пере)загрузка?",
"text.autoconfig.rrls.option.earlyPackStatusSend": "Ранняя отправка статуса о состоянии ресурспака сервера",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip[0]": "Некоторые серверы специально ждут, пока игрок загрузит ресурсы, из-за этого игра может отображаться некорректно",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip[1]": "Например: Вы оказались под землей во время перезагрузки ресурсов",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip": "Некоторые серверы специально ждут, пока игрок загрузит ресурсы, из-за этого игра может отображаться некорректно\nНапример: Вы оказались под землей во время перезагрузки ресурсов",
"text.autoconfig.rrls.option.animationSpeed": "Скорость анимации сплеша",
"text.autoconfig.rrls.option.animationSpeed.@Tooltip": "В милисекундах",
"text.autoconfig.rrls.option.doubleLoad": "Повторная загрузка ресурсов при возникновении ошибки",
Expand Down
3 changes: 1 addition & 2 deletions common/src/main/resources/assets/rrls/lang/tt_ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"text.autoconfig.rrls.option.reInitScreen": "Яңадан йөкләүдән соң хәзерге экран кабат әзерләү",
"text.autoconfig.rrls.option.reInitScreen.@Tooltip": "Функция сүндерелгәндә, яңадан йөкләүне тәмамланганнан соң асылынып торуны бетерә ала",
"text.autoconfig.rrls.option.earlyPackStatusSend": "Серверның ресурс җыелмасы турында халәтне иртә җибәрү",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip[0]": "Уенчы ресурсларны йөкләү өчен кайбер серверлар махсус көтә, бу сәбәпле уен ялгыш күрсәтә ала",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip[1]": "Мәсәлән: Ресурслар яңадан йөкләнгәндә Сез җир астында булды",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip": "Уенчы ресурсларны йөкләү өчен кайбер серверлар махсус көтә, бу сәбәпле уен ялгыш күрсәтә ала\nМәсәлән: Ресурслар яңадан йөкләнгәндә Сез җир астында булды",
"text.autoconfig.rrls.option.animationSpeed": "Спләш анимациясе тизлеге",
"text.autoconfig.rrls.option.animationSpeed.@Tooltip": "Миллисекундта"
}
3 changes: 1 addition & 2 deletions common/src/main/resources/assets/rrls/lang/zh_tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"text.autoconfig.rrls.option.removeOverlayAtEnd": "結束後隱藏覆蓋層",
"text.autoconfig.rrls.option.removeOverlayAtEnd.@Tooltip": "無限(重新)載入?",
"text.autoconfig.rrls.option.earlyPackStatusSend": "提早傳送伺服器資源包狀態",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip[0]": "有些伺服器特別等待玩家載入資源,因此遊戲可能顯示不正確",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip[1]": "例如:重新載入資源時你正在地下,這可能導致顯示異常",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip": "有些伺服器特別等待玩家載入資源,因此遊戲可能顯示不正確\n例如:重新載入資源時你正在地下,這可能導致顯示異常",
"text.autoconfig.rrls.option.animationSpeed": "載入動畫速度",
"text.autoconfig.rrls.option.animationSpeed.@Tooltip": "以毫秒為單位",
"text.autoconfig.rrls.option.doubleLoad": "如果發生錯誤,請重新載入資源",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class ConfigExpectPlatformImpl implements ConfigData {
public boolean removeOverlayAtEnd = true;

@ConfigEntry.Category("other")
@ConfigEntry.Gui.Tooltip(count = 2)
@ConfigEntry.Gui.Tooltip
public boolean earlyPackStatusSend = false;

@ConfigEntry.Category("other")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@
* https://spdx.org/licenses/OSL-3.0.txt
*/

/*package org.redlance.dima_dencep.mods.rrls.forge;
package org.redlance.dima_dencep.mods.rrls.forge;

import net.neoforged.api.distmarker.Dist;
import net.neoforged.fml.ModContainer;
import net.neoforged.neoforge.client.gui.ConfigurationScreen;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
import org.redlance.dima_dencep.mods.rrls.Rrls;
import net.neoforged.fml.common.Mod;

@Mod(value = Rrls.MOD_ID, dist = Dist.CLIENT)
public class RrlsForge extends Rrls {
public RrlsForge(ModContainer container) {
// no-op
container.registerExtensionPoint(IConfigScreenFactory.class, ConfigurationScreen::new);
}
}*/
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2023 - 2024 dima_dencep.
*
* Licensed under the Open Software License, Version 3.0 (the "License");
* you may not use this file except in compliance with the License.
*
* You may obtain a copy of the License at
* https://spdx.org/licenses/OSL-3.0.txt
*/

package org.redlance.dima_dencep.mods.rrls.forge.mixins.config;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import net.neoforged.fml.ModContainer;
import net.neoforged.neoforge.client.gui.ConfigurationScreen;
import org.redlance.dima_dencep.mods.rrls.Rrls;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(value = ConfigurationScreen.class, remap = false)
public class ConfigurationScreenMixin {
@WrapOperation(
method = "<init>(Lnet/neoforged/fml/ModContainer;Lnet/minecraft/client/gui/screens/Screen;Lnet/minecraft/data/models/blockstates/PropertyDispatch$QuadFunction;)V",
at = @At(
value = "INVOKE",
target = "Lnet/neoforged/neoforge/client/gui/ConfigurationScreen$TranslationChecker;check(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"
)
)
private static String rrls$clothconfig(ConfigurationScreen.TranslationChecker instance, String translationKey, String fallback, Operation<String> original, @Local(argsOnly = true) ModContainer mod) {
return original.call(instance, Rrls.MOD_ID.equals(mod.getModId()) ? "text.autoconfig.rrls.title" : translationKey, fallback);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Copyright 2023 - 2024 dima_dencep.
*
* Licensed under the Open Software License, Version 3.0 (the "License");
* you may not use this file except in compliance with the License.
*
* You may obtain a copy of the License at
* https://spdx.org/licenses/OSL-3.0.txt
*/

package org.redlance.dima_dencep.mods.rrls.forge.mixins.config;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.neoforge.client.gui.ConfigurationScreen;
import net.neoforged.neoforge.common.ModConfigSpec;
import org.redlance.dima_dencep.mods.rrls.Rrls;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.Supplier;

@Mixin(value = ConfigurationScreen.ConfigurationSectionScreen.class, remap = false)
public abstract class ConfigurationSectionScreenMixin {
@Shadow
@Final
protected ConfigurationScreen.ConfigurationSectionScreen.Context context;

@Shadow
protected abstract ConfigurationScreen.ConfigurationSectionScreen.Element createBooleanValue(String key, ModConfigSpec.ValueSpec spec, Supplier<Boolean> source, Consumer<Boolean> target);
@Shadow
protected abstract ConfigurationScreen.ConfigurationSectionScreen.Element createIntegerValue(String key, ModConfigSpec.ValueSpec spec, Supplier<Integer> source, Consumer<Integer> target);
@Shadow
protected abstract ConfigurationScreen.ConfigurationSectionScreen.Element createLongValue(String key, ModConfigSpec.ValueSpec spec, Supplier<Long> source, Consumer<Long> target);
@Shadow
protected abstract ConfigurationScreen.ConfigurationSectionScreen.Element createDoubleValue(String key, ModConfigSpec.ValueSpec spec, Supplier<Double> source, Consumer<Double> target);
@Shadow
protected abstract ConfigurationScreen.ConfigurationSectionScreen.Element createStringValue(String key, Predicate<String> tester, Supplier<String> source, Consumer<String> target);

@Shadow
protected ConfigurationScreen.RestartType needsRestart;

@Inject(
method = "<init>(Lnet/minecraft/client/gui/screens/Screen;Lnet/neoforged/fml/config/ModConfig$Type;Lnet/neoforged/fml/config/ModConfig;Lnet/minecraft/network/chat/Component;)V",
at = @At(
value = "TAIL"
)
)
public void rrls$fixStartupConfigs(Screen parent, ModConfig.Type type, ModConfig modConfig, Component title, CallbackInfo ci) {
if (Rrls.MOD_ID.equals(context.modId())) {
this.needsRestart = ConfigurationScreen.RestartType.NONE;
}
}

@ModifyVariable(
method = "getTooltipComponent",
at = @At(
value = "STORE"
),
ordinal = 1
)
public String rrls$clothconfig(String value) {
if (Rrls.MOD_ID.equals(this.context.modId())) {
return value.replace(".tooltip", ".@Tooltip");
}

return value;
}

@WrapOperation(
method = "rebuild",
at = @At(
value = "INVOKE",
target = "Lnet/neoforged/neoforge/client/gui/ConfigurationScreen$ConfigurationSectionScreen;createOtherValue(Ljava/lang/String;Lnet/neoforged/neoforge/common/ModConfigSpec$ConfigValue;)Lnet/neoforged/neoforge/client/gui/ConfigurationScreen$ConfigurationSectionScreen$Element;"
)
)
public ConfigurationScreen.ConfigurationSectionScreen.Element rrls$fixValues(ConfigurationScreen.ConfigurationSectionScreen instance, String key, ModConfigSpec.ConfigValue value, Operation<ConfigurationScreen.ConfigurationSectionScreen.Element> original, @Local(ordinal = 0) ModConfigSpec.ValueSpec valueSpec) {
if (Rrls.MOD_ID.equals(this.context.modId())) {
return switch (valueSpec.getDefault()) {
case Boolean b -> createBooleanValue(key, valueSpec, value, value::set);
case Integer i -> createIntegerValue(key, valueSpec, value, value::set);
case Long l -> createLongValue(key, valueSpec, value, value::set);
case Double d -> createDoubleValue(key, valueSpec, value, value::set);
case String s -> createStringValue(key, valueSpec::test, value, value::set);
default -> original.call(instance, key, value);
};
}

return original.call(instance, key, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class ConfigExpectPlatformImpl { // TODO categorize

public ConfigExpectPlatformImpl(ModConfigSpec.Builder builder) {
hideType = builder
.translation("text.autoconfig.rrls.option.hideType")
.translation("text.autoconfig.rrls.option.hideOverlays")
.defineEnum("hideOverlays", HideType.ALL);

rgbProgress = builder
Expand Down
2 changes: 1 addition & 1 deletion forge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
modLoader = "lowcodefml" # javafml
modLoader = "javafml"
loaderVersion = "*"
issueTrackerURL = "https://github.com/dima-dencep/rrls/issues"
license = "OSL-3.0"
Expand Down
4 changes: 3 additions & 1 deletion forge/src/main/resources/rrls-forge.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"package": "org.redlance.dima_dencep.mods.rrls.forge.mixins",
"compatibilityLevel": "JAVA_21",
"client": [
"NeoForgeLoadingOverlayMixin"
"NeoForgeLoadingOverlayMixin",
"config.ConfigurationScreenMixin",
"config.ConfigurationSectionScreenMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ org.gradle.parallel=true
minecraft_version = 1.21
parchment_version = 2024.07.07
loader_version = 0.16.0
forge_version = 21.0.96-beta
forge_version = 21.0.110-beta

# Mod Properties
mod_version = 5.0.4
Expand Down

0 comments on commit af07f91

Please sign in to comment.