Initial sanctuary sources

This commit is contained in:
cnstiout
2026-07-04 20:27:08 +02:00
commit c796a20321
1582 changed files with 253264 additions and 0 deletions
+34
View File
@@ -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
+168
View File
@@ -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.
+71
View File
@@ -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 {
}
}
Binary file not shown.

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
Binary file not shown.
@@ -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
+253
View File
@@ -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" "$@"
+93
View File
@@ -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));
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 KiB

Binary file not shown.

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"
}
}
Binary file not shown.

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
}
}