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
@@ -0,0 +1 @@
{"meta":{"format_version":"5.0","model_format":"modded_entity","box_uv":true},"name":"butterfly","model_identifier":"pipallon:butterfly","modded_entity_entity_class":"fr.koka99cab.pipallon.entity.ButterflyEntity","modded_entity_version":"1.17","modded_entity_flip_y":true,"visible_box":[1,1,0],"variable_placeholders":"","multi_file_ruleset":"","variable_placeholder_buttons":[],"timeline_setups":[],"unhandled_root_fields":{},"resolution":{"width":32,"height":32},"elements":[{"name":"body","box_uv":true,"render_order":"default","locked":false,"export":true,"scope":0,"allow_mirror_modeling":true,"from":[-1,0,-1],"to":[1,2,3],"autouv":0,"color":6,"origin":[0,1,1],"uv_offset":[0,16],"faces":{"north":{"uv":[4,20,6,22],"texture":0},"east":{"uv":[0,20,4,22],"texture":0},"south":{"uv":[10,20,12,22],"texture":0},"west":{"uv":[6,20,10,22],"texture":0},"up":{"uv":[6,20,4,16],"texture":0},"down":{"uv":[8,16,6,20],"texture":0}},"type":"cube","uuid":"f554aa52-27d3-c7d5-b995-c55ec3574fd8"},{"name":"left-wing","box_uv":true,"render_order":"default","locked":false,"export":true,"scope":0,"allow_mirror_modeling":true,"from":[-5,2,-3],"to":[0,2,5],"autouv":0,"color":9,"origin":[0,2,1],"faces":{"north":{"uv":[8,8,13,8],"texture":0},"east":{"uv":[0,8,8,8],"texture":0},"south":{"uv":[21,8,26,8],"texture":0},"west":{"uv":[13,8,21,8],"texture":0},"up":{"uv":[13,8,8,0],"texture":0},"down":{"uv":[18,0,13,8],"texture":0}},"type":"cube","uuid":"3936b2b0-a079-134c-3389-47f48c4da143","uv_offset":[0,0]},{"name":"right-wing","box_uv":true,"render_order":"default","locked":false,"export":true,"scope":0,"allow_mirror_modeling":true,"from":[0,2,-3],"to":[5,2,5],"autouv":0,"color":9,"origin":[0,2,1],"uv_offset":[0,8],"faces":{"north":{"uv":[8,16,13,16],"texture":0},"east":{"uv":[0,16,8,16],"texture":0},"south":{"uv":[21,16,26,16],"texture":0},"west":{"uv":[13,16,21,16],"texture":0},"up":{"uv":[13,16,8,8],"texture":0},"down":{"uv":[18,8,13,16],"texture":0}},"type":"cube","uuid":"81db23db-8756-ed17-c130-20cd284bf5a2"}],"groups":[],"outliner":[{"name":"body_root","uuid":"efdf16b6-0c8d-4f1f-8c34-45318f3cc5c9","origin":[0,1,1],"children":["f554aa52-27d3-c7d5-b995-c55ec3574fd8",{"name":"left_wing_pivot","uuid":"9b2a8291-298d-4fa9-9a2e-0d479b3e5f77","origin":[0,2,1],"children":["3936b2b0-a079-134c-3389-47f48c4da143"]},{"name":"right_wing_pivot","uuid":"bb610bbb-0b0a-48aa-9fd9-ded14661a20f","origin":[0,2,1],"children":["81db23db-8756-ed17-c130-20cd284bf5a2"]}]}],"textures":[{"name":"monarch.png","path":"../src/main/resources/assets/pipallon/textures/entity/butterfly/monarch.png","folder":"entity/butterfly","namespace":"pipallon","id":"0","group":"","scope":0,"width":32,"height":32,"uv_width":32,"uv_height":32,"particle":false,"use_as_default":true,"layers_enabled":false,"sync_to_project":"","file_format":"png","render_mode":"default","render_sides":"auto","wrap_mode":"limited","pbr_channel":"color","fps":7,"frame_time":1,"frame_order_type":"loop","frame_order":"","frame_interpolate":false,"visible":true,"internal":false,"saved":true,"uuid":"3ed85cd8-b795-8be9-c27a-ce37361a9bb2","relative_path":"../src/main/resources/assets/pipallon/textures/entity/butterfly/monarch.png"}]}
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

+67
View File
@@ -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 {
"pipallon" {
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 {
}
}
+21
View File
@@ -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=pipallon
# 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
Vendored Executable
+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
+12
View File
@@ -0,0 +1,12 @@
pluginManagement {
repositories {
maven {
name = "Fabric"
url = "https://maven.fabricmc.net/"
}
mavenCentral()
gradlePluginPortal()
}
}
rootProject.name = "pipallon"
@@ -0,0 +1,16 @@
package fr.koka99cab.pipallon.client;
import fr.koka99cab.pipallon.client.model.ButterflyModel;
import fr.koka99cab.pipallon.client.renderer.ButterflyRenderer;
import fr.koka99cab.pipallon.registry.ModEntityTypes;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.ModelLayerRegistry;
public final class PipallonClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
ModelLayerRegistry.registerModelLayer(ButterflyModel.LAYER_LOCATION, ButterflyModel::createBodyLayer);
EntityRendererRegistry.register(ModEntityTypes.BUTTERFLY, ButterflyRenderer::new);
}
}
@@ -0,0 +1,82 @@
package fr.koka99cab.pipallon.client.model;
import fr.koka99cab.pipallon.PipallonMod;
import fr.koka99cab.pipallon.client.renderer.ButterflyRenderState;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.CubeListBuilder;
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.PartDefinition;
import net.minecraft.util.Mth;
public final class ButterflyModel extends EntityModel<ButterflyRenderState> {
public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(PipallonMod.id("butterfly"), "main");
private final ModelPart bodyRoot;
private final ModelPart leftWingPivot;
private final ModelPart rightWingPivot;
public ButterflyModel(ModelPart root) {
super(root);
this.bodyRoot = root.getChild("body_root");
this.leftWingPivot = this.bodyRoot.getChild("left_wing_pivot");
this.rightWingPivot = this.bodyRoot.getChild("right_wing_pivot");
}
public static LayerDefinition createBodyLayer() {
MeshDefinition mesh = new MeshDefinition();
PartDefinition root = mesh.getRoot();
PartDefinition bodyRoot = root.addOrReplaceChild("body_root", CubeListBuilder.create(), PartPose.offset(0.0F, 23.0F, 1.0F));
bodyRoot.addOrReplaceChild(
"body",
CubeListBuilder.create()
.texOffs(0, 16)
.addBox(-1.0F, -1.0F, -2.0F, 2.0F, 2.0F, 4.0F),
PartPose.ZERO
);
PartDefinition leftWingPivot = bodyRoot.addOrReplaceChild("left_wing_pivot", CubeListBuilder.create(), PartPose.offset(0.0F, -1.0F, 0.0F));
leftWingPivot.addOrReplaceChild(
"left_wing",
CubeListBuilder.create()
.texOffs(0, 0)
.addBox(-5.0F, 0.0F, -4.0F, 5.0F, 0.0F, 8.0F),
PartPose.ZERO
);
PartDefinition rightWingPivot = bodyRoot.addOrReplaceChild("right_wing_pivot", CubeListBuilder.create(), PartPose.offset(0.0F, -1.0F, 0.0F));
rightWingPivot.addOrReplaceChild(
"right_wing",
CubeListBuilder.create()
.texOffs(0, 8)
.addBox(0.0F, 0.0F, -4.0F, 5.0F, 0.0F, 8.0F),
PartPose.ZERO
);
return LayerDefinition.create(mesh, 32, 32);
}
@Override
public void setupAnim(ButterflyRenderState state) {
super.setupAnim(state);
float speed = state.isAngry ? 1.9F : 1.15F;
float maxLift = state.isAngry ? 0.95F : 0.75F;
float wingLift = 0.12F + ((Mth.sin(state.ageInTicks * speed) + 1.0F) * 0.5F) * maxLift;
float idleTilt = Mth.sin(state.ageInTicks * 0.17F) * 0.08F;
this.bodyRoot.y = 23.0F + Mth.sin(state.ageInTicks * 0.21F) * 0.35F;
this.bodyRoot.z = 1.0F;
this.bodyRoot.xRot = state.isFlying ? idleTilt : 0.0F;
this.bodyRoot.yRot = Mth.sin(state.ageInTicks * 0.09F) * 0.06F;
this.leftWingPivot.xRot = 0.0F;
this.rightWingPivot.xRot = 0.0F;
this.leftWingPivot.yRot = 0.04F;
this.rightWingPivot.yRot = -0.04F;
this.leftWingPivot.zRot = wingLift;
this.rightWingPivot.zRot = -wingLift;
}
}
@@ -0,0 +1,10 @@
package fr.koka99cab.pipallon.client.renderer;
import fr.koka99cab.pipallon.entity.ButterflyVariant;
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
public final class ButterflyRenderState extends LivingEntityRenderState {
public ButterflyVariant variant = ButterflyVariant.MONARCH;
public boolean isAngry;
public boolean isFlying;
}
@@ -0,0 +1,47 @@
package fr.koka99cab.pipallon.client.renderer;
import fr.koka99cab.pipallon.PipallonMod;
import fr.koka99cab.pipallon.client.model.ButterflyModel;
import fr.koka99cab.pipallon.entity.ButterflyEntity;
import fr.koka99cab.pipallon.entity.ButterflyVariant;
import java.util.EnumMap;
import java.util.Map;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.resources.Identifier;
public final class ButterflyRenderer extends MobRenderer<ButterflyEntity, ButterflyRenderState, ButterflyModel> {
private static final Map<ButterflyVariant, Identifier> TEXTURES = createTextureMap();
public ButterflyRenderer(EntityRendererProvider.Context context) {
super(context, new ButterflyModel(context.bakeLayer(ButterflyModel.LAYER_LOCATION)), 0.18F);
}
@Override
public Identifier getTextureLocation(ButterflyRenderState state) {
return TEXTURES.getOrDefault(state.variant, TEXTURES.get(ButterflyVariant.MONARCH));
}
@Override
public ButterflyRenderState createRenderState() {
return new ButterflyRenderState();
}
@Override
public void extractRenderState(ButterflyEntity butterfly, ButterflyRenderState state, float partialTick) {
super.extractRenderState(butterfly, state, partialTick);
state.variant = butterfly.getVariant();
state.isAngry = butterfly.isAngryVisual();
state.isFlying = butterfly.isFlying();
}
private static Map<ButterflyVariant, Identifier> createTextureMap() {
EnumMap<ButterflyVariant, Identifier> textures = new EnumMap<>(ButterflyVariant.class);
for (ButterflyVariant variant : ButterflyVariant.values()) {
textures.put(variant, PipallonMod.id("textures/entity/butterfly/" + variant.textureName() + ".png"));
}
return textures;
}
}
@@ -0,0 +1,24 @@
package fr.koka99cab.pipallon;
import fr.koka99cab.pipallon.registry.ModEntityTypes;
import fr.koka99cab.pipallon.registry.ModItems;
import net.fabricmc.api.ModInitializer;
import net.minecraft.resources.Identifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class PipallonMod implements ModInitializer {
public static final String MOD_ID = "pipallon";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
@Override
public void onInitialize() {
ModEntityTypes.register();
ModItems.register();
LOGGER.info("Pipallon butterflies are taking off");
}
public static Identifier id(String path) {
return Identifier.fromNamespaceAndPath(MOD_ID, path);
}
}
@@ -0,0 +1,348 @@
package fr.koka99cab.pipallon.entity;
import fr.koka99cab.pipallon.registry.ModEntityTypes;
import java.util.EnumSet;
import net.minecraft.core.BlockPos;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.util.RandomSource;
import net.minecraft.util.TimeUtil;
import net.minecraft.util.valueproviders.UniformInt;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.AgeableMob;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityReference;
import net.minecraft.world.entity.EntitySpawnReason;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.NeutralMob;
import net.minecraft.world.entity.SpawnGroupData;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.FlyingMoveControl;
import net.minecraft.world.entity.ai.goal.FloatGoal;
import net.minecraft.world.entity.ai.goal.FollowParentGoal;
import net.minecraft.world.entity.ai.goal.Goal;
import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal;
import net.minecraft.world.entity.ai.goal.MeleeAttackGoal;
import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal;
import net.minecraft.world.entity.ai.goal.TemptGoal;
import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomFlyingGoal;
import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal;
import net.minecraft.world.entity.ai.goal.target.ResetUniversalAngerTargetGoal;
import net.minecraft.world.entity.ai.navigation.FlyingPathNavigation;
import net.minecraft.world.entity.ai.navigation.PathNavigation;
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.animal.FlyingAnimal;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.ValueInput;
import net.minecraft.world.level.storage.ValueOutput;
public final class ButterflyEntity extends Animal implements FlyingAnimal, NeutralMob {
private static final EntityDataAccessor<Integer> VARIANT = SynchedEntityData.defineId(ButterflyEntity.class, EntityDataSerializers.INT);
private static final EntityDataAccessor<Boolean> ANGRY = SynchedEntityData.defineId(ButterflyEntity.class, EntityDataSerializers.BOOLEAN);
private static final UniformInt PERSISTENT_ANGER_TIME = TimeUtil.rangeOfSeconds(18, 35);
private static final String VARIANT_KEY = "ButterflyVariant";
private long persistentAngerEndTime;
private EntityReference<LivingEntity> persistentAngerTarget;
public ButterflyEntity(EntityType<? extends ButterflyEntity> entityType, Level level) {
super(entityType, level);
this.moveControl = new FlyingMoveControl(this, 20, true);
this.setNoGravity(true);
}
public static AttributeSupplier.Builder createAttributes() {
return Animal.createAnimalAttributes()
.add(Attributes.MAX_HEALTH, 6.0D)
.add(Attributes.FOLLOW_RANGE, 20.0D)
.add(Attributes.MOVEMENT_SPEED, 0.22D)
.add(Attributes.FLYING_SPEED, 0.45D)
.add(Attributes.ATTACK_DAMAGE, 1.0D);
}
public static boolean canSpawn(EntityType<ButterflyEntity> entityType, ServerLevelAccessor level, EntitySpawnReason spawnReason, BlockPos blockPos, RandomSource random) {
return Animal.checkAnimalSpawnRules(entityType, level, spawnReason, blockPos, random);
}
@Override
protected void defineSynchedData(SynchedEntityData.Builder builder) {
super.defineSynchedData(builder);
builder.define(VARIANT, ButterflyVariant.MONARCH.id());
builder.define(ANGRY, false);
}
@Override
protected void registerGoals() {
this.goalSelector.addGoal(0, new FloatGoal(this));
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.25D, true));
this.goalSelector.addGoal(2, new HoverNearFlowersGoal(this));
this.goalSelector.addGoal(3, new TemptGoal(this, 1.05D, stack -> stack.is(ItemTags.FLOWERS), false));
this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.05D));
this.goalSelector.addGoal(5, new WaterAvoidingRandomFlyingGoal(this, 0.85D));
this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 6.0F));
this.goalSelector.addGoal(7, new RandomLookAroundGoal(this));
this.targetSelector.addGoal(0, new HurtByTargetGoal(this));
this.targetSelector.addGoal(1, new ResetUniversalAngerTargetGoal<>(this, true));
}
@Override
protected PathNavigation createNavigation(Level level) {
return new FlyingPathNavigation(this, level);
}
@Override
public SpawnGroupData finalizeSpawn(ServerLevelAccessor level, DifficultyInstance difficulty, EntitySpawnReason spawnReason, SpawnGroupData spawnGroupData) {
SpawnGroupData finalizedSpawn = super.finalizeSpawn(level, difficulty, spawnReason, spawnGroupData);
this.setVariant(ButterflyVariant.choose(this.random));
this.setNoGravity(true);
return finalizedSpawn;
}
@Override
protected void customServerAiStep(ServerLevel serverLevel) {
super.customServerAiStep(serverLevel);
this.setNoGravity(true);
this.updatePersistentAnger(serverLevel, true);
this.setAngryVisual(this.isAngry() || this.getTarget() != null);
}
@Override
public void tick() {
super.tick();
this.setNoGravity(true);
}
@Override
protected void addAdditionalSaveData(ValueOutput output) {
super.addAdditionalSaveData(output);
output.putInt(VARIANT_KEY, this.getVariant().id());
this.addPersistentAngerSaveData(output);
}
@Override
protected void readAdditionalSaveData(ValueInput input) {
super.readAdditionalSaveData(input);
this.setVariant(ButterflyVariant.byId(input.getIntOr(VARIANT_KEY, ButterflyVariant.MONARCH.id())));
this.readPersistentAngerSaveData(this.level(), input);
this.setNoGravity(true);
}
@Override
public boolean hurtServer(ServerLevel serverLevel, DamageSource damageSource, float amount) {
boolean hurt = super.hurtServer(serverLevel, damageSource, amount);
Entity attacker = damageSource.getEntity();
if (hurt && attacker instanceof LivingEntity livingEntity && livingEntity != this && this.canAttack(livingEntity)) {
this.setPersistentAngerTarget(EntityReference.of(livingEntity));
this.setTarget(livingEntity);
this.startPersistentAngerTimer();
this.setAngryVisual(true);
}
return hurt;
}
@Override
public boolean doHurtTarget(ServerLevel serverLevel, Entity entity) {
boolean hurt = super.doHurtTarget(serverLevel, entity);
if (hurt) {
this.playSound(SoundEvents.BEE_STING, 0.35F, 1.45F);
}
return hurt;
}
@Override
public boolean isFood(ItemStack itemStack) {
return itemStack.is(ItemTags.FLOWERS);
}
@Override
public ButterflyEntity getBreedOffspring(ServerLevel serverLevel, AgeableMob ageableMob) {
ButterflyEntity baby = ModEntityTypes.BUTTERFLY.create(serverLevel, EntitySpawnReason.BREEDING);
if (baby != null) {
if (ageableMob instanceof ButterflyEntity otherButterfly && this.random.nextBoolean()) {
baby.setVariant(otherButterfly.getVariant());
} else {
baby.setVariant(this.getVariant());
}
}
return baby;
}
@Override
public float getWalkTargetValue(BlockPos blockPos, LevelReader levelReader) {
if (isAttractiveFlower(levelReader, blockPos) || isAttractiveFlower(levelReader, blockPos.below())) {
return 10.0F;
}
return levelReader.getPathfindingCostFromLightLevels(blockPos);
}
@Override
protected void checkFallDamage(double fallDistance, boolean landed, BlockState state, BlockPos pos) {
}
@Override
public boolean isFlying() {
return !this.onGround();
}
@Override
protected SoundEvent getAmbientSound() {
return this.isAngryVisual() ? SoundEvents.BEE_LOOP_AGGRESSIVE : SoundEvents.BAT_AMBIENT;
}
@Override
protected SoundEvent getHurtSound(DamageSource damageSource) {
return SoundEvents.BEE_HURT;
}
@Override
protected SoundEvent getDeathSound() {
return SoundEvents.BEE_DEATH;
}
@Override
protected float getSoundVolume() {
return 0.25F;
}
@Override
public float getVoicePitch() {
return 1.35F + this.random.nextFloat() * 0.25F;
}
public ButterflyVariant getVariant() {
return ButterflyVariant.byId(this.entityData.get(VARIANT));
}
public void setVariant(ButterflyVariant variant) {
this.entityData.set(VARIANT, variant.id());
}
public boolean isAngryVisual() {
return this.entityData.get(ANGRY);
}
private void setAngryVisual(boolean angry) {
this.entityData.set(ANGRY, angry);
this.setAggressive(angry);
}
@Override
public long getPersistentAngerEndTime() {
return this.persistentAngerEndTime;
}
@Override
public void setPersistentAngerEndTime(long persistentAngerEndTime) {
this.persistentAngerEndTime = persistentAngerEndTime;
}
@Override
public EntityReference<LivingEntity> getPersistentAngerTarget() {
return this.persistentAngerTarget;
}
@Override
public void setPersistentAngerTarget(EntityReference<LivingEntity> persistentAngerTarget) {
this.persistentAngerTarget = persistentAngerTarget;
}
@Override
public void startPersistentAngerTimer() {
this.setPersistentAngerEndTime(this.level().getGameTime() + PERSISTENT_ANGER_TIME.sample(this.random));
}
private static boolean isAttractiveFlower(LevelReader levelReader, BlockPos blockPos) {
BlockState state = levelReader.getBlockState(blockPos);
return state.is(BlockTags.BEE_ATTRACTIVE) || state.is(BlockTags.FLOWERS);
}
private static final class HoverNearFlowersGoal extends Goal {
private static final int SEARCH_RADIUS = 7;
private static final int VERTICAL_RADIUS = 4;
private final ButterflyEntity butterfly;
private BlockPos flowerPos;
private HoverNearFlowersGoal(ButterflyEntity butterfly) {
this.butterfly = butterfly;
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
}
@Override
public boolean canUse() {
if (this.butterfly.isAngryVisual() || this.butterfly.getTarget() != null || this.butterfly.random.nextInt(12) != 0) {
return false;
}
this.flowerPos = this.findNearbyFlower();
return this.flowerPos != null;
}
@Override
public boolean canContinueToUse() {
return this.flowerPos != null
&& !this.butterfly.isAngryVisual()
&& this.butterfly.distanceToSqr(this.flowerPos.getX() + 0.5D, this.flowerPos.getY() + 0.8D, this.flowerPos.getZ() + 0.5D) > 0.8D
&& this.butterfly.distanceToSqr(this.flowerPos.getX() + 0.5D, this.flowerPos.getY() + 0.8D, this.flowerPos.getZ() + 0.5D) < 100.0D;
}
@Override
public void tick() {
this.butterfly.getMoveControl().setWantedPosition(
this.flowerPos.getX() + 0.5D,
this.flowerPos.getY() + 0.9D,
this.flowerPos.getZ() + 0.5D,
1.05D
);
}
@Override
public void stop() {
this.flowerPos = null;
}
private BlockPos findNearbyFlower() {
BlockPos origin = this.butterfly.blockPosition();
for (int attempt = 0; attempt < 18; attempt++) {
int x = origin.getX() + this.butterfly.random.nextInt(SEARCH_RADIUS * 2 + 1) - SEARCH_RADIUS;
int y = origin.getY() + this.butterfly.random.nextInt(VERTICAL_RADIUS * 2 + 1) - VERTICAL_RADIUS;
int z = origin.getZ() + this.butterfly.random.nextInt(SEARCH_RADIUS * 2 + 1) - SEARCH_RADIUS;
BlockPos candidate = new BlockPos(x, y, z);
if (!this.butterfly.level().isLoaded(candidate)) {
continue;
}
if (isAttractiveFlower(this.butterfly.level(), candidate) && this.butterfly.level().isEmptyBlock(candidate.above())) {
return candidate;
}
}
return null;
}
}
}
@@ -0,0 +1,68 @@
package fr.koka99cab.pipallon.entity;
import net.minecraft.util.RandomSource;
public enum ButterflyVariant {
MONARCH("monarch", 50, 0xE77B12),
MORPHO("morpho", 22, 0x09A5F0),
EYED_MOTH("eyed_moth", 13, 0xB58B72),
ATLAS("atlas", 9, 0xB97842),
EMERALD_SWALLOWTAIL("emerald_swallowtail", 6, 0x58DFA5);
private static final ButterflyVariant[] VALUES = values();
private static final int TOTAL_WEIGHT = totalWeight();
private final String textureName;
private final int spawnWeight;
private final int eggColor;
ButterflyVariant(String textureName, int spawnWeight, int eggColor) {
this.textureName = textureName;
this.spawnWeight = spawnWeight;
this.eggColor = eggColor;
}
public String textureName() {
return this.textureName;
}
public int eggColor() {
return this.eggColor;
}
public int id() {
return this.ordinal();
}
public static ButterflyVariant byId(int id) {
if (id < 0 || id >= VALUES.length) {
return MONARCH;
}
return VALUES[id];
}
public static ButterflyVariant choose(RandomSource random) {
int choice = random.nextInt(TOTAL_WEIGHT);
for (ButterflyVariant variant : VALUES) {
choice -= variant.spawnWeight;
if (choice < 0) {
return variant;
}
}
return MONARCH;
}
private static int totalWeight() {
int total = 0;
for (ButterflyVariant variant : VALUES) {
total += variant.spawnWeight;
}
return total;
}
}
@@ -0,0 +1,51 @@
package fr.koka99cab.pipallon.registry;
import fr.koka99cab.pipallon.PipallonMod;
import fr.koka99cab.pipallon.entity.ButterflyEntity;
import java.util.function.Predicate;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectionContext;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
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.entity.EntityDimensions;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.entity.SpawnPlacementTypes;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.levelgen.Heightmap;
public final class ModEntityTypes {
public static final Identifier BUTTERFLY_ID = PipallonMod.id("butterfly");
public static final EntityType<ButterflyEntity> BUTTERFLY = Registry.register(
BuiltInRegistries.ENTITY_TYPE,
BUTTERFLY_ID,
FabricEntityTypeBuilder.createMob()
.mobCategory(MobCategory.CREATURE)
.entityFactory(ButterflyEntity::new)
.dimensions(EntityDimensions.scalable(0.45F, 0.35F))
.defaultAttributes(ButterflyEntity::createAttributes)
.spawnPlacement(SpawnPlacementTypes.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, ButterflyEntity::canSpawn)
.trackRangeBlocks(8)
.trackedUpdateRate(2)
.build(ResourceKey.create(Registries.ENTITY_TYPE, BUTTERFLY_ID))
);
private ModEntityTypes() {
}
public static void register() {
Predicate<BiomeSelectionContext> flowerBiomes = BiomeSelectors.includeByKey(
Biomes.FLOWER_FOREST,
Biomes.MEADOW,
Biomes.SUNFLOWER_PLAINS,
Biomes.CHERRY_GROVE
);
Predicate<BiomeSelectionContext> beeBiomes = BiomeSelectors.spawnsOneOf(EntityType.BEE);
BiomeModifications.addSpawn(flowerBiomes.or(beeBiomes), MobCategory.CREATURE, BUTTERFLY, 8, 2, 4);
}
}
@@ -0,0 +1,32 @@
package fr.koka99cab.pipallon.registry;
import fr.koka99cab.pipallon.PipallonMod;
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.SpawnEggItem;
public final class ModItems {
private static final ResourceKey<Item> BUTTERFLY_SPAWN_EGG_KEY = ResourceKey.create(Registries.ITEM, PipallonMod.id("butterfly_spawn_egg"));
private static final ResourceKey<CreativeModeTab> SPAWN_EGGS_TAB = ResourceKey.create(Registries.CREATIVE_MODE_TAB, Identifier.withDefaultNamespace("spawn_eggs"));
public static final Item BUTTERFLY_SPAWN_EGG = Registry.register(
BuiltInRegistries.ITEM,
BUTTERFLY_SPAWN_EGG_KEY,
new SpawnEggItem(new Item.Properties()
.spawnEgg(ModEntityTypes.BUTTERFLY)
.setId(BUTTERFLY_SPAWN_EGG_KEY))
);
private ModItems() {
}
public static void register() {
CreativeModeTabEvents.modifyOutputEvent(SPAWN_EGGS_TAB).register(entries -> entries.accept(BUTTERFLY_SPAWN_EGG));
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "pipallon:item/butterfly_spawn_egg"
}
}
@@ -0,0 +1,4 @@
{
"entity.pipallon.butterfly": "Butterfly",
"item.pipallon.butterfly_spawn_egg": "Butterfly Spawn Egg"
}
@@ -0,0 +1,4 @@
{
"entity.pipallon.butterfly": "Papillon",
"item.pipallon.butterfly_spawn_egg": "Oeuf d'apparition de papillon"
}
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "pipallon:item/butterfly_spawn_egg"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

@@ -0,0 +1,27 @@
{
"schemaVersion": 1,
"id": "pipallon",
"version": "${version}",
"name": "Pipallon",
"description": "Adds neutral flying butterflies that spawn around flower-rich biomes.",
"authors": [
"KOKA99CAB"
],
"license": "LGPL-3.0-or-later",
"icon": "assets/pipallon/icon.png",
"environment": "*",
"entrypoints": {
"main": [
"fr.koka99cab.pipallon.PipallonMod"
],
"client": [
"fr.koka99cab.pipallon.client.PipallonClient"
]
},
"depends": {
"fabricloader": ">=0.19.2",
"minecraft": "~26.1.2",
"java": ">=25",
"fabric-api": "*"
}
}