Compare commits

...

7 Commits

Author SHA1 Message Date
57fa9c4263 update to 1.21.4 2025-01-05 14:41:32 +01:00
a4ce4504c6 update dependencies 2024-10-11 22:48:41 +02:00
332b3df632 update to 1.21 2024-07-11 23:38:19 +02:00
f6c2ea900c bump version 2023-07-07 23:31:32 +02:00
af7aadc9ca rename velocityMultiplier 2023-07-07 23:30:57 +02:00
f83d2c220f fix config and extend example 2023-07-07 22:48:25 +02:00
74801ef10b fix example generation 2023-07-06 00:03:50 +02:00
21 changed files with 670 additions and 746 deletions

View File

@ -20,9 +20,10 @@
nether_ore, bone, netherite, ancient_debris, lodestone, chain, nether_ore, bone, netherite, ancient_debris, lodestone, chain,
nether_gold_ore, gilded_blackstone, candle, amethyst_block, nether_gold_ore, gilded_blackstone, candle, amethyst_block,
amethyst_cluster, small_amethyst_bud, medium_amethyst_bud, amethyst_cluster, small_amethyst_bud, medium_amethyst_bud,
large_amethyst_bud, tuff, calcite, dripstone_block, large_amethyst_bud, tuff, tuff_bricks, polished_tuff, calcite,
pointed_dripstone, copper, cave_vines, spore_blossom, azalea, dripstone_block, pointed_dripstone, copper, copper_bulb,
flowering_azalea, moss_carpet, pink_petals, moss_block, big_dripleaf, copper_grate, cave_vines, spore_blossom, azalea, flowering_azalea,
moss_carpet, pink_petals, moss_block, big_dripleaf,
small_dripleaf, rooted_dirt, hanging_roots, azalea_leaves, small_dripleaf, rooted_dirt, hanging_roots, azalea_leaves,
sculk_sensor, sculk_catalyst, sculk, sculk_vein, sculk_shrieker, sculk_sensor, sculk_catalyst, sculk, sculk_vein, sculk_shrieker,
glow_lichen, deepslate, deepslate_bricks, deepslate_tiles, glow_lichen, deepslate, deepslate_bricks, deepslate_tiles,
@ -31,7 +32,9 @@
nether_wood_hanging_sign, bamboo_wood_hanging_sign, bamboo_wood, nether_wood_hanging_sign, bamboo_wood_hanging_sign, bamboo_wood,
nether_wood, cherry_wood, cherry_sapling, cherry_leaves, nether_wood, cherry_wood, cherry_sapling, cherry_leaves,
cherry_wood_hanging_sign, chiseled_bookshelf, suspicious_sand, cherry_wood_hanging_sign, chiseled_bookshelf, suspicious_sand,
suspicious_gravel, decorated_pot, decorated_pot_shatter suspicious_gravel, decorated_pot, decorated_pot_shatter,
trial_spawner, sponge, wet_sponge, vault, heavy_core,
cobweb
changes how the block sounds changes how the block sounds
"dropTableId" ~ string "dropTableId" ~ string
@ -55,7 +58,7 @@
"slipperiness" ~ float "slipperiness" ~ float
"slowDownMultiplier" ~ float "movementVelocityMultiplier" ~ float
"jumpVelocityMultiplier" ~ float "jumpVelocityMultiplier" ~ float

View File

@ -1,5 +1,6 @@
plugins { plugins {
id 'fabric-loom' version '1.2-SNAPSHOT' id "com.modrinth.minotaur" version "2.+"
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'maven-publish' id 'maven-publish'
} }
@ -16,23 +17,9 @@ repositories {
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically. // Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html // See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories. // for more information about repositories.
maven { url 'https://maven.siphalor.de/' }
maven { url 'https://jitpack.io' }
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/releases/" }
maven {
name = 'Ladysnake Mods'
url = 'https://ladysnake.jfrog.io/artifactory/mods'
}
maven { maven {
url = "https://api.modrinth.com/maven" url = "https://api.modrinth.com/maven"
} }
maven {
url = uri("https://ueaj.dev/maven")
// for 0.4.2 and older
// url uri("https://raw.githubusercontent.com/Devan-Kerman/Devan-Repo/master/")
}
} }
@ -45,21 +32,9 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway. // Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Uncomment the following line to enable the deprecated Fabric API modules. modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}"
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time. include "maven.modrinth:midnightlib:${project.midnightlib_version}"
include(modApi(platform("de.siphalor.tweed4:tweed4-bom-$project.minecraft_major_version:$project.tweed_version")))
// Pick any modules you want to use, e.g.:
include(modApi("de.siphalor.tweed4:tweed4-base-$project.minecraft_major_version"))
include(modApi("de.siphalor.tweed4:tweed4-annotated-$project.minecraft_major_version"))
include(modApi("de.siphalor.tweed4:tweed4-data-$project.minecraft_major_version"))
include(modApi("de.siphalor.tweed4:tweed4-data-hjson-$project.minecraft_major_version"))
//include(modApi("de.siphalor.tweed4:tweed4-tailor-cloth-$project.minecraft_major_version"))
include(modApi("de.siphalor.tweed4:tweed4-tailor-screen-$project.minecraft_major_version"))
modImplementation("me.shedaniel.cloth:cloth-config-fabric:$project.cloth_config_version")
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}" // modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
} }
@ -79,7 +54,7 @@ processResources {
} }
tasks.withType(JavaCompile).configureEach { tasks.withType(JavaCompile).configureEach {
it.options.release = 17 it.options.release = 21
} }
java { java {
@ -88,8 +63,8 @@ java {
// If you remove this line, sources will not be generated. // If you remove this line, sources will not be generated.
withSourcesJar() withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_17 sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_21
} }
jar { jar {
@ -98,6 +73,18 @@ jar {
} }
} }
import com.modrinth.minotaur.dependencies.DependencyType
import com.modrinth.minotaur.dependencies.ModDependency
modrinth {
projectId = 'vHsuCD0F' // The ID of your Modrinth project. Slugs will not work.
uploadFile = remapJar // Tells Minotaur to use the remapped jar
versionType = "alpha"
dependencies = [
new ModDependency('P7dR8mSH', DependencyType.REQUIRED), //required dependency on Fabric API
new ModDependency('codAaoxh', DependencyType.EMBEDDED), //embedded midnightlib
]
}
// configure the maven publication // configure the maven publication
publishing { publishing {
publications { publications {

View File

@ -1,18 +1,16 @@
org.gradle.jvmargs = -Xmx1G org.gradle.jvmargs = -Xmx1G
#Fabric properties #Fabric properties
minecraft_version=1.20.1 minecraft_version=1.21.4
minecraft_major_version=1.20 yarn_mappings=1.21.4+build.7
yarn_mappings=1.20.1+build.9 loader_version=0.16.9
loader_version=0.14.21
#Fabric api # Fabric API
fabric_version=0.84.0+1.20.1 fabric_version=0.114.0+1.21.4
#Mod properties #Mod properties
mod_version = 0.10.1 mod_version = 0.10.3
maven_group = quimufu.simple_creator maven_group = quimufu.simple_creator
archives_base_name = simple_creator archives_base_name = simple_creator
tweed_version=1.3.0+mc1.20-pre1 midnightlib_version=1.6.6-fabric
cloth_config_version=11.0.99

Binary file not shown.

View File

@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

298
gradlew vendored
View File

@ -1,7 +1,7 @@
#!/usr/bin/env sh #!/bin/sh
# #
# Copyright 2015 the original author or authors. # Copyright © 2015-2021 the original authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -15,80 +15,116 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
# SPDX-License-Identifier: Apache-2.0
#
############################################################################## ##############################################################################
## #
## Gradle start up script for UN*X # 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/HEAD/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 # Attempt to set APP_HOME
# Resolve links: $0 may be a link # Resolve links: $0 may be a link
PRG="$0" app_path=$0
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do # Need this for daisy-chained symlinks.
ls=`ls -ld "$PRG"` while
link=`expr "$ls" : '.*-> \(.*\)$'` APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
if expr "$link" : '/.*' > /dev/null; then [ -h "$app_path" ]
PRG="$link" do
else ls=$( ls -ld "$app_path" )
PRG=`dirname "$PRG"`"/$link" link=${ls#*' -> '}
fi case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle" # This is normally unused
APP_BASE_NAME=`basename "$0"` # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD=maximum
warn () { warn () {
echo "$*" echo "$*"
} } >&2
die () { die () {
echo echo
echo "$*" echo "$*"
echo echo
exit 1 exit 1
} } >&2
# OS specific support (must be 'true' or 'false'). # OS specific support (must be 'true' or 'false').
cygwin=false cygwin=false
msys=false msys=false
darwin=false darwin=false
nonstop=false nonstop=false
case "`uname`" in case "$( uname )" in #(
CYGWIN* ) CYGWIN* ) cygwin=true ;; #(
cygwin=true Darwin* ) darwin=true ;; #(
;; MSYS* | MINGW* ) msys=true ;; #(
Darwin* ) NONSTOP* ) nonstop=true ;;
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables # IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java" JAVACMD=$JAVA_HOME/jre/sh/java
else else
JAVACMD="$JAVA_HOME/bin/java" JAVACMD=$JAVA_HOME/bin/java
fi fi
if [ ! -x "$JAVACMD" ] ; then if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@ -97,92 +133,120 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi fi
else else
JAVACMD="java" JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 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 Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi fi
fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
MAX_FD_LIMIT=`ulimit -H -n` case $MAX_FD in #(
if [ $? -eq 0 ] ; then max*)
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
MAX_FD="$MAX_FD_LIMIT" # shellcheck disable=SC2039,SC3045
fi MAX_FD=$( ulimit -H -n ) ||
ulimit -n $MAX_FD warn "Could not query maximum file descriptor limit"
if [ $? -ne 0 ] ; then esac
warn "Could not set maximum file descriptor limit: $MAX_FD" case $MAX_FD in #(
fi '' | soft) :;; #(
else *)
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
fi # shellcheck disable=SC2039,SC3045
fi ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac esac
fi fi
# Escape application args # Collect all arguments for the java command, stacking in reverse order:
save () { # * args from the command line
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done # * the main class name
echo " " # * -classpath
} # * -D...appname settings
APP_ARGS=$(save "$@") # * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# Collect all arguments for the java command, following the shell quoting and substitution rules # For Cygwin or MSYS, switch paths to Windows format before running java
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong JAVACMD=$( cygpath --unix "$JAVACMD" )
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")" # 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 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, 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" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# 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" "$@" exec "$JAVACMD" "$@"

56
gradlew.bat vendored
View File

@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and @rem See the License for the specific language governing permissions and
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off @if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@ -26,9 +28,13 @@ if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=. if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% 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. @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" set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@ -37,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if %ERRORLEVEL% equ 0 goto execute
echo. echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. echo location of your Java installation. 1>&2
goto fail goto fail
@ -51,48 +57,36 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto execute
echo. echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. echo location of your Java installation. 1>&2
goto fail goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd if %ERRORLEVEL% equ 0 goto mainEnd
:fail :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code! rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 set EXIT_CODE=%ERRORLEVEL%
exit /b 1 if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd :mainEnd
if "%OS%"=="Windows_NT" endlocal if "%OS%"=="Windows_NT" endlocal

View File

@ -4,31 +4,34 @@ import com.google.common.collect.Maps;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.minecraft.block.AbstractBlock; import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.MapColor; import net.minecraft.block.MapColor;
import net.minecraft.block.enums.Instrument; import net.minecraft.block.enums.NoteBlockInstrument;
import net.minecraft.block.piston.PistonBehavior; import net.minecraft.block.piston.PistonBehavior;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.Items;
import net.minecraft.loot.LootTable;
import net.minecraft.registry.Registries; import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry; import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.Pair; import net.minecraft.util.Pair;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Level;
import quimufu.simple_creator.mixin.BlockSettingsAccessor;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import static quimufu.simple_creator.SimpleCreatorMod.log; import static quimufu.simple_creator.SimpleCreatorMod.log;
@ -58,6 +61,7 @@ public class BlockResourceLoader extends GenericManualResourceLoader<Pair<Block,
@Override @Override
protected Pair<Block, Item> deserialize(Pair<Identifier, JsonObject> e) { protected Pair<Block, Item> deserialize(Pair<Identifier, JsonObject> e) {
JsonObject jo = e.getRight(); JsonObject jo = e.getRight();
log(Level.INFO, e.getRight().toString());
// get block information // get block information
BlockSettingsPojo bspj = GSON.fromJson(jo, BlockSettingsPojo.class); BlockSettingsPojo bspj = GSON.fromJson(jo, BlockSettingsPojo.class);
@ -68,9 +72,17 @@ public class BlockResourceLoader extends GenericManualResourceLoader<Pair<Block,
// parse item group // parse item group
String group = bspj.itemGroup; String group = bspj.itemGroup;
RegistryKey<ItemGroup> g = ItemResourceLoader.findGroup(group); RegistryKey<ItemGroup> g = ItemResourceLoader.findGroup(group);
bs.registryKey(RegistryKey.of(Registries.BLOCK.getKey(), e.getLeft()));
//create block and corresponding item //create block and corresponding item
Block resB = new Block(bs); Block resB = new Block(bs);
Item resI = new BlockItem(resB, new FabricItemSettings());
Item.Settings is = new Item.Settings();
is.useBlockPrefixedTranslationKey();
is.registryKey(RegistryKey.of(Registries.ITEM.getKey(), e.getLeft()));
Item resI = new BlockItem(resB, is);
ItemGroupEvents.modifyEntriesEvent(g).register(content -> content.add(resI)); ItemGroupEvents.modifyEntriesEvent(g).register(content -> content.add(resI));
int burnChance = bspj.burnChance; int burnChance = bspj.burnChance;
@ -84,15 +96,14 @@ public class BlockResourceLoader extends GenericManualResourceLoader<Pair<Block,
} }
private Block.Settings getSettings(BlockSettingsPojo bspj) { private Block.Settings getSettings(BlockSettingsPojo bspj) {
FabricBlockSettings fabricBlockSettings = FabricBlockSettings.create(); AbstractBlock.Settings blockSettings = AbstractBlock.Settings.create();
fabricBlockSettings blockSettings
.collidable(bspj.collidable)
.slipperiness(bspj.slipperiness) .slipperiness(bspj.slipperiness)
.velocityMultiplier(bspj.slowDownMultiplier) .velocityMultiplier(bspj.movementVelocityMultiplier)
.jumpVelocityMultiplier(bspj.jumpVelocityMultiplier) .jumpVelocityMultiplier(bspj.jumpVelocityMultiplier)
.sounds(getSoundGroup(bspj.soundGroup)) .sounds(getSoundGroup(bspj.soundGroup))
.drops(getDropTableId(bspj.dropTableId)) .lootTable(Optional.ofNullable(getDropTableId(bspj.dropTableId)))
.mapColor(getMapColor(bspj.mapColor)) .mapColor(getMapColor(bspj.mapColor))
.allowsSpawning(bspj.allowsSpawning ? BlockResourceLoader::always : BlockResourceLoader::never) .allowsSpawning(bspj.allowsSpawning ? BlockResourceLoader::always : BlockResourceLoader::never)
.solidBlock(bspj.solidBlock ? BlockResourceLoader::always : BlockResourceLoader::never) .solidBlock(bspj.solidBlock ? BlockResourceLoader::always : BlockResourceLoader::never)
@ -105,108 +116,88 @@ public class BlockResourceLoader extends GenericManualResourceLoader<Pair<Block,
.offset(getOffset(bspj.modelOffset)) .offset(getOffset(bspj.modelOffset))
.pistonBehavior(getPistonBehavior(bspj.pistonBehavior)) .pistonBehavior(getPistonBehavior(bspj.pistonBehavior))
.instrument(getInstrument(bspj.instrument)) .instrument(getInstrument(bspj.instrument))
.luminance(bspj.lightLevel); .luminance((blockState) -> bspj.lightLevel);
((BlockSettingsAccessor) blockSettings)
.setCollidable(bspj.collidable);
if (bspj.burnable) { if (bspj.burnable) {
fabricBlockSettings.burnable(); blockSettings.burnable();
} }
//not supported for now //not supported for now
//fabricBlockSettings.liquid() //blockSettings.liquid()
if (bspj.solidBlock) { if (bspj.solidBlock) {
fabricBlockSettings.solid(); blockSettings.solid();
} else { } else {
fabricBlockSettings.notSolid(); blockSettings.notSolid();
} }
if (bspj.replaceable) { if (bspj.replaceable) {
fabricBlockSettings.replaceable(); blockSettings.replaceable();
} }
//not supported for now //not supported for now
//fabricBlockSettings.air() //blockSettings.air()
if (bspj.noBlockBreakParticles) { if (bspj.noBlockBreakParticles) {
fabricBlockSettings.noBlockBreakParticles(); blockSettings.noBlockBreakParticles();
} }
if (bspj.requiresTool) { if (bspj.requiresTool) {
fabricBlockSettings.requiresTool(); blockSettings.requiresTool();
} }
if (bspj.breaksInstantly) { if (bspj.breaksInstantly) {
fabricBlockSettings.breakInstantly(); blockSettings.breakInstantly();
} }
if (!bspj.opaque) { if (!bspj.opaque) {
fabricBlockSettings.nonOpaque(); blockSettings.nonOpaque();
} }
return fabricBlockSettings; return blockSettings;
} }
private Instrument getInstrument(String instrument) { private NoteBlockInstrument getInstrument(String instrument) {
switch (instrument.toUpperCase()) { return switch (instrument.toUpperCase()) {
case "HARP": case "HARP" -> NoteBlockInstrument.HARP;
return Instrument.HARP; case "BASEDRUM" -> NoteBlockInstrument.BASEDRUM;
case "BASEDRUM": case "SNARE" -> NoteBlockInstrument.SNARE;
return Instrument.BASEDRUM; case "HAT" -> NoteBlockInstrument.HAT;
case "SNARE": case "BASS" -> NoteBlockInstrument.BASS;
return Instrument.SNARE; case "FLUTE" -> NoteBlockInstrument.FLUTE;
case "HAT": case "BELL" -> NoteBlockInstrument.BELL;
return Instrument.HAT; case "GUITAR" -> NoteBlockInstrument.GUITAR;
case "BASS": case "CHIME" -> NoteBlockInstrument.CHIME;
return Instrument.BASS; case "XYLOPHONE" -> NoteBlockInstrument.XYLOPHONE;
case "FLUTE": case "IRON_XYLOPHONE" -> NoteBlockInstrument.IRON_XYLOPHONE;
return Instrument.FLUTE; case "COW_BELL" -> NoteBlockInstrument.COW_BELL;
case "BELL": case "DIDGERIDOO" -> NoteBlockInstrument.DIDGERIDOO;
return Instrument.BELL; case "BIT" -> NoteBlockInstrument.BIT;
case "GUITAR": case "BANJO" -> NoteBlockInstrument.BANJO;
return Instrument.GUITAR; case "PLING" -> NoteBlockInstrument.PLING;
case "CHIME": case "ZOMBIE" -> NoteBlockInstrument.ZOMBIE;
return Instrument.CHIME; case "SKELETON" -> NoteBlockInstrument.SKELETON;
case "XYLOPHONE": case "CREEPER" -> NoteBlockInstrument.CREEPER;
return Instrument.XYLOPHONE; case "DRAGON" -> NoteBlockInstrument.DRAGON;
case "IRON_XYLOPHONE": case "WITHER_SKELETON" -> NoteBlockInstrument.WITHER_SKELETON;
return Instrument.IRON_XYLOPHONE; case "PIGLIN" -> NoteBlockInstrument.PIGLIN;
case "COW_BELL": case "CUSTOM_HEAD" -> NoteBlockInstrument.CUSTOM_HEAD;
return Instrument.COW_BELL; default -> {
case "DIDGERIDOO":
return Instrument.DIDGERIDOO;
case "BIT":
return Instrument.BIT;
case "BANJO":
return Instrument.BANJO;
case "PLING":
return Instrument.PLING;
case "ZOMBIE":
return Instrument.ZOMBIE;
case "SKELETON":
return Instrument.SKELETON;
case "CREEPER":
return Instrument.CREEPER;
case "DRAGON":
return Instrument.DRAGON;
case "WITHER_SKELETON":
return Instrument.WITHER_SKELETON;
case "PIGLIN":
return Instrument.PIGLIN;
case "CUSTOM_HEAD":
return Instrument.CUSTOM_HEAD;
default:
log(Level.WARN, "Instrument " + instrument + " not found, using harp"); log(Level.WARN, "Instrument " + instrument + " not found, using harp");
return Instrument.HARP; yield NoteBlockInstrument.HARP;
} }
};
} }
private AbstractBlock.OffsetType getOffset(String modelOffset) { private AbstractBlock.OffsetType getOffset(String modelOffset) {
switch (modelOffset.toUpperCase()) { return switch (modelOffset.toUpperCase()) {
case "NONE": case "NONE" -> AbstractBlock.OffsetType.NONE;
return AbstractBlock.OffsetType.NONE; case "XZ" -> AbstractBlock.OffsetType.XZ;
case "XZ": case "XYZ" -> AbstractBlock.OffsetType.XYZ;
return AbstractBlock.OffsetType.XZ; default -> {
case "XYZ":
return AbstractBlock.OffsetType.XYZ;
default:
log(Level.WARN, "ModelOffset " + modelOffset + " not found, using none"); log(Level.WARN, "ModelOffset " + modelOffset + " not found, using none");
return AbstractBlock.OffsetType.NONE; yield AbstractBlock.OffsetType.NONE;
} }
};
} }
@ -235,386 +226,221 @@ public class BlockResourceLoader extends GenericManualResourceLoader<Pair<Block,
} }
private PistonBehavior getPistonBehavior(String pistonBehavior) { private PistonBehavior getPistonBehavior(String pistonBehavior) {
switch (pistonBehavior.toUpperCase()) { return switch (pistonBehavior.toUpperCase()) {
case "NORMAL" -> { case "NORMAL" -> PistonBehavior.NORMAL;
return PistonBehavior.NORMAL; case "DESTROY" -> PistonBehavior.DESTROY;
} case "BLOCK" -> PistonBehavior.BLOCK;
case "DESTROY" -> { case "IGNORE" -> PistonBehavior.IGNORE;
return PistonBehavior.DESTROY; case "PUSH_ONLY" -> PistonBehavior.PUSH_ONLY;
}
case "BLOCK" -> {
return PistonBehavior.BLOCK;
}
case "IGNORE" -> {
return PistonBehavior.IGNORE;
}
case "PUSH_ONLY" -> {
return PistonBehavior.PUSH_ONLY;
}
default -> { default -> {
log(Level.WARN, "Piston Behavior " + pistonBehavior + " not found, using normal"); log(Level.WARN, "Piston Behavior " + pistonBehavior + " not found, using normal");
return PistonBehavior.NORMAL; yield PistonBehavior.NORMAL;
}
} }
};
} }
private MapColor getMapColor(String color) { private MapColor getMapColor(String color) {
switch (color.toUpperCase()) { return switch (color.toUpperCase()) {
case "CLEAR": case "CLEAR" -> MapColor.CLEAR;
return MapColor.CLEAR; case "PALE_GREEN" -> MapColor.PALE_GREEN;
case "PALE_GREEN": case "PALE_YELLOW" -> MapColor.PALE_YELLOW;
return MapColor.PALE_GREEN; case "WHITE_GRAY" -> MapColor.WHITE_GRAY;
case "PALE_YELLOW": case "BRIGHT_RED" -> MapColor.BRIGHT_RED;
return MapColor.PALE_YELLOW; case "PALE_PURPLE" -> MapColor.PALE_PURPLE;
case "WHITE_GRAY": case "IRON_GRAY" -> MapColor.IRON_GRAY;
return MapColor.WHITE_GRAY; case "DARK_GREEN" -> MapColor.DARK_GREEN;
case "BRIGHT_RED": case "WHITE" -> MapColor.WHITE;
return MapColor.BRIGHT_RED; case "LIGHT_BLUE_GRAY" -> MapColor.LIGHT_BLUE_GRAY;
case "PALE_PURPLE": case "DIRT_BROWN" -> MapColor.DIRT_BROWN;
return MapColor.PALE_PURPLE; case "STONE_GRAY" -> MapColor.STONE_GRAY;
case "IRON_GRAY": case "WATER_BLUE" -> MapColor.WATER_BLUE;
return MapColor.IRON_GRAY; case "OAK_TAN" -> MapColor.OAK_TAN;
case "DARK_GREEN": case "OFF_WHITE" -> MapColor.OFF_WHITE;
return MapColor.DARK_GREEN; case "ORANGE" -> MapColor.ORANGE;
case "WHITE": case "MAGENTA" -> MapColor.MAGENTA;
return MapColor.WHITE; case "LIGHT_BLUE" -> MapColor.LIGHT_BLUE;
case "LIGHT_BLUE_GRAY": case "YELLOW" -> MapColor.YELLOW;
return MapColor.LIGHT_BLUE_GRAY; case "LIME" -> MapColor.LIME;
case "DIRT_BROWN": case "PINK" -> MapColor.PINK;
return MapColor.DIRT_BROWN; case "GRAY" -> MapColor.GRAY;
case "STONE_GRAY": case "LIGHT_GRAY" -> MapColor.LIGHT_GRAY;
return MapColor.STONE_GRAY; case "CYAN" -> MapColor.CYAN;
case "WATER_BLUE": case "PURPLE" -> MapColor.PURPLE;
return MapColor.WATER_BLUE; case "BLUE" -> MapColor.BLUE;
case "OAK_TAN": case "BROWN" -> MapColor.BROWN;
return MapColor.OAK_TAN; case "GREEN" -> MapColor.GREEN;
case "OFF_WHITE": case "RED" -> MapColor.RED;
return MapColor.OFF_WHITE; case "BLACK" -> MapColor.BLACK;
case "ORANGE": case "GOLD" -> MapColor.GOLD;
return MapColor.ORANGE; case "DIAMOND_BLUE" -> MapColor.DIAMOND_BLUE;
case "MAGENTA": case "LAPIS_BLUE" -> MapColor.LAPIS_BLUE;
return MapColor.MAGENTA; case "EMERALD_GREEN" -> MapColor.EMERALD_GREEN;
case "LIGHT_BLUE": case "SPRUCE_BROWN" -> MapColor.SPRUCE_BROWN;
return MapColor.LIGHT_BLUE; case "DARK_RED" -> MapColor.DARK_RED;
case "YELLOW": case "TERRACOTTA_WHITE" -> MapColor.TERRACOTTA_WHITE;
return MapColor.YELLOW; case "TERRACOTTA_ORANGE" -> MapColor.TERRACOTTA_ORANGE;
case "LIME": case "TERRACOTTA_MAGENTA" -> MapColor.TERRACOTTA_MAGENTA;
return MapColor.LIME; case "TERRACOTTA_LIGHT_BLUE" -> MapColor.TERRACOTTA_LIGHT_BLUE;
case "PINK": case "TERRACOTTA_YELLOW" -> MapColor.TERRACOTTA_YELLOW;
return MapColor.PINK; case "TERRACOTTA_LIME" -> MapColor.TERRACOTTA_LIME;
case "GRAY": case "TERRACOTTA_PINK" -> MapColor.TERRACOTTA_PINK;
return MapColor.GRAY; case "TERRACOTTA_GRAY" -> MapColor.TERRACOTTA_GRAY;
case "LIGHT_GRAY": case "TERRACOTTA_LIGHT_GRAY" -> MapColor.TERRACOTTA_LIGHT_GRAY;
return MapColor.LIGHT_GRAY; case "TERRACOTTA_CYAN" -> MapColor.TERRACOTTA_CYAN;
case "CYAN": case "TERRACOTTA_PURPLE" -> MapColor.TERRACOTTA_PURPLE;
return MapColor.CYAN; case "TERRACOTTA_BLUE" -> MapColor.TERRACOTTA_BLUE;
case "PURPLE": case "TERRACOTTA_BROWN" -> MapColor.TERRACOTTA_BROWN;
return MapColor.PURPLE; case "TERRACOTTA_GREEN" -> MapColor.TERRACOTTA_GREEN;
case "BLUE": case "TERRACOTTA_RED" -> MapColor.TERRACOTTA_RED;
return MapColor.BLUE; case "TERRACOTTA_BLACK" -> MapColor.TERRACOTTA_BLACK;
case "BROWN": case "DULL_RED" -> MapColor.DULL_RED;
return MapColor.BROWN; case "DULL_PINK" -> MapColor.DULL_PINK;
case "GREEN": case "DARK_CRIMSON" -> MapColor.DARK_CRIMSON;
return MapColor.GREEN; case "TEAL" -> MapColor.TEAL;
case "RED": case "DARK_AQUA" -> MapColor.DARK_AQUA;
return MapColor.RED; case "DARK_DULL_PINK" -> MapColor.DARK_DULL_PINK;
case "BLACK": case "BRIGHT_TEAL" -> MapColor.BRIGHT_TEAL;
return MapColor.BLACK; case "DEEPSLATE_GRAY" -> MapColor.DEEPSLATE_GRAY;
case "GOLD": case "RAW_IRON_PINK" -> MapColor.RAW_IRON_PINK;
return MapColor.GOLD; case "LICHEN_GREEN" -> MapColor.LICHEN_GREEN;
case "DIAMOND_BLUE": default -> {
return MapColor.DIAMOND_BLUE;
case "LAPIS_BLUE":
return MapColor.LAPIS_BLUE;
case "EMERALD_GREEN":
return MapColor.EMERALD_GREEN;
case "SPRUCE_BROWN":
return MapColor.SPRUCE_BROWN;
case "DARK_RED":
return MapColor.DARK_RED;
case "TERRACOTTA_WHITE":
return MapColor.TERRACOTTA_WHITE;
case "TERRACOTTA_ORANGE":
return MapColor.TERRACOTTA_ORANGE;
case "TERRACOTTA_MAGENTA":
return MapColor.TERRACOTTA_MAGENTA;
case "TERRACOTTA_LIGHT_BLUE":
return MapColor.TERRACOTTA_LIGHT_BLUE;
case "TERRACOTTA_YELLOW":
return MapColor.TERRACOTTA_YELLOW;
case "TERRACOTTA_LIME":
return MapColor.TERRACOTTA_LIME;
case "TERRACOTTA_PINK":
return MapColor.TERRACOTTA_PINK;
case "TERRACOTTA_GRAY":
return MapColor.TERRACOTTA_GRAY;
case "TERRACOTTA_LIGHT_GRAY":
return MapColor.TERRACOTTA_LIGHT_GRAY;
case "TERRACOTTA_CYAN":
return MapColor.TERRACOTTA_CYAN;
case "TERRACOTTA_PURPLE":
return MapColor.TERRACOTTA_PURPLE;
case "TERRACOTTA_BLUE":
return MapColor.TERRACOTTA_BLUE;
case "TERRACOTTA_BROWN":
return MapColor.TERRACOTTA_BROWN;
case "TERRACOTTA_GREEN":
return MapColor.TERRACOTTA_GREEN;
case "TERRACOTTA_RED":
return MapColor.TERRACOTTA_RED;
case "TERRACOTTA_BLACK":
return MapColor.TERRACOTTA_BLACK;
case "DULL_RED":
return MapColor.DULL_RED;
case "DULL_PINK":
return MapColor.DULL_PINK;
case "DARK_CRIMSON":
return MapColor.DARK_CRIMSON;
case "TEAL":
return MapColor.TEAL;
case "DARK_AQUA":
return MapColor.DARK_AQUA;
case "DARK_DULL_PINK":
return MapColor.DARK_DULL_PINK;
case "BRIGHT_TEAL":
return MapColor.BRIGHT_TEAL;
case "DEEPSLATE_GRAY":
return MapColor.DEEPSLATE_GRAY;
case "RAW_IRON_PINK":
return MapColor.RAW_IRON_PINK;
case "LICHEN_GREEN":
return MapColor.LICHEN_GREEN;
default:
log(Level.WARN, "MapColor " + color + " not found, using pink"); log(Level.WARN, "MapColor " + color + " not found, using pink");
return MapColor.PINK; yield MapColor.PINK;
} }
};
} }
private Identifier getDropTableId(String s) { private RegistryKey<LootTable> getDropTableId(String s) {
if (s == null) if (s == null)
return null; return null;
Identifier i = Identifier.tryParse(s); Identifier i = Identifier.tryParse(s);
if (i == null) { if (i == null) {
log(Level.WARN, "Drop table invalid " + s + ", using default"); log(Level.WARN, "Drop table invalid " + s + ", using default");
i = null;
} }
return i; return RegistryKey.of(RegistryKeys.LOOT_TABLE, i);
} }
private BlockSoundGroup getSoundGroup(String s) { private BlockSoundGroup getSoundGroup(String s) {
switch (s.toUpperCase()) { return switch (s.toUpperCase()) {
case "INTENTIONALLY_EMPTY": case "INTENTIONALLY_EMPTY" -> BlockSoundGroup.INTENTIONALLY_EMPTY;
return BlockSoundGroup.INTENTIONALLY_EMPTY; case "WOOD" -> BlockSoundGroup.WOOD;
case "WOOD": case "GRAVEL" -> BlockSoundGroup.GRAVEL;
return BlockSoundGroup.WOOD; case "GRASS" -> BlockSoundGroup.GRASS;
case "GRAVEL": case "LILY_PAD" -> BlockSoundGroup.LILY_PAD;
return BlockSoundGroup.GRAVEL; case "STONE" -> BlockSoundGroup.STONE;
case "GRASS": case "METAL" -> BlockSoundGroup.METAL;
return BlockSoundGroup.GRASS; case "GLASS" -> BlockSoundGroup.GLASS;
case "LILY_PAD": case "WOOL" -> BlockSoundGroup.WOOL;
return BlockSoundGroup.LILY_PAD; case "SAND" -> BlockSoundGroup.SAND;
case "STONE": case "SNOW" -> BlockSoundGroup.SNOW;
return BlockSoundGroup.STONE; case "POWDER_SNOW" -> BlockSoundGroup.POWDER_SNOW;
case "METAL": case "LADDER" -> BlockSoundGroup.LADDER;
return BlockSoundGroup.METAL; case "ANVIL" -> BlockSoundGroup.ANVIL;
case "GLASS": case "SLIME" -> BlockSoundGroup.SLIME;
return BlockSoundGroup.GLASS; case "HONEY" -> BlockSoundGroup.HONEY;
case "WOOL": case "WET_GRASS" -> BlockSoundGroup.WET_GRASS;
return BlockSoundGroup.WOOL; case "CORAL" -> BlockSoundGroup.CORAL;
case "SAND": case "BAMBOO" -> BlockSoundGroup.BAMBOO;
return BlockSoundGroup.SAND; case "BAMBOO_SAPLING" -> BlockSoundGroup.BAMBOO_SAPLING;
case "SNOW": case "SCAFFOLDING" -> BlockSoundGroup.SCAFFOLDING;
return BlockSoundGroup.SNOW; case "SWEET_BERRY_BUSH" -> BlockSoundGroup.SWEET_BERRY_BUSH;
case "POWDER_SNOW": case "CROP" -> BlockSoundGroup.CROP;
return BlockSoundGroup.POWDER_SNOW; case "STEM" -> BlockSoundGroup.STEM;
case "LADDER": case "VINE" -> BlockSoundGroup.VINE;
return BlockSoundGroup.LADDER; case "NETHER_WART" -> BlockSoundGroup.NETHER_WART;
case "ANVIL": case "LANTERN" -> BlockSoundGroup.LANTERN;
return BlockSoundGroup.ANVIL; case "NETHER_STEM" -> BlockSoundGroup.NETHER_STEM;
case "SLIME": case "NYLIUM" -> BlockSoundGroup.NYLIUM;
return BlockSoundGroup.SLIME; case "FUNGUS" -> BlockSoundGroup.FUNGUS;
case "HONEY": case "ROOTS" -> BlockSoundGroup.ROOTS;
return BlockSoundGroup.HONEY; case "SHROOMLIGHT" -> BlockSoundGroup.SHROOMLIGHT;
case "WET_GRASS": case "WEEPING_VINES" -> BlockSoundGroup.WEEPING_VINES;
return BlockSoundGroup.WET_GRASS; case "WEEPING_VINES_LOW_PITCH" -> BlockSoundGroup.WEEPING_VINES_LOW_PITCH;
case "CORAL": case "SOUL_SAND" -> BlockSoundGroup.SOUL_SAND;
return BlockSoundGroup.CORAL; case "SOUL_SOIL" -> BlockSoundGroup.SOUL_SOIL;
case "BAMBOO": case "BASALT" -> BlockSoundGroup.BASALT;
return BlockSoundGroup.BAMBOO; case "WART_BLOCK" -> BlockSoundGroup.WART_BLOCK;
case "BAMBOO_SAPLING": case "NETHERRACK" -> BlockSoundGroup.NETHERRACK;
return BlockSoundGroup.BAMBOO_SAPLING; case "NETHER_BRICKS" -> BlockSoundGroup.NETHER_BRICKS;
case "SCAFFOLDING": case "NETHER_SPROUTS" -> BlockSoundGroup.NETHER_SPROUTS;
return BlockSoundGroup.SCAFFOLDING; case "NETHER_ORE" -> BlockSoundGroup.NETHER_ORE;
case "SWEET_BERRY_BUSH": case "BONE" -> BlockSoundGroup.BONE;
return BlockSoundGroup.SWEET_BERRY_BUSH; case "NETHERITE" -> BlockSoundGroup.NETHERITE;
case "CROP": case "ANCIENT_DEBRIS" -> BlockSoundGroup.ANCIENT_DEBRIS;
return BlockSoundGroup.CROP; case "LODESTONE" -> BlockSoundGroup.LODESTONE;
case "STEM": case "CHAIN" -> BlockSoundGroup.CHAIN;
return BlockSoundGroup.STEM; case "NETHER_GOLD_ORE" -> BlockSoundGroup.NETHER_GOLD_ORE;
case "VINE": case "GILDED_BLACKSTONE" -> BlockSoundGroup.GILDED_BLACKSTONE;
return BlockSoundGroup.VINE; case "CANDLE" -> BlockSoundGroup.CANDLE;
case "NETHER_WART": case "AMETHYST_BLOCK" -> BlockSoundGroup.AMETHYST_BLOCK;
return BlockSoundGroup.NETHER_WART; case "AMETHYST_CLUSTER" -> BlockSoundGroup.AMETHYST_CLUSTER;
case "LANTERN": case "SMALL_AMETHYST_BUD" -> BlockSoundGroup.SMALL_AMETHYST_BUD;
return BlockSoundGroup.LANTERN; case "MEDIUM_AMETHYST_BUD" -> BlockSoundGroup.MEDIUM_AMETHYST_BUD;
case "NETHER_STEM": case "LARGE_AMETHYST_BUD" -> BlockSoundGroup.LARGE_AMETHYST_BUD;
return BlockSoundGroup.NETHER_STEM; case "TUFF" -> BlockSoundGroup.TUFF;
case "NYLIUM": case "TUFF_BRICKS" -> BlockSoundGroup.TUFF_BRICKS;
return BlockSoundGroup.NYLIUM; case "POLISHED_TUFF" -> BlockSoundGroup.POLISHED_TUFF;
case "FUNGUS": case "CALCITE" -> BlockSoundGroup.CALCITE;
return BlockSoundGroup.FUNGUS; case "DRIPSTONE_BLOCK" -> BlockSoundGroup.DRIPSTONE_BLOCK;
case "ROOTS": case "POINTED_DRIPSTONE" -> BlockSoundGroup.POINTED_DRIPSTONE;
return BlockSoundGroup.ROOTS; case "COPPER" -> BlockSoundGroup.COPPER;
case "SHROOMLIGHT": case "COPPER_BULB" -> BlockSoundGroup.COPPER_BULB;
return BlockSoundGroup.SHROOMLIGHT; case "COPPER_GRATE" -> BlockSoundGroup.COPPER_GRATE;
case "WEEPING_VINES": case "CAVE_VINES" -> BlockSoundGroup.CAVE_VINES;
return BlockSoundGroup.WEEPING_VINES; case "SPORE_BLOSSOM" -> BlockSoundGroup.SPORE_BLOSSOM;
case "WEEPING_VINES_LOW_PITCH": case "AZALEA" -> BlockSoundGroup.AZALEA;
return BlockSoundGroup.WEEPING_VINES_LOW_PITCH; case "FLOWERING_AZALEA" -> BlockSoundGroup.FLOWERING_AZALEA;
case "SOUL_SAND": case "MOSS_CARPET" -> BlockSoundGroup.MOSS_CARPET;
return BlockSoundGroup.SOUL_SAND; case "PINK_PETALS" -> BlockSoundGroup.PINK_PETALS;
case "SOUL_SOIL": case "MOSS_BLOCK" -> BlockSoundGroup.MOSS_BLOCK;
return BlockSoundGroup.SOUL_SOIL; case "BIG_DRIPLEAF" -> BlockSoundGroup.BIG_DRIPLEAF;
case "BASALT": case "SMALL_DRIPLEAF" -> BlockSoundGroup.SMALL_DRIPLEAF;
return BlockSoundGroup.BASALT; case "ROOTED_DIRT" -> BlockSoundGroup.ROOTED_DIRT;
case "WART_BLOCK": case "HANGING_ROOTS" -> BlockSoundGroup.HANGING_ROOTS;
return BlockSoundGroup.WART_BLOCK; case "AZALEA_LEAVES" -> BlockSoundGroup.AZALEA_LEAVES;
case "NETHERRACK": case "SCULK_SENSOR" -> BlockSoundGroup.SCULK_SENSOR;
return BlockSoundGroup.NETHERRACK; case "SCULK_CATALYST" -> BlockSoundGroup.SCULK_CATALYST;
case "NETHER_BRICKS": case "SCULK" -> BlockSoundGroup.SCULK;
return BlockSoundGroup.NETHER_BRICKS; case "SCULK_VEIN" -> BlockSoundGroup.SCULK_VEIN;
case "NETHER_SPROUTS": case "SCULK_SHRIEKER" -> BlockSoundGroup.SCULK_SHRIEKER;
return BlockSoundGroup.NETHER_SPROUTS; case "GLOW_LICHEN" -> BlockSoundGroup.GLOW_LICHEN;
case "NETHER_ORE": case "DEEPSLATE" -> BlockSoundGroup.DEEPSLATE;
return BlockSoundGroup.NETHER_ORE; case "DEEPSLATE_BRICKS" -> BlockSoundGroup.DEEPSLATE_BRICKS;
case "BONE": case "DEEPSLATE_TILES" -> BlockSoundGroup.DEEPSLATE_TILES;
return BlockSoundGroup.BONE; case "POLISHED_DEEPSLATE" -> BlockSoundGroup.POLISHED_DEEPSLATE;
case "NETHERITE": case "FROGLIGHT" -> BlockSoundGroup.FROGLIGHT;
return BlockSoundGroup.NETHERITE; case "FROGSPAWN" -> BlockSoundGroup.FROGSPAWN;
case "ANCIENT_DEBRIS": case "MANGROVE_ROOTS" -> BlockSoundGroup.MANGROVE_ROOTS;
return BlockSoundGroup.ANCIENT_DEBRIS; case "MUDDY_MANGROVE_ROOTS" -> BlockSoundGroup.MUDDY_MANGROVE_ROOTS;
case "LODESTONE": case "MUD" -> BlockSoundGroup.MUD;
return BlockSoundGroup.LODESTONE; case "MUD_BRICKS" -> BlockSoundGroup.MUD_BRICKS;
case "CHAIN": case "PACKED_MUD" -> BlockSoundGroup.PACKED_MUD;
return BlockSoundGroup.CHAIN; case "HANGING_SIGN" -> BlockSoundGroup.HANGING_SIGN;
case "NETHER_GOLD_ORE": case "NETHER_WOOD_HANGING_SIGN" -> BlockSoundGroup.NETHER_WOOD_HANGING_SIGN;
return BlockSoundGroup.NETHER_GOLD_ORE; case "BAMBOO_WOOD_HANGING_SIGN" -> BlockSoundGroup.BAMBOO_WOOD_HANGING_SIGN;
case "GILDED_BLACKSTONE": case "BAMBOO_WOOD" -> BlockSoundGroup.BAMBOO_WOOD;
return BlockSoundGroup.GILDED_BLACKSTONE; case "NETHER_WOOD" -> BlockSoundGroup.NETHER_WOOD;
case "CANDLE": case "CHERRY_WOOD" -> BlockSoundGroup.CHERRY_WOOD;
return BlockSoundGroup.CANDLE; case "CHERRY_SAPLING" -> BlockSoundGroup.CHERRY_SAPLING;
case "AMETHYST_BLOCK": case "CHERRY_LEAVES" -> BlockSoundGroup.CHERRY_LEAVES;
return BlockSoundGroup.AMETHYST_BLOCK; case "CHERRY_WOOD_HANGING_SIGN" -> BlockSoundGroup.CHERRY_WOOD_HANGING_SIGN;
case "AMETHYST_CLUSTER": case "CHISELED_BOOKSHELF" -> BlockSoundGroup.CHISELED_BOOKSHELF;
return BlockSoundGroup.AMETHYST_CLUSTER; case "SUSPICIOUS_SAND" -> BlockSoundGroup.SUSPICIOUS_SAND;
case "SMALL_AMETHYST_BUD": case "SUSPICIOUS_GRAVEL" -> BlockSoundGroup.SUSPICIOUS_GRAVEL;
return BlockSoundGroup.SMALL_AMETHYST_BUD; case "DECORATED_POT" -> BlockSoundGroup.DECORATED_POT;
case "MEDIUM_AMETHYST_BUD": case "DECORATED_POT_SHATTER" -> BlockSoundGroup.DECORATED_POT_SHATTER;
return BlockSoundGroup.MEDIUM_AMETHYST_BUD; case "TRIAL_SPAWNER" -> BlockSoundGroup.TRIAL_SPAWNER;
case "LARGE_AMETHYST_BUD": case "SPONGE" -> BlockSoundGroup.SPONGE;
return BlockSoundGroup.LARGE_AMETHYST_BUD; case "WET_SPONGE" -> BlockSoundGroup.WET_SPONGE;
case "TUFF": case "VAULT" -> BlockSoundGroup.VAULT;
return BlockSoundGroup.TUFF; case "HEAVY_CORE" -> BlockSoundGroup.HEAVY_CORE;
case "CALCITE": case "COBWEB" -> BlockSoundGroup.COBWEB;
return BlockSoundGroup.CALCITE; default -> {
case "DRIPSTONE_BLOCK":
return BlockSoundGroup.DRIPSTONE_BLOCK;
case "POINTED_DRIPSTONE":
return BlockSoundGroup.POINTED_DRIPSTONE;
case "COPPER":
return BlockSoundGroup.COPPER;
case "CAVE_VINES":
return BlockSoundGroup.CAVE_VINES;
case "SPORE_BLOSSOM":
return BlockSoundGroup.SPORE_BLOSSOM;
case "AZALEA":
return BlockSoundGroup.AZALEA;
case "FLOWERING_AZALEA":
return BlockSoundGroup.FLOWERING_AZALEA;
case "MOSS_CARPET":
return BlockSoundGroup.MOSS_CARPET;
case "PINK_PETALS":
return BlockSoundGroup.PINK_PETALS;
case "MOSS_BLOCK":
return BlockSoundGroup.MOSS_BLOCK;
case "BIG_DRIPLEAF":
return BlockSoundGroup.BIG_DRIPLEAF;
case "SMALL_DRIPLEAF":
return BlockSoundGroup.SMALL_DRIPLEAF;
case "ROOTED_DIRT":
return BlockSoundGroup.ROOTED_DIRT;
case "HANGING_ROOTS":
return BlockSoundGroup.HANGING_ROOTS;
case "AZALEA_LEAVES":
return BlockSoundGroup.AZALEA_LEAVES;
case "SCULK_SENSOR":
return BlockSoundGroup.SCULK_SENSOR;
case "SCULK_CATALYST":
return BlockSoundGroup.SCULK_CATALYST;
case "SCULK":
return BlockSoundGroup.SCULK;
case "SCULK_VEIN":
return BlockSoundGroup.SCULK_VEIN;
case "SCULK_SHRIEKER":
return BlockSoundGroup.SCULK_SHRIEKER;
case "GLOW_LICHEN":
return BlockSoundGroup.GLOW_LICHEN;
case "DEEPSLATE":
return BlockSoundGroup.DEEPSLATE;
case "DEEPSLATE_BRICKS":
return BlockSoundGroup.DEEPSLATE_BRICKS;
case "DEEPSLATE_TILES":
return BlockSoundGroup.DEEPSLATE_TILES;
case "POLISHED_DEEPSLATE":
return BlockSoundGroup.POLISHED_DEEPSLATE;
case "FROGLIGHT":
return BlockSoundGroup.FROGLIGHT;
case "FROGSPAWN":
return BlockSoundGroup.FROGSPAWN;
case "MANGROVE_ROOTS":
return BlockSoundGroup.MANGROVE_ROOTS;
case "MUDDY_MANGROVE_ROOTS":
return BlockSoundGroup.MUDDY_MANGROVE_ROOTS;
case "MUD":
return BlockSoundGroup.MUD;
case "MUD_BRICKS":
return BlockSoundGroup.MUD_BRICKS;
case "PACKED_MUD":
return BlockSoundGroup.PACKED_MUD;
case "HANGING_SIGN":
return BlockSoundGroup.HANGING_SIGN;
case "NETHER_WOOD_HANGING_SIGN":
return BlockSoundGroup.NETHER_WOOD_HANGING_SIGN;
case "BAMBOO_WOOD_HANGING_SIGN":
return BlockSoundGroup.BAMBOO_WOOD_HANGING_SIGN;
case "BAMBOO_WOOD":
return BlockSoundGroup.BAMBOO_WOOD;
case "NETHER_WOOD":
return BlockSoundGroup.NETHER_WOOD;
case "CHERRY_WOOD":
return BlockSoundGroup.CHERRY_WOOD;
case "CHERRY_SAPLING":
return BlockSoundGroup.CHERRY_SAPLING;
case "CHERRY_LEAVES":
return BlockSoundGroup.CHERRY_LEAVES;
case "CHERRY_WOOD_HANGING_SIGN":
return BlockSoundGroup.CHERRY_WOOD_HANGING_SIGN;
case "CHISELED_BOOKSHELF":
return BlockSoundGroup.CHISELED_BOOKSHELF;
case "SUSPICIOUS_SAND":
return BlockSoundGroup.SUSPICIOUS_SAND;
case "SUSPICIOUS_GRAVEL":
return BlockSoundGroup.SUSPICIOUS_GRAVEL;
case "DECORATED_POT":
return BlockSoundGroup.DECORATED_POT;
case "DECORATED_POT_SHATTER":
return BlockSoundGroup.DECORATED_POT_SHATTER;
default:
log(Level.WARN, "Sound group " + s + " not found, using stone"); log(Level.WARN, "Sound group " + s + " not found, using stone");
return BlockSoundGroup.STONE; yield BlockSoundGroup.STONE;
} }
};
} }

View File

@ -10,7 +10,7 @@ public class BlockSettingsPojo {
public float explosionResistance = 6.0F; public float explosionResistance = 6.0F;
public float hardness = 1.5F; public float hardness = 1.5F;
public float slipperiness = 0.6F; public float slipperiness = 0.6F;
public float slowDownMultiplier = 1.0F; public float movementVelocityMultiplier = 1.0F;
public float jumpVelocityMultiplier = 1.0F; public float jumpVelocityMultiplier = 1.0F;
public boolean opaque = true; public boolean opaque = true;
public boolean allowsSpawning = true; public boolean allowsSpawning = true;

View File

@ -2,15 +2,19 @@ package quimufu.simple_creator;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.Pair; import net.minecraft.util.Pair;
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Level;
import java.io.*; import java.io.*;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Optional;
import static quimufu.simple_creator.SimpleCreatorMod.MOD_ID;
import static quimufu.simple_creator.SimpleCreatorMod.log; import static quimufu.simple_creator.SimpleCreatorMod.log;
public abstract class GenericManualResourceLoader<T> { public abstract class GenericManualResourceLoader<T> {
@ -43,7 +47,7 @@ public abstract class GenericManualResourceLoader<T> {
public void load() { public void load() {
if (true) { if (SimpleCreatorConfig.enableTestThings) {
createFromResource("simple_creator/blocks/test_block.json"); createFromResource("simple_creator/blocks/test_block.json");
createFromResource("simple_creator/items/test_item.json"); createFromResource("simple_creator/items/test_item.json");
} }
@ -84,7 +88,7 @@ public abstract class GenericManualResourceLoader<T> {
continue; continue;
} }
String entryName = blockJsonName.substring(0,blockJsonName.length()-5); String entryName = blockJsonName.substring(0,blockJsonName.length()-5);
Identifier identifier = new Identifier(modId, entryName); Identifier identifier = Identifier.of(modId, entryName);
try (Reader reader = new FileReader(entryJson)) { try (Reader reader = new FileReader(entryJson)) {
JsonObject jsonObject = gson.fromJson(reader, JsonObject.class); JsonObject jsonObject = gson.fromJson(reader, JsonObject.class);
@ -103,10 +107,21 @@ public abstract class GenericManualResourceLoader<T> {
} }
private static void createFromResource(String path) { private static void createFromResource(String path) {
try (InputStream blocks = ClassLoader.getSystemClassLoader().getResourceAsStream("data/" + path)) { Optional<ModContainer> modContainerOp = FabricLoader.getInstance().getModContainer(MOD_ID);
if(modContainerOp.isEmpty()){
log(Level.ERROR,"ModContainer " + MOD_ID + " not Found" );
return;
}
Optional<Path> nioPath = modContainerOp
.flatMap(modContainer -> modContainer.findPath("data/" + path));
if(nioPath.isEmpty()){
log(Level.ERROR,"data/" + path + " Not Found" );
return;
}
try (InputStream blocks = Files.newInputStream(nioPath.get())) {
File file = new File("./simplyCreated/" + path); File file = new File("./simplyCreated/" + path);
if (!file.exists() && blocks != null) { if (!file.exists()) {
File parent = file.getParentFile(); File parent = file.getParentFile();
if (parent != null && !parent.exists() && !parent.mkdirs()) { if (parent != null && !parent.exists() && !parent.mkdirs()) {

View File

@ -3,15 +3,20 @@ package quimufu.simple_creator;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gson.*; import com.google.gson.*;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.component.type.ConsumableComponent;
import net.minecraft.component.type.ConsumableComponents;
import net.minecraft.component.type.FoodComponent;
import net.minecraft.entity.effect.StatusEffect; import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemGroups; import net.minecraft.item.ItemGroups;
import net.minecraft.item.Items;
import net.minecraft.item.consume.ApplyEffectsConsumeEffect;
import net.minecraft.registry.Registries; import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry; import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper; import net.minecraft.util.JsonHelper;
import net.minecraft.util.Pair; import net.minecraft.util.Pair;
@ -57,7 +62,7 @@ public class ItemResourceLoader extends GenericManualResourceLoader<Item> {
} }
settings.maxCount(stackSize); settings.maxCount(stackSize);
JsonObject jsonFoodObject = JsonHelper.getObject(jo, "food"); JsonObject jsonFoodObject = JsonHelper.getObject(jo, "food");
settings.food(deserializeFoodComponent(jsonFoodObject)); settings.food(deserializeFoodComponent(jsonFoodObject), deserializeEffectComponent(jsonFoodObject));
} else if (durability != 0 && stackSize != 1) { } else if (durability != 0 && stackSize != 1) {
log(Level.WARN, "durability and stackSize do not work together"); log(Level.WARN, "durability and stackSize do not work together");
log(Level.WARN, "ignoring stackSize"); log(Level.WARN, "ignoring stackSize");
@ -70,6 +75,7 @@ public class ItemResourceLoader extends GenericManualResourceLoader<Item> {
} }
} }
settings.rarity(findRarity(rarity)); settings.rarity(findRarity(rarity));
settings.registryKey(RegistryKey.of(Registries.ITEM.getKey(), e.getLeft()));
Item item = new Item(settings); Item item = new Item(settings);
@ -78,6 +84,17 @@ public class ItemResourceLoader extends GenericManualResourceLoader<Item> {
return item; return item;
} }
private ConsumableComponent deserializeEffectComponent(JsonObject jo) {
ConsumableComponent.Builder ccb = ConsumableComponents.food();
if (JsonHelper.getBoolean(jo, "isFast", false))
ccb.consumeSeconds(0.8f);
if (JsonHelper.hasArray(jo, "effects")) {
JsonArray jsonEffectsArray = JsonHelper.getArray(jo, "effects");
deserializeEffects(ccb, jsonEffectsArray);
}
return ccb.build();
}
@Override @Override
protected void save(Identifier id, Item item) { protected void save(Identifier id, Item item) {
items.put(id, item); items.put(id, item);
@ -86,25 +103,17 @@ public class ItemResourceLoader extends GenericManualResourceLoader<Item> {
private static FoodComponent deserializeFoodComponent(JsonObject jo) { private static FoodComponent deserializeFoodComponent(JsonObject jo) {
FoodComponent fc; FoodComponent fc;
FoodComponent.Builder fcb = new FoodComponent.Builder(); FoodComponent.Builder fcb = new FoodComponent.Builder();
fcb.hunger(JsonHelper.getInt(jo, "hunger", 4)); fcb.nutrition(JsonHelper.getInt(jo, "hunger", 4));
fcb.saturationModifier(JsonHelper.getFloat(jo, "saturationModifier", 0.3F)); fcb.saturationModifier(JsonHelper.getFloat(jo, "saturationModifier", 0.3F));
if (JsonHelper.getBoolean(jo, "isAlwaysEdible", false)) if (JsonHelper.getBoolean(jo, "isAlwaysEdible", false))
fcb.alwaysEdible(); fcb.alwaysEdible();
if (JsonHelper.getBoolean(jo, "isWolfFood", false))
fcb.meat();
if (JsonHelper.getBoolean(jo, "isFast", false))
fcb.snack();
if (JsonHelper.hasArray(jo, "effects")) {
JsonArray jsonEffectsArray = JsonHelper.getArray(jo, "effects");
deserializeEffects(fcb, jsonEffectsArray);
}
fc = fcb.build(); fc = fcb.build();
return fc; return fc;
} }
private static void deserializeEffects(FoodComponent.Builder fcb, JsonArray ja) { private static void deserializeEffects(ConsumableComponent.Builder ccb, JsonArray ja) {
for (JsonElement e : ja) { for (JsonElement e : ja) {
StatusEffect type; RegistryEntry<StatusEffect> type;
int duration = 0; int duration = 0;
int amplifier = 0; int amplifier = 0;
boolean ambient = false; boolean ambient = false;
@ -114,9 +123,9 @@ public class ItemResourceLoader extends GenericManualResourceLoader<Item> {
String effect = JsonHelper.getString(jo, "effect"); String effect = JsonHelper.getString(jo, "effect");
Identifier ei = Identifier.tryParse(effect); Identifier ei = Identifier.tryParse(effect);
if (ei != null) { if (ei != null) {
StatusEffect se = Registries.STATUS_EFFECT.get(ei); Optional<RegistryEntry.Reference<StatusEffect>> se = Registries.STATUS_EFFECT.getEntry(ei);
if (se != null) { if (se.isPresent()) {
type = se; type = se.get();
} else { } else {
log(Level.WARN, "Effect " + ei + " not found, skipping"); log(Level.WARN, "Effect " + ei + " not found, skipping");
continue; continue;
@ -130,13 +139,13 @@ public class ItemResourceLoader extends GenericManualResourceLoader<Item> {
ambient = JsonHelper.getBoolean(jo, "ambient", ambient); ambient = JsonHelper.getBoolean(jo, "ambient", ambient);
visible = JsonHelper.getBoolean(jo, "visible", visible); visible = JsonHelper.getBoolean(jo, "visible", visible);
chance = JsonHelper.getFloat(jo, "chance", chance); chance = JsonHelper.getFloat(jo, "chance", chance);
fcb.statusEffect(new StatusEffectInstance(type, duration, amplifier, ambient, visible), chance); ccb.consumeEffect(new ApplyEffectsConsumeEffect(new StatusEffectInstance(type, duration, amplifier, ambient, visible), chance));
} }
} }
private static Rarity findRarity(String filter) { private static Rarity findRarity(String filter) {
for (Rarity r : Rarity.values()) { for (Rarity r : Rarity.values()) {
if (r.name().toLowerCase().equals(filter.toLowerCase())) if (r.name().equalsIgnoreCase(filter))
return r; return r;
} }
log(Level.WARN, "Rarity " + filter + " not found, using common"); log(Level.WARN, "Rarity " + filter + " not found, using common");

View File

@ -1,19 +1,12 @@
package quimufu.simple_creator; package quimufu.simple_creator;
import com.google.common.base.CaseFormat; import eu.midnightdust.lib.config.MidnightConfig;
import de.siphalor.tweed4.annotated.AConfigEntry;
import de.siphalor.tweed4.annotated.ATweedConfig;
import de.siphalor.tweed4.config.ConfigEnvironment;
import de.siphalor.tweed4.config.ConfigScope;
public class SimpleCreatorConfig extends MidnightConfig {
@ATweedConfig(serializer = "tweed4:hjson", scope = ConfigScope.GAME, environment = ConfigEnvironment.UNIVERSAL, tailors = {"tweed4:lang_json_descriptions", "tweed4:coat", "tweed4:json_schema"}, casing = CaseFormat.LOWER_HYPHEN) @Comment(category = "text")
//@ClothData(modid = "tweed4_testmod") public static Comment explanation;
public class SimpleCreatorConfig {
@AConfigEntry(name = "enableTestThings", comment = "Enables included test Blocks and Items") @Entry(category = "text", name = "Enables included test Blocks and Items")
public static boolean enableTestThings = false; public static boolean enableTestThings = false;
public static boolean extendedLogging = false;
} }

View File

@ -1,6 +1,9 @@
package quimufu.simple_creator; package quimufu.simple_creator;
import eu.midnightdust.lib.config.MidnightConfig;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.util.Pair; import net.minecraft.util.Pair;
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Level;
@ -22,9 +25,12 @@ public class SimpleCreatorMod implements ModInitializer {
@Override @Override
public void onInitialize() { public void onInitialize() {
log(Level.INFO, "Initializing"); log(Level.INFO, "Simply creating Blocks and Items");
MidnightConfig.init(MOD_ID, SimpleCreatorConfig.class);
irl.load(); irl.load();
brl.load(); brl.load();
log(Level.INFO, "Simply created!");
} }
public static void log(Level level, String message) { public static void log(Level level, String message) {

View File

@ -13,76 +13,49 @@ import org.apache.logging.log4j.Level;
public class SimpleCreatorModClient implements ClientModInitializer { public class SimpleCreatorModClient implements ClientModInitializer {
@Override @Override
public void onInitializeClient() { public void onInitializeClient() {
SimpleCreatorMod.log(Level.INFO, "Client init");
for (Pair<Block, String> blockRenderLayerPair : SimpleCreatorMod.BLOCKS_RENDER_LAYER) { for (Pair<Block, String> blockRenderLayerPair : SimpleCreatorMod.BLOCKS_RENDER_LAYER) {
BlockRenderLayerMap.INSTANCE.putBlock(blockRenderLayerPair.getLeft(), getRenderLayer(blockRenderLayerPair.getRight())); BlockRenderLayerMap.INSTANCE.putBlock(blockRenderLayerPair.getLeft(), getRenderLayer(blockRenderLayerPair.getRight()));
} }
} }
private net.minecraft.client.render.RenderLayer getRenderLayer(String renderLayer) { private net.minecraft.client.render.RenderLayer getRenderLayer(String renderLayer) {
switch (renderLayer.toUpperCase()){ return switch (renderLayer.toUpperCase()) {
case "SOLID": case "SOLID" -> RenderLayer.getSolid();
return RenderLayer.getSolid(); case "CUTOUT_MIPPED" -> RenderLayer.getCutoutMipped();
case "CUTOUT_MIPPED": case "CUTOUT" -> RenderLayer.getCutout();
return RenderLayer.getCutoutMipped(); case "TRANSLUCENT" -> RenderLayer.getTranslucent();
case "CUTOUT": case "TRANSLUCENT_MOVING_BLOCK" -> RenderLayer.getTranslucentMovingBlock();
return RenderLayer.getCutout(); case "LEASH" -> RenderLayer.getLeash();
case "TRANSLUCENT": case "WATER_MASK" -> RenderLayer.getWaterMask();
return RenderLayer.getTranslucent(); case "ARMOR_ENTITY_GLINT" -> RenderLayer.getArmorEntityGlint();
case "TRANSLUCENT_MOVING_BLOCK": case "GLINT_TRANSLUCENT" -> RenderLayer.getGlintTranslucent();
return RenderLayer.getTranslucentMovingBlock(); case "GLINT" -> RenderLayer.getGlint();
case "TRANSLUCENT_NO_CRUMBLING": case "ENTITY_GLINT" -> RenderLayer.getEntityGlint();
return RenderLayer.getTranslucentNoCrumbling(); case "TEXT_BACKGROUND" -> RenderLayer.getTextBackground();
case "LEASH": case "TEXT_BACKGROUND_SEE_THROUGH" -> RenderLayer.getTextBackgroundSeeThrough();
return RenderLayer.getLeash(); case "LIGHTNING" -> RenderLayer.getLightning();
case "WATER_MASK": case "DRAGON_RAYS" -> RenderLayer.getDragonRays();
return RenderLayer.getWaterMask(); case "DRAGON_RAYS_DEPTH" -> RenderLayer.getDragonRaysDepth();
case "ARMOR_GLINT": case "TRIPWIRE" -> RenderLayer.getTripwire();
return RenderLayer.getArmorGlint(); case "END_PORTAL" -> RenderLayer.getEndPortal();
case "ARMOR_ENTITY_GLINT": case "END_GATEWAY" -> RenderLayer.getEndGateway();
return RenderLayer.getArmorEntityGlint(); case "FAST_CLOUDS" -> RenderLayer.getFastClouds();
case "GLINT_TRANSLUCENT": case "FANCY_CLOUDS" -> RenderLayer.getFancyClouds();
return RenderLayer.getGlintTranslucent(); case "LINES" -> RenderLayer.getLines();
case "GLINT": case "LINE_STRIP" -> RenderLayer.getLineStrip();
return RenderLayer.getGlint(); case "DEBUG_FILLED_BOX" -> RenderLayer.getDebugFilledBox();
case "DIRECT_GLINT": case "DEBUG_QUADS" -> RenderLayer.getDebugQuads();
return RenderLayer.getDirectGlint(); case "DEBUG_STRUCTURE_QUADS" -> RenderLayer.getDebugStructureQuads();
case "ENTITY_GLINT": case "DEBUG_SECTION_QUADS" -> RenderLayer.getDebugSectionQuads();
return RenderLayer.getEntityGlint(); case "GUI" -> RenderLayer.getGui();
case "DIRECT_ENTITY_GLINT": case "GUI_OVERLAY" -> RenderLayer.getGuiOverlay();
return RenderLayer.getDirectEntityGlint(); case "GUI_TEXT_HIGHLIGHT" -> RenderLayer.getGuiTextHighlight();
case "TEXT_BACKGROUND": case "GUI_GHOST_RECIPE_OVERLAY" -> RenderLayer.getGuiGhostRecipeOverlay();
return RenderLayer.getTextBackground(); default -> {
case "TEXT_BACKGROUND_SEE_THROUGH":
return RenderLayer.getTextBackgroundSeeThrough();
case "LIGHTNING":
return RenderLayer.getLightning();
case "TRIPWIRE":
return RenderLayer.getTripwire();
case "END_PORTAL":
return RenderLayer.getEndPortal();
case "END_GATEWAY":
return RenderLayer.getEndGateway();
case "LINES":
return RenderLayer.getLines();
case "LINE_STRIP":
return RenderLayer.getLineStrip();
case "DEBUG_FILLED_BOX":
return RenderLayer.getDebugFilledBox();
case "DEBUG_QUADS":
return RenderLayer.getDebugQuads();
case "DEBUG_SECTION_QUADS":
return RenderLayer.getDebugSectionQuads();
case "GUI":
return RenderLayer.getGui();
case "GUI_OVERLAY":
return RenderLayer.getGuiOverlay();
case "GUI_TEXT_HIGHLIGHT":
return RenderLayer.getGuiTextHighlight();
case "GUI_GHOST_RECIPE_OVERLAY":
return RenderLayer.getGuiGhostRecipeOverlay();
default:
SimpleCreatorMod.log(Level.INFO, "Could not find renderLayer " + renderLayer + " using solid"); SimpleCreatorMod.log(Level.INFO, "Could not find renderLayer " + renderLayer + " using solid");
return RenderLayer.getSolid(); yield RenderLayer.getSolid();
} }
};
} }
} }

View File

@ -0,0 +1,11 @@
package quimufu.simple_creator.mixin;
import net.minecraft.block.AbstractBlock;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(AbstractBlock.Settings.class)
public interface BlockSettingsAccessor {
@Accessor
void setCollidable(boolean collidable);
}

View File

@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "simple_creator:item/test_block"
}
}

View File

@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "simple_creator:item/test_item"
}
}

View File

@ -1,6 +1,7 @@
{ {
"text.autoconfig.simple_creator.title": "Simple Item/Block Creator Settings", "simple_creator.midnightconfig.title": "Simple Item/Block Creator Settings",
"text.autoconfig.simple_creator.option.enableTestThings": "Enable a test item and block", "simple_creator.midnightconfig.explanation": "Simple Item/Block Creator Settings",
"simple_creator.midnightconfig.enableTestThings": "Enable a test item and block",
"item.simple_creator.test_item": "Forbidden Fruit", "item.simple_creator.test_item": "Forbidden Fruit",
"block.simple_creator.test_block": "Fast jumpy wooly diamond-dropping block of Eternal Fire" "block.simple_creator.test_block": "Fast jumpy wooly diamond-dropping block of Eternal Fire"
} }

View File

@ -1,5 +1,4 @@
{ {
"material": "ice",
"mapColor": "yellow", "mapColor": "yellow",
"collidable": true, "collidable": true,
"soundGroup": "wool", "soundGroup": "wool",
@ -10,8 +9,23 @@
"explosionResistance": 5.0, "explosionResistance": 5.0,
"hardness": 0.5, "hardness": 0.5,
"slipperiness": 0.6, "slipperiness": 0.6,
"slowDownMultiplier": 2.0, "movementVelocityMultiplier": 2.0,
"jumpVelocityMultiplier": 2.0, "jumpVelocityMultiplier": 2.0,
"opaque": true, "opaque": true,
"itemGroup": "food" "itemGroup": "minecraft:building_blocks",
"allowsSpawning": true,
"solidBlock": true,
"suffocates": true,
"blockVision": true,
"postProcess": false,
"emissiveLighting": false,
"modelOffset": "none",
"pistonBehavior": "normal",
"instrument": "harp",
"burnable": false,
"replaceable": false,
"noBlockBreakParticles": false,
"requiresTool": false,
"breaksInstantly": false,
"renderLayer": "solid"
} }

View File

@ -23,7 +23,9 @@
"quimufu.simple_creator.SimpleCreatorConfig" "quimufu.simple_creator.SimpleCreatorConfig"
] ]
}, },
"mixins": [], "mixins": [
"simple_creator.mixins.json"
],
"depends": { "depends": {
"fabricloader": ">=0.14.21", "fabricloader": ">=0.14.21",
"fabric": "*" "fabric": "*"

View File

@ -0,0 +1,14 @@
{
"required": true,
"minVersion": "0.8",
"package": "quimufu.simple_creator.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"BlockSettingsAccessor"
],
"client": [],
"server": [],
"injectors": {
"defaultRequire": 1
}
}