Skip to content

Commit

Permalink
v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Plastoid501 committed Jul 18, 2024
1 parent 6d224c6 commit 1f40521
Show file tree
Hide file tree
Showing 14 changed files with 546 additions and 7 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ repositories {
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.

maven { url "https://maven.terraformersmc.com/releases/" }
}

dependencies {
Expand All @@ -26,7 +28,7 @@ dependencies {

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"
}

processResources {
Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ yarn_mappings=1.20.4+build.3
loader_version=0.15.11

# Mod Properties
mod_version=1.0.0
mod_version=1.0.1
maven_group=net.plastoid501.movement
archives_base_name=movement-in-gui-mc1.20.4

# Dependencies
fabric_version=0.97.1+1.20.4
fabric_version=0.97.1+1.20.4
modmenu_version=9.2.0-beta.2
6 changes: 4 additions & 2 deletions src/main/java/net/plastoid501/movement/MovementInGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

import net.fabricmc.api.ModInitializer;

import net.plastoid501.movement.util.FileUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MovementInGUI implements ModInitializer {
// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final Logger LOGGER = LoggerFactory.getLogger("movement-in-gui");
public static final String MOD_ID = "movement-in-gui";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

@Override
public void onInitialize() {
// This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.

FileUtil.generateClientModConfig();
}
}
35 changes: 35 additions & 0 deletions src/main/java/net/plastoid501/movement/config/Configs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package net.plastoid501.movement.config;

import net.plastoid501.movement.config.json.JToggleConfig;

import java.util.LinkedHashMap;
import java.util.Map;

public class Configs {
public static Map<String, ToggleConfig> toggles = new LinkedHashMap<>();
public static Map<String, JToggleConfig> jToggles = new LinkedHashMap<>();

public static ToggleConfig modEnable = new ToggleConfig("modEnable", "If true, this mod is enable", true);
public static ToggleConfig inCreative = new ToggleConfig("inCreative", "If true, this mod is enable when creative mode.", true);

public static ModConfig config;

static {
toggles.put(modEnable.getId(), modEnable);
toggles.put(inCreative.getId(), inCreative);
jToggles.put(modEnable.getId(), new JToggleConfig(modEnable.isEnable()));
jToggles.put(inCreative.getId(), new JToggleConfig(inCreative.isEnable()));

config = new ModConfig(jToggles);

}


public static Map<String, ToggleConfig> getToggles() {
return toggles;
}

public static Map<String, JToggleConfig> getJToggles() {
return jToggles;
}
}
22 changes: 22 additions & 0 deletions src/main/java/net/plastoid501/movement/config/ModConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package net.plastoid501.movement.config;

import net.plastoid501.movement.config.json.JToggleConfig;

import java.util.Map;

public class ModConfig {
private Map<String, JToggleConfig> Toggles;

public ModConfig(Map<String, JToggleConfig> Toggles) {
this.Toggles = Toggles;
}

public Map<String, JToggleConfig> getToggles() {
return Toggles;
}

public void setToggles(Map<String, JToggleConfig> toggles) {
Toggles = toggles;
}
}

30 changes: 30 additions & 0 deletions src/main/java/net/plastoid501/movement/config/ToggleConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.plastoid501.movement.config;

import net.plastoid501.movement.config.json.JToggleConfig;

public class ToggleConfig extends JToggleConfig {
private String id;
private String narrator;

public ToggleConfig(String id, String narrator, Boolean enable) {
super(enable);
this.id = id;
this.narrator = narrator;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getNarrator() {
return narrator;
}

public void setNarrator(String narrator) {
this.narrator = narrator;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package net.plastoid501.movement.config.json;

public class JToggleConfig {
private boolean enable;

public JToggleConfig(boolean enable) {
this.enable = enable;
}

public boolean isEnable() {
return enable;
}

public void setEnable(boolean enable) {
this.enable = enable;
}
}
57 changes: 57 additions & 0 deletions src/main/java/net/plastoid501/movement/gui/ConfigScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package net.plastoid501.movement.gui;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import net.plastoid501.movement.gui.widget.ConfigWidget;

public class ConfigScreen extends Screen {
private ConfigWidget configList;
private final Screen parent;

public ConfigScreen(Screen parent) {
super(Text.literal("Movement In GUI"));
this.parent = parent;
}

@Override
protected void init() {
this.configList = new ConfigWidget(this, this.client);
this.addSelectableChild(this.configList);
this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> {
this.close();
}).dimensions(this.width / 2 - 100, this.height - 27, 200, 20).build());
}

@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);
this.configList.render(context, mouseX, mouseY, delta);
context.drawCenteredTextWithShadow(this.textRenderer, this.title, this.width / 2, 8, 0xFFFFFF);
}

@Override
public boolean shouldPause() {
return false;
}

@Override
public void close() {
if (this.client != null) {
this.client.setScreen(this.parent);
}
}

/*
@Override
public void renderBackground(DrawContext context, int mouseX, int mouseY, float delta) {
if (this.client == null || this.client.player == null || this.client.world == null) {
this.renderBackgroundTexture(context);
}
}
*/

}
13 changes: 13 additions & 0 deletions src/main/java/net/plastoid501/movement/gui/ModMenuIntegration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package net.plastoid501.movement.gui;

import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import net.plastoid501.movement.util.FileUtil;

public class ModMenuIntegration implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
FileUtil.updateConfigs();
return ConfigScreen::new;
}
}
Loading

0 comments on commit 1f40521

Please sign in to comment.