mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2026-10-19 22:12:28 +00:00
Support NeoForge's config GUI
See #1727. This is not sufficient to fix the issue, as it's NeoForge only, and doesn't support our address rules.
This commit is contained in:
@@ -60,6 +60,7 @@ path = [
|
||||
"doc/logo-darkmode.png",
|
||||
"projects/common/src/main/resources/assets/computercraft/models/**",
|
||||
"projects/common/src/main/resources/assets/computercraft/textures/**",
|
||||
"projects/common/src/main/resources/banner.png",
|
||||
"projects/common/src/main/resources/pack.mcmeta",
|
||||
"projects/common/src/main/resources/pack.png",
|
||||
"projects/core/src/main/resources/assets/computercraft/textures/gui/term_font.png",
|
||||
|
||||
@@ -146,10 +146,7 @@ public abstract class ConfigFile {
|
||||
}
|
||||
|
||||
protected String getTranslation(String name) {
|
||||
var key = new StringBuilder(TRANSLATION_PREFIX);
|
||||
for (var group : groupStack) key.append(group).append('.');
|
||||
key.append(name);
|
||||
return key.toString();
|
||||
return TRANSLATION_PREFIX + getPath(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
@@ -0,0 +1,22 @@
|
||||
// SPDX-FileCopyrightText: 2026 The CC: Tweaked Developers
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package dan200.computercraft.client;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.fml.ModContainer;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.client.gui.ConfigurationScreen;
|
||||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||
|
||||
@Mod(value = ComputerCraftAPI.MOD_ID, dist = Dist.CLIENT)
|
||||
public class ComputerCraftClient {
|
||||
public ComputerCraftClient(ModContainer container) {
|
||||
// Register our config screen. We exclude http.rules, as we don't currently have a config UI for this.
|
||||
container.registerExtensionPoint(IConfigScreenFactory.class, (modContainer, screen) -> new ConfigurationScreen(
|
||||
modContainer, screen, (ctx, key, element) -> key.equals("rules") ? null : element
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -42,8 +42,8 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.ModContainer;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.fml.ModLoadingContext;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.config.ModConfig;
|
||||
@@ -72,10 +72,9 @@ import java.util.function.BiFunction;
|
||||
public final class ComputerCraft {
|
||||
private static @Nullable IEventBus eventBus;
|
||||
|
||||
public ComputerCraft(IEventBus eventBus) {
|
||||
public ComputerCraft(IEventBus eventBus, ModContainer container) {
|
||||
withEventBus(eventBus, ModRegistry::register);
|
||||
|
||||
var container = ModLoadingContext.get().getActiveContainer();
|
||||
container.registerConfig(ModConfig.Type.SERVER, ((ForgeConfigFile) ConfigSpec.serverSpec).spec());
|
||||
container.registerConfig(ModConfig.Type.CLIENT, ((ForgeConfigFile) ConfigSpec.clientSpec).spec());
|
||||
|
||||
|
||||
+1
-2
@@ -46,9 +46,8 @@ public final class ForgeConfigFile extends ConfigFile {
|
||||
|
||||
@Override
|
||||
public void push(String name) {
|
||||
super.push(name);
|
||||
|
||||
translation(name);
|
||||
super.push(name);
|
||||
builder.push(name);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ modLoader="javafml"
|
||||
loaderVersion="[1,)"
|
||||
|
||||
issueTrackerURL="https://github.com/cc-tweaked/CC-Tweaked/issues"
|
||||
logoFile="pack.png"
|
||||
logoBlur=false
|
||||
logoFile="banner.png"
|
||||
|
||||
license="ComputerCraft Public License (https://raw.githubusercontent.com/dan200/ComputerCraft/master/LICENSE)"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user