Added custom config

This commit is contained in:
coolGi2007
2021-12-06 02:57:56 +00:00
parent ed6dff3b5e
commit faf8579b41
21 changed files with 406 additions and 1401 deletions
@@ -17,26 +17,22 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.lod.fabric;
package com.seibel.lod.common;
import com.seibel.lod.common.wrappers.config.ConfigGui;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.core.enums.config.*;
import com.seibel.lod.core.enums.rendering.*;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IAdvanced.*;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics.*;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IWorldGenerator;
import com.seibel.lod.fabric.wrappers.config.ConfigGui;
import me.shedaniel.autoconfig.ConfigData;
import me.shedaniel.autoconfig.annotation.ConfigEntry;
/**
* This handles any configuration the user has access to.
* @author coolGi2007
* @version 12-02-2021
*/
@me.shedaniel.autoconfig.annotation.Config(name = ModInfo.ID)
public class Config implements ConfigData
//public class Config extends ConfigGui
public class Config extends ConfigGui
{
// CONFIG STRUCTURE
// -> Client
@@ -55,195 +51,185 @@ public class Config implements ConfigData
// Since the original config system uses forge stuff, that means we have to rewrite the whole config system
@ConfigEntry.Gui.CollapsibleObject
public Client client = new Client();
@ScreenEntry(to = "client")
public static ScreenEntry client;
public static class Client
{
@ConfigEntry.Gui.CollapsibleObject
public Graphics graphics = new Graphics();
@Category("client")
@ScreenEntry(to = "graphics")
public static ScreenEntry graphics;
@ConfigEntry.Gui.CollapsibleObject
public WorldGenerator worldGenerator = new WorldGenerator();
@Category("client")
@ScreenEntry(to = "worldGenerator")
public static ScreenEntry worldGenerator;
@ConfigEntry.Gui.CollapsibleObject
public Advanced advanced = new Advanced();
@Category("client")
@ScreenEntry(to = "advanced")
public static ScreenEntry advanced;
public static class Graphics
{
@ConfigEntry.Gui.CollapsibleObject
public Quality quality = new Quality();
@Category("client.graphics")
@ScreenEntry(to = "quality")
public static ScreenEntry quality;
@ConfigEntry.Gui.CollapsibleObject
public FogQuality fogQuality = new FogQuality();
@Category("client.graphics")
@ScreenEntry(to = "fogQuality")
public static ScreenEntry fogQuality;
@ConfigEntry.Gui.CollapsibleObject
public AdvancedGraphics advancedGraphicsOption = new AdvancedGraphics();
@Category("client.graphics")
@ScreenEntry(to = "advancedGraphics")
public static ScreenEntry advancedGraphics;
public static class Quality
{
@ConfigEntry.Category("lod.Graphics.QualityOption")
@ConfigEntry.Gui.Tooltip
@Category("client.graphics.quality")
@Entry
public static HorizontalResolution drawResolution = IQuality.DRAW_RESOLUTION_DEFAULT;
@ConfigEntry.Category("lod.Graphics.QualityOption")
@ConfigEntry.Gui.Tooltip
@ConfigEntry.BoundedDiscrete(min = 16, max = 1024)
@Category("client.graphics.quality")
@Entry(min = 16, max = 1024)
public static int lodChunkRenderDistance = IQuality.LOD_CHUNK_RENDER_DISTANCE_MIN_DEFAULT_MAX.defaultValue;
@ConfigEntry.Category("lod.Graphics.QualityOption")
@ConfigEntry.Gui.Tooltip
@Category("client.graphics.quality")
@Entry
public static VerticalQuality verticalQuality = IQuality.VERTICAL_QUALITY_DEFAULT;
@ConfigEntry.Category("lod.Graphics.QualityOption")
@ConfigEntry.Gui.Tooltip
@Category("client.graphics.quality")
@Entry
public static HorizontalScale horizontalScale = IQuality.HORIZONTAL_SCALE_DEFAULT;
@ConfigEntry.Category("lod.Graphics.QualityOption")
@ConfigEntry.Gui.Tooltip
@Category("client.graphics.quality")
@Entry
public static HorizontalQuality horizontalQuality = IQuality.HORIZONTAL_QUALITY_DEFAULT;
}
public static class FogQuality
{
@ConfigEntry.Category("lod.Graphics.FogQualityOption")
@ConfigEntry.Gui.Tooltip
@Category("client.graphics.fogQuality")
@Entry
public static FogDistance fogDistance = IFogQuality.FOG_DISTANCE_DEFAULT;
@ConfigEntry.Category("lod.Graphics.FogQualityOption")
@ConfigEntry.Gui.Tooltip
@Category("client.graphics.fogQuality")
@Entry
public static FogDrawMode fogDrawMode = IFogQuality.FOG_DRAW_MODE_DEFAULT;
@ConfigEntry.Category("lod.Graphics.FogQualityOption")
@ConfigEntry.Gui.Tooltip
@Category("client.graphics.fogQuality")
@Entry
public static FogColorMode fogColorMode = IFogQuality.FOG_COLOR_MODE_DEFAULT;
@ConfigEntry.Category("lod.Graphics.FogQualityOption")
@ConfigEntry.Gui.Tooltip
@Category("client.graphics.fogQuality")
@Entry
public static boolean disableVanillaFog = IFogQuality.DISABLE_VANILLA_FOG_DEFAULT;
}
public static class AdvancedGraphics
{
@ConfigEntry.Category("lod.Graphics.AdvancedGraphicsOption")
@ConfigEntry.Gui.Tooltip
@Category("client.graphics.advancedGraphics")
@Entry
public static LodTemplate lodTemplate = IAdvancedGraphics.LOD_TEMPLATE_DEFAULT;
@ConfigEntry.Category("lod.Graphics.AdvancedGraphicsOption")
@ConfigEntry.Gui.Tooltip
@Category("client.graphics.advancedGraphics")
@Entry
public static boolean disableDirectionalCulling = IAdvancedGraphics.DISABLE_DIRECTIONAL_CULLING_DEFAULT;
@ConfigEntry.Category("lod.Graphics.AdvancedGraphicsOption")
@ConfigEntry.Gui.Tooltip
@Category("client.graphics.advancedGraphics")
@Entry
public static boolean alwaysDrawAtMaxQuality = IAdvancedGraphics.ALWAYS_DRAW_AT_MAD_QUALITY_DEFAULT;
@ConfigEntry.Category("lod.Graphics.AdvancedGraphicsOption")
@ConfigEntry.Gui.Tooltip
@Category("client.graphics.advancedGraphics")
@Entry
public static VanillaOverdraw vanillaOverdraw = IAdvancedGraphics.VANILLA_OVERDRAW_DEFAULT;
@ConfigEntry.Category("lod.Graphics.AdvancedGraphicsOption")
@ConfigEntry.Gui.Tooltip
@Category("client.graphics.advancedGraphics")
@Entry
public static boolean useExtendedNearClipPlane = IAdvancedGraphics.USE_EXTENDED_NEAR_CLIP_PLANE_DEFAULT;
}
}
//========================//
// WorldGenerator Configs //
//========================//
public static class WorldGenerator
{
@ConfigEntry.Category("lod.WorldGenerator")
@ConfigEntry.Gui.Tooltip
@Category("client.worldGenerator")
@Entry
public static GenerationPriority generationPriority = IWorldGenerator.GENERATION_PRIORITY_DEFAULT;
@ConfigEntry.Category("lod.WorldGenerator")
@ConfigEntry.Gui.Tooltip
@Category("client.worldGenerator")
@Entry
public static DistanceGenerationMode distanceGenerationMode = IWorldGenerator.DISTANCE_GENERATION_MODE_DEFAULT;
@ConfigEntry.Category("lod.WorldGenerator")
@ConfigEntry.Gui.Tooltip
@Category("client.worldGenerator")
@Entry
public static boolean allowUnstableFeatureGeneration = IWorldGenerator.ALLOW_UNSTABLE_FEATURE_GENERATION_DEFAULT;
@ConfigEntry.Category("lod.WorldGenerator")
@ConfigEntry.Gui.Tooltip
@Category("client.worldGenerator")
@Entry
public static BlocksToAvoid blocksToAvoid = IWorldGenerator.BLOCKS_TO_AVOID_DEFAULT;
/*
@ConfigEntry.Category("lod.WorldGenerator")
@ConfigEntry.Gui.Tooltip
public static boolean useExperimentalPreGenLoading = false;
*/
// public static boolean useExperimentalPreGenLoading = false;
}
//==================//
// Advanced Configs //
//==================//
public static class Advanced
{
@ConfigEntry.Gui.CollapsibleObject
public Threading threading = new Threading();
@Category("client.advanced")
@ScreenEntry(to = "threading")
public static ScreenEntry threading;
@ConfigEntry.Gui.CollapsibleObject
public Debugging debugging = new Debugging();
@Category("client.advanced")
@ScreenEntry(to = "debugging")
public static ScreenEntry debugging;
@ConfigEntry.Gui.CollapsibleObject
public Buffers buffers = new Buffers();
@Category("client.advanced")
@ScreenEntry(to = "buffers")
public static ScreenEntry buffers;
public static class Threading
{
@ConfigEntry.Category("lod.AdvancedModOptions.Threading")
@ConfigEntry.Gui.Tooltip
// Find a way to set the max to a variable
@ConfigEntry.BoundedDiscrete(min = 1, max = 50)
@Category("client.advanced.threading")
@Entry(min = 1, max = 50)
public static int numberOfWorldGenerationThreads = IThreading.NUMBER_OF_WORLD_GENERATION_THREADS_DEFAULT.defaultValue;
@ConfigEntry.Category("lod.AdvancedModOptions.Threading")
@ConfigEntry.Gui.Tooltip
// Find a way to set the max to a variable
@ConfigEntry.BoundedDiscrete(min = 1, max = 50)
@Category("client.advanced.threading")
@Entry(min = 1, max = 50)
public static int numberOfBufferBuilderThreads = IThreading.NUMBER_OF_BUFFER_BUILDER_THREADS_MIN_DEFAULT_MAX.defaultValue;
}
//===============//
// Debug Options //
//===============//
public static class Debugging
{
@ConfigEntry.Category("lod.AdvancedModOptions.Debugging")
@ConfigEntry.Gui.Tooltip
@Category("client.advanced.debugging")
@Entry
public static boolean drawLods = IDebugging.DRAW_LODS_DEFAULT;
@ConfigEntry.Category("lod.AdvancedModOptions.Debugging")
@ConfigEntry.Gui.Tooltip
@Category("client.advanced.debugging")
@Entry
public static DebugMode debugMode = IDebugging.DEBUG_MODE_DEFAULT;
@ConfigEntry.Category("lod.AdvancedModOptions.Debugging")
@ConfigEntry.Gui.Tooltip
@Category("client.advanced.debugging")
@Entry
public static boolean enableDebugKeybindings = IDebugging.DEBUG_KEYBINDINGS_ENABLED_DEFAULT;
}
public static class Buffers
{
@ConfigEntry.Category("lod.Graphics.AdvancedGraphicsOption")
@ConfigEntry.Gui.Tooltip
@Category("client.advanced.buffers")
@Entry
public static GpuUploadMethod gpuUploadMethod = IBuffers.GPU_UPLOAD_METHOD_DEFAULT;
@ConfigEntry.Category("lod.Graphics.AdvancedGraphicsOption")
@ConfigEntry.Gui.Tooltip
@ConfigEntry.BoundedDiscrete(min = 0, max = 5000)
@Category("client.advanced.buffers")
@Entry(min = 0, max = 5000)
public static int gpuUploadTimeoutInMilleseconds = IBuffers.GPU_UPLOAD_TIMEOUT_IN_MILLISECONDS_DEFAULT.defaultValue;
@ConfigEntry.Category("lod.AdvancedModOptions.Buffers")
@ConfigEntry.Gui.Tooltip
@Category("client.advanced.buffers")
@Entry
public static BufferRebuildTimes rebuildTimes = IBuffers.REBUILD_TIMES_DEFAULT;
}
}
@@ -1,4 +1,4 @@
package com.seibel.lod.fabric.wrappers.config;
package com.seibel.lod.common.wrappers.config;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
@@ -6,11 +6,9 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mojang.blaze3d.vertex.PoseStack;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.fabric.Config;
import jdk.dynalink.beans.StaticClass;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.loader.api.FabricLoader;
//import net.fabricmc.api.EnvType;
//import net.fabricmc.api.Environment;
//import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
@@ -43,27 +41,27 @@ import java.util.function.Predicate;
import java.util.regex.Pattern;
/**
* Handles the configs gui
* Based upon MidnightConfig
* https://github.com/TeamMidnightDust/MidnightLib/blob/main/src/main/java/eu/midnightdust/lib/config/
* which is based upon TinyConfig
* https://github.com/Minenash/TinyConfig
*
* Credits to Minenash, TeamMidnightDust & Motschen
* Credits to Motschen
*
* @author coolGi2007
* @version 12-03-2021
* @version 12-06-2021
*/
// Everything required is packed into 1 class, so it is easier to copy
// This config should work for both Fabric and Forge as long as you use Mojang mappings
@SuppressWarnings("unchecked")
public abstract class ConfigGui {
/*
Small wiki on how to use this config
Create a new class that extends this class
Every time you want to add a button put a @Entry before it and if you want it to be within a range then do @Entry(min = 0, max = 10)
Every time you want to add a button put an @Entry before it and if you want it to be within a range then do @Entry(min = 0, max = 10)
MAKE SURE THE VARIABLE YOU ARE PUTTING IN IS A STATIC VARIABLE
If you want to make a config asking if you want coolness then do this
public class Config extends ConfigGui {
@@ -71,12 +69,12 @@ public abstract class ConfigGui {
public static bool coolness = false;
}
If you want a comment then do this
@Comment public static Comment text1;
FOR THE CONFIG TO SHOW
you need to have this somewhere in the main class
ConfigGui.init(ModInfo.ID, Config.class);
If you want a comment then do this
@Comment public static Comment ThisIsACoolComment;
For putting nested classes do @ScreenEntry for example
@@ -84,13 +82,29 @@ public abstract class ConfigGui {
@Entry
public static bool coolness = false;
@ScreenEntry
public static NestedScreen nestedScreen = new NestedScreen();
public static void NestedScreen() {
@Category("nestedScreen")
@Entry(min = 0, max = 100)
public static int howMuchCoolness = 0;
}
}
All the text should be in your language file
There won't be a tutorial on how to make on since it is easy
FOR THE CONFIG TO SHOW
you need to have this somewhere in the main class
ConfigGui.init(ModInfo.ID, Config.class);
For mod-menu integration look at the ModMenuIntegration class and put a reference to it in the fabric.mod.json
To make a textured button to the options screen look in the mixins/MixinOptionsScreen class and TexturedButtonWidget class
Remember to add the MixinOptionsScreen to your ModID.mixins.json
*/
private static final Pattern INTEGER_ONLY = Pattern.compile("(-?[0-9]*)");
private static final Pattern DECIMAL_ONLY = Pattern.compile("-?([\\d]+\\.?[\\d]*|[\\d]*\\.?[\\d]+|\\.)");
@@ -110,6 +124,9 @@ public abstract class ConfigGui {
String id;
TranslatableComponent name;
int index;
boolean button = false; // This asks if it is a button to goto a new screen
String gotoScreen = ""; // This is only called if button is true
String category;
}
public static final Map<String,Class<?>> configClass = new HashMap<>();
@@ -118,20 +135,28 @@ public abstract class ConfigGui {
private static final Gson gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT).excludeFieldsWithModifiers(Modifier.PRIVATE).addSerializationExclusionStrategy(new HiddenAnnotationExclusionStrategy()).setPrettyPrinting().create();
public static void init(String modid, Class<?> config) {
path = FabricLoader.getInstance().getConfigDir().resolve(modid + ".json");
path = Minecraft.getInstance().gameDirectory.toPath().resolve("config").resolve(modid + ".json");
configClass.put(modid, config);
for (Field field : config.getFields()) {
EntryInfo info = new EntryInfo();
if (field.isAnnotationPresent(Entry.class) || field.isAnnotationPresent(Comment.class) || field.isAnnotationPresent(ScreenEntry.class))
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) initClient(modid, field, info);
// TODO: Fix the check for client/server
// if (Minecraft.getInstance().getEnvironmentType() == EnvType.CLIENT)
initClient(modid, field, info);
if (field.isAnnotationPresent(Entry.class))
try {
info.defaultValue = field.get(null);
} catch (IllegalAccessException ignored) {}
}
try { gson.fromJson(Files.newBufferedReader(path), config); }
catch (Exception e) { write(modid); }
// File saving stuff
// TODO[CONFIG]: Change to .toml
try {
gson.fromJson(Files.newBufferedReader(path), config);
} catch (Exception e) {
write(modid);
}
for (EntryInfo info : entries) {
if (info.field.isAnnotationPresent(Entry.class))
@@ -142,14 +167,15 @@ public abstract class ConfigGui {
}
}
}
@Environment(EnvType.CLIENT)
private static void initClient(String modid, Field field, EntryInfo info) {
Class<?> type = field.getType();
Category c = field.getAnnotation(Category.class);
Entry e = field.getAnnotation(Entry.class);
ScreenEntry s = field.getAnnotation(ScreenEntry.class);
info.width = e != null ? e.width() : 0;
info.field = field;
info.id = modid;
info.category = c != null ? c.value() : "";
if (e != null) {
if (!e.name().equals(""))
@@ -177,11 +203,10 @@ public abstract class ConfigGui {
}, func);
}
} else if (s != null) {
if (!s.name().equals("")) info.name = new TranslatableComponent(s.name());
Function<Object, Component> func = value -> new TextComponent((Boolean) value ? "True" : "False").withStyle((Boolean) value ? ChatFormatting.GREEN : ChatFormatting.RED);
info.widget = new AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>>(button -> {
button.setMessage(info.name);
}, func);
if (!s.name().equals(""))
info.name = new TranslatableComponent(s.name());
info.button = true;
info.gotoScreen = (info.category != "" ? info.category + "." : "") + s.to();
}
entries.add(info);
}
@@ -219,31 +244,33 @@ public abstract class ConfigGui {
};
}
// TODO[CONFIG]: Change to .toml
// Creates the modid.json
public static void write(String modid) {
path = FabricLoader.getInstance().getConfigDir().resolve(modid + ".json");
path = Minecraft.getInstance().gameDirectory.toPath().resolve("config").resolve(modid + ".json");
try {
if (!Files.exists(path)) Files.createFile(path);
if (!Files.exists(path))
Files.createFile(path);
Files.write(path, gson.toJson(configClass.get(modid).getDeclaredConstructor().newInstance()).getBytes());
} catch (Exception e) {
e.printStackTrace();
}
}
@Environment(EnvType.CLIENT)
public static Screen getScreen(Screen parent, String modid) {
return new ConfigScreen(parent, modid);
public static Screen getScreen(Screen parent, String modid, String category) {
return new ConfigScreen(parent, modid, category);
}
@Environment(EnvType.CLIENT)
private static class ConfigScreen extends Screen {
protected ConfigScreen(Screen parent, String modid) {
protected ConfigScreen(Screen parent, String modid, String category) {
super(new TranslatableComponent(modid + ".config.title"));
this.parent = parent;
this.modid = modid;
this.category = category;
this.translationPrefix = modid + ".config.";
}
private final String translationPrefix;
private final Screen parent;
private final String modid;
private String category;
private ConfigListWidget list;
private boolean reload = false;
@@ -256,8 +283,11 @@ public abstract class ConfigGui {
}
}
private void loadValues() {
try { gson.fromJson(Files.newBufferedReader(path), configClass.get(modid)); }
catch (Exception e) { write(modid); }
try {
gson.fromJson(Files.newBufferedReader(path), configClass.get(modid));
} catch (Exception e) {
write(modid);
}
for (EntryInfo info : entries) {
if (info.field.isAnnotationPresent(Entry.class))
@@ -292,8 +322,8 @@ public abstract class ConfigGui {
if (this.minecraft != null && this.minecraft.level != null) this.list.setRenderBackground(false);
this.addWidget(this.list);
for (EntryInfo info : entries) {
if (info.id.equals(modid)) {
TranslatableComponent name = Objects.requireNonNullElseGet(info.name, () -> new TranslatableComponent(translationPrefix + info.field.getName()));
if (info.id.equals(modid) && info.category.matches(category)) {
TranslatableComponent name = Objects.requireNonNullElseGet(info.name, () -> new TranslatableComponent(translationPrefix + (info.category != "" ? info.category + "." : "") + info.field.getName()));
Button resetButton = new Button(width - 205, 0, 40, 20, new TextComponent("Reset").withStyle(ChatFormatting.RED), (button -> {
info.value = info.defaultValue;
info.tempValue = info.defaultValue.toString();
@@ -306,24 +336,26 @@ public abstract class ConfigGui {
if (info.widget instanceof Map.Entry) {
Map.Entry<Button.OnPress, Function<Object, Component>> widget = (Map.Entry<Button.OnPress, Function<Object, Component>>) info.widget;
if (info.field.getType().isEnum()) widget.setValue(value -> new TranslatableComponent(translationPrefix + "enum." + info.field.getType().getSimpleName() + "." + info.value.toString()));
this.list.addButton(new Button(width - 160, 0,150, 20, widget.getValue().apply(info.value), widget.getKey()),resetButton, null,name);
if (info.field.getType().isEnum())
widget.setValue(value -> new TranslatableComponent(translationPrefix + "enum." + info.field.getType().getSimpleName() + "." + info.value.toString()));
this.list.addButton(new Button(width - 160, 0, 150, 20, widget.getValue().apply(info.value), widget.getKey()), resetButton, null, name);
} else if (info.field.getType() == List.class) {
if (!reload) info.index = 0;
EditBox widget = new EditBox(font, width - 160, 0, 150, 20, null);
widget.setMaxLength(info.width);
if (info.index < ((List<String>)info.value).size()) widget.insertText((String.valueOf(((List<String>)info.value).get(info.index))));
if (info.index < ((List<String>) info.value).size())
widget.insertText((String.valueOf(((List<String>) info.value).get(info.index))));
else widget.insertText("");
Predicate<String> processor = ((BiFunction<EditBox, Button, Predicate<String>>) info.widget).apply(widget, done);
widget.setFilter(processor);
resetButton.setWidth(20);
resetButton.setMessage(new TextComponent("R").withStyle(ChatFormatting.RED));
Button cycleButton = new Button(width - 185, 0, 20, 20, new TextComponent(String.valueOf(info.index)).withStyle(ChatFormatting.GOLD), (button -> {
((List<String>)info.value).remove("");
((List<String>) info.value).remove("");
double scrollAmount = list.getScrollAmount();
this.reload = true;
info.index = info.index + 1;
if (info.index > ((List<String>)info.value).size()) info.index = 0;
if (info.index > ((List<String>) info.value).size()) info.index = 0;
Objects.requireNonNull(minecraft).setScreen(this);
list.setScrollAmount(scrollAmount);
}));
@@ -335,8 +367,13 @@ public abstract class ConfigGui {
Predicate<String> processor = ((BiFunction<EditBox, Button, Predicate<String>>) info.widget).apply(widget, done);
widget.setFilter(processor);
this.list.addButton(widget, resetButton, null, name);
} else if (info.button) {
Button widget = new Button(this.width / 2 - 100, this.height - 28, 200, 20, name, (button -> {
Objects.requireNonNull(minecraft).setScreen(ConfigGui.getScreen(this, ModInfo.ID, info.gotoScreen));
}));
this.list.addButton(widget, null, null, null);
} else {
this.list.addButton(null,null,null,name);
this.list.addButton(null, null, null, name);
}
}
}
@@ -348,13 +385,15 @@ public abstract class ConfigGui {
this.list.render(matrices, mouseX, mouseY, delta);
drawCenteredString(matrices, font, title, width / 2, 15, 0xFFFFFF);
// TODO[CONFIG]: Fix the tooltip
for (EntryInfo info : entries) {
if (info.id.equals(modid)) {
if (info.id.equals(modid) && info.category.matches(category)) {
if (list.getHoveredButton(mouseX,mouseY).isPresent()) {
AbstractWidget buttonWidget = list.getHoveredButton(mouseX,mouseY).get();
Component text = ButtonEntry.buttonsWithText.get(buttonWidget);
TranslatableComponent name = new TranslatableComponent(this.translationPrefix + info.field.getName());
String key = translationPrefix + info.field.getName() + ".tooltip";
// When you fixed the config then add a @ before the tooltip in this line
String key = translationPrefix + info.field.getName() + (info.category != "" ? info.category + "." : "") + ".tooltip";
if (info.error != null && text.equals(name)) renderTooltip(matrices, info.error.getValue(), mouseX, mouseY);
else if (I18n.exists(key) && text.equals(name)) {
@@ -369,7 +408,6 @@ public abstract class ConfigGui {
super.render(matrices,mouseX,mouseY,delta);
}
}
@Environment(EnvType.CLIENT)
public static class ConfigListWidget extends ContainerObjectSelectionList<ButtonEntry> {
Font textRenderer;
@@ -453,9 +491,17 @@ public abstract class ConfigGui {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface ScreenEntry {
String to();
String name() default "";
}
// Where the @Category is defined
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Category {
String value() default "";
}
// Where the @Comment is defined
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@@ -1,9 +1,9 @@
package com.seibel.lod.fabric.wrappers.config;
package com.seibel.lod.common.wrappers.config;
import com.seibel.lod.core.enums.config.*;
import com.seibel.lod.core.enums.rendering.*;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.fabric.Config;
import com.seibel.lod.common.Config;
/**
* This holds the config defaults and setters/getters
@@ -1,11 +1,11 @@
package com.seibel.lod.fabric.wrappers.config;
package com.seibel.lod.common.wrappers.config;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.components.ImageButton;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.client.gui.components.ImageButton;
/**
* Creates a button with a texture on it
@@ -1,68 +1,122 @@
{
"lod.title": "Distant Horizons mod",
"text.autoconfig.lod.title": "Distant Horizons config",
"text.autoconfig.lod.option.client": "Client",
"text.autoconfig.lod.option.client.graphics": "Graphics",
"text.autoconfig.lod.option.client.graphics.quality": "Quality options",
"text.autoconfig.lod.option.client.graphics.quality.drawResolution": "Draw resolution",
"text.autoconfig.lod.option.client.graphics.quality.drawResolution.@Tooltip": "What is the maximum detail fake chunks should be drawn at?",
"text.autoconfig.lod.option.client.graphics.quality.lodChunkRenderDistance": "Chunk render distance",
"text.autoconfig.lod.option.client.graphics.quality.lodChunkRenderDistance.@Tooltip": "The mod's render distance, measured in chunks",
"text.autoconfig.lod.option.client.graphics.quality.verticalQuality": "Vertical quality",
"text.autoconfig.lod.option.client.graphics.quality.verticalQuality.@Tooltip": "This indicates how detailed fake chunks will represent overhangs, caves, floating islands, ect. \nHigher options will use more memory and increase GPU usage",
"text.autoconfig.lod.option.client.graphics.quality.horizontalScale": "Horizontal scale",
"text.autoconfig.lod.option.client.graphics.quality.horizontalScale.@Tooltip": "This indicates how quickly fake chunks drop off in quality",
"text.autoconfig.lod.option.client.graphics.quality.horizontalQuality": "Horizontal quality",
"text.autoconfig.lod.option.client.graphics.quality.horizontalQuality.@Tooltip": "This indicates the exponential base of the quadratic drop-off",
"text.autoconfig.lod.option.client.graphics.fogQuality": "Fog options",
"text.autoconfig.lod.option.client.graphics.fogQuality.fogDistance": "Fog distance",
"text.autoconfig.lod.option.client.graphics.fogQuality.fogDistance.@Tooltip": "At what distance should Fog be drawn on the fake chunks?",
"text.autoconfig.lod.option.client.graphics.fogQuality.fogDrawMode": "Fog draw mode",
"text.autoconfig.lod.option.client.graphics.fogQuality.fogDrawMode.@Tooltip": "When should fog be drawn?",
"text.autoconfig.lod.option.client.graphics.fogQuality.fogColorMode": "Fog color mode",
"text.autoconfig.lod.option.client.graphics.fogQuality.fogColorMode.@Tooltip": "What color should fog use?",
"text.autoconfig.lod.option.client.graphics.fogQuality.disableVanillaFog": "Disable vanilla fog",
"text.autoconfig.lod.option.client.graphics.fogQuality.disableVanillaFog.@Tooltip": "If true disable Minecraft's fog. \nMay cause issues with other mods that edit fog. \nMay cause errors with other fog editing mods",
"text.autoconfig.lod.option.client.graphics.advancedGraphicsOption": "Advanced quality option",
"text.autoconfig.lod.option.client.graphics.advancedGraphicsOption.lodTemplate": "LOD template",
"text.autoconfig.lod.option.client.graphics.advancedGraphicsOption.lodTemplate.@Tooltip": "How should the LODs be drawn? \nNOTE: Currently only CUBIC is implemented!",
"text.autoconfig.lod.option.client.graphics.advancedGraphicsOption.disableDirectionalCulling": "Disable directional culling",
"text.autoconfig.lod.option.client.graphics.advancedGraphicsOption.disableDirectionalCulling.@Tooltip": "If false fake chunks behind the player's camera aren't drawn, increasing performance. \nIf true all LODs are drawn, even those behind the player's camera, decreasing performance",
"text.autoconfig.lod.option.client.graphics.advancedGraphicsOption.alwaysDrawAtMaxQuality": "Always draw at max quality",
"text.autoconfig.lod.option.client.graphics.advancedGraphicsOption.alwaysDrawAtMaxQuality.@Tooltip": "Disable quality falloff, all fake chunks will be drawn at the highest available detail level",
"text.autoconfig.lod.option.client.graphics.advancedGraphicsOption.vanillaOverdraw": "Vanilla overdraw",
"text.autoconfig.lod.option.client.graphics.advancedGraphicsOption.vanillaOverdraw.@Tooltip": "How often should LODs be drawn on top of regular chunks? \nHALF and ALWAYS will prevent holes in the world, but may look odd for transparent blocks or in caves.",
"text.autoconfig.lod.option.client.graphics.advancedGraphicsOption.useExtendedNearClipPlane": "Use extended near clip plane",
"text.autoconfig.lod.option.client.graphics.advancedGraphicsOption.useExtendedNearClipPlane.@Tooltip": "Will prevent some overdraw issues, but may cause nearby fake chunks to render incorrectly especially when in/near an ocean",
"text.autoconfig.lod.option.client.worldGenerator": "World generator",
"text.autoconfig.lod.option.client.worldGenerator.generationPriority": "Generation priority",
"text.autoconfig.lod.option.client.worldGenerator.generationPriority.@Tooltip": "What is the priority of the chunks being generated around the player",
"text.autoconfig.lod.option.client.worldGenerator.distanceGenerationMode": "Distance generation mode",
"text.autoconfig.lod.option.client.worldGenerator.distanceGenerationMode.@Tooltip": "How much of the generation should be used when generating fake chunks",
"text.autoconfig.lod.option.client.worldGenerator.allowUnstableFeatureGeneration": "Allow unstable feature generation",
"text.autoconfig.lod.option.client.worldGenerator.allowUnstableFeatureGeneration.@Tooltip": "Some features may not be thread safe. \nCould cause instability and crashes",
"text.autoconfig.lod.option.client.worldGenerator.blocksToAvoid": "Block to avoid",
"text.autoconfig.lod.option.client.worldGenerator.blocksToAvoid.@Tooltip": "What block to avoid when generating fake chunks",
"text.autoconfig.lod.option.client.advanced": "Advance options",
"text.autoconfig.lod.option.client.advanced.threading": "Threading",
"text.autoconfig.lod.option.client.advanced.threading.numberOfWorldGenerationThreads": "NO. of world generation threads",
"text.autoconfig.lod.option.client.advanced.threading.numberOfWorldGenerationThreads.@Tooltip": "This is how many threads are used when generating LODs outside the normal render distance. \nIf you experience stuttering when generating distant LODs, decrease this number. If you want to increase LOD generation speed, increase this number \nCan only be between 1 and your current number of threads",
"text.autoconfig.lod.option.client.advanced.threading.numberOfBufferBuilderThreads": "NO. of buffer builder threads",
"text.autoconfig.lod.option.client.advanced.threading.numberOfBufferBuilderThreads.@Tooltip": "This is how many threads are used when building vertex buffers (The things sent to your GPU to draw the fake chunks) \nCan only be between 1 and your current number of threads",
"text.autoconfig.lod.option.client.advanced.buffers": "Buffers",
"text.autoconfig.lod.option.client.advanced.buffers.gpuUploadMethod": "GPU upload method",
"text.autoconfig.lod.option.client.advanced.buffers.gpuUploadMethod.@Tooltip": "What method should be used to upload geometry to the GPU?",
"text.autoconfig.lod.option.client.advanced.buffers.gpuUploadTimeoutInMilleseconds": "GPU upload timeout (milliseconds)",
"text.autoconfig.lod.option.client.advanced.buffers.gpuUploadTimeoutInMilleseconds.@Tooltip": "How long should we wait before uploading a buffer to the GPU? \nHelpful resource for frame times: https://fpstoms.com",
"text.autoconfig.lod.option.client.advanced.buffers.rebuildTimes": "Rebuild times",
"text.autoconfig.lod.option.client.advanced.buffers.rebuildTimes.@Tooltip": "Rebuild times",
"text.autoconfig.lod.option.client.advanced.debugging": "Debug",
"text.autoconfig.lod.option.client.advanced.debugging.drawLods": "Draw LOD's",
"text.autoconfig.lod.option.client.advanced.debugging.drawLods.@Tooltip": "If true, the mod is enabled and fake chunks will be drawn.",
"text.autoconfig.lod.option.client.advanced.debugging.debugMode": "Debug mode",
"text.autoconfig.lod.option.client.advanced.debugging.debugMode.@Tooltip": "What type of debug mode do you want",
"text.autoconfig.lod.option.client.advanced.debugging.enableDebugKeybindings": "Enable debug keybindings",
"text.autoconfig.lod.option.client.advanced.debugging.enableDebugKeybindings.@Tooltip": "Enable debug keybindings to change the Debug mode on the fly in game",
"lod.title": "Distant Horizons",
"lod.config.title": "Distant Horizons config",
"lod.config.client": "Client",
"lod.config.client.graphics": "Graphics",
"lod.config.client.graphics.quality": "Quality options",
"lod.config.client.graphics.quality.drawResolution": "Draw resolution",
"lod.config.client.graphics.quality.drawResolution.@tooltip": "What is the maximum detail fake chunks should be drawn at?",
"lod.config.client.graphics.quality.lodChunkRenderDistance": "Chunk render distance",
"lod.config.client.graphics.quality.lodChunkRenderDistance.@tooltip": "The mod's render distance, measured in chunks",
"lod.config.client.graphics.quality.verticalQuality": "Vertical quality",
"lod.config.client.graphics.quality.verticalQuality.@tooltip": "This indicates how detailed fake chunks will represent overhangs, caves, floating islands, ect. \nHigher options will use more memory and increase GPU usage",
"lod.config.client.graphics.quality.horizontalScale": "Horizontal scale",
"lod.config.client.graphics.quality.horizontalScale.@tooltip": "This indicates how quickly fake chunks drop off in quality",
"lod.config.client.graphics.quality.horizontalQuality": "Horizontal quality",
"lod.config.client.graphics.quality.horizontalQuality.@tooltip": "This indicates the exponential base of the quadratic drop-off",
"lod.config.client.graphics.fogQuality": "Fog options",
"lod.config.client.graphics.fogQuality.fogDistance": "Fog distance",
"lod.config.client.graphics.fogQuality.fogDistance.@tooltip": "At what distance should Fog be drawn on the fake chunks?",
"lod.config.client.graphics.fogQuality.fogDrawMode": "Fog draw mode",
"lod.config.client.graphics.fogQuality.fogDrawMode.@tooltip": "When should fog be drawn?",
"lod.config.client.graphics.fogQuality.fogColorMode": "Fog color mode",
"lod.config.client.graphics.fogQuality.fogColorMode.@tooltip": "What color should fog use?",
"lod.config.client.graphics.fogQuality.disableVanillaFog": "Disable vanilla fog",
"lod.config.client.graphics.fogQuality.disableVanillaFog.@tooltip": "If true disable Minecraft's fog. \nMay cause issues with other mods that edit fog. \nMay cause errors with other fog editing mods",
"lod.config.client.graphics.advancedGraphics": "Advanced quality option",
"lod.config.client.graphics.advancedGraphics.lodTemplate": "LOD template",
"lod.config.client.graphics.advancedGraphics.lodTemplate.@tooltip": "How should the LODs be drawn? \nNOTE: Currently only CUBIC is implemented!",
"lod.config.client.graphics.advancedGraphics.disableDirectionalCulling": "Disable directional culling",
"lod.config.client.graphics.advancedGraphics.disableDirectionalCulling.@tooltip": "If false fake chunks behind the player's camera aren't drawn, increasing performance. \nIf true all LODs are drawn, even those behind the player's camera, decreasing performance",
"lod.config.client.graphics.advancedGraphics.alwaysDrawAtMaxQuality": "Always draw at max quality",
"lod.config.client.graphics.advancedGraphics.alwaysDrawAtMaxQuality.@tooltip": "Disable quality falloff, all fake chunks will be drawn at the highest available detail level",
"lod.config.client.graphics.advancedGraphics.vanillaOverdraw": "Vanilla overdraw",
"lod.config.client.graphics.advancedGraphics.vanillaOverdraw.@tooltip": "How often should LODs be drawn on top of regular chunks? \nHALF and ALWAYS will prevent holes in the world, but may look odd for transparent blocks or in caves.",
"lod.config.client.graphics.advancedGraphics.useExtendedNearClipPlane": "Use extended near clip plane",
"lod.config.client.graphics.advancedGraphics.useExtendedNearClipPlane.@tooltip": "Will prevent some overdraw issues, but may cause nearby fake chunks to render incorrectly especially when in/near an ocean",
"lod.config.client.worldGenerator": "World generator",
"lod.config.client.worldGenerator.generationPriority": "Generation priority",
"lod.config.client.worldGenerator.generationPriority.@tooltip": "What is the priority of the chunks being generated around the player",
"lod.config.client.worldGenerator.distanceGenerationMode": "Distance generation mode",
"lod.config.client.worldGenerator.distanceGenerationMode.@tooltip": "How much of the generation should be used when generating fake chunks",
"lod.config.client.worldGenerator.allowUnstableFeatureGeneration": "Allow unstable feature generation",
"lod.config.client.worldGenerator.allowUnstableFeatureGeneration.@tooltip": "Some features may not be thread safe. \nCould cause instability and crashes",
"lod.config.client.worldGenerator.blocksToAvoid": "Block to avoid",
"lod.config.client.worldGenerator.blocksToAvoid.@tooltip": "What block to avoid when generating fake chunks",
"lod.config.client.advanced": "Advance options",
"lod.config.client.advanced.threading": "Threading",
"lod.config.client.advanced.threading.numberOfWorldGenerationThreads": "NO. of world generation threads",
"lod.config.client.advanced.threading.numberOfWorldGenerationThreads.@tooltip": "This is how many threads are used when generating LODs outside the normal render distance. \nIf you experience stuttering when generating distant LODs, decrease this number. If you want to increase LOD generation speed, increase this number \nCan only be between 1 and your current number of threads",
"lod.config.client.advanced.threading.numberOfBufferBuilderThreads": "NO. of buffer builder threads",
"lod.config.client.advanced.threading.numberOfBufferBuilderThreads.@tooltip": "This is how many threads are used when building vertex buffers (The things sent to your GPU to draw the fake chunks) \nCan only be between 1 and your current number of threads",
"lod.config.client.advanced.buffers": "Buffers",
"lod.config.client.advanced.buffers.gpuUploadMethod": "GPU upload method",
"lod.config.client.advanced.buffers.gpuUploadMethod.@tooltip": "What method should be used to upload geometry to the GPU?",
"lod.config.client.advanced.buffers.gpuUploadTimeoutInMilleseconds": "GPU upload timeout (milliseconds)",
"lod.config.client.advanced.buffers.gpuUploadTimeoutInMilleseconds.@tooltip": "How long should we wait before uploading a buffer to the GPU? \nHelpful resource for frame times: https://fpstoms.com",
"lod.config.client.advanced.buffers.rebuildTimes": "Rebuild times",
"lod.config.client.advanced.buffers.rebuildTimes.@tooltip": "Rebuild times",
"lod.config.client.advanced.debugging": "Debug",
"lod.config.client.advanced.debugging.drawLods": "Draw LOD's",
"lod.config.client.advanced.debugging.drawLods.@tooltip": "If true, the mod is enabled and fake chunks will be drawn.",
"lod.config.client.advanced.debugging.debugMode": "Debug mode",
"lod.config.client.advanced.debugging.debugMode.@tooltip": "What type of debug mode do you want",
"lod.config.client.advanced.debugging.enableDebugKeybindings": "Enable debug keybindings",
"lod.config.client.advanced.debugging.enableDebugKeybindings.@tooltip": "Enable debug keybindings to change the Debug mode on the fly in game",
"lod.config.enum.HorizontalResolution.BLOCK": "Block",
"lod.config.enum.HorizontalResolution.TWO_BLOCKS": "2 blocks",
"lod.config.enum.HorizontalResolution.FOUR_BLOCKS": "4 blocks",
"lod.config.enum.HorizontalResolution.HALF_CHUNK": "Half a chunk",
"lod.config.enum.HorizontalResolution.CHUNK": "Chunk",
"lod.config.enum.VerticalQuality.LOW": "Low",
"lod.config.enum.VerticalQuality.MEDIUM": "Medium",
"lod.config.enum.VerticalQuality.HIGH": "High",
"lod.config.enum.HorizontalScale.LOW": "Low",
"lod.config.enum.HorizontalScale.MEDIUM": "Medium",
"lod.config.enum.HorizontalScale.HIGH": "High",
"lod.config.enum.HorizontalQuality.LOWEST": "Lowest",
"lod.config.enum.HorizontalQuality.LOW": "Low",
"lod.config.enum.HorizontalQuality.MEDIUM": "Medium",
"lod.config.enum.HorizontalQuality.HIGH": "High",
"lod.config.enum.FogDistance.NEAR": "Near",
"lod.config.enum.FogDistance.FAR": "Far",
"lod.config.enum.FogDistance.NEAR_AND_FAR": "Near and far",
"lod.config.enum.FogDrawMode.USE_OPTIFINE_SETTING": "Use modded settings",
"lod.config.enum.FogDrawMode.FOG_ENABLED": "Fog enabled",
"lod.config.enum.FogDrawMode.FOG_DISABLED": "Fog disabled",
"lod.config.enum.FogColorMode.USE_WORLD_FOG_COLOR": "Use world fog",
"lod.config.enum.FogColorMode.USE_SKY_COLOR": "Use sky color",
"lod.config.enum.LodTemplate.CUBIC": "Cubic",
"lod.config.enum.LodTemplate.TRIANGULAR": "Triangular",
"lod.config.enum.LodTemplate.DYNAMIC": "Dynamic",
"lod.config.enum.VanillaOverdraw.NEVER": "Never",
"lod.config.enum.VanillaOverdraw.DYNAMIC": "Dynamic",
"lod.config.enum.VanillaOverdraw.ALWAYS": "Always",
"lod.config.enum.VanillaOverdraw.BORDER": "Border",
"lod.config.enum.GenerationPriority.AUTO": "Auto",
"lod.config.enum.GenerationPriority.NEAR_FIRST": "Near first",
"lod.config.enum.GenerationPriority.FAR_FIRST": "Far first",
"lod.config.enum.DistanceGenerationMode.NONE": "None",
"lod.config.enum.DistanceGenerationMode.BIOME_ONLY": "Biome only",
"lod.config.enum.DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT": "Biome only simulate height",
"lod.config.enum.DistanceGenerationMode.SURFACE": "Surface",
"lod.config.enum.DistanceGenerationMode.FEATURES": "Features",
"lod.config.enum.DistanceGenerationMode.FULL": "Full",
"lod.config.enum.BlocksToAvoid.NONE": "None",
"lod.config.enum.BlocksToAvoid.NON_FULL": "Non full",
"lod.config.enum.BlocksToAvoid.NO_COLLISION": "No collision",
"lod.config.enum.BlocksToAvoid.BOTH": "Both",
"lod.config.enum.DebugMode.OFF": "Off",
"lod.config.enum.DebugMode.SHOW_DETAIL": "Show detail",
"lod.config.enum.DebugMode.SHOW_DETAIL_WIREFRAME": "Show detail with wireframe",
"lod.config.enum.GpuUploadMethod.AUTO": "Auto",
"lod.config.enum.GpuUploadMethod.BUFFER_STORAGE": "Buffer storage",
"lod.config.enum.GpuUploadMethod.SUB_DATA": "Sub data",
"lod.config.enum.GpuUploadMethod.BUFFER_MAPPING": "Buffer mapping",
"lod.config.enum.GpuUploadMethod.DATA": "Data",
"lod.config.enum.BufferRebuildTimes.FREQUENT": "Frequent",
"lod.config.enum.BufferRebuildTimes.NORMAL": "Normal",
"lod.config.enum.BufferRebuildTimes.RARE": "Rare",
"toast.lod.title": "Distant Horizons",
"key.lod.category": "Distant Horizons",
"key.lod.DebugToggle": "Debug toggle",
+1 -7
View File
@@ -18,8 +18,7 @@ configurations {
}
repositories {
// Required for ModMenu and ClothAPI
maven { url "https://maven.shedaniel.me/" }
// Required for ModMenu
maven { url "https://maven.terraformersmc.com/" }
}
@@ -36,11 +35,6 @@ dependencies {
exclude(group: "net.fabricmc.fabric-api")
}
// Cloth Config (including Auto Config)
modApi("me.shedaniel.cloth:cloth-config-fabric:5.0.38") {
exclude(group: "net.fabricmc.fabric-api")
}
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowMe(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
@@ -19,8 +19,8 @@
package com.seibel.lod.fabric;
import com.seibel.lod.common.Config;
import com.seibel.lod.core.api.EventApi;
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
import com.seibel.lod.common.wrappers.world.DimensionTypeWrapper;
import com.seibel.lod.common.wrappers.world.WorldWrapper;
@@ -33,7 +33,6 @@ import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents;
import net.minecraft.client.KeyMapping;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.BlockEventData;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.chunk.LevelChunk;
@@ -19,16 +19,14 @@
package com.seibel.lod.fabric;
import com.seibel.lod.common.Config;
import com.seibel.lod.common.LodCommonMain;
import com.seibel.lod.common.wrappers.config.ConfigGui;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.core.api.ClientApi;
import com.seibel.lod.fabric.wrappers.DependencySetup;
import com.seibel.lod.fabric.wrappers.config.ConfigGui;
import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
/**
* Initialize and setup the Mod. <br>
@@ -48,8 +46,6 @@ public class Main implements ClientModInitializer
public static ClientProxy client_proxy;
public static final Config CONFIG = AutoConfig.register(Config.class, Toml4jConfigSerializer::new).getConfig();
// Do if implements ClientModInitializer
// This loads the mod before minecraft loads which causes a lot of issues
@@ -60,7 +56,7 @@ public class Main implements ClientModInitializer
// This loads the mod after minecraft loads which doesn't causes a lot of issues
public static void init() {
// ConfigGui.init(ModInfo.ID, Config.class);
initConfig();
LodCommonMain.startup(null);
DependencySetup.createInitialBindings();
ClientApi.LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION);
@@ -69,4 +65,19 @@ public class Main implements ClientModInitializer
client_proxy = new ClientProxy();
client_proxy.registerEvents();
}
// TODO[CONFIG]: Find a better way to initialise everything
private static void initConfig() {
ConfigGui.init(ModInfo.ID, Config.class);
ConfigGui.init(ModInfo.ID, Config.Client.class);
ConfigGui.init(ModInfo.ID, Config.Client.Graphics.class);
ConfigGui.init(ModInfo.ID, Config.Client.Graphics.Quality.class);
ConfigGui.init(ModInfo.ID, Config.Client.Graphics.FogQuality.class);
ConfigGui.init(ModInfo.ID, Config.Client.Graphics.AdvancedGraphics.class);
ConfigGui.init(ModInfo.ID, Config.Client.WorldGenerator.class);
ConfigGui.init(ModInfo.ID, Config.Client.Advanced.class);
ConfigGui.init(ModInfo.ID, Config.Client.Advanced.Threading.class);
ConfigGui.init(ModInfo.ID, Config.Client.Advanced.Debugging.class);
ConfigGui.init(ModInfo.ID, Config.Client.Advanced.Buffers.class);
}
}
@@ -1,10 +1,8 @@
package com.seibel.lod.fabric.mixins;
import com.seibel.lod.common.wrappers.config.ConfigGui;
import com.seibel.lod.common.wrappers.config.TexturedButtonWidget;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.fabric.Config;
import com.seibel.lod.fabric.wrappers.config.TexturedButtonWidget;
import me.shedaniel.autoconfig.AutoConfig;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.gui.screens.OptionsScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
@@ -43,8 +41,7 @@ public class MixinOptionsScreen extends Screen {
// Some textuary stuff
20, ICON_TEXTURE, 20, 40,
// Create the button and tell it where to go
(buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(AutoConfig.getConfigScreen(Config.class, this).get()),
// (buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(Config.getScreen(this, ModInfo.ID)),
(buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(ConfigGui.getScreen(this, ModInfo.ID, "")),
// Add a title to the screen
new TranslatableComponent("text.autoconfig." + ModInfo.ID + ".title")));
}
@@ -48,42 +48,6 @@ import net.minecraft.client.renderer.RenderType;
@Mixin(LevelRenderer.class)
public class MixinWorldRenderer
{
/*
private static float previousPartialTicks = 0;
@Inject(at = @At("RETURN"), method = "renderClouds")
private void renderClouds(PoseStack poseStack, Matrix4f matrix4f, float f, double d, double e, double g, CallbackInfo ci)
// private void renderClouds(PoseStack matrixStackIn, float partialTicks, CallbackInfo callback)
{
// get the partial ticks since renderBlockLayer doesn't
// have access to them
previousPartialTicks = f;
}
@Inject(at = @At("HEAD"), method = "renderChunkLayer")
private void renderChunkLayer(RenderType renderType, PoseStack matrixStackIn, double d, double e, double f, Matrix4f matrix4f, CallbackInfo ci)
{
// only render if LODs are enabled and
// only render before solid blocks
if (renderType.equals(RenderType.solid()))
{
// get MC's current projection matrix
float[] mcProjMatrixRaw = new float[16];
GL15.glGetFloatv(GL15.GL_PROJECTION_MATRIX, mcProjMatrixRaw);
Mat4f mcProjectionMatrix = new Mat4f(mcProjMatrixRaw);
// OpenGl outputs their matrices in col,row form instead of row,col
// (or maybe vice versa I have no idea :P)
mcProjectionMatrix.transpose();
Mat4f mcModelViewMatrix = McObjectConverter.Convert(matrixStackIn.last().pose());
ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
}
}
*/
private static float previousPartialTicks = 0;
@Inject(at = @At("RETURN"), method = "renderClouds(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/math/Matrix4f;FDDD)V")
@@ -2,7 +2,7 @@ package com.seibel.lod.fabric.wrappers;
import com.seibel.lod.core.util.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.fabric.wrappers.config.LodConfigWrapperSingleton;
import com.seibel.lod.common.wrappers.config.LodConfigWrapperSingleton;
/**
* Binds all necessary dependencies, so we
@@ -1,9 +1,10 @@
package com.seibel.lod.fabric.wrappers.config;
import com.seibel.lod.fabric.Config;
import com.seibel.lod.common.wrappers.config.ConfigGui;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.common.Config;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import me.shedaniel.autoconfig.AutoConfig;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@@ -15,23 +16,16 @@ import java.util.Map;
*/
@Environment(EnvType.CLIENT)
public class ModMenuIntegration implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> AutoConfig.getConfigScreen(Config.class, parent).get();
}
// For the custom config code
/*
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> Config.getScreen(parent, ModInfo.ID);
return parent -> Config.getScreen(parent, ModInfo.ID, "");
}
@Override
public Map<String, ConfigScreenFactory<?>> getProvidedConfigScreenFactories() {
HashMap<String, ConfigScreenFactory<?>> map = new HashMap<>();
Config.configClass.forEach((modid, cClass) -> map.put(modid, parent -> ConfigGui.getScreen(parent, modid)));
Config.configClass.forEach((modid, cClass) -> map.put(modid, parent -> ConfigGui.getScreen(parent, modid, "")));
return map;
}
*/
}
+1 -3
View File
@@ -39,9 +39,7 @@
"fabricloader": ">=0.11.3",
"fabric": "*",
"minecraft": "1.17.x",
"java": ">=16",
"modmenu": ">=2.0.14",
"cloth-config2": ">=5.0.38"
"java": ">=16"
},
"suggests": {
"another-mod": "*"
@@ -1,101 +0,0 @@
/*
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
* licensed under the GNU GPL v3 License.
*
* Copyright (C) 2020 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.lod;
import com.seibel.lod.common.LodCommonMain;
import com.seibel.lod.common.forge.LodForgeMethodCaller;
import com.seibel.lod.common.wrappers.minecraft.MinecraftWrapper;
import com.seibel.lod.forge.ForgeClientProxy;
import com.seibel.lod.forge.ForgeConfig;
import com.seibel.lod.forge.wrappers.ForgeDependencySetup;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.data.ModelDataMap;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fmlserverevents.FMLServerStartedEvent;
import java.util.List;
import java.util.Random;
/**
* Initialize and setup the Mod.
* <br>
* If you are looking for the real start of the mod
* check out the ClientProxy.
*
* @author James Seibel
* @version 7-3-2021
*/
@Mod(ModInfo.ID)
public class LodMain implements LodForgeMethodCaller
{
public static LodMain instance;
public static ForgeClientProxy client_proxy;
private void init(final FMLCommonSetupEvent event)
{
LodCommonMain.startup(this);
ForgeDependencySetup.createInitialBindings();
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ForgeConfig.CLIENT_SPEC);
}
public LodMain()
{
// Register the methods
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::init);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onClientStart);
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
}
private void onClientStart(final FMLClientSetupEvent event)
{
client_proxy = new ForgeClientProxy();
MinecraftForge.EVENT_BUS.register(client_proxy);
}
@SubscribeEvent
public void onServerStarting(FMLServerStartedEvent event)
{
// this is called when the server starts
}
private ModelDataMap dataMap = new ModelDataMap.Builder().build();
@Override
public List<BakedQuad> getQuads(MinecraftWrapper mc, Block block, BlockState blockState, Direction direction, Random random) {
return mc.getModelManager().getBlockModelShaper().getBlockModel(block.defaultBlockState()).getQuads(blockState, direction, random, dataMap);
}
}
@@ -1,35 +0,0 @@
/*
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
* licensed under the GNU GPL v3 License.
*
* Copyright (C) 2020 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.lod;
/**
* This file is similar to mcmod.info
* @author James Seibel
* @version 10-23-2021
*/
public final class ModInfo
{
public static final String ID = "lod";
public static final String NAME = "DistantHorizons";
/** Human readable version of MOD_NAME */
public static final String READABLE_NAME = "Distant Horizons";
public static final String API = "LodAPI";
public static final String VERSION = "1.5.3a";
}
@@ -1,454 +0,0 @@
/*
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
* licensed under the GNU GPL v3 License.
*
* Copyright (C) 2020 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.lod.forge;
import java.nio.file.Path;
import java.nio.file.Paths;
import net.minecraftforge.fml.event.config.ModConfigEvent;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager;
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
import com.electronwill.nightconfig.core.io.WritingMode;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.core.enums.config.BlocksToAvoid;
import com.seibel.lod.core.enums.config.BufferRebuildTimes;
import com.seibel.lod.core.enums.config.DistanceGenerationMode;
import com.seibel.lod.core.enums.config.GenerationPriority;
import com.seibel.lod.core.enums.config.GpuUploadMethod;
import com.seibel.lod.core.enums.config.HorizontalQuality;
import com.seibel.lod.core.enums.config.HorizontalResolution;
import com.seibel.lod.core.enums.config.HorizontalScale;
import com.seibel.lod.core.enums.config.LodTemplate;
import com.seibel.lod.core.enums.config.VanillaOverdraw;
import com.seibel.lod.core.enums.config.VerticalQuality;
import com.seibel.lod.core.enums.rendering.DebugMode;
import com.seibel.lod.core.enums.rendering.FogColorMode;
import com.seibel.lod.core.enums.rendering.FogDistance;
import com.seibel.lod.core.enums.rendering.FogDrawMode;
import com.seibel.lod.core.objects.MinDefaultMax;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IAdvanced;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IAdvanced.IBuffers;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IAdvanced.IDebugging;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IAdvanced.IThreading;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics.IAdvancedGraphics;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics.IFogQuality;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics.IQuality;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IWorldGenerator;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
/**
* This handles any configuration the user has access to.
* @author Leonardo Amato
* @author James Seibel
* @version 12-1-2021
*/
@Mod.EventBusSubscriber
public class ForgeConfig
{
// CONFIG STRUCTURE
// -> Client
// |
// |-> Graphics
// | |-> Quality
// | |-> FogQuality
// | |-> AdvancedGraphics
// |
// |-> World Generation
// |
// |-> Advanced
// |-> Threads
// |-> Buffers
// |-> Debugging
public static class Client
{
public final Graphics graphics;
public final WorldGenerator worldGenerator;
public final Advanced advanced;
//================//
// Client Configs //
//================//
public Client(ForgeConfigSpec.Builder builder)
{
builder.push(this.getClass().getSimpleName());
{
graphics = new Graphics(builder);
worldGenerator = new WorldGenerator(builder);
advanced = new Advanced(builder);
}
builder.pop();
}
//==================//
// Graphics Configs //
//==================//
public static class Graphics
{
public final Quality quality;
public final FogQuality fogQuality;
public final AdvancedGraphics advancedGraphics;
Graphics(ForgeConfigSpec.Builder builder)
{
builder.comment(IGraphics.DESC).push("Graphics");
{
quality = new Quality(builder);
advancedGraphics = new AdvancedGraphics(builder);
fogQuality = new FogQuality(builder);
}
builder.pop();
}
public static class Quality
{
public final ForgeConfigSpec.EnumValue<HorizontalResolution> drawResolution;
public final ForgeConfigSpec.IntValue lodChunkRenderDistance;
public final ForgeConfigSpec.EnumValue<VerticalQuality> verticalQuality;
public final ForgeConfigSpec.EnumValue<HorizontalScale> horizontalScale;
public final ForgeConfigSpec.EnumValue<HorizontalQuality> horizontalQuality;
Quality(ForgeConfigSpec.Builder builder)
{
builder.comment(IQuality.DESC).push(this.getClass().getSimpleName());
verticalQuality = builder
.comment("\n\n"
+ IQuality.VERTICAL_QUALITY_DESC)
.defineEnum("Vertical Quality", IQuality.VERTICAL_QUALITY_DEFAULT);
horizontalScale = builder
.comment("\n\n"
+ IQuality.HORIZONTAL_SCALE_DESC)
.defineEnum("Horizontal Scale", IQuality.HORIZONTAL_SCALE_DEFAULT);
horizontalQuality = builder
.comment("\n\n"
+ IQuality.HORIZONTAL_QUALITY_DESC)
.defineEnum("Horizontal Quality", IQuality.HORIZONTAL_QUALITY_DEFAULT);
drawResolution = builder
.comment("\n\n"
+ IQuality.DRAW_RESOLUTION_DESC)
.defineEnum("Block size", IQuality.DRAW_RESOLUTION_DEFAULT);
MinDefaultMax<Integer> minDefaultMax = IQuality.LOD_CHUNK_RENDER_DISTANCE_MIN_DEFAULT_MAX;
lodChunkRenderDistance = builder
.comment("\n\n"
+ IQuality.LOD_CHUNK_RENDER_DISTANCE_DESC)
.defineInRange("Lod Render Distance", minDefaultMax.defaultValue, minDefaultMax.minValue, minDefaultMax.maxValue);
builder.pop();
}
}
public static class FogQuality
{
public final ForgeConfigSpec.EnumValue<FogDistance> fogDistance;
public final ForgeConfigSpec.EnumValue<FogDrawMode> fogDrawMode;
public final ForgeConfigSpec.EnumValue<FogColorMode> fogColorMode;
public final ForgeConfigSpec.BooleanValue disableVanillaFog;
FogQuality(ForgeConfigSpec.Builder builder)
{
builder.comment(IFogQuality.DESC).push(this.getClass().getSimpleName());
fogDistance = builder
.comment("\n\n"
+ IFogQuality.FOG_DISTANCE_DESC)
.defineEnum("Fog Distance", IFogQuality.FOG_DISTANCE_DEFAULT);
fogDrawMode = builder
.comment("\n\n"
+ IFogQuality.FOG_DRAW_MODE_DESC)
.defineEnum("Fog Draw Mode", IFogQuality.FOG_DRAW_MODE_DEFAULT);
fogColorMode = builder
.comment("\n\n"
+ IFogQuality.FOG_COLOR_MODE_DESC)
.defineEnum("Fog Color Mode", IFogQuality.FOG_COLOR_MODE_DEFAULT);
disableVanillaFog = builder
.comment("\n\n"
+ IFogQuality.DISABLE_VANILLA_FOG_DESC)
.define("Experimental Disable Vanilla Fog", IFogQuality.DISABLE_VANILLA_FOG_DEFAULT);
builder.pop();
}
}
public static class AdvancedGraphics
{
public final ForgeConfigSpec.EnumValue<LodTemplate> lodTemplate;
public final ForgeConfigSpec.BooleanValue disableDirectionalCulling;
public final ForgeConfigSpec.BooleanValue alwaysDrawAtMaxQuality;
public final ForgeConfigSpec.EnumValue<VanillaOverdraw> vanillaOverdraw;
public final ForgeConfigSpec.BooleanValue useExtendedNearClipPlane;
AdvancedGraphics(ForgeConfigSpec.Builder builder)
{
builder.comment(IAdvancedGraphics.DESC).push(this.getClass().getSimpleName());
lodTemplate = builder
.comment("\n\n"
+ IAdvancedGraphics.LOD_TEMPLATE_DESC)
.defineEnum("LOD Template", IAdvancedGraphics.LOD_TEMPLATE_DEFAULT);
disableDirectionalCulling = builder
.comment("\n\n"
+ IAdvancedGraphics.DISABLE_DIRECTIONAL_CULLING_DESC)
.define("Disable Directional Culling", IAdvancedGraphics.DISABLE_DIRECTIONAL_CULLING_DEFAULT);
alwaysDrawAtMaxQuality = builder
.comment("\n\n"
+ IAdvancedGraphics.ALWAYS_DRAW_AT_MAD_QUALITY_DESC)
.define("Always Use Max Quality", IAdvancedGraphics.ALWAYS_DRAW_AT_MAD_QUALITY_DEFAULT);
vanillaOverdraw = builder
.comment("\n\n"
+ IAdvancedGraphics.VANILLA_OVERDRAW_DESC)
.defineEnum("Vanilla Overdraw", IAdvancedGraphics.VANILLA_OVERDRAW_DEFAULT);
// This is a temporary fix (like vanilla overdraw)
// hopefully we can remove both once we get individual chunk rendering figured out
useExtendedNearClipPlane = builder
.comment("\n\n"
+ IAdvancedGraphics.USE_EXTENDED_NEAR_CLIP_PLANE_DESC)
.define("Use Extended Near Clip Plane", IAdvancedGraphics.USE_EXTENDED_NEAR_CLIP_PLANE_DEFAULT);
builder.pop();
}
}
}
//========================//
// WorldGenerator Configs //
//========================//
public static class WorldGenerator
{
public final ForgeConfigSpec.EnumValue<GenerationPriority> generationPriority;
public final ForgeConfigSpec.EnumValue<DistanceGenerationMode> distanceGenerationMode;
public final ForgeConfigSpec.BooleanValue allowUnstableFeatureGeneration;
public final ForgeConfigSpec.EnumValue<BlocksToAvoid> blocksToAvoid;
//public final ForgeConfigSpec.BooleanValue useExperimentalPreGenLoading;
WorldGenerator(ForgeConfigSpec.Builder builder)
{
builder.comment(IWorldGenerator.DESC).push("Generation");
generationPriority = builder
.comment("\n\n"
+ IWorldGenerator.GENERATION_PRIORITY_DESC)
.defineEnum("Generation Priority", IWorldGenerator.GENERATION_PRIORITY_DEFAULT);
distanceGenerationMode = builder
.comment("\n\n"
+ IWorldGenerator.DISTANCE_GENERATION_MODE_DESC)
.defineEnum("Distance Generation Mode", IWorldGenerator.DISTANCE_GENERATION_MODE_DEFAULT);
allowUnstableFeatureGeneration = builder
.comment("\n\n"
+ IWorldGenerator.ALLOW_UNSTABLE_FEATURE_GENERATION_DESC)
.define("Allow Unstable Feature Generation", IWorldGenerator.ALLOW_UNSTABLE_FEATURE_GENERATION_DEFAULT);
blocksToAvoid = builder
.comment("\n\n"
+ IWorldGenerator.BLOCKS_TO_AVOID_DESC)
.defineEnum("Blocks to avoid", IWorldGenerator.BLOCKS_TO_AVOID_DEFAULT);
/*useExperimentalPreGenLoading = builder
.comment("\n\n"
+ " if a chunk has been pre-generated, then the mod would use the real chunk for the \n"
+ "fake chunk creation. May require a deletion of the lod file to see the result. \n")
.define("Use pre-generated chunks", false);*/
builder.pop();
}
}
//==================//
// Advanced Configs //
//==================//
public static class Advanced
{
public final Threading threading;
public final Debugging debugging;
public final Buffers buffers;
public Advanced(ForgeConfigSpec.Builder builder)
{
builder.comment(IAdvanced.DESC).push(this.getClass().getSimpleName());
{
threading = new Threading(builder);
debugging = new Debugging(builder);
buffers = new Buffers(builder);
}
builder.pop();
}
public static class Threading
{
public final ForgeConfigSpec.IntValue numberOfWorldGenerationThreads;
public final ForgeConfigSpec.IntValue numberOfBufferBuilderThreads;
Threading(ForgeConfigSpec.Builder builder)
{
builder.comment(IThreading.DESC).push(this.getClass().getSimpleName());
MinDefaultMax<Integer> minDefaultMax = IThreading.NUMBER_OF_WORLD_GENERATION_THREADS_DEFAULT;
numberOfWorldGenerationThreads = builder
.comment("\n\n"
+ IThreading.NUMBER_OF_WORLD_GENERATION_THREADS_DESC)
.defineInRange("numberOfWorldGenerationThreads", minDefaultMax.defaultValue, minDefaultMax.minValue, minDefaultMax.maxValue);
minDefaultMax = IThreading.NUMBER_OF_BUFFER_BUILDER_THREADS_MIN_DEFAULT_MAX;
numberOfBufferBuilderThreads = builder
.comment("\n\n"
+ IThreading.NUMBER_OF_BUFFER_BUILDER_THREADS_MIN_DEFAULT_MAX)
.defineInRange("numberOfBufferBuilderThreads", minDefaultMax.defaultValue, minDefaultMax.minValue, minDefaultMax.maxValue);
builder.pop();
}
}
//===============//
// Debug Options //
//===============//
public static class Debugging
{
public final ForgeConfigSpec.BooleanValue drawLods;
public final ForgeConfigSpec.EnumValue<DebugMode> debugMode;
public final ForgeConfigSpec.BooleanValue enableDebugKeybindings;
Debugging(ForgeConfigSpec.Builder builder)
{
builder.comment(IDebugging.DESC).push(this.getClass().getSimpleName());
drawLods = builder
.comment("\n\n"
+ IDebugging.DRAW_LODS_DESC)
.define("Enable Rendering", IDebugging.DRAW_LODS_DEFAULT);
debugMode = builder
.comment("\n\n"
+ IDebugging.DEBUG_MODE_DESC)
.defineEnum("Debug Mode", IDebugging.DEBUG_MODE_DEFAULT);
enableDebugKeybindings = builder
.comment("\n\n"
+ IDebugging.DEBUG_KEYBINDINGS_ENABLED_DESC)
.define("Enable Debug Keybinding", IDebugging.DEBUG_KEYBINDINGS_ENABLED_DEFAULT);
builder.pop();
}
}
public static class Buffers
{
public final ForgeConfigSpec.EnumValue<GpuUploadMethod> gpuUploadMethod;
public final ForgeConfigSpec.IntValue gpuUploadTimeoutInMilleseconds;
public final ForgeConfigSpec.EnumValue<BufferRebuildTimes> rebuildTimes;
Buffers(ForgeConfigSpec.Builder builder)
{
builder.comment(IBuffers.DESC).push(this.getClass().getSimpleName());
gpuUploadMethod = builder
.comment("\n\n"
+ IBuffers.GPU_UPLOAD_METHOD_DESC)
.defineEnum("GPU Upload Method", IBuffers.GPU_UPLOAD_METHOD_DEFAULT);
MinDefaultMax<Integer> minDefaultMax = IBuffers.GPU_UPLOAD_TIMEOUT_IN_MILLISECONDS_DEFAULT;
gpuUploadTimeoutInMilleseconds = builder
.comment("\n\n"
+ IBuffers.GPU_UPLOAD_TIMEOUT_IN_MILLISECONDS_DESC)
.defineInRange("GPU Upload Timeout in Milleseconds", minDefaultMax.defaultValue, minDefaultMax.minValue, minDefaultMax.maxValue);
rebuildTimes = builder
.comment("\n\n"
+ IBuffers.REBUILD_TIMES_DESC)
.defineEnum("rebuildFrequency", IBuffers.REBUILD_TIMES_DEFAULT);
builder.pop();
}
}
}
}
/** {@link Path} to the configuration file of this mod */
private static final Path CONFIG_PATH = Paths.get("config", ModInfo.NAME + ".toml");
public static final ForgeConfigSpec CLIENT_SPEC;
public static final Client CLIENT;
static
{
final Pair<Client, ForgeConfigSpec> specPair = new ForgeConfigSpec.Builder().configure(Client::new);
CLIENT_SPEC = specPair.getRight();
CLIENT = specPair.getLeft();
CommentedFileConfig clientConfig = CommentedFileConfig.builder(CONFIG_PATH)
.writingMode(WritingMode.REPLACE)
.build();
clientConfig.load();
clientConfig.save();
CLIENT_SPEC.setConfig(clientConfig);
}
@SubscribeEvent
public static void onLoad(final ModConfigEvent.Loading configEvent)
{
LogManager.getLogger().debug(ModInfo.NAME, "Loaded forge config file {}", configEvent.getConfig().getFileName());
}
@SubscribeEvent
public static void onFileChange(final ModConfigEvent.Reloading configEvent)
{
LogManager.getLogger().debug(ModInfo.NAME, "Forge config just got changed on the file system!");
}
}
@@ -19,8 +19,10 @@
package com.seibel.lod.forge;
import com.seibel.lod.common.Config;
import com.seibel.lod.common.LodCommonMain;
import com.seibel.lod.common.forge.LodForgeMethodCaller;
import com.seibel.lod.common.wrappers.config.ConfigGui;
import com.seibel.lod.common.wrappers.minecraft.MinecraftWrapper;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.forge.wrappers.ForgeDependencySetup;
@@ -61,7 +63,9 @@ public class ForgeMain implements LodForgeMethodCaller
// make sure the dependencies are set up before the mod needs them
LodCommonMain.startup(this);
ForgeDependencySetup.createInitialBindings();
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ForgeConfig.CLIENT_SPEC);
initConfig();
// ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ForgeConfig.CLIENT_SPEC);
}
@@ -94,4 +98,19 @@ public class ForgeMain implements LodForgeMethodCaller
public List<BakedQuad> getQuads(MinecraftWrapper mc, Block block, BlockState blockState, Direction direction, Random random) {
return mc.getModelManager().getBlockModelShaper().getBlockModel(block.defaultBlockState()).getQuads(blockState, direction, random, dataMap);
}
// TODO[CONFIG]: Find a better way to initialise everything
private static void initConfig() {
ConfigGui.init(ModInfo.ID, Config.class);
ConfigGui.init(ModInfo.ID, Config.Client.class);
ConfigGui.init(ModInfo.ID, Config.Client.Graphics.class);
ConfigGui.init(ModInfo.ID, Config.Client.Graphics.Quality.class);
ConfigGui.init(ModInfo.ID, Config.Client.Graphics.FogQuality.class);
ConfigGui.init(ModInfo.ID, Config.Client.Graphics.AdvancedGraphics.class);
ConfigGui.init(ModInfo.ID, Config.Client.WorldGenerator.class);
ConfigGui.init(ModInfo.ID, Config.Client.Advanced.class);
ConfigGui.init(ModInfo.ID, Config.Client.Advanced.Threading.class);
ConfigGui.init(ModInfo.ID, Config.Client.Advanced.Debugging.class);
ConfigGui.init(ModInfo.ID, Config.Client.Advanced.Buffers.class);
}
}
@@ -0,0 +1,48 @@
package com.seibel.lod.forge.mixins;
import com.seibel.lod.common.wrappers.config.ConfigGui;
import com.seibel.lod.common.wrappers.config.TexturedButtonWidget;
import com.seibel.lod.core.ModInfo;
import net.minecraft.client.gui.screens.OptionsScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Objects;
/**
* Adds a button to the menu to goto the config
*
* @author coolGi2007
* @version 12-02-2021
*/
@Mixin(OptionsScreen.class)
public class MixinOptionsScreen extends Screen {
// Get the texture for the button
private static final ResourceLocation ICON_TEXTURE = new ResourceLocation(ModInfo.ID,"textures/gui/button.png");
protected MixinOptionsScreen(Component title) {
super(title);
}
@Inject(at = @At("HEAD"),method = "init")
private void lodconfig$init(CallbackInfo ci) {
this.addRenderableWidget(new TexturedButtonWidget(
// Where the button is on the screen
this.width / 2 - 180, this.height / 6 - 12,
// Width and height of the button
20, 20,
// Offset
0, 0,
// Some textuary stuff
20, ICON_TEXTURE, 20, 40,
// Create the button and tell it where to go
(buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(ConfigGui.getScreen(this, ModInfo.ID, "")),
// Add a title to the screen
new TranslatableComponent("text.autoconfig." + ModInfo.ID + ".title")));
}
}
@@ -1,8 +1,8 @@
package com.seibel.lod.forge.wrappers;
import com.seibel.lod.common.wrappers.config.LodConfigWrapperSingleton;
import com.seibel.lod.core.util.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.forge.wrappers.config.LodConfigWrapperSingleton;
/**
* Binds all necessary dependencies so we
@@ -1,516 +0,0 @@
/*
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
* licensed under the GNU GPL v3 License.
*
* Copyright (C) 2020 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.lod.forge.wrappers.config;
import com.seibel.lod.core.enums.config.BlocksToAvoid;
import com.seibel.lod.core.enums.config.BufferRebuildTimes;
import com.seibel.lod.core.enums.config.DistanceGenerationMode;
import com.seibel.lod.core.enums.config.GenerationPriority;
import com.seibel.lod.core.enums.config.GpuUploadMethod;
import com.seibel.lod.core.enums.config.HorizontalQuality;
import com.seibel.lod.core.enums.config.HorizontalResolution;
import com.seibel.lod.core.enums.config.HorizontalScale;
import com.seibel.lod.core.enums.config.LodTemplate;
import com.seibel.lod.core.enums.config.VanillaOverdraw;
import com.seibel.lod.core.enums.config.VerticalQuality;
import com.seibel.lod.core.enums.rendering.DebugMode;
import com.seibel.lod.core.enums.rendering.FogColorMode;
import com.seibel.lod.core.enums.rendering.FogDistance;
import com.seibel.lod.core.enums.rendering.FogDrawMode;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.forge.ForgeConfig;
/**
* @author James Seibel
* @version 11-29-2021
*/
public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
{
public static final LodConfigWrapperSingleton INSTANCE = new LodConfigWrapperSingleton();
private static final Client client = new Client();
@Override
public IClient client()
{
return client;
}
public static class Client implements IClient
{
public final IGraphics graphics;
public final IWorldGenerator worldGenerator;
public final IAdvanced advanced;
@Override
public IGraphics graphics()
{
return graphics;
}
@Override
public IWorldGenerator worldGenerator()
{
return worldGenerator;
}
@Override
public IAdvanced advanced()
{
return advanced;
}
//================//
// Client Configs //
//================//
public Client()
{
graphics = new Graphics();
worldGenerator = new WorldGenerator();
advanced = new Advanced();
}
//==================//
// Graphics Configs //
//==================//
public static class Graphics implements IGraphics
{
public final IQuality quality;
public final IFogQuality fogQuality;
public final IAdvancedGraphics advancedGraphics;
@Override
public IQuality quality()
{
return quality;
}
@Override
public IFogQuality fogQuality()
{
return fogQuality;
}
@Override
public IAdvancedGraphics advancedGraphics()
{
return advancedGraphics;
}
Graphics()
{
quality = new Quality();
advancedGraphics = new AdvancedGraphics();
fogQuality = new FogQuality();
}
public static class Quality implements IQuality
{
@Override
public HorizontalResolution getDrawResolution()
{
return ForgeConfig.CLIENT.graphics.quality.drawResolution.get();
}
@Override
public void setDrawResolution(HorizontalResolution newHorizontalResolution)
{
ForgeConfig.CLIENT.graphics.quality.drawResolution.set(newHorizontalResolution);
}
@Override
public int getLodChunkRenderDistance()
{
return ForgeConfig.CLIENT.graphics.quality.lodChunkRenderDistance.get();
}
@Override
public void setLodChunkRenderDistance(int newLodChunkRenderDistance)
{
ForgeConfig.CLIENT.graphics.quality.lodChunkRenderDistance.set(newLodChunkRenderDistance);
}
@Override
public VerticalQuality getVerticalQuality()
{
return ForgeConfig.CLIENT.graphics.quality.verticalQuality.get();
}
@Override
public void setVerticalQuality(VerticalQuality newVerticalQuality)
{
ForgeConfig.CLIENT.graphics.quality.verticalQuality.set(newVerticalQuality);
}
@Override
public HorizontalScale getHorizontalScale()
{
return ForgeConfig.CLIENT.graphics.quality.horizontalScale.get();
}
@Override
public void setHorizontalScale(HorizontalScale newHorizontalScale)
{
ForgeConfig.CLIENT.graphics.quality.horizontalScale.set(newHorizontalScale);
}
@Override
public HorizontalQuality getHorizontalQuality()
{
return ForgeConfig.CLIENT.graphics.quality.horizontalQuality.get();
}
@Override
public void setHorizontalQuality(HorizontalQuality newHorizontalQuality)
{
ForgeConfig.CLIENT.graphics.quality.horizontalQuality.set(newHorizontalQuality);
}
}
public static class FogQuality implements IFogQuality
{
@Override
public FogDistance getFogDistance()
{
return ForgeConfig.CLIENT.graphics.fogQuality.fogDistance.get();
}
@Override
public void setFogDistance(FogDistance newFogDistance)
{
ForgeConfig.CLIENT.graphics.fogQuality.fogDistance.set(newFogDistance);
}
@Override
public FogDrawMode getFogDrawMode()
{
return ForgeConfig.CLIENT.graphics.fogQuality.fogDrawMode.get();
}
@Override
public void setFogDrawMode(FogDrawMode newFogDrawMode)
{
ForgeConfig.CLIENT.graphics.fogQuality.fogDrawMode.set(newFogDrawMode);
}
@Override
public FogColorMode getFogColorMode()
{
return ForgeConfig.CLIENT.graphics.fogQuality.fogColorMode.get();
}
@Override
public void setFogColorMode(FogColorMode newFogColorMode)
{
ForgeConfig.CLIENT.graphics.fogQuality.fogColorMode.set(newFogColorMode);
}
@Override
public boolean getDisableVanillaFog()
{
return ForgeConfig.CLIENT.graphics.fogQuality.disableVanillaFog.get();
}
@Override
public void setDisableVanillaFog(boolean newDisableVanillaFog)
{
ForgeConfig.CLIENT.graphics.fogQuality.disableVanillaFog.set(newDisableVanillaFog);
}
}
public static class AdvancedGraphics implements IAdvancedGraphics
{
@Override
public LodTemplate getLodTemplate()
{
return ForgeConfig.CLIENT.graphics.advancedGraphics.lodTemplate.get();
}
@Override
public void setLodTemplate(LodTemplate newLodTemplate)
{
ForgeConfig.CLIENT.graphics.advancedGraphics.lodTemplate.set(newLodTemplate);
}
@Override
public boolean getDisableDirectionalCulling()
{
return ForgeConfig.CLIENT.graphics.advancedGraphics.disableDirectionalCulling.get();
}
@Override
public void setDisableDirectionalCulling(boolean newDisableDirectionalCulling)
{
ForgeConfig.CLIENT.graphics.advancedGraphics.disableDirectionalCulling.set(newDisableDirectionalCulling);
}
@Override
public boolean getAlwaysDrawAtMaxQuality()
{
return ForgeConfig.CLIENT.graphics.advancedGraphics.alwaysDrawAtMaxQuality.get();
}
@Override
public void setAlwaysDrawAtMaxQuality(boolean newAlwaysDrawAtMaxQuality)
{
ForgeConfig.CLIENT.graphics.advancedGraphics.alwaysDrawAtMaxQuality.set(newAlwaysDrawAtMaxQuality);
}
@Override
public VanillaOverdraw getVanillaOverdraw()
{
return ForgeConfig.CLIENT.graphics.advancedGraphics.vanillaOverdraw.get();
}
@Override
public void setVanillaOverdraw(VanillaOverdraw newVanillaOverdraw)
{
ForgeConfig.CLIENT.graphics.advancedGraphics.vanillaOverdraw.set(newVanillaOverdraw);
}
@Override
public boolean getUseExtendedNearClipPlane()
{
return ForgeConfig.CLIENT.graphics.advancedGraphics.useExtendedNearClipPlane.get();
}
@Override
public void setUseExtendedNearClipPlane(boolean newUseExtendedNearClipPlane)
{
ForgeConfig.CLIENT.graphics.advancedGraphics.useExtendedNearClipPlane.set(newUseExtendedNearClipPlane);
}
}
}
//========================//
// WorldGenerator Configs //
//========================//
public static class WorldGenerator implements IWorldGenerator
{
@Override
public GenerationPriority getGenerationPriority()
{
return ForgeConfig.CLIENT.worldGenerator.generationPriority.get();
}
@Override
public void setGenerationPriority(GenerationPriority newGenerationPriority)
{
ForgeConfig.CLIENT.worldGenerator.generationPriority.set(newGenerationPriority);
}
@Override
public DistanceGenerationMode getDistanceGenerationMode()
{
return ForgeConfig.CLIENT.worldGenerator.distanceGenerationMode.get();
}
@Override
public void setDistanceGenerationMode(DistanceGenerationMode newDistanceGenerationMode)
{
ForgeConfig.CLIENT.worldGenerator.distanceGenerationMode.set(newDistanceGenerationMode);
}
@Override
public boolean getAllowUnstableFeatureGeneration()
{
return ForgeConfig.CLIENT.worldGenerator.allowUnstableFeatureGeneration.get();
}
@Override
public void setAllowUnstableFeatureGeneration(boolean newAllowUnstableFeatureGeneration)
{
ForgeConfig.CLIENT.worldGenerator.allowUnstableFeatureGeneration.set(newAllowUnstableFeatureGeneration);
}
@Override
public BlocksToAvoid getBlocksToAvoid()
{
return ForgeConfig.CLIENT.worldGenerator.blocksToAvoid.get();
}
@Override
public void setBlockToAvoid(BlocksToAvoid newBlockToAvoid)
{
ForgeConfig.CLIENT.worldGenerator.blocksToAvoid.set(newBlockToAvoid);
}
}
//============================//
// AdvancedModOptions Configs //
//============================//
public static class Advanced implements IAdvanced
{
public final IThreading threading;
public final IDebugging debugging;
public final IBuffers buffers;
@Override
public IThreading threading()
{
return threading;
}
@Override
public IDebugging debugging()
{
return debugging;
}
@Override
public IBuffers buffers()
{
return buffers;
}
public Advanced()
{
threading = new Threading();
debugging = new Debugging();
buffers = new Buffers();
}
public static class Threading implements IThreading
{
@Override
public int getNumberOfWorldGenerationThreads()
{
return ForgeConfig.CLIENT.advanced.threading.numberOfWorldGenerationThreads.get();
}
@Override
public void setNumberOfWorldGenerationThreads(int newNumberOfWorldGenerationThreads)
{
ForgeConfig.CLIENT.advanced.threading.numberOfWorldGenerationThreads.set(newNumberOfWorldGenerationThreads);
}
@Override
public int getNumberOfBufferBuilderThreads()
{
return ForgeConfig.CLIENT.advanced.threading.numberOfBufferBuilderThreads.get();
}
@Override
public void setNumberOfBufferBuilderThreads(int newNumberOfWorldBuilderThreads)
{
ForgeConfig.CLIENT.advanced.threading.numberOfBufferBuilderThreads.set(newNumberOfWorldBuilderThreads);
}
}
//===============//
// Debug Options //
//===============//
public static class Debugging implements IDebugging
{
@Override
public boolean getDrawLods()
{
return ForgeConfig.CLIENT.advanced.debugging.drawLods.get();
}
@Override
public void setDrawLods(boolean newDrawLods)
{
ForgeConfig.CLIENT.advanced.debugging.drawLods.set(newDrawLods);
}
@Override
public DebugMode getDebugMode()
{
return ForgeConfig.CLIENT.advanced.debugging.debugMode.get();
}
@Override
public void setDebugMode(DebugMode newDebugMode)
{
ForgeConfig.CLIENT.advanced.debugging.debugMode.set(newDebugMode);
}
@Override
public boolean getDebugKeybindingsEnabled()
{
return ForgeConfig.CLIENT.advanced.debugging.enableDebugKeybindings.get();
}
@Override
public void setDebugKeybindingsEnabled(boolean newEnableDebugKeybindings)
{
ForgeConfig.CLIENT.advanced.debugging.enableDebugKeybindings.set(newEnableDebugKeybindings);
}
}
public static class Buffers implements IBuffers
{
@Override
public GpuUploadMethod getGpuUploadMethod()
{
return ForgeConfig.CLIENT.advanced.buffers.gpuUploadMethod.get();
}
@Override
public void setGpuUploadMethod(GpuUploadMethod newDisableVanillaFog)
{
ForgeConfig.CLIENT.advanced.buffers.gpuUploadMethod.set(newDisableVanillaFog);
}
@Override
public int getGpuUploadTimeoutInMilliseconds()
{
return ForgeConfig.CLIENT.advanced.buffers.gpuUploadTimeoutInMilleseconds.get();
}
@Override
public void setGpuUploadTimeoutInMilliseconds(int newTimeoutInMilliseconds)
{
ForgeConfig.CLIENT.advanced.buffers.gpuUploadTimeoutInMilleseconds.set(newTimeoutInMilliseconds);
}
@Override
public BufferRebuildTimes getRebuildTimes()
{
return ForgeConfig.CLIENT.advanced.buffers.rebuildTimes.get();
}
@Override
public void setRebuildTimes(BufferRebuildTimes newBufferRebuildTimes)
{
ForgeConfig.CLIENT.advanced.buffers.rebuildTimes.set(newBufferRebuildTimes);
}
}
}
}
}
+2 -1
View File
@@ -4,7 +4,8 @@
"compatibilityLevel": "JAVA_8",
"refmap": "lod.refmap.json",
"mixins": [
"MixinWorldRenderer"
"MixinWorldRenderer",
"MixinOptionsScreen"
],
"minVersion": "0.8"
}