Initial sanctuary sources
@@ -0,0 +1,34 @@
|
||||
# Gradle
|
||||
.gradle/
|
||||
build/
|
||||
out/
|
||||
classes/
|
||||
|
||||
# Eclipse
|
||||
*.launch
|
||||
|
||||
# IntelliJ IDEA
|
||||
.idea/
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
# VS Code
|
||||
.settings/
|
||||
.vscode/
|
||||
bin/
|
||||
.classpath
|
||||
.project
|
||||
|
||||
# macOS
|
||||
*.DS_Store
|
||||
|
||||
# Fabric
|
||||
run/
|
||||
|
||||
# Java
|
||||
.jdk/
|
||||
hs_err_*.log
|
||||
replay_*.log
|
||||
*.hprof
|
||||
*.jfr
|
||||
@@ -0,0 +1,168 @@
|
||||
IBelieveChickenFly is licensed by KOKA99CAB under the GNU Lesser General
|
||||
Public License, version 3.0 or later.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
@@ -0,0 +1,71 @@
|
||||
plugins {
|
||||
id "net.fabricmc.fabric-loom" version "${loom_version}"
|
||||
id "maven-publish"
|
||||
}
|
||||
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
|
||||
base {
|
||||
archivesName = project.archives_base_name
|
||||
}
|
||||
|
||||
repositories {
|
||||
}
|
||||
|
||||
loom {
|
||||
splitEnvironmentSourceSets()
|
||||
|
||||
mods {
|
||||
"ibelievechickenfly" {
|
||||
sourceSet sourceSets.main
|
||||
sourceSet sourceSets.client
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
implementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
|
||||
}
|
||||
|
||||
processResources {
|
||||
def version = project.version
|
||||
inputs.property "version", version
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": version
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.release = 25
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_25
|
||||
targetCompatibility = JavaVersion.VERSION_25
|
||||
}
|
||||
|
||||
jar {
|
||||
def archivesName = project.archives_base_name
|
||||
inputs.property "archivesName", archivesName
|
||||
|
||||
from("LICENSE") {
|
||||
rename { "${it}_${archivesName}" }
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create("mavenJava", MavenPublication) {
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 28 KiB |
@@ -0,0 +1,21 @@
|
||||
# Done to increase the memory available to Gradle.
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
org.gradle.parallel=true
|
||||
|
||||
# IntelliJ IDEA is not yet fully compatible with configuration cache:
|
||||
# https://github.com/FabricMC/fabric-loom/issues/1349
|
||||
org.gradle.configuration-cache=false
|
||||
|
||||
# Fabric properties
|
||||
# Check current versions on https://fabricmc.net/develop
|
||||
minecraft_version=26.1.2
|
||||
loader_version=0.19.2
|
||||
loom_version=1.16-SNAPSHOT
|
||||
|
||||
# Mod properties
|
||||
mod_version=1.0.0
|
||||
maven_group=fr.koka99cab
|
||||
archives_base_name=ibelievechickenfly
|
||||
|
||||
# Dependencies
|
||||
fabric_api_version=0.148.0+26.1.2
|
||||
@@ -0,0 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,253 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015 the original 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.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# 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/2d6327017519d23b96af35865dc997fcb544fb40/platforms/jvm/plugins-application/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
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
if [ -z "$JAVA_HOME" ] && [ -x "$APP_HOME/.jdk/current/bin/java" ] ; then
|
||||
JAVA_HOME=$APP_HOME/.jdk/current
|
||||
export JAVA_HOME
|
||||
fi
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# 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 ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
# 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
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
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
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -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
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -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
|
||||
fi
|
||||
|
||||
|
||||
# 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"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# 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" "$@"
|
||||
@@ -0,0 +1,93 @@
|
||||
@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
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@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=.
|
||||
@rem This is normally unused
|
||||
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% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1,12 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven {
|
||||
name = "Fabric"
|
||||
url = "https://maven.fabricmc.net/"
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "ibelievechickenfly"
|
||||
@@ -0,0 +1,36 @@
|
||||
package fr.koka99cab.ibelievechickenfly.chickenboat;
|
||||
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.vehicle.boat.AbstractBoat;
|
||||
|
||||
public final class ChickenBoatClientController {
|
||||
private ChickenBoatClientController() {
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
ClientTickEvents.END_CLIENT_TICK.register(ChickenBoatClientController::tick);
|
||||
}
|
||||
|
||||
private static void tick(Minecraft client) {
|
||||
if (client.player == null || client.level == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity vehicle = client.player.getVehicle();
|
||||
|
||||
if (!(vehicle instanceof AbstractBoat boat) || !ChickenBoatUtil.hasChickenPassenger(boat)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ClientPlayNetworking.canSend(ChickenBoatControlPayload.ID)) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean up = client.options.keyJump.isDown();
|
||||
ClientPlayNetworking.send(new ChickenBoatControlPayload(up));
|
||||
ChickenBoatFlightPhysics.apply(boat, up);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package fr.koka99cab.ibelievechickenfly.client;
|
||||
|
||||
import fr.koka99cab.ibelievechickenfly.chickenboat.ChickenBoatClientController;
|
||||
import fr.koka99cab.ibelievechickenfly.IBelieveChickenFlyMod;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
|
||||
public final class IBelieveChickenFlyClient implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
ChickenBoatClientController.register();
|
||||
IBelieveChickenFlyMod.LOGGER.info("IBelieveChickenFly client initialise.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package fr.koka99cab.ibelievechickenfly;
|
||||
|
||||
import fr.koka99cab.ibelievechickenfly.chickenboat.ChickenBoatControlPayload;
|
||||
import fr.koka99cab.ibelievechickenfly.chickenboat.ChickenBoatServerController;
|
||||
import fr.koka99cab.ibelievechickenfly.chickenfly.ChickenCarryController;
|
||||
import fr.koka99cab.ibelievechickenfly.registry.ModItems;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public final class IBelieveChickenFlyMod implements ModInitializer {
|
||||
public static final String MOD_ID = "ibelievechickenfly";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
ModItems.register();
|
||||
PayloadTypeRegistry.serverboundPlay().register(ChickenBoatControlPayload.ID, ChickenBoatControlPayload.CODEC);
|
||||
ChickenCarryController.register();
|
||||
ChickenBoatServerController.register();
|
||||
|
||||
LOGGER.info("IBelieveChickenFly 26.1.2 charge.");
|
||||
}
|
||||
|
||||
public static Identifier id(String path) {
|
||||
return Identifier.fromNamespaceAndPath(MOD_ID, path);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package fr.koka99cab.ibelievechickenfly.chickenboat;
|
||||
|
||||
import fr.koka99cab.ibelievechickenfly.IBelieveChickenFlyMod;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
|
||||
public record ChickenBoatControlPayload(boolean up) implements CustomPacketPayload {
|
||||
public static final CustomPacketPayload.Type<ChickenBoatControlPayload> ID =
|
||||
new CustomPacketPayload.Type<>(IBelieveChickenFlyMod.id("boat_control"));
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, ChickenBoatControlPayload> CODEC =
|
||||
CustomPacketPayload.codec(ChickenBoatControlPayload::write, ChickenBoatControlPayload::new);
|
||||
|
||||
public ChickenBoatControlPayload(RegistryFriendlyByteBuf buffer) {
|
||||
this(buffer.readBoolean());
|
||||
}
|
||||
|
||||
private void write(RegistryFriendlyByteBuf buffer) {
|
||||
buffer.writeBoolean(this.up);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<? extends CustomPacketPayload> type() {
|
||||
return ID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package fr.koka99cab.ibelievechickenfly.chickenboat;
|
||||
|
||||
import net.minecraft.world.entity.vehicle.boat.AbstractBoat;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public final class ChickenBoatFlightPhysics {
|
||||
private static final double ASCEND_ACCELERATION = 0.07D;
|
||||
private static final double MIN_ASCEND_SPEED = 0.1D;
|
||||
private static final double MAX_ASCEND_SPEED = 0.24D;
|
||||
private static final double DESCEND_ACCELERATION = 0.025D;
|
||||
private static final double MAX_DESCEND_SPEED = -0.04D;
|
||||
|
||||
private ChickenBoatFlightPhysics() {
|
||||
}
|
||||
|
||||
public static void apply(AbstractBoat boat, boolean up) {
|
||||
Vec3 velocity = boat.getDeltaMovement();
|
||||
double yVelocity;
|
||||
|
||||
if (up) {
|
||||
yVelocity = clamp(velocity.y + ASCEND_ACCELERATION, MIN_ASCEND_SPEED, MAX_ASCEND_SPEED);
|
||||
} else {
|
||||
yVelocity = glideVelocity(velocity.y);
|
||||
}
|
||||
|
||||
boat.setDeltaMovement(velocity.x, yVelocity, velocity.z);
|
||||
boat.fallDistance = 0.0F;
|
||||
boat.push(0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
|
||||
private static double glideVelocity(double yVelocity) {
|
||||
return Math.max(yVelocity - DESCEND_ACCELERATION, MAX_DESCEND_SPEED);
|
||||
}
|
||||
|
||||
private static double clamp(double value, double min, double max) {
|
||||
return Math.max(min, Math.min(max, value));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package fr.koka99cab.ibelievechickenfly.chickenboat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.vehicle.boat.AbstractBoat;
|
||||
|
||||
public final class ChickenBoatServerController {
|
||||
private static final int INPUT_TIMEOUT_TICKS = 5;
|
||||
|
||||
private static final Map<UUID, ControlState> CONTROL_STATES = new HashMap<>();
|
||||
|
||||
private ChickenBoatServerController() {
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
ServerPlayNetworking.registerGlobalReceiver(
|
||||
ChickenBoatControlPayload.ID,
|
||||
(payload, context) -> updateControls(context.player(), payload)
|
||||
);
|
||||
ServerTickEvents.END_SERVER_TICK.register(ChickenBoatServerController::tick);
|
||||
}
|
||||
|
||||
private static void updateControls(ServerPlayer player, ChickenBoatControlPayload payload) {
|
||||
UUID playerId = player.getUUID();
|
||||
|
||||
if (getValidBoat(player) == null) {
|
||||
CONTROL_STATES.remove(playerId);
|
||||
return;
|
||||
}
|
||||
|
||||
CONTROL_STATES.computeIfAbsent(playerId, id -> new ControlState()).update(payload.up());
|
||||
}
|
||||
|
||||
private static void tick(MinecraftServer server) {
|
||||
for (ServerPlayer player : server.getPlayerList().getPlayers()) {
|
||||
tickPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
private static void tickPlayer(ServerPlayer player) {
|
||||
UUID playerId = player.getUUID();
|
||||
AbstractBoat boat = getValidBoat(player);
|
||||
|
||||
if (boat == null) {
|
||||
CONTROL_STATES.remove(playerId);
|
||||
return;
|
||||
}
|
||||
|
||||
ControlState controls = CONTROL_STATES.get(playerId);
|
||||
boolean hasFreshInput = controls != null && controls.ticksSinceUpdate <= INPUT_TIMEOUT_TICKS;
|
||||
boolean up = hasFreshInput && controls.up;
|
||||
|
||||
ChickenBoatFlightPhysics.apply(boat, up);
|
||||
|
||||
if (controls != null) {
|
||||
controls.ticksSinceUpdate++;
|
||||
}
|
||||
}
|
||||
|
||||
private static AbstractBoat getValidBoat(ServerPlayer player) {
|
||||
Entity vehicle = player.getVehicle();
|
||||
|
||||
if (!(vehicle instanceof AbstractBoat boat)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (boat.level() != player.level() || !boat.isAlive() || !boat.hasPassenger(player)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ChickenBoatUtil.hasChickenPassenger(boat) ? boat : null;
|
||||
}
|
||||
|
||||
private static final class ControlState {
|
||||
private boolean up;
|
||||
private int ticksSinceUpdate;
|
||||
|
||||
private void update(boolean up) {
|
||||
this.up = up;
|
||||
this.ticksSinceUpdate = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package fr.koka99cab.ibelievechickenfly.chickenboat;
|
||||
|
||||
import net.minecraft.world.entity.animal.chicken.Chicken;
|
||||
import net.minecraft.world.entity.vehicle.boat.AbstractBoat;
|
||||
|
||||
public final class ChickenBoatUtil {
|
||||
private ChickenBoatUtil() {
|
||||
}
|
||||
|
||||
public static boolean hasChickenPassenger(AbstractBoat boat) {
|
||||
return boat != null
|
||||
&& !boat.isRemoved()
|
||||
&& boat.hasPassenger(passenger -> passenger instanceof Chicken && passenger.isAlive());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
package fr.koka99cab.ibelievechickenfly.chickenfly;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
|
||||
import net.fabricmc.fabric.api.event.player.UseItemCallback;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.Pose;
|
||||
import net.minecraft.world.entity.animal.chicken.Chicken;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public final class ChickenCarryController {
|
||||
private static final int EFFECT_DURATION_TICKS = 10;
|
||||
private static final int JUMP_BOOST_AMPLIFIER = 0;
|
||||
private static final int SLOW_FALLING_AMPLIFIER = 0;
|
||||
private static final double CHICKEN_HEIGHT_OFFSET = 0.5D;
|
||||
private static final double CHICKEN_FORWARD_OFFSET = 0.18D;
|
||||
private static final double CHICKEN_VELOCITY_COMPENSATION = 1.2D;
|
||||
private static final double RELEASE_DISTANCE = 0.9D;
|
||||
private static final double RELEASE_EXTRA_DISTANCE = 0.35D;
|
||||
private static final double RELEASE_SIDE_OFFSET = 0.55D;
|
||||
private static final double RELEASE_COLLISION_EPSILON = 1.0E-4D;
|
||||
private static final double[] RELEASE_Y_OFFSETS = new double[] {
|
||||
0.0D, 0.25D, 0.5D, 1.0D, 1.5D, 2.0D, -0.25D, -0.5D, -1.0D
|
||||
};
|
||||
|
||||
private static final Map<UUID, UUID> PLAYER_TO_CHICKEN = new HashMap<>();
|
||||
private static final Map<UUID, UUID> CHICKEN_TO_PLAYER = new HashMap<>();
|
||||
|
||||
private ChickenCarryController() {
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
UseItemCallback.EVENT.register(ChickenCarryController::tryReleaseChicken);
|
||||
UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> tryReleaseChicken(player, world, hand));
|
||||
ServerTickEvents.END_SERVER_TICK.register(server -> server.getPlayerList().getPlayers().forEach(ChickenCarryController::refreshChickenFlyState));
|
||||
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> releaseChicken(handler.player, false));
|
||||
}
|
||||
|
||||
public static InteractionResult tryPickUpChicken(Player player, Level level, InteractionHand hand, Entity entity) {
|
||||
if (player.isSpectator() || !player.isCrouching() || !(entity instanceof Chicken chicken)) {
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
if (!player.getItemInHand(hand).isEmpty() || !player.getPassengers().isEmpty() || chicken.isPassenger()) {
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
if (level.isClientSide()) {
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
if (!(player instanceof ServerPlayer serverPlayer)) {
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
return pickUpChicken(serverPlayer, chicken) ? InteractionResult.SUCCESS_SERVER : InteractionResult.PASS;
|
||||
}
|
||||
|
||||
private static InteractionResult tryReleaseChicken(Player player, Level level, InteractionHand hand) {
|
||||
if (player.isSpectator() || !player.isCrouching() || !player.getItemInHand(hand).isEmpty()) {
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
if (level.isClientSide()) {
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
Chicken chicken = getCarriedChicken(player);
|
||||
if (chicken == null) {
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
releaseChicken(player, true);
|
||||
return InteractionResult.SUCCESS_SERVER;
|
||||
}
|
||||
|
||||
private static boolean pickUpChicken(ServerPlayer player, Chicken chicken) {
|
||||
if (PLAYER_TO_CHICKEN.containsKey(player.getUUID()) || CHICKEN_TO_PLAYER.containsKey(chicken.getUUID())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PLAYER_TO_CHICKEN.put(player.getUUID(), chicken.getUUID());
|
||||
CHICKEN_TO_PLAYER.put(chicken.getUUID(), player.getUUID());
|
||||
chicken.stopRiding();
|
||||
chicken.setNoGravity(true);
|
||||
chicken.noPhysics = true;
|
||||
|
||||
if (chicken instanceof Mob mob) {
|
||||
mob.setNoAi(true);
|
||||
}
|
||||
|
||||
positionChicken(player, chicken);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void refreshChickenFlyState(ServerPlayer player) {
|
||||
Chicken chicken = getCarriedChicken(player);
|
||||
if (chicken == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.isAlive() || chicken.level() != player.level()) {
|
||||
releaseChicken(player, false);
|
||||
return;
|
||||
}
|
||||
|
||||
positionChicken(player, chicken);
|
||||
refreshHiddenEffect(player, MobEffects.JUMP_BOOST, JUMP_BOOST_AMPLIFIER);
|
||||
refreshHiddenEffect(player, MobEffects.SLOW_FALLING, SLOW_FALLING_AMPLIFIER);
|
||||
}
|
||||
|
||||
private static void refreshHiddenEffect(ServerPlayer player, Holder<MobEffect> effect, int amplifier) {
|
||||
MobEffectInstance currentEffect = player.getEffect(effect);
|
||||
if (currentEffect != null && currentEffect.getAmplifier() == amplifier && currentEffect.getDuration() > EFFECT_DURATION_TICKS / 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.addEffect(new MobEffectInstance(effect, EFFECT_DURATION_TICKS, amplifier, false, false, false));
|
||||
}
|
||||
|
||||
private static void releaseChicken(Player player, boolean placeInFront) {
|
||||
Chicken chicken = getCarriedChicken(player);
|
||||
if (chicken == null) {
|
||||
clearChickenAssociation(player.getUUID(), null);
|
||||
return;
|
||||
}
|
||||
|
||||
clearChickenAssociation(player.getUUID(), chicken.getUUID());
|
||||
chicken.setNoGravity(false);
|
||||
chicken.noPhysics = false;
|
||||
|
||||
if (chicken instanceof Mob mob) {
|
||||
mob.setNoAi(false);
|
||||
}
|
||||
|
||||
Vec3 releasePos = findSafeReleasePosition(player, chicken, placeInFront);
|
||||
|
||||
chicken.setPos(releasePos.x, releasePos.y, releasePos.z);
|
||||
chicken.setYRot(player.getYRot());
|
||||
chicken.setXRot(0.0F);
|
||||
chicken.setYBodyRot(player.getYRot());
|
||||
chicken.setYHeadRot(player.getYRot());
|
||||
chicken.setDeltaMovement(Vec3.ZERO);
|
||||
chicken.resetFallDistance();
|
||||
}
|
||||
|
||||
private static Vec3 findSafeReleasePosition(Player player, Chicken chicken, boolean placeInFront) {
|
||||
Level level = player.level();
|
||||
Vec3 playerPos = player.position();
|
||||
|
||||
if (!placeInFront) {
|
||||
Vec3 safePlayerPos = findSafeStandingPosition(level, chicken, playerPos);
|
||||
return safePlayerPos != null ? safePlayerPos : playerPos.add(0.0D, player.getEyeHeight(), 0.0D);
|
||||
}
|
||||
|
||||
Vec3 forward = getHorizontalLook(player);
|
||||
Vec3 right = new Vec3(-forward.z, 0.0D, forward.x);
|
||||
Vec3 forwardPos = playerPos.add(forward.scale(RELEASE_DISTANCE + RELEASE_EXTRA_DISTANCE));
|
||||
Vec3[] candidates = new Vec3[] {
|
||||
forwardPos,
|
||||
forwardPos.add(right.scale(RELEASE_SIDE_OFFSET)),
|
||||
forwardPos.add(right.scale(-RELEASE_SIDE_OFFSET)),
|
||||
playerPos.add(forward.scale(RELEASE_DISTANCE * 0.5D)),
|
||||
playerPos.add(right.scale(RELEASE_SIDE_OFFSET)),
|
||||
playerPos.add(right.scale(-RELEASE_SIDE_OFFSET))
|
||||
};
|
||||
|
||||
for (Vec3 candidate : candidates) {
|
||||
Vec3 safeCandidate = findSafeStandingPosition(level, chicken, candidate);
|
||||
if (safeCandidate != null) {
|
||||
return safeCandidate;
|
||||
}
|
||||
}
|
||||
|
||||
Vec3 headFallback = playerPos.add(0.0D, player.getEyeHeight() + CHICKEN_HEIGHT_OFFSET, 0.0D);
|
||||
Vec3 safeFallback = findSafeStandingPosition(level, chicken, headFallback);
|
||||
return safeFallback != null ? safeFallback : headFallback;
|
||||
}
|
||||
|
||||
private static Vec3 getHorizontalLook(Player player) {
|
||||
Vec3 look = player.getLookAngle();
|
||||
Vec3 horizontalLook = new Vec3(look.x, 0.0D, look.z);
|
||||
if (horizontalLook.lengthSqr() > 1.0E-4D) {
|
||||
return horizontalLook.normalize();
|
||||
}
|
||||
|
||||
double yawRadians = Math.toRadians(player.getYRot());
|
||||
return new Vec3(-Math.sin(yawRadians), 0.0D, Math.cos(yawRadians));
|
||||
}
|
||||
|
||||
private static Vec3 findSafeStandingPosition(Level level, Chicken chicken, Vec3 basePosition) {
|
||||
for (double yOffset : RELEASE_Y_OFFSETS) {
|
||||
Vec3 candidate = basePosition.add(0.0D, yOffset, 0.0D);
|
||||
AABB boundingBox = chicken.getDimensions(Pose.STANDING)
|
||||
.makeBoundingBox(candidate)
|
||||
.deflate(RELEASE_COLLISION_EPSILON);
|
||||
if (level.noCollision(chicken, boundingBox)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void positionChicken(ServerPlayer player, Chicken chicken) {
|
||||
Vec3 look = player.getLookAngle();
|
||||
Vec3 forwardOffset = new Vec3(look.x, 0.0D, look.z).scale(CHICKEN_FORWARD_OFFSET);
|
||||
Vec3 velocityOffset = new Vec3(player.getDeltaMovement().x, 0.0D, player.getDeltaMovement().z).scale(CHICKEN_VELOCITY_COMPENSATION);
|
||||
Vec3 headPos = player.position()
|
||||
.add(0.0D, player.getEyeHeight() + CHICKEN_HEIGHT_OFFSET, 0.0D)
|
||||
.add(forwardOffset)
|
||||
.add(velocityOffset);
|
||||
|
||||
chicken.setPos(headPos.x, headPos.y, headPos.z);
|
||||
chicken.setYRot(player.getYRot());
|
||||
chicken.setXRot(0.0F);
|
||||
chicken.setYBodyRot(player.getYRot());
|
||||
chicken.setYHeadRot(player.getYRot());
|
||||
chicken.setDeltaMovement(Vec3.ZERO);
|
||||
}
|
||||
|
||||
private static Chicken getCarriedChicken(Player player) {
|
||||
UUID chickenUuid = PLAYER_TO_CHICKEN.get(player.getUUID());
|
||||
if (chickenUuid == null || player.level().getServer() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (ServerLevel level : player.level().getServer().getAllLevels()) {
|
||||
Entity entity = level.getEntity(chickenUuid);
|
||||
if (entity instanceof Chicken chicken && entity.isAlive()) {
|
||||
return chicken;
|
||||
}
|
||||
}
|
||||
|
||||
clearChickenAssociation(player.getUUID(), chickenUuid);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isChickenCarried(Entity entity) {
|
||||
return entity instanceof Chicken && CHICKEN_TO_PLAYER.containsKey(entity.getUUID());
|
||||
}
|
||||
|
||||
private static void clearChickenAssociation(UUID playerUuid, UUID chickenUuid) {
|
||||
UUID actualChickenUuid = chickenUuid != null ? chickenUuid : PLAYER_TO_CHICKEN.remove(playerUuid);
|
||||
if (actualChickenUuid != null) {
|
||||
PLAYER_TO_CHICKEN.remove(playerUuid);
|
||||
CHICKEN_TO_PLAYER.remove(actualChickenUuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package fr.koka99cab.ibelievechickenfly.chickenfly;
|
||||
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Position;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEgg;
|
||||
import net.minecraft.world.item.EggItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public class GoldenEggItem extends EggItem {
|
||||
public GoldenEggItem(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(Level level, Player player, InteractionHand hand) {
|
||||
applyBlueVariant(level, player.getItemInHand(hand));
|
||||
return super.use(level, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Projectile asProjectile(Level level, Position position, ItemStack stack, Direction direction) {
|
||||
return new ThrownEgg(level, position.x(), position.y(), position.z(), stackWithBlueVariant(level, stack));
|
||||
}
|
||||
|
||||
private static void applyBlueVariant(Level level, ItemStack stack) {
|
||||
ModChickenVariants.getBlue(level.registryAccess()).ifPresent(variant -> stack.set(DataComponents.CHICKEN_VARIANT, variant));
|
||||
}
|
||||
|
||||
private static ItemStack stackWithBlueVariant(Level level, ItemStack stack) {
|
||||
ItemStack copy = stack.copyWithCount(1);
|
||||
applyBlueVariant(level, copy);
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package fr.koka99cab.ibelievechickenfly.chickenfly;
|
||||
|
||||
import fr.koka99cab.ibelievechickenfly.IBelieveChickenFlyMod;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.entity.animal.chicken.Chicken;
|
||||
import net.minecraft.world.entity.animal.chicken.ChickenVariant;
|
||||
|
||||
public final class ModChickenVariants {
|
||||
public static final ResourceKey<ChickenVariant> BLUE = ResourceKey.create(Registries.CHICKEN_VARIANT, IBelieveChickenFlyMod.id("blue"));
|
||||
|
||||
private ModChickenVariants() {
|
||||
}
|
||||
|
||||
public static Optional<Holder.Reference<ChickenVariant>> getBlue(RegistryAccess registryAccess) {
|
||||
Registry<ChickenVariant> registry = registryAccess.lookupOrThrow(Registries.CHICKEN_VARIANT);
|
||||
return registry.get(BLUE);
|
||||
}
|
||||
|
||||
public static boolean isBlue(Chicken chicken) {
|
||||
return chicken.getVariant().is(BLUE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package fr.koka99cab.ibelievechickenfly.mixin;
|
||||
|
||||
import fr.koka99cab.ibelievechickenfly.chickenfly.ChickenCarryController;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.animal.Animal;
|
||||
import net.minecraft.world.entity.animal.chicken.Chicken;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Animal.class)
|
||||
public abstract class AnimalEntityMixin {
|
||||
@Inject(method = "mobInteract", at = @At("HEAD"), cancellable = true)
|
||||
private void ibelievechickenfly$pickUpChicken(Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir) {
|
||||
Animal self = (Animal) (Object) this;
|
||||
if (!(self instanceof Chicken)) {
|
||||
return;
|
||||
}
|
||||
|
||||
InteractionResult result = ChickenCarryController.tryPickUpChicken(player, self.level(), hand, self);
|
||||
if (result != InteractionResult.PASS) {
|
||||
cir.setReturnValue(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package fr.koka99cab.ibelievechickenfly.mixin;
|
||||
|
||||
import fr.koka99cab.ibelievechickenfly.chickenfly.ModChickenVariants;
|
||||
import fr.koka99cab.ibelievechickenfly.registry.ModItems;
|
||||
import java.util.function.BiConsumer;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.animal.chicken.Chicken;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(Chicken.class)
|
||||
public abstract class ChickenMixin {
|
||||
private static final int GOLDEN_EGG_LAY_CHANCE = 256;
|
||||
|
||||
@Redirect(
|
||||
method = "aiStep",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/animal/chicken/Chicken;dropFromGiftLootTable(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/resources/ResourceKey;Ljava/util/function/BiConsumer;)Z"
|
||||
)
|
||||
)
|
||||
private boolean ibelievechickenfly$dropSpecialEgg(Chicken chicken, ServerLevel serverLevel, ResourceKey<LootTable> lootTable, BiConsumer<ServerLevel, ItemStack> dropper) {
|
||||
if (ModChickenVariants.isBlue(chicken)) {
|
||||
dropper.accept(serverLevel, new ItemStack(Items.DIAMOND));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (chicken.getRandom().nextInt(GOLDEN_EGG_LAY_CHANCE) == 0) {
|
||||
dropper.accept(serverLevel, new ItemStack(ModItems.GOLDEN_EGG));
|
||||
return true;
|
||||
}
|
||||
|
||||
return chicken.dropFromGiftLootTable(serverLevel, lootTable, dropper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package fr.koka99cab.ibelievechickenfly.mixin;
|
||||
|
||||
import fr.koka99cab.ibelievechickenfly.chickenfly.ChickenCarryController;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.animal.chicken.Chicken;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public abstract class EntityMixin {
|
||||
@Inject(method = "interact", at = @At("HEAD"), cancellable = true)
|
||||
private void ibelievechickenfly$pickUpChickenAt(Player player, InteractionHand hand, Vec3 hitPos, CallbackInfoReturnable<InteractionResult> cir) {
|
||||
Entity self = (Entity) (Object) this;
|
||||
if (!(self instanceof Chicken)) {
|
||||
return;
|
||||
}
|
||||
|
||||
InteractionResult result = ChickenCarryController.tryPickUpChicken(player, self.level(), hand, self);
|
||||
if (result != InteractionResult.PASS) {
|
||||
cir.setReturnValue(result);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "isPushable", at = @At("HEAD"), cancellable = true)
|
||||
private void ibelievechickenfly$disablePush(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ChickenCarryController.isChickenCarried((Entity) (Object) this)) {
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "isPickable", at = @At("HEAD"), cancellable = true)
|
||||
private void ibelievechickenfly$disablePick(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ChickenCarryController.isChickenCarried((Entity) (Object) this)) {
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "canCollideWith", at = @At("HEAD"), cancellable = true)
|
||||
private void ibelievechickenfly$disableEntityCollision(Entity entity, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ChickenCarryController.isChickenCarried((Entity) (Object) this)) {
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package fr.koka99cab.ibelievechickenfly.mixin;
|
||||
|
||||
import fr.koka99cab.ibelievechickenfly.chickenfly.ChickenCarryController;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
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;
|
||||
|
||||
@Mixin(LivingEntity.class)
|
||||
public abstract class LivingEntityMixin {
|
||||
@Inject(method = "doPush", at = @At("HEAD"), cancellable = true)
|
||||
private void ibelievechickenfly$cancelPushAway(Entity entity, CallbackInfo ci) {
|
||||
if (ChickenCarryController.isChickenCarried((Entity) (Object) this)) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package fr.koka99cab.ibelievechickenfly.registry;
|
||||
|
||||
import fr.koka99cab.ibelievechickenfly.IBelieveChickenFlyMod;
|
||||
import fr.koka99cab.ibelievechickenfly.chickenfly.GoldenEggItem;
|
||||
import fr.koka99cab.ibelievechickenfly.chickenfly.ModChickenVariants;
|
||||
import net.fabricmc.fabric.api.creativetab.v1.CreativeModeTabEvents;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.SpawnEggItem;
|
||||
|
||||
public final class ModItems {
|
||||
private static final ResourceKey<Item> GOLDEN_EGG_KEY = ResourceKey.create(Registries.ITEM, IBelieveChickenFlyMod.id("golden_egg"));
|
||||
private static final ResourceKey<Item> BLUE_CHICKEN_SPAWN_EGG_KEY = ResourceKey.create(Registries.ITEM, IBelieveChickenFlyMod.id("blue_chicken_spawn_egg"));
|
||||
private static final ResourceKey<CreativeModeTab> INGREDIENTS_TAB = vanillaTab("ingredients");
|
||||
private static final ResourceKey<CreativeModeTab> SPAWN_EGGS_TAB = vanillaTab("spawn_eggs");
|
||||
|
||||
public static final Item GOLDEN_EGG = Registry.register(
|
||||
BuiltInRegistries.ITEM,
|
||||
GOLDEN_EGG_KEY,
|
||||
new GoldenEggItem(new Item.Properties().stacksTo(16).rarity(Rarity.RARE).setId(GOLDEN_EGG_KEY))
|
||||
);
|
||||
|
||||
public static final Item BLUE_CHICKEN_SPAWN_EGG = Registry.register(
|
||||
BuiltInRegistries.ITEM,
|
||||
BLUE_CHICKEN_SPAWN_EGG_KEY,
|
||||
new SpawnEggItem(new Item.Properties()
|
||||
.spawnEgg(EntityType.CHICKEN)
|
||||
.delayedHolderComponent(DataComponents.CHICKEN_VARIANT, ModChickenVariants.BLUE)
|
||||
.setId(BLUE_CHICKEN_SPAWN_EGG_KEY))
|
||||
);
|
||||
|
||||
private ModItems() {
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
CreativeModeTabEvents.modifyOutputEvent(INGREDIENTS_TAB).register(entries -> entries.insertAfter(Items.EGG, GOLDEN_EGG));
|
||||
CreativeModeTabEvents.modifyOutputEvent(SPAWN_EGGS_TAB).register(entries -> entries.insertAfter(Items.CHICKEN_SPAWN_EGG, BLUE_CHICKEN_SPAWN_EGG));
|
||||
IBelieveChickenFlyMod.LOGGER.debug("Objets IBelieveChickenFly enregistres.");
|
||||
}
|
||||
|
||||
private static ResourceKey<CreativeModeTab> vanillaTab(String path) {
|
||||
return ResourceKey.create(Registries.CREATIVE_MODE_TAB, Identifier.withDefaultNamespace(path));
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 518 KiB |
|
After Width: | Height: | Size: 462 KiB |
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "ibelievechickenfly:item/blue_chicken_spawn_egg"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "ibelievechickenfly:item/golden_egg"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"modmenu.nameTranslation.ibelievechickenfly": "IBelieveChickenFly",
|
||||
"modmenu.descriptionTranslation.ibelievechickenfly": "Carry chickens to glide through the air, and let boats fly when a chicken is on board.",
|
||||
"item.ibelievechickenfly.golden_egg": "Golden Egg",
|
||||
"item.ibelievechickenfly.blue_chicken_spawn_egg": "Blue Chicken Spawn Egg"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"modmenu.nameTranslation.ibelievechickenfly": "IBelieveChickenFly",
|
||||
"modmenu.descriptionTranslation.ibelievechickenfly": "Carry chickens to glide through the air, and let boats fly when a chicken is on board.",
|
||||
"item.ibelievechickenfly.golden_egg": "\u0152uf dor\u00e9",
|
||||
"item.ibelievechickenfly.blue_chicken_spawn_egg": "\u0152uf d'apparition de poule bleue"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "ibelievechickenfly:item/blue_chicken_spawn_egg"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "ibelievechickenfly:item/golden_egg"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 705 B |
|
After Width: | Height: | Size: 251 B |
|
After Width: | Height: | Size: 294 B |
|
After Width: | Height: | Size: 223 B |
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"asset_id": "ibelievechickenfly:entity/chicken/chicken_blue",
|
||||
"baby_asset_id": "ibelievechickenfly:entity/chicken/chicken_blue_baby",
|
||||
"spawn_conditions": []
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "ibelievechickenfly",
|
||||
"version": "${version}",
|
||||
"name": "IBelieveChickenFly",
|
||||
"description": "Carry chickens to glide through the air, and let boats fly when a chicken is on board.",
|
||||
"authors": [
|
||||
"KOKA99CAB"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"icon": "assets/ibelievechickenfly/chicken.png",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"fr.koka99cab.ibelievechickenfly.IBelieveChickenFlyMod"
|
||||
],
|
||||
"client": [
|
||||
"fr.koka99cab.ibelievechickenfly.client.IBelieveChickenFlyClient"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"ibelievechickenfly.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.19.2",
|
||||
"minecraft": "~26.1.2",
|
||||
"java": ">=25",
|
||||
"fabric-api": "*"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "fr.koka99cab.ibelievechickenfly.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"AnimalEntityMixin",
|
||||
"ChickenMixin",
|
||||
"EntityMixin",
|
||||
"LivingEntityMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
# Gradle
|
||||
.gradle/
|
||||
build/
|
||||
out/
|
||||
classes/
|
||||
|
||||
# Eclipse
|
||||
*.launch
|
||||
|
||||
# IntelliJ IDEA
|
||||
.idea/
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
# VS Code
|
||||
.settings/
|
||||
.vscode/
|
||||
bin/
|
||||
.classpath
|
||||
.project
|
||||
|
||||
# macOS
|
||||
*.DS_Store
|
||||
|
||||
# Fabric
|
||||
run/
|
||||
|
||||
# Java
|
||||
.jdk/
|
||||
hs_err_*.log
|
||||
replay_*.log
|
||||
*.hprof
|
||||
*.jfr
|
||||
@@ -0,0 +1,67 @@
|
||||
plugins {
|
||||
id "net.fabricmc.fabric-loom" version "${loom_version}"
|
||||
id "maven-publish"
|
||||
}
|
||||
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
|
||||
repositories {
|
||||
}
|
||||
|
||||
loom {
|
||||
splitEnvironmentSourceSets()
|
||||
|
||||
mods {
|
||||
"magiccarpet" {
|
||||
sourceSet sourceSets.main
|
||||
sourceSet sourceSets.client
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
implementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
|
||||
}
|
||||
|
||||
processResources {
|
||||
def version = project.version
|
||||
inputs.property "version", version
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": version
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.release = 25
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_25
|
||||
targetCompatibility = JavaVersion.VERSION_25
|
||||
}
|
||||
|
||||
jar {
|
||||
def projectName = project.name
|
||||
inputs.property "projectName", projectName
|
||||
|
||||
from("../../license.txt") {
|
||||
rename { "${it}_${projectName}" }
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create("mavenJava", MavenPublication) {
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
# Done to increase the memory available to Gradle.
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
org.gradle.parallel=true
|
||||
|
||||
# IntelliJ IDEA is not yet fully compatible with configuration cache:
|
||||
# https://github.com/FabricMC/fabric-loom/issues/1349
|
||||
org.gradle.configuration-cache=false
|
||||
|
||||
# Fabric properties
|
||||
# Check current versions on https://fabricmc.net/develop
|
||||
minecraft_version=26.1.2
|
||||
loader_version=0.19.2
|
||||
loom_version=1.16-SNAPSHOT
|
||||
|
||||
# Mod properties
|
||||
mod_version=1.0.0
|
||||
maven_group=fr.koka99cab
|
||||
archives_base_name=magiccarpet
|
||||
|
||||
# Dependencies
|
||||
fabric_api_version=0.148.0+26.1.2
|
||||
@@ -0,0 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,253 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015 the original 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.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# 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/2d6327017519d23b96af35865dc997fcb544fb40/platforms/jvm/plugins-application/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
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
if [ -z "$JAVA_HOME" ] && [ -x "$APP_HOME/.jdk/current/bin/java" ] ; then
|
||||
JAVA_HOME=$APP_HOME/.jdk/current
|
||||
export JAVA_HOME
|
||||
fi
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# 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 ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
# 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
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
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
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -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
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -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
|
||||
fi
|
||||
|
||||
|
||||
# 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"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# 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" "$@"
|
||||
@@ -0,0 +1,93 @@
|
||||
@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
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@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=.
|
||||
@rem This is normally unused
|
||||
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% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1,12 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven {
|
||||
name = "Fabric"
|
||||
url = "https://maven.fabricmc.net/"
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "magiccarpet"
|
||||
@@ -0,0 +1,11 @@
|
||||
package fr.koka99cab.magiccarpet.client;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import fr.koka99cab.magiccarpet.MagicCarpetMod;
|
||||
|
||||
public class MagicCarpetClient implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
MagicCarpetMod.LOGGER.info("MagicCarpet client initialise.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package fr.koka99cab.magiccarpet;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class MagicCarpetMod implements ModInitializer {
|
||||
public static final String MOD_ID = "magiccarpet";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
LOGGER.info("MagicCarpet charge pour Minecraft 26.1.2.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"modmenu.nameTranslation.magiccarpet": "MagicCarpet",
|
||||
"modmenu.descriptionTranslation.magiccarpet": "Example Fabric mod for the Hello World mod collection."
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"modmenu.nameTranslation.magiccarpet": "MagicCarpet",
|
||||
"modmenu.descriptionTranslation.magiccarpet": "Mod Fabric exemple pour la collection de mods Hello World."
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "magiccarpet",
|
||||
"version": "${version}",
|
||||
"name": "MagicCarpet",
|
||||
"description": "Mod Fabric exemple pour la collection de mods Hello World.",
|
||||
"authors": [
|
||||
"KOKA99CAB"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"fr.koka99cab.magiccarpet.MagicCarpetMod"
|
||||
],
|
||||
"client": [
|
||||
"fr.koka99cab.magiccarpet.client.MagicCarpetClient"
|
||||
]
|
||||
},
|
||||
"depends": {
|
||||
"fabricloader": ">=0.19.2",
|
||||
"minecraft": "~26.1.2",
|
||||
"java": ">=25",
|
||||
"fabric-api": "*"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
# Gradle
|
||||
.gradle/
|
||||
build/
|
||||
out/
|
||||
classes/
|
||||
|
||||
# Eclipse
|
||||
*.launch
|
||||
|
||||
# IntelliJ IDEA
|
||||
.idea/
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
# VS Code
|
||||
.settings/
|
||||
.vscode/
|
||||
bin/
|
||||
.classpath
|
||||
.project
|
||||
|
||||
# macOS
|
||||
*.DS_Store
|
||||
|
||||
# Fabric
|
||||
run/
|
||||
|
||||
# Java
|
||||
.jdk/
|
||||
hs_err_*.log
|
||||
replay_*.log
|
||||
*.hprof
|
||||
*.jfr
|
||||
@@ -0,0 +1,67 @@
|
||||
plugins {
|
||||
id "net.fabricmc.fabric-loom" version "${loom_version}"
|
||||
id "maven-publish"
|
||||
}
|
||||
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
|
||||
repositories {
|
||||
}
|
||||
|
||||
loom {
|
||||
splitEnvironmentSourceSets()
|
||||
|
||||
mods {
|
||||
"spiderman" {
|
||||
sourceSet sourceSets.main
|
||||
sourceSet sourceSets.client
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
implementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
|
||||
}
|
||||
|
||||
processResources {
|
||||
def version = project.version
|
||||
inputs.property "version", version
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": version
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.release = 25
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_25
|
||||
targetCompatibility = JavaVersion.VERSION_25
|
||||
}
|
||||
|
||||
jar {
|
||||
def projectName = project.name
|
||||
inputs.property "projectName", projectName
|
||||
|
||||
from("../../license.txt") {
|
||||
rename { "${it}_${projectName}" }
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create("mavenJava", MavenPublication) {
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
# Done to increase the memory available to Gradle.
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
org.gradle.parallel=true
|
||||
|
||||
# IntelliJ IDEA is not yet fully compatible with configuration cache:
|
||||
# https://github.com/FabricMC/fabric-loom/issues/1349
|
||||
org.gradle.configuration-cache=false
|
||||
|
||||
# Fabric properties
|
||||
# Check current versions on https://fabricmc.net/develop
|
||||
minecraft_version=26.1.2
|
||||
loader_version=0.19.2
|
||||
loom_version=1.16-SNAPSHOT
|
||||
|
||||
# Mod properties
|
||||
mod_version=1.0.0
|
||||
maven_group=fr.koka99cab
|
||||
archives_base_name=spiderman
|
||||
|
||||
# Dependencies
|
||||
fabric_api_version=0.148.0+26.1.2
|
||||
@@ -0,0 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,253 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015 the original 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.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# 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/2d6327017519d23b96af35865dc997fcb544fb40/platforms/jvm/plugins-application/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
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
if [ -z "$JAVA_HOME" ] && [ -x "$APP_HOME/.jdk/current/bin/java" ] ; then
|
||||
JAVA_HOME=$APP_HOME/.jdk/current
|
||||
export JAVA_HOME
|
||||
fi
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# 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 ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
# 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
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
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
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -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
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -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
|
||||
fi
|
||||
|
||||
|
||||
# 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"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# 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" "$@"
|
||||
@@ -0,0 +1,93 @@
|
||||
@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
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@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=.
|
||||
@rem This is normally unused
|
||||
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% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1,12 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven {
|
||||
name = "Fabric"
|
||||
url = "https://maven.fabricmc.net/"
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "spiderman"
|
||||
@@ -0,0 +1,17 @@
|
||||
package fr.koka99cab.spiderman.client;
|
||||
|
||||
import fr.koka99cab.spiderman.SpidermanMod;
|
||||
import fr.koka99cab.spiderman.client.item.GrapplingRodCastProperty;
|
||||
import fr.koka99cab.spiderman.client.render.GrapplingHookRenderer;
|
||||
import fr.koka99cab.spiderman.mixin.client.ConditionalItemModelPropertiesAccessor;
|
||||
import fr.koka99cab.spiderman.registry.SpidermanEntityTypes;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
|
||||
|
||||
public class SpidermanClient implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
ConditionalItemModelPropertiesAccessor.spiderman$getIdMapper().put(SpidermanMod.id("grappling_rod/cast"), GrapplingRodCastProperty.MAP_CODEC);
|
||||
EntityRendererRegistry.register(SpidermanEntityTypes.GRAPPLING_HOOK, GrapplingHookRenderer::new);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package fr.koka99cab.spiderman.client.item;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import fr.koka99cab.spiderman.entity.GrapplingHookEntity;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.item.properties.conditional.ConditionalItemModelProperty;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public record GrapplingRodCastProperty() implements ConditionalItemModelProperty {
|
||||
public static final MapCodec<GrapplingRodCastProperty> MAP_CODEC = MapCodec.unit(new GrapplingRodCastProperty());
|
||||
|
||||
@Override
|
||||
public boolean get(ItemStack stack, ClientLevel level, LivingEntity entity, int seed, ItemDisplayContext displayContext) {
|
||||
if (!(entity instanceof Player player) || !isHeldStack(player, stack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Entity renderedEntity : level.entitiesForRendering()) {
|
||||
if (renderedEntity instanceof GrapplingHookEntity hook && hook.getOwner() == player) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapCodec<GrapplingRodCastProperty> type() {
|
||||
return MAP_CODEC;
|
||||
}
|
||||
|
||||
private static boolean isHeldStack(Player player, ItemStack stack) {
|
||||
return player.getMainHandItem() == stack || player.getOffhandItem() == stack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package fr.koka99cab.spiderman.client.render;
|
||||
|
||||
import fr.koka99cab.spiderman.entity.GrapplingHookEntity;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.client.renderer.entity.ThrownItemRenderer;
|
||||
import net.minecraft.client.renderer.entity.state.EntityRenderState.LeashState;
|
||||
import net.minecraft.client.renderer.entity.state.ThrownItemRenderState;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class GrapplingHookRenderer extends ThrownItemRenderer<GrapplingHookEntity> {
|
||||
private static final Vec3 HOOK_LEASH_OFFSET = new Vec3(0.0D, 0.04D, 0.0D);
|
||||
|
||||
public GrapplingHookRenderer(EntityRendererProvider.Context context) {
|
||||
super(context, 0.9F, false);
|
||||
this.shadowRadius = 0.08F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extractRenderState(GrapplingHookEntity hook, ThrownItemRenderState state, float partialTick) {
|
||||
super.extractRenderState(hook, state, partialTick);
|
||||
Entity owner = hook.getOwner();
|
||||
if (owner == null) {
|
||||
state.leashStates = null;
|
||||
return;
|
||||
}
|
||||
|
||||
Vec3 hookPosition = hook.getPosition(partialTick);
|
||||
Vec3 leashStart = hookPosition.add(HOOK_LEASH_OFFSET);
|
||||
Vec3 leashEnd = owner.getRopeHoldPosition(partialTick);
|
||||
LeashState leashState = new LeashState();
|
||||
|
||||
leashState.offset = HOOK_LEASH_OFFSET;
|
||||
leashState.start = leashStart;
|
||||
leashState.end = leashEnd;
|
||||
leashState.slack = false;
|
||||
fillLight(hook.level(), leashState, leashStart, leashEnd);
|
||||
state.leashStates = List.of(leashState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean affectedByCulling(GrapplingHookEntity hook) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void fillLight(Level level, LeashState leashState, Vec3 leashStart, Vec3 leashEnd) {
|
||||
BlockPos start = BlockPos.containing(leashStart);
|
||||
BlockPos end = BlockPos.containing(leashEnd);
|
||||
|
||||
leashState.startBlockLight = level.getBrightness(LightLayer.BLOCK, start);
|
||||
leashState.endBlockLight = level.getBrightness(LightLayer.BLOCK, end);
|
||||
leashState.startSkyLight = level.getBrightness(LightLayer.SKY, start);
|
||||
leashState.endSkyLight = level.getBrightness(LightLayer.SKY, end);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package fr.koka99cab.spiderman.mixin.client;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import net.minecraft.client.renderer.item.properties.conditional.ConditionalItemModelProperties;
|
||||
import net.minecraft.client.renderer.item.properties.conditional.ConditionalItemModelProperty;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.util.ExtraCodecs;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(ConditionalItemModelProperties.class)
|
||||
public interface ConditionalItemModelPropertiesAccessor {
|
||||
@Accessor("ID_MAPPER")
|
||||
static ExtraCodecs.LateBoundIdMapper<Identifier, MapCodec<? extends ConditionalItemModelProperty>> spiderman$getIdMapper() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package fr.koka99cab.spiderman;
|
||||
|
||||
import fr.koka99cab.spiderman.grapple.GrappleController;
|
||||
import fr.koka99cab.spiderman.registry.SpidermanEntityTypes;
|
||||
import fr.koka99cab.spiderman.registry.SpidermanItems;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SpidermanMod implements ModInitializer {
|
||||
public static final String MOD_ID = "spiderman";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
SpidermanEntityTypes.register();
|
||||
SpidermanItems.register();
|
||||
GrappleController.register();
|
||||
LOGGER.info("Spiderman charge: le grappin est pret.");
|
||||
}
|
||||
|
||||
public static Identifier id(String path) {
|
||||
return Identifier.fromNamespaceAndPath(MOD_ID, path);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package fr.koka99cab.spiderman.entity;
|
||||
|
||||
import fr.koka99cab.spiderman.grapple.GrappleController;
|
||||
import fr.koka99cab.spiderman.registry.SpidermanEntityTypes;
|
||||
import fr.koka99cab.spiderman.registry.SpidermanItems;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MoverType;
|
||||
import net.minecraft.world.entity.projectile.ItemSupplier;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.storage.ValueInput;
|
||||
import net.minecraft.world.level.storage.ValueOutput;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class GrapplingHookEntity extends Projectile implements ItemSupplier {
|
||||
private static final EntityDataAccessor<Boolean> ANCHORED = SynchedEntityData.defineId(GrapplingHookEntity.class, EntityDataSerializers.BOOLEAN);
|
||||
private static final double GRAVITY = 0.035D;
|
||||
private static final double DRAG = 0.985D;
|
||||
private static final double MAX_FLIGHT_DISTANCE = 72.0D;
|
||||
private static final int MAX_FLIGHT_TICKS = 80;
|
||||
|
||||
private double traveledDistance;
|
||||
|
||||
public GrapplingHookEntity(EntityType<? extends GrapplingHookEntity> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
this.noPhysics = true;
|
||||
this.setNoGravity(true);
|
||||
}
|
||||
|
||||
public GrapplingHookEntity(Level level, Entity owner, Vec3 startPosition, Vec3 velocity) {
|
||||
this(SpidermanEntityTypes.GRAPPLING_HOOK, level);
|
||||
this.setOwner(owner);
|
||||
this.snapTo(startPosition.x, startPosition.y, startPosition.z);
|
||||
this.setDeltaMovement(velocity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void defineSynchedData(SynchedEntityData.Builder builder) {
|
||||
builder.define(ANCHORED, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
this.noPhysics = true;
|
||||
this.setNoGravity(true);
|
||||
|
||||
if (!this.level().isClientSide() && (this.getOwner() == null || !this.getOwner().isAlive())) {
|
||||
this.discard();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isAnchored()) {
|
||||
this.setDeltaMovement(Vec3.ZERO);
|
||||
return;
|
||||
}
|
||||
|
||||
Vec3 velocity = this.getDeltaMovement();
|
||||
Vec3 from = this.position();
|
||||
Vec3 to = from.add(velocity);
|
||||
BlockHitResult hitResult = this.level().clip(new ClipContext(from, to, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this));
|
||||
|
||||
if (hitResult.getType() == HitResult.Type.BLOCK) {
|
||||
this.anchor(hitResult);
|
||||
if (!this.level().isClientSide() && this.getOwner() instanceof ServerPlayer player) {
|
||||
GrappleController.attach(player, this, hitResult);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this.move(MoverType.SELF, velocity);
|
||||
this.traveledDistance += velocity.length();
|
||||
this.setDeltaMovement(velocity.scale(DRAG).add(0.0D, -GRAVITY, 0.0D));
|
||||
|
||||
if (!this.level().isClientSide() && this.getOwner() instanceof ServerPlayer player && (this.traveledDistance > MAX_FLIGHT_DISTANCE || this.tickCount > MAX_FLIGHT_TICKS)) {
|
||||
GrappleController.expire(player, this);
|
||||
}
|
||||
}
|
||||
|
||||
public void anchor(BlockHitResult hitResult) {
|
||||
this.entityData.set(ANCHORED, true);
|
||||
this.noPhysics = true;
|
||||
this.setNoGravity(true);
|
||||
this.setDeltaMovement(Vec3.ZERO);
|
||||
Vec3 hitLocation = hitResult.getLocation();
|
||||
this.snapTo(hitLocation.x, hitLocation.y, hitLocation.z);
|
||||
}
|
||||
|
||||
public boolean isAnchored() {
|
||||
return this.entityData.get(ANCHORED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem() {
|
||||
return new ItemStack(SpidermanItems.GRAPPLING_HAND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPickable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addAdditionalSaveData(ValueOutput output) {
|
||||
super.addAdditionalSaveData(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readAdditionalSaveData(ValueInput input) {
|
||||
super.readAdditionalSaveData(input);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,427 @@
|
||||
package fr.koka99cab.spiderman.grapple;
|
||||
|
||||
import fr.koka99cab.spiderman.entity.GrapplingHookEntity;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Input;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public final class GrappleController {
|
||||
private static final Map<UUID, GrappleSession> ACTIVE = new HashMap<>();
|
||||
|
||||
private static final double CAST_SPEED = 2.35D;
|
||||
private static final double CAST_PLAYER_VELOCITY_FACTOR = 0.9D;
|
||||
private static final double MAX_INITIAL_HOOK_SPEED = 4.25D;
|
||||
private static final double CAST_FORWARD_OFFSET = 0.65D;
|
||||
private static final double CAST_DOWN_OFFSET = 0.18D;
|
||||
private static final double INITIAL_SLACK = 5.0D;
|
||||
private static final double HELD_ROPE_SLACK = 0.02D;
|
||||
private static final double ROPE_TAUT_TOLERANCE = 0.12D;
|
||||
private static final double MIN_ROPE_LENGTH = 1.0D;
|
||||
private static final double MAX_EXTRA_ROPE = 64.0D;
|
||||
private static final double MAX_SESSION_DISTANCE = 152.0D;
|
||||
private static final double SWING_PUMP = 0.055D;
|
||||
private static final double REEL_IN_SPEED = 0.18D;
|
||||
private static final double STUCK_REEL_IN_SPEED = 0.24D;
|
||||
private static final double STUCK_SPEED_SQ = 0.018D;
|
||||
private static final int STUCK_REEL_DELAY = 8;
|
||||
private static final double PENDULUM_GRAVITY = 0.08D;
|
||||
private static final double SWING_DAMPING = 0.998D;
|
||||
private static final double FALL_INERTIA_TO_SWING = 1.22D;
|
||||
private static final double CATCH_LIFT_FROM_SPEED = 0.18D;
|
||||
private static final double CATCH_LIFT_FROM_FALL = 0.22D;
|
||||
private static final double MAX_CATCH_LIFT = 0.72D;
|
||||
private static final double MAX_SWING_SPEED = 6.5D;
|
||||
private static final double PLAYER_CENTER_FACTOR = 0.5D;
|
||||
private static final double RELEASE_BOOST_SPEED = 0.85D;
|
||||
private static final double RELEASE_BOOST_FROM_SWING_SPEED = 0.12D;
|
||||
private static final double MAX_RELEASE_SPEED_BOOST = 0.65D;
|
||||
private static final double MAX_RELEASE_SPEED = 8.0D;
|
||||
private static final double MIN_RELEASE_SWING_SPEED_SQ = 0.05D;
|
||||
|
||||
private GrappleController() {
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
ServerTickEvents.END_SERVER_TICK.register(server -> {
|
||||
Set<UUID> onlinePlayers = new HashSet<>();
|
||||
|
||||
for (ServerPlayer player : server.getPlayerList().getPlayers()) {
|
||||
onlinePlayers.add(player.getUUID());
|
||||
tick(player);
|
||||
}
|
||||
|
||||
ACTIVE.keySet().removeIf(uuid -> !onlinePlayers.contains(uuid));
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean start(ServerLevel level, ServerPlayer player, InteractionHand hand, ItemStack stack) {
|
||||
GrappleSession existingSession = ACTIVE.get(player.getUUID());
|
||||
if (existingSession != null) {
|
||||
stop(player, true);
|
||||
playRetrieveSound(level, player);
|
||||
return true;
|
||||
}
|
||||
|
||||
Vec3 look = player.calculateViewVector(player.getXRot(), player.getYRot()).normalize();
|
||||
Vec3 startPosition = player.getEyePosition().add(look.scale(CAST_FORWARD_OFFSET)).add(0.0D, -CAST_DOWN_OFFSET, 0.0D);
|
||||
Vec3 velocity = initialHookVelocity(player, look);
|
||||
GrapplingHookEntity hook = new GrapplingHookEntity(level, player, startPosition, velocity);
|
||||
|
||||
level.addFreshEntity(hook);
|
||||
ACTIVE.put(player.getUUID(), new GrappleSession(level.dimension(), startPosition, BlockPos.containing(startPosition), hook.getId()));
|
||||
|
||||
stack.hurtAndBreak(1, player, hand);
|
||||
level.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.FISHING_BOBBER_THROW, SoundSource.PLAYERS, 0.8F, 1.15F);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void attach(ServerPlayer player, GrapplingHookEntity hook, BlockHitResult hitResult) {
|
||||
GrappleSession session = ACTIVE.get(player.getUUID());
|
||||
if (session == null || session.visualHookId != hook.getId()) {
|
||||
hook.discard();
|
||||
return;
|
||||
}
|
||||
|
||||
Vec3 anchorPosition = hitResult.getLocation();
|
||||
Vec3 playerCenter = playerCenter(player);
|
||||
|
||||
session.anchored = true;
|
||||
session.anchorPosition = anchorPosition;
|
||||
session.anchorBlockPos = hitResult.getBlockPos();
|
||||
session.ropeLength = playerCenter.distanceTo(anchorPosition) + INITIAL_SLACK;
|
||||
session.maxRopeLength = session.ropeLength + MAX_EXTRA_ROPE;
|
||||
session.swingVelocity = player.getDeltaMovement();
|
||||
session.held = false;
|
||||
session.ropeTaut = false;
|
||||
session.manualReel = false;
|
||||
session.jumpHeldLastTick = false;
|
||||
session.stillTicks = 0;
|
||||
|
||||
levelSound(player, SoundEvents.LEAD_TIED, 0.8F, 1.1F);
|
||||
}
|
||||
|
||||
public static void expire(ServerPlayer player, GrapplingHookEntity hook) {
|
||||
GrappleSession session = ACTIVE.get(player.getUUID());
|
||||
if (session != null && session.visualHookId == hook.getId() && !session.anchored) {
|
||||
stop(player);
|
||||
playMissSound((ServerLevel) player.level(), player);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean stop(ServerPlayer player) {
|
||||
return stop(player, false);
|
||||
}
|
||||
|
||||
private static boolean stop(ServerPlayer player, boolean boostIfJumping) {
|
||||
GrappleSession session = ACTIVE.remove(player.getUUID());
|
||||
if (session == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (boostIfJumping) {
|
||||
applyReleaseBoost(player, session);
|
||||
}
|
||||
|
||||
discardVisualHook((ServerLevel) player.level(), session);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void tick(ServerPlayer player) {
|
||||
GrappleSession session = ACTIVE.get(player.getUUID());
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!canKeepGrappling(player, session)) {
|
||||
stop(player);
|
||||
return;
|
||||
}
|
||||
|
||||
Entity visualHook = ((ServerLevel) player.level()).getEntity(session.visualHookId);
|
||||
if (!(visualHook instanceof GrapplingHookEntity hook)) {
|
||||
ACTIVE.remove(player.getUUID());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!session.anchored) {
|
||||
tickFlyingHook(player, session, hook);
|
||||
return;
|
||||
}
|
||||
|
||||
Vec3 center = playerCenter(player);
|
||||
double distance = center.distanceTo(session.anchorPosition);
|
||||
if (distance > MAX_SESSION_DISTANCE || distance < 0.001D) {
|
||||
stop(player);
|
||||
return;
|
||||
}
|
||||
|
||||
Input input = player.getLastClientInput();
|
||||
updateReelState(session, input);
|
||||
if (!shouldTensionRope(session, distance)) {
|
||||
session.held = false;
|
||||
session.ropeTaut = false;
|
||||
session.swingVelocity = player.getDeltaMovement();
|
||||
session.jumpHeldLastTick = session.manualReel;
|
||||
return;
|
||||
}
|
||||
|
||||
boolean firstCatch = tensionRope(session, distance) || !session.ropeTaut;
|
||||
reelInIfRequested(session);
|
||||
simulatePendulum(player, session, center, firstCatch);
|
||||
session.ropeTaut = true;
|
||||
session.jumpHeldLastTick = session.manualReel;
|
||||
|
||||
player.resetFallDistance();
|
||||
}
|
||||
|
||||
private static void tickFlyingHook(ServerPlayer player, GrappleSession session, GrapplingHookEntity hook) {
|
||||
session.anchorPosition = hook.position();
|
||||
session.anchorBlockPos = hook.blockPosition();
|
||||
session.swingVelocity = player.getDeltaMovement();
|
||||
}
|
||||
|
||||
private static void updateReelState(GrappleSession session, Input input) {
|
||||
if (session.swingVelocity.lengthSqr() < STUCK_SPEED_SQ) {
|
||||
session.stillTicks++;
|
||||
} else {
|
||||
session.stillTicks = 0;
|
||||
}
|
||||
|
||||
session.manualReel = input.jump();
|
||||
}
|
||||
|
||||
private static boolean shouldTensionRope(GrappleSession session, double distance) {
|
||||
return session.manualReel || session.ropeTaut || distance >= session.ropeLength - ROPE_TAUT_TOLERANCE;
|
||||
}
|
||||
|
||||
private static boolean tensionRope(GrappleSession session, double distance) {
|
||||
boolean firstHold = session.manualReel && !session.jumpHeldLastTick;
|
||||
if (firstHold || (session.manualReel && !session.held)) {
|
||||
double heldLength = Math.max(MIN_ROPE_LENGTH, distance + HELD_ROPE_SLACK);
|
||||
session.ropeLength = Math.min(session.ropeLength, heldLength);
|
||||
}
|
||||
|
||||
session.held = session.manualReel;
|
||||
return firstHold;
|
||||
}
|
||||
|
||||
private static void reelInIfRequested(GrappleSession session) {
|
||||
if (session.manualReel) {
|
||||
double reelSpeed = session.stillTicks >= STUCK_REEL_DELAY ? STUCK_REEL_IN_SPEED : REEL_IN_SPEED;
|
||||
session.ropeLength = Math.max(MIN_ROPE_LENGTH, session.ropeLength - reelSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
private static void simulatePendulum(ServerPlayer player, GrappleSession session, Vec3 center, boolean firstCatch) {
|
||||
Vec3 radial = center.subtract(session.anchorPosition).normalize();
|
||||
Vec3 currentCenter = session.anchorPosition.add(radial.scale(session.ropeLength));
|
||||
Vec3 swingVelocity = firstCatch ? preservedCatchVelocity(player, radial) : projectOntoSwingPlane(session.swingVelocity, radial);
|
||||
|
||||
Vec3 gravity = new Vec3(0.0D, -PENDULUM_GRAVITY, 0.0D);
|
||||
swingVelocity = swingVelocity.add(projectOntoSwingPlane(gravity, radial));
|
||||
swingVelocity = swingVelocity.add(swingInput(player, radial)).scale(SWING_DAMPING);
|
||||
swingVelocity = limitSpeed(swingVelocity);
|
||||
|
||||
Vec3 nextCenter = currentCenter.add(swingVelocity);
|
||||
Vec3 nextRadial = nextCenter.subtract(session.anchorPosition);
|
||||
if (nextRadial.lengthSqr() < 0.001D) {
|
||||
nextRadial = radial;
|
||||
} else {
|
||||
nextRadial = nextRadial.normalize();
|
||||
}
|
||||
|
||||
Vec3 constrainedCenter = session.anchorPosition.add(nextRadial.scale(session.ropeLength));
|
||||
Vec3 actualVelocity = limitSpeed(constrainedCenter.subtract(currentCenter));
|
||||
double centerOffset = player.getBbHeight() * PLAYER_CENTER_FACTOR;
|
||||
|
||||
session.swingVelocity = actualVelocity;
|
||||
player.snapTo(constrainedCenter.x, constrainedCenter.y - centerOffset, constrainedCenter.z);
|
||||
player.setDeltaMovement(actualVelocity);
|
||||
player.hurtMarked = true;
|
||||
}
|
||||
|
||||
private static Vec3 preservedCatchVelocity(ServerPlayer player, Vec3 radial) {
|
||||
Vec3 incomingVelocity = player.getDeltaMovement();
|
||||
Vec3 tangentVelocity = projectOntoSwingPlane(incomingVelocity, radial).add(catchLift(radial, incomingVelocity));
|
||||
double fallSpeed = Math.max(0.0D, -incomingVelocity.y);
|
||||
double outwardSpeed = Math.max(0.0D, incomingVelocity.dot(radial));
|
||||
double targetSwingSpeed = Math.max(fallSpeed, outwardSpeed) * FALL_INERTIA_TO_SWING;
|
||||
|
||||
if (targetSwingSpeed <= tangentVelocity.length()) {
|
||||
return tangentVelocity;
|
||||
}
|
||||
|
||||
Vec3 swingDirection = catchSwingDirection(player, radial, tangentVelocity);
|
||||
return swingDirection.scale(targetSwingSpeed);
|
||||
}
|
||||
|
||||
private static Vec3 catchLift(Vec3 radial, Vec3 incomingVelocity) {
|
||||
double speed = incomingVelocity.length();
|
||||
if (speed < 0.08D) {
|
||||
return Vec3.ZERO;
|
||||
}
|
||||
|
||||
Vec3 upwardTangent = projectOntoSwingPlane(new Vec3(0.0D, 1.0D, 0.0D), radial);
|
||||
if (upwardTangent.lengthSqr() < 0.001D) {
|
||||
return Vec3.ZERO;
|
||||
}
|
||||
|
||||
double fallSpeed = Math.max(0.0D, -incomingVelocity.y);
|
||||
double lift = Math.min(MAX_CATCH_LIFT, speed * CATCH_LIFT_FROM_SPEED + fallSpeed * CATCH_LIFT_FROM_FALL);
|
||||
return upwardTangent.normalize().scale(lift);
|
||||
}
|
||||
|
||||
private static Vec3 swingInput(ServerPlayer player, Vec3 radial) {
|
||||
Vec3 tangentIntent = projectOntoSwingPlane(player.getLastClientMoveIntent(), radial);
|
||||
if (tangentIntent.lengthSqr() < 0.001D) {
|
||||
return Vec3.ZERO;
|
||||
}
|
||||
|
||||
return tangentIntent.normalize().scale(SWING_PUMP);
|
||||
}
|
||||
|
||||
private static Vec3 catchSwingDirection(ServerPlayer player, Vec3 radial, Vec3 tangentVelocity) {
|
||||
if (tangentVelocity.lengthSqr() > 0.001D) {
|
||||
return tangentVelocity.normalize();
|
||||
}
|
||||
|
||||
Vec3 moveIntent = player.getLastClientMoveIntent();
|
||||
Vec3 tangentIntent = projectOntoSwingPlane(moveIntent, radial);
|
||||
if (tangentIntent.lengthSqr() > 0.001D) {
|
||||
return tangentIntent.normalize();
|
||||
}
|
||||
|
||||
Vec3 look = player.calculateViewVector(player.getXRot(), player.getYRot());
|
||||
Vec3 tangentLook = projectOntoSwingPlane(look, radial);
|
||||
if (tangentLook.lengthSqr() > 0.001D) {
|
||||
return tangentLook.normalize();
|
||||
}
|
||||
|
||||
Vec3 horizontalFallback = new Vec3(-radial.z, 0.0D, radial.x);
|
||||
if (horizontalFallback.lengthSqr() > 0.001D) {
|
||||
return horizontalFallback.normalize();
|
||||
}
|
||||
|
||||
return new Vec3(1.0D, 0.0D, 0.0D);
|
||||
}
|
||||
|
||||
private static Vec3 projectOntoSwingPlane(Vec3 direction, Vec3 radial) {
|
||||
return direction.subtract(radial.scale(direction.dot(radial)));
|
||||
}
|
||||
|
||||
private static Vec3 limitSpeed(Vec3 velocity) {
|
||||
double speed = velocity.length();
|
||||
if (speed <= MAX_SWING_SPEED) {
|
||||
return velocity;
|
||||
}
|
||||
|
||||
return velocity.scale(MAX_SWING_SPEED / speed);
|
||||
}
|
||||
|
||||
private static void applyReleaseBoost(ServerPlayer player, GrappleSession session) {
|
||||
if (!player.getLastClientInput().sprint() || !canBoostOnRelease(session)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Vec3 currentVelocity = player.getDeltaMovement();
|
||||
Vec3 baseVelocity = currentVelocity.lengthSqr() >= session.swingVelocity.lengthSqr() ? currentVelocity : session.swingVelocity;
|
||||
Vec3 look = player.calculateViewVector(player.getXRot(), player.getYRot()).normalize();
|
||||
double baseSpeed = baseVelocity.length();
|
||||
double boostSpeed = RELEASE_BOOST_SPEED + Math.min(MAX_RELEASE_SPEED_BOOST, baseSpeed * RELEASE_BOOST_FROM_SWING_SPEED);
|
||||
Vec3 boostedVelocity = softLimitReleaseSpeed(baseVelocity.add(look.scale(boostSpeed)), baseSpeed + boostSpeed);
|
||||
|
||||
player.setDeltaMovement(boostedVelocity);
|
||||
player.hurtMarked = true;
|
||||
}
|
||||
|
||||
private static boolean canBoostOnRelease(GrappleSession session) {
|
||||
return session.ropeTaut || session.swingVelocity.lengthSqr() >= MIN_RELEASE_SWING_SPEED_SQ;
|
||||
}
|
||||
|
||||
private static Vec3 softLimitReleaseSpeed(Vec3 velocity, double carriedSpeed) {
|
||||
double speed = velocity.length();
|
||||
double maxAllowedSpeed = Math.max(MAX_RELEASE_SPEED, carriedSpeed);
|
||||
if (speed <= maxAllowedSpeed) {
|
||||
return velocity;
|
||||
}
|
||||
|
||||
return velocity.scale(maxAllowedSpeed / speed);
|
||||
}
|
||||
|
||||
private static boolean canKeepGrappling(ServerPlayer player, GrappleSession session) {
|
||||
return player.isAlive()
|
||||
&& player.level().dimension() == session.dimension;
|
||||
}
|
||||
|
||||
private static Vec3 playerCenter(ServerPlayer player) {
|
||||
return player.position().add(0.0D, player.getBbHeight() * PLAYER_CENTER_FACTOR, 0.0D);
|
||||
}
|
||||
|
||||
private static Vec3 initialHookVelocity(ServerPlayer player, Vec3 look) {
|
||||
Vec3 velocity = look.scale(CAST_SPEED).add(player.getDeltaMovement().scale(CAST_PLAYER_VELOCITY_FACTOR));
|
||||
double speed = velocity.length();
|
||||
if (speed <= MAX_INITIAL_HOOK_SPEED) {
|
||||
return velocity;
|
||||
}
|
||||
|
||||
return velocity.scale(MAX_INITIAL_HOOK_SPEED / speed);
|
||||
}
|
||||
|
||||
private static void discardVisualHook(ServerLevel level, GrappleSession session) {
|
||||
Entity entity = level.getEntity(session.visualHookId);
|
||||
if (entity instanceof GrapplingHookEntity) {
|
||||
entity.discard();
|
||||
}
|
||||
}
|
||||
|
||||
private static void playRetrieveSound(ServerLevel level, ServerPlayer player) {
|
||||
level.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.LEAD_UNTIED, SoundSource.PLAYERS, 0.9F, 1.0F);
|
||||
}
|
||||
|
||||
private static void playMissSound(ServerLevel level, ServerPlayer player) {
|
||||
level.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.LEAD_UNTIED, SoundSource.PLAYERS, 0.35F, 0.8F);
|
||||
}
|
||||
|
||||
private static void levelSound(ServerPlayer player, net.minecraft.sounds.SoundEvent soundEvent, float volume, float pitch) {
|
||||
player.level().playSound(null, player.getX(), player.getY(), player.getZ(), soundEvent, SoundSource.PLAYERS, volume, pitch);
|
||||
}
|
||||
|
||||
private static final class GrappleSession {
|
||||
private final ResourceKey<Level> dimension;
|
||||
private Vec3 anchorPosition;
|
||||
private BlockPos anchorBlockPos;
|
||||
private double maxRopeLength;
|
||||
private final int visualHookId;
|
||||
private double ropeLength;
|
||||
private Vec3 swingVelocity = Vec3.ZERO;
|
||||
private boolean anchored;
|
||||
private boolean held;
|
||||
private boolean ropeTaut;
|
||||
private boolean manualReel;
|
||||
private boolean jumpHeldLastTick;
|
||||
private int stillTicks;
|
||||
|
||||
private GrappleSession(ResourceKey<Level> dimension, Vec3 anchorPosition, BlockPos anchorBlockPos, int visualHookId) {
|
||||
this.dimension = dimension;
|
||||
this.anchorPosition = anchorPosition;
|
||||
this.anchorBlockPos = anchorBlockPos;
|
||||
this.visualHookId = visualHookId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package fr.koka99cab.spiderman.item;
|
||||
|
||||
import fr.koka99cab.spiderman.grapple.GrappleController;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
|
||||
public class GrapplingRodItem extends Item {
|
||||
public GrapplingRodItem(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(Level level, Player player, InteractionHand hand) {
|
||||
ItemStack stack = player.getItemInHand(hand);
|
||||
|
||||
if (level instanceof ServerLevel serverLevel && player instanceof ServerPlayer serverPlayer) {
|
||||
if (!GrappleController.start(serverLevel, serverPlayer, hand, stack)) {
|
||||
return InteractionResult.FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
player.awardStat(Stats.ITEM_USED.get(this));
|
||||
stack.causeUseVibration(player, GameEvent.ITEM_INTERACT_START);
|
||||
return InteractionResult.CONSUME;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package fr.koka99cab.spiderman.registry;
|
||||
|
||||
import fr.koka99cab.spiderman.SpidermanMod;
|
||||
import fr.koka99cab.spiderman.entity.GrapplingHookEntity;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
|
||||
public final class SpidermanEntityTypes {
|
||||
private static final ResourceKey<EntityType<?>> GRAPPLING_HOOK_KEY = ResourceKey.create(Registries.ENTITY_TYPE, SpidermanMod.id("grappling_hook"));
|
||||
|
||||
public static final EntityType<GrapplingHookEntity> GRAPPLING_HOOK = Registry.register(
|
||||
BuiltInRegistries.ENTITY_TYPE,
|
||||
GRAPPLING_HOOK_KEY,
|
||||
EntityType.Builder.<GrapplingHookEntity>of(GrapplingHookEntity::new, MobCategory.MISC)
|
||||
.sized(0.25F, 0.25F)
|
||||
.clientTrackingRange(96)
|
||||
.updateInterval(1)
|
||||
.noSave()
|
||||
.build(GRAPPLING_HOOK_KEY)
|
||||
);
|
||||
|
||||
private SpidermanEntityTypes() {
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
SpidermanMod.LOGGER.debug("Entites Spiderman enregistrees.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package fr.koka99cab.spiderman.registry;
|
||||
|
||||
import fr.koka99cab.spiderman.SpidermanMod;
|
||||
import fr.koka99cab.spiderman.item.GrapplingRodItem;
|
||||
import net.fabricmc.fabric.api.creativetab.v1.CreativeModeTabEvents;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
public final class SpidermanItems {
|
||||
private static final ResourceKey<Item> GRAPPLING_HAND_KEY = key("grappling_hand");
|
||||
private static final ResourceKey<Item> GRAPPLING_ROD_KEY = key("grappling_rod");
|
||||
private static final ResourceKey<CreativeModeTab> INGREDIENTS_TAB = vanillaTab("ingredients");
|
||||
private static final ResourceKey<CreativeModeTab> TOOLS_TAB = vanillaTab("tools_and_utilities");
|
||||
|
||||
public static final Item GRAPPLING_HAND = Registry.register(
|
||||
BuiltInRegistries.ITEM,
|
||||
GRAPPLING_HAND_KEY,
|
||||
new Item(new Item.Properties().setId(GRAPPLING_HAND_KEY))
|
||||
);
|
||||
|
||||
public static final Item GRAPPLING_ROD = Registry.register(
|
||||
BuiltInRegistries.ITEM,
|
||||
GRAPPLING_ROD_KEY,
|
||||
new GrapplingRodItem(new Item.Properties().durability(64).setId(GRAPPLING_ROD_KEY))
|
||||
);
|
||||
|
||||
private SpidermanItems() {
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
CreativeModeTabEvents.modifyOutputEvent(INGREDIENTS_TAB).register(entries -> entries.insertAfter(Items.TRIPWIRE_HOOK, GRAPPLING_HAND));
|
||||
CreativeModeTabEvents.modifyOutputEvent(TOOLS_TAB).register(entries -> entries.insertAfter(Items.FISHING_ROD, GRAPPLING_ROD));
|
||||
SpidermanMod.LOGGER.debug("Objets Spiderman enregistres.");
|
||||
}
|
||||
|
||||
private static ResourceKey<Item> key(String path) {
|
||||
return ResourceKey.create(Registries.ITEM, SpidermanMod.id(path));
|
||||
}
|
||||
|
||||
private static ResourceKey<CreativeModeTab> vanillaTab(String path) {
|
||||
return ResourceKey.create(Registries.CREATIVE_MODE_TAB, Identifier.withDefaultNamespace(path));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "spiderman:item/grappling_hand"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:condition",
|
||||
"property": "spiderman:grappling_rod/cast",
|
||||
"on_false": {
|
||||
"type": "minecraft:model",
|
||||
"model": "spiderman:item/grappling_rod"
|
||||
},
|
||||
"on_true": {
|
||||
"type": "minecraft:model",
|
||||
"model": "spiderman:item/grappling_rod_cast"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"item.spiderman.grappling_hand": "Grappling Hand",
|
||||
"item.spiderman.grappling_rod": "Grappling Rod"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"item.spiderman.grappling_hand": "Main du grappin",
|
||||
"item.spiderman.grappling_rod": "Canne-grappin"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "spiderman:item/grappling_hook"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/handheld_rod",
|
||||
"textures": {
|
||||
"layer0": "spiderman:item/grappling_rod"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/handheld_rod",
|
||||
"textures": {
|
||||
"layer0": "spiderman:item/grappling_rod_cast"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 141 B |
|
After Width: | Height: | Size: 184 B |
|
After Width: | Height: | Size: 149 B |
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"category": "equipment",
|
||||
"pattern": [
|
||||
" I ",
|
||||
"ISI",
|
||||
" I "
|
||||
],
|
||||
"key": {
|
||||
"I": "minecraft:iron_ingot",
|
||||
"S": "minecraft:string"
|
||||
},
|
||||
"result": {
|
||||
"id": "spiderman:grappling_hand"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"category": "equipment",
|
||||
"pattern": [
|
||||
" #",
|
||||
" #X",
|
||||
"# H"
|
||||
],
|
||||
"key": {
|
||||
"#": "minecraft:stick",
|
||||
"X": "minecraft:string",
|
||||
"H": "spiderman:grappling_hand"
|
||||
},
|
||||
"result": {
|
||||
"id": "spiderman:grappling_rod"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "spiderman",
|
||||
"version": "${version}",
|
||||
"name": "Spiderman",
|
||||
"description": "Transforme la canne a peche en grappin Fabric simple.",
|
||||
"authors": [
|
||||
"KOKA99CAB"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"fr.koka99cab.spiderman.SpidermanMod"
|
||||
],
|
||||
"client": [
|
||||
"fr.koka99cab.spiderman.client.SpidermanClient"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
{
|
||||
"config": "spiderman.client.mixins.json",
|
||||
"environment": "client"
|
||||
}
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.19.2",
|
||||
"minecraft": "~26.1.2",
|
||||
"java": ">=25",
|
||||
"fabric-api": "*"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "fr.koka99cab.spiderman.mixin.client",
|
||||
"compatibilityLevel": "JAVA_25",
|
||||
"client": [
|
||||
"ConditionalItemModelPropertiesAccessor"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||