.
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### [`→` CurseForge](https://www.curseforge.com/minecraft/mc-mods/bounced) [`→` Modrinth](https://modrinth.com/mod/bounced)
2 |
3 | # Bounced!
4 |
5 | ###### Bounces Your Minecraft Title as It Loads.
6 |
7 |
8 |
9 | **Bounced** does nothing except making your Minecraft titles bounced every time the titles are shown, adding a little vitality to the rigid title screen.
10 |
11 | **Bounced** may be too simple to have a config, and if you don't like the animations, just uninstall the mod. Otherwise if you like it, feel free recommending **Bounced** to your friends!
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | base
3 | java
4 | idea
5 | `maven-publish`
6 | alias(libs.plugins.fabric.loom)
7 | alias(libs.plugins.modpublisher)
8 | }
9 |
10 | val display = libs.versions.display
11 |
12 | group = libs.versions.maven.group.get()
13 | version = "${libs.versions.mod.get()}-${libs.versions.loader.get()}.${libs.versions.minecraft.get()}"
14 |
15 | base {
16 | archivesName.set(libs.versions.archives.name)
17 | }
18 |
19 | repositories {
20 | mavenCentral()
21 | maven { url = uri("https://jitpack.io") }
22 | maven { url = uri("https://api.modrinth.com/maven") }
23 | }
24 |
25 | dependencies {
26 | minecraft(libs.minecraft)
27 | mappings(libs.yarn) { artifact { classifier = "v2" } }
28 | modImplementation(libs.bundles.fabric)
29 |
30 | modCompileOnly(libs.splasher)
31 | }
32 |
33 | java {
34 | sourceCompatibility = JavaVersion.VERSION_21
35 | targetCompatibility = JavaVersion.VERSION_21
36 |
37 | withSourcesJar()
38 | }
39 |
40 | tasks {
41 | processResources {
42 | filesMatching("fabric.mod.json") {
43 | expand(mapOf(
44 | "version" to libs.versions.mod.get(),
45 | "display" to display
46 | ))
47 | }
48 | }
49 |
50 | jar {
51 | from("LICENSE")
52 | }
53 | }
54 |
55 | publishing {
56 | publications {
57 | create("mavenJava") {
58 | from(components["java"])
59 | }
60 | }
61 |
62 | repositories {
63 | }
64 | }
65 |
66 | publisher {
67 | apiKeys {
68 | modrinth(System.getenv("MODRINTH_TOKEN"))
69 | curseforge(System.getenv("CURSEFORGE_TOKEN"))
70 | }
71 |
72 | modrinthID.set(libs.versions.id.modrinth)
73 | curseID.set(libs.versions.id.curseforge)
74 |
75 | versionType.set("release")
76 | projectVersion.set(project.version.toString())
77 | gameVersions.set(listOf("1.21"))
78 | loaders.set(listOf("fabric", "quilt"))
79 | curseEnvironment.set("client")
80 |
81 | modrinthDepends.required("fabric-api")
82 | modrinthDepends.optional("splasher")
83 | modrinthDepends.embedded()
84 |
85 | curseDepends.required("fabric-api")
86 | curseDepends.optional("splasher")
87 | curseDepends.embedded()
88 |
89 | displayName.set("${display.name.get()} ${libs.versions.mod.get()} for ${display.loader.get()} ${display.version.get()}")
90 |
91 | artifact.set(tasks.remapJar)
92 | addAdditionalFile(tasks.remapSourcesJar)
93 |
94 | changelog.set(file("CHANGELOG.md"))
95 | }
96 |
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | maven-group = "band.kessokuteatime"
3 | archives-name = "bounced"
4 | mod = "4.1.3"
5 | loader = "fabric"
6 |
7 | minecraft = "1.21"
8 | yarn = "1.21+build.9"
9 | fabric-loader = "0.15.11"
10 | fabric-api = "0.100.6+1.21"
11 | fabric-loom = "1.6-SNAPSHOT"
12 | modpublisher = "2.1.0"
13 |
14 | splasher = "6.2.3-fabric.1.21"
15 |
16 | # id
17 | id-modrinth = "2mlOZXZr"
18 | id-curseforge = "844458"
19 |
20 | # display
21 | display-name = "Bounced"
22 | display-loader = "Fabric"
23 | display-version = "1.21+"
24 |
25 | [libraries]
26 | minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft" }
27 | yarn = { group = "net.fabricmc", name = "yarn", version.ref = "yarn" }
28 | fabric-loader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fabric-loader" }
29 | fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabric-api" }
30 |
31 | splasher = { group = "maven.modrinth", name = "splasher", version.ref = "splasher" }
32 |
33 | [plugins]
34 | fabric-loom = { id = "fabric-loom", version.ref = "fabric-loom" }
35 | modpublisher = { id = "com.hypherionmc.modutils.modpublisher", version.ref = "modpublisher" }
36 |
37 | [bundles]
38 | fabric = ["fabric-loader", "fabric-api"]
39 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KessokuTeaTime/Bounced/443a0cfd4f3d3f2a0281e8b24ff5b15cf99884d7/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
4 | networkTimeout=10000
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | # This is normally unused
84 | # shellcheck disable=SC2034
85 | APP_BASE_NAME=${0##*/}
86 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87 |
88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147 | # shellcheck disable=SC3045
148 | MAX_FD=$( ulimit -H -n ) ||
149 | warn "Could not query maximum file descriptor limit"
150 | esac
151 | case $MAX_FD in #(
152 | '' | soft) :;; #(
153 | *)
154 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155 | # shellcheck disable=SC3045
156 | ulimit -n "$MAX_FD" ||
157 | warn "Could not set maximum file descriptor limit to $MAX_FD"
158 | esac
159 | fi
160 |
161 | # Collect all arguments for the java command, stacking in reverse order:
162 | # * args from the command line
163 | # * the main class name
164 | # * -classpath
165 | # * -D...appname settings
166 | # * --module-path (only if needed)
167 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
168 |
169 | # For Cygwin or MSYS, switch paths to Windows format before running java
170 | if "$cygwin" || "$msys" ; then
171 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
172 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
173 |
174 | JAVACMD=$( cygpath --unix "$JAVACMD" )
175 |
176 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
177 | for arg do
178 | if
179 | case $arg in #(
180 | -*) false ;; # don't mess with options #(
181 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
182 | [ -e "$t" ] ;; #(
183 | *) false ;;
184 | esac
185 | then
186 | arg=$( cygpath --path --ignore --mixed "$arg" )
187 | fi
188 | # Roll the args list around exactly as many times as the number of
189 | # args, so each arg winds up back in the position where it started, but
190 | # possibly modified.
191 | #
192 | # NB: a `for` loop captures its iteration list before it begins, so
193 | # changing the positional parameters here affects neither the number of
194 | # iterations, nor the values presented in `arg`.
195 | shift # remove old arg
196 | set -- "$@" "$arg" # push replacement arg
197 | done
198 | fi
199 |
200 | # Collect all arguments for the java command;
201 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
202 | # shell script including quotes and variable substitutions, so put them in
203 | # double quotes to make sure that they get re-expanded; and
204 | # * put everything else in single quotes, so that it's not re-expanded.
205 |
206 | set -- \
207 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
208 | -classpath "$CLASSPATH" \
209 | org.gradle.wrapper.GradleWrapperMain \
210 | "$@"
211 |
212 | # Stop when "xargs" is not available.
213 | if ! command -v xargs >/dev/null 2>&1
214 | then
215 | die "xargs is not available"
216 | fi
217 |
218 | # Use "xargs" to parse quoted args.
219 | #
220 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
221 | #
222 | # In Bash we could simply go:
223 | #
224 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
225 | # set -- "${ARGS[@]}" "$@"
226 | #
227 | # but POSIX shell has neither arrays nor command substitution, so instead we
228 | # post-process each arg (as a line of input to sed) to backslash-escape any
229 | # character that might be a shell metacharacter, then use eval to reverse
230 | # that process (while maintaining the separation between arguments), and wrap
231 | # the whole thing up as a single "set" statement.
232 | #
233 | # This will of course break if any of these variables contains a newline or
234 | # an unmatched quote.
235 | #
236 |
237 | eval "set -- $(
238 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
239 | xargs -n1 |
240 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
241 | tr '\n' ' '
242 | )" '"$@"'
243 |
244 | exec "$JAVACMD" "$@"
245 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo.
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48 | echo.
49 | echo Please set the JAVA_HOME variable in your environment to match the
50 | echo location of your Java installation.
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo.
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62 | echo.
63 | echo Please set the JAVA_HOME variable in your environment to match the
64 | echo location of your Java installation.
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/jitpack.yml:
--------------------------------------------------------------------------------
1 | jdk:
2 | - openjdk21
3 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | maven {
4 | name = "Fabric"
5 | url = uri("https://maven.fabricmc.net/")
6 | }
7 | maven { url = uri("https://maven.firstdark.dev/releases") } // modpublisher
8 | mavenCentral()
9 | gradlePluginPortal()
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/band/kessokuteatime/bounced/Bounced.java:
--------------------------------------------------------------------------------
1 | package band.kessokuteatime.bounced;
2 |
3 | import band.kessokuteatime.splasher.Splasher;
4 | import net.fabricmc.api.ClientModInitializer;
5 | import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
6 | import net.fabricmc.fabric.api.client.screen.v1.ScreenMouseEvents;
7 | import net.fabricmc.loader.api.FabricLoader;
8 | import net.minecraft.client.MinecraftClient;
9 | import net.minecraft.client.gui.screen.AccessibilityOnboardingScreen;
10 | import net.minecraft.client.gui.screen.TitleScreen;
11 | import org.slf4j.Logger;
12 | import org.slf4j.LoggerFactory;
13 |
14 | import java.util.concurrent.atomic.AtomicBoolean;
15 |
16 | public class Bounced implements ClientModInitializer {
17 | public static final String NAME = "Bounced!", ID = "bounced";
18 | public static final Logger LOGGER = LoggerFactory.getLogger(ID);
19 | private static double primaryPos, secondaryPos;
20 | private static long startTime = -1, initializationTime = -1, thresholdOffset;
21 | private static final long
22 | primaryAnimationTime = 863 /* Animation time for the 'MINECRAFT' logo */ ,
23 | secondaryAnimationTime = 936 /* Animation time for the 'EDITION' banner and splash text */ ;
24 | private static final AtomicBoolean
25 | shouldAnimate = new AtomicBoolean(true),
26 | shouldJump = new AtomicBoolean(false);
27 |
28 | @Override
29 | public void onInitializeClient() {
30 | boolean isSplasherLoaded = FabricLoader.getInstance().isModLoaded("splasher");
31 |
32 | ScreenEvents.BEFORE_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
33 | if (screen instanceof TitleScreen || screen instanceof AccessibilityOnboardingScreen) {
34 | ScreenMouseEvents.beforeMouseClick(screen)
35 | .register((currentScreen, mouseX, mouseY, button) -> {
36 | double centerX = scaledWidth / 2.0, y = 30 + primaryPos(), width = 310, height = 44;
37 | if (!isIntro()
38 | && mouseX >= centerX - width / 2 && mouseX <= centerX + width / 2
39 | && mouseY >= y && mouseY <= y + height
40 | ) {
41 | // Linkage with Splasher
42 | if (!isSplasherLoaded || !Splasher.isMouseHovering(scaledWidth, mouseX, mouseY))
43 | push();
44 | }
45 | });
46 | }
47 | });
48 | }
49 |
50 | public static double offset(boolean isIntro) {
51 | return MinecraftClient.getInstance().getWindow().getScaledHeight() / (isIntro ? 4.1 : 7.0);
52 | }
53 |
54 | public static void update() {
55 | double offset = offset(isIntro());
56 | if (isIntro()) {
57 | primaryPos = (shouldAnimate.get() ? 0 : easeOutBounce(primaryAnimationTime) * offset) - offset;
58 | secondaryPos = (shouldAnimate.get() ? 0 : easeOutBounce(secondaryAnimationTime) * offset) - offset;
59 | } else {
60 | if (shouldAnimate.get()) {
61 | primaryPos = 0;
62 | secondaryPos = 0;
63 | }
64 | else {
65 | if (shouldJump.get() && Math.max(Math.abs(-offset - primaryPos()), Math.abs(-offset - secondaryPos())) > 0.5) {
66 | primaryPos += (-offset - primaryPos()) * 0.26;
67 | secondaryPos += (-offset - secondaryPos()) * 0.23;
68 |
69 | startTime = System.currentTimeMillis();
70 | } else {
71 | shouldJump.set(false);
72 |
73 | primaryPos = easeOutBounce(primaryAnimationTime) * offset - offset;
74 | secondaryPos = easeOutBounce(secondaryAnimationTime) * offset - offset;
75 | }
76 | }
77 | }
78 | }
79 |
80 | public static double primaryPos() {
81 | return primaryPos;
82 | }
83 |
84 | public static double secondaryPos() {
85 | return secondaryPos;
86 | }
87 |
88 | public static long totalAnimationTime() {
89 | return Math.max(primaryAnimationTime, secondaryAnimationTime);
90 | }
91 |
92 | public static boolean isIntro() {
93 | return System.currentTimeMillis() - (initializationTime + thresholdOffset) <= totalAnimationTime();
94 | }
95 |
96 | public static void init() {
97 | init(false);
98 | }
99 |
100 | public static void init(boolean force) {
101 | if (force || !isIntro()) {
102 | initializationTime = System.currentTimeMillis();
103 | thresholdOffset = -1;
104 | shouldJump.set(false);
105 | }
106 | }
107 |
108 | public static void push() {
109 | shouldAnimate.set(true);
110 | shouldJump.set(true);
111 | }
112 |
113 | public static void resetWhen(boolean condition) {
114 | if (condition && shouldAnimate.getAndSet(false)) {
115 | startTime = System.currentTimeMillis();
116 | if (thresholdOffset == -1) thresholdOffset = System.currentTimeMillis() - initializationTime;
117 | }
118 | }
119 |
120 | public static double easeOutBounce(double animationTime) {
121 | double progress = Math.min((System.currentTimeMillis() - startTime) / animationTime, 1);
122 |
123 | if (progress < 1 / 2.75) {
124 | return 7.5625 * progress * progress;
125 | } else if (progress < 2 / 2.75) {
126 | progress -= 1.5 / 2.75;
127 | return 7.5625 * progress * progress + 0.75;
128 | } else if (progress < 2.5 / 2.75) {
129 | progress -= 2.25 / 2.75;
130 | return 7.5625 * progress * progress + 0.9375;
131 | } else {
132 | progress -= 2.625 / 2.75;
133 | return 7.5625 * progress * progress + 0.984375;
134 | }
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/src/main/java/band/kessokuteatime/bounced/mixin/LogoDrawerAnimator.java:
--------------------------------------------------------------------------------
1 | package band.kessokuteatime.bounced.mixin;
2 |
3 | import band.kessokuteatime.bounced.Bounced;
4 | import net.minecraft.client.gui.DrawContext;
5 | import net.minecraft.client.gui.LogoDrawer;
6 | import org.spongepowered.asm.mixin.Mixin;
7 | import org.spongepowered.asm.mixin.injection.At;
8 | import org.spongepowered.asm.mixin.injection.Inject;
9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
10 |
11 | /**
12 | * This class is responsible for animating the logo.
13 | */
14 | @Mixin(LogoDrawer.class)
15 | public abstract class LogoDrawerAnimator {
16 | /**
17 | * Applies the animation transformation to the 'MINECRAFT' logo.
18 | */
19 | @Inject(
20 | method = "draw(Lnet/minecraft/client/gui/DrawContext;IFI)V",
21 | at = @At(
22 | value = "INVOKE",
23 | target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIFFIIII)V",
24 | shift = At.Shift.BEFORE,
25 | ordinal = 0
26 | )
27 | )
28 | private void animateLogoPre(DrawContext context, int screenWidth, float alpha, int y, CallbackInfo ci) {
29 | context.getMatrices().push();
30 | context.getMatrices().translate(0, Bounced.primaryPos(), 0);
31 | }
32 |
33 | /**
34 | * Pops the matrix stack after rendering the 'MINECRAFT' logo.
35 | */
36 | @Inject(
37 | method = "draw(Lnet/minecraft/client/gui/DrawContext;IFI)V",
38 | at = @At(
39 | value = "INVOKE",
40 | target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIFFIIII)V",
41 | shift = At.Shift.AFTER,
42 | ordinal = 0
43 | )
44 | )
45 | private void animateLogoPost(DrawContext context, int screenWidth, float alpha, int y, CallbackInfo ci) {
46 | context.getMatrices().pop();
47 | }
48 |
49 | /**
50 | * Applies the animation transformation to the 'EDITION' banner.
51 | */
52 | @Inject(
53 | method = "draw(Lnet/minecraft/client/gui/DrawContext;IFI)V",
54 | at = @At(
55 | value = "INVOKE",
56 | target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIFFIIII)V",
57 | shift = At.Shift.BEFORE,
58 | ordinal = 1
59 | )
60 | )
61 | private void animateBannerPre(DrawContext context, int screenWidth, float alpha, int y, CallbackInfo ci) {
62 | context.getMatrices().push();
63 | context.getMatrices().translate(0, Bounced.secondaryPos(), 0);
64 | }
65 |
66 | /**
67 | * Pops the matrix stack after rendering the 'EDITION' banner.
68 | */
69 | @Inject(
70 | method = "draw(Lnet/minecraft/client/gui/DrawContext;IFI)V",
71 | at = @At(
72 | value = "INVOKE",
73 | target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIFFIIII)V",
74 | shift = At.Shift.AFTER,
75 | ordinal = 1
76 | )
77 | )
78 | private void animateBannerPost(DrawContext context, int screenWidth, float alpha, int y, CallbackInfo ci) {
79 | context.getMatrices().pop();
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/band/kessokuteatime/bounced/mixin/SplashTextAnimator.java:
--------------------------------------------------------------------------------
1 | package band.kessokuteatime.bounced.mixin;
2 |
3 | import band.kessokuteatime.bounced.Bounced;
4 | import net.minecraft.client.gui.screen.*;
5 | import org.spongepowered.asm.mixin.Mixin;
6 | import org.spongepowered.asm.mixin.injection.*;
7 |
8 | /**
9 | * This class is responsible for triggering the animation and animating the splash text.
10 | */
11 | @Mixin(SplashTextRenderer.class)
12 | class SplashTextAnimator {
13 | /**
14 | * Applies the animation transformation to the splash text.
15 | */
16 | @ModifyArg(
17 | method = "render",
18 | at = @At(
19 | value = "INVOKE",
20 | target = "Lnet/minecraft/client/util/math/MatrixStack;translate(FFF)V",
21 | ordinal = 0
22 | ), index = 1
23 | )
24 | private float animateSplashText(float y) {
25 | return (float) (y + Bounced.secondaryPos());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/band/kessokuteatime/bounced/mixin/Trigger.java:
--------------------------------------------------------------------------------
1 | package band.kessokuteatime.bounced.mixin;
2 |
3 |
4 | import band.kessokuteatime.bounced.Bounced;
5 | import net.minecraft.client.MinecraftClient;
6 | import net.minecraft.client.gui.DrawContext;
7 | import net.minecraft.client.gui.screen.AccessibilityOnboardingScreen;
8 | import net.minecraft.client.gui.screen.Screen;
9 | import net.minecraft.client.gui.screen.TitleScreen;
10 | import net.minecraft.util.math.MathHelper;
11 | import org.spongepowered.asm.mixin.Mixin;
12 | import org.spongepowered.asm.mixin.Shadow;
13 | import org.spongepowered.asm.mixin.injection.At;
14 | import org.spongepowered.asm.mixin.injection.Inject;
15 | import org.spongepowered.asm.mixin.injection.ModifyArg;
16 | import org.spongepowered.asm.mixin.injection.Redirect;
17 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
18 |
19 | /**
20 | * This class is responsible for triggering the title animation before the title screen is rendered.
21 | */
22 | @Mixin(MinecraftClient.class)
23 | public class Trigger {
24 | @Inject(method = "setScreen", at = @At("TAIL"))
25 | private void trigger(Screen screen, CallbackInfo ci) {
26 | if (!(screen instanceof TitleScreen || screen instanceof AccessibilityOnboardingScreen)) {
27 | Bounced.push();
28 | }
29 | }
30 | }
31 |
32 | /**
33 | * This class is responsible for triggering the title animation when the game starts for the first time.
34 | */
35 | @Mixin(AccessibilityOnboardingScreen.class)
36 | class AccessibilityOnboardingTrigger {
37 | @Inject(method = "init", at = @At("RETURN"))
38 | private void init(CallbackInfo ci) {
39 | Bounced.init(true);
40 | }
41 |
42 | /**
43 | * Triggers and restarts the animation.
44 | */
45 | @ModifyArg(
46 | method = "renderPanoramaBackground",
47 | at = @At(
48 | value = "INVOKE",
49 | target = "Lnet/minecraft/client/gui/RotatingCubeMapRenderer;render(Lnet/minecraft/client/gui/DrawContext;IIFF)V"
50 | ), index = 3
51 | )
52 | private float trigger(float progress) {
53 | Bounced.resetWhen(progress > 0.9);
54 | Bounced.update();
55 | return progress;
56 | }
57 | }
58 |
59 | /**
60 | * This class is responsible for triggering the animation every time the title screen is shown.
61 | */
62 | @Mixin(TitleScreen.class)
63 | class TitleScreenTrigger {
64 | @Shadow
65 | private boolean doBackgroundFade;
66 |
67 | @Inject(method = "init", at = @At("RETURN"))
68 | private void init(CallbackInfo ci) {
69 | Bounced.init(true);
70 | }
71 |
72 | /**
73 | * Triggers the animation when background is fading.
74 | */
75 | @Redirect(
76 | method = "render",
77 | at = @At(
78 | value = "INVOKE",
79 | target = "Lnet/minecraft/util/math/MathHelper;clampedMap(FFFFF)F"
80 | )
81 | )
82 | private float trigger(float value, float oldStart, float oldEnd, float newStart, float newEnd) {
83 | float clamped = MathHelper.clampedMap(value, oldStart, oldEnd, newStart, newEnd);
84 | Bounced.resetWhen(clamped > 0.9);
85 | return clamped;
86 | }
87 |
88 | /**
89 | * Triggers and restarts the animation at normal render phases.
90 | */
91 | @Inject(
92 | method = "render",
93 | at = @At("HEAD")
94 | )
95 | private void trigger(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
96 | Bounced.resetWhen(!doBackgroundFade);
97 | Bounced.update();
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/src/main/resources/assets/bounced/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KessokuTeaTime/Bounced/443a0cfd4f3d3f2a0281e8b24ff5b15cf99884d7/src/main/resources/assets/bounced/icon.png
--------------------------------------------------------------------------------
/src/main/resources/assets/bounced/lang/tt_ru.json:
--------------------------------------------------------------------------------
1 | {
2 | "modmenu.descriptionTranslation.bounced": "Шундый кыймылдаучы исем!"
3 | }
4 |
--------------------------------------------------------------------------------
/src/main/resources/assets/bounced/lang/zh_cn.json:
--------------------------------------------------------------------------------
1 | {
2 | "modmenu.descriptionTranslation.bounced": "让你的Minecraft标题跳动!"
3 | }
--------------------------------------------------------------------------------
/src/main/resources/bounced.mixins.json:
--------------------------------------------------------------------------------
1 | {
2 | "required": true,
3 | "minVersion": "0.8",
4 | "package": "band.kessokuteatime.bounced.mixin",
5 | "compatibilityLevel": "JAVA_17",
6 | "mixins": [
7 | ],
8 | "client": [
9 | "AccessibilityOnboardingTrigger",
10 | "LogoDrawerAnimator",
11 | "SplashTextAnimator",
12 | "TitleScreenTrigger",
13 | "Trigger"
14 | ],
15 | "injectors": {
16 | "defaultRequire": 0
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/resources/fabric.mod.json:
--------------------------------------------------------------------------------
1 | {
2 | "schemaVersion": 1,
3 | "id": "bounced",
4 | "version": "${version}",
5 |
6 | "name": "${display.name.get()}",
7 | "description": "Get your 'Minecraft' bounced!",
8 | "authors": [
9 | "Kessoku Tea Time",
10 | "KrLite"
11 | ],
12 | "contact": {
13 | "homepage": "https://modrinth.com/mod/bounced",
14 | "sources": "https://github.com/KessokuTeaTime/Bounced",
15 | "issues": "https://github.com/KessokuTeaTime/Bounced/issues"
16 | },
17 |
18 | "license": "GPL-3.0",
19 | "icon": "assets/bounced/icon.png",
20 |
21 | "environment": "client",
22 | "entrypoints": {
23 | "client": [
24 | "band.kessokuteatime.bounced.Bounced"
25 | ]
26 | },
27 | "mixins": [
28 | "bounced.mixins.json"
29 | ],
30 |
31 | "depends": {
32 | "fabricloader": "*",
33 | "fabric-api": "*",
34 | "minecraft": "1.21.x"
35 | },
36 | "suggests": {
37 | "splasher": "*"
38 | }
39 | }
40 |
--------------------------------------------------------------------------------