Compare commits
No commits in common. "master" and "0.8.0" have entirely different histories.
24
README.md
24
README.md
@ -2,25 +2,17 @@
|
||||
Started as a Fabric port of [structure-item-mod](https://github.com/QuImUfu/structure-item-mod).
|
||||
Currently, the only supported version of the mod
|
||||
|
||||
Usage:
|
||||
-------
|
||||
This is an item capable of placing structures on right click:
|
||||
## Example Usage
|
||||
```
|
||||
structure_item:item{offset:{X:0,Y:5,Z:0},structure:"structure:mine",allowedOn:"minecraft:stone",blacklist:["minecraft:bedrock"],replaceEntities:0,placeEntities:0}
|
||||
/give User structure_item:item{offset: [I; 0, 5, 0],structure: "structure:mine",allowedOn: "minecraft:stone",blacklist:["minecraft:bedrock"]} 1
|
||||
```
|
||||
If the clicked block is Stone, no Bedrock and no entity is in the way, it will place the structure "structure:mine" excluding (potentially) saved Entities moved up by 5 blocks. (The low coordinate corner will start 5 blocks above the block you would have placed if this item were a block).
|
||||
|
||||
And tada, you have an item capable of placing structures on right click.
|
||||
If the clicked block is Stone and neither Diamond blocks nor Bedrock is in the way, it will place the structure "structure:mine" moved up by 5 blocks. (The low coordinate corner will start 5 blocks above the block you would have placed if this item were a block). Blocks (non structure voids) delete intersecting entities.
|
||||
If you leave out "structure", it won't work.
|
||||
If you leave out "offset", it will place the structure at the block you clicked at, expanding in your view direction, up and to both sides. if you look up or down, it'll place the structure centred above or below the block you clicked at.
|
||||
If you leave out "offset", it will place the structure at the block you clicked at, expanding in your view direction, up and to both sides. if you look up or down, it'll place the structure centered above or below the block you clicked at.
|
||||
If you leave out "blacklist", it will replace anything.
|
||||
If you leave out "allowedOn", it will allow "placement" on any block.
|
||||
If you leave out "replaceEntities" or set it to 1, it will allow placement even if non player entities are in the way of blocks (non structure voids). Those will get deleted.
|
||||
If you leave out "placeEntities" or set it to 1, entities saved in the structure will be placed.
|
||||
If you leave out "allowedOn", it will allow "placement" on any block.
|
||||
|
||||
Error handling:
|
||||
---------------
|
||||
Errors made by the items' creator will be displayed in Chat, any errors made by the user will produce a fat massage in the middle of the screen.
|
||||
Any errors made by the creators will be displayed in chat, any errors made by the user will produce a fat massage in the middle of the screen.
|
||||
|
||||
Model & Localization:
|
||||
---------------------
|
||||
If you use this mod, you may want to change the model of the item (currently = stick) and edit the language file.
|
||||
If you use this mod, you may want to change the model of the item (currently = stick) and fix the language file.
|
||||
|
91
build.gradle
91
build.gradle
@ -1,92 +1,79 @@
|
||||
plugins {
|
||||
id "com.modrinth.minotaur" version "2.+"
|
||||
id 'fabric-loom' version '1.9-SNAPSHOT'
|
||||
id 'fabric-loom' version '0.6-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
archivesBaseName = project.archives_base_name
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
|
||||
base {
|
||||
archivesName = project.archives_base_name
|
||||
}
|
||||
|
||||
repositories {
|
||||
// Add repositories to retrieve artifacts from in here.
|
||||
// You should only use this when depending on other mods because
|
||||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||
// for more information about repositories.
|
||||
mavenCentral()
|
||||
minecraft {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// To change the versions see the gradle.properties file
|
||||
//to change the versions see the gradle.properties file
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
|
||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
|
||||
// Uncomment the following line to enable the deprecated Fabric API modules.
|
||||
// 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 'net.objecthunter:exp4j:0.4.8'
|
||||
implementation 'net.objecthunter:exp4j:0.4.8'
|
||||
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include "fabric.mod.json"
|
||||
expand "version": project.version
|
||||
}
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude "fabric.mod.json"
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.release = 21
|
||||
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||
// this fixes some edge cases with special characters not displaying correctly
|
||||
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||
// if it is present.
|
||||
// If you remove this line, sources will not be generated.
|
||||
withSourcesJar()
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||
// if it is present.
|
||||
// If you remove this task, sources will not be generated.
|
||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||
classifier = "sources"
|
||||
from sourceSets.main.allSource
|
||||
}
|
||||
|
||||
jar {
|
||||
from("LICENSE") {
|
||||
rename { "${it}_${project.archivesBaseName}"}
|
||||
}
|
||||
from "LICENSE"
|
||||
}
|
||||
|
||||
import com.modrinth.minotaur.dependencies.ModDependency
|
||||
|
||||
modrinth {
|
||||
projectId = 'lwR0Ovmu' // The ID of your Modrinth project. Slugs will not work.
|
||||
uploadFile = remapJar // Tells Minotaur to use the remapped jar
|
||||
versionType = "beta"
|
||||
dependencies = [
|
||||
new ModDependency('P7dR8mSH', 'required'), //required dependency on Fabric API
|
||||
]
|
||||
}
|
||||
// configure the maven publication
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
from components.java
|
||||
// add all the jars that should be included when publishing to maven
|
||||
artifact(jar) {
|
||||
builtBy remapJar
|
||||
}
|
||||
artifact("${project.buildDir.absolutePath}/libs/${archivesBaseName}-${project.version}.jar"){
|
||||
builtBy remapJar
|
||||
}
|
||||
artifact(sourcesJar) {
|
||||
builtBy remapSourcesJar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
// select the repositories you want to publish to
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
// Notice: This block does NOT have the same function as the block in the top level.
|
||||
// The repositories here will be used for publishing your artifact, not for
|
||||
// retrieving dependencies.
|
||||
// uncomment to publish to the local maven
|
||||
// mavenLocal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
org.gradle.jvmargs = -Xmx1G
|
||||
|
||||
#Fabric properties
|
||||
minecraft_version=1.21.4
|
||||
yarn_mappings=1.21.4+build.7
|
||||
loader_version=0.16.9
|
||||
minecraft_version=1.16.5
|
||||
yarn_mappings=1.16.5+build.6
|
||||
loader_version=0.11.3
|
||||
|
||||
# Fabric API
|
||||
fabric_version=0.114.0+1.21.4
|
||||
#Fabric api
|
||||
fabric_version=0.32.5+1.16
|
||||
|
||||
#Mod properties
|
||||
mod_version = 0.9.7
|
||||
mod_version = 0.8.0
|
||||
maven_group = quimufu.structure_item
|
||||
archives_base_name = structure_item
|
||||
|
||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,7 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
296
gradlew
vendored
296
gradlew
vendored
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@ -15,116 +15,80 @@
|
||||
# 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/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/.
|
||||
#
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# 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
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
# 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
|
||||
' "$PWD" ) || exit
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# 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"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
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 ;;
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# 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
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
@ -133,120 +97,92 @@ 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.
|
||||
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.
|
||||
|
||||
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" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
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" )
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
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
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# 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
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# 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, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# 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"
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
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" "$@"
|
||||
|
60
gradlew.bat
vendored
60
gradlew.bat
vendored
@ -13,10 +13,8 @@
|
||||
@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
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@ -27,14 +25,10 @@
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
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"
|
||||
|
||||
@ -43,13 +37,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
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
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
@ -57,36 +51,48 @@ goto fail
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
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
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
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
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
@ -2,137 +2,79 @@ package quimufu.structure_item;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.NbtComponent;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.item.tooltip.TooltipType;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtElement;
|
||||
import net.minecraft.nbt.NbtHelper;
|
||||
import net.minecraft.nbt.NbtList;
|
||||
import net.minecraft.network.packet.s2c.play.SubtitleS2CPacket;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.network.MessageType;
|
||||
import net.minecraft.network.packet.s2c.play.TitleS2CPacket;
|
||||
import net.minecraft.registry.DefaultedRegistry;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.structure.StructureTemplate;
|
||||
import net.minecraft.structure.Structure;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.registry.DefaultedRegistry;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static quimufu.structure_item.StructureItemMod.LOGGER;
|
||||
|
||||
public class MyItem extends Item {
|
||||
static Item.Settings p = (new Item.Settings()).group(ItemGroup.REDSTONE).maxCount(1);
|
||||
|
||||
public MyItem(Item.Settings p) {
|
||||
public MyItem() {
|
||||
super(p);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendTooltip(ItemStack itemStack, Item.TooltipContext context, List<Text> texts, TooltipType tooltipFlag) {
|
||||
NbtComponent nbtComponent = itemStack.get(DataComponentTypes.CUSTOM_DATA);
|
||||
if (nbtComponent == null || nbtComponent.isEmpty() || !nbtComponent.getNbt().contains("structure", 8)) {
|
||||
texts.add((Text.translatable("item.structure_item.item.tooltip.tag.invalid")).formatted(Formatting.RED));
|
||||
public void appendTooltip(ItemStack itemStack, World world, List<Text> texts, TooltipContext tooltipFlag) {
|
||||
if (!itemStack.hasTag() || !itemStack.getTag().contains("structure", 8)) {
|
||||
texts.add((new TranslatableText("item.structure_item.item.tooltip.tag.invalid")).formatted(Formatting.RED));
|
||||
} else {
|
||||
NbtCompound tag = nbtComponent.getNbt();
|
||||
CompoundTag tag = itemStack.getTag();
|
||||
if (tooltipFlag.isAdvanced()) {
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.structure"));
|
||||
texts.add(Text.literal(" " + tag.getString("structure")));
|
||||
texts.add(new TranslatableText("item.structure_item.item.tooltip.structure"));
|
||||
texts.add(new LiteralText(" " + tag.getString("structure")));
|
||||
if (tag.contains("allowedOn", 8)) {
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.allowed.on"));
|
||||
texts.add(Text.literal(" " + tag.getString("allowedOn")));
|
||||
texts.add(new TranslatableText("item.structure_item.item.tooltip.allowed.on"));
|
||||
texts.add(new LiteralText(" " + tag.getString("allowedOn")));
|
||||
}
|
||||
if (tag.contains("offset", 10)) {
|
||||
|
||||
BlockPos offset = toBlockPosNewOrOld(tag, "offset");
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.fixed.offset"));
|
||||
Text c = Text.translatable("item.structure_item.item.tooltip.xyz",
|
||||
Text.literal(String.valueOf(offset.getX())),
|
||||
Text.literal(String.valueOf(offset.getY())),
|
||||
Text.literal(String.valueOf(offset.getZ())));
|
||||
BlockPos offset = NbtHelper.toBlockPos(tag.getCompound("offset"));
|
||||
texts.add(new TranslatableText("item.structure_item.item.tooltip.fixed.offset"));
|
||||
Text c = new TranslatableText("item.structure_item.item.tooltip.xyz",
|
||||
new LiteralText(String.valueOf(offset.getX())),
|
||||
new LiteralText(String.valueOf(offset.getY())),
|
||||
new LiteralText(String.valueOf(offset.getZ())));
|
||||
texts.add(c);
|
||||
} else if (tag.contains("offsetV2", 10)) {
|
||||
|
||||
NbtCompound offsetV2 = tag.getCompound("offsetV2");
|
||||
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.v2.offset"));
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.xFuncOff",
|
||||
Text.literal(String.valueOf(offsetV2.get("x")))));
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.yFuncOff",
|
||||
Text.literal(String.valueOf(offsetV2.get("y")))));
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.zFuncOff",
|
||||
Text.literal(String.valueOf(offsetV2.get("z")))));
|
||||
} else {
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.dynamic.offset"));
|
||||
texts.add(new TranslatableText("item.structure_item.item.tooltip.dynamic.offset"));
|
||||
}
|
||||
if (tag.contains("blacklist", 9)) {
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.blacklist"));
|
||||
NbtList bl = tag.getList("blacklist", 8);
|
||||
texts.add(new TranslatableText("item.structure_item.item.tooltip.blacklist"));
|
||||
ListTag bl = tag.getList("blacklist", 8);
|
||||
int i = 0;
|
||||
for (NbtElement entry : bl) {
|
||||
texts.add(Text.literal(" " + entry.asString()));
|
||||
for ( Tag entry : bl) {
|
||||
texts.add(new LiteralText(" " + entry.asString()));
|
||||
i++;
|
||||
if (i == 4) {
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.blacklist.more",
|
||||
Text.literal(String.valueOf(bl.size() - i))));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (tag.contains("whitelist", 9)) {
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.whitelist"));
|
||||
NbtList bl = tag.getList("whitelist", 8);
|
||||
int i = 0;
|
||||
for (NbtElement entry : bl) {
|
||||
texts.add(Text.literal(" " + entry.asString()));
|
||||
i++;
|
||||
if (i == 4) {
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.whitelist.more",
|
||||
Text.literal(String.valueOf(bl.size() - i))));
|
||||
break;
|
||||
texts.add(new TranslatableText("item.structure_item.item.tooltip.blacklist.more",
|
||||
new LiteralText(String.valueOf(bl.size() - i))));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!tag.contains("replaceEntities", 99) || tag.getBoolean("replaceEntities")) {
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.replaceEntities"));
|
||||
} else {
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.doNotReplaceEntities"));
|
||||
}
|
||||
if (!tag.contains("placeEntities", 99) || tag.getBoolean("placeEntities")) {
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.placeEntities"));
|
||||
} else {
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.doNotPlaceEntities"));
|
||||
}
|
||||
if (tag.contains("rotate", NbtElement.STRING_TYPE)) {
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.dynamic.rotation"));
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.dynamic.rotation.value",
|
||||
Text.translatable("item.structure_item.item.tooltip.dynamic.dir." + tag.getString("rotate"))));
|
||||
} else {
|
||||
texts.add(Text.translatable("item.structure_item.item.tooltip.fixed.rotation"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static @NotNull BlockPos toBlockPosNewOrOld(NbtCompound tag, String key) {
|
||||
return NbtHelper.toBlockPos(tag, key).orElseGet(() -> toBlockPosOld(tag.getCompound(key)));
|
||||
}
|
||||
|
||||
public static BlockPos toBlockPosOld(NbtCompound nbt) {
|
||||
return new BlockPos(nbt.getInt("X"), nbt.getInt("Y"), nbt.getInt("Z"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -144,11 +86,10 @@ public class MyItem extends Item {
|
||||
} else {
|
||||
player = null;
|
||||
}
|
||||
NbtCompound tag;
|
||||
NbtComponent nbtComponent = c.getStack().get(DataComponentTypes.CUSTOM_DATA);
|
||||
if (nbtComponent == null || (tag = nbtComponent.getNbt()) == null) {
|
||||
Text message =
|
||||
Text.translatable("items.structure.spawner.no.tag");
|
||||
CompoundTag tag = c.getStack().getTag();
|
||||
if (tag == null) {
|
||||
TranslatableText message =
|
||||
new TranslatableText("items.structure.spawner.no.tag");
|
||||
sendPlayerChat(player, message);
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
@ -157,9 +98,9 @@ public class MyItem extends Item {
|
||||
String allowedOn = tag.getString("allowedOn");
|
||||
allowed = getBlock(allowedOn);
|
||||
if (allowed == null) {
|
||||
Text message =
|
||||
Text.translatable("items.structure.spawner.invalid.block",
|
||||
Text.literal(allowedOn));
|
||||
TranslatableText message =
|
||||
new TranslatableText("items.structure.spawner.invalid.block",
|
||||
new LiteralText(allowedOn));
|
||||
sendPlayerChat(player, message);
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
@ -167,192 +108,136 @@ public class MyItem extends Item {
|
||||
Block current = c.getWorld().getBlockState(c.getBlockPos()).getBlock();
|
||||
|
||||
if (allowed != null && !current.equals(allowed)) {
|
||||
Text currentName = Text.translatable(current.getTranslationKey());
|
||||
Text allowedName = Text.translatable(allowed.getTranslationKey());
|
||||
Text message =
|
||||
Text.translatable("items.structure.spawner.invalid.block.clicked",
|
||||
Text currentName = new TranslatableText(current.getTranslationKey());
|
||||
Text allowedName = new TranslatableText(allowed.getTranslationKey());
|
||||
TranslatableText message =
|
||||
new TranslatableText("items.structure.spawner.invalid.block.clicked",
|
||||
currentName, allowedName);
|
||||
sendPlayer(player, message);
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
if (!tag.contains("structure", 8)) {
|
||||
LOGGER.info("No structure name set");
|
||||
Text message =
|
||||
Text.translatable("items.structure.spawner.no.structure");
|
||||
TranslatableText message =
|
||||
new TranslatableText("items.structure.spawner.no.structure");
|
||||
sendPlayerChat(player, message);
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
String structureName = tag.getString("structure");
|
||||
Identifier structureResourceID = Identifier.tryParse(structureName);
|
||||
if (structureResourceID == null) {
|
||||
Text message =
|
||||
Text.translatable("items.structure.spawner.invalid.structure.name");
|
||||
TranslatableText message =
|
||||
new TranslatableText("items.structure.spawner.invalid.structure.name");
|
||||
sendPlayerChat(player, message);
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
Optional<StructureTemplate> optionalStructureTemplate = ((ServerWorld) c.getWorld()).getStructureTemplateManager().getTemplate(structureResourceID);
|
||||
if (optionalStructureTemplate.isEmpty()) {
|
||||
Text message =
|
||||
Text.translatable("items.structure.spawner.structure.nonexistent",
|
||||
Text.literal(structureResourceID.toString()));
|
||||
Structure x = ((ServerWorld) c.getWorld()).getStructureManager().getStructure(structureResourceID);
|
||||
if (x == null) {
|
||||
TranslatableText message =
|
||||
new TranslatableText("items.structure.spawner.structure.nonexistent",
|
||||
new LiteralText(structureResourceID.toString()));
|
||||
sendPlayerChat(player, message);
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
StructureTemplate structureTemplate = optionalStructureTemplate.get();
|
||||
|
||||
BlockRotation rotation = BlockRotation.NONE;
|
||||
if (tag.contains("rotate", NbtElement.STRING_TYPE)) {
|
||||
String defaultOrientation = tag.getString("rotate");
|
||||
|
||||
Direction defaultDir = Direction.byName(defaultOrientation);
|
||||
Direction currentDir = c.getSide();
|
||||
|
||||
if (defaultDir == null) {
|
||||
Text message =
|
||||
Text.translatable("items.structure.spawner.invalid.rotate",
|
||||
Text.literal(defaultOrientation));
|
||||
sendPlayerChat(player, message);
|
||||
} else {
|
||||
rotation = getRotationBetween(defaultDir, currentDir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BlockPos loc = c.getBlockPos().offset(c.getSide());
|
||||
if (tag.contains("offset", 10)) {
|
||||
BlockPos offset = toBlockPosNewOrOld(tag, "offset");
|
||||
BlockPos offset = NbtHelper.toBlockPos(tag.getCompound("offset"));
|
||||
loc = loc.add(offset);
|
||||
|
||||
Vec3i size = structureTemplate.getSize();
|
||||
switch (rotation) {
|
||||
case CLOCKWISE_90 -> loc = loc.add(new Vec3i(size.getX() - 1, 0, 0));
|
||||
case CLOCKWISE_180 -> loc = loc.add(new Vec3i(size.getX() - 1, 0, size.getZ() - 1));
|
||||
case COUNTERCLOCKWISE_90 -> loc = loc.add(new Vec3i(0, 0, size.getZ() - 1));
|
||||
}
|
||||
} else if (tag.contains("offsetV2", 10)) {
|
||||
Direction direction = c.getSide().getOpposite();
|
||||
try {
|
||||
StructureOffsetSettings offset = StructureOffsetSettings.ofTag(tag.getCompound("offsetV2"));
|
||||
offset.setRotation(rotation);
|
||||
Vec3i size = structureTemplate.getSize();
|
||||
loc = loc.add(offset.getEffective(direction, size));
|
||||
} catch (Exception e) {
|
||||
Text message =
|
||||
Text.translatable("items.structure.spawner.invalid.offsetV2",
|
||||
Text.literal(tag.getCompound("offsetV2").asString()), e.getMessage());
|
||||
sendPlayerChat(player, message);
|
||||
}
|
||||
} else if (c.getPlayer() != null) {
|
||||
Direction direction = Direction.getEntityFacingOrder(c.getPlayer())[0];
|
||||
BlockPos size = x.getSize();
|
||||
loc = loc.add(getDirectionalOffset(direction, size));
|
||||
} else {
|
||||
Direction direction = c.getSide().getOpposite();
|
||||
StructureOffsetSettings offset = StructureOffsetSettings.dynamic();
|
||||
offset.setRotation(rotation);
|
||||
Vec3i size = structureTemplate.getSize();
|
||||
loc = loc.add(offset.getEffective(direction, size));
|
||||
LOGGER.info("No player & no offset");
|
||||
}
|
||||
|
||||
MyPlacementSettings ps = new MyPlacementSettings();
|
||||
if (tag.contains("replaceEntities", 99)) {
|
||||
ps.setReplaceEntities(tag.getBoolean("replaceEntities"));
|
||||
}
|
||||
if (tag.contains("placeEntities", 99)) {
|
||||
ps.setIgnoreEntities(!tag.getBoolean("placeEntities"));
|
||||
}
|
||||
MyPlacementSettings ps = (new MyPlacementSettings());
|
||||
if (tag.contains("blacklist", 9)) {
|
||||
NbtList bl = tag.getList("blacklist", 8);
|
||||
ListTag bl = tag.getList("blacklist", 8);
|
||||
List<Block> blacklist = Lists.newArrayList();
|
||||
for (NbtElement b : bl) {
|
||||
for (Tag b : bl) {
|
||||
Block block = getBlock(b.asString());
|
||||
if (block != null) {
|
||||
blacklist.add(block);
|
||||
} else {
|
||||
Text message =
|
||||
Text.translatable("items.structure.spawner.invalid.block",
|
||||
Text.literal(b.asString()));
|
||||
TranslatableText message =
|
||||
new TranslatableText("items.structure.spawner.invalid.block",
|
||||
new LiteralText(b.asString()));
|
||||
sendPlayerChat(player, message);
|
||||
}
|
||||
|
||||
}
|
||||
ps.forbidOverwrite(blacklist);
|
||||
} else if (tag.contains("whitelist", 9)) {
|
||||
NbtList bl = tag.getList("whitelist", 8);
|
||||
List<Block> whitelist = Lists.newArrayList();
|
||||
for (NbtElement b : bl) {
|
||||
Block block = getBlock(b.asString());
|
||||
if (block != null) {
|
||||
whitelist.add(block);
|
||||
} else {
|
||||
Text message =
|
||||
Text.translatable("items.structure.spawner.invalid.block",
|
||||
Text.literal(b.asString()));
|
||||
sendPlayerChat(player, message);
|
||||
}
|
||||
|
||||
}
|
||||
ps.overwriteOnly(whitelist);
|
||||
}
|
||||
|
||||
|
||||
ps.setWorld(c.getWorld())
|
||||
.setSize(structureTemplate.getSize())
|
||||
.setSize(x.getSize())
|
||||
.setMirror(BlockMirror.NONE)
|
||||
.setRotation(rotation);
|
||||
try {
|
||||
if (structureTemplate.place((ServerWorld) c.getWorld(), loc, BlockPos.ORIGIN, ps, c.getWorld().getRandom(), 2)) {
|
||||
c.getStack().decrement(1);
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
} catch (PlacementNotAllowedException placementNotAllowedException) {
|
||||
Text message =
|
||||
Text.translatable("items.structure.spawner.invalid.location.reason",
|
||||
placementNotAllowedException.getName(),
|
||||
Text.literal(String.valueOf(placementNotAllowedException.getPos().getX())),
|
||||
Text.literal(String.valueOf(placementNotAllowedException.getPos().getY())),
|
||||
Text.literal(String.valueOf(placementNotAllowedException.getPos().getZ())));
|
||||
sendPlayer(player, message);
|
||||
return ActionResult.FAIL;
|
||||
.setRotation(BlockRotation.NONE)
|
||||
.setChunkPosition(null);
|
||||
boolean success = x.place((ServerWorld)c.getWorld(), loc, loc, ps, c.getWorld().getRandom(), 2);
|
||||
if (success) {
|
||||
c.getStack().decrement(1);
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
Text message =
|
||||
Text.translatable("items.structure.spawner.invalid.location");
|
||||
TranslatableText message =
|
||||
new TranslatableText("items.structure.spawner.invalid.location");
|
||||
sendPlayer(player, message);
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
|
||||
private BlockRotation getRotationBetween(Direction from, Direction to) {
|
||||
if (to == Direction.DOWN || to == Direction.UP) {
|
||||
return BlockRotation.NONE;
|
||||
}
|
||||
if (from.getOpposite() == to) {
|
||||
return BlockRotation.CLOCKWISE_180;
|
||||
}
|
||||
if (from.rotateYClockwise() == to) {
|
||||
return BlockRotation.CLOCKWISE_90;
|
||||
}
|
||||
if (from.rotateYCounterclockwise() == to) {
|
||||
return BlockRotation.COUNTERCLOCKWISE_90;
|
||||
}
|
||||
return BlockRotation.NONE;
|
||||
}
|
||||
|
||||
private static void sendPlayer(ServerPlayerEntity player, Text message) {
|
||||
if (player == null)
|
||||
return;
|
||||
ServerPlayNetworkHandler connection = player.networkHandler;
|
||||
SubtitleS2CPacket packet = new SubtitleS2CPacket(message);
|
||||
TitleS2CPacket packet = new TitleS2CPacket(TitleS2CPacket.Action.SUBTITLE, message);
|
||||
connection.sendPacket(packet);
|
||||
packet = new TitleS2CPacket(TitleS2CPacket.Action.TITLE, new LiteralText(""));
|
||||
connection.sendPacket(packet);
|
||||
TitleS2CPacket titleS2CPacket = new TitleS2CPacket(Text.literal(""));
|
||||
connection.sendPacket(titleS2CPacket);
|
||||
}
|
||||
|
||||
private static void sendPlayerChat(ServerPlayerEntity player, Text message) {
|
||||
if (player != null)
|
||||
player.sendMessage(message, false);
|
||||
LOGGER.info(message.asString());
|
||||
}
|
||||
|
||||
private BlockPos getDirectionalOffset(Direction direction, BlockPos size) {
|
||||
BlockPos loc = new BlockPos(0, 0, 0);
|
||||
switch (direction) {
|
||||
case WEST:
|
||||
loc = loc.offset(Direction.NORTH, size.getZ() / 2);
|
||||
loc = loc.offset(Direction.WEST, size.getX() - 1);
|
||||
break;
|
||||
case EAST: //positive x
|
||||
loc = loc.offset(Direction.NORTH, size.getZ() / 2);
|
||||
break;
|
||||
case NORTH:
|
||||
loc = loc.offset(Direction.NORTH, size.getZ() - 1);
|
||||
loc = loc.offset(Direction.WEST, size.getX() / 2);
|
||||
break;
|
||||
case SOUTH: //positive z
|
||||
loc = loc.offset(Direction.WEST, size.getX() / 2);
|
||||
break;
|
||||
case UP: //positive y
|
||||
loc = loc.offset(Direction.NORTH, size.getZ() / 2);
|
||||
loc = loc.offset(Direction.WEST, size.getX() / 2);
|
||||
loc = loc.offset(Direction.UP);
|
||||
break;
|
||||
case DOWN:
|
||||
loc = loc.offset(Direction.NORTH, size.getZ() / 2);
|
||||
loc = loc.offset(Direction.WEST, size.getX() / 2);
|
||||
loc = loc.offset(Direction.DOWN, size.getY());
|
||||
break;
|
||||
}
|
||||
return loc;
|
||||
}
|
||||
|
||||
private Block getBlock(String loc) {
|
||||
Identifier location = Identifier.tryParse(loc);
|
||||
DefaultedRegistry<Block> blocks = Registries.BLOCK;
|
||||
DefaultedRegistry<Block> blocks = Registry.BLOCK;
|
||||
if (location == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -3,42 +3,26 @@ package quimufu.structure_item;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.structure.Structure;
|
||||
import net.minecraft.structure.StructurePlacementData;
|
||||
import net.minecraft.structure.StructureTemplate;
|
||||
import net.minecraft.structure.processor.BlockIgnoreStructureProcessor;
|
||||
import net.minecraft.structure.processor.StructureProcessor;
|
||||
import net.minecraft.structure.processor.StructureProcessorType;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldView;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MyPlacementSettings extends StructurePlacementData {
|
||||
private List<Block> blacklist;
|
||||
private List<Block> whitelist;
|
||||
private World world;
|
||||
private Vec3i size;
|
||||
private boolean replaceEntities = true;
|
||||
|
||||
public MyPlacementSettings() {
|
||||
addProcessor(BlockIgnoreStructureProcessor.IGNORE_STRUCTURE_BLOCKS);
|
||||
addProcessor(new CheckingStructureProcess());
|
||||
}
|
||||
private BlockPos size;
|
||||
|
||||
public void forbidOverwrite(List<Block> blocks) {
|
||||
if (blocks.isEmpty()) {
|
||||
if (blocks.size() == 0) {
|
||||
blacklist = null;
|
||||
return;
|
||||
}
|
||||
blacklist = Lists.newArrayList(blocks);
|
||||
this.whitelist = null;
|
||||
}
|
||||
|
||||
public MyPlacementSettings setWorld(World w) {
|
||||
@ -46,63 +30,57 @@ public class MyPlacementSettings extends StructurePlacementData {
|
||||
return this;
|
||||
}
|
||||
|
||||
public MyPlacementSettings setSize(Vec3i p) {
|
||||
public MyPlacementSettings setSize(BlockPos p) {
|
||||
size = p;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean shouldReplaceEntities() {
|
||||
return replaceEntities;
|
||||
}
|
||||
|
||||
public void setReplaceEntities(boolean replaceEntities) {
|
||||
this.replaceEntities = replaceEntities;
|
||||
}
|
||||
|
||||
public void overwriteOnly(List<Block> whitelist) {
|
||||
if (whitelist.isEmpty()) {
|
||||
this.whitelist = null;
|
||||
return;
|
||||
@Override
|
||||
public Structure.PalettedBlockInfoList getRandomBlockInfos(List<Structure.PalettedBlockInfoList> blocks, BlockPos pos) {
|
||||
if (world == null || pos == null || size == null) {
|
||||
return super.getRandomBlockInfos(blocks, pos);
|
||||
}
|
||||
this.whitelist = Lists.newArrayList(whitelist);
|
||||
this.blacklist = null;
|
||||
}
|
||||
|
||||
public class CheckingStructureProcess extends StructureProcessor {
|
||||
|
||||
List<? extends Entity> entitiesWithinAABB;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public StructureTemplate.StructureBlockInfo process(WorldView world, BlockPos pos, BlockPos pivot, StructureTemplate.StructureBlockInfo originalBlockInfo, StructureTemplate.StructureBlockInfo currentBlockInfo, StructurePlacementData data) {
|
||||
if (entitiesWithinAABB == null) {
|
||||
if (shouldReplaceEntities()) {
|
||||
entitiesWithinAABB = ((ServerWorld) world).getNonSpectatingEntities(PlayerEntity.class, Box.enclosing(pos.subtract(size), pos.add(size)));
|
||||
} else {
|
||||
entitiesWithinAABB = ((ServerWorld) world).getNonSpectatingEntities(Entity.class, Box.enclosing(pos.subtract(size), pos.add(size)));
|
||||
List<Structure.PalettedBlockInfoList> eligibleStructures = new ArrayList<>();
|
||||
if (blacklist == null) {
|
||||
eligibleStructures = blocks;
|
||||
} else {
|
||||
for (Structure.PalettedBlockInfoList struct : blocks) {
|
||||
if (isValid(struct, pos)) {
|
||||
eligibleStructures.add(struct);
|
||||
}
|
||||
}
|
||||
BlockPos posToCheck;
|
||||
if (currentBlockInfo != null && World.isValid(posToCheck = currentBlockInfo.pos())) {
|
||||
}
|
||||
if (eligibleStructures.size() == 0)
|
||||
setIgnoreEntities(true);
|
||||
Structure.PalettedBlockInfoList randomBlockInfos = super.getRandomBlockInfos(eligibleStructures, pos);
|
||||
List<Structure.StructureBlockInfo> locs = randomBlockInfos.getAll();
|
||||
if (!locs.isEmpty()) {
|
||||
List<Entity> entitiesWithinAABB = world.getNonSpectatingEntities(Entity.class, new Box(pos,pos.add(size)));
|
||||
for (Structure.StructureBlockInfo blockInfo : locs) {
|
||||
BlockPos posToClean = blockInfo.pos.add(pos);
|
||||
for (Entity e : entitiesWithinAABB) {
|
||||
if (e.getBoundingBox().intersects(new Box(posToCheck))) {
|
||||
throw new PlacementNotAllowedException(e.getName(), posToCheck);
|
||||
if (e.getBoundingBox().intersects(new Box(posToClean))) {
|
||||
e.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return randomBlockInfos;
|
||||
}
|
||||
|
||||
private boolean isValid(Structure.PalettedBlockInfoList struct, BlockPos pos) {
|
||||
for (Structure.StructureBlockInfo bi : struct.getAll()) {
|
||||
BlockPos posToCheck = bi.pos.add(pos);
|
||||
if (World.isValid(posToCheck)) {
|
||||
Block blockToCheck = world.getBlockState(posToCheck).getBlock();
|
||||
if (blacklist != null && blacklist.contains(blockToCheck)) {
|
||||
throw new PlacementNotAllowedException(blockToCheck.getName(), posToCheck);
|
||||
}
|
||||
if (whitelist != null && !whitelist.contains(blockToCheck)) {
|
||||
throw new PlacementNotAllowedException(blockToCheck.getName(), posToCheck);
|
||||
for (Block b : blacklist) {
|
||||
if (blockToCheck.equals(b)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return currentBlockInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StructureProcessorType<?> getType() {
|
||||
return null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
package quimufu.structure_item;
|
||||
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class PlacementNotAllowedException extends RuntimeException {
|
||||
private final Text name;
|
||||
private final BlockPos pos;
|
||||
|
||||
public PlacementNotAllowedException(Text name, BlockPos pos) {
|
||||
this.name = name;
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
public BlockPos getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public Text getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
@ -2,13 +2,7 @@ package quimufu.structure_item;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Rarity;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@ -20,18 +14,12 @@ public class StructureItemMod implements ModInitializer {
|
||||
|
||||
public static final String MOD_ID = "structure_item";
|
||||
public static final String MOD_NAME = "Structure Item Mod (Fabric)";
|
||||
public static final Item ITEM = Items.register(
|
||||
RegistryKey.of(RegistryKeys.ITEM, Identifier.of(MOD_ID, "item")),
|
||||
MyItem::new,
|
||||
new Item.Settings()
|
||||
.fireproof()
|
||||
.rarity(Rarity.RARE)
|
||||
.maxCount(1)
|
||||
);
|
||||
public static final Item item = new MyItem();
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
log(Level.INFO, "Initializing");
|
||||
Registry.register(Registry.ITEM, MOD_ID + ":item", item);
|
||||
}
|
||||
|
||||
public static void log(Level level, String message) {
|
||||
|
@ -1,180 +0,0 @@
|
||||
package quimufu.structure_item;
|
||||
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.util.BlockRotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.objecthunter.exp4j.Expression;
|
||||
import net.objecthunter.exp4j.ExpressionBuilder;
|
||||
import net.objecthunter.exp4j.function.Function;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
public class StructureOffsetSettings {
|
||||
|
||||
Expression[] xyz = new Expression[3];
|
||||
String[] xyzS = new String[3];
|
||||
boolean[] rel = new boolean[3];
|
||||
static Function DIR_SELECT = new Function("dirSelect", 7) {
|
||||
@Override
|
||||
public double apply(double... args) {
|
||||
return args[(int) (Math.round(args[0]) + 1L)];
|
||||
}
|
||||
};
|
||||
private BlockRotation rotation;
|
||||
|
||||
public static StructureOffsetSettings ofTag(NbtCompound offsetTag) {
|
||||
StructureOffsetSettings settings = new StructureOffsetSettings();
|
||||
String x1 = offsetTag.getString("x");
|
||||
unwrap(x1, settings, 0);
|
||||
String y1 = offsetTag.getString("y");
|
||||
unwrap(y1, settings, 1);
|
||||
String z1 = offsetTag.getString("z");
|
||||
unwrap(z1, settings, 2);
|
||||
return settings;
|
||||
}
|
||||
|
||||
private static void unwrap(String expr, StructureOffsetSettings settings, int x) {
|
||||
if (expr.startsWith("~")) {
|
||||
settings.rel[x] = true;
|
||||
expr = expr.substring(1);
|
||||
}
|
||||
if (expr.isBlank()) {
|
||||
expr = "0";
|
||||
}
|
||||
settings.xyzS[x] = expr;
|
||||
settings.xyz[x] = new ExpressionBuilder(expr)
|
||||
.variables("sizeX", "sizeY", "sizeZ", "dir")
|
||||
.function(DIR_SELECT)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static StructureOffsetSettings dynamic() {
|
||||
StructureOffsetSettings settings = new StructureOffsetSettings();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
settings.xyz[i] = new ExpressionBuilder("0").build();
|
||||
settings.xyzS[i] = "0";
|
||||
}
|
||||
Arrays.fill(settings.rel, true);
|
||||
return settings;
|
||||
}
|
||||
|
||||
public Vec3i getEffective(Direction direction, Vec3i size) {
|
||||
int[] xyzI = new int[3];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
xyz[i].setVariables(Map.of("sizeX", (double) size.getX(),
|
||||
"sizeY", (double) size.getY(),
|
||||
"sizeZ", (double) size.getZ(),
|
||||
"dir", (double) direction.getId()
|
||||
));
|
||||
xyzI[i] = MathHelper.floor(xyz[i].evaluate());
|
||||
}
|
||||
Vec3i dynamicOffset = getDirectionalOffset(direction, size);
|
||||
|
||||
int[] xyzDynamicI = {dynamicOffset.getX(), dynamicOffset.getY(), dynamicOffset.getZ()};
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (rel[i]) {
|
||||
xyzI[i] += xyzDynamicI[i];
|
||||
}
|
||||
}
|
||||
return new Vec3i(xyzI[0], xyzI[1], xyzI[2]);
|
||||
}
|
||||
|
||||
private Vec3i getDirectionalOffset(Direction direction, Vec3i size) {
|
||||
BlockPos loc = new BlockPos(0, 0, 0);
|
||||
switch (rotation) {
|
||||
case NONE:
|
||||
switch (direction) {
|
||||
case WEST:
|
||||
loc = loc.offset(Direction.NORTH, size.getZ() / 2);
|
||||
return loc.offset(Direction.WEST, size.getX() - 1);
|
||||
case EAST://positive x
|
||||
return loc.offset(Direction.NORTH, size.getZ() / 2);
|
||||
case NORTH:
|
||||
loc = loc.offset(Direction.NORTH, size.getZ() - 1);
|
||||
return loc.offset(Direction.WEST, size.getX() / 2);
|
||||
case SOUTH://positive z
|
||||
return loc.offset(Direction.WEST, size.getX() / 2);
|
||||
case UP://positive y
|
||||
loc = loc.offset(Direction.NORTH, size.getZ() / 2);
|
||||
loc = loc.offset(Direction.WEST, size.getX() / 2);
|
||||
return loc.offset(Direction.UP);
|
||||
case DOWN:
|
||||
loc = loc.offset(Direction.NORTH, size.getZ() / 2);
|
||||
loc = loc.offset(Direction.WEST, size.getX() / 2);
|
||||
return loc.offset(Direction.DOWN, size.getY());
|
||||
}
|
||||
case CLOCKWISE_90:
|
||||
switch (direction) {
|
||||
case WEST:
|
||||
return loc.offset(Direction.NORTH, size.getX() / 2);
|
||||
case EAST://positive x
|
||||
loc = loc.offset(Direction.NORTH, size.getX() / 2);
|
||||
return loc.offset(Direction.EAST, size.getZ() - 1);
|
||||
case NORTH:
|
||||
loc = loc.offset(Direction.NORTH, size.getX() - 1);
|
||||
return loc.offset(Direction.EAST, size.getZ() / 2);
|
||||
case SOUTH://positive z
|
||||
return loc.offset(Direction.EAST, size.getZ() / 2);
|
||||
case UP://positive y
|
||||
loc = loc.offset(Direction.NORTH, size.getX() / 2);
|
||||
loc = loc.offset(Direction.EAST, size.getZ() / 2);
|
||||
return loc.offset(Direction.UP);
|
||||
case DOWN:
|
||||
loc = loc.offset(Direction.NORTH, size.getX() / 2);
|
||||
loc = loc.offset(Direction.EAST, size.getZ() / 2);
|
||||
return loc.offset(Direction.DOWN, size.getY());
|
||||
}
|
||||
case CLOCKWISE_180:
|
||||
switch (direction) {
|
||||
case WEST:
|
||||
return loc.offset(Direction.SOUTH, size.getX() / 2);
|
||||
case EAST://positive x
|
||||
loc = loc.offset(Direction.SOUTH, size.getZ() / 2);
|
||||
return loc.offset(Direction.EAST, size.getX() - 1);
|
||||
case NORTH:
|
||||
return loc.offset(Direction.EAST, size.getX() / 2);
|
||||
case SOUTH://positive z
|
||||
loc = loc.offset(Direction.EAST, size.getX() / 2);
|
||||
return loc.offset(Direction.SOUTH, size.getZ() - 1);
|
||||
case UP://positive y
|
||||
loc = loc.offset(Direction.SOUTH, size.getZ() / 2);
|
||||
loc = loc.offset(Direction.EAST, size.getX() / 2);
|
||||
return loc.offset(Direction.UP);
|
||||
case DOWN:
|
||||
loc = loc.offset(Direction.SOUTH, size.getZ() / 2);
|
||||
loc = loc.offset(Direction.EAST, size.getX() / 2);
|
||||
return loc.offset(Direction.DOWN, size.getY());
|
||||
}
|
||||
case COUNTERCLOCKWISE_90:
|
||||
switch (direction) {
|
||||
case WEST:
|
||||
loc = loc.offset(Direction.SOUTH, size.getX() / 2);
|
||||
return loc.offset(Direction.WEST, size.getZ() - 1);
|
||||
case EAST://positive x
|
||||
return loc.offset(Direction.SOUTH, size.getX() / 2);
|
||||
case NORTH:
|
||||
return loc.offset(Direction.WEST, size.getZ() / 2);
|
||||
case SOUTH://positive z
|
||||
loc = loc.offset(Direction.SOUTH, size.getX() - 1);
|
||||
return loc.offset(Direction.WEST, size.getZ() / 2);
|
||||
case UP://positive y
|
||||
loc = loc.offset(Direction.SOUTH, size.getX() / 2);
|
||||
loc = loc.offset(Direction.WEST, size.getZ() / 2);
|
||||
return loc.offset(Direction.UP);
|
||||
case DOWN:
|
||||
loc = loc.offset(Direction.SOUTH, size.getX() / 2);
|
||||
loc = loc.offset(Direction.WEST, size.getZ() / 2);
|
||||
return loc.offset(Direction.DOWN, size.getY());
|
||||
}
|
||||
}
|
||||
return loc;
|
||||
}
|
||||
|
||||
public void setRotation(BlockRotation rotation) {
|
||||
this.rotation = rotation;
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "structure_item:item/item"
|
||||
}
|
||||
}
|
@ -1,12 +1,9 @@
|
||||
{
|
||||
"items.structure.spawner.invalid.block.clicked": "Can only be placed on %2$s, not %1$s.",
|
||||
"items.structure.spawner.invalid.location.reason": "%s is in the way at %s, %s, %s!",
|
||||
"items.structure.spawner.invalid.location": "Something is in the way!",
|
||||
"items.structure.spawner.invalid.block.clicked": "Digga %s is net %s, maan.",
|
||||
"items.structure.spawner.invalid.location": "An irreplaceable block is in the way!",
|
||||
"items.structure.spawner.invalid.structure.name": "Invalid structure name",
|
||||
"items.structure.spawner.structure.nonexistent": "Structure: %s does not exist",
|
||||
"items.structure.spawner.invalid.block": "Block %s invalid",
|
||||
"items.structure.spawner.invalid.offsetV2": "offsetV2 tag %s invalid: %s",
|
||||
"items.structure.spawner.invalid.rotate": "rotate tag invalid direction: %s",
|
||||
"items.structure.spawner.no.tag": "Item has no NBT tag",
|
||||
"items.structure.spawner.no.structure": "Item has no String \"structure\": tag",
|
||||
"item.structure_item.item": "Structure Spawner",
|
||||
@ -14,25 +11,8 @@
|
||||
"item.structure_item.item.tooltip.structure": "Places down: ",
|
||||
"item.structure_item.item.tooltip.allowed.on": "Can be placed on: ",
|
||||
"item.structure_item.item.tooltip.fixed.offset": "Offset:",
|
||||
"item.structure_item.item.tooltip.v2.offset": "Advanced offset:",
|
||||
"item.structure_item.item.tooltip.xyz":" x: %s y: %s z: %s",
|
||||
"item.structure_item.item.tooltip.xFuncOff":" x: %s",
|
||||
"item.structure_item.item.tooltip.yFuncOff":" y: %s",
|
||||
"item.structure_item.item.tooltip.zFuncOff":" z: %s",
|
||||
"item.structure_item.item.tooltip.dynamic.offset": "Dynamic offset",
|
||||
"item.structure_item.item.tooltip.blacklist": "Blacklist:",
|
||||
"item.structure_item.item.tooltip.blacklist.more": " And %s more...",
|
||||
"item.structure_item.item.tooltip.whitelist": "Whitelist:",
|
||||
"item.structure_item.item.tooltip.whitelist.more": " And %s more...",
|
||||
"item.structure_item.item.tooltip.replaceEntities": "Deletes Entities in the way",
|
||||
"item.structure_item.item.tooltip.doNotReplaceEntities": "Doesn't allow placement with entities in the way",
|
||||
"item.structure_item.item.tooltip.placeEntities": "Places contained Entities",
|
||||
"item.structure_item.item.tooltip.doNotPlaceEntities": "Doesn't place contained entities",
|
||||
"item.structure_item.item.tooltip.dynamic.rotation": "Rotated dynamically",
|
||||
"item.structure_item.item.tooltip.dynamic.rotation.value": "Player is standing %s of structure ",
|
||||
"item.structure_item.item.tooltip.dynamic.dir.north": "north",
|
||||
"item.structure_item.item.tooltip.dynamic.dir.south": "south",
|
||||
"item.structure_item.item.tooltip.dynamic.dir.east": "east",
|
||||
"item.structure_item.item.tooltip.dynamic.dir.west": "west",
|
||||
"item.structure_item.item.tooltip.fixed.rotation": "Fixed rotation"
|
||||
"item.structure_item.item.tooltip.blacklist.more": " And %s more..."
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/handheld",
|
||||
"parent": "item/handheld",
|
||||
"textures": {
|
||||
"layer0": "minecraft:item/stick"
|
||||
"layer0": "item/stick"
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@
|
||||
},
|
||||
"mixins": [],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14",
|
||||
"fabricloader": ">=0.4.0",
|
||||
"fabric": "*"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user