Skip to content
Merged
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ minecraft_version=1.21.4
yarn_mappings=1.21.4+build.8
loader_version=0.16.10
# Mod Properties
mod_version=1.0.0-1.21.4-fabric
mod_version=1.0.1-1.21.4-fabric
maven_group=net.i_no_am.view_model
archives_base_name=view-model
# Dependencies
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/net/i_no_am/viewmodel/ViewModel.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.i_no_am.viewmodel;

import eu.midnightdust.lib.config.MidnightConfig;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
Expand All @@ -11,7 +12,6 @@
import org.lwjgl.glfw.GLFW;

public class ViewModel implements ModInitializer, Global {

public static final KeyBinding BIND = KeyBindingHelper.registerKeyBinding(new KeyBinding("View Model GUI", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_V, KeyBinding.MISC_CATEGORY));
public static final String API = "https://api.github.com/repos/I-No-oNe/View-Model/releases/latest";
public static final String DOWNLOAD = "https://modrinth.com/mod/no-ones-view-model/versions";
Expand All @@ -25,13 +25,15 @@ public void onInitialize() {
Log("Config has been registered!");
Log("Has been initialized!");

WorldRenderEvents.AFTER_SETUP.register((context) -> {
Version.create(API, DOWNLOAD).notifyUpdate(isDev);
});
WorldRenderEvents.AFTER_SETUP.register((context) -> Version.create(API, DOWNLOAD).notifyUpdate(isDev));

ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (BIND.wasPressed()) mc.setScreen(Config.getScreen(mc.currentScreen, modId));
if (mc.player != null && mc.world != null) Config.configFix(Config.noHandSwingV1, Config.noHandSwingV2);
if (BIND.wasPressed() && mc.player != null) {
var screenConfig = Config.getScreen(mc.currentScreen, modId);
mc.setScreen(screenConfig);
if (screenConfig.shouldCloseOnEsc()) MidnightConfig.write(modId);
}
if (mc.player != null && mc.world != null) Config.configFix();
});
}

Expand Down
47 changes: 28 additions & 19 deletions src/main/java/net/i_no_am/viewmodel/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,61 @@

public class Config extends MidnightConfig implements Global {

public static boolean sentOnce = false;
public final static String FIRST_PAGE = "Settings";
public final static String SECOND_PAGE = "Advanced Settings";

@Client
@Comment(category = FIRST_PAGE, centered = true)
public static String firstMsg;

@Entry(requiredMod = "dummy", name = "dummy")
public static boolean shouldCheck = true;

@Comment(category = FIRST_PAGE, centered = true)
public static String secondMsg;

@Entry(isSlider = true, category = FIRST_PAGE, min = -45, max = 45, name = "Main hand position on X axis")
@Entry(precision = 200, isSlider = true, category = FIRST_PAGE, min = -45, max = 45, name = "Main hand position on X axis")
public static float mainPositionX = 0.0F;

@Entry(isSlider = true, category = FIRST_PAGE, min = -70, max = 70, name = "Main hand rotation on X axis")
@Entry(precision = 200, isSlider = true, category = FIRST_PAGE, min = -70, max = 70, name = "Main hand rotation on X axis")
public static float mainRotationX = 0.0F;

@Entry(isSlider = true, category = FIRST_PAGE, min = -45, max = 45, name = "Off hand position on X axis")
@Entry(precision = 200, isSlider = true, category = FIRST_PAGE, min = -45, max = 45, name = "Off hand position on X axis")
public static float offPositionX = 0.0F;

@Entry(isSlider = true, category = FIRST_PAGE, min = -70, max = 70, name = "Off hand rotation on X axis")
@Entry(precision = 200, isSlider = true, category = FIRST_PAGE, min = -70, max = 70, name = "Off hand rotation on X axis")
public static float offRotationX = 0.0F;

@Entry(isSlider = true, category = FIRST_PAGE, min = -45, max = 45, name = "Main hand position on Y axis")
@Entry(precision = 200, isSlider = true, category = FIRST_PAGE, min = -45, max = 45, name = "Main hand position on Y axis")
public static float mainPositionY = 0.0F;

@Entry(isSlider = true, category = FIRST_PAGE, min = -60, max = 60, name = "Main hand rotation on Y axis")
@Entry(precision = 200, isSlider = true, category = FIRST_PAGE, min = -60, max = 60, name = "Main hand rotation on Y axis")
public static float mainRotationY = 0.0F;

@Entry(isSlider = true, category = FIRST_PAGE, min = -45, max = 45, name = "Off hand position on Y axis")
@Entry(precision = 200, isSlider = true, category = FIRST_PAGE, min = -45, max = 45, name = "Off hand position on Y axis")
public static float offPositionY = 0.0F;

@Entry(isSlider = true, category = FIRST_PAGE, min = -60, max = 60, name = "Off hand rotation on Y axis")
@Entry(precision = 200, isSlider = true, category = FIRST_PAGE, min = -60, max = 60, name = "Off hand rotation on Y axis")
public static float offRotationY = 0.0F;

@Entry(isSlider = true, category = FIRST_PAGE, min = -30, max = 30, name = "Main hand position on Z axis")
@Entry(precision = 200, isSlider = true, category = FIRST_PAGE, min = -30, max = 30, name = "Main hand position on Z axis")
public static float mainPositionZ = 0.0F;

@Entry(isSlider = true, category = FIRST_PAGE, min = -60, max = 60, name = "Main hand rotation on Z axis")
@Entry(precision = 200, isSlider = true, category = FIRST_PAGE, min = -60, max = 60, name = "Main hand rotation on Z axis")
public static float mainRotationZ = 0.0F;

@Entry(isSlider = true, category = FIRST_PAGE, min = -30, max = 30, name = "Off hand position on Z axis")
@Entry(precision = 200, isSlider = true, category = FIRST_PAGE, min = -30, max = 30, name = "Off hand position on Z axis")
public static float offPositionZ = 0.0F;

@Entry(isSlider = true, category = FIRST_PAGE, min = -60, max = 60, name = "Off hand rotation on Z axis")
@Entry(precision = 200, isSlider = true, category = FIRST_PAGE, min = -60, max = 60, name = "Off hand rotation on Z axis")
public static float offRotationZ = 0.0F;

// Second Page Settings
@Comment(category = SECOND_PAGE, centered = true)
public static String thirdMsg;

@Entry(isSlider = true, category = SECOND_PAGE, min = 0, max = 5, name = "Speed of the hand swing animation")
@Entry(precision = 200, isSlider = true, category = SECOND_PAGE, min = 0, max = 5, name = "Speed of the hand swing animation")
public static int handSpeedSwing = 4;

@Entry(isSlider = true, category = SECOND_PAGE, min = 0.1F, max = 5.0F, name = "Scale of the main hand")
Expand All @@ -84,11 +88,16 @@ public static void register() {
MidnightConfig.init(modId, Config.class);
}

public static void configFix(boolean bl, boolean bl1) {
if (bl == bl1 && bl) {
bl = false;
bl1 = false;
mc.player.sendMessage(Text.of(PREFIX + Formatting.RED + "Choose one swing method!"), false);

public static void configFix() {
if (noHandSwingV1 == noHandSwingV2 && noHandSwingV2) {
noHandSwingV1 = false;
noHandSwingV2 = false;
if (!sentOnce && mc != null && mc.player != null) {
mc.player.sendMessage(Text.of(PREFIX + Formatting.RED + "Choose one swing method!"), false);
MidnightConfig.write(modId);
sentOnce = true;
}
}
}
}
}
12 changes: 7 additions & 5 deletions src/main/java/net/i_no_am/viewmodel/version/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import net.fabricmc.loader.api.FabricLoader;
import net.i_no_am.viewmodel.Global;
import net.i_no_am.viewmodel.ViewModel;
import net.i_no_am.viewmodel.config.Config;
import net.minecraft.client.gui.screen.ConfirmScreen;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Util;
import org.jetbrains.annotations.Nullable;

import java.net.URI;
import java.net.http.HttpClient;
Expand All @@ -21,17 +23,17 @@
public class Version implements Global {

private static final Map<String, Double> versionCache = new HashMap<>();
private final String api;
private final String download;
@Nullable private final String api;
@Nullable private final String download;
private static boolean bl = false;
private final double version;

/**
@param api The link to the github repo api.
@param api The link to the GITHUB repo api.
@param download The link to the download page.
***/

public Version(String api, String download) throws Exception {
private Version(@Nullable String api, @Nullable String download) throws Exception {
this.api = api;
this.download = download;
this.version = getVApi();
Expand All @@ -46,7 +48,7 @@ public static Version create(String apiLink, String downloadLink) {
}

public void notifyUpdate(boolean printVersions) {
if (!bl && mc.currentScreen == null && mc.player != null && !isUpdated()) {
if (!bl && mc.currentScreen == null && mc.player != null && !isUpdated() && Config.shouldCheck) {
if (printVersions) {
ViewModel.Log("Versions: \nCurrent Version: " + getSelf() + "\n" + "Online Version: " + getApi());
}
Expand Down