diff --git a/build.gradle b/build.gradle index f2dda7b..a5b906e 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,13 @@ base { archivesName = project.archives_base_name + "-" + project.minecraft_version } -repositories {} +repositories { + maven { + name = "Terraformers" + url = "https://maven.terraformersmc.com/" + } + maven { url "https://maven.shedaniel.me/" } +} fabricApi { configureDataGeneration() @@ -21,6 +27,10 @@ dependencies { mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}") + modApi("me.shedaniel.cloth:cloth-config-fabric:${project.clothconfig_version}") { + exclude(group: "net.fabricmc.fabric-api") + } } loom { @@ -66,4 +76,4 @@ publishing { } } } -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index 098b6ea..d70d63c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,4 +12,6 @@ maven_group=amymialee archives_base_name=visiblebarriers # Dependencies -fabric_version=0.100.7+1.21 \ No newline at end of file +fabric_version=0.100.7+1.21 +modmenu_version=11.0.2 +clothconfig_version=15.0.140 diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/src/main/java/xyz/amymialee/visiblebarriers/VisibleConfig.java b/src/main/java/xyz/amymialee/visiblebarriers/VisibleConfig.java index 0c0c115..40e8513 100644 --- a/src/main/java/xyz/amymialee/visiblebarriers/VisibleConfig.java +++ b/src/main/java/xyz/amymialee/visiblebarriers/VisibleConfig.java @@ -49,6 +49,16 @@ public static void setForcedTime(long forcedTime) { } } + public static void setSolidLights(boolean solidLights) { + VisibleConfig.solidLights = solidLights; + saveConfig(); + } + + public static void setBaseZoom(Float baseZoom) { + VisibleConfig.baseZoom = baseZoom; + saveConfig(); + } + public static boolean isBarrierVisible() { return visibleBarrier; } diff --git a/src/main/java/xyz/amymialee/visiblebarriers/integration/modmenu/VisibleBarriersModMenu.java b/src/main/java/xyz/amymialee/visiblebarriers/integration/modmenu/VisibleBarriersModMenu.java new file mode 100644 index 0000000..af360ad --- /dev/null +++ b/src/main/java/xyz/amymialee/visiblebarriers/integration/modmenu/VisibleBarriersModMenu.java @@ -0,0 +1,117 @@ +package xyz.amymialee.visiblebarriers.integration.modmenu; + +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; +import me.shedaniel.autoconfig.annotation.ConfigEntry; +import me.shedaniel.clothconfig2.api.ConfigBuilder; +import me.shedaniel.clothconfig2.api.ConfigCategory; +import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; +import net.minecraft.client.MinecraftClient; +import net.minecraft.text.Text; +import net.minecraft.text.TranslatableTextContent; +import xyz.amymialee.visiblebarriers.VisibleBarriers; +import xyz.amymialee.visiblebarriers.VisibleConfig; + +public class VisibleBarriersModMenu implements ModMenuApi { + + @Override + public ConfigScreenFactory getModConfigScreenFactory() { + return parent -> { + ConfigBuilder builder = ConfigBuilder.create() + .setParentScreen(parent) + .setTitle(Text.translatable("title.visiblebarriers.config")) + ; + ConfigCategory generalCategory = builder.getOrCreateCategory(Text.translatable("category.visiblebarriers.general")); + ConfigEntryBuilder configEntryBuilder = builder.entryBuilder(); + + // Visible Barrier + generalCategory.addEntry(configEntryBuilder.startBooleanToggle(Text.translatable("option.visiblebarriers.visible_barrier"), VisibleConfig.isBarrierVisible()) + .setDefaultValue(false) + .setTooltip(Text.translatable("option.visiblebarriers.visible_barrier.tooltip")) + .setSaveConsumer(newValue -> { + if(newValue!=VisibleConfig.isBarrierVisible()) { + VisibleConfig.setVisibleBarrier(newValue); + VisibleBarriers.setBarriers(newValue); + } + }) + .build() + ); + + // Visible Air + generalCategory.addEntry(configEntryBuilder.startBooleanToggle(Text.translatable("option.visiblebarriers.visible_air"), VisibleConfig.isAirVisible()) + .setDefaultValue(false) + .setTooltip(Text.translatable("option.visiblebarriers.visible_air.tooltip")) + .setSaveConsumer(newValue -> { + if(newValue!=VisibleConfig.isAirVisible()) { + VisibleConfig.setVisibleAir(newValue); + VisibleBarriers.reloadWorldRenderer(); + } + }) + .build() + ); + + // Hide Particles + generalCategory.addEntry(configEntryBuilder.startBooleanToggle(Text.translatable("option.visiblebarriers.hide_particles"), VisibleConfig.shouldHideParticles()) + .setDefaultValue(true) + .setTooltip(Text.translatable("option.visiblebarriers.hide_particles.tooltip")) + .setSaveConsumer(newValue -> { + if(newValue!=VisibleConfig.shouldHideParticles()) { + VisibleConfig.setHideParticles(newValue); + } + }) + .build() + ); + + // Send Feedback + generalCategory.addEntry(configEntryBuilder.startBooleanToggle(Text.translatable("option.visiblebarriers.send_feedback"), VisibleConfig.shouldSendFeedback()) + .setDefaultValue(true) + .setTooltip(Text.translatable("option.visiblebarriers.send_feedback.tooltip")) + .setSaveConsumer(newValue -> { + if(newValue!=VisibleConfig.shouldSendFeedback()) { + VisibleConfig.setSendFeedback(newValue); + } + }) + .build() + ); + + // Solid Lights + generalCategory.addEntry(configEntryBuilder.startBooleanToggle(Text.translatable("option.visiblebarriers.solid_lights"), VisibleConfig.areLightsSolid()) + .setDefaultValue(false) + .setTooltip(Text.translatable("option.visiblebarriers.solid_lights.tooltip")) + .setSaveConsumer(newValue -> { + if(newValue!=VisibleConfig.areLightsSolid()) { + VisibleConfig.setSolidLights(newValue); + } + }) + .build() + ); + + // Base Zoom + generalCategory.addEntry(configEntryBuilder.startFloatField(Text.translatable("option.visiblebarriers.base_zoom"),VisibleConfig.getBaseZoom()) + .setDefaultValue(2.8f) + .setTooltip(Text.translatable("option.visiblebarriers.base_zoom.tooltip")) + .setSaveConsumer(newValue -> { + if(newValue!=VisibleConfig.getBaseZoom()) { + VisibleConfig.setBaseZoom(newValue); + } + }) + .build() + ); + + // Forced Time Value + generalCategory.addEntry(configEntryBuilder.startLongField(Text.translatable("option.visiblebarriers.forced_time"),VisibleConfig.getForcedTime()) + .setDefaultValue(6000) + .setTooltip(Text.translatable("option.visiblebarriers.forced_time.tooltip")) + .setSaveConsumer(newValue -> { + if(newValue!=VisibleConfig.getForcedTime()) { + VisibleConfig.setForcedTime(newValue); + } + }) + .build() + ); + + return builder.build(); + + }; + } +} diff --git a/src/main/resources/assets/visiblebarriers/lang/en_us.json b/src/main/resources/assets/visiblebarriers/lang/en_us.json index 258cce6..2afd403 100644 --- a/src/main/resources/assets/visiblebarriers/lang/en_us.json +++ b/src/main/resources/assets/visiblebarriers/lang/en_us.json @@ -8,6 +8,7 @@ "key.visiblebarriers.fullbright" : "Toggle Fullbright", "key.visiblebarriers.time" : "Toggle Forced Time", "key.visiblebarriers.zoom" : "Zoom", + "title.visiblebarriers.config": "Visible Barriers Config", "visiblebarriers.enabled" : "Enabled", "visiblebarriers.disabled" : "Disabled", @@ -36,6 +37,21 @@ "visiblebarriers.settings.visibleair" : "Visible Air", "visiblebarriers.settings.hiddenparticles" : "Hidden Particles", - "visiblebarriers.settings.sendfeedback" : "Send Feedback" + "visiblebarriers.settings.sendfeedback" : "Send Feedback", + "category.visiblebarriers.general": "General", + "option.visiblebarriers.visible_barrier": "Visible Barriers", + "option.visiblebarriers.visible_barrier.tooltip": "Are Barrier blocks visible?", + "option.visiblebarriers.visible_air": "Visible Air", + "option.visiblebarriers.visible_air.tooltip": "Are Air blocks visible?", + "option.visiblebarriers.hide_particles": "Hide Particles", + "option.visiblebarriers.hide_particles.tooltip": "Are particles hidden?", + "option.visiblebarriers.send_feedback": "Send Feedback", + "option.visiblebarriers.send_feedback.tooltip": "Print feedback to screen when visibility changes?", + "option.visiblebarriers.solid_lights": "Solid Lights", + "option.visiblebarriers.solid_lights.tooltip": "Are lights solid?", + "option.visiblebarriers.base_zoom": "Base Zoom", + "option.visiblebarriers.base_zoom.tooltip": "Set base zoom value", + "option.visiblebarriers.forced_time": "Forced Time", + "option.visiblebarriers.forced_time.tooltip": "Sets current time to be forced to this value" } \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 8802471..6305c12 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -22,6 +22,9 @@ ], "client": [ "xyz.amymialee.visiblebarriers.VisibleBarriers" + ], + "modmenu": [ + "xyz.amymialee.visiblebarriers.integration.modmenu.VisibleBarriersModMenu" ] }, "mixins": [