Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
0f2c9b947b | |||
5a136233af |
3
.gitignore
vendored
3
.gitignore
vendored
@ -13,5 +13,4 @@
|
|||||||
!gradlew.bat
|
!gradlew.bat
|
||||||
!LICENSE
|
!LICENSE
|
||||||
!readme.md
|
!readme.md
|
||||||
!settings.gradle
|
!settings.gradle
|
||||||
!run/
|
|
13
README.md
13
README.md
@ -1,24 +1,21 @@
|
|||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
<img src="src/main/resources/assets/animated-chunks/icon.png" width="100">
|
<img src="src/main/resources/assets/smooth-chunks/icon.png" width="100">
|
||||||
|
|
||||||
# Animated Chunks
|
# Smooth Chunks
|
||||||
|
|
||||||
[![Mod Loader](https://img.shields.io/badge/Mod%20Loader-Fabric-lightyellow?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAFHGlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDIgNzkuMTYwOTI0LCAyMDE3LzA3LzEzLTAxOjA2OjM5ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxOCAoV2luZG93cykiIHhtcDpDcmVhdGVEYXRlPSIyMDE4LTEyLTE2VDE2OjU0OjE3LTA4OjAwIiB4bXA6TW9kaWZ5RGF0ZT0iMjAxOS0wNy0yOFQyMToxNzo0OC0wNzowMCIgeG1wOk1ldGFkYXRhRGF0ZT0iMjAxOS0wNy0yOFQyMToxNzo0OC0wNzowMCIgZGM6Zm9ybWF0PSJpbWFnZS9wbmciIHBob3Rvc2hvcDpDb2xvck1vZGU9IjMiIHBob3Rvc2hvcDpJQ0NQcm9maWxlPSJzUkdCIElFQzYxOTY2LTIuMSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDowZWRiMWMyYy1mZjhjLWU0NDEtOTMxZi00OTVkNGYxNGM3NjAiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MGVkYjFjMmMtZmY4Yy1lNDQxLTkzMWYtNDk1ZDRmMTRjNzYwIiB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6MGVkYjFjMmMtZmY4Yy1lNDQxLTkzMWYtNDk1ZDRmMTRjNzYwIj4gPHhtcE1NOkhpc3Rvcnk+IDxyZGY6U2VxPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY3JlYXRlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDowZWRiMWMyYy1mZjhjLWU0NDEtOTMxZi00OTVkNGYxNGM3NjAiIHN0RXZ0OndoZW49IjIwMTgtMTItMTZUMTY6NTQ6MTctMDg6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCBDQyAyMDE4IChXaW5kb3dzKSIvPiA8L3JkZjpTZXE+IDwveG1wTU06SGlzdG9yeT4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz4/HiGMAAAAtUlEQVRYw+XXrQqAMBQF4D2P2eBL+QIG8RnEJFaNBjEum+0+zMQLtwwv+wV3ZzhhMDgfJ0wUSinxZUQWgKos1JP/AbD4OneIDyQPwCFniA+EJ4CaXm4TxAXCC0BNHgLhAdAnx9hC8PwGSRtAFVMQjF7cNTWED8B1cgwW20yfJgAvrssAsZ1cB3g/xckAxr6FmCDU5N6f488BrpCQ4rQBJkiMYh4ACmLzwOQF0CExinkCsvw7vgGikl+OotaKRwAAAABJRU5ErkJggg==)](https://fabricmc.net)
|
[![Mod Loader](https://img.shields.io/badge/Mod%20Loader-Fabric-lightyellow?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAFHGlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDIgNzkuMTYwOTI0LCAyMDE3LzA3LzEzLTAxOjA2OjM5ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxOCAoV2luZG93cykiIHhtcDpDcmVhdGVEYXRlPSIyMDE4LTEyLTE2VDE2OjU0OjE3LTA4OjAwIiB4bXA6TW9kaWZ5RGF0ZT0iMjAxOS0wNy0yOFQyMToxNzo0OC0wNzowMCIgeG1wOk1ldGFkYXRhRGF0ZT0iMjAxOS0wNy0yOFQyMToxNzo0OC0wNzowMCIgZGM6Zm9ybWF0PSJpbWFnZS9wbmciIHBob3Rvc2hvcDpDb2xvck1vZGU9IjMiIHBob3Rvc2hvcDpJQ0NQcm9maWxlPSJzUkdCIElFQzYxOTY2LTIuMSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDowZWRiMWMyYy1mZjhjLWU0NDEtOTMxZi00OTVkNGYxNGM3NjAiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MGVkYjFjMmMtZmY4Yy1lNDQxLTkzMWYtNDk1ZDRmMTRjNzYwIiB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6MGVkYjFjMmMtZmY4Yy1lNDQxLTkzMWYtNDk1ZDRmMTRjNzYwIj4gPHhtcE1NOkhpc3Rvcnk+IDxyZGY6U2VxPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY3JlYXRlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDowZWRiMWMyYy1mZjhjLWU0NDEtOTMxZi00OTVkNGYxNGM3NjAiIHN0RXZ0OndoZW49IjIwMTgtMTItMTZUMTY6NTQ6MTctMDg6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCBDQyAyMDE4IChXaW5kb3dzKSIvPiA8L3JkZjpTZXE+IDwveG1wTU06SGlzdG9yeT4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz4/HiGMAAAAtUlEQVRYw+XXrQqAMBQF4D2P2eBL+QIG8RnEJFaNBjEum+0+zMQLtwwv+wV3ZzhhMDgfJ0wUSinxZUQWgKos1JP/AbD4OneIDyQPwCFniA+EJ4CaXm4TxAXCC0BNHgLhAdAnx9hC8PwGSRtAFVMQjF7cNTWED8B1cgwW20yfJgAvrssAsZ1cB3g/xckAxr6FmCDU5N6f488BrpCQ4rQBJkiMYh4ACmLzwOQF0CExinkCsvw7vgGikl+OotaKRwAAAABJRU5ErkJggg==)](https://fabricmc.net)
|
||||||
![Enviroment](https://img.shields.io/badge/Enviroment-Client-purple)
|
![Enviroment](https://img.shields.io/badge/Enviroment-Client-purple)
|
||||||
|
[![Modrinth](https://img.shields.io/badge/dynamic/json?color=158000&label=downloads&prefix=+%20&query=downloads&url=https://api.modrinth.com/api/v1/mod/animated-chunks&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMSAxMSIgd2lkdGg9IjE0LjY2NyIgaGVpZ2h0PSIxNC42NjciICB4bWxuczp2PSJodHRwczovL3ZlY3RhLmlvL25hbm8iPjxkZWZzPjxjbGlwUGF0aCBpZD0iQSI+PHBhdGggZD0iTTAgMGgxMXYxMUgweiIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNBKSI+PHBhdGggZD0iTTEuMzA5IDcuODU3YTQuNjQgNC42NCAwIDAgMS0uNDYxLTEuMDYzSDBDLjU5MSA5LjIwNiAyLjc5NiAxMSA1LjQyMiAxMWMxLjk4MSAwIDMuNzIyLTEuMDIgNC43MTEtMi41NTZoMGwtLjc1LS4zNDVjLS44NTQgMS4yNjEtMi4zMSAyLjA5Mi0zLjk2MSAyLjA5MmE0Ljc4IDQuNzggMCAwIDEtMy4wMDUtMS4wNTVsMS44MDktMS40NzQuOTg0Ljg0NyAxLjkwNS0xLjAwM0w4LjE3NCA1LjgybC0uMzg0LS43ODYtMS4xMTYuNjM1LS41MTYuNjk0LS42MjYuMjM2LS44NzMtLjM4N2gwbC0uMjEzLS45MS4zNTUtLjU2Ljc4Ny0uMzcuODQ1LS45NTktLjcwMi0uNTEtMS44NzQuNzEzLTEuMzYyIDEuNjUxLjY0NSAxLjA5OC0xLjgzMSAxLjQ5MnptOS42MTQtMS40NEE1LjQ0IDUuNDQgMCAwIDAgMTEgNS41QzExIDIuNDY0IDguNTAxIDAgNS40MjIgMCAyLjc5NiAwIC41OTEgMS43OTQgMCA0LjIwNmguODQ4QzEuNDE5IDIuMjQ1IDMuMjUyLjgwOSA1LjQyMi44MDljMi42MjYgMCA0Ljc1OCAyLjEwMiA0Ljc1OCA0LjY5MSAwIC4xOS0uMDEyLjM3Ni0uMDM0LjU2bC43NzcuMzU3aDB6IiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGZpbGw9IiM1ZGE0MjYiLz48L2c+PC9zdmc+)](https://modrinth.com/mod/animated-chunks)
|
||||||
[![Modrinth](https://img.shields.io/modrinth/dt/animated-chunks?color=00AF5C&label=downloads&logo=modrinth)](https://modrinth.com/mod/animated-chunks)
|
[![CurseForge](https://cf.way2muchnoise.eu/full_animated-chunks_downloads.svg)](https://curseforge.com/minecraft/mc-mods/animated-chunks)
|
||||||
[![CurseForge](https://cf.way2muchnoise.eu/full_678609_downloads.svg)](https://curseforge.com/minecraft/mc-mods/animated-chunks)
|
|
||||||
|
|
||||||
An enhanecd fork of [cadenkriese's mod](https://github.com/cadenkriese/smooth-chunks) for the latest versions of the game, with a completely different code base.
|
An enhanecd fork of [cadenkriese's mod](https://github.com/cadenkriese/smooth-chunks) for the latest versions of the game, with a completely different code base.
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
**NOTE: This mod WILL NOT support Sodium, since Sodium doesn't render separate chunks, but whole regions, hence separate chunk animations are rendered impossible. Anyone interested in making sodium compatibility, be my guest**
|
|
||||||
|
|
||||||
## What is this?
|
## What is this?
|
||||||
|
|
||||||
Animated Chunks is a Fabric mod that adds animations of currently loading chunks. This makes chunk loading generally seem much more pleasant than them appearing out of thin air. There are multiple built-in animations and ease types, and if this isnt't enough, there's an API which will allow you to add your own animations and eases<br/>(with ease :trollface:)
|
Smooth Chunks is a Fabric mod that adds animations of currently loading chunks. This makes chunk loading generally seem much more pleasant than them appearing out of thin air. There are multiple built-in animations and ease types, and if this isnt't enough, there's an API which will allow you to add your own animations and eases <br/> (with ease :trollface:)
|
||||||
|
|
||||||
Generally, this is what you'd call an "eye-candy" mod.
|
Generally, this is what you'd call an "eye-candy" mod.
|
||||||
|
|
||||||
|
@ -14,10 +14,6 @@ repositories {
|
|||||||
maven {
|
maven {
|
||||||
url "https://maven.terraformersmc.com/releases"
|
url "https://maven.terraformersmc.com/releases"
|
||||||
}
|
}
|
||||||
// maven {
|
|
||||||
// url "https://jitpack.io/"
|
|
||||||
// }
|
|
||||||
mavenLocal()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -54,7 +50,6 @@ dependencies {
|
|||||||
// include("me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig_version}")
|
// include("me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig_version}")
|
||||||
|
|
||||||
modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}")
|
modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}")
|
||||||
// modImplementation("com.github.CaffeineMC:sodium-fabric:${project.sodium_version}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,16 +3,15 @@
|
|||||||
org.gradle.jvmargs=-Xmx4G
|
org.gradle.jvmargs=-Xmx4G
|
||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
minecraft_version=1.19.2
|
minecraft_version=1.18.2
|
||||||
yarn_mappings=1.19.2+build.28
|
yarn_mappings=1.18.2+build.1
|
||||||
loader_version=0.14.12
|
loader_version=0.14.9
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=0.3.0
|
mod_version=0.2.0
|
||||||
maven_group=me.topchetoeu
|
maven_group=me.topchetoeu
|
||||||
archives_base_name=animated-chunks
|
archives_base_name=animated-chunks
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
fabric_version=0.72.0+1.19.2
|
fabric_version=0.58.0+1.18.2
|
||||||
modmenu_version=4.1.2
|
modmenu_version=3.2.1
|
||||||
# sodium_version=mc1.19.2-0.4.3
|
|
||||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
257
gradlew
vendored
257
gradlew
vendored
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright © 2015-2021 the original authors.
|
# Copyright 2015 the original author or authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@ -17,101 +17,67 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
##
|
||||||
# Gradle start up script for POSIX generated by Gradle.
|
## Gradle start up script for UN*X
|
||||||
#
|
##
|
||||||
# Important for running:
|
|
||||||
#
|
|
||||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
||||||
# noncompliant, but you have some other compliant shell such as ksh or
|
|
||||||
# bash, then to run this script, type that shell name before the whole
|
|
||||||
# command line, like:
|
|
||||||
#
|
|
||||||
# ksh Gradle
|
|
||||||
#
|
|
||||||
# Busybox and similar reduced shells will NOT work, because this script
|
|
||||||
# requires all of these POSIX shell features:
|
|
||||||
# * functions;
|
|
||||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
||||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
||||||
# * compound commands having a testable exit status, especially «case»;
|
|
||||||
# * various built-in commands including «command», «set», and «ulimit».
|
|
||||||
#
|
|
||||||
# Important for patching:
|
|
||||||
#
|
|
||||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
||||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
||||||
#
|
|
||||||
# The "traditional" practice of packing multiple parameters into a
|
|
||||||
# space-separated string is a well documented source of bugs and security
|
|
||||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
||||||
# options in "$@", and eventually passing that to Java.
|
|
||||||
#
|
|
||||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
||||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
||||||
# see the in-line comments for details.
|
|
||||||
#
|
|
||||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
||||||
# Darwin, MinGW, and NonStop.
|
|
||||||
#
|
|
||||||
# (3) This script is generated from the Groovy template
|
|
||||||
# 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/.
|
|
||||||
#
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
app_path=$0
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
# Need this for daisy-chained symlinks.
|
while [ -h "$PRG" ] ; do
|
||||||
while
|
ls=`ls -ld "$PRG"`
|
||||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
[ -h "$app_path" ]
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
do
|
PRG="$link"
|
||||||
ls=$( ls -ld "$app_path" )
|
else
|
||||||
link=${ls#*' -> '}
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
case $link in #(
|
fi
|
||||||
/*) app_path=$link ;; #(
|
|
||||||
*) app_path=$APP_HOME$link ;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
APP_NAME="Gradle"
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# 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"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD="maximum"
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
} >&2
|
}
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
} >&2
|
}
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "$( uname )" in #(
|
case "`uname`" in
|
||||||
CYGWIN* ) cygwin=true ;; #(
|
CYGWIN* )
|
||||||
Darwin* ) darwin=true ;; #(
|
cygwin=true
|
||||||
MSYS* | MINGW* ) msys=true ;; #(
|
;;
|
||||||
NONSTOP* ) nonstop=true ;;
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
@ -121,9 +87,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
else
|
else
|
||||||
JAVACMD=$JAVA_HOME/bin/java
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
@ -132,7 +98,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD="java"
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
@ -140,95 +106,80 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
case $MAX_FD in #(
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
max*)
|
if [ $? -eq 0 ] ; then
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
warn "Could not query maximum file descriptor limit"
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
esac
|
fi
|
||||||
case $MAX_FD in #(
|
ulimit -n $MAX_FD
|
||||||
'' | soft) :;; #(
|
if [ $? -ne 0 ] ; then
|
||||||
*)
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
ulimit -n "$MAX_FD" ||
|
fi
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
else
|
||||||
esac
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command, stacking in reverse order:
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
# * args from the command line
|
if $darwin; then
|
||||||
# * the main class name
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
# * -classpath
|
fi
|
||||||
# * -D...appname settings
|
|
||||||
# * --module-path (only if needed)
|
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if "$cygwin" || "$msys" ; then
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
for arg do
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
if
|
SEP=""
|
||||||
case $arg in #(
|
for dir in $ROOTDIRSRAW ; do
|
||||||
-*) false ;; # don't mess with options #(
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
SEP="|"
|
||||||
[ -e "$t" ] ;; #(
|
|
||||||
*) false ;;
|
|
||||||
esac
|
|
||||||
then
|
|
||||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
|
||||||
fi
|
|
||||||
# Roll the args list around exactly as many times as the number of
|
|
||||||
# args, so each arg winds up back in the position where it started, but
|
|
||||||
# possibly modified.
|
|
||||||
#
|
|
||||||
# NB: a `for` loop captures its iteration list before it begins, so
|
|
||||||
# changing the positional parameters here affects neither the number of
|
|
||||||
# iterations, nor the values presented in `arg`.
|
|
||||||
shift # remove old arg
|
|
||||||
set -- "$@" "$arg" # push replacement arg
|
|
||||||
done
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=`expr $i + 1`
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
0) set -- ;;
|
||||||
|
1) set -- "$args0" ;;
|
||||||
|
2) set -- "$args0" "$args1" ;;
|
||||||
|
3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
# Escape application args
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
save () {
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
# double quotes to make sure that they get re-expanded; and
|
echo " "
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
}
|
||||||
|
APP_ARGS=`save "$@"`
|
||||||
|
|
||||||
set -- \
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
-classpath "$CLASSPATH" \
|
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
|
||||||
"$@"
|
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
|
||||||
#
|
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
||||||
#
|
|
||||||
# In Bash we could simply go:
|
|
||||||
#
|
|
||||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
|
||||||
# set -- "${ARGS[@]}" "$@"
|
|
||||||
#
|
|
||||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
|
||||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
|
||||||
# character that might be a shell metacharacter, then use eval to reverse
|
|
||||||
# that process (while maintaining the separation between arguments), and wrap
|
|
||||||
# the whole thing up as a single "set" statement.
|
|
||||||
#
|
|
||||||
# This will of course break if any of these variables contains a newline or
|
|
||||||
# an unmatched quote.
|
|
||||||
#
|
|
||||||
|
|
||||||
eval "set -- $(
|
|
||||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
|
||||||
xargs -n1 |
|
|
||||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
|
||||||
tr '\n' ' '
|
|
||||||
)" '"$@"'
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
@ -5,10 +5,11 @@ import java.io.File;
|
|||||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||||
|
|
||||||
|
import me.topchetoeu.animatedchunks.Manager.RegisterEvent;
|
||||||
import me.topchetoeu.animatedchunks.animation.Animation;
|
import me.topchetoeu.animatedchunks.animation.Animation;
|
||||||
import me.topchetoeu.animatedchunks.animation.FallAnimation;
|
import me.topchetoeu.animatedchunks.animation.FallAnimation;
|
||||||
import me.topchetoeu.animatedchunks.animation.FlyInAnimation;
|
import me.topchetoeu.animatedchunks.animation.FlyInAnimation;
|
||||||
import me.topchetoeu.animatedchunks.animation.Animator;
|
import me.topchetoeu.animatedchunks.animation.ProgressManager;
|
||||||
import me.topchetoeu.animatedchunks.animation.RiseAnimation;
|
import me.topchetoeu.animatedchunks.animation.RiseAnimation;
|
||||||
import me.topchetoeu.animatedchunks.animation.ScaleAnimation;
|
import me.topchetoeu.animatedchunks.animation.ScaleAnimation;
|
||||||
import me.topchetoeu.animatedchunks.easing.Ease;
|
import me.topchetoeu.animatedchunks.easing.Ease;
|
||||||
@ -19,27 +20,54 @@ import me.topchetoeu.animatedchunks.easing.SineEase;
|
|||||||
import me.topchetoeu.animatedchunks.gui.AnimatedChunksScreen;
|
import me.topchetoeu.animatedchunks.gui.AnimatedChunksScreen;
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientChunkEvents;
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientChunkEvents;
|
||||||
|
import net.fabricmc.fabric.api.event.Event;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
public final class AnimatedChunks implements ClientModInitializer, ModMenuApi {
|
public final class AnimatedChunks implements ClientModInitializer, ModMenuApi {
|
||||||
private static AnimatedChunks instance;
|
private static AnimatedChunks instance;
|
||||||
/**
|
|
||||||
* Gets the currently running instance of this mod
|
|
||||||
*/
|
|
||||||
public static AnimatedChunks getInstance() {
|
public static AnimatedChunks getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The animator used by the mod. Used to manage animation progress and animate chunks
|
* An event, fired once, when eases are being registered
|
||||||
*/
|
*/
|
||||||
public final Animator animator;
|
public final Event<RegisterEvent<Ease>> EASES_REGISTERING = Manager.createEvent();
|
||||||
/**
|
/**
|
||||||
* The config manager used by the mod. Used to save/load config from disk
|
* An event, fired once, when animations are being registered
|
||||||
*/
|
*/
|
||||||
public final ConfigManager config;
|
public final Event<RegisterEvent<Animation>> ANIMATIONS_REGISTERING = Manager.createEvent();
|
||||||
|
|
||||||
|
private ProgressManager progress;
|
||||||
|
private ConfigManager config;
|
||||||
|
private Manager<Ease> ease;
|
||||||
|
private Manager<Animation> animation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the config manager
|
||||||
|
*/
|
||||||
|
public ConfigManager getConfigManager() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Gets the chunk progress manager
|
||||||
|
*/
|
||||||
|
public ProgressManager getProgressManager() {
|
||||||
|
return progress;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Gets the animation manager
|
||||||
|
*/
|
||||||
|
public Manager<Animation> getAnimationManager() {
|
||||||
|
return animation;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Gets the ease manager
|
||||||
|
*/
|
||||||
|
public Manager<Ease> getEaseManager() {
|
||||||
|
return ease;
|
||||||
|
}
|
||||||
|
|
||||||
private static void registerEases(Manager<Ease> manager) {
|
private static void registerEases(Manager<Ease> manager) {
|
||||||
manager.register(new Descriptor<>(new LinearEase(), "linear")
|
manager.register(new Descriptor<>(new LinearEase(), "linear")
|
||||||
@ -63,7 +91,7 @@ public final class AnimatedChunks implements ClientModInitializer, ModMenuApi {
|
|||||||
.description("Animation takes off very quickly, overshoots, then undershoots, until it reaches the end.")
|
.description("Animation takes off very quickly, overshoots, then undershoots, until it reaches the end.")
|
||||||
);
|
);
|
||||||
|
|
||||||
manager.set("sine");
|
manager.set("elastic");
|
||||||
}
|
}
|
||||||
private static void registerAnimations(Manager<Animation> manager) {
|
private static void registerAnimations(Manager<Animation> manager) {
|
||||||
manager.register(new Descriptor<>(new RiseAnimation(), "rise")
|
manager.register(new Descriptor<>(new RiseAnimation(), "rise")
|
||||||
@ -93,35 +121,34 @@ public final class AnimatedChunks implements ClientModInitializer, ModMenuApi {
|
|||||||
@Override public void onInitializeClient() {
|
@Override public void onInitializeClient() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
|
progress = new ProgressManager();
|
||||||
|
ease = new Manager<>(x -> 1);
|
||||||
|
ease.get()
|
||||||
|
.description("Ends the animation as soon as it has started.")
|
||||||
|
.displayName("No animation");
|
||||||
|
animation = new Manager<>((a, b, c, d, e, f, g, h) -> {});
|
||||||
|
animation.get()
|
||||||
|
.description("Does nothing.")
|
||||||
|
.displayName("No animation");
|
||||||
|
|
||||||
|
registerEases(ease);
|
||||||
|
registerAnimations(animation);
|
||||||
|
|
||||||
|
config = new ConfigManager(new File("config/animated-chunks.dat"), animation, ease);
|
||||||
|
|
||||||
|
EASES_REGISTERING.invoker().register(ease);
|
||||||
|
ANIMATIONS_REGISTERING.invoker().register(animation);
|
||||||
|
|
||||||
ClientChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> {
|
ClientChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> {
|
||||||
BlockPos pos = chunk.getPos().getStartPos();
|
BlockPos pos = chunk.getPos().getStartPos();
|
||||||
animator.unload(pos.getX(), pos.getY(), pos.getZ());
|
progress.unload(pos.getX(), pos.getY(), pos.getZ());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||||
return (Screen parent) -> {
|
return (Screen parent) -> {
|
||||||
var _this = getInstance();
|
var _this = getInstance();
|
||||||
return new AnimatedChunksScreen(parent, _this.config, _this.animator);
|
return new AnimatedChunksScreen(parent, _this.animation, _this.ease, _this.config);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public AnimatedChunks() {
|
|
||||||
var eases = new Manager<>(new Descriptor<Ease>(x -> 1, "default")
|
|
||||||
.author("TopchetoEU")
|
|
||||||
.description("Ends the animation as soon as it has started.")
|
|
||||||
.displayName("No animation")
|
|
||||||
);
|
|
||||||
var animations = new Manager<>(new Descriptor<Animation>((a, b, c, d, e, f, g, h) -> {}, "default")
|
|
||||||
.author("TopchetoEU")
|
|
||||||
.description("Does nothing.")
|
|
||||||
.displayName("No animation")
|
|
||||||
);
|
|
||||||
|
|
||||||
registerEases(eases);
|
|
||||||
registerAnimations(animations);
|
|
||||||
|
|
||||||
animator = new Animator(animations, eases);
|
|
||||||
config = new ConfigManager(new File("config/animated-chunks.dat"), animator);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
package me.topchetoeu.animatedchunks;
|
package me.topchetoeu.animatedchunks;
|
||||||
|
|
||||||
import java.io.EOFException;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileReader;
|
||||||
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStreamWriter;
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
|
|
||||||
import me.topchetoeu.animatedchunks.animation.Animator;
|
import me.topchetoeu.animatedchunks.animation.Animation;
|
||||||
|
import me.topchetoeu.animatedchunks.easing.Ease;
|
||||||
|
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
public final File configFile;
|
public final File configFile;
|
||||||
private final Animator animator;
|
private final Manager<Animation> animation;
|
||||||
|
private final Manager<Ease> ease;
|
||||||
|
|
||||||
private String readString(InputStream reader) throws IOException {
|
private String readString(InputStreamReader reader) throws IOException {
|
||||||
String res = "";
|
String res = "";
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -26,46 +27,36 @@ public class ConfigManager {
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
private void writeString(OutputStream writer, String str) throws IOException {
|
private void writeString(OutputStreamWriter writer, String str) throws IOException {
|
||||||
for (int i = 0; i < str.length(); i++) {
|
for (int i = 0; i < str.length(); i++) {
|
||||||
writer.write((byte)str.charAt(i));
|
writer.write((char)str.charAt(i));
|
||||||
}
|
|
||||||
writer.write((byte)0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private float readFloat(InputStream reader) throws IOException {
|
|
||||||
try {
|
|
||||||
var bytes = reader.readNBytes(4);
|
|
||||||
return ByteBuffer.wrap(bytes).getFloat();
|
|
||||||
}
|
|
||||||
catch (IndexOutOfBoundsException e) {
|
|
||||||
throw new EOFException();
|
|
||||||
}
|
}
|
||||||
|
writer.write(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reload() {
|
public void reload() {
|
||||||
try {
|
try {
|
||||||
var reader = new FileInputStream(configFile);
|
var reader = new FileReader(configFile);
|
||||||
String animation = readString(reader);
|
String animation = readString(reader);
|
||||||
String ease = readString(reader);
|
String ease = readString(reader);
|
||||||
float duration = readFloat(reader);
|
|
||||||
|
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
||||||
this.animator.ANIMATIONS.set(animation);
|
this.animation.set(animation);
|
||||||
this.animator.EASES.set(ease);
|
this.ease.set(ease);
|
||||||
this.animator.setDuration(duration);
|
}
|
||||||
|
catch (FileNotFoundException e) {
|
||||||
|
save();
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
save();
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void save() {
|
public void save() {
|
||||||
try {
|
try {
|
||||||
var writer = new FileOutputStream(configFile);
|
var writer = new FileWriter(configFile);
|
||||||
writeString(writer, this.animator.ANIMATIONS.get().getName());
|
writeString(writer, animation.get().getName());
|
||||||
writeString(writer, this.animator.EASES.get().getName());
|
writeString(writer, ease.get().getName());
|
||||||
writer.write(ByteBuffer.allocate(4).putFloat(animator.getDuration()).array());
|
|
||||||
writer.close();
|
writer.close();
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
@ -73,9 +64,10 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigManager(File configFile, Animator animator) {
|
public ConfigManager(File configFile, Manager<Animation> animation, Manager<Ease> ease) {
|
||||||
this.configFile = configFile;
|
this.configFile = configFile;
|
||||||
this.animator = animator;
|
this.animation = animation;
|
||||||
|
this.ease = ease;
|
||||||
|
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,21 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.event.Event;
|
||||||
|
import net.fabricmc.fabric.api.event.EventFactory;
|
||||||
|
|
||||||
public final class Manager<T> {
|
public final class Manager<T> {
|
||||||
|
public static interface RegisterEvent<T> {
|
||||||
|
public void register(Manager<T> manager);
|
||||||
|
}
|
||||||
|
public static final <T> Event<RegisterEvent<T>> createEvent() {
|
||||||
|
return EventFactory.createArrayBacked(RegisterEvent.class, (listeners) -> (manager) -> {
|
||||||
|
for (RegisterEvent<T> listener: listeners) {
|
||||||
|
listener.register(manager);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private String currName = null;
|
private String currName = null;
|
||||||
private Map<String, Descriptor<T>> objects = new Hashtable<>();
|
private Map<String, Descriptor<T>> objects = new Hashtable<>();
|
||||||
|
|
||||||
@ -61,8 +75,8 @@ public final class Manager<T> {
|
|||||||
return Collections.unmodifiableCollection(objects.values());
|
return Collections.unmodifiableCollection(objects.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Manager(Descriptor<T> _default) {
|
public Manager(T _default) {
|
||||||
register(_default);
|
register(new Descriptor<>(_default, "default").displayName("Default").author("TopchetoEU"));
|
||||||
set("default");
|
set("default");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,184 +1,146 @@
|
|||||||
package me.topchetoeu.animatedchunks.animation;
|
package me.topchetoeu.animatedchunks.animation;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
|
||||||
import me.topchetoeu.animatedchunks.Manager;
|
public final class ProgressManager {
|
||||||
import me.topchetoeu.animatedchunks.easing.Ease;
|
public static class ChunkLoc {
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
public final int x;
|
||||||
import net.minecraft.client.util.math.Vector3d;
|
public final int y;
|
||||||
import net.minecraft.util.math.BlockPos;
|
public final int z;
|
||||||
|
|
||||||
public final class Animator {
|
@Override
|
||||||
public static class ChunkLoc {
|
public boolean equals(Object obj) {
|
||||||
public final int x;
|
return obj instanceof ChunkLoc && ((ChunkLoc)obj).x == x && ((ChunkLoc)obj).y == y && ((ChunkLoc)obj).z == z;
|
||||||
public final int y;
|
}
|
||||||
public final int z;
|
|
||||||
|
@Override
|
||||||
@Override
|
public int hashCode() {
|
||||||
public boolean equals(Object obj) {
|
return 137 * x + 149 * y + 163 * z;
|
||||||
return obj instanceof ChunkLoc && ((ChunkLoc)obj).x == x && ((ChunkLoc)obj).y == y && ((ChunkLoc)obj).z == z;
|
}
|
||||||
}
|
|
||||||
@Override
|
public ChunkLoc(int x, int y, int z) {
|
||||||
public int hashCode() {
|
this.x = x;
|
||||||
return 137 * x + 149 * y + 163 * z;
|
this.y = y;
|
||||||
}
|
this.z = z;
|
||||||
|
}
|
||||||
public ChunkLoc(int x, int y, int z) {
|
}
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
private Hashtable<ChunkLoc, Float> chunkToStage = new Hashtable<>();
|
||||||
this.z = z;
|
private HashSet<ChunkLoc> chunks = new HashSet<>();
|
||||||
}
|
private float duration = 1;
|
||||||
}
|
|
||||||
|
public ProgressManager() {
|
||||||
public final Manager<Animation> ANIMATIONS;
|
|
||||||
public final Manager<Ease> EASES;
|
}
|
||||||
|
|
||||||
private Hashtable<ChunkLoc, Float> chunkToStage = new Hashtable<>();
|
public float getDuration() {
|
||||||
private HashSet<ChunkLoc> chunks = new HashSet<>();
|
return duration;
|
||||||
private float duration = 1;
|
}
|
||||||
|
public void setDuration(float duration) {
|
||||||
public Animator(Manager<Animation> animations, Manager<Ease> eases) {
|
this.duration = duration;
|
||||||
ANIMATIONS = animations;
|
}
|
||||||
EASES = eases;
|
|
||||||
}
|
/**
|
||||||
|
* Removes all loaded chunks (called when a world is unloaded and loaded)
|
||||||
public float getDuration() {
|
*/
|
||||||
return duration;
|
public void reset() {
|
||||||
}
|
chunkToStage.clear();
|
||||||
public void setDuration(float duration) {
|
chunks.clear();
|
||||||
this.duration = duration;
|
}
|
||||||
}
|
/**
|
||||||
|
* Advances the animation for all tracked chunks, according to the duration and the specified delta
|
||||||
/**
|
* @param delta The second delta to advance the animation by
|
||||||
* Removes all loaded chunks (called when a world is unloaded and loaded)
|
*/
|
||||||
*/
|
public void tick(float delta) {
|
||||||
public void reset() {
|
for (ChunkLoc loc : new ArrayList<>(chunkToStage.keySet())) {
|
||||||
chunkToStage.clear();
|
float val = chunkToStage.get(loc);
|
||||||
chunks.clear();
|
val += delta / duration;
|
||||||
}
|
if (val > 1f) chunkToStage.remove(loc);
|
||||||
/**
|
chunkToStage.put(loc, val);
|
||||||
* Advances the animation for all tracked chunks, according to the duration and the specified delta
|
}
|
||||||
* @param delta The second delta to advance the animation by
|
}
|
||||||
*/
|
|
||||||
public void tick(float delta) {
|
/**
|
||||||
for (ChunkLoc loc : new ArrayList<>(chunkToStage.keySet())) {
|
* Loads a specified chunk (starts tracking its animation)
|
||||||
float val = chunkToStage.get(loc);
|
* @param x The x of the chunk
|
||||||
val += delta / duration;
|
* @param y The y of the chunk
|
||||||
if (val > 1f) chunkToStage.remove(loc);
|
* @param y The z of the chunk
|
||||||
chunkToStage.put(loc, val);
|
*/
|
||||||
}
|
public void load(int x, int y, int z) {
|
||||||
}
|
if (isChunkLoaded(x, y, z)) return;
|
||||||
|
ChunkLoc loc = new ChunkLoc(x, y, z);
|
||||||
/**
|
chunks.add(loc);
|
||||||
* Loads a specified chunk (starts tracking its animation)
|
chunkToStage.put(loc, 0f);
|
||||||
* @param x The x of the chunk
|
}
|
||||||
* @param y The y of the chunk
|
/**
|
||||||
* @param y The z of the chunk
|
* Unloads a specified chunk (stops tracking its animation)
|
||||||
*/
|
* @param x The x of the chunk
|
||||||
public void load(int x, int y, int z) {
|
* @param y The y of the chunk
|
||||||
if (isChunkLoaded(x, y, z)) return;
|
* @param y The z of the chunk
|
||||||
ChunkLoc loc = new ChunkLoc(x, y, z);
|
*/
|
||||||
chunks.add(loc);
|
public void unload(int x, int y, int z) {
|
||||||
chunkToStage.put(loc, 0f);
|
ChunkLoc loc = new ChunkLoc(x, y, z);
|
||||||
}
|
chunkToStage.remove(loc);
|
||||||
/**
|
chunks.remove(loc);
|
||||||
* Unloads a specified chunk (stops tracking its animation)
|
}
|
||||||
* @param x The x of the chunk
|
/**
|
||||||
* @param y The y of the chunk
|
* Unloads all loaded chunks
|
||||||
* @param y The z of the chunk
|
*/
|
||||||
*/
|
public void unloadAll() {
|
||||||
public void unload(int x, int y, int z) {
|
chunkToStage.clear();
|
||||||
ChunkLoc loc = new ChunkLoc(x, y, z);
|
chunks.clear();
|
||||||
chunkToStage.remove(loc);
|
}
|
||||||
chunks.remove(loc);
|
/**
|
||||||
}
|
* Unloads all the chunks that are outside the render distance specified
|
||||||
/**
|
* @param viewDistance The view distance (in chunks, radius)
|
||||||
* Unloads all loaded chunks
|
* @param playerChunkX The x coordinate of the chunk in which the player stands
|
||||||
*/
|
* @param playerChunkY The y coordinate of the chunk in which the player stands
|
||||||
public void unloadAll() {
|
* @param playerChunkZ The z coordinate of the chunk in which the player stands
|
||||||
chunkToStage.clear();
|
*/
|
||||||
chunks.clear();
|
public void unloadAllFar(int viewDistance, int playerChunkX, int playerChunkY, int playerChunkZ) {
|
||||||
}
|
float circleVD = viewDistance + 1.38f;
|
||||||
/**
|
int squareVD = viewDistance;
|
||||||
* Unloads all the chunks that are outside the render distance specified
|
|
||||||
* @param viewDistance The view distance (in chunks, radius)
|
for (ChunkLoc loc : new ArrayList<>(chunks)) {
|
||||||
* @param playerChunkX The x coordinate of the chunk in which the player stands
|
int chunkX = loc.x / 16;
|
||||||
* @param playerChunkY The y coordinate of the chunk in which the player stands
|
int chunkZ = loc.z / 16;
|
||||||
* @param playerChunkZ The z coordinate of the chunk in which the player stands
|
|
||||||
*/
|
int diffSquareX = playerChunkX - chunkX ;
|
||||||
public void unloadAllFar(int viewDistance, int playerChunkX, int playerChunkY, int playerChunkZ) {
|
int diffSquareZ = playerChunkZ - chunkZ;
|
||||||
float circleVD = viewDistance + 1.38f;
|
|
||||||
int squareVD = viewDistance;
|
int diffCircleX = playerChunkX - chunkX;
|
||||||
|
int diffCircleZ = playerChunkZ - chunkZ;
|
||||||
for (ChunkLoc loc : new ArrayList<>(chunks)) {
|
|
||||||
int chunkX = loc.x / 16;
|
int dist = diffCircleX * diffCircleX + diffCircleZ * diffCircleZ;
|
||||||
int chunkZ = loc.z / 16;
|
|
||||||
|
if (dist > circleVD * circleVD) unload(loc.x, loc.y, loc.z);
|
||||||
int diffSquareX = playerChunkX - chunkX ;
|
if (Math.abs(diffSquareX) > squareVD || Math.abs(diffSquareZ) > squareVD) unload(loc.x, loc.y, loc.z);
|
||||||
int diffSquareZ = playerChunkZ - chunkZ;
|
}
|
||||||
|
}
|
||||||
int diffCircleX = playerChunkX - chunkX;
|
|
||||||
int diffCircleZ = playerChunkZ - chunkZ;
|
/**
|
||||||
|
* Checks whether or not a chunk is loaded
|
||||||
int dist = diffCircleX * diffCircleX + diffCircleZ * diffCircleZ;
|
* @param x The x of the chunk
|
||||||
|
* @param y The y of the chunk
|
||||||
if (dist > circleVD * circleVD) unload(loc.x, loc.y, loc.z);
|
* @param y The z of the chunk
|
||||||
if (Math.abs(diffSquareX) > squareVD || Math.abs(diffSquareZ) > squareVD) unload(loc.x, loc.y, loc.z);
|
* @return A value indicating whether or not the specified chunk is tracked
|
||||||
}
|
*/
|
||||||
}
|
public boolean isChunkLoaded(int x, int y, int z) {
|
||||||
|
return chunks.contains(new ChunkLoc(x, y, z));
|
||||||
/**
|
}
|
||||||
* Checks whether or not a chunk is loaded
|
|
||||||
* @param x The x of the chunk
|
/**
|
||||||
* @param y The y of the chunk
|
* Gets the animation progress of the specified chunk
|
||||||
* @param y The z of the chunk
|
* @param x The x of the chunk
|
||||||
* @return A value indicating whether or not the specified chunk is tracked
|
* @param y The y of the chunk
|
||||||
*/
|
* @param y The z of the chunk
|
||||||
public boolean isChunkLoaded(int x, int y, int z) {
|
* @return A float value from 0 to 1 (0 if the chunk is not tracked), indicating the animation progress of the specified chunk
|
||||||
return chunks.contains(new ChunkLoc(x, y, z));
|
*/
|
||||||
}
|
public float getChunkProgress(int x, int y, int z) {
|
||||||
|
if (!isChunkLoaded(x, y, z)) return 0f;
|
||||||
/**
|
if (!chunkToStage.containsKey(new ChunkLoc(x, y, z))) return 1f;
|
||||||
* Gets the animation progress of the specified chunk
|
return chunkToStage.get(new ChunkLoc(x, y, z));
|
||||||
* @param x The x of the chunk
|
}
|
||||||
* @param y The y of the chunk
|
}
|
||||||
* @param y The z of the chunk
|
|
||||||
* @return A float value from 0 to 1 (0 if the chunk is not tracked), indicating the animation progress of the specified chunk
|
|
||||||
*/
|
|
||||||
public float getChunkProgress(int x, int y, int z) {
|
|
||||||
if (!isChunkLoaded(x, y, z)) return 0f;
|
|
||||||
if (!chunkToStage.containsKey(new ChunkLoc(x, y, z))) return 1f;
|
|
||||||
return chunkToStage.get(new ChunkLoc(x, y, z));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void animate(MatrixStack matrices, float progress, BlockPos chunkPos, Vector3d playerPos) {
|
|
||||||
if (progress < 0) progress = 0;
|
|
||||||
if (progress > 1) progress = 1;
|
|
||||||
if (progress < 0.999) {
|
|
||||||
float _progress = EASES.getValue().ease(progress);
|
|
||||||
ANIMATIONS.getValue().animate(
|
|
||||||
_progress, matrices,
|
|
||||||
chunkPos.getX() * 16, chunkPos.getY() * 16, chunkPos.getZ() * 16,
|
|
||||||
(float)playerPos.x, (float)playerPos.y, (float)playerPos.z
|
|
||||||
);
|
|
||||||
// matrices.translate(0, 0, 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void animate(MatrixStack matrices, BlockPos chunkPos, Vector3d playerPos) {
|
|
||||||
if (!isChunkLoaded(chunkPos.getX(), chunkPos.getY(), chunkPos.getZ())) {
|
|
||||||
matrices.scale(0, 0, 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
animate(matrices, getChunkProgress(chunkPos.getX(), chunkPos.getY(), chunkPos.getZ()), chunkPos, playerPos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void animate(MatrixStack matrices, BlockPos chunkPos) {
|
|
||||||
animate(matrices, chunkPos, new Vector3d(0, 0, 0));
|
|
||||||
}
|
|
||||||
public void animate(MatrixStack matrices, float progress, BlockPos chunkPos) {
|
|
||||||
animate(matrices, progress, chunkPos, new Vector3d(0, 0, 0));
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,20 +4,23 @@ import net.minecraft.client.gui.screen.Screen;
|
|||||||
import net.minecraft.client.sound.PositionedSoundInstance;
|
import net.minecraft.client.sound.PositionedSoundInstance;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.math.ColorHelper.Argb;
|
import net.minecraft.util.math.ColorHelper.Argb;
|
||||||
import me.topchetoeu.animatedchunks.ConfigManager;
|
import me.topchetoeu.animatedchunks.ConfigManager;
|
||||||
import me.topchetoeu.animatedchunks.Manager;
|
import me.topchetoeu.animatedchunks.Manager;
|
||||||
import me.topchetoeu.animatedchunks.animation.Animator;
|
import me.topchetoeu.animatedchunks.animation.Animation;
|
||||||
|
import me.topchetoeu.animatedchunks.easing.Ease;
|
||||||
import me.topchetoeu.animatedchunks.gui.Section.OrderType;
|
import me.topchetoeu.animatedchunks.gui.Section.OrderType;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
|
||||||
public class AnimatedChunksScreen extends Screen {
|
public class AnimatedChunksScreen extends Screen {
|
||||||
public final Screen parent;
|
public final Screen parent;
|
||||||
private final HorizontalSection mainSection = new HorizontalSection();
|
private final HorizontalSection mainSection = new HorizontalSection();
|
||||||
|
private final Manager<Animation> animation;
|
||||||
|
private final Manager<Ease> ease;
|
||||||
private final ConfigManager config;
|
private final ConfigManager config;
|
||||||
private final Animator animator;
|
|
||||||
|
|
||||||
public static void playClick() {
|
public static void playClick() {
|
||||||
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0f));
|
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0f));
|
||||||
@ -44,6 +47,7 @@ public class AnimatedChunksScreen extends Screen {
|
|||||||
mainSection.order = OrderType.Justified;
|
mainSection.order = OrderType.Justified;
|
||||||
mainSection.children.addSelectableChild(selectionsSection());
|
mainSection.children.addSelectableChild(selectionsSection());
|
||||||
mainSection.children.addSelectableChild(previewSection());
|
mainSection.children.addSelectableChild(previewSection());
|
||||||
|
// setZOffset(parent.getZOffset() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -61,7 +65,7 @@ public class AnimatedChunksScreen extends Screen {
|
|||||||
res.x = res.y = 5;
|
res.x = res.y = 5;
|
||||||
res.title = Text.of("Preview:");
|
res.title = Text.of("Preview:");
|
||||||
|
|
||||||
res.children.addSelectableChild(new ChunkPreview(0, 0, 150, 150, animator));
|
res.children.addSelectableChild(new ChunkPreview(0, 0, 150, 150));
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -78,51 +82,34 @@ public class AnimatedChunksScreen extends Screen {
|
|||||||
buttonSection.order = OrderType.Justified;
|
buttonSection.order = OrderType.Justified;
|
||||||
buttonSection.children.addChild(new Label(
|
buttonSection.children.addChild(new Label(
|
||||||
5, 7,
|
5, 7,
|
||||||
Text.of(manager.get().getDisplayName()).copy().formatted(Formatting.BOLD)
|
new LiteralText(manager.get().getDisplayName()).formatted(Formatting.BOLD)
|
||||||
));
|
));
|
||||||
buttonSection.children.addSelectableChild(new Button(5, 5, Text.of("Select ..."), () -> client.setScreen(selectScreen)));
|
buttonSection.children.addSelectableChild(new Button(5, 5, Text.of("Select ..."), () -> client.setScreen(selectScreen)));
|
||||||
res.children.addSelectableChild(buttonSection);
|
res.children.addSelectableChild(buttonSection);
|
||||||
res.children.addChild(new Label(
|
res.children.addChild(new Label(
|
||||||
5, 3,
|
5, 3,
|
||||||
Text.of("Author: " + manager.get().getAuthorOrDefault())
|
new LiteralText("Author: " + manager.get().getAuthorOrDefault())
|
||||||
).setMaxWidth(width / 2));
|
).setMaxWidth(width / 2));
|
||||||
res.children.addChild(new Label(
|
res.children.addChild(new Label(
|
||||||
5, 3,
|
5, 3,
|
||||||
Text.of(manager.get().getDescriptionOrDefault()).copy().formatted(Formatting.ITALIC)
|
new LiteralText(manager.get().getDescriptionOrDefault()).formatted(Formatting.ITALIC)
|
||||||
).setMaxWidth(width / 2));
|
).setMaxWidth(width / 2));
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
private Section durationSection() {
|
|
||||||
var res = new HorizontalSection();
|
|
||||||
res.setTargetWidth(width / 2);
|
|
||||||
var input = new NumberInput(res, 5, 5, animator.getDuration(), (sender, val) -> {
|
|
||||||
if (val <= 0) sender.invalid = true;
|
|
||||||
else {
|
|
||||||
animator.setDuration(val);
|
|
||||||
sender.invalid = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
input.width = (int)res.getTargetWidth();
|
|
||||||
res.x = res.y = 5;
|
|
||||||
res.title = Text.of("Duration:");
|
|
||||||
res.children.addSelectableChild(input);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
private Section selectionsSection() {
|
private Section selectionsSection() {
|
||||||
var res = new HorizontalSection();
|
var res = new HorizontalSection();
|
||||||
res.x = res.y = 5;
|
res.x = res.y = 5;
|
||||||
res.title = Text.of("Animation config:");
|
res.title = Text.of("Animation config:");
|
||||||
res.children.addSelectableChild(selectionSection(animator.ANIMATIONS, "Animation"));
|
res.children.addSelectableChild(selectionSection(animation, "Animation"));
|
||||||
res.children.addSelectableChild(selectionSection(animator.EASES, "Ease"));
|
res.children.addSelectableChild(selectionSection(ease, "Ease"));
|
||||||
res.children.addSelectableChild(durationSection());
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
public AnimatedChunksScreen(Screen parent, Manager<Animation> animation, Manager<Ease> ease, ConfigManager config) {
|
||||||
public AnimatedChunksScreen(Screen parent, ConfigManager config, Animator animator) {
|
|
||||||
super(Text.of("Animated Chunks Config"));
|
super(Text.of("Animated Chunks Config"));
|
||||||
config.reload();
|
config.reload();
|
||||||
this.animator = animator;
|
this.animation = animation;
|
||||||
|
this.ease = ease;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
mainSection.x = mainSection.y = 5;
|
mainSection.x = mainSection.y = 5;
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public class Button extends DrawableHelper implements Drawable, Element, Selecta
|
|||||||
matrices.push();
|
matrices.push();
|
||||||
matrices.translate(this.x, this.y, getZOffset());
|
matrices.translate(this.x, this.y, getZOffset());
|
||||||
|
|
||||||
hovered = isMouseOver(x - this.x, y - this.y);
|
hovered = isMouseOver(x, y);
|
||||||
|
|
||||||
if (hovered) {
|
if (hovered) {
|
||||||
fill(matrices, 0, 0, (int)getWidth(), (int)getHeight(), Argb.getArgb(32, 255, 255, 255));
|
fill(matrices, 0, 0, (int)getWidth(), (int)getHeight(), Argb.getArgb(32, 255, 255, 255));
|
||||||
@ -109,6 +109,9 @@ public class Button extends DrawableHelper implements Drawable, Element, Selecta
|
|||||||
public boolean isMouseOver(double x, double y) {
|
public boolean isMouseOver(double x, double y) {
|
||||||
if (clicked) return true;
|
if (clicked) return true;
|
||||||
|
|
||||||
|
x -= this.x;
|
||||||
|
y -= this.y;
|
||||||
|
|
||||||
return x >= 0 && x < getWidth() && y >= 0 && y < getHeight();
|
return x >= 0 && x < getWidth() && y >= 0 && y < getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +136,7 @@ public class Button extends DrawableHelper implements Drawable, Element, Selecta
|
|||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
if (button != 0) return false;
|
if (button != 0) return false;
|
||||||
if (isMouseOver(mouseX - this.x, mouseY - this.x)) {
|
if (isMouseOver(mouseX, mouseY)) {
|
||||||
clicked = true;
|
clicked = true;
|
||||||
hovered = true;
|
hovered = true;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import org.lwjgl.opengl.GL11;
|
|||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
import me.topchetoeu.animatedchunks.animation.Animator;
|
import me.topchetoeu.animatedchunks.AnimatedChunks;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.Drawable;
|
import net.minecraft.client.gui.Drawable;
|
||||||
import net.minecraft.client.gui.DrawableHelper;
|
import net.minecraft.client.gui.DrawableHelper;
|
||||||
@ -20,7 +20,6 @@ import net.minecraft.client.render.Tessellator;
|
|||||||
import net.minecraft.client.render.VertexFormat;
|
import net.minecraft.client.render.VertexFormat;
|
||||||
import net.minecraft.client.render.VertexFormats;
|
import net.minecraft.client.render.VertexFormats;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.Matrix4f;
|
import net.minecraft.util.math.Matrix4f;
|
||||||
import net.minecraft.util.math.Quaternion;
|
import net.minecraft.util.math.Quaternion;
|
||||||
import net.minecraft.util.math.Vec3f;
|
import net.minecraft.util.math.Vec3f;
|
||||||
@ -32,10 +31,8 @@ public class ChunkPreview extends DrawableHelper implements Drawable, Element, S
|
|||||||
void onClick();
|
void onClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final MinecraftClient client;
|
|
||||||
public final Animator animator;
|
|
||||||
|
|
||||||
public ClickAction clickAction;
|
public ClickAction clickAction;
|
||||||
|
public final MinecraftClient client;
|
||||||
private boolean clicked = false;
|
private boolean clicked = false;
|
||||||
private boolean rotating = false;
|
private boolean rotating = false;
|
||||||
private boolean focused = false;
|
private boolean focused = false;
|
||||||
@ -92,7 +89,7 @@ public class ChunkPreview extends DrawableHelper implements Drawable, Element, S
|
|||||||
return z < 3;
|
return z < 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void myFill(MatrixStack matrices, float x1, float y1, float x2, float y2, float a, float r, float g, float b) {
|
private static void myFill(MatrixStack matrices, float x1, float y1, float x2, float y2, float a, float r, float g, float b) {
|
||||||
if (x1 < x2) {
|
if (x1 < x2) {
|
||||||
float tmp = x1;
|
float tmp = x1;
|
||||||
x1 = x2;
|
x1 = x2;
|
||||||
@ -124,13 +121,15 @@ public class ChunkPreview extends DrawableHelper implements Drawable, Element, S
|
|||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.disableCull();
|
RenderSystem.disableCull();
|
||||||
RenderSystem.disableTexture();
|
RenderSystem.disableTexture();
|
||||||
|
RenderSystem.defaultBlendFunc();
|
||||||
RenderSystem.setShader(GameRenderer::getPositionColorShader);
|
RenderSystem.setShader(GameRenderer::getPositionColorShader);
|
||||||
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
|
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
|
||||||
bufferBuilder.vertex(p1.getX(), p1.getY(), p1.getZ()).color(r, g, b, a).next();
|
bufferBuilder.vertex(p1.getX(), p1.getY(), p1.getZ()).color(r, g, b, a).next();
|
||||||
bufferBuilder.vertex(p2.getX(), p2.getY(), p2.getZ()).color(r, g, b, a).next();
|
bufferBuilder.vertex(p2.getX(), p2.getY(), p2.getZ()).color(r, g, b, a).next();
|
||||||
bufferBuilder.vertex(p3.getX(), p3.getY(), p3.getZ()).color(r, g, b, a).next();
|
bufferBuilder.vertex(p3.getX(), p3.getY(), p3.getZ()).color(r, g, b, a).next();
|
||||||
bufferBuilder.vertex(p4.getX(), p4.getY(), p4.getZ()).color(r, g, b, a).next();
|
bufferBuilder.vertex(p4.getX(), p4.getY(), p4.getZ()).color(r, g, b, a).next();
|
||||||
BufferRenderer.drawWithShader(bufferBuilder.end());
|
bufferBuilder.end();
|
||||||
|
BufferRenderer.draw(bufferBuilder);
|
||||||
RenderSystem.enableTexture();
|
RenderSystem.enableTexture();
|
||||||
RenderSystem.disableBlend();
|
RenderSystem.disableBlend();
|
||||||
}
|
}
|
||||||
@ -161,30 +160,23 @@ public class ChunkPreview extends DrawableHelper implements Drawable, Element, S
|
|||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
}
|
}
|
||||||
private void renderChunk(MatrixStack matrices, int x, int y, int n, float delta) {
|
private void renderChunk(MatrixStack matrices, int x, int y, int n, float delta) {
|
||||||
duration = animator.getDuration();
|
|
||||||
|
|
||||||
float progress = globalProgress / duration - (float)Math.sqrt(x * x + y * y) / (float)n / 2;
|
|
||||||
if (progress > 1) progress = 1;
|
|
||||||
if (progress <= 0) return;
|
|
||||||
|
|
||||||
matrices.push();
|
matrices.push();
|
||||||
matrices.translate(x * 16 - 8, 0, y * 16 - 8);
|
matrices.translate(x * 16 - 8, 0, y * 16 - 8);
|
||||||
|
|
||||||
// x += n;
|
// x += n;
|
||||||
// y += n;
|
// y += n;
|
||||||
|
|
||||||
animator.animate(matrices, progress, new BlockPos(x * 16, 0, y * 16));
|
float progress = globalProgress / duration - (float)Math.sqrt(x * x + y * y) / (float)n / 2;
|
||||||
|
if (progress < 0) progress = 0;
|
||||||
// if (progress < 0) progress = 0;
|
if (progress > 1) progress = 1;
|
||||||
// if (progress > 1) progress = 1;
|
if (progress < 0.999) {
|
||||||
// if (progress < 0.999) {
|
float _progress = AnimatedChunks.getInstance().getEaseManager().getValue().ease(progress);
|
||||||
// float _progress = animator.EASES.getValue().ease(progress);
|
AnimatedChunks.getInstance().getAnimationManager().getValue().animate(
|
||||||
// AnimatedChunks.getInstance().getAnimationManager().getValue().animate(
|
_progress, matrices,
|
||||||
// _progress, matrices,
|
x * 16, 0, y * 16, 0, 0, 0
|
||||||
// x * 16, 0, y * 16, 0, 0, 0
|
);
|
||||||
// );
|
// matrices.translate(0, 0, 16);
|
||||||
// // matrices.translate(0, 0, 16);
|
}
|
||||||
// }
|
|
||||||
matrices.translate(0, 0, 16);
|
matrices.translate(0, 0, 16);
|
||||||
matrices.multiply(rotation);
|
matrices.multiply(rotation);
|
||||||
myFill(matrices, 2, 1, 14, 2, progress, 1, 1, 1);
|
myFill(matrices, 2, 1, 14, 2, progress, 1, 1, 1);
|
||||||
@ -195,6 +187,7 @@ public class ChunkPreview extends DrawableHelper implements Drawable, Element, S
|
|||||||
matrices.pop();
|
matrices.pop();
|
||||||
}
|
}
|
||||||
private void renderChunks(MatrixStack matrices, float delta, int n) {
|
private void renderChunks(MatrixStack matrices, float delta, int n) {
|
||||||
|
duration = AnimatedChunks.getInstance().getProgressManager().getDuration();
|
||||||
// globalProgress += (lastTime - (lastTime = System.nanoTime())) / -1000000000f;
|
// globalProgress += (lastTime - (lastTime = System.nanoTime())) / -1000000000f;
|
||||||
globalProgress += delta * 0.05f;
|
globalProgress += delta * 0.05f;
|
||||||
matrices.push();
|
matrices.push();
|
||||||
@ -254,6 +247,9 @@ public class ChunkPreview extends DrawableHelper implements Drawable, Element, S
|
|||||||
public boolean isMouseOver(double x, double y) {
|
public boolean isMouseOver(double x, double y) {
|
||||||
if (clicked) return true;
|
if (clicked) return true;
|
||||||
|
|
||||||
|
x -= this.x;
|
||||||
|
y -= this.y;
|
||||||
|
|
||||||
return x >= 0 && x < getWidth() && y >= 0 && y < getHeight();
|
return x >= 0 && x < getWidth() && y >= 0 && y < getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,18 +321,16 @@ public class ChunkPreview extends DrawableHelper implements Drawable, Element, S
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkPreview(int x, int y, Animator animator) {
|
public ChunkPreview(int x, int y) {
|
||||||
this.client = MinecraftClient.getInstance();
|
this.client = MinecraftClient.getInstance();
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.animator = animator;
|
|
||||||
}
|
}
|
||||||
public ChunkPreview(int x, int y, int w, int h, Animator animator) {
|
public ChunkPreview(int x, int y, int w, int h) {
|
||||||
this.client = MinecraftClient.getInstance();
|
this.client = MinecraftClient.getInstance();
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.width = w;
|
this.width = w;
|
||||||
this.height = h;
|
this.height = h;
|
||||||
this.animator = animator;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public final class HorizontalSection extends Section {
|
|||||||
|
|
||||||
private float targetWidth;
|
private float targetWidth;
|
||||||
|
|
||||||
public float getTargetWidth() {
|
public float getTargetWidth(float width) {
|
||||||
return this.targetWidth;
|
return this.targetWidth;
|
||||||
}
|
}
|
||||||
public void setTargetWidth(float width) {
|
public void setTargetWidth(float width) {
|
||||||
|
@ -1,207 +0,0 @@
|
|||||||
package me.topchetoeu.animatedchunks.gui;
|
|
||||||
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager.DstFactor;
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager.SrcFactor;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
|
||||||
import net.minecraft.client.gui.Drawable;
|
|
||||||
import net.minecraft.client.gui.DrawableHelper;
|
|
||||||
import net.minecraft.client.gui.Element;
|
|
||||||
import net.minecraft.client.gui.ParentElement;
|
|
||||||
import net.minecraft.client.gui.Selectable;
|
|
||||||
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
|
|
||||||
import net.minecraft.client.gui.screen.narration.NarrationPart;
|
|
||||||
import net.minecraft.client.render.GameRenderer;
|
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
|
||||||
import net.minecraft.util.math.ColorHelper.Argb;
|
|
||||||
|
|
||||||
public class Input extends DrawableHelper implements Drawable, Element, Selectable, BoundboxProvider {
|
|
||||||
public interface InputAction {
|
|
||||||
void onInput(Input sender, String val);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final MinecraftClient client;
|
|
||||||
private boolean clicked = false;
|
|
||||||
private boolean hovered = false;
|
|
||||||
private boolean isFocused() {
|
|
||||||
return parent.getFocused() == this;
|
|
||||||
}
|
|
||||||
private int index = 0;
|
|
||||||
|
|
||||||
private final ParentElement parent;
|
|
||||||
private String content = "";
|
|
||||||
public int paddingX = 5, paddingY = 2;
|
|
||||||
private float time = 0;
|
|
||||||
public int x, y, width = 100;
|
|
||||||
public boolean invalid = false;
|
|
||||||
public InputAction action = null;
|
|
||||||
|
|
||||||
public String getContent() {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
public Input setContent(String val) {
|
|
||||||
if (index > val.length()) index = val.length();
|
|
||||||
content = val;
|
|
||||||
action.onInput(this, val);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
public float getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getWidth() {
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
public float getHeight() {
|
|
||||||
return 1 + paddingY * 2 + client.textRenderer.fontHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void appendNarrations(NarrationMessageBuilder msgBuilder) {
|
|
||||||
msgBuilder.put(NarrationPart.HINT, "Input");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SelectionType getType() {
|
|
||||||
if (isFocused()) return SelectionType.FOCUSED;
|
|
||||||
if (hovered) return SelectionType.HOVERED;
|
|
||||||
return SelectionType.NONE;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public boolean changeFocus(boolean lookForwards) {
|
|
||||||
if (isFocused()) {
|
|
||||||
parent.setFocused(null);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
parent.setFocused(this);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderCursor(MatrixStack matrices, float delta) {
|
|
||||||
time += delta / 20;
|
|
||||||
|
|
||||||
if ((int)(time * 2) % 2 != 0) return;
|
|
||||||
|
|
||||||
// RenderSystem.enableBlend();
|
|
||||||
RenderSystem.setShader(GameRenderer::getPositionColorShader);
|
|
||||||
RenderSystem.disableCull();
|
|
||||||
RenderSystem.disableTexture();
|
|
||||||
RenderSystem.blendFuncSeparate(SrcFactor.ONE_MINUS_DST_COLOR, DstFactor.ONE_MINUS_SRC_COLOR, SrcFactor.ONE, DstFactor.ZERO);
|
|
||||||
|
|
||||||
float x1 = paddingX + client.textRenderer.getWidth(content.substring(0, index)) + 1;
|
|
||||||
float x2 = x1 + 1;
|
|
||||||
// if (index < content.length()) {
|
|
||||||
// x2 += client.textRenderer.getWidth("" + content.charAt(index)) - 2;
|
|
||||||
// }
|
|
||||||
float y1 = paddingY;
|
|
||||||
float y2 = y1 + client.textRenderer.fontHeight;
|
|
||||||
|
|
||||||
ChunkPreview.myFill(matrices, x1, y1, x2, y2, 1, 1, 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(MatrixStack matrices, int x, int y, float delta) {
|
|
||||||
int white = Argb.getArgb(255, 255, 255, 255);
|
|
||||||
matrices.push();
|
|
||||||
matrices.translate(this.x, this.y, getZOffset());
|
|
||||||
|
|
||||||
hovered = isMouseOver(x, y);
|
|
||||||
|
|
||||||
// if (hovered) {
|
|
||||||
// fill(matrices, 0, 0, (int)getWidth(), (int)getHeight(), Argb.getArgb(32, 255, 255, 255));
|
|
||||||
// }
|
|
||||||
if (clicked) {
|
|
||||||
fill(matrices, 0, 0, (int)getWidth(), (int)getHeight(), Argb.getArgb(127, 255, 255, 255));
|
|
||||||
}
|
|
||||||
|
|
||||||
client.textRenderer.draw(matrices, content, paddingX + 1, paddingY + 1, white);
|
|
||||||
if (isFocused()) renderCursor(matrices, delta);
|
|
||||||
|
|
||||||
if (invalid) white = 0xFFFF0000;
|
|
||||||
|
|
||||||
drawHorizontalLine(matrices, 0, (int)getWidth() - 1, 0, white);
|
|
||||||
drawVerticalLine(matrices, 0, 0, (int)getHeight() - 1, white);
|
|
||||||
drawVerticalLine(matrices, (int)getWidth() - 1, 0, (int)getHeight() - 1, white);
|
|
||||||
drawHorizontalLine(matrices, 0, (int)getWidth() - 1, (int)getHeight() - 1, white);
|
|
||||||
|
|
||||||
// if (focused) {
|
|
||||||
// }
|
|
||||||
|
|
||||||
matrices.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isMouseOver(double x, double y) {
|
|
||||||
if (clicked) return true;
|
|
||||||
|
|
||||||
return x >= 0 && x < getWidth() && y >= 0 && y < getHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean charTyped(char chr, int modifiers) {
|
|
||||||
content = content.substring(0, index) + chr + content.substring(index);
|
|
||||||
action.onInput(this, content);
|
|
||||||
index++;
|
|
||||||
time = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
|
||||||
if (keyCode == GLFW.GLFW_KEY_BACKSPACE && index > 0) {
|
|
||||||
content = content.substring(0, index - 1) + content.substring(index);
|
|
||||||
action.onInput(this, content);
|
|
||||||
index--;
|
|
||||||
}
|
|
||||||
if (keyCode == GLFW.GLFW_KEY_DELETE && index < content.length()) {
|
|
||||||
time = 0;
|
|
||||||
content = content.substring(0, index) + content.substring(index + 1);
|
|
||||||
action.onInput(this, content);
|
|
||||||
}
|
|
||||||
if (keyCode == GLFW.GLFW_KEY_RIGHT && index < content.length()) {
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
if (keyCode == GLFW.GLFW_KEY_LEFT && index > 0) {
|
|
||||||
index--;
|
|
||||||
}
|
|
||||||
time = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
|
||||||
if (button != 0) return false;
|
|
||||||
if (isMouseOver(mouseX - this.x, mouseY - this.y)) {
|
|
||||||
clicked = true;
|
|
||||||
hovered = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
// return true;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
|
||||||
if (button != 0) return false;
|
|
||||||
if (clicked) {
|
|
||||||
clicked = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Input(ParentElement parent, int x, int y, InputAction input) {
|
|
||||||
this.parent = parent;
|
|
||||||
this.action = input;
|
|
||||||
this.client = MinecraftClient.getInstance();
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
package me.topchetoeu.animatedchunks.gui;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.ParentElement;
|
|
||||||
|
|
||||||
public class NumberInput extends Input {
|
|
||||||
public interface InputAction {
|
|
||||||
void input(NumberInput sender, float number);
|
|
||||||
}
|
|
||||||
private float value;
|
|
||||||
public InputAction action;
|
|
||||||
|
|
||||||
public float getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
public NumberInput setValue(float val) {
|
|
||||||
value = val;
|
|
||||||
action.input(this, val);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NumberInput(ParentElement parent, int x, int y, float value, InputAction action) {
|
|
||||||
super(parent, x, y, null);
|
|
||||||
super.action = (sender, val) -> {
|
|
||||||
try {
|
|
||||||
invalid = false;
|
|
||||||
setValue(Float.parseFloat(val.trim()));
|
|
||||||
}
|
|
||||||
catch (NumberFormatException e) {
|
|
||||||
invalid = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
this.action = action;
|
|
||||||
setContent(Float.toString(value));
|
|
||||||
}
|
|
||||||
public NumberInput(ParentElement parent, int x, int y, InputAction action) {
|
|
||||||
this(parent, x, y, 0, action);
|
|
||||||
}
|
|
||||||
}
|
|
@ -181,7 +181,7 @@ public abstract class Section extends AbstractParentElement implements Drawable,
|
|||||||
@Override
|
@Override
|
||||||
public Optional<Element> hoveredElement(double mouseX, double mouseY) {
|
public Optional<Element> hoveredElement(double mouseX, double mouseY) {
|
||||||
for (Selectable element : this.children.selectables) {
|
for (Selectable element : this.children.selectables) {
|
||||||
var offset = children.getOffset(element);
|
var offset = children.getOffsetAndPos(element);
|
||||||
if (element.getType() != SelectionType.HOVERED || !((Element)element).isMouseOver(mouseX - offset.x, mouseY - offset.y)) continue;
|
if (element.getType() != SelectionType.HOVERED || !((Element)element).isMouseOver(mouseX - offset.x, mouseY - offset.y)) continue;
|
||||||
return Optional.of((Element)element);
|
return Optional.of((Element)element);
|
||||||
}
|
}
|
||||||
@ -191,8 +191,8 @@ public abstract class Section extends AbstractParentElement implements Drawable,
|
|||||||
@Override
|
@Override
|
||||||
public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
|
public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
|
||||||
for (Element element : this.children()) {
|
for (Element element : this.children()) {
|
||||||
var offset = children.getOffset(element);
|
var offset = children.getOffsetAndPos(element);
|
||||||
if (!element.mouseScrolled(mouseX - offset.x - x, mouseY - offset.y - y, delta)) continue;
|
if (!element.mouseScrolled(mouseX - offset.x, mouseY - offset.y, delta)) continue;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -200,8 +200,8 @@ public abstract class Section extends AbstractParentElement implements Drawable,
|
|||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
for (Element element : this.children()) {
|
for (Element element : this.children()) {
|
||||||
var offset = children.getOffset(element);
|
var offset = children.getOffsetAndPos(element);
|
||||||
if (!element.mouseClicked(mouseX - offset.x - x, mouseY - offset.y - y, button)) continue;
|
if (!element.mouseClicked(mouseX - offset.x, mouseY - offset.y, button)) continue;
|
||||||
this.setFocused(element);
|
this.setFocused(element);
|
||||||
if (button == 0) {
|
if (button == 0) {
|
||||||
this.setDragging(true);
|
this.setDragging(true);
|
||||||
@ -214,8 +214,8 @@ public abstract class Section extends AbstractParentElement implements Drawable,
|
|||||||
@Override
|
@Override
|
||||||
public void mouseMoved(double mouseX, double mouseY) {
|
public void mouseMoved(double mouseX, double mouseY) {
|
||||||
for (Element element : this.children()) {
|
for (Element element : this.children()) {
|
||||||
var offset = children.getOffset(element);
|
var offset = children.getOffsetAndPos(element);
|
||||||
element.mouseMoved(mouseX - offset.x - x, mouseY - offset.y - y);
|
element.mouseMoved(mouseX - offset.x, mouseY - offset.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,8 +224,8 @@ public abstract class Section extends AbstractParentElement implements Drawable,
|
|||||||
this.setDragging(false);
|
this.setDragging(false);
|
||||||
|
|
||||||
for (Element element : children.get()) {
|
for (Element element : children.get()) {
|
||||||
var offset = children.getOffset(element);
|
var offset = children.getOffsetAndPos(element);
|
||||||
if (element.mouseReleased(mouseX - (int)offset.x - x, mouseY - (int)offset.y - y, button)) return true;
|
if (element.mouseReleased(mouseX - (int)offset.x, mouseY - (int)offset.y, button)) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -234,8 +234,8 @@ public abstract class Section extends AbstractParentElement implements Drawable,
|
|||||||
@Override
|
@Override
|
||||||
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
|
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
|
||||||
if (this.getFocused() != null && this.isDragging() && button == 0) {
|
if (this.getFocused() != null && this.isDragging() && button == 0) {
|
||||||
var offset = children.getOffset(getFocused());
|
var offset = children.getOffsetAndPos(getFocused());
|
||||||
return this.getFocused().mouseDragged(mouseX - offset.x - x, mouseY - offset.y - y, button, deltaX, deltaY);
|
return this.getFocused().mouseDragged(mouseX - offset.x, mouseY - offset.y, button, deltaX, deltaY);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import net.minecraft.client.MinecraftClient;
|
|||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.math.ColorHelper.Argb;
|
import net.minecraft.util.math.ColorHelper.Argb;
|
||||||
@ -44,11 +45,11 @@ public class SelectionScreen<T> extends Screen {
|
|||||||
float y = 0;
|
float y = 0;
|
||||||
matrices.push();
|
matrices.push();
|
||||||
matrices.translate(20, 5, 0);
|
matrices.translate(20, 5, 0);
|
||||||
textRenderer.draw(matrices, Text.of(element.getDisplayNameOrDefault()).copy().formatted(Formatting.BOLD), 0, y, 0xFFFFFFFF);
|
textRenderer.draw(matrices, new LiteralText(element.getDisplayNameOrDefault()).formatted(Formatting.BOLD), 0, y, 0xFFFFFFFF);
|
||||||
y += textRenderer.fontHeight + 3;
|
y += textRenderer.fontHeight + 3;
|
||||||
textRenderer.draw(matrices, Text.of("Author: " + element.getAuthorOrDefault()), 0, y, 0xFFFFFFFF);
|
textRenderer.draw(matrices, new LiteralText("Author: " + element.getAuthorOrDefault()), 0, y, 0xFFFFFFFF);
|
||||||
y += textRenderer.fontHeight + 2;
|
y += textRenderer.fontHeight + 2;
|
||||||
y += drawWarpedText(textRenderer, matrices, Text.of(element.getDescriptionOrDefault()).copy().formatted(Formatting.ITALIC), 0, (int)y, width - 40);
|
y += drawWarpedText(textRenderer, matrices, new LiteralText(element.getDescriptionOrDefault()).formatted(Formatting.ITALIC), 0, (int)y, width - 40);
|
||||||
y += 5;
|
y += 5;
|
||||||
matrices.pop();
|
matrices.pop();
|
||||||
|
|
||||||
|
@ -11,12 +11,12 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
|
|
||||||
// From flogic's mod
|
// From flogic's mod
|
||||||
@Mixin(ChunkBuilder.BuiltChunk.class)
|
@Mixin(ChunkBuilder.BuiltChunk.class)
|
||||||
public abstract class BuiltChunkMixin {
|
abstract class BuiltChunkMixin {
|
||||||
@Inject(method = "clear", at = @At(value = "TAIL"), cancellable = true)
|
@Inject(method = "clear", at = @At(value = "TAIL"), cancellable = true)
|
||||||
public void clear(CallbackInfo ci) {
|
public void clear(CallbackInfo ci) {
|
||||||
// ci.cancel();
|
// ci.cancel();
|
||||||
// return;
|
// return;
|
||||||
BlockPos origin = ((ChunkBuilder.BuiltChunk)(Object)this).getOrigin();
|
BlockPos origin = ((ChunkBuilder.BuiltChunk)(Object)this).getOrigin();
|
||||||
AnimatedChunks.getInstance().animator.unload(origin.getX(), 0, origin.getZ());
|
AnimatedChunks.getInstance().getProgressManager().unload(origin.getX(), 0, origin.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,12 +7,10 @@ import net.minecraft.client.render.GameRenderer;
|
|||||||
import net.minecraft.client.render.LightmapTextureManager;
|
import net.minecraft.client.render.LightmapTextureManager;
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
import net.minecraft.client.render.Shader;
|
import net.minecraft.client.render.Shader;
|
||||||
|
import net.minecraft.client.render.VertexFormat;
|
||||||
import net.minecraft.client.render.WorldRenderer;
|
import net.minecraft.client.render.WorldRenderer;
|
||||||
import net.minecraft.client.render.WorldRenderer.ChunkInfo;
|
|
||||||
import net.minecraft.client.render.chunk.ChunkBuilder.BuiltChunk;
|
import net.minecraft.client.render.chunk.ChunkBuilder.BuiltChunk;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.client.util.math.Vector3d;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.Matrix4f;
|
import net.minecraft.util.math.Matrix4f;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@ -24,17 +22,22 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
|||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
|
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
|
||||||
import me.topchetoeu.animatedchunks.AnimatedChunks;
|
import me.topchetoeu.animatedchunks.AnimatedChunks;
|
||||||
|
import me.topchetoeu.animatedchunks.animation.ProgressManager;
|
||||||
|
|
||||||
@Mixin(WorldRenderer.class)
|
@Mixin(WorldRenderer.class)
|
||||||
public abstract class WorldRendererMixin {
|
abstract class WorldRendererMixin {
|
||||||
private long lastTime = System.nanoTime();
|
private long lastTime = System.nanoTime();
|
||||||
|
|
||||||
@Accessor abstract BuiltChunkStorage getChunks();
|
@Accessor abstract BuiltChunkStorage getChunks();
|
||||||
|
|
||||||
|
private ProgressManager getProgressManager() {
|
||||||
|
return AnimatedChunks.getInstance().getProgressManager();
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "render", at = @At(value = "HEAD"))
|
@Inject(method = "render", at = @At(value = "HEAD"))
|
||||||
private void renderStart(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, CallbackInfo ci) {
|
private void renderStart(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, CallbackInfo ci) {
|
||||||
long currTime = System.nanoTime();
|
long currTime = System.nanoTime();
|
||||||
AnimatedChunks.getInstance().animator.tick((currTime - lastTime) / 1000000000f);
|
getProgressManager().tick((currTime - lastTime) / 1000000000f);
|
||||||
lastTime = currTime;
|
lastTime = currTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,44 +51,48 @@ public abstract class WorldRendererMixin {
|
|||||||
if (playerY < 0) chunkY--;
|
if (playerY < 0) chunkY--;
|
||||||
if (playerZ < 0) chunkZ--;
|
if (playerZ < 0) chunkZ--;
|
||||||
|
|
||||||
AnimatedChunks.getInstance().animator.unloadAllFar((int)((WorldRenderer)(Object)this).getViewDistance(), chunkX, chunkY, chunkZ);
|
getProgressManager().unloadAllFar((int)((WorldRenderer)(Object)this).getViewDistance(), chunkX, chunkY, chunkZ);
|
||||||
}
|
}
|
||||||
@Inject(method = "renderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gl/VertexBuffer;drawElements()V"), locals=LocalCapture.CAPTURE_FAILHARD)
|
@Inject(method = "renderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gl/VertexBuffer;drawVertices()V"), locals=LocalCapture.CAPTURE_FAILHARD)
|
||||||
private void renderChunkBefore(RenderLayer renderLayer, MatrixStack matrices, double playerX, double playerY, double playerZ, Matrix4f positionMatrix, CallbackInfo ci,
|
private void renderChunkBefore(RenderLayer renderLayer, MatrixStack matrices, double playerX, double playerY, double playerZ, Matrix4f positionMatrix, CallbackInfo ci,
|
||||||
boolean _1, ObjectListIterator<?> _2, Shader shader, GlUniform _4, ChunkInfo _6, BuiltChunk chunk) {
|
boolean _1, ObjectListIterator<?> _2, VertexFormat _3, Shader shader, GlUniform _4, boolean _5, WorldRenderer.ChunkInfo _6, BuiltChunk chunk) {
|
||||||
|
|
||||||
matrices.push();
|
matrices.push();
|
||||||
|
|
||||||
AnimatedChunks.getInstance().animator.animate(matrices, new BlockPos(chunk.getOrigin().getX(), 0, chunk.getOrigin().getZ()), new Vector3d(playerX, playerY, playerZ));
|
int x = chunk.getOrigin().getX();
|
||||||
|
int y = chunk.getOrigin().getY();
|
||||||
|
int z = chunk.getOrigin().getZ();
|
||||||
|
|
||||||
// if (getProgressManager().isChunkLoaded(x, 0, z)) {
|
shader.fogStart.set(Float.POSITIVE_INFINITY);
|
||||||
// float progress = getProgressManager().getChunkProgress(x, 0, z);
|
|
||||||
|
|
||||||
// if (progress < 0.999) {
|
if (getProgressManager().isChunkLoaded(x, 0, z)) {
|
||||||
// progress = AnimatedChunks.getInstance().getEaseManager().getValue().ease(progress);
|
float progress = getProgressManager().getChunkProgress(x, 0, z);
|
||||||
|
|
||||||
// float centerX = (float)playerX - x;
|
if (progress < 0.999) {
|
||||||
// float centerY = (float)playerY - y;
|
progress = AnimatedChunks.getInstance().getEaseManager().getValue().ease(progress);
|
||||||
// float centerZ = (float)playerZ - z;
|
|
||||||
|
|
||||||
// matrices.translate(-centerX, -centerY, -centerZ);
|
float centerX = (float)playerX - x;
|
||||||
// AnimatedChunks.getInstance().getAnimationManager().getValue().animate(progress, matrices, x, y, z, (float)playerX, (float)playerY, (float)playerZ);
|
float centerY = (float)playerY - y;
|
||||||
// matrices.translate(centerX, centerY, centerZ);
|
float centerZ = (float)playerZ - z;
|
||||||
// }
|
|
||||||
// }
|
matrices.translate(-centerX, -centerY, -centerZ);
|
||||||
// else {
|
AnimatedChunks.getInstance().getAnimationManager().getValue().animate(progress, matrices, x, y, z, (float)playerX, (float)playerY, (float)playerZ);
|
||||||
// matrices.scale(0, 0, 0);
|
matrices.translate(centerX, centerY, centerZ);
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
matrices.scale(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
shader.modelViewMat.set(matrices.peek().getPositionMatrix());
|
shader.modelViewMat.set(matrices.peek().getPositionMatrix());
|
||||||
matrices.pop();
|
matrices.pop();
|
||||||
shader.bind();
|
shader.bind();
|
||||||
}
|
}
|
||||||
@Inject(method = "renderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gl/VertexBuffer;drawElements()V"), locals=LocalCapture.CAPTURE_FAILHARD)
|
@Inject(method = "renderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gl/VertexBuffer;drawVertices()V"), locals=LocalCapture.CAPTURE_FAILHARD)
|
||||||
private void renderChunkAfter(RenderLayer renderLayer, MatrixStack matrices, double playerX, double playerY, double playerZ, Matrix4f positionMatrix, CallbackInfo ci,
|
private void renderChunkAfter(RenderLayer renderLayer, MatrixStack matrices, double playerX, double playerY, double playerZ, Matrix4f positionMatrix, CallbackInfo ci,
|
||||||
boolean _1, ObjectListIterator<?> _2, Shader shader, GlUniform _4, ChunkInfo _6, BuiltChunk chunk) {
|
boolean _1, ObjectListIterator<?> _2, VertexFormat _3, Shader _4, GlUniform _5, boolean _6, WorldRenderer.ChunkInfo _7, BuiltChunk chunk) {
|
||||||
int x = chunk.getOrigin().getX();
|
int x = chunk.getOrigin().getX();
|
||||||
int z = chunk.getOrigin().getZ();
|
int z = chunk.getOrigin().getZ();
|
||||||
AnimatedChunks.getInstance().animator.load(x, 0, z);
|
getProgressManager().load(x, 0, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"id": "animated-chunks",
|
"id": "animated-chunks",
|
||||||
"version": "0.3.0",
|
"version": "0.2.0",
|
||||||
"name": "Animated Chunks",
|
"name": "Animated Chunks",
|
||||||
"description": "Animated chunk load animations.",
|
"description": "animated chunk load animations.",
|
||||||
"authors": [ "TopchetoEU" ],
|
"authors": [ "TopchetoEU" ],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"icon": "assets/animated-chunks/icon.png",
|
"icon": "assets/animated-chunks/icon.png",
|
||||||
@ -21,12 +21,13 @@
|
|||||||
"animated-chunks.mixins.json"
|
"animated-chunks.mixins.json"
|
||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.9.3+build.207",
|
"fabricloader": "*",
|
||||||
"fabric": "*",
|
"fabric": "*",
|
||||||
"minecraft": "=1.19.2",
|
"minecraft": "=1.18.2",
|
||||||
"modmenu": ">=4.0.0"
|
"modmenu": "3.*"
|
||||||
},
|
},
|
||||||
"breaks": {
|
"breaks": {
|
||||||
"sodium": "*"
|
"sodium": "*",
|
||||||
|
"iris": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user