Skip to content

Commit

Permalink
go on
Browse files Browse the repository at this point in the history
  • Loading branch information
KrLite committed Feb 24, 2024
1 parent 006ed39 commit e71a78c
Show file tree
Hide file tree
Showing 13 changed files with 191 additions and 354 deletions.
68 changes: 0 additions & 68 deletions build.gradle

This file was deleted.

64 changes: 64 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
plugins {
base
java
idea
`maven-publish`
alias(libs.plugins.fabric.loom)
}

group = libs.versions.maven.group.get()
version = "${libs.versions.minecraft.get()}-${libs.versions.mod.get()}"

base {
archivesName.set(libs.versions.archives.name)
}

repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
maven { url = uri("https://maven.shedaniel.me/") } // Cloth Config
maven { url = uri("https://maven.terraformersmc.com/releases/") } // Mod Menu
}

dependencies {
minecraft(libs.minecraft)
mappings(libs.yarn)
modImplementation(libs.bundles.fabric)

modApi(libs.cloth.config)
modApi(libs.modmenu)
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

withSourcesJar()
}

tasks {
processResources {
inputs.property("version", libs.versions.mod.get())

filesMatching("fabric.mod.json") {
expand(mapOf("version" to libs.versions.mod.get()))
}
}

jar {
from("LICENSE") {
rename { "${it}_${base.archivesName}" }
}
}
}

publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
}
}

repositories {
}
}
17 changes: 0 additions & 17 deletions gradle.properties

This file was deleted.

28 changes: 28 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[versions]
maven-group = "net.krlite"
archives-name = "tapestop"
mod = "3.0.0"

minecraft = "1.20"
yarn = "1.20+build.1"
fabric-loader = "0.15.7"
fabric-api = "0.83.0+1.20"
fabric-loom = "1.5-SNAPSHOT"

cloth-config = "11.1.118"
modmenu = "7.0.1"

[libraries]
minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft" }
yarn = { group = "net.fabricmc", name = "yarn", version.ref = "yarn" }
fabric-loader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fabric-loader" }
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabric-api" }

cloth-config = { group = "me.shedaniel.cloth", name = "cloth-config-fabric", version.ref = "cloth-config" }
modmenu = { group = "com.terraformersmc", name = "modmenu", version.ref = "modmenu" }

[plugins]
fabric-loom = { id = "fabric-loom", version.ref = "fabric-loom" }

[bundles]
fabric = ["fabric-loader", "fabric-api"]
4 changes: 2 additions & 2 deletions settings.gradle → settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pluginManagement {
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
name = "Fabric"
url = uri("https://maven.fabricmc.net/")
}
mavenCentral()
gradlePluginPortal()
Expand Down
22 changes: 14 additions & 8 deletions src/main/java/net/krlite/tapestop/TapeStop.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.krlite.tapestop;

import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;
import net.fabricmc.api.ModInitializer;
import net.krlite.tapestop.config.TapeStopConfig;
import net.minecraft.client.MinecraftClient;
Expand All @@ -23,7 +25,12 @@
public class TapeStop implements ModInitializer {
public static final String NAME = "Tape Stop", ID = "tapestop";
public static final Logger LOGGER = LoggerFactory.getLogger(ID);
public static final TapeStopConfig CONFIG = new TapeStopConfig();
public static final TapeStopConfig CONFIG;

static {
AutoConfig.register(TapeStopConfig.class, Toml4jConfigSerializer::new);
CONFIG = AutoConfig.getConfigHolder(TapeStopConfig.class).get();
}

private static final Class<?>[] excluded = new Class[]{
TitleScreen.class, DemoScreen.class, AccessibilityOnboardingScreen.class, SplashOverlay.class,
Expand All @@ -48,21 +55,20 @@ public class TapeStop implements ModInitializer {

@Override
public void onInitialize() {
CONFIG.save();
updateColors();
}

public static boolean shouldTapeStop(@Nullable Screen screen) {
if (!CONFIG.enabled() || MinecraftClient.getInstance().world == null) return false;
if (!CONFIG.enabled || MinecraftClient.getInstance().world == null) return false;

if (CONFIG.whenMinimized() && GLFW.glfwGetWindowAttrib(MinecraftClient.getInstance().getWindow().getHandle(), GLFW.GLFW_ICONIFIED) == GLFW.GLFW_TRUE) return true;
if (CONFIG.trigger.whenMinimized && GLFW.glfwGetWindowAttrib(MinecraftClient.getInstance().getWindow().getHandle(), GLFW.GLFW_ICONIFIED) == GLFW.GLFW_TRUE) return true;

if (CONFIG.whenLostFocus() && !MinecraftClient.getInstance().isWindowFocused()) return true;
if (CONFIG.trigger.whenLostFocus && !MinecraftClient.getInstance().isWindowFocused()) return true;

if (screen == null && CONFIG.afterGameTimeout() && isTimeout()) return true;
if (screen == null && CONFIG.trigger.afterGameTimeout && isTimeout()) return true;

if (screen != null && !Arrays.asList(excluded).contains(screen.getClass())
&& CONFIG.afterGUITimeout() && isTimeout()) return true;
&& CONFIG.trigger.afterGUITimeout && isTimeout()) return true;

tapeStopTime = Util.getMeasuringTimeMs();
updateColors();
Expand Down Expand Up @@ -107,7 +113,7 @@ public static int color() {
}

public static boolean isTimeout() {
return Util.getMeasuringTimeMs() - lastActionTime > CONFIG.timeoutMs();
return Util.getMeasuringTimeMs() - lastActionTime > CONFIG.timeoutMs;
}

public static void action() {
Expand Down
Loading

0 comments on commit e71a78c

Please sign in to comment.