Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added config menu using modmenu and cloth_config lib #71

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 {
Expand Down Expand Up @@ -66,4 +76,4 @@ publishing {
}
}
}
}
}
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ maven_group=amymialee
archives_base_name=visiblebarriers

# Dependencies
fabric_version=0.100.7+1.21
fabric_version=0.100.7+1.21
modmenu_version=11.0.2
clothconfig_version=15.0.140
Empty file modified gradlew
100644 → 100755
Empty file.
10 changes: 10 additions & 0 deletions src/main/java/xyz/amymialee/visiblebarriers/VisibleConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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();

};
}
}
18 changes: 17 additions & 1 deletion src/main/resources/assets/visiblebarriers/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"

}
3 changes: 3 additions & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
],
"client": [
"xyz.amymialee.visiblebarriers.VisibleBarriers"
],
"modmenu": [
"xyz.amymialee.visiblebarriers.integration.modmenu.VisibleBarriersModMenu"
]
},
"mixins": [
Expand Down