Premier commit
Aucun fichier ne correspond à votre recherche
@@ -0,0 +1,66 @@
|
||||
|
||||
# --- double-push : exclusions generiques (secrets, builds, binaires, gros fichiers) ---
|
||||
target/
|
||||
node_modules/
|
||||
build/
|
||||
build-*/
|
||||
dist/
|
||||
out/
|
||||
.gradle/
|
||||
.idea/
|
||||
venv/
|
||||
.venv/
|
||||
env/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
.cache/
|
||||
.next/
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
accounts.json
|
||||
Clee.API/
|
||||
*.pem
|
||||
*.key
|
||||
*.p12
|
||||
*.pfx
|
||||
*.jks
|
||||
*.keystore
|
||||
keystore.properties
|
||||
id_rsa*
|
||||
id_ed25519*
|
||||
*.kdbx
|
||||
*.odt
|
||||
*.sqlite
|
||||
*.sqlite3
|
||||
*.db
|
||||
*.log
|
||||
*.exe
|
||||
*.dll
|
||||
*.msi
|
||||
*.jar
|
||||
*.zip
|
||||
*.7z
|
||||
*.rar
|
||||
*.tar
|
||||
*.tar.gz
|
||||
*.tgz
|
||||
*.gguf
|
||||
*.safetensors
|
||||
*.onnx
|
||||
*.pt
|
||||
*.pth
|
||||
*.bin
|
||||
*.iso
|
||||
*.gws
|
||||
*.apk
|
||||
*.aab
|
||||
*.so
|
||||
*.o
|
||||
*.a
|
||||
*.lib
|
||||
*.pdb
|
||||
*.mp4
|
||||
*.mkv
|
||||
*.wav
|
||||
*.flac
|
||||
@@ -0,0 +1,37 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'net.neoforged.moddev' version '2.0.142'
|
||||
}
|
||||
|
||||
version = project.mod_version
|
||||
group = project.mod_group_id
|
||||
base { archivesName = "${project.mod_id}-neoforge-1.21.1" }
|
||||
|
||||
java { toolchain { languageVersion = JavaLanguageVersion.of(21) } }
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { name = 'NeoForged'; url = 'https://maven.neoforged.net/releases' }
|
||||
}
|
||||
|
||||
neoForge {
|
||||
version = project.neoforge_version
|
||||
runs {
|
||||
client {
|
||||
client()
|
||||
}
|
||||
server {
|
||||
server()
|
||||
}
|
||||
}
|
||||
mods {
|
||||
"${project.mod_id}" {
|
||||
sourceSet sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8'
|
||||
options.release = 21
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
org.gradle.jvmargs=-Xmx2G
|
||||
org.gradle.parallel=true
|
||||
|
||||
mod_version=1.0.0
|
||||
mod_group_id=com.sculkorbs
|
||||
mod_id=sculkorbs
|
||||
|
||||
minecraft_version=1.21.1
|
||||
neoforge_version=21.1.248
|
||||
@@ -0,0 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,248 @@
|
||||
#!/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/3d91ce3b8caaf77ad09f381f43615b715b53f72c/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
|
||||
|
||||
# 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,82 @@
|
||||
@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, and ensure extensions are enabled
|
||||
setlocal EnableExtensions
|
||||
|
||||
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
|
||||
|
||||
"%COMSPEC%" /c exit 1
|
||||
|
||||
: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
|
||||
|
||||
"%COMSPEC%" /c exit 1
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
|
||||
@rem which allows us to clear the local environment before executing the java command
|
||||
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
|
||||
|
||||
:exitWithErrorLevel
|
||||
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
|
||||
"%COMSPEC%" /c exit %ERRORLEVEL%
|
||||
@@ -0,0 +1,8 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
maven { name = 'NeoForged'; url = 'https://maven.neoforged.net/releases' }
|
||||
}
|
||||
}
|
||||
rootProject.name = 'sculkorbs-neoforge-1.21.1'
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.sculkorbs;
|
||||
|
||||
import com.sculkorbs.event.AnvilEnchantHandler;
|
||||
import com.sculkorbs.event.SculkDropHandler;
|
||||
import com.sculkorbs.registry.ModCreativeTabs;
|
||||
import com.sculkorbs.registry.ModItems;
|
||||
import com.sculkorbs.registry.ModRecipeSerializers;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.fml.ModContainer;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Mod(SculkOrbsMod.MOD_ID)
|
||||
public class SculkOrbsMod {
|
||||
|
||||
public static final String MOD_ID = "sculkorbs";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(SculkOrbsMod.class);
|
||||
|
||||
public SculkOrbsMod(IEventBus modEventBus, ModContainer modContainer) {
|
||||
LOGGER.info("[SculkOrbs] Initialisation du mod Sculk Orbs & Perfect Enchant 1.21.1...");
|
||||
|
||||
// Enregistrement des items, onglets et sérialiseurs de recettes
|
||||
ModItems.ITEMS.register(modEventBus);
|
||||
ModCreativeTabs.CREATIVE_MODE_TABS.register(modEventBus);
|
||||
ModRecipeSerializers.RECIPE_SERIALIZERS.register(modEventBus);
|
||||
|
||||
// Enregistrement des gestionnaires d'événements NeoForge
|
||||
NeoForge.EVENT_BUS.register(SculkDropHandler.class);
|
||||
NeoForge.EVENT_BUS.register(AnvilEnchantHandler.class);
|
||||
|
||||
LOGGER.info("[SculkOrbs] Sculk Orbs, Perfect Enchant et Enclume universelle prêts !");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package com.sculkorbs.enchant;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.item.enchantment.ItemEnchantments;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PerfectEnchantApplier {
|
||||
|
||||
private record EnchantTarget(ResourceKey<Enchantment> key, int maxLevel) {}
|
||||
|
||||
public static ItemStack applyPerfectEnchantments(ItemStack original, int tier, HolderLookup.Provider registries) {
|
||||
if (original.isEmpty()) return ItemStack.EMPTY;
|
||||
|
||||
ItemStack result = original.copy();
|
||||
Item item = result.getItem();
|
||||
|
||||
List<EnchantTarget> targets = getEnchantmentsForItem(item);
|
||||
if (targets.isEmpty()) {
|
||||
// Si c'est un item endommagé / enchantable générique (ex: moddé, bouclier, briquet, etc.)
|
||||
if (result.isDamageableItem() || item.isEnchantable(result)) {
|
||||
targets = List.of(
|
||||
new EnchantTarget(Enchantments.UNBREAKING, 3),
|
||||
new EnchantTarget(Enchantments.MENDING, 1)
|
||||
);
|
||||
} else {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
var enchantmentLookup = registries.lookupOrThrow(Registries.ENCHANTMENT);
|
||||
ItemEnchantments existing = EnchantmentHelper.getEnchantmentsForCrafting(result);
|
||||
ItemEnchantments.Mutable mutable = new ItemEnchantments.Mutable(existing);
|
||||
|
||||
boolean modified = false;
|
||||
|
||||
for (EnchantTarget target : targets) {
|
||||
var holderOpt = enchantmentLookup.get(target.key());
|
||||
if (holderOpt.isPresent()) {
|
||||
Holder<Enchantment> holder = holderOpt.get();
|
||||
int targetLevel = Math.min(tier, target.maxLevel());
|
||||
int currentLevel = mutable.getLevel(holder);
|
||||
|
||||
if (targetLevel > currentLevel) {
|
||||
mutable.set(holder, targetLevel);
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!modified && !existing.isEmpty()) {
|
||||
// Même si tous les enchants étaient déjà au max, on peut valider l'opération
|
||||
modified = true;
|
||||
}
|
||||
|
||||
if (modified) {
|
||||
EnchantmentHelper.setEnchantments(result, mutable.toImmutable());
|
||||
return result;
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
private static List<EnchantTarget> getEnchantmentsForItem(Item item) {
|
||||
List<EnchantTarget> list = new ArrayList<>();
|
||||
|
||||
if (item instanceof PickaxeItem) {
|
||||
// Pioche : Fortune par défaut (le plus polyvalent comme demandé), Efficacité, Solidité, Raccommodage
|
||||
list.add(new EnchantTarget(Enchantments.EFFICIENCY, 5));
|
||||
list.add(new EnchantTarget(Enchantments.FORTUNE, 3));
|
||||
list.add(new EnchantTarget(Enchantments.UNBREAKING, 3));
|
||||
list.add(new EnchantTarget(Enchantments.MENDING, 1));
|
||||
} else if (item instanceof AxeItem) {
|
||||
// Hache : Efficacité, Tranchant, Fortune, Solidité, Raccommodage
|
||||
list.add(new EnchantTarget(Enchantments.EFFICIENCY, 5));
|
||||
list.add(new EnchantTarget(Enchantments.SHARPNESS, 5));
|
||||
list.add(new EnchantTarget(Enchantments.FORTUNE, 3));
|
||||
list.add(new EnchantTarget(Enchantments.UNBREAKING, 3));
|
||||
list.add(new EnchantTarget(Enchantments.MENDING, 1));
|
||||
} else if (item instanceof ShovelItem || item instanceof HoeItem) {
|
||||
// Pelle & Houe : Efficacité, Fortune, Solidité, Raccommodage
|
||||
list.add(new EnchantTarget(Enchantments.EFFICIENCY, 5));
|
||||
list.add(new EnchantTarget(Enchantments.FORTUNE, 3));
|
||||
list.add(new EnchantTarget(Enchantments.UNBREAKING, 3));
|
||||
list.add(new EnchantTarget(Enchantments.MENDING, 1));
|
||||
} else if (item instanceof SwordItem) {
|
||||
// Épée : Tranchant, Butin, Balayage, Aura de Feu, Recul, Solidité, Raccommodage
|
||||
list.add(new EnchantTarget(Enchantments.SHARPNESS, 5));
|
||||
list.add(new EnchantTarget(Enchantments.LOOTING, 3));
|
||||
list.add(new EnchantTarget(Enchantments.SWEEPING_EDGE, 3));
|
||||
list.add(new EnchantTarget(Enchantments.FIRE_ASPECT, 2));
|
||||
list.add(new EnchantTarget(Enchantments.KNOCKBACK, 2));
|
||||
list.add(new EnchantTarget(Enchantments.UNBREAKING, 3));
|
||||
list.add(new EnchantTarget(Enchantments.MENDING, 1));
|
||||
} else if (item instanceof MaceItem) {
|
||||
// Masse (1.21) : Densité, Brèche, Rafale, Solidité, Raccommodage
|
||||
list.add(new EnchantTarget(Enchantments.DENSITY, 5));
|
||||
list.add(new EnchantTarget(Enchantments.BREACH, 4));
|
||||
list.add(new EnchantTarget(Enchantments.WIND_BURST, 3));
|
||||
list.add(new EnchantTarget(Enchantments.UNBREAKING, 3));
|
||||
list.add(new EnchantTarget(Enchantments.MENDING, 1));
|
||||
} else if (item instanceof BowItem) {
|
||||
// Arc : Puissance, Flamme, Frappe, Infinité, Solidité
|
||||
list.add(new EnchantTarget(Enchantments.POWER, 5));
|
||||
list.add(new EnchantTarget(Enchantments.FLAME, 1));
|
||||
list.add(new EnchantTarget(Enchantments.PUNCH, 2));
|
||||
list.add(new EnchantTarget(Enchantments.INFINITY, 1));
|
||||
list.add(new EnchantTarget(Enchantments.UNBREAKING, 3));
|
||||
} else if (item instanceof CrossbowItem) {
|
||||
// Arbalète : Tir multiple, Charge rapide, Solidité, Raccommodage
|
||||
list.add(new EnchantTarget(Enchantments.MULTISHOT, 1));
|
||||
list.add(new EnchantTarget(Enchantments.QUICK_CHARGE, 3));
|
||||
list.add(new EnchantTarget(Enchantments.UNBREAKING, 3));
|
||||
list.add(new EnchantTarget(Enchantments.MENDING, 1));
|
||||
} else if (item instanceof TridentItem) {
|
||||
// Trident : Empalement, Loyauté, Canalisation, Solidité, Raccommodage
|
||||
list.add(new EnchantTarget(Enchantments.IMPALING, 5));
|
||||
list.add(new EnchantTarget(Enchantments.LOYALTY, 3));
|
||||
list.add(new EnchantTarget(Enchantments.CHANNELING, 1));
|
||||
list.add(new EnchantTarget(Enchantments.UNBREAKING, 3));
|
||||
list.add(new EnchantTarget(Enchantments.MENDING, 1));
|
||||
} else if (item instanceof ArmorItem armor) {
|
||||
// Armures
|
||||
list.add(new EnchantTarget(Enchantments.PROTECTION, 4));
|
||||
list.add(new EnchantTarget(Enchantments.UNBREAKING, 3));
|
||||
list.add(new EnchantTarget(Enchantments.MENDING, 1));
|
||||
list.add(new EnchantTarget(Enchantments.THORNS, 3));
|
||||
|
||||
switch (armor.getType()) {
|
||||
case HELMET -> {
|
||||
list.add(new EnchantTarget(Enchantments.RESPIRATION, 3));
|
||||
list.add(new EnchantTarget(Enchantments.AQUA_AFFINITY, 1));
|
||||
}
|
||||
case LEGGINGS -> {
|
||||
list.add(new EnchantTarget(Enchantments.SWIFT_SNEAK, 3));
|
||||
}
|
||||
case BOOTS -> {
|
||||
list.add(new EnchantTarget(Enchantments.FEATHER_FALLING, 4));
|
||||
list.add(new EnchantTarget(Enchantments.DEPTH_STRIDER, 3));
|
||||
list.add(new EnchantTarget(Enchantments.SOUL_SPEED, 3));
|
||||
}
|
||||
default -> {}
|
||||
}
|
||||
} else if (item instanceof ElytraItem) {
|
||||
list.add(new EnchantTarget(Enchantments.UNBREAKING, 3));
|
||||
list.add(new EnchantTarget(Enchantments.MENDING, 1));
|
||||
} else if (item instanceof FishingRodItem) {
|
||||
list.add(new EnchantTarget(Enchantments.LUCK_OF_THE_SEA, 3));
|
||||
list.add(new EnchantTarget(Enchantments.LURE, 3));
|
||||
list.add(new EnchantTarget(Enchantments.UNBREAKING, 3));
|
||||
list.add(new EnchantTarget(Enchantments.MENDING, 1));
|
||||
} else if (item instanceof ShearsItem) {
|
||||
list.add(new EnchantTarget(Enchantments.EFFICIENCY, 5));
|
||||
list.add(new EnchantTarget(Enchantments.UNBREAKING, 3));
|
||||
list.add(new EnchantTarget(Enchantments.MENDING, 1));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.sculkorbs.event;
|
||||
|
||||
import com.sculkorbs.enchant.PerfectEnchantApplier;
|
||||
import com.sculkorbs.item.PerfectEnchantItem;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.event.AnvilUpdateEvent;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
||||
|
||||
public class AnvilEnchantHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onAnvilUpdate(AnvilUpdateEvent event) {
|
||||
ItemStack left = event.getLeft();
|
||||
ItemStack right = event.getRight();
|
||||
|
||||
if (left.isEmpty() || right.isEmpty()) return;
|
||||
|
||||
if (right.getItem() instanceof PerfectEnchantItem enchantItem) {
|
||||
HolderLookup.Provider registries;
|
||||
if (event.getPlayer() != null) {
|
||||
registries = event.getPlayer().level().registryAccess();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack output = PerfectEnchantApplier.applyPerfectEnchantments(left, enchantItem.getLevel(), registries);
|
||||
|
||||
if (!output.isEmpty()) {
|
||||
event.setOutput(output);
|
||||
event.setCost(1); // 1 niveau d'XP de coût à l'enclume
|
||||
event.setMaterialCost(1); // Consomme 1 Perfect Enchant
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onItemCrafted(PlayerEvent.ItemCraftedEvent event) {
|
||||
ItemStack crafted = event.getCrafting();
|
||||
if (crafted.getItem() instanceof PerfectEnchantItem) {
|
||||
Container container = event.getInventory();
|
||||
|
||||
// Calcul du nombre de slots contenant du sculk
|
||||
int sculkSlots = 0;
|
||||
for (int i = 0; i < container.getContainerSize(); i++) {
|
||||
ItemStack stack = container.getItem(i);
|
||||
if (stack.is(Blocks.SCULK.asItem())) {
|
||||
sculkSlots++;
|
||||
}
|
||||
}
|
||||
|
||||
// Minecraft a déjà décrémenté 1 item par slot non vide lors du clic de craft.
|
||||
// On retire le reste des 64 blocs de sculk nécessaires :
|
||||
int sculkToConsume = Math.max(0, 64 - sculkSlots);
|
||||
|
||||
for (int i = 0; i < container.getContainerSize(); i++) {
|
||||
if (sculkToConsume <= 0) break;
|
||||
ItemStack stack = container.getItem(i);
|
||||
if (stack.is(Blocks.SCULK.asItem())) {
|
||||
int toTake = Math.min(stack.getCount(), sculkToConsume);
|
||||
stack.shrink(toTake);
|
||||
sculkToConsume -= toTake;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.sculkorbs.event;
|
||||
|
||||
import com.sculkorbs.registry.ModItems;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.event.level.BlockDropsEvent;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class SculkDropHandler {
|
||||
|
||||
private static final Random RANDOM = new Random();
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onBlockDrops(BlockDropsEvent event) {
|
||||
Level level = event.getLevel();
|
||||
if (level.isClientSide() || !(level instanceof ServerLevel serverLevel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockState state = event.getState();
|
||||
if (!state.is(Blocks.SCULK)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity breaker = event.getBreaker();
|
||||
if (breaker instanceof Player player && player.isCreative()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack tool = event.getTool();
|
||||
|
||||
// Vérification de Silk Touch (Toucher de soie)
|
||||
boolean hasSilkTouch = false;
|
||||
if (!tool.isEmpty()) {
|
||||
var silkTouchHolder = level.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).get(Enchantments.SILK_TOUCH);
|
||||
if (silkTouchHolder.isPresent()) {
|
||||
hasSilkTouch = EnchantmentHelper.getItemEnchantmentLevel(silkTouchHolder.get(), tool) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasSilkTouch) {
|
||||
return; // Silk Touch conserve le bloc de sculk vanilla
|
||||
}
|
||||
|
||||
// Vider les drops par défaut
|
||||
event.getDrops().clear();
|
||||
|
||||
// Tirage aléatoire :
|
||||
// 25% Orbe Massif (0.00 à 0.25)
|
||||
// 25% Orbe Géant (0.25 à 0.50)
|
||||
// 25% Orbe Colossal (0.50 à 0.75)
|
||||
// 20% Orbe Mythique (0.75 à 0.95)
|
||||
// 5% Orbe Maximal (0.95 à 1.00)
|
||||
double roll = RANDOM.nextDouble();
|
||||
ItemStack droppedOrb;
|
||||
|
||||
if (roll < 0.25) {
|
||||
droppedOrb = new ItemStack(ModItems.MASSIVE_ORB.get());
|
||||
} else if (roll < 0.50) {
|
||||
droppedOrb = new ItemStack(ModItems.GIANT_ORB.get());
|
||||
} else if (roll < 0.75) {
|
||||
droppedOrb = new ItemStack(ModItems.COLOSSAL_ORB.get());
|
||||
} else if (roll < 0.95) {
|
||||
droppedOrb = new ItemStack(ModItems.MYTHIC_ORB.get());
|
||||
} else {
|
||||
droppedOrb = new ItemStack(ModItems.MAXIMAL_ORB.get());
|
||||
}
|
||||
|
||||
BlockPos pos = event.getPos();
|
||||
ItemEntity orbEntity = new ItemEntity(
|
||||
serverLevel,
|
||||
pos.getX() + 0.5,
|
||||
pos.getY() + 0.5,
|
||||
pos.getZ() + 0.5,
|
||||
droppedOrb
|
||||
);
|
||||
orbEntity.setDefaultPickUpDelay();
|
||||
event.getDrops().add(orbEntity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.sculkorbs.item;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PerfectEnchantItem extends Item {
|
||||
|
||||
private final int level;
|
||||
|
||||
public PerfectEnchantItem(int level, Properties properties) {
|
||||
super(properties);
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFoil(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
|
||||
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
|
||||
|
||||
String roman = switch (level) {
|
||||
case 1 -> "I";
|
||||
case 2 -> "II";
|
||||
case 3 -> "III";
|
||||
case 4 -> "IV";
|
||||
case 5 -> "V";
|
||||
default -> String.valueOf(level);
|
||||
};
|
||||
|
||||
tooltipComponents.add(Component.translatable("tooltip.sculkorbs.perfect_enchant_tier", roman).withStyle(ChatFormatting.GOLD));
|
||||
tooltipComponents.add(Component.translatable("tooltip.sculkorbs.perfect_enchant_desc").withStyle(ChatFormatting.AQUA));
|
||||
tooltipComponents.add(Component.translatable("tooltip.sculkorbs.perfect_enchant_max", level).withStyle(ChatFormatting.YELLOW));
|
||||
tooltipComponents.add(Component.empty());
|
||||
|
||||
if (level == 1) {
|
||||
tooltipComponents.add(Component.translatable("tooltip.sculkorbs.craft_hint_t1").withStyle(ChatFormatting.DARK_GRAY, ChatFormatting.ITALIC));
|
||||
} else {
|
||||
String prevRoman = switch (level - 1) {
|
||||
case 1 -> "I";
|
||||
case 2 -> "II";
|
||||
case 3 -> "III";
|
||||
case 4 -> "IV";
|
||||
default -> String.valueOf(level - 1);
|
||||
};
|
||||
tooltipComponents.add(Component.translatable("tooltip.sculkorbs.craft_hint_tn", prevRoman).withStyle(ChatFormatting.DARK_GRAY, ChatFormatting.ITALIC));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.sculkorbs.item;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SculkOrbItem extends Item {
|
||||
|
||||
private final SculkOrbTier tier;
|
||||
|
||||
public SculkOrbItem(SculkOrbTier tier, Properties properties) {
|
||||
super(properties);
|
||||
this.tier = tier;
|
||||
}
|
||||
|
||||
public SculkOrbTier getTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFoil(ItemStack stack) {
|
||||
return tier.isFoil() || super.isFoil(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
|
||||
ItemStack itemStack = player.getItemInHand(hand);
|
||||
|
||||
if (!level.isClientSide && level instanceof ServerLevel serverLevel) {
|
||||
// Donner l'expérience
|
||||
player.giveExperiencePoints(tier.getXpAmount());
|
||||
|
||||
// Effets, particules et sons selon le palier de l'orbe
|
||||
double px = player.getX();
|
||||
double py = player.getY();
|
||||
double pz = player.getZ();
|
||||
|
||||
switch (tier) {
|
||||
case MASSIVE -> {
|
||||
serverLevel.sendParticles(ParticleTypes.SCULK_CHARGE_POP, px, py + 1.0, pz, 20, 0.4, 0.5, 0.4, 0.05);
|
||||
level.playSound(null, px, py, pz, SoundEvents.EXPERIENCE_ORB_PICKUP, SoundSource.PLAYERS, 1.0f, 1.2f);
|
||||
}
|
||||
case GIANT -> {
|
||||
player.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SPEED, 300, 0)); // 15s Vitesse I
|
||||
serverLevel.sendParticles(ParticleTypes.SCULK_SOUL, px, py + 1.0, pz, 30, 0.5, 0.6, 0.5, 0.08);
|
||||
level.playSound(null, px, py, pz, SoundEvents.SCULK_CATALYST_BLOOM, SoundSource.PLAYERS, 1.0f, 1.3f);
|
||||
level.playSound(null, px, py, pz, SoundEvents.EXPERIENCE_ORB_PICKUP, SoundSource.PLAYERS, 1.0f, 1.0f);
|
||||
}
|
||||
case COLOSSAL -> {
|
||||
player.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 200, 1)); // 10s Regen II
|
||||
player.addEffect(new MobEffectInstance(MobEffects.NIGHT_VISION, 600, 0)); // 30s Vision nocturne
|
||||
serverLevel.sendParticles(ParticleTypes.SCULK_SOUL, px, py + 1.0, pz, 45, 0.6, 0.8, 0.6, 0.1);
|
||||
serverLevel.sendParticles(ParticleTypes.END_ROD, px, py + 1.0, pz, 15, 0.4, 0.5, 0.4, 0.05);
|
||||
level.playSound(null, px, py, pz, SoundEvents.AMETHYST_BLOCK_RESONATE, SoundSource.PLAYERS, 1.5f, 0.8f);
|
||||
level.playSound(null, px, py, pz, SoundEvents.PLAYER_LEVELUP, SoundSource.PLAYERS, 0.8f, 1.2f);
|
||||
}
|
||||
case MYTHIC -> {
|
||||
player.addEffect(new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 600, 1)); // 30s Résistance II
|
||||
player.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 300, 2)); // 15s Regen III
|
||||
player.addEffect(new MobEffectInstance(MobEffects.ABSORPTION, 1200, 3)); // 60s Absorption IV
|
||||
serverLevel.sendParticles(ParticleTypes.TOTEM_OF_UNDYING, px, py + 1.0, pz, 50, 0.5, 0.8, 0.5, 0.3);
|
||||
serverLevel.sendParticles(ParticleTypes.SCULK_SOUL, px, py + 1.0, pz, 50, 0.6, 0.8, 0.6, 0.1);
|
||||
level.playSound(null, px, py, pz, SoundEvents.TOTEM_USE, SoundSource.PLAYERS, 0.8f, 1.4f);
|
||||
level.playSound(null, px, py, pz, SoundEvents.SCULK_SHRIEKER_SHRIEK, SoundSource.PLAYERS, 0.5f, 1.3f);
|
||||
}
|
||||
case MAXIMAL -> {
|
||||
player.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, 900, 2)); // 45s Force III
|
||||
player.addEffect(new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 900, 2)); // 45s Résistance III
|
||||
player.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 600, 3)); // 30s Regen IV
|
||||
player.addEffect(new MobEffectInstance(MobEffects.ABSORPTION, 2400, 4)); // 2m Absorption V
|
||||
player.addEffect(new MobEffectInstance(MobEffects.DIG_SPEED, 1200, 1)); // 1m Célérité II
|
||||
serverLevel.sendParticles(ParticleTypes.SONIC_BOOM, px, py + 1.0, pz, 1, 0, 0, 0, 0);
|
||||
serverLevel.sendParticles(ParticleTypes.FLASH, px, py + 1.0, pz, 3, 0.2, 0.5, 0.2, 0);
|
||||
serverLevel.sendParticles(ParticleTypes.SCULK_SOUL, px, py + 1.0, pz, 80, 0.8, 1.2, 0.8, 0.2);
|
||||
serverLevel.sendParticles(ParticleTypes.ENCHANTED_HIT, px, py + 1.0, pz, 60, 0.8, 1.0, 0.8, 0.5);
|
||||
level.playSound(null, px, py, pz, SoundEvents.WARDEN_SONIC_BOOM, SoundSource.PLAYERS, 1.2f, 1.0f);
|
||||
level.playSound(null, px, py, pz, SoundEvents.UI_TOAST_CHALLENGE_COMPLETE, SoundSource.PLAYERS, 1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
// Consommation de l'item en mode survie
|
||||
if (!player.getAbilities().instabuild) {
|
||||
itemStack.shrink(1);
|
||||
}
|
||||
|
||||
player.awardStat(Stats.ITEM_USED.get(this));
|
||||
}
|
||||
|
||||
return InteractionResultHolder.sidedSuccess(itemStack, level.isClientSide());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
|
||||
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
|
||||
|
||||
tooltipComponents.add(Component.translatable("tooltip.sculkorbs.drop_rate", tier.getDropRatePercent() + "%").withStyle(ChatFormatting.GRAY));
|
||||
tooltipComponents.add(Component.translatable("tooltip.sculkorbs.xp_gain", String.format("%,d", tier.getXpAmount())).withStyle(ChatFormatting.GREEN));
|
||||
tooltipComponents.add(Component.empty());
|
||||
tooltipComponents.add(Component.translatable("tooltip.sculkorbs.use_hint").withStyle(ChatFormatting.DARK_GRAY, ChatFormatting.ITALIC));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.sculkorbs.item;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
|
||||
public enum SculkOrbTier {
|
||||
MASSIVE("massive", "Orbe Massif", "Massive Orb", 25.0, 75, ChatFormatting.GREEN, false),
|
||||
GIANT("giant", "Orbe Géant", "Giant Orb", 25.0, 350, ChatFormatting.AQUA, false),
|
||||
COLOSSAL("colossal", "Orbe Colossal", "Colossal Orb", 25.0, 1500, ChatFormatting.LIGHT_PURPLE, true),
|
||||
MYTHIC("mythic", "Orbe Mythique", "Mythic Orb", 20.0, 6000, ChatFormatting.GOLD, true),
|
||||
MAXIMAL("maximal", "Orbe Maximal", "Maximal Orb", 5.0, 30000, ChatFormatting.DARK_RED, true);
|
||||
|
||||
private final String id;
|
||||
private final String frenchName;
|
||||
private final String englishName;
|
||||
private final double dropRatePercent;
|
||||
private final int xpAmount;
|
||||
private final ChatFormatting color;
|
||||
private final boolean foil;
|
||||
|
||||
SculkOrbTier(String id, String frenchName, String englishName, double dropRatePercent, int xpAmount, ChatFormatting color, boolean foil) {
|
||||
this.id = id;
|
||||
this.frenchName = frenchName;
|
||||
this.englishName = englishName;
|
||||
this.dropRatePercent = dropRatePercent;
|
||||
this.xpAmount = xpAmount;
|
||||
this.color = color;
|
||||
this.foil = foil;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getFrenchName() {
|
||||
return frenchName;
|
||||
}
|
||||
|
||||
public String getEnglishName() {
|
||||
return englishName;
|
||||
}
|
||||
|
||||
public double getDropRatePercent() {
|
||||
return dropRatePercent;
|
||||
}
|
||||
|
||||
public int getXpAmount() {
|
||||
return xpAmount;
|
||||
}
|
||||
|
||||
public ChatFormatting getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public boolean isFoil() {
|
||||
return foil;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.sculkorbs.recipe;
|
||||
|
||||
import com.sculkorbs.item.PerfectEnchantItem;
|
||||
import com.sculkorbs.registry.ModItems;
|
||||
import com.sculkorbs.registry.ModRecipeSerializers;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.CraftingBookCategory;
|
||||
import net.minecraft.world.item.crafting.CraftingInput;
|
||||
import net.minecraft.world.item.crafting.CustomRecipe;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
public class PerfectEnchantCraftingRecipe extends CustomRecipe {
|
||||
|
||||
public PerfectEnchantCraftingRecipe(CraftingBookCategory category) {
|
||||
super(category);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(CraftingInput input, Level level) {
|
||||
return getResultTier(input) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack assemble(CraftingInput input, HolderLookup.Provider registries) {
|
||||
int targetTier = getResultTier(input);
|
||||
return switch (targetTier) {
|
||||
case 1 -> new ItemStack(ModItems.PERFECT_ENCHANT_1.get());
|
||||
case 2 -> new ItemStack(ModItems.PERFECT_ENCHANT_2.get());
|
||||
case 3 -> new ItemStack(ModItems.PERFECT_ENCHANT_3.get());
|
||||
case 4 -> new ItemStack(ModItems.PERFECT_ENCHANT_4.get());
|
||||
case 5 -> new ItemStack(ModItems.PERFECT_ENCHANT_5.get());
|
||||
default -> ItemStack.EMPTY;
|
||||
};
|
||||
}
|
||||
|
||||
private int getResultTier(CraftingInput input) {
|
||||
int totalSculk = 0;
|
||||
int prevEnchantLevel = 0;
|
||||
int enchantCount = 0;
|
||||
|
||||
for (int i = 0; i < input.size(); i++) {
|
||||
ItemStack stack = input.getItem(i);
|
||||
if (stack.isEmpty()) continue;
|
||||
|
||||
if (stack.is(Blocks.SCULK.asItem())) {
|
||||
totalSculk += stack.getCount();
|
||||
} else if (stack.getItem() instanceof PerfectEnchantItem enchantItem) {
|
||||
enchantCount++;
|
||||
prevEnchantLevel = enchantItem.getLevel();
|
||||
} else {
|
||||
return 0; // Item non autorisé dans la recette
|
||||
}
|
||||
}
|
||||
|
||||
// Il faut au moins 64 blocs de sculk au total dans la grille
|
||||
if (totalSculk < 64) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Niveau 1 : 64 sculk et aucun item précédent
|
||||
if (enchantCount == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Niveau N+1 : 1 item de niveau N + 64 sculk (jusqu'à 5)
|
||||
if (enchantCount == 1 && prevEnchantLevel >= 1 && prevEnchantLevel < 5) {
|
||||
return prevEnchantLevel + 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonNullList<ItemStack> getRemainingItems(CraftingInput input) {
|
||||
return NonNullList.withSize(input.size(), ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCraftInDimensions(int width, int height) {
|
||||
return width * height >= 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return ModRecipeSerializers.PERFECT_ENCHANT_CRAFTING.get();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.sculkorbs.registry;
|
||||
|
||||
import com.sculkorbs.SculkOrbsMod;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.neoforged.neoforge.registries.DeferredHolder;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
|
||||
public class ModCreativeTabs {
|
||||
|
||||
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS =
|
||||
DeferredRegister.create(Registries.CREATIVE_MODE_TAB, SculkOrbsMod.MOD_ID);
|
||||
|
||||
public static final DeferredHolder<CreativeModeTab, CreativeModeTab> SCULK_ORBS_TAB = CREATIVE_MODE_TABS.register("sculk_orbs_tab",
|
||||
() -> CreativeModeTab.builder()
|
||||
.title(Component.translatable("itemGroup.sculkorbs"))
|
||||
.icon(() -> new ItemStack(ModItems.PERFECT_ENCHANT_5.get()))
|
||||
.displayItems((parameters, output) -> {
|
||||
// Orbes de Sculk
|
||||
output.accept(ModItems.MASSIVE_ORB.get());
|
||||
output.accept(ModItems.GIANT_ORB.get());
|
||||
output.accept(ModItems.COLOSSAL_ORB.get());
|
||||
output.accept(ModItems.MYTHIC_ORB.get());
|
||||
output.accept(ModItems.MAXIMAL_ORB.get());
|
||||
|
||||
// Perfect Enchants
|
||||
output.accept(ModItems.PERFECT_ENCHANT_1.get());
|
||||
output.accept(ModItems.PERFECT_ENCHANT_2.get());
|
||||
output.accept(ModItems.PERFECT_ENCHANT_3.get());
|
||||
output.accept(ModItems.PERFECT_ENCHANT_4.get());
|
||||
output.accept(ModItems.PERFECT_ENCHANT_5.get());
|
||||
})
|
||||
.build());
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.sculkorbs.registry;
|
||||
|
||||
import com.sculkorbs.SculkOrbsMod;
|
||||
import com.sculkorbs.item.PerfectEnchantItem;
|
||||
import com.sculkorbs.item.SculkOrbItem;
|
||||
import com.sculkorbs.item.SculkOrbTier;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.neoforged.neoforge.registries.DeferredItem;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
|
||||
public class ModItems {
|
||||
|
||||
public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(SculkOrbsMod.MOD_ID);
|
||||
|
||||
// --- Les 5 Orbes de Sculk ---
|
||||
public static final DeferredItem<SculkOrbItem> MASSIVE_ORB = ITEMS.register("massive_orb",
|
||||
() -> new SculkOrbItem(SculkOrbTier.MASSIVE, new Item.Properties().rarity(Rarity.COMMON).stacksTo(64)));
|
||||
|
||||
public static final DeferredItem<SculkOrbItem> GIANT_ORB = ITEMS.register("giant_orb",
|
||||
() -> new SculkOrbItem(SculkOrbTier.GIANT, new Item.Properties().rarity(Rarity.UNCOMMON).stacksTo(64)));
|
||||
|
||||
public static final DeferredItem<SculkOrbItem> COLOSSAL_ORB = ITEMS.register("colossal_orb",
|
||||
() -> new SculkOrbItem(SculkOrbTier.COLOSSAL, new Item.Properties().rarity(Rarity.RARE).stacksTo(64)));
|
||||
|
||||
public static final DeferredItem<SculkOrbItem> MYTHIC_ORB = ITEMS.register("mythic_orb",
|
||||
() -> new SculkOrbItem(SculkOrbTier.MYTHIC, new Item.Properties().rarity(Rarity.EPIC).stacksTo(64)));
|
||||
|
||||
public static final DeferredItem<SculkOrbItem> MAXIMAL_ORB = ITEMS.register("maximal_orb",
|
||||
() -> new SculkOrbItem(SculkOrbTier.MAXIMAL, new Item.Properties().rarity(Rarity.EPIC).stacksTo(64)));
|
||||
|
||||
// --- Les 5 Niveaux de Perfect Enchant ---
|
||||
public static final DeferredItem<PerfectEnchantItem> PERFECT_ENCHANT_1 = ITEMS.register("perfect_enchant_1",
|
||||
() -> new PerfectEnchantItem(1, new Item.Properties().rarity(Rarity.COMMON).stacksTo(16)));
|
||||
|
||||
public static final DeferredItem<PerfectEnchantItem> PERFECT_ENCHANT_2 = ITEMS.register("perfect_enchant_2",
|
||||
() -> new PerfectEnchantItem(2, new Item.Properties().rarity(Rarity.UNCOMMON).stacksTo(16)));
|
||||
|
||||
public static final DeferredItem<PerfectEnchantItem> PERFECT_ENCHANT_3 = ITEMS.register("perfect_enchant_3",
|
||||
() -> new PerfectEnchantItem(3, new Item.Properties().rarity(Rarity.RARE).stacksTo(16)));
|
||||
|
||||
public static final DeferredItem<PerfectEnchantItem> PERFECT_ENCHANT_4 = ITEMS.register("perfect_enchant_4",
|
||||
() -> new PerfectEnchantItem(4, new Item.Properties().rarity(Rarity.EPIC).stacksTo(16)));
|
||||
|
||||
public static final DeferredItem<PerfectEnchantItem> PERFECT_ENCHANT_5 = ITEMS.register("perfect_enchant_5",
|
||||
() -> new PerfectEnchantItem(5, new Item.Properties().rarity(Rarity.EPIC).stacksTo(16)));
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.sculkorbs.registry;
|
||||
|
||||
import com.sculkorbs.SculkOrbsMod;
|
||||
import com.sculkorbs.recipe.PerfectEnchantCraftingRecipe;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.item.crafting.SimpleCraftingRecipeSerializer;
|
||||
import net.neoforged.neoforge.registries.DeferredHolder;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
|
||||
public class ModRecipeSerializers {
|
||||
|
||||
public static final DeferredRegister<RecipeSerializer<?>> RECIPE_SERIALIZERS =
|
||||
DeferredRegister.create(Registries.RECIPE_SERIALIZER, SculkOrbsMod.MOD_ID);
|
||||
|
||||
public static final DeferredHolder<RecipeSerializer<?>, SimpleCraftingRecipeSerializer<PerfectEnchantCraftingRecipe>> PERFECT_ENCHANT_CRAFTING =
|
||||
RECIPE_SERIALIZERS.register("perfect_enchant_crafting",
|
||||
() -> new SimpleCraftingRecipeSerializer<>(PerfectEnchantCraftingRecipe::new));
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
modLoader="javafml"
|
||||
loaderVersion="[1,)"
|
||||
license="MIT"
|
||||
|
||||
[[mods]]
|
||||
modId="sculkorbs"
|
||||
version="1.0.0"
|
||||
displayName="Sculk Orbs"
|
||||
authors="Théo Gastinel"
|
||||
description='''Mod ajoutant 5 types d'orbes mystiques et d'expérience avec des probabilités configurées en minant des blocs de sculk.'''
|
||||
|
||||
[[dependencies.sculkorbs]]
|
||||
modId="neoforge"
|
||||
type="required"
|
||||
versionRange="[21.1,)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
[[dependencies.sculkorbs]]
|
||||
modId="minecraft"
|
||||
type="required"
|
||||
versionRange="[1.21.1,1.21.2)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"itemGroup.sculkorbs": "Sculk Orbs & Perfect Enchant",
|
||||
"item.sculkorbs.massive_orb": "Massive Orb",
|
||||
"item.sculkorbs.giant_orb": "Giant Orb",
|
||||
"item.sculkorbs.colossal_orb": "Colossal Orb",
|
||||
"item.sculkorbs.mythic_orb": "Mythic Orb",
|
||||
"item.sculkorbs.maximal_orb": "Maximal Orb",
|
||||
"item.sculkorbs.perfect_enchant_1": "Perfect Enchant I",
|
||||
"item.sculkorbs.perfect_enchant_2": "Perfect Enchant II",
|
||||
"item.sculkorbs.perfect_enchant_3": "Perfect Enchant III",
|
||||
"item.sculkorbs.perfect_enchant_4": "Perfect Enchant IV",
|
||||
"item.sculkorbs.perfect_enchant_5": "Perfect Enchant V",
|
||||
"tooltip.sculkorbs.drop_rate": "§7Drop Rate: §e%s",
|
||||
"tooltip.sculkorbs.xp_gain": "§7Experience: §a+%s XP",
|
||||
"tooltip.sculkorbs.use_hint": "Right click to consume",
|
||||
"tooltip.sculkorbs.perfect_enchant_tier": "§6§lTier : %s",
|
||||
"tooltip.sculkorbs.perfect_enchant_desc": "Combine with equipment in an anvil",
|
||||
"tooltip.sculkorbs.perfect_enchant_max": "Applies the best enchantments up to level §e%s",
|
||||
"tooltip.sculkorbs.craft_hint_t1": "Craft: 64 sculk blocks in crafting grid",
|
||||
"tooltip.sculkorbs.craft_hint_tn": "Craft: Perfect Enchant %s + 64 sculk blocks"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"itemGroup.sculkorbs": "Sculk Orbs & Perfect Enchant",
|
||||
"item.sculkorbs.massive_orb": "Orbe Massif",
|
||||
"item.sculkorbs.giant_orb": "Orbe Géant",
|
||||
"item.sculkorbs.colossal_orb": "Orbe Colossal",
|
||||
"item.sculkorbs.mythic_orb": "Orbe Mythique",
|
||||
"item.sculkorbs.maximal_orb": "Orbe Maximal",
|
||||
"item.sculkorbs.perfect_enchant_1": "Enchantement Parfait I",
|
||||
"item.sculkorbs.perfect_enchant_2": "Enchantement Parfait II",
|
||||
"item.sculkorbs.perfect_enchant_3": "Enchantement Parfait III",
|
||||
"item.sculkorbs.perfect_enchant_4": "Enchantement Parfait IV",
|
||||
"item.sculkorbs.perfect_enchant_5": "Enchantement Parfait V",
|
||||
"tooltip.sculkorbs.drop_rate": "§7Taux d'apparition: §e%s",
|
||||
"tooltip.sculkorbs.xp_gain": "§7Expérience: §a+%s XP",
|
||||
"tooltip.sculkorbs.use_hint": "Faites un clic droit pour consommer",
|
||||
"tooltip.sculkorbs.perfect_enchant_tier": "§6§lRang : %s",
|
||||
"tooltip.sculkorbs.perfect_enchant_desc": "Combinez avec un équipement dans une enclume",
|
||||
"tooltip.sculkorbs.perfect_enchant_max": "Applique les meilleurs enchantements jusqu'au niveau §e%s",
|
||||
"tooltip.sculkorbs.craft_hint_t1": "Craft : 64 blocs de sculk dans la grille",
|
||||
"tooltip.sculkorbs.craft_hint_tn": "Craft : Enchantement Parfait %s + 64 blocs de sculk"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "sculkorbs:item/colossal_orb"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "sculkorbs:item/giant_orb"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "sculkorbs:item/massive_orb"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "sculkorbs:item/maximal_orb"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "sculkorbs:item/mythic_orb"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "sculkorbs:item/perfect_enchant_1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "sculkorbs:item/perfect_enchant_2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "sculkorbs:item/perfect_enchant_3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "sculkorbs:item/perfect_enchant_4"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "sculkorbs:item/perfect_enchant_5"
|
||||
}
|
||||
}
|
||||
|
Après Largeur: | Hauteur: | Taille: 177 B |
|
Après Largeur: | Hauteur: | Taille: 175 B |
|
Après Largeur: | Hauteur: | Taille: 177 B |
|
Après Largeur: | Hauteur: | Taille: 226 B |
|
Après Largeur: | Hauteur: | Taille: 177 B |
|
Après Largeur: | Hauteur: | Taille: 156 B |
|
Après Largeur: | Hauteur: | Taille: 156 B |
|
Après Largeur: | Hauteur: | Taille: 159 B |
|
Après Largeur: | Hauteur: | Taille: 160 B |
|
Après Largeur: | Hauteur: | Taille: 158 B |
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"type": "sculkorbs:perfect_enchant_crafting",
|
||||
"category": "misc"
|
||||
}
|
||||