Compare commits
1 Commits
1.16.4-for
...
v0.1-1.16.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6221b50d9 |
41
.github/workflows/build.yml
vendored
Normal file
41
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Automatically build the project and run any configured tests for every push
|
||||||
|
# and submitted pull request. This can help catch issues that only occur on
|
||||||
|
# certain platforms or Java versions, and provides a first line of defence
|
||||||
|
# against bad commits.
|
||||||
|
|
||||||
|
name: build
|
||||||
|
on: [pull_request, push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
# Use these Java versions
|
||||||
|
java: [
|
||||||
|
1.8, # Minimum supported by Minecraft
|
||||||
|
11, # Current Java LTS
|
||||||
|
15 # Latest version
|
||||||
|
]
|
||||||
|
# and run on both Linux and Windows
|
||||||
|
os: [ubuntu-20.04, windows-latest]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: checkout repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: validate gradle wrapper
|
||||||
|
uses: gradle/wrapper-validation-action@v1
|
||||||
|
- name: setup jdk ${{ matrix.java }}
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: ${{ matrix.java }}
|
||||||
|
- name: make gradle wrapper executable
|
||||||
|
if: ${{ runner.os != 'Windows' }}
|
||||||
|
run: chmod +x ./gradlew
|
||||||
|
- name: build
|
||||||
|
run: ./gradlew build
|
||||||
|
- name: capture build artifacts
|
||||||
|
if: ${{ runner.os == 'Linux' && matrix.java == '11' }} # Only upload artifacts built from LTS java on one OS
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: Artifacts
|
||||||
|
path: build/libs/
|
||||||
44
.gitignore
vendored
44
.gitignore
vendored
@@ -1,26 +1,34 @@
|
|||||||
|
# gradle
|
||||||
|
|
||||||
|
.gradle/
|
||||||
|
build/
|
||||||
|
out/
|
||||||
|
classes/
|
||||||
|
|
||||||
# eclipse
|
# eclipse
|
||||||
bin
|
|
||||||
*.launch
|
*.launch
|
||||||
.settings
|
|
||||||
.metadata
|
# idea
|
||||||
|
|
||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# vscode
|
||||||
|
|
||||||
|
.settings/
|
||||||
|
.vscode/
|
||||||
|
bin/
|
||||||
.classpath
|
.classpath
|
||||||
.project
|
.project
|
||||||
|
|
||||||
# idea
|
# macos
|
||||||
out
|
|
||||||
*.ipr
|
|
||||||
*.iws
|
|
||||||
*.iml
|
|
||||||
.idea
|
|
||||||
|
|
||||||
# gradle
|
*.DS_Store
|
||||||
build
|
|
||||||
.gradle
|
|
||||||
|
|
||||||
# other
|
# fabric
|
||||||
eclipse
|
|
||||||
run
|
|
||||||
|
|
||||||
# Files from Forge MDK
|
run/
|
||||||
forge*changelog.txt
|
/logs/
|
||||||
/local.properties
|
|
||||||
|
|||||||
92
build.gradle
Normal file
92
build.gradle
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
plugins {
|
||||||
|
id 'fabric-loom' version '0.5-SNAPSHOT'
|
||||||
|
id 'maven-publish'
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
|
||||||
|
archivesBaseName = project.archives_base_name
|
||||||
|
version = project.mod_version + "-" + project.minecraft_version + "-fabric"
|
||||||
|
group = project.maven_group
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
// Add repositories to retrieve artifacts from in here.
|
||||||
|
// You should only use this when depending on other mods because
|
||||||
|
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||||
|
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||||
|
// for more information about repositories.
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// To change the versions see the gradle.properties file
|
||||||
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||||
|
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||||
|
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||||
|
|
||||||
|
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||||
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
|
|
||||||
|
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
|
||||||
|
// You may need to force-disable transitiveness on them.
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
inputs.property "version", project.version
|
||||||
|
|
||||||
|
filesMatching("fabric.mod.json") {
|
||||||
|
expand "version": project.version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile).configureEach {
|
||||||
|
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||||
|
// this fixes some edge cases with special characters not displaying correctly
|
||||||
|
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
||||||
|
// If Javadoc is generated, this must be specified in that task too.
|
||||||
|
it.options.encoding = "UTF-8"
|
||||||
|
|
||||||
|
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
|
||||||
|
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
|
||||||
|
// We'll use that if it's available, but otherwise we'll use the older option.
|
||||||
|
def targetVersion = 8
|
||||||
|
if (JavaVersion.current().isJava9Compatible()) {
|
||||||
|
it.options.release = targetVersion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||||
|
// if it is present.
|
||||||
|
// If you remove this line, sources will not be generated.
|
||||||
|
withSourcesJar()
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
from("LICENSE") {
|
||||||
|
rename { "${it}_${project.archivesBaseName}"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// configure the maven publication
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
mavenJava(MavenPublication) {
|
||||||
|
// add all the jars that should be included when publishing to maven
|
||||||
|
artifact(remapJar) {
|
||||||
|
builtBy remapJar
|
||||||
|
}
|
||||||
|
artifact(sourcesJar) {
|
||||||
|
builtBy remapSourcesJar
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||||
|
repositories {
|
||||||
|
// Add repositories to publish to here.
|
||||||
|
// Notice: This block does NOT have the same function as the block in the top level.
|
||||||
|
// The repositories here will be used for publishing your artifact, not for
|
||||||
|
// retrieving dependencies.
|
||||||
|
}
|
||||||
|
}
|
||||||
17
gradle.properties
Normal file
17
gradle.properties
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Done to increase the memory available to gradle.
|
||||||
|
org.gradle.jvmargs=-Xmx1G
|
||||||
|
|
||||||
|
# Fabric Properties
|
||||||
|
# check these on https://fabricmc.net/use
|
||||||
|
minecraft_version=1.16.4
|
||||||
|
yarn_mappings=1.16.4+build.9
|
||||||
|
loader_version=0.11.1
|
||||||
|
|
||||||
|
# Mod Properties
|
||||||
|
mod_version = 0.1
|
||||||
|
maven_group = markil3
|
||||||
|
archives_base_name = immersive_hud
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||||
|
fabric_version=0.30.3+1.16
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
185
gradlew
vendored
Executable file
185
gradlew
vendored
Executable file
@@ -0,0 +1,185 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2015 the original author or authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
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.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
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.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
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
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=`save "$@"`
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
89
gradlew.bat
vendored
Normal file
89
gradlew.bat
vendored
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
9
settings.gradle
Normal file
9
settings.gradle
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = 'Fabric'
|
||||||
|
url = 'https://maven.fabricmc.net/'
|
||||||
|
}
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
910
src/main/java/markil3/immersive_hud/EventBus.java
Normal file
910
src/main/java/markil3/immersive_hud/EventBus.java
Normal file
@@ -0,0 +1,910 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2021 Markil 3
|
||||||
|
* <p>
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
* <p>
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
* <p>
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package markil3.immersive_hud;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.effect.StatusEffects;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.BowItem;
|
||||||
|
import net.minecraft.item.CrossbowItem;
|
||||||
|
import net.minecraft.item.EggItem;
|
||||||
|
import net.minecraft.item.EnderPearlItem;
|
||||||
|
import net.minecraft.item.FilledMapItem;
|
||||||
|
import net.minecraft.item.FishingRodItem;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.RangedWeaponItem;
|
||||||
|
import net.minecraft.item.ShieldItem;
|
||||||
|
import net.minecraft.item.SnowballItem;
|
||||||
|
import net.minecraft.item.ThrowablePotionItem;
|
||||||
|
import net.minecraft.item.TridentItem;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.hit.EntityHitResult;
|
||||||
|
import net.minecraft.util.hit.HitResult;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the logic for changing the HUD.
|
||||||
|
*
|
||||||
|
* @author Markil 3
|
||||||
|
* @version 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
public class EventBus
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The number of ticks that the hand will be onscreen. Every tick is 1/20th
|
||||||
|
* of a second.
|
||||||
|
*/
|
||||||
|
static final int HAND_TIME = 10 * 20;
|
||||||
|
/**
|
||||||
|
* The number of ticks most elements will be onscreen. Every tick is 1/20th
|
||||||
|
* of a second.
|
||||||
|
*/
|
||||||
|
static final int VISUAL_TIME = 6 * 20;
|
||||||
|
/**
|
||||||
|
* The number of ticks that the health and hunger bars will be onscreen.
|
||||||
|
* Every tick is 1/20th of a second.
|
||||||
|
*/
|
||||||
|
static final int HEALTH_TIME = (int) ((float) VISUAL_TIME * 2.5);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many more ticks the hand will be onscreen. Every tick is 1/20th of a
|
||||||
|
* second.
|
||||||
|
*/
|
||||||
|
private static int mainHandTime, offHandTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many more ticks the crosshair will be onscreen. Every tick is 1/20th
|
||||||
|
* of a second.
|
||||||
|
*/
|
||||||
|
private static int crosshairTime;
|
||||||
|
/**
|
||||||
|
* If true, then the hand (and crosshairs) will be locked onto the screen
|
||||||
|
* without disappearing until this flag is updated.
|
||||||
|
*/
|
||||||
|
private static boolean mainHandLock, offHandLock;
|
||||||
|
/**
|
||||||
|
* A bitmask that will lock the corresponding hand without necessarily
|
||||||
|
* showing the crosshairs. The first bit will be the main hand, and the
|
||||||
|
* second will be the offhand.
|
||||||
|
*/
|
||||||
|
private static int mapLock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many more ticks the hotbar will be onscreen. Every tick is 1/20th of
|
||||||
|
* a second.
|
||||||
|
*/
|
||||||
|
private static int hotbarTime;
|
||||||
|
/**
|
||||||
|
* The last hotbar slot that was selected. This is used to check for a
|
||||||
|
* change in the hotbar slot.
|
||||||
|
*/
|
||||||
|
private static int selectedHotbarSlot = -1;
|
||||||
|
/**
|
||||||
|
* The last item that was in this hand. This is used to check for a change
|
||||||
|
* in what was equipped.
|
||||||
|
*/
|
||||||
|
private static Item mainHandItem = null, offHandItem = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many more ticks the health bar will be onscreen. Every tick is 1/20th
|
||||||
|
* of a second.
|
||||||
|
*/
|
||||||
|
private static int healthTime;
|
||||||
|
/**
|
||||||
|
* Records what the health was previously. Used to check for a change in the
|
||||||
|
* health.
|
||||||
|
* <p>
|
||||||
|
* Note that the display of the armor is linked to this.
|
||||||
|
*/
|
||||||
|
private static float health = -1;
|
||||||
|
/**
|
||||||
|
* Records what the maximum health was previously. Used to check for a
|
||||||
|
* change in the health.
|
||||||
|
*/
|
||||||
|
private static float maxHealth = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many more ticks the hunger bar will be onscreen. Every tick is 1/20th
|
||||||
|
* of a second.
|
||||||
|
*/
|
||||||
|
private static int hungerTime;
|
||||||
|
/**
|
||||||
|
* Records what the hunger level was previously. Used to check for a change
|
||||||
|
* in hunger.
|
||||||
|
*/
|
||||||
|
private static int hunger = -1;
|
||||||
|
/**
|
||||||
|
* Records whether or not there was food poisoning. Used to check for a
|
||||||
|
* change in hunger.
|
||||||
|
*/
|
||||||
|
private static boolean isFoodPoisoned = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many more ticks the mount's health bar will be onscreen. Every tick
|
||||||
|
* is 1/20th of a second.
|
||||||
|
*/
|
||||||
|
private static int mountTime;
|
||||||
|
/**
|
||||||
|
* Records what the health of the mount was previously. Used to check for a
|
||||||
|
* change in the health.
|
||||||
|
*/
|
||||||
|
private static float mountHealth = -1;
|
||||||
|
/**
|
||||||
|
* Records what the maximum health of the mount was previously. Used to
|
||||||
|
* check for a change in the health.
|
||||||
|
*/
|
||||||
|
private static float mountMaxHealth = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many more ticks the mount's jump bar will be onscreen. Every tick is
|
||||||
|
* 1/20th of a second.
|
||||||
|
*/
|
||||||
|
private static int jumpTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many more ticks the experience bar will be onscreen. Every tick is
|
||||||
|
* 1/20th of a second.
|
||||||
|
*/
|
||||||
|
private static int experienceTime;
|
||||||
|
/**
|
||||||
|
* Records what the experience was previously. Used to check for a change in
|
||||||
|
* the health.
|
||||||
|
*/
|
||||||
|
private static float experienceProgress = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run whenever the player clicks a mouse button. This brings the hands into
|
||||||
|
* view, and briefly brings the health and hunger into view if the held item
|
||||||
|
* is food.
|
||||||
|
*
|
||||||
|
* @param hand - The hand being triggered
|
||||||
|
* @param clear - Whether the hand it being enabled or disabled.
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
public static void onClick(Hand hand, boolean clear)
|
||||||
|
{
|
||||||
|
MinecraftClient mc = MinecraftClient.getInstance();
|
||||||
|
LivingEntity entity;
|
||||||
|
Item item;
|
||||||
|
Iterator<ItemStack> hands;
|
||||||
|
if (mc.getCameraEntity() instanceof LivingEntity)
|
||||||
|
{
|
||||||
|
entity = (LivingEntity) mc.getCameraEntity();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (clear)
|
||||||
|
{
|
||||||
|
item = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hands = entity.getItemsHand().iterator();
|
||||||
|
if (hand == Hand.OFF_HAND)
|
||||||
|
{
|
||||||
|
hands.next();
|
||||||
|
}
|
||||||
|
item =
|
||||||
|
Optional.ofNullable(hands.next())
|
||||||
|
.filter(stack -> !stack.isEmpty())
|
||||||
|
.map(ItemStack::getItem)
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
crosshairTime = VISUAL_TIME;
|
||||||
|
if (hand == Hand.MAIN_HAND)
|
||||||
|
{
|
||||||
|
mainHandTime = HAND_TIME;
|
||||||
|
mainHandLock = item != null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
offHandTime = HAND_TIME;
|
||||||
|
offHandLock = item != null;
|
||||||
|
}
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
if (item.isFood())
|
||||||
|
{
|
||||||
|
healthTime = HEALTH_TIME;
|
||||||
|
hungerTime = HEALTH_TIME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.out.println("Unusing hand " + hand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run whenever a hand is rendered in 1st person. This brings the player
|
||||||
|
* hands into and out of view as needed.
|
||||||
|
*
|
||||||
|
* @param hand - The hand being rendered.
|
||||||
|
* @param matrixStack - The rendering stack.
|
||||||
|
*
|
||||||
|
* @return If true, then don't render this hand at all.
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
public static boolean onRenderHand(Hand hand, MatrixStack matrixStack)
|
||||||
|
{
|
||||||
|
final int HAND_UP_TIME = 20;
|
||||||
|
switch (hand)
|
||||||
|
{
|
||||||
|
case OFF_HAND:
|
||||||
|
if (offHandTime == 0 && !offHandLock)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (!offHandLock && (mapLock & 0b01) == 0)
|
||||||
|
{
|
||||||
|
offHandTime--;
|
||||||
|
if (offHandTime < HAND_UP_TIME)
|
||||||
|
{
|
||||||
|
matrixStack
|
||||||
|
.translate(0,
|
||||||
|
-1.0F * (HAND_UP_TIME - offHandTime) /
|
||||||
|
HAND_UP_TIME,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MAIN_HAND:
|
||||||
|
if (mainHandTime == 0 && !mainHandLock)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (!mainHandLock && (mapLock & 0b10) == 0)
|
||||||
|
{
|
||||||
|
System.out.println("Decreasing main hand time");
|
||||||
|
mainHandTime--;
|
||||||
|
if (mainHandTime < HAND_UP_TIME)
|
||||||
|
{
|
||||||
|
matrixStack
|
||||||
|
.translate(0,
|
||||||
|
-1.0F * (HAND_UP_TIME - mainHandTime) /
|
||||||
|
HAND_UP_TIME,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether or not to draw the crosshair, adjusting the alpha as
|
||||||
|
* needed.
|
||||||
|
*
|
||||||
|
* @return If true, then cancel drawing the crosshair.
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
public static boolean drawCrosshair()
|
||||||
|
{
|
||||||
|
MinecraftClient mc = MinecraftClient.getInstance();
|
||||||
|
Entity entity = mc.getCameraEntity();
|
||||||
|
boolean changed = false;
|
||||||
|
if (mc.crosshairTarget != null && mc.crosshairTarget
|
||||||
|
.getType() != HitResult.Type.MISS)
|
||||||
|
{
|
||||||
|
if (mc.crosshairTarget.getType() == HitResult.Type
|
||||||
|
.ENTITY)
|
||||||
|
{
|
||||||
|
if (((EntityHitResult) mc.crosshairTarget).getEntity() != entity
|
||||||
|
.getVehicle())
|
||||||
|
{
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changed || mainHandLock || offHandLock || crosshairTime
|
||||||
|
> 0)
|
||||||
|
{
|
||||||
|
RenderSystem.color4f(1.0F,
|
||||||
|
1.0F,
|
||||||
|
1.0F,
|
||||||
|
Main.getAlpha(crosshairTime > 0 ?
|
||||||
|
crosshairTime :
|
||||||
|
VISUAL_TIME));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RenderSystem.color4f(1.0F,
|
||||||
|
1.0F,
|
||||||
|
1.0F,
|
||||||
|
0F);
|
||||||
|
}
|
||||||
|
if (crosshairTime > 0)
|
||||||
|
{
|
||||||
|
crosshairTime--;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether or not to draw the mount's health, adjusting the alpha
|
||||||
|
* as needed.
|
||||||
|
*
|
||||||
|
* @return If true, then cancel drawing the mount health bar.
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
public static boolean drawMountHealth()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* When the health percentage falls to this level or below, the
|
||||||
|
* health bar won't disappear, allowing the player to be constantly
|
||||||
|
* reminded of their low health.
|
||||||
|
*/
|
||||||
|
final float CONST_BOUNDARY = 0.5F;
|
||||||
|
|
||||||
|
MinecraftClient mc = MinecraftClient.getInstance();
|
||||||
|
Entity entity = mc.getCameraEntity();
|
||||||
|
Entity tmp = entity.getVehicle();
|
||||||
|
LivingEntity mount;
|
||||||
|
boolean changed = false;
|
||||||
|
|
||||||
|
if (tmp == null)
|
||||||
|
{
|
||||||
|
mountHealth = -1;
|
||||||
|
mountMaxHealth = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mount = (LivingEntity) tmp;
|
||||||
|
if (mountHealth != mount.getHealth())
|
||||||
|
{
|
||||||
|
mountHealth = mount.getHealth();
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
if (mountMaxHealth != mount.getMaxHealth())
|
||||||
|
{
|
||||||
|
mountMaxHealth = mount.getMaxHealth();
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
mountTime = VISUAL_TIME;
|
||||||
|
}
|
||||||
|
else if (mountTime > 0)
|
||||||
|
{
|
||||||
|
mountTime--;
|
||||||
|
}
|
||||||
|
if (mountTime > 0)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Renders it along with health.
|
||||||
|
*/
|
||||||
|
RenderSystem.color4f(1.0F,
|
||||||
|
1.0F,
|
||||||
|
1.0F,
|
||||||
|
Main.getAlpha(mountTime));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether or not to draw the armor bar, adjusting the alpha as
|
||||||
|
* needed.
|
||||||
|
*
|
||||||
|
* @return If true, then cancel drawing the armor bar.
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
public static boolean drawArmor()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Sets the armor to fade in and out in sync with the health.
|
||||||
|
* Technically, since this method gets called before health, it will
|
||||||
|
* be 1 tick behind, but I'm not too concerned about it.
|
||||||
|
*/
|
||||||
|
if (healthTime > 0)
|
||||||
|
{
|
||||||
|
RenderSystem.color4f(1.0F,
|
||||||
|
1.0F,
|
||||||
|
1.0F,
|
||||||
|
Main.getAlpha(healthTime));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RenderSystem.color4f(1.0F,
|
||||||
|
1.0F,
|
||||||
|
1.0F,
|
||||||
|
0.0F);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether or not to draw the health bar, adjusting the alpha as
|
||||||
|
* needed.
|
||||||
|
*
|
||||||
|
* @return If true, then cancel drawing the health.
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
public static boolean drawHealth()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* When the health percentage falls to this level or below, the
|
||||||
|
* health bar won't disappear, allowing the player to be constantly
|
||||||
|
* reminded of their low health.
|
||||||
|
*/
|
||||||
|
final float CONST_BOUNDARY = 0.5F;
|
||||||
|
|
||||||
|
MinecraftClient mc = MinecraftClient.getInstance();
|
||||||
|
LivingEntity entity;
|
||||||
|
if (mc.getCameraEntity() instanceof LivingEntity)
|
||||||
|
{
|
||||||
|
entity = (LivingEntity) mc.getCameraEntity();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
boolean changed = false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Resets the transparency from the armor call.
|
||||||
|
*/
|
||||||
|
RenderSystem.color4f(1.0F,
|
||||||
|
1.0F,
|
||||||
|
1.0F,
|
||||||
|
1F);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks for a change in current or max health.
|
||||||
|
*/
|
||||||
|
if (health != entity.getHealth())
|
||||||
|
{
|
||||||
|
health = entity.getHealth();
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
if (maxHealth != entity.getMaxHealth())
|
||||||
|
{
|
||||||
|
maxHealth = entity.getMaxHealth();
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
healthTime = HEALTH_TIME;
|
||||||
|
}
|
||||||
|
else if (healthTime > 0)
|
||||||
|
{
|
||||||
|
healthTime--;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Only makes a change if the player is healthy. Otherwise,
|
||||||
|
* the bar is shown.
|
||||||
|
*/
|
||||||
|
if (health / maxHealth > CONST_BOUNDARY)
|
||||||
|
{
|
||||||
|
RenderSystem.color4f(1.0F,
|
||||||
|
1.0F,
|
||||||
|
1.0F,
|
||||||
|
Main.getAlpha(healthTime));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether or not to draw the hunger bar, adjusting the alpha as
|
||||||
|
* needed.
|
||||||
|
*
|
||||||
|
* @return If true, then cancel drawing the hunger bar.
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
public static boolean drawHunger()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* When hunger falls to this level or below, the hunger bar won't
|
||||||
|
* disappear, allowing the player to be constantly reminded of their
|
||||||
|
* low hunger.
|
||||||
|
*/
|
||||||
|
final int HUNGER_BOUNDARY = 15;
|
||||||
|
|
||||||
|
MinecraftClient mc = MinecraftClient.getInstance();
|
||||||
|
PlayerEntity entity;
|
||||||
|
boolean changed = false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Resets the transparency from last time.
|
||||||
|
*/
|
||||||
|
RenderSystem.color4f(1.0F,
|
||||||
|
1.0F,
|
||||||
|
1.0F,
|
||||||
|
1F);
|
||||||
|
if (mc.getCameraEntity() instanceof PlayerEntity)
|
||||||
|
{
|
||||||
|
entity = (PlayerEntity) mc.getCameraEntity();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hunger != entity.getHungerManager().getFoodLevel())
|
||||||
|
{
|
||||||
|
hunger = entity.getHungerManager().getFoodLevel();
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
if (isFoodPoisoned != entity.hasStatusEffect(StatusEffects
|
||||||
|
.HUNGER))
|
||||||
|
{
|
||||||
|
isFoodPoisoned =
|
||||||
|
entity.hasStatusEffect(StatusEffects.HUNGER);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
if (hunger <= HUNGER_BOUNDARY)
|
||||||
|
{
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
hungerTime = HEALTH_TIME;
|
||||||
|
}
|
||||||
|
else if (hungerTime > 0)
|
||||||
|
{
|
||||||
|
hungerTime--;
|
||||||
|
}
|
||||||
|
RenderSystem.color4f(1.0F,
|
||||||
|
1.0F,
|
||||||
|
1.0F,
|
||||||
|
Main.getAlpha(hungerTime));
|
||||||
|
/*
|
||||||
|
* Only makes a change if the player is satisfied. Otherwise,
|
||||||
|
* the bar is shown.
|
||||||
|
*/
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether or not to draw the horse jump bar, adjusting the alpha
|
||||||
|
* as needed.
|
||||||
|
*
|
||||||
|
* @return If true, then cancel drawing the jump bar.
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
public static boolean drawJumpbar()
|
||||||
|
{
|
||||||
|
MinecraftClient mc = MinecraftClient.getInstance();
|
||||||
|
ClientPlayerEntity entity;
|
||||||
|
boolean changed = false;
|
||||||
|
|
||||||
|
if (mc.getCameraEntity() instanceof ClientPlayerEntity)
|
||||||
|
{
|
||||||
|
entity = (ClientPlayerEntity) mc.getCameraEntity();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.method_3151() > 0)
|
||||||
|
{
|
||||||
|
jumpTime = VISUAL_TIME;
|
||||||
|
}
|
||||||
|
else if (jumpTime > 0)
|
||||||
|
{
|
||||||
|
jumpTime--;
|
||||||
|
}
|
||||||
|
if (experienceTime > 0)
|
||||||
|
{
|
||||||
|
RenderSystem.color4f(1.0F,
|
||||||
|
1.0F,
|
||||||
|
1.0F,
|
||||||
|
Main.getAlpha(jumpTime));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether or not to draw the experience bar, adjusting the alpha
|
||||||
|
* as needed.
|
||||||
|
*
|
||||||
|
* @return If true, then cancel drawing the experience bar.
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
public static boolean drawExperience()
|
||||||
|
{
|
||||||
|
MinecraftClient mc = MinecraftClient.getInstance();
|
||||||
|
ClientPlayerEntity entity;
|
||||||
|
boolean changed = false;
|
||||||
|
|
||||||
|
if (mc.getCameraEntity() instanceof ClientPlayerEntity)
|
||||||
|
{
|
||||||
|
entity = (ClientPlayerEntity) mc.getCameraEntity();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (experienceProgress != entity.totalExperience)
|
||||||
|
{
|
||||||
|
experienceProgress = entity.totalExperience;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
experienceTime = VISUAL_TIME;
|
||||||
|
}
|
||||||
|
else if (experienceTime > 0)
|
||||||
|
{
|
||||||
|
experienceTime--;
|
||||||
|
}
|
||||||
|
if (experienceTime > 0)
|
||||||
|
{
|
||||||
|
RenderSystem.color4f(1.0F,
|
||||||
|
1.0F,
|
||||||
|
1.0F,
|
||||||
|
Main.getAlpha(experienceTime));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether or not to draw the hotbar. Note that this method does
|
||||||
|
* not directly change the transparency of the hotbar, only checking whether
|
||||||
|
* or not to draw it.
|
||||||
|
*
|
||||||
|
* @return If true, then cancel drawing the hotbar.
|
||||||
|
*
|
||||||
|
* @see #recolorHotbar()
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
public static boolean updateHotbar()
|
||||||
|
{
|
||||||
|
MinecraftClient mc = MinecraftClient.getInstance();
|
||||||
|
ClientPlayerEntity entity;
|
||||||
|
Item item, handItem = null;
|
||||||
|
boolean changed = false;
|
||||||
|
|
||||||
|
if (mc.getCameraEntity() instanceof ClientPlayerEntity)
|
||||||
|
{
|
||||||
|
entity = (ClientPlayerEntity) mc.getCameraEntity();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
mainHandLock = offHandLock = false;
|
||||||
|
mapLock = 0;
|
||||||
|
int i = 0;
|
||||||
|
for (ItemStack stack : entity.getItemsHand())
|
||||||
|
{
|
||||||
|
item =
|
||||||
|
Optional.ofNullable(stack)
|
||||||
|
.map(ItemStack::getItem)
|
||||||
|
.orElse(null);
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
if (item instanceof RangedWeaponItem)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Enables the crosshairs and lock the hand
|
||||||
|
* whenever the bow is drawn.
|
||||||
|
*/
|
||||||
|
if (item instanceof BowItem)
|
||||||
|
{
|
||||||
|
if (entity.isUsingItem() && entity
|
||||||
|
.getActiveHand()
|
||||||
|
.ordinal() == i)
|
||||||
|
{
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
mainHandLock = true;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
offHandLock = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Enables the crosshairs and lock the hand
|
||||||
|
* whenever a loaded crossbow is equipped.
|
||||||
|
*/
|
||||||
|
else if (item instanceof CrossbowItem)
|
||||||
|
{
|
||||||
|
if (CrossbowItem.isCharged(stack))
|
||||||
|
{
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
mainHandLock = true;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
offHandLock = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* We don't know how modded items behave
|
||||||
|
* exactly, so we keep it safe and enable the
|
||||||
|
* crosshairs at all times for any shootable
|
||||||
|
* items.
|
||||||
|
*/
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
mainHandLock = true;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
offHandLock = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Items that have the crosshairs enabled for as long
|
||||||
|
* as the item is actively being used.
|
||||||
|
*/
|
||||||
|
else if (item instanceof TridentItem || item
|
||||||
|
instanceof ShieldItem)
|
||||||
|
{
|
||||||
|
if (entity.isUsingItem() && entity
|
||||||
|
.getActiveHand() != null && entity.getActiveHand()
|
||||||
|
.ordinal() == i)
|
||||||
|
{
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
mainHandLock = true;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
offHandLock = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Items that have the crosshairs enabled for as long
|
||||||
|
* as the item is being held at all.
|
||||||
|
*/
|
||||||
|
else if (item instanceof ThrowablePotionItem ||
|
||||||
|
item instanceof SnowballItem || item instanceof
|
||||||
|
EggItem || item instanceof EnderPearlItem || item
|
||||||
|
instanceof FishingRodItem)
|
||||||
|
{
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
mainHandLock = true;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
offHandLock = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Maps get special treatment. The hand is locked,
|
||||||
|
* but the crosshairs are not enabled.
|
||||||
|
*/
|
||||||
|
else if (item instanceof FilledMapItem)
|
||||||
|
{
|
||||||
|
mapLock = mapLock | (2 - i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Checks for a change in the item
|
||||||
|
*/
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
handItem = mainHandItem;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
handItem = offHandItem;
|
||||||
|
}
|
||||||
|
if (item != handItem)
|
||||||
|
{
|
||||||
|
changed = true;
|
||||||
|
/*
|
||||||
|
* Briefly shows the health and hunger bar whenever
|
||||||
|
* food is switched to.
|
||||||
|
*/
|
||||||
|
if (item.isFood())
|
||||||
|
{
|
||||||
|
healthTime = HEALTH_TIME;
|
||||||
|
hungerTime = HEALTH_TIME;
|
||||||
|
}
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
mainHandItem = item;
|
||||||
|
mainHandTime = HAND_TIME;
|
||||||
|
}
|
||||||
|
else if (i == 1)
|
||||||
|
{
|
||||||
|
offHandItem = item;
|
||||||
|
offHandTime = HAND_TIME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Checks for a change in what slot is used.
|
||||||
|
*/
|
||||||
|
if (selectedHotbarSlot != entity.inventory.selectedSlot)
|
||||||
|
{
|
||||||
|
selectedHotbarSlot = entity.inventory.selectedSlot;
|
||||||
|
mainHandTime = HAND_TIME;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
hotbarTime = VISUAL_TIME;
|
||||||
|
}
|
||||||
|
else if (hotbarTime > 0)
|
||||||
|
{
|
||||||
|
hotbarTime--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hotbarTime == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether or not to draw the crosshair, adjusting the alpha as
|
||||||
|
* needed.
|
||||||
|
*
|
||||||
|
* @return If true, then cancel drawing the crosshair.
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
public static void recolorHotbar()
|
||||||
|
{
|
||||||
|
RenderSystem.color4f(1.0F,
|
||||||
|
1.0F,
|
||||||
|
1.0F,
|
||||||
|
Main.getAlpha(hotbarTime));
|
||||||
|
}
|
||||||
|
}
|
||||||
53
src/main/java/markil3/immersive_hud/Main.java
Normal file
53
src/main/java/markil3/immersive_hud/Main.java
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* This Minecraft mod aims to move the ingame HUD out of the way whenever
|
||||||
|
* possible. Copyright (C) 2021 Markil 3
|
||||||
|
* <p>
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
* <p>
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
* <p>
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package markil3.immersive_hud;
|
||||||
|
|
||||||
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
import net.minecraft.client.gui.DrawableHelper;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main entry point for the Immersive HUD mod.
|
||||||
|
*
|
||||||
|
* @author Markil 3
|
||||||
|
* @version 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
public class Main implements ModInitializer
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onInitialize()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A utility method to handle the transparency timing. It will (for the most
|
||||||
|
* part), make
|
||||||
|
*
|
||||||
|
* @param renderTime - How many ticks until the element entirely
|
||||||
|
* disappears.
|
||||||
|
*
|
||||||
|
* @return The new alpha value.
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
static float getAlpha(int renderTime)
|
||||||
|
{
|
||||||
|
return Math.min(renderTime / 20.0F,
|
||||||
|
1.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2021 Markil 3
|
||||||
|
* <p>
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
* <p>
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
* <p>
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package markil3.immersive_hud.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
|
import net.minecraft.client.render.VertexConsumerProvider;
|
||||||
|
import net.minecraft.client.render.item.HeldItemRenderer;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import markil3.immersive_hud.EventBus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This mixin hooks into the client player class to check for when the hands
|
||||||
|
* move. Note that most of the logic can be found in {@link EventBus}.
|
||||||
|
*
|
||||||
|
* @author Markil 3
|
||||||
|
* @version 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Mixin(ClientPlayerEntity.class)
|
||||||
|
public class ClientPlayerHook
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Updates hand timing every time an attack is initiated.
|
||||||
|
*
|
||||||
|
* @param hand - The attacking hand.
|
||||||
|
* @param callbackInfo
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Inject(method = "swingHand", at = @At(value = "TAIL"))
|
||||||
|
public void swingHand(Hand hand, CallbackInfo callbackInfo)
|
||||||
|
{
|
||||||
|
EventBus.onClick(hand, hand == null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates hand timing every time an item is used.
|
||||||
|
*
|
||||||
|
* @param hand - The using hand.
|
||||||
|
* @param callbackInfo
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Inject(method = "setCurrentHand", at = @At(value = "TAIL"))
|
||||||
|
public void setCurrentHand(Hand hand, CallbackInfo callbackInfo)
|
||||||
|
{
|
||||||
|
EventBus.onClick(hand, hand == null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates hand timing every the hand is no longer being used.
|
||||||
|
*
|
||||||
|
* @param callbackInfo
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Inject(method = "clearActiveItem", at = @At(value = "HEAD"))
|
||||||
|
public void clearActiveItem(CallbackInfo callbackInfo)
|
||||||
|
{
|
||||||
|
if (MinecraftClient.getInstance().cameraEntity instanceof LivingEntity)
|
||||||
|
{
|
||||||
|
EventBus.onClick(((LivingEntity) MinecraftClient.getInstance().cameraEntity)
|
||||||
|
.getActiveHand(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
84
src/main/java/markil3/immersive_hud/mixin/HeldItemHook.java
Normal file
84
src/main/java/markil3/immersive_hud/mixin/HeldItemHook.java
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2021 Markil 3
|
||||||
|
* <p>
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
* <p>
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
* <p>
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package markil3.immersive_hud.mixin;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.hud.InGameHud;
|
||||||
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
|
import net.minecraft.client.render.VertexConsumerProvider;
|
||||||
|
import net.minecraft.client.render.item.HeldItemRenderer;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import markil3.immersive_hud.EventBus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This mixin hooks into the hand renderer to make the hands move in and out of
|
||||||
|
* view. Note that most of the logic can be found in {@link EventBus}.
|
||||||
|
*
|
||||||
|
* @author Markil 3
|
||||||
|
* @version 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Mixin(HeldItemRenderer.class)
|
||||||
|
public class HeldItemHook
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determines whether or not to render a certain hand.
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* @param tickDelta
|
||||||
|
* @param pitch
|
||||||
|
* @param hand
|
||||||
|
* @param swingProgress
|
||||||
|
* @param item
|
||||||
|
* @param equipProgress
|
||||||
|
* @param matrices
|
||||||
|
* @param vertexConsumers
|
||||||
|
* @param light
|
||||||
|
* @param callbackInfo
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/client/util/math/MatrixStack;push()V",
|
||||||
|
shift = At.Shift.AFTER), cancellable = true)
|
||||||
|
public void renderHand(AbstractClientPlayerEntity player,
|
||||||
|
float tickDelta,
|
||||||
|
float pitch,
|
||||||
|
Hand hand,
|
||||||
|
float swingProgress,
|
||||||
|
ItemStack item,
|
||||||
|
float equipProgress,
|
||||||
|
MatrixStack matrices,
|
||||||
|
VertexConsumerProvider vertexConsumers,
|
||||||
|
int light,
|
||||||
|
CallbackInfo callbackInfo)
|
||||||
|
{
|
||||||
|
if (EventBus.onRenderHand(hand, matrices))
|
||||||
|
{
|
||||||
|
callbackInfo.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
237
src/main/java/markil3/immersive_hud/mixin/HudHook.java
Normal file
237
src/main/java/markil3/immersive_hud/mixin/HudHook.java
Normal file
@@ -0,0 +1,237 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2021 Markil 3
|
||||||
|
* <p>
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
* <p>
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
* <p>
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package markil3.immersive_hud.mixin;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.hud.InGameHud;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.util.profiler.DummyProfiler;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import markil3.immersive_hud.EventBus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This mixin hooks into the HUD class to modify most of the HUD elements. Note
|
||||||
|
* that most of the logic can be found in {@link EventBus}.
|
||||||
|
*
|
||||||
|
* @author Markil 3
|
||||||
|
* @version 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Mixin(InGameHud.class)
|
||||||
|
public class HudHook
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determines whether or not to draw the crosshair.
|
||||||
|
*
|
||||||
|
* @param stack - The matrix drawing stack.
|
||||||
|
* @param callbackInfo
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Inject(method = "renderCrosshair", at = @At(value = "HEAD"))
|
||||||
|
public void startCrosshair(MatrixStack stack, CallbackInfo callbackInfo)
|
||||||
|
{
|
||||||
|
EventBus.drawCrosshair();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets any changes from drawing the crosshair.
|
||||||
|
*
|
||||||
|
* @param stack - The matrix drawing stack.
|
||||||
|
* @param callbackInfo
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Inject(method = "renderCrosshair", at = @At(value = "TAIL"))
|
||||||
|
public void finishCrosshair(MatrixStack stack, CallbackInfo callbackInfo)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Resets the color so that nothing else is bothered.
|
||||||
|
*/
|
||||||
|
RenderSystem.color4f(1, 1, 1, 1F);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether or not to draw the horse jump bar.
|
||||||
|
*
|
||||||
|
* @param stack - The matrix drawing stack.
|
||||||
|
* @param callbackInfo
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Inject(method = "renderMountJumpBar", at = @At(value = "HEAD"))
|
||||||
|
public void startJumpbar(MatrixStack stack,
|
||||||
|
int x,
|
||||||
|
CallbackInfo callbackInfo)
|
||||||
|
{
|
||||||
|
EventBus.drawJumpbar();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets any changes from drawing the horse jump bar.
|
||||||
|
*
|
||||||
|
* @param stack - The matrix drawing stack.
|
||||||
|
* @param callbackInfo
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Inject(method = "renderMountJumpBar", at = @At(value = "TAIL"))
|
||||||
|
public void finishJumpbar(MatrixStack stack,
|
||||||
|
int x,
|
||||||
|
CallbackInfo callbackInfo)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Resets the color so that nothing else is bothered.
|
||||||
|
*/
|
||||||
|
RenderSystem.color4f(1, 1, 1, 1F);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether or not to draw the experience bar.
|
||||||
|
*
|
||||||
|
* @param stack - The matrix drawing stack.
|
||||||
|
* @param callbackInfo
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Inject(method = "renderExperienceBar", at = @At(value = "HEAD"),
|
||||||
|
cancellable = true)
|
||||||
|
public void startExperience(MatrixStack stack,
|
||||||
|
int x,
|
||||||
|
CallbackInfo callbackInfo)
|
||||||
|
{
|
||||||
|
if (EventBus.drawExperience())
|
||||||
|
{
|
||||||
|
callbackInfo.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets any changes from drawing the experience bar.
|
||||||
|
*
|
||||||
|
* @param stack - The matrix drawing stack.
|
||||||
|
* @param callbackInfo
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Inject(method = "renderExperienceBar", at = @At(value = "TAIL"))
|
||||||
|
public void finishExperience(MatrixStack stack,
|
||||||
|
int x,
|
||||||
|
CallbackInfo callbackInfo)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Resets the color so that nothing else is bothered.
|
||||||
|
*/
|
||||||
|
RenderSystem.color4f(1, 1, 1, 1F);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether or not to draw the mount's health.
|
||||||
|
*
|
||||||
|
* @param stack - The matrix drawing stack.
|
||||||
|
* @param callbackInfo
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Inject(method = "renderMountHealth", at = @At(value = "HEAD"))
|
||||||
|
public void startMountHealth(MatrixStack stack, CallbackInfo callbackInfo)
|
||||||
|
{
|
||||||
|
EventBus.drawMountHealth();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets any changes from drawing the mount's health.
|
||||||
|
*
|
||||||
|
* @param stack - The matrix drawing stack.
|
||||||
|
* @param callbackInfo
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Inject(method = "renderMountHealth", at = @At(value = "TAIL"))
|
||||||
|
public void finishMountHealth(MatrixStack stack, CallbackInfo callbackInfo)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Resets the color so that nothing else is bothered.
|
||||||
|
*/
|
||||||
|
RenderSystem.color4f(1, 1, 1, 1F);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether or not to draw the hotbar.
|
||||||
|
*
|
||||||
|
* @param tickDelta
|
||||||
|
* @param matrices - The matrix drawing stack.
|
||||||
|
* @param callbackInfo
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Inject(method = "renderHotbar", at = @At(value = "HEAD"), cancellable =
|
||||||
|
true)
|
||||||
|
public void startHotbar(float tickDelta,
|
||||||
|
MatrixStack matrices,
|
||||||
|
CallbackInfo callbackInfo)
|
||||||
|
{
|
||||||
|
if (EventBus.updateHotbar())
|
||||||
|
{
|
||||||
|
callbackInfo.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes the actual adjustment to the hotbar as needed.
|
||||||
|
*
|
||||||
|
* @param tickDelta
|
||||||
|
* @param matrices - The matrix drawing stack.
|
||||||
|
* @param callbackInfo
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Inject(method = "renderHotbar", at = @At(value = "INVOKE", target =
|
||||||
|
"Lcom/mojang/blaze3d/systems/RenderSystem;color4f(FFFF)V", shift
|
||||||
|
= At.Shift.AFTER))
|
||||||
|
public void adjustHotbar(float tickDelta,
|
||||||
|
MatrixStack matrices,
|
||||||
|
CallbackInfo callbackInfo)
|
||||||
|
{
|
||||||
|
EventBus.recolorHotbar();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets any changes from drawing the hotbar.
|
||||||
|
*
|
||||||
|
* @param tickDelta
|
||||||
|
* @param matrices - The matrix drawing stack.
|
||||||
|
* @param callbackInfo
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Inject(method = "renderHotbar", at = @At(value = "TAIL"))
|
||||||
|
public void finishHotbar(float tickDelta,
|
||||||
|
MatrixStack matrices,
|
||||||
|
CallbackInfo callbackInfo)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Resets the color so that nothing else is bothered.
|
||||||
|
*/
|
||||||
|
RenderSystem.color4f(1, 1, 1, 1F);
|
||||||
|
}
|
||||||
|
}
|
||||||
85
src/main/java/markil3/immersive_hud/mixin/ProfilerHook.java
Normal file
85
src/main/java/markil3/immersive_hud/mixin/ProfilerHook.java
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2021 Markil 3
|
||||||
|
* <p>
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option) any later
|
||||||
|
* version.
|
||||||
|
* <p>
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
* <p>
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package markil3.immersive_hud.mixin;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
|
import net.minecraft.util.profiler.DummyProfiler;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import markil3.immersive_hud.EventBus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class hooks into the profiler to trigger color changes for the status
|
||||||
|
* indicators.
|
||||||
|
*
|
||||||
|
* @author Markil 3
|
||||||
|
* @version 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Mixin(DummyProfiler.class)
|
||||||
|
public class ProfilerHook
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Hooks into the profiler to add logic to drawing armor.
|
||||||
|
*
|
||||||
|
* @param section - The profiler section
|
||||||
|
* @param callbackInfo
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Inject(method = "push", at = @At(value = "TAIL"))
|
||||||
|
public void renderArmor(String section, CallbackInfo callbackInfo)
|
||||||
|
{
|
||||||
|
if (section.equals("armor"))
|
||||||
|
{
|
||||||
|
EventBus.drawArmor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hooks into the profiler to add logic to drawing status bars besides
|
||||||
|
* armor.
|
||||||
|
*
|
||||||
|
* @param section - The profiler section
|
||||||
|
* @param callbackInfo
|
||||||
|
*
|
||||||
|
* @since 0.1-1.16.4-fabric
|
||||||
|
*/
|
||||||
|
@Inject(method = "swap", at = @At(value = "TAIL"))
|
||||||
|
public void renderStatus(String section, CallbackInfo callbackInfo)
|
||||||
|
{
|
||||||
|
switch (section)
|
||||||
|
{
|
||||||
|
case "health":
|
||||||
|
EventBus.drawHealth();
|
||||||
|
break;
|
||||||
|
case "food":
|
||||||
|
EventBus.drawHunger();
|
||||||
|
break;
|
||||||
|
case "air":
|
||||||
|
/*
|
||||||
|
* Resets the color so that nothing else is bothered.
|
||||||
|
*/
|
||||||
|
RenderSystem.color4f(1, 1, 1, 1F);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
src/main/resources/assets/immersive_hud/icon.png
Normal file
BIN
src/main/resources/assets/immersive_hud/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 380 KiB |
37
src/main/resources/fabric.mod.json
Normal file
37
src/main/resources/fabric.mod.json
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": 1,
|
||||||
|
"id": "immersive_hud",
|
||||||
|
"version": "${version}",
|
||||||
|
|
||||||
|
"name": "Immersive HUD",
|
||||||
|
"description": "This mod aims to move the ingame HUD out of the way whenever possible. Whenever an element updates (i.e., health changes, you swap items, you look at something, etc.), the respective item will show up. However, once you've been able to see the information, it will fade away and allow you to enjoy your game without the clutter of unneeded HUD elements.\n\nNote that the following elements are unaffected:\n* The F3 Menu. Honestly, anyone who uses this isn't in the need for immersion at the moment.\n* The chat. This will automatically fade away by itself.\n* The oxygen bar. This will disappear as soon as it is filled, anyway.\n* Boss health. It is helpful to have this available in a hectic situation.\n* Sub-maximum health or hunger. In hectic battles, it can be convenient to see health at a glance.",
|
||||||
|
"authors": [
|
||||||
|
"Markil 3"
|
||||||
|
],
|
||||||
|
"contact": {
|
||||||
|
"homepage": "https://fabricmc.net/",
|
||||||
|
"sources": "https://github.com/FabricMC/fabric-example-mod"
|
||||||
|
},
|
||||||
|
|
||||||
|
"license": "GPL-3.0-only",
|
||||||
|
"icon": "assets/immersive_hud/icon.png",
|
||||||
|
|
||||||
|
"environment": "client",
|
||||||
|
"entrypoints": {
|
||||||
|
"main": [
|
||||||
|
"markil3.immersive_hud.Main"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"mixins": [
|
||||||
|
{
|
||||||
|
"config": "modid.mixins.json",
|
||||||
|
"environment": "client"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"depends": {
|
||||||
|
"fabricloader": ">=0.7.4",
|
||||||
|
"fabric": "*",
|
||||||
|
"minecraft": "1.16.x"
|
||||||
|
}
|
||||||
|
}
|
||||||
17
src/main/resources/modid.mixins.json
Normal file
17
src/main/resources/modid.mixins.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"minVersion": "0.8",
|
||||||
|
"package": "markil3.immersive_hud.mixin",
|
||||||
|
"compatibilityLevel": "JAVA_8",
|
||||||
|
"mixins": [
|
||||||
|
],
|
||||||
|
"client": [
|
||||||
|
"ClientPlayerHook",
|
||||||
|
"HeldItemHook",
|
||||||
|
"HudHook",
|
||||||
|
"ProfilerHook"
|
||||||
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user