diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e2fa68a..3910d32 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,40 +1,24 @@ -# Automatically build the project and run any configured tests for every push -# and submitted pull request. This can help catch issues that only occur on -# certain platforms or Java versions, and provides a first line of defence -# against bad commits. +name: Java CI with Gradle -name: build -on: [pull_request, push] +on: [ pull_request, push ] jobs: build: - strategy: - matrix: - # Use these Java versions - java: [ - 17, # Current Java LTS & minimum supported by Minecraft - ] - # and run on both Linux and Windows - os: [ubuntu-22.04, windows-2022] - runs-on: ${{ matrix.os }} + runs-on: ubuntu-22.04 + steps: - - name: checkout repository - uses: actions/checkout@v3 - - name: validate gradle wrapper - uses: gradle/wrapper-validation-action@v1 - - name: setup jdk ${{ matrix.java }} + - uses: actions/checkout@v3 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: ${{ matrix.java }} - distribution: 'microsoft' - - name: make gradle wrapper executable - if: ${{ runner.os != 'Windows' }} - run: chmod +x ./gradlew - - name: build + distribution: 'temurin' + java-version: 17 + - name: Grant execute permission for Gradlew + run: chmod +x gradlew + - name: Build with Gradle run: ./gradlew build - - name: capture build artifacts - if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS + - name: Upload build artifacts uses: actions/upload-artifact@v3 with: name: Artifacts - path: build/libs/ + path: build/libs \ No newline at end of file diff --git a/.gitignore b/.gitignore index c476faf..5b90215 100644 --- a/.gitignore +++ b/.gitignore @@ -1,40 +1,9 @@ -# gradle - .gradle/ build/ out/ classes/ - -# eclipse - -*.launch - -# idea - .idea/ *.iml *.ipr *.iws - -# vscode - -.settings/ -.vscode/ -bin/ -.classpath -.project - -# macos - -*.DS_Store - -# fabric - run/ - -# java - -hs_err_*.log -replay_*.log -*.hprof -*.jfr diff --git a/build.gradle b/build.gradle index c57f328..39ccf8c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,57 +1,60 @@ plugins { - id 'fabric-loom' version '1.2-SNAPSHOT' - id 'maven-publish' + id "dev.architectury.loom" version "1.1-SNAPSHOT" + id "maven-publish" } -archivesBaseName = "${project.archives_base_name}-${project.minecraft_version}" +sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17 + +archivesBaseName = project.archives_base_name version = project.mod_version group = project.maven_group -repositories { - maven { url 'https://api.modrinth.com/maven' } +loom { + silentMojangMappingsLicense() + forge { + mixinConfigs = [ + "bounced.mixins.json" + ] + } } +repositories {} + dependencies { - minecraft "com.mojang:minecraft:${project.minecraft_version}" + minecraft "com.mojang:minecraft:${project.minecraft_version}" 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}" - - compileOnly "maven.modrinth:splasher:${project.minecraft_version}-${project.splasher_version}" + forge "net.minecraftforge:forge:${project.forge_version}" } processResources { - inputs.property "version", project.version - - filesMatching("fabric.mod.json") { - expand "version": project.version - } + inputs.property "version", project.version + filesMatching("META-INF/mods.toml") { + expand "version": project.version + } } -tasks.withType(JavaCompile).configureEach { - it.options.release = Integer.parseInt(sourceCompatibility) -} - -java { - withSourcesJar() - - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 +tasks.withType(JavaCompile) { + options.encoding = "UTF-8" + options.release.set(17) } jar { - from("LICENSE") { - rename { "${it}_${project.archivesBaseName}"} - } + manifest { + attributes([ + "Implementation-Title" : project.name, + "Implementation-Version" : version, + "Implementation-Vendor" : project.mod_author, + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + ]) + } } publishing { - publications { - mavenJava(MavenPublication) { - from components.java - } - } - - repositories { - } + publications { + mavenJava(MavenPublication) { + from components.java + } + } + + repositories {} } diff --git a/gradle.properties b/gradle.properties index ce93591..3359a79 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,17 @@ -org.gradle.jvmargs = -Xmx1G -org.gradle.parallel = true +# Gradle + org.gradle.jvmargs=-Xmx2G + org.gradle.daemon=false + org.gradle.parallel=true + +# Base properties + loom.platform=forge + minecraft_version=1.19.2 + yarn_mappings=1.19.2+build.28 + forge_version=1.19.2-43.2.8 -# https://fabricmc.net/develop -minecraft_version = 1.19 -yarn_mappings = 1.19+build.4 -loader_version = 0.14.19 - -mod_version = 2.1.2 -maven_group = net.krlite -archives_base_name = bounced - -# Dependencies -fabric_version = 0.58.0+1.19 -splasher_version = v4.0.4-beta +# Mod Properties + mod_version=1.19.2-1.0.0 + maven_group=net.krlite.bounced + archives_base_name=bounced-forge + mod_id=bounced + mod_author=KrLite, Kasualix diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 943f0cb..7454180 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 37aef8d..2e6e589 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip -networkTimeout=10000 +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 65dcd68..cbc23f7 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -69,7 +69,7 @@ app_path=$0 # Need this for daisy-chained symlinks. while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + APP_HOME=${app_path%"${app_path##*/}"} [ -h "$app_path" ] do ls=$( ls -ld "$app_path" ) @@ -80,11 +80,11 @@ do esac done -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,16 +143,12 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -209,12 +205,6 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 93e3f59..107acd3 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%"=="" @echo off +@if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,8 +25,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused +if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -41,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -76,15 +75,13 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd +if "%ERRORLEVEL%"=="0" goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/settings.gradle b/settings.gradle index b02216b..606cfc1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,10 +1,10 @@ pluginManagement { + // when using additional gradle plugins like shadow, + // add their repositories to this list! repositories { - maven { - name = 'Fabric' - url = 'https://maven.fabricmc.net/' - } - mavenCentral() + maven { url "https://maven.fabricmc.net/" } + maven { url "https://maven.architectury.dev/" } + maven { url "https://files.minecraftforge.net/maven/" } gradlePluginPortal() } } diff --git a/src/main/java/net/krlite/bounced/Bounced.java b/src/main/java/net/krlite/bounced/Bounced.java index aeccf0e..309c24d 100644 --- a/src/main/java/net/krlite/bounced/Bounced.java +++ b/src/main/java/net/krlite/bounced/Bounced.java @@ -1,129 +1,98 @@ package net.krlite.bounced; -import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; -import net.fabricmc.fabric.api.client.screen.v1.ScreenMouseEvents; -import net.fabricmc.loader.api.FabricLoader; -import net.krlite.splasher.Splasher; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.TitleScreen; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import net.minecraftforge.fml.common.Mod; import java.util.concurrent.atomic.AtomicBoolean; -public class Bounced implements ModInitializer { - public static final String NAME = "Bounced!", ID = "bounced"; - public static final Logger LOGGER = LoggerFactory.getLogger(ID); - private static double primaryPos, secondaryPos; - private static long startTime, initializationTime, thresholdOffset; - private static final long - primaryAnimationTime = 863 /* Animation time for the 'MINECRAFT' logo */ , - secondaryAnimationTime = 936 /* Animation time for the 'EDITION' banner and splash text */ ; - private static final AtomicBoolean - shouldAnimate = new AtomicBoolean(true), - shouldJump = new AtomicBoolean(false); - - @Override - public void onInitialize() { - boolean isSplasherLoaded = FabricLoader.getInstance().isModLoaded("splasher"); - - ScreenEvents.BEFORE_INIT.register((client, screen, scaledWidth, scaledHeight) -> { - if (screen instanceof TitleScreen) { - ScreenMouseEvents.beforeMouseClick(screen) - .register((currentScreen, mouseX, mouseY, button) -> { - double centerX = scaledWidth / 2.0, y = 30, width = 310, height = 44; - if (!isIntro() - && mouseX >= centerX - width / 2 && mouseX <= centerX + width / 2 - && mouseY >= y && mouseY <= y + height - ) { - if (!isSplasherLoaded || !Splasher.isMouseHovering(scaledWidth, mouseX, mouseY)) { - // Linkage with Splasher - push(); - } - } - }); - } - }); - } - - public static void update() { - if (isIntro()) { - double offset = MinecraftClient.getInstance().getWindow().getScaledHeight() / 4.1; - primaryPos = (shouldAnimate.get() ? 0 : easeOutBounce(primaryAnimationTime) * offset) - offset; - secondaryPos = (shouldAnimate.get() ? 0 : easeOutBounce(secondaryAnimationTime) * offset) - offset; - } - else { - double offset = MinecraftClient.getInstance().getWindow().getScaledHeight() / 7.0; - - if (shouldAnimate.get()) { - primaryPos = 0; - secondaryPos = 0; - } - else { - if (shouldJump.get() && Math.max(Math.abs(-offset - primaryPos()), Math.abs(-offset - secondaryPos())) > 0.5) { - primaryPos += (-offset - primaryPos()) * 0.26; - secondaryPos += (-offset - secondaryPos()) * 0.23; - - startTime = System.currentTimeMillis(); - } else { - shouldJump.set(false); - - primaryPos = easeOutBounce(primaryAnimationTime) * offset - offset; - secondaryPos = easeOutBounce(secondaryAnimationTime) * offset - offset; - } - } - } - } - - public static double primaryPos() { - return primaryPos; - } - - public static double secondaryPos() { - return secondaryPos; - } - - public static long totalAnimationTime() { - return Math.max(primaryAnimationTime, secondaryAnimationTime); - } - - public static boolean isIntro() { - return System.currentTimeMillis() - (initializationTime + thresholdOffset) <= totalAnimationTime(); - } - - public static void init() { - initializationTime = System.currentTimeMillis(); - thresholdOffset = -1; - shouldJump.set(false); - } - - public static void push() { - shouldAnimate.set(true); - shouldJump.set(true); - } - - public static void resetWhen(boolean condition) { - if (condition && shouldAnimate.getAndSet(false)) { - startTime = System.currentTimeMillis(); - if (thresholdOffset == -1) thresholdOffset = System.currentTimeMillis() - initializationTime; - } - } - - public static double easeOutBounce(double animationTime) { - double progress = Math.min((System.currentTimeMillis() - startTime) / animationTime, 1); - - if (progress < 1 / 2.75) { - return 7.5625 * progress * progress; - } else if (progress < 2 / 2.75) { - progress -= 1.5 / 2.75; - return 7.5625 * progress * progress + 0.75; - } else if (progress < 2.5 / 2.75) { - progress -= 2.25 / 2.75; - return 7.5625 * progress * progress + 0.9375; - } else { - progress -= 2.625 / 2.75; - return 7.5625 * progress * progress + 0.984375; - } - } +@Mod(Bounced.MOD_ID) +public class Bounced { + public static final String MOD_ID = "bounced"; + private static double primaryPos, secondaryPos; + private static long startTime, initializationTime, thresholdOffset; + private static final long + primaryAnimationTime = 863 /* Animation time for the 'MINECRAFT' logo */ , + secondaryAnimationTime = 936 /* Animation time for the 'EDITION' banner and splash text */ ; + private static final AtomicBoolean + shouldAnimate = new AtomicBoolean(true), + shouldJump = new AtomicBoolean(false); + public static void update() { + if (isIntro()) { + double offset = MinecraftClient.getInstance().getWindow().getScaledHeight() / 4.1; + primaryPos = (shouldAnimate.get() ? 0 : easeOutBounce(primaryAnimationTime) * offset) - offset; + secondaryPos = (shouldAnimate.get() ? 0 : easeOutBounce(secondaryAnimationTime) * offset) - offset; + } + else { + double offset = MinecraftClient.getInstance().getWindow().getScaledHeight() / 7.0; + + if (shouldAnimate.get()) { + primaryPos = 0; + secondaryPos = 0; + } + else { + if (shouldJump.get() && Math.max(Math.abs(-offset - primaryPos()), Math.abs(-offset - secondaryPos())) > 0.5) { + primaryPos += (-offset - primaryPos()) * 0.26; + secondaryPos += (-offset - secondaryPos()) * 0.23; + + startTime = System.currentTimeMillis(); + } else { + shouldJump.set(false); + + primaryPos = easeOutBounce(primaryAnimationTime) * offset - offset; + secondaryPos = easeOutBounce(secondaryAnimationTime) * offset - offset; + } + } + } + } + + public static double primaryPos() { + return primaryPos; + } + + public static double secondaryPos() { + return secondaryPos; + } + + public static long totalAnimationTime() { + return Math.max(primaryAnimationTime, secondaryAnimationTime); + } + + public static boolean isIntro() { + return System.currentTimeMillis() - (initializationTime + thresholdOffset) <= totalAnimationTime(); + } + + public static void init() { + initializationTime = System.currentTimeMillis(); + thresholdOffset = -1; + shouldJump.set(false); + } + + public static void push() { + shouldAnimate.set(true); + shouldJump.set(true); + } + + public static void resetWhen(boolean condition) { + if (condition && shouldAnimate.getAndSet(false)) { + startTime = System.currentTimeMillis(); + if (thresholdOffset == -1) thresholdOffset = System.currentTimeMillis() - initializationTime; + } + } + + public static double easeOutBounce(double animationTime) { + double progress = Math.min((System.currentTimeMillis() - startTime) / animationTime, 1); + + if (progress < 1 / 2.75) { + return 7.5625 * progress * progress; + } else if (progress < 2 / 2.75) { + progress -= 1.5 / 2.75; + return 7.5625 * progress * progress + 0.75; + } else if (progress < 2.5 / 2.75) { + progress -= 2.25 / 2.75; + return 7.5625 * progress * progress + 0.9375; + } else { + progress -= 2.625 / 2.75; + return 7.5625 * progress * progress + 0.984375; + } + } } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..7be394e --- /dev/null +++ b/src/main/resources/META-INF/mods.toml @@ -0,0 +1,14 @@ +modLoader = "javafml" +loaderVersion = "[43,)" +license = "MIT" + +[[mods]] +modId = "bounced" +version = "${version}" +displayName = "Bounced" +credits="Kasualix - Forge Port" +authors="KrLite" +logoFile="icon.png" +description = ''' +Such A Vibrant Title! +''' \ No newline at end of file diff --git a/src/main/resources/assets/bounced/lang/tt_ru.json b/src/main/resources/assets/bounced/lang/tt_ru.json deleted file mode 100644 index 9873add..0000000 --- a/src/main/resources/assets/bounced/lang/tt_ru.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "modmenu.descriptionTranslation.bounced": "Шундый кыймылдаучы исем!" -} diff --git a/src/main/resources/bounced.mixins.json b/src/main/resources/bounced.mixins.json index 6c1d84f..15d3912 100644 --- a/src/main/resources/bounced.mixins.json +++ b/src/main/resources/bounced.mixins.json @@ -1,16 +1,14 @@ { "required": true, - "minVersion": "0.8", "package": "net.krlite.bounced.mixin", "compatibilityLevel": "JAVA_17", - "mixins": [ - ], - "client": [ - "SplashTextAnimator", - "TitleScreenAnimator", - "Trigger" - ], + "minVersion": "0.8", "injectors": { - "defaultRequire": 0 - } + "defaultRequire": 0 + }, + "client": [ + "SplashTextAnimator", + "TitleScreenAnimator", + "Trigger" + ] } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json deleted file mode 100644 index ebe1593..0000000 --- a/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "schemaVersion": 1, - "id": "bounced", - "version": "${version}", - - "name": "Bounced", - "description": "Such A Vibrant Title!", - "authors": [ - "KrLite" - ], - "contact": { - "homepage": "https://github.com/KrLite", - "sources": "https://github.com/KrLite/Bounced" - }, - - "license": "GPL-3.0", - "icon": "assets/bounced/icon.png", - - "environment": "*", - "entrypoints": { - "main": [ - "net.krlite.bounced.Bounced" - ] - }, - "mixins": [ - "bounced.mixins.json" - ], - - "depends": { - "fabricloader": ">=0.14.19", - "fabric": "*", - "minecraft": ["~1.19", "~1.19.1", "~1.19.2"] - }, - "suggests": { - } -} diff --git a/src/main/resources/assets/bounced/icon.png b/src/main/resources/icon.png similarity index 100% rename from src/main/resources/assets/bounced/icon.png rename to src/main/resources/icon.png diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta new file mode 100644 index 0000000..aa72783 --- /dev/null +++ b/src/main/resources/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "Resources", + "pack_format": 9 + } +}