Converted
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2024
|
Copyright (c) 2024 skippyall
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
- Module:
|
||||||
|
- Bewegungsmodul ✓
|
||||||
|
- Angriffsmodul ✓
|
||||||
|
- Abbaumodul ✓
|
||||||
|
- Platziermodul / Verwendungsmodul ✓
|
||||||
|
- Werfmodul
|
||||||
|
- Inventarmanagementmodul (Noch nicht wirklich)
|
||||||
|
- Inventaropenmodul (Nä)
|
||||||
|
|
||||||
|
- Detektoren:
|
||||||
|
- Blockdetektor
|
||||||
|
- Entitydetektor
|
||||||
|
- Dimensiondetektor
|
||||||
|
- Positiondetektor
|
||||||
|
- Inventardetektor
|
||||||
|
|
||||||
|
- Programmieren: Nö
|
||||||
|
- Variablen Nö
|
||||||
|
- (Listen) Nö
|
||||||
|
- Warten Nö
|
||||||
|
- Wiederholen Nö
|
||||||
|
- Wiederhole bis/während Nö
|
||||||
|
- Wiederhole x mal/(für jedes Element) Nö
|
||||||
|
- Bedingung Nö
|
||||||
|
|
||||||
|
- VariableTypen:
|
||||||
|
- Integer ✓
|
||||||
|
- String ✓
|
||||||
|
- Position (Nö)
|
||||||
|
- Block (weisned)
|
||||||
|
- BlockType
|
||||||
|
- (NBT) Nö
|
||||||
|
- (World) Nö
|
||||||
|
- (Chunk) Nö
|
||||||
|
- Inventory (weisned)
|
||||||
+9
-9
@@ -108,6 +108,11 @@ jar {
|
|||||||
from("LICENSE") {
|
from("LICENSE") {
|
||||||
rename { "${it}_${project.archives_base_name}"}
|
rename { "${it}_${project.archives_base_name}"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
from("src/main/resoures/assets/minions/lang") {
|
||||||
|
include("*")
|
||||||
|
into("data/minions/lang/")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// configure the maven publication
|
// configure the maven publication
|
||||||
@@ -124,15 +129,10 @@ publishing {
|
|||||||
// Notice: This block does NOT have the same function as the block in the top level.
|
// 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
|
// The repositories here will be used for publishing your artifact, not for
|
||||||
// retrieving dependencies.
|
// retrieving dependencies.
|
||||||
if(project.hasProperty("foxgalaxy_user_name") && project.hasProperty("foxgalaxy_password")) {
|
maven {
|
||||||
maven {
|
name = "foxgalaxy"
|
||||||
url = "https://maven.foxgalaxy.de/private"
|
url = "https://maven.foxgalaxy.de/private"
|
||||||
|
credentials(PasswordCredentials)
|
||||||
credentials {
|
|
||||||
username = project.property("foxgalaxy_user_name")
|
|
||||||
password = project.property("foxgalaxy_password")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
yarn_mappings=1.21.7+build.2
|
yarn_mappings=1.21.7+build.2
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.0.0-SNAPSHOT-1
|
mod_version = 1.0.0-TEST-1
|
||||||
maven_group = io.github.skippyall
|
maven_group = io.github.skippyall
|
||||||
archives_base_name = Minions
|
archives_base_name = Minions
|
||||||
|
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
+7
-1
@@ -1 +1,7 @@
|
|||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@@ -0,0 +1,248 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/2d6327017519d23b96af35865dc997fcb544fb40/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "$( uname )" in #(
|
||||||
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
|
Darwin* ) darwin=true ;; #(
|
||||||
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
|
NONSTOP* ) nonstop=true ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD=java
|
||||||
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
|
case $MAX_FD in #(
|
||||||
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
|
warn "Could not query maximum file descriptor limit"
|
||||||
|
esac
|
||||||
|
case $MAX_FD in #(
|
||||||
|
'' | soft) :;; #(
|
||||||
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
Vendored
+93
@@ -0,0 +1,93 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%"=="" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
bash gradlew publish -PfoxgalaxyPassword=$(read -s -p "Enter Password: ")
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package io.github.skippyall.minions.client;
|
package io.github.skippyall.minions.client;
|
||||||
|
|
||||||
import eu.pb4.polymer.networking.api.client.PolymerClientNetworking;
|
import eu.pb4.polymer.networking.api.client.PolymerClientNetworking;
|
||||||
import io.github.skippyall.minions.registration.MinionBlocks;
|
|
||||||
import io.github.skippyall.minions.polymer.VersionSync;
|
import io.github.skippyall.minions.polymer.VersionSync;
|
||||||
|
import io.github.skippyall.minions.registration.MinionBlocks;
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
import net.fabricmc.fabric.api.client.rendering.v1.BlockRenderLayerMap;
|
import net.fabricmc.fabric.api.client.rendering.v1.BlockRenderLayerMap;
|
||||||
import net.minecraft.client.render.BlockRenderLayer;
|
import net.minecraft.client.render.BlockRenderLayer;
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ public class MinionMixinConfigPlugin implements IMixinConfigPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||||
if(mixinClassName.startsWith("io.github.skippyall.mixins.compat.universal_graves.")) {
|
if(mixinClassName.startsWith("io.github.skippyall.minions.mixins.compat.universal_graves.")) {
|
||||||
return MinionsConfig.get().compat.enableGravesCompat && FabricLoader.getInstance().isModLoaded("universal-graves");
|
return MinionsConfig.get().compat.enableGravesCompat && FabricLoader.getInstance().isModLoaded("universal-graves");
|
||||||
}
|
}
|
||||||
if(mixinClassName.startsWith("io.github.skippyall.mixins.antimobcap.")) {
|
if(mixinClassName.startsWith("io.github.skippyall.minions.mixins.antimobcap.")) {
|
||||||
return MinionsConfig.get().minion.enableMobCapHacks;
|
return MinionsConfig.get().minion.enableMobCapHacks;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ package io.github.skippyall.minions;
|
|||||||
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
|
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
|
||||||
import io.github.skippyall.minions.command.MinionsCommand;
|
import io.github.skippyall.minions.command.MinionsCommand;
|
||||||
import io.github.skippyall.minions.docs.DocsManager;
|
import io.github.skippyall.minions.docs.DocsManager;
|
||||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
|
||||||
import io.github.skippyall.minions.minion.MinionPersistentState;
|
import io.github.skippyall.minions.minion.MinionPersistentState;
|
||||||
import io.github.skippyall.minions.registration.MinionRegistration;
|
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||||
import io.github.skippyall.minions.polymer.VersionSync;
|
import io.github.skippyall.minions.polymer.VersionSync;
|
||||||
|
import io.github.skippyall.minions.registration.MinionRegistration;
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||||
@@ -38,12 +38,6 @@ public class Minions implements ModInitializer {
|
|||||||
|
|
||||||
CommandRegistrationCallback.EVENT.register(MinionsCommand::register);
|
CommandRegistrationCallback.EVENT.register(MinionsCommand::register);
|
||||||
|
|
||||||
/*ServerBlockEntityEvents.BLOCK_ENTITY_LOAD.register((blockEntity, world) -> {
|
|
||||||
if(blockEntity instanceof MinionTriggerBlockEntity) {
|
|
||||||
world.updateComparators(blockEntity.getPos(), MinionBlocks.MINION_TRIGGER_BLOCK);
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
|
|
||||||
PolymerResourcePackUtils.addModAssets(Minions.MOD_ID);
|
PolymerResourcePackUtils.addModAssets(Minions.MOD_ID);
|
||||||
|
|
||||||
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(new DocsManager());
|
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(new DocsManager());
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import com.electronwill.nightconfig.core.serde.ObjectDeserializer;
|
|||||||
import com.electronwill.nightconfig.core.serde.ObjectSerializer;
|
import com.electronwill.nightconfig.core.serde.ObjectSerializer;
|
||||||
import com.electronwill.nightconfig.core.serde.SerdeException;
|
import com.electronwill.nightconfig.core.serde.SerdeException;
|
||||||
import com.electronwill.nightconfig.core.serde.annotations.SerdeComment;
|
import com.electronwill.nightconfig.core.serde.annotations.SerdeComment;
|
||||||
import com.electronwill.nightconfig.core.serde.annotations.SerdeSkipDeserializingIf;
|
|
||||||
import com.electronwill.nightconfig.toml.TomlFormat;
|
import com.electronwill.nightconfig.toml.TomlFormat;
|
||||||
import com.electronwill.nightconfig.toml.TomlParser;
|
import com.electronwill.nightconfig.toml.TomlParser;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
@@ -17,31 +16,24 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
import static com.electronwill.nightconfig.core.serde.annotations.SerdeSkipDeserializingIf.SkipDeIf.IS_MISSING;
|
|
||||||
|
|
||||||
public class MinionsConfig {
|
public class MinionsConfig {
|
||||||
private static MinionsConfig INSTANCE;
|
private static MinionsConfig INSTANCE;
|
||||||
|
|
||||||
@SerdeSkipDeserializingIf(IS_MISSING)
|
|
||||||
public Minion minion = new Minion();
|
public Minion minion = new Minion();
|
||||||
|
|
||||||
public static class Minion {
|
public static class Minion {
|
||||||
@SerdeComment("The prefix for all minion names")
|
@SerdeComment("The prefix for all minion names")
|
||||||
@SerdeSkipDeserializingIf(IS_MISSING)
|
|
||||||
public String minionPrefix = "+";
|
public String minionPrefix = "+";
|
||||||
|
|
||||||
@SerdeComment("Makes minions not raise the mob cap if they can't spawn mobs.")
|
@SerdeComment("Makes minions not raise the mob cap if they can't spawn mobs.")
|
||||||
@SerdeComment("Might cause incompatibilities.")
|
@SerdeComment("Might cause incompatibilities.")
|
||||||
@SerdeSkipDeserializingIf(IS_MISSING)
|
|
||||||
public boolean enableMobCapHacks = true;
|
public boolean enableMobCapHacks = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SerdeSkipDeserializingIf(IS_MISSING)
|
|
||||||
public Compat compat = new Compat();
|
public Compat compat = new Compat();
|
||||||
|
|
||||||
public static class Compat {
|
public static class Compat {
|
||||||
@SerdeComment("Enables compat with Universal Graves, which allows everyone to pick up graves from minions")
|
@SerdeComment("Enables compat with Universal Graves, which allows everyone to pick up graves from minions")
|
||||||
@SerdeSkipDeserializingIf(IS_MISSING)
|
|
||||||
public boolean enableGravesCompat = true;
|
public boolean enableGravesCompat = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,12 +58,15 @@ public class MinionsConfig {
|
|||||||
|
|
||||||
public static void loadConfig() {
|
public static void loadConfig() {
|
||||||
try {
|
try {
|
||||||
|
CommentedConfig defaultConfig = ObjectSerializer.standard().serializeFields(new MinionsConfig(), TomlFormat::newConfig);
|
||||||
|
|
||||||
CommentedConfig config = new TomlParser().parse(getPath(), (file, configFormat) -> {
|
CommentedConfig config = new TomlParser().parse(getPath(), (file, configFormat) -> {
|
||||||
CommentedConfig defaultConfig = ObjectSerializer.standard().serializeFields(new MinionsConfig(), TomlFormat::newConfig);
|
|
||||||
configFormat.createWriter().write(defaultConfig, file, WritingMode.REPLACE);
|
configFormat.createWriter().write(defaultConfig, file, WritingMode.REPLACE);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Always use default values when entries are missing
|
||||||
|
config.addAll(defaultConfig);
|
||||||
INSTANCE = ObjectDeserializer.standard().deserializeFields(config, MinionsConfig::new);
|
INSTANCE = ObjectDeserializer.standard().deserializeFields(config, MinionsConfig::new);
|
||||||
} catch (SerdeException | ParsingException | WritingException e) {
|
} catch (SerdeException | ParsingException | WritingException e) {
|
||||||
Minions.LOGGER.error("Error while reading config", e);
|
Minions.LOGGER.error("Error while reading config", e);
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ public class AnalogInputBlock extends Block {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
|
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
|
||||||
player.getInventory().offer(ClipboardItem.createBlockPosReference(world, pos), true);
|
if(!world.isClient) {
|
||||||
|
player.getInventory().offer(ClipboardItem.createBlockPosReference(world, pos), true);
|
||||||
|
}
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-4
@@ -7,6 +7,7 @@ import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
|||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.block.entity.BlockEntityType;
|
import net.minecraft.block.entity.BlockEntityType;
|
||||||
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -25,13 +26,17 @@ public abstract class InstructionBoundBlockEntity<L extends BlockEntityMinionLis
|
|||||||
protected abstract Class<L> getListenerClass();
|
protected abstract Class<L> getListenerClass();
|
||||||
|
|
||||||
public void removeListener() {
|
public void removeListener() {
|
||||||
L listener = getListener();
|
if(world instanceof ServerWorld serverWorld) {
|
||||||
listener.remove(world.getServer());
|
L listener = getListener();
|
||||||
|
listener.remove(serverWorld.getServer());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListener() {
|
public void addListener() {
|
||||||
L listener = createListener();
|
if(world instanceof ServerWorld serverWorld) {
|
||||||
listener.add(world.getServer());
|
L listener = createListener();
|
||||||
|
listener.add(serverWorld.getServer());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInstruction(UUID minionUuid, String instructionName) {
|
public void setInstruction(UUID minionUuid, String instructionName) {
|
||||||
|
|||||||
+7
-5
@@ -8,11 +8,10 @@ import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
|
|||||||
import eu.pb4.polymer.virtualentity.api.BlockWithElementHolder;
|
import eu.pb4.polymer.virtualentity.api.BlockWithElementHolder;
|
||||||
import eu.pb4.polymer.virtualentity.api.ElementHolder;
|
import eu.pb4.polymer.virtualentity.api.ElementHolder;
|
||||||
import eu.pb4.polymer.virtualentity.api.elements.ItemDisplayElement;
|
import eu.pb4.polymer.virtualentity.api.elements.ItemDisplayElement;
|
||||||
import io.github.skippyall.minions.block.instruction_bound.InstructionBoundBlock;
|
|
||||||
import io.github.skippyall.minions.block.instruction_bound.InstructionBoundBlockEntity;
|
|
||||||
import io.github.skippyall.minions.registration.MinionBlocks;
|
|
||||||
import io.github.skippyall.minions.Minions;
|
import io.github.skippyall.minions.Minions;
|
||||||
|
import io.github.skippyall.minions.block.instruction_bound.InstructionBoundBlock;
|
||||||
import io.github.skippyall.minions.polymer.VersionSync;
|
import io.github.skippyall.minions.polymer.VersionSync;
|
||||||
|
import io.github.skippyall.minions.registration.MinionBlocks;
|
||||||
import net.minecraft.block.AbstractRedstoneGateBlock;
|
import net.minecraft.block.AbstractRedstoneGateBlock;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
@@ -21,6 +20,7 @@ import net.minecraft.block.SideShapeType;
|
|||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.block.entity.BlockEntityType;
|
import net.minecraft.block.entity.BlockEntityType;
|
||||||
import net.minecraft.component.DataComponentTypes;
|
import net.minecraft.component.DataComponentTypes;
|
||||||
|
import net.minecraft.item.ItemDisplayContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||||
@@ -120,7 +120,7 @@ public class MinionTriggerBlock extends InstructionBoundBlock implements Polymer
|
|||||||
ElementHolder holder = new ElementHolder() {
|
ElementHolder holder = new ElementHolder() {
|
||||||
@Override
|
@Override
|
||||||
public boolean startWatching(ServerPlayNetworkHandler player) {
|
public boolean startWatching(ServerPlayNetworkHandler player) {
|
||||||
if(PolymerResourcePackUtils.hasMainPack(player)) {
|
if(PolymerResourcePackUtils.hasMainPack(player) && !VersionSync.isOnClient(player)) {
|
||||||
return super.startWatching(player);
|
return super.startWatching(player);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@@ -130,7 +130,9 @@ public class MinionTriggerBlock extends InstructionBoundBlock implements Polymer
|
|||||||
ItemStack stack = new ItemStack(Items.BARRIER);
|
ItemStack stack = new ItemStack(Items.BARRIER);
|
||||||
stack.set(DataComponentTypes.ITEM_MODEL, Identifier.of(Minions.MOD_ID, "minion_trigger_no_plate_" + (initialBlockState.get(MinionTriggerBlock.POWERED) ? "active" : "inactive")));
|
stack.set(DataComponentTypes.ITEM_MODEL, Identifier.of(Minions.MOD_ID, "minion_trigger_no_plate_" + (initialBlockState.get(MinionTriggerBlock.POWERED) ? "active" : "inactive")));
|
||||||
|
|
||||||
holder.addElement(new ItemDisplayElement(stack));
|
ItemDisplayElement element = new ItemDisplayElement(stack);
|
||||||
|
element.setItemDisplayContext(ItemDisplayContext.NONE);
|
||||||
|
holder.addElement(element);
|
||||||
return holder;
|
return holder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-8
@@ -1,21 +1,13 @@
|
|||||||
package io.github.skippyall.minions.block.miniontrigger;
|
package io.github.skippyall.minions.block.miniontrigger;
|
||||||
|
|
||||||
import io.github.skippyall.minions.block.instruction_bound.InstructionBoundBlockEntity;
|
import io.github.skippyall.minions.block.instruction_bound.InstructionBoundBlockEntity;
|
||||||
import io.github.skippyall.minions.listener.BlockEntityMinionListener;
|
|
||||||
import io.github.skippyall.minions.registration.MinionBlocks;
|
import io.github.skippyall.minions.registration.MinionBlocks;
|
||||||
import io.github.skippyall.minions.minion.MinionRuntime;
|
|
||||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
|
||||||
import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.storage.ReadView;
|
import net.minecraft.storage.ReadView;
|
||||||
import net.minecraft.storage.WriteView;
|
import net.minecraft.storage.WriteView;
|
||||||
import net.minecraft.util.Uuids;
|
import net.minecraft.util.Uuids;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class MinionTriggerBlockEntity extends InstructionBoundBlockEntity<MinionTriggerMinionListener> {
|
public class MinionTriggerBlockEntity extends InstructionBoundBlockEntity<MinionTriggerMinionListener> {
|
||||||
public MinionTriggerBlockEntity(BlockPos pos, BlockState state) {
|
public MinionTriggerBlockEntity(BlockPos pos, BlockState state) {
|
||||||
super(MinionBlocks.MINION_TRIGGER_BE_TYPE, pos, state);
|
super(MinionBlocks.MINION_TRIGGER_BE_TYPE, pos, state);
|
||||||
|
|||||||
+1
-1
@@ -5,10 +5,10 @@ import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|||||||
import io.github.skippyall.minions.Minions;
|
import io.github.skippyall.minions.Minions;
|
||||||
import io.github.skippyall.minions.listener.BlockEntityMinionInstructionListener;
|
import io.github.skippyall.minions.listener.BlockEntityMinionInstructionListener;
|
||||||
import io.github.skippyall.minions.minion.MinionRuntime;
|
import io.github.skippyall.minions.minion.MinionRuntime;
|
||||||
import io.github.skippyall.minions.registration.MinionBlocks;
|
|
||||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||||
import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
||||||
import io.github.skippyall.minions.program.instruction.ConfiguredInstructionListener;
|
import io.github.skippyall.minions.program.instruction.ConfiguredInstructionListener;
|
||||||
|
import io.github.skippyall.minions.registration.MinionBlocks;
|
||||||
import net.minecraft.registry.RegistryKey;
|
import net.minecraft.registry.RegistryKey;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package io.github.skippyall.minions.clipboard;
|
package io.github.skippyall.minions.clipboard;
|
||||||
|
|
||||||
import eu.pb4.polymer.core.api.item.PolymerItem;
|
import eu.pb4.polymer.core.api.item.PolymerItem;
|
||||||
|
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||||
import io.github.skippyall.minions.registration.MinionComponentTypes;
|
import io.github.skippyall.minions.registration.MinionComponentTypes;
|
||||||
import io.github.skippyall.minions.registration.MinionItems;
|
import io.github.skippyall.minions.registration.MinionItems;
|
||||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
|
||||||
import net.minecraft.component.DataComponentTypes;
|
import net.minecraft.component.DataComponentTypes;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -22,7 +22,7 @@ public class ClipboardItem extends Item implements PolymerItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item getPolymerItem(ItemStack itemStack, PacketContext context) {
|
public Item getPolymerItem(ItemStack itemStack, PacketContext context) {
|
||||||
return Items.PAPER;
|
return /*VersionSync.isOnClient(context) ? this : */Items.PAPER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import net.minecraft.util.Identifier;
|
|||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import static net.minecraft.server.command.CommandManager.literal;
|
|
||||||
import static net.minecraft.server.command.CommandManager.argument;
|
import static net.minecraft.server.command.CommandManager.argument;
|
||||||
|
import static net.minecraft.server.command.CommandManager.literal;
|
||||||
|
|
||||||
public class DocsSubcommand {
|
public class DocsSubcommand {
|
||||||
public static final LiteralArgumentBuilder<ServerCommandSource> DOCS = literal("docs")
|
public static final LiteralArgumentBuilder<ServerCommandSource> DOCS = literal("docs")
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ public class MinionsCommand {
|
|||||||
LiteralArgumentBuilder<ServerCommandSource> builder = literal("minions")
|
LiteralArgumentBuilder<ServerCommandSource> builder = literal("minions")
|
||||||
.then(SpawnSubcommand.SPAWN)
|
.then(SpawnSubcommand.SPAWN)
|
||||||
.then(ListSubcommand.LIST)
|
.then(ListSubcommand.LIST)
|
||||||
.then(DocsSubcommand.DOCS);
|
.then(DocsSubcommand.DOCS)
|
||||||
|
.then(TestSubcommand.TEST);
|
||||||
|
|
||||||
if(MinionsConfig.get().minion.enableMobCapHacks) {
|
if(MinionsConfig.get().minion.enableMobCapHacks) {
|
||||||
builder.then(MobCapDebugSubcommand.MOB_CAP_DEBUG);
|
builder.then(MobCapDebugSubcommand.MOB_CAP_DEBUG);
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package io.github.skippyall.minions.command;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
|
import io.github.skippyall.minions.Minions;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.command.argument.BlockPosArgumentType;
|
||||||
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import static net.minecraft.server.command.CommandManager.argument;
|
||||||
|
import static net.minecraft.server.command.CommandManager.literal;
|
||||||
|
|
||||||
|
public class TestSubcommand {
|
||||||
|
public static LiteralArgumentBuilder<ServerCommandSource> TEST = literal("test")
|
||||||
|
.then(argument("pos", BlockPosArgumentType.blockPos())
|
||||||
|
.executes(TestSubcommand::execute)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
private static int execute(CommandContext<ServerCommandSource> context) {
|
||||||
|
try {
|
||||||
|
BlockPos pos = BlockPosArgumentType.getBlockPos(context, "pos");
|
||||||
|
Collection<BlockPos> result = findInputs(context.getSource().getWorld(), pos);
|
||||||
|
for (BlockPos resultPos : result) {
|
||||||
|
context.getSource().sendFeedback(() -> Text.literal(resultPos.toShortString()), false);
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Minions.LOGGER.error("Error", e);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Collection<BlockPos> findInputs(World world, BlockPos pos) {
|
||||||
|
//positions that are already processed
|
||||||
|
Collection<BlockPos> visitedPositions = new HashSet<>();
|
||||||
|
//positions we are currently looking at
|
||||||
|
Collection<BlockPos> currentPositions = new HashSet<>();
|
||||||
|
//new positions are added here
|
||||||
|
Collection<BlockPos> newPositions = new HashSet<>();
|
||||||
|
//resulting machines
|
||||||
|
Collection<BlockPos> machines = new HashSet<>();
|
||||||
|
|
||||||
|
currentPositions.add(pos);
|
||||||
|
|
||||||
|
while(!currentPositions.isEmpty()) {
|
||||||
|
for(BlockPos currentPosition : currentPositions) {
|
||||||
|
for(Direction dir : Direction.values()) {
|
||||||
|
//check each neighbor of the current positions
|
||||||
|
BlockPos newPos = currentPosition.offset(dir);
|
||||||
|
//Do not check blocks that were already checked
|
||||||
|
if(!visitedPositions.contains(newPos)) {
|
||||||
|
if (world.getBlockState(newPos).getBlock() == Blocks.REDSTONE_BLOCK) {
|
||||||
|
//Add pipes to positions for the next iteration
|
||||||
|
newPositions.add(newPos);
|
||||||
|
} else if (world.getBlockState(newPos).getBlock() == Blocks.IRON_BLOCK) {
|
||||||
|
//Add machines to output set
|
||||||
|
machines.add(newPos);
|
||||||
|
}
|
||||||
|
//Add checked blocks here so that they are not checked again
|
||||||
|
visitedPositions.add(newPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Check the new positions in the next iteration
|
||||||
|
currentPositions = newPositions;
|
||||||
|
newPositions = new HashSet<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return machines;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,6 @@ import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|||||||
import io.github.skippyall.minions.registration.MinionRegistries;
|
import io.github.skippyall.minions.registration.MinionRegistries;
|
||||||
import net.minecraft.dialog.body.DialogBody;
|
import net.minecraft.dialog.body.DialogBody;
|
||||||
import net.minecraft.registry.DynamicRegistryManager;
|
import net.minecraft.registry.DynamicRegistryManager;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import net.minecraft.dialog.AfterAction;
|
|||||||
import net.minecraft.dialog.DialogActionButtonData;
|
import net.minecraft.dialog.DialogActionButtonData;
|
||||||
import net.minecraft.dialog.DialogButtonData;
|
import net.minecraft.dialog.DialogButtonData;
|
||||||
import net.minecraft.dialog.DialogCommonData;
|
import net.minecraft.dialog.DialogCommonData;
|
||||||
import net.minecraft.dialog.action.DynamicRunCommandDialogAction;
|
|
||||||
import net.minecraft.dialog.action.SimpleDialogAction;
|
import net.minecraft.dialog.action.SimpleDialogAction;
|
||||||
import net.minecraft.dialog.type.MultiActionDialog;
|
import net.minecraft.dialog.type.MultiActionDialog;
|
||||||
import net.minecraft.registry.entry.RegistryEntry;
|
import net.minecraft.registry.entry.RegistryEntry;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public record ReferenceEntry(Metadata metadata, RegistryKey<?> object, Text shor
|
|||||||
bodyElements.add(new ItemDialogBody(display.createItemStack(), Optional.empty(), false, false, 16, 16));
|
bodyElements.add(new ItemDialogBody(display.createItemStack(), Optional.empty(), false, false, 16, 16));
|
||||||
}
|
}
|
||||||
bodyElements.add(new PlainMessageDialogBody(Text.translatable(object.getValue().toTranslationKey(object.getRegistry().getPath())), 200));
|
bodyElements.add(new PlainMessageDialogBody(Text.translatable(object.getValue().toTranslationKey(object.getRegistry().getPath())), 200));
|
||||||
bodyElements.add(new PlainMessageDialogBody(longDescription.copy().append("\n".repeat(100)), 200));
|
bodyElements.add(new PlainMessageDialogBody(longDescription, 200));
|
||||||
|
|
||||||
return bodyElements;
|
return bodyElements;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import net.minecraft.registry.DynamicRegistryManager;
|
|||||||
import net.minecraft.registry.Registries;
|
import net.minecraft.registry.Registries;
|
||||||
import net.minecraft.registry.Registry;
|
import net.minecraft.registry.Registry;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.Rarity;
|
import net.minecraft.util.Rarity;
|
||||||
import net.minecraft.util.Uuids;
|
import net.minecraft.util.Uuids;
|
||||||
@@ -46,7 +47,7 @@ public interface GuiDisplay {
|
|||||||
|
|
||||||
static <T> ItemStack getDisplayStackWithName(Registry<T> registry, T element, DynamicRegistryManager manager) {
|
static <T> ItemStack getDisplayStackWithName(Registry<T> registry, T element, DynamicRegistryManager manager) {
|
||||||
ItemStack stack = getDisplayStack(registry, element, manager);
|
ItemStack stack = getDisplayStack(registry, element, manager);
|
||||||
stack.set(DataComponentTypes.ITEM_NAME, Text.translatable(TranslationUtil.getTranslationKey(element, registry)));
|
stack.set(DataComponentTypes.CUSTOM_NAME, Text.translatable(TranslationUtil.getTranslationKey(element, registry)).styled(style -> style.withItalic(false).withColor(Formatting.WHITE)));
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
package io.github.skippyall.minions.gui;
|
|
||||||
|
|
||||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
|
||||||
import io.github.skippyall.minions.minion.MinionListener;
|
|
||||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
|
||||||
import net.minecraft.screen.ScreenHandlerType;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
public class MinionBoundSimpleGui extends SimpleGui implements MinionListener {
|
|
||||||
protected final MinionFakePlayer minion;
|
|
||||||
|
|
||||||
public MinionBoundSimpleGui(ScreenHandlerType<?> type, ServerPlayerEntity player, MinionFakePlayer minion) {
|
|
||||||
super(type, player, false);
|
|
||||||
this.minion = minion;
|
|
||||||
minion.addMinionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MinionFakePlayer getMinion() {
|
|
||||||
return minion;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMinionRemove(MinionFakePlayer minion) {
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClose() {
|
|
||||||
minion.removeMinionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (!(o instanceof MinionBoundSimpleGui that)) return false;
|
|
||||||
return minion == that.minion && player == that.player;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,12 +2,12 @@ package io.github.skippyall.minions.gui;
|
|||||||
|
|
||||||
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
||||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||||
import io.github.skippyall.minions.registration.MinionRegistries;
|
|
||||||
import io.github.skippyall.minions.gui.input.TextInput;
|
import io.github.skippyall.minions.gui.input.TextInput;
|
||||||
import io.github.skippyall.minions.minion.MinionData;
|
import io.github.skippyall.minions.minion.MinionData;
|
||||||
import io.github.skippyall.minions.minion.MinionItem;
|
import io.github.skippyall.minions.minion.MinionItem;
|
||||||
import io.github.skippyall.minions.minion.MinionProfileUtils;
|
import io.github.skippyall.minions.minion.MinionProfileUtils;
|
||||||
import io.github.skippyall.minions.minion.skin.SkinProvider;
|
import io.github.skippyall.minions.minion.skin.SkinProvider;
|
||||||
|
import io.github.skippyall.minions.registration.MinionRegistries;
|
||||||
import io.github.skippyall.minions.registration.SkinProviders;
|
import io.github.skippyall.minions.registration.SkinProviders;
|
||||||
import net.minecraft.component.DataComponentTypes;
|
import net.minecraft.component.DataComponentTypes;
|
||||||
import net.minecraft.component.type.ProfileComponent;
|
import net.minecraft.component.type.ProfileComponent;
|
||||||
|
|||||||
@@ -6,23 +6,25 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
public abstract class MinionsGui {
|
public abstract class MinionsGui {
|
||||||
protected final @Nullable MinionsGui parent;
|
protected final @Nullable MinionsGui parent;
|
||||||
protected final ServerPlayerEntity viewer;
|
protected final ServerPlayerEntity viewer;
|
||||||
private @Nullable MinionsGui child = null;
|
protected @Nullable MinionsGui child = null;
|
||||||
private boolean open = true;
|
private boolean open = true;
|
||||||
|
|
||||||
public MinionsGui(MinionsGui parent) {
|
public MinionsGui(MinionsGui parent) {
|
||||||
this.viewer = parent.viewer;
|
this.viewer = parent.viewer;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
parent.child = this;
|
parent.child = this;
|
||||||
open();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MinionsGui(ServerPlayerEntity viewer) {
|
public MinionsGui(ServerPlayerEntity viewer) {
|
||||||
this.viewer = viewer;
|
this.viewer = viewer;
|
||||||
this.parent = null;
|
this.parent = null;
|
||||||
open();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void open() {}
|
public ServerPlayerEntity getViewer() {
|
||||||
|
return viewer;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void open();
|
||||||
|
|
||||||
protected void reopen() {
|
protected void reopen() {
|
||||||
open();
|
open();
|
||||||
@@ -38,17 +40,26 @@ public abstract class MinionsGui {
|
|||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
if(open) {
|
if(open) {
|
||||||
if(child != null) {
|
|
||||||
child.close();
|
|
||||||
}
|
|
||||||
if(parent != null) {
|
if(parent != null) {
|
||||||
parent.child = null;
|
parent.child = null;
|
||||||
parent.reopen();
|
parent.reopen();
|
||||||
}
|
}
|
||||||
onClose();
|
closeNoOpen(parent == null);
|
||||||
open = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onClose() {}
|
private void closeNoOpen(boolean closeBacking) {
|
||||||
|
if(child != null) {
|
||||||
|
child.closeNoOpen(closeBacking);
|
||||||
|
}
|
||||||
|
if(parent != null) {
|
||||||
|
parent.child = null;
|
||||||
|
}
|
||||||
|
if(closeBacking) {
|
||||||
|
closeBacking();
|
||||||
|
}
|
||||||
|
open = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void closeBacking();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,55 +1,79 @@
|
|||||||
package io.github.skippyall.minions.gui;
|
package io.github.skippyall.minions.gui;
|
||||||
|
|
||||||
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
||||||
import eu.pb4.sgui.api.gui.SlotGuiInterface;
|
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||||
import io.github.skippyall.minions.gui.minion.MinionGui;
|
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.screen.ScreenHandlerType;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.collection.IndexedIterable;
|
import net.minecraft.util.collection.IndexedIterable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public class PaginatedList {
|
public class PaginatedList extends MinionsGui {
|
||||||
public static void createList(SlotGuiInterface gui, int size, Function<Integer, GuiElementBuilder> display, Runnable onBack) {
|
private int page = 0;
|
||||||
AtomicInteger page = new AtomicInteger(0);
|
private SimpleGui gui;
|
||||||
addItems(page, gui, size, display);
|
private final Text title;
|
||||||
|
private final int size;
|
||||||
|
private final BiFunction<Integer, PaginatedList, GuiElementBuilder> display;
|
||||||
|
|
||||||
gui.setSlot(27, MinionGui.backButton(onBack));
|
public PaginatedList(MinionsGui parent, Text title, int size, BiFunction<Integer, PaginatedList, GuiElementBuilder> display) {
|
||||||
|
super(parent);
|
||||||
|
this.title = title;
|
||||||
|
this.size = size;
|
||||||
|
this.display = display;
|
||||||
|
open();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> void createList(SlotGuiInterface gui, List<T> list, Function<T, GuiElementBuilder> display, Runnable onBack) {
|
@Override
|
||||||
createList(gui, list.size(), i -> display.apply(list.get(i)), onBack);
|
protected void open() {
|
||||||
|
gui = new SimpleGui(ScreenHandlerType.GENERIC_9X4, viewer, false) {
|
||||||
|
@Override
|
||||||
|
public void onClose() {
|
||||||
|
onBackingClosed();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
gui.setTitle(title);
|
||||||
|
addItems();
|
||||||
|
gui.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> void createList(SlotGuiInterface gui, IndexedIterable<T> list, Function<T, GuiElementBuilder> display, Runnable onBack) {
|
@Override
|
||||||
createList(gui, list.size(), i -> display.apply(list.get(i)), onBack);
|
protected void closeBacking() {
|
||||||
|
gui.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addItems(AtomicInteger page, SlotGuiInterface gui, int size, Function<Integer, GuiElementBuilder> display) {
|
public static <T> void createList(MinionsGui parent, Text title, List<T> list, BiFunction<T, PaginatedList, GuiElementBuilder> display) {
|
||||||
for(int i = 27 * page.get(); i < Math.min(27 * (page.get() + 1), size); i++) {
|
new PaginatedList(parent, title, list.size(), (i, gui) -> display.apply(list.get(i), gui));
|
||||||
gui.addSlot(display.apply(i));
|
}
|
||||||
|
|
||||||
|
public static <T> void createList(MinionsGui parent, Text title, IndexedIterable<T> list, BiFunction<T, PaginatedList, GuiElementBuilder> display) {
|
||||||
|
new PaginatedList(parent, title, list.size(), (i, gui) -> display.apply(list.get(i), gui));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addItems() {
|
||||||
|
for(int i = 27 * page; i < Math.min(27 * (page + 1), size); i++) {
|
||||||
|
gui.addSlot(display.apply(i, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(page.get() > 0) {
|
if(page > 0) {
|
||||||
gui.setSlot(30, new GuiElementBuilder(Items.SPECTRAL_ARROW)
|
gui.setSlot(30, new GuiElementBuilder(Items.SPECTRAL_ARROW)
|
||||||
.setItemName(Text.translatable("book.page_button.previous"))
|
.setItemName(Text.translatable("book.page_button.previous"))
|
||||||
.setCallback(() -> {
|
.setCallback(() -> {
|
||||||
page.decrementAndGet();
|
page--;
|
||||||
addItems(page, gui, size, display);
|
addItems();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
gui.clearSlot(30);
|
gui.clearSlot(30);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(27 * (page.get() + 1) < size) {
|
if(27 * (page + 1) < size) {
|
||||||
gui.setSlot(32, new GuiElementBuilder(Items.ARROW)
|
gui.setSlot(32, new GuiElementBuilder(Items.ARROW)
|
||||||
.setItemName(Text.translatable("book.page_button.next"))
|
.setItemName(Text.translatable("book.page_button.next"))
|
||||||
.setCallback(() -> {
|
.setCallback(() -> {
|
||||||
page.incrementAndGet();
|
page++;
|
||||||
addItems(page, gui, size, display);
|
addItems();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
|||||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||||
import io.github.skippyall.minions.gui.Displayable;
|
import io.github.skippyall.minions.gui.Displayable;
|
||||||
import io.github.skippyall.minions.gui.GuiDisplay;
|
import io.github.skippyall.minions.gui.GuiDisplay;
|
||||||
|
import io.github.skippyall.minions.gui.MinionsGui;
|
||||||
|
import io.github.skippyall.minions.gui.minion.SimpleMinionsGui;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.screen.ScreenHandlerType;
|
import net.minecraft.screen.ScreenHandlerType;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
@@ -72,6 +74,36 @@ public class ChoiceInput {
|
|||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CompletableFuture<Void> confirm(MinionsGui parent, Text title) {
|
||||||
|
CompletableFuture<Void> future = new CompletableFuture<>();
|
||||||
|
|
||||||
|
new SimpleMinionsGui(parent, (onClose, me) -> {
|
||||||
|
SimpleGui gui = new SimpleGui(ScreenHandlerType.GENERIC_3X3, parent.getViewer(), false) {
|
||||||
|
@Override
|
||||||
|
public void onClose() {
|
||||||
|
future.cancel(false);
|
||||||
|
onClose.run();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
gui.setTitle(title);
|
||||||
|
|
||||||
|
gui.setSlot(3, new GuiElementBuilder(Items.REDSTONE_BLOCK)
|
||||||
|
.setName(Text.translatable("minions.gui.abort"))
|
||||||
|
.setCallback(() -> future.cancel(false))
|
||||||
|
);
|
||||||
|
|
||||||
|
gui.setSlot(5, new GuiElementBuilder(Items.EMERALD_BLOCK)
|
||||||
|
.setName(Text.translatable("minions.gui.confirm"))
|
||||||
|
.setCallback(() -> future.complete(null))
|
||||||
|
);
|
||||||
|
|
||||||
|
gui.open();
|
||||||
|
return gui;
|
||||||
|
});
|
||||||
|
return future;
|
||||||
|
}
|
||||||
|
|
||||||
public static BiFunction<ServerPlayerEntity, Boolean, CompletableFuture<Boolean>> inputBoolean(Text title) {
|
public static BiFunction<ServerPlayerEntity, Boolean, CompletableFuture<Boolean>> inputBoolean(Text title) {
|
||||||
return createDialogOpener(ScreenHandlerType.GENERIC_3X3, title, value -> {
|
return createDialogOpener(ScreenHandlerType.GENERIC_3X3, title, value -> {
|
||||||
if(value) {
|
if(value) {
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package io.github.skippyall.minions.gui.input;
|
package io.github.skippyall.minions.gui.input;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public interface Result<T, E> {
|
public interface Result<T, E> {
|
||||||
static <T> Result<T, String> wrap(UnsafeOperation<T> toWrap) {
|
static <T> Result<T, String> wrap(UnsafeOperation<T> toWrap) {
|
||||||
@@ -23,6 +25,22 @@ public interface Result<T, E> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static <T, E> Result<T, E> ofNullable(@Nullable T value, E error) {
|
||||||
|
if(value != null) {
|
||||||
|
return new Success<>(value);
|
||||||
|
} else {
|
||||||
|
return new Error<>(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static <T, E> Result<T, E> ofNullable(@Nullable T value, Supplier<E> error) {
|
||||||
|
if(value != null) {
|
||||||
|
return new Success<>(value);
|
||||||
|
} else {
|
||||||
|
return new Error<>(error.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean isSuccess();
|
boolean isSuccess();
|
||||||
|
|
||||||
T getOrDefault(T defaultValue);
|
T getOrDefault(T defaultValue);
|
||||||
@@ -33,10 +51,18 @@ public interface Result<T, E> {
|
|||||||
|
|
||||||
@NotNull Optional<T> getOptional();
|
@NotNull Optional<T> getOptional();
|
||||||
|
|
||||||
|
@NotNull Optional<E> getOptionalError();
|
||||||
|
|
||||||
void ifSuccess(@NotNull Consumer<T> handler);
|
void ifSuccess(@NotNull Consumer<T> handler);
|
||||||
|
|
||||||
void ifError(@NotNull Consumer<Error<T, E>> handler);
|
void ifError(@NotNull Consumer<Error<T, E>> handler);
|
||||||
|
|
||||||
|
<U> Result<U,E> map(Function<T, U> mapper);
|
||||||
|
|
||||||
|
<U> Result<U,E> flatMap(Function<T, Result<U, E>> mapper);
|
||||||
|
|
||||||
|
<U> Result<T,U> mapError(Function<E, U> mapper);
|
||||||
|
|
||||||
record Success<T, E>(T result) implements Result<T, E> {
|
record Success<T, E>(T result) implements Result<T, E> {
|
||||||
@Override
|
@Override
|
||||||
public boolean isSuccess() {
|
public boolean isSuccess() {
|
||||||
@@ -48,6 +74,11 @@ public interface Result<T, E> {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Optional<E> getOptionalError() {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T getOrThrow() {
|
public T getOrThrow() {
|
||||||
return result;
|
return result;
|
||||||
@@ -60,7 +91,7 @@ public interface Result<T, E> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Optional<T> getOptional() {
|
public @NotNull Optional<T> getOptional() {
|
||||||
return Optional.of(result);
|
return Optional.ofNullable(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -72,6 +103,21 @@ public interface Result<T, E> {
|
|||||||
public void ifError(@NotNull Consumer<Error<T, E>> handler) {
|
public void ifError(@NotNull Consumer<Error<T, E>> handler) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <U> Result<U, E> map(Function<T, U> mapper) {
|
||||||
|
return new Success<>(mapper.apply(result));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <U> Result<U, E> flatMap(Function<T, Result<U, E>> mapper) {
|
||||||
|
return mapper.apply(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <U> Result<T, U> mapError(Function<E, U> mapper) {
|
||||||
|
return new Success<>(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
record Error<T, E>(E message) implements Result<T, E> {
|
record Error<T, E>(E message) implements Result<T, E> {
|
||||||
@@ -101,6 +147,11 @@ public interface Result<T, E> {
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Optional<E> getOptionalError() {
|
||||||
|
return Optional.ofNullable(message);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ifSuccess(@NotNull Consumer<T> handler) {
|
public void ifSuccess(@NotNull Consumer<T> handler) {
|
||||||
|
|
||||||
@@ -110,6 +161,21 @@ public interface Result<T, E> {
|
|||||||
public void ifError(@NotNull Consumer<Error<T, E>> handler) {
|
public void ifError(@NotNull Consumer<Error<T, E>> handler) {
|
||||||
handler.accept(this);
|
handler.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <U> Result<U, E> map(Function<T, U> mapper) {
|
||||||
|
return new Error<>(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <U> Result<U, E> flatMap(Function<T, Result<U, E>> mapper) {
|
||||||
|
return new Error<>(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <U> Result<T, U> mapError(Function<E, U> mapper) {
|
||||||
|
return new Error<>(mapper.apply(message));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UnsafeOperation<T> {
|
interface UnsafeOperation<T> {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package io.github.skippyall.minions.gui.input;
|
|||||||
|
|
||||||
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
||||||
import eu.pb4.sgui.api.gui.AnvilInputGui;
|
import eu.pb4.sgui.api.gui.AnvilInputGui;
|
||||||
|
import io.github.skippyall.minions.gui.MinionsGui;
|
||||||
|
import io.github.skippyall.minions.gui.minion.SimpleMinionsGui;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.screen.AnvilScreenHandler;
|
import net.minecraft.screen.AnvilScreenHandler;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
@@ -37,24 +39,54 @@ public class TextInput<T> extends AnvilInputGui {
|
|||||||
return input(player, title, defaultValue, (String string) -> CompletableFuture.completedFuture(parser.apply(string)));
|
return input(player, title, defaultValue, (String string) -> CompletableFuture.completedFuture(parser.apply(string)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> CompletableFuture<T> inputSync(MinionsGui gui, Text title, String defaultValue, Function<String, Result<T, Text>> parser) {
|
||||||
|
return input(gui, title, defaultValue, (String string) -> CompletableFuture.completedFuture(parser.apply(string)));
|
||||||
|
}
|
||||||
|
|
||||||
public static <T> CompletableFuture<T> input(ServerPlayerEntity player, Text title, String defaultValue, Function<String, CompletableFuture<Result<T, Text>>> parser) {
|
public static <T> CompletableFuture<T> input(ServerPlayerEntity player, Text title, String defaultValue, Function<String, CompletableFuture<Result<T, Text>>> parser) {
|
||||||
CompletableFuture<T> future = new CompletableFuture<>();
|
CompletableFuture<T> future = new CompletableFuture<>();
|
||||||
new TextInput<>(player, title, defaultValue, parser, future).open();
|
new TextInput<>(player, title, defaultValue, parser, future).open();
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> CompletableFuture<T> input(MinionsGui gui, Text title, String defaultValue, Function<String, CompletableFuture<Result<T, Text>>> parser) {
|
||||||
|
CompletableFuture<T> future = new CompletableFuture<>();
|
||||||
|
new SimpleMinionsGui(gui, (onClose, me) -> {
|
||||||
|
TextInput<T> input = new TextInput<>(gui.getViewer(), title, defaultValue, parser, future);
|
||||||
|
future.handle((v, e) -> {
|
||||||
|
onClose.run();
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
input.open();
|
||||||
|
return input;
|
||||||
|
});
|
||||||
|
return future;
|
||||||
|
}
|
||||||
|
|
||||||
public static CompletableFuture<String> inputString(ServerPlayerEntity player, Text title, String defaultValue) {
|
public static CompletableFuture<String> inputString(ServerPlayerEntity player, Text title, String defaultValue) {
|
||||||
return inputSync(player, title, defaultValue, Result.Success::new);
|
return inputSync(player, title, defaultValue, Result.Success::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CompletableFuture<String> inputString(MinionsGui gui, Text title, String defaultValue) {
|
||||||
|
return inputSync(gui, title, defaultValue, Result.Success::new);
|
||||||
|
}
|
||||||
|
|
||||||
public static CompletableFuture<Long> inputLong(ServerPlayerEntity player, Text title, String defaultValue) {
|
public static CompletableFuture<Long> inputLong(ServerPlayerEntity player, Text title, String defaultValue) {
|
||||||
return inputSync(player, title, defaultValue, string -> Result.wrapCustomError(() -> Long.valueOf(string), Text.translatable("minions.command.input.int.fail")));
|
return inputSync(player, title, defaultValue, string -> Result.wrapCustomError(() -> Long.valueOf(string), Text.translatable("minions.command.input.int.fail")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CompletableFuture<Long> inputLong(MinionsGui gui, Text title, String defaultValue) {
|
||||||
|
return inputSync(gui, title, defaultValue, string -> Result.wrapCustomError(() -> Long.valueOf(string), Text.translatable("minions.command.input.int.fail")));
|
||||||
|
}
|
||||||
|
|
||||||
public static CompletableFuture<Double> inputDouble(ServerPlayerEntity player, Text title, String defaultValue) {
|
public static CompletableFuture<Double> inputDouble(ServerPlayerEntity player, Text title, String defaultValue) {
|
||||||
return inputSync(player, title, defaultValue, string -> Result.wrapCustomError(() -> Double.valueOf(string), Text.translatable("minions.command.input.float.fail")));
|
return inputSync(player, title, defaultValue, string -> Result.wrapCustomError(() -> Double.valueOf(string), Text.translatable("minions.command.input.float.fail")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CompletableFuture<Double> inputDouble(MinionsGui gui, Text title, String defaultValue) {
|
||||||
|
return inputSync(gui, title, defaultValue, string -> Result.wrapCustomError(() -> Double.valueOf(string), Text.translatable("minions.command.input.float.fail")));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInput(String input) {
|
public void onInput(String input) {
|
||||||
updateConfirmButton(input);
|
updateConfirmButton(input);
|
||||||
|
|||||||
@@ -3,79 +3,160 @@ package io.github.skippyall.minions.gui.instruction;
|
|||||||
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
||||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||||
import io.github.skippyall.minions.gui.GuiDisplay;
|
import io.github.skippyall.minions.gui.GuiDisplay;
|
||||||
|
import io.github.skippyall.minions.gui.MinionsGui;
|
||||||
|
import io.github.skippyall.minions.gui.PaginatedList;
|
||||||
|
import io.github.skippyall.minions.gui.minion.GuiContext;
|
||||||
import io.github.skippyall.minions.minion.MinionRuntime;
|
import io.github.skippyall.minions.minion.MinionRuntime;
|
||||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||||
import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
||||||
import io.github.skippyall.minions.program.supplier.Parameter;
|
import io.github.skippyall.minions.program.supplier.Parameter;
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplier;
|
import io.github.skippyall.minions.program.supplier.ValueSupplier;
|
||||||
|
import io.github.skippyall.minions.program.supplier.ValueSupplierList;
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplierType;
|
import io.github.skippyall.minions.program.supplier.ValueSupplierType;
|
||||||
import io.github.skippyall.minions.registration.MinionRegistries;
|
import io.github.skippyall.minions.registration.MinionRegistries;
|
||||||
import io.github.skippyall.minions.util.TranslationUtil;
|
import io.github.skippyall.minions.util.TranslationUtil;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.screen.ScreenHandlerType;
|
import net.minecraft.screen.ScreenHandlerType;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
public class ArgumentGui extends MinionsGui {
|
||||||
|
private final GuiContext.ValueSupplier context;
|
||||||
|
private final MinionFakePlayer minion;
|
||||||
|
private final ConfiguredInstruction<MinionRuntime> instruction;
|
||||||
|
private final Parameter<?> parameter;
|
||||||
|
|
||||||
public class ArgumentGui {
|
private SimpleGui gui;
|
||||||
public static <T, A extends ValueSupplier<T, MinionRuntime>> void configureArgumentMenu(String instructionName, ConfiguredInstruction<MinionRuntime> instruction, Parameter<?> parameter, MinionFakePlayer minion, ServerPlayerEntity player) {
|
|
||||||
if (!InstructionGui.checkInstructionExists(instructionName, instruction, minion, player)) {
|
private @Nullable ValueSupplierType<MinionRuntime> argumentType;
|
||||||
return;
|
private @Nullable ValueSupplierList.ValueSupplierEntry<?, MinionRuntime> entry;
|
||||||
|
|
||||||
|
public ArgumentGui(MinionsGui parent, GuiContext.ValueSupplier context) {
|
||||||
|
super(parent);
|
||||||
|
minion = context.getMinion();
|
||||||
|
instruction = context.getInstruction();
|
||||||
|
this.parameter = context.getParameter();
|
||||||
|
this.context = context;
|
||||||
|
|
||||||
|
this.entry = instruction.getArguments().getEntry(parameter);
|
||||||
|
if(entry != null) {
|
||||||
|
this.argumentType = entry.getSupplier().getType();
|
||||||
}
|
}
|
||||||
|
open();
|
||||||
@Nullable ValueSupplier<?, MinionRuntime> argument = instruction.getArguments().getArgument(parameter);
|
|
||||||
|
|
||||||
if(argument == null) {
|
|
||||||
configureTypeAndValue(instructionName, instruction, parameter, minion, player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
configureArgumentHelper(instructionName, instruction, parameter, argument, minion, player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <F, T> void configureArgumentHelper(String instructionName, ConfiguredInstruction<MinionRuntime> instruction, Parameter<T> parameter, ValueSupplier<F, MinionRuntime> argument, MinionFakePlayer minion, ServerPlayerEntity player) {
|
public String getInstructionName() {
|
||||||
SimpleGui gui = new InstructionBoundSimpleGui(ScreenHandlerType.GENERIC_3X3, player, minion, instruction);
|
return context.getName();
|
||||||
|
}
|
||||||
|
|
||||||
ItemStack displayStack = GuiDisplay.getDisplayStack(MinionRegistries.VALUE_SUPPLIER_TYPES, argument.getType(), player.getRegistryManager());
|
public @Nullable ValueSupplier<?, MinionRuntime> getArgument() {
|
||||||
|
if(entry != null) {
|
||||||
|
return entry.getSupplier();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void open() {
|
||||||
|
gui = new SimpleGui(ScreenHandlerType.GENERIC_3X3, viewer, false) {
|
||||||
|
@Override
|
||||||
|
public void onClose() {
|
||||||
|
onBackingClosed();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
gui.setTitle(Text.translatable(
|
||||||
|
"minions.gui.instruction.argument.title",
|
||||||
|
parameter.name(),
|
||||||
|
Text.translatable(TranslationUtil.getTranslationKey(parameter.type(), MinionRegistries.VALUE_TYPES))
|
||||||
|
));
|
||||||
|
|
||||||
|
updateTypeConfiguration();
|
||||||
|
updateArgumentConfiguration();
|
||||||
|
updateConverterConfiguration();
|
||||||
|
gui.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTypeConfiguration() {
|
||||||
|
ItemStack displayStack;
|
||||||
|
if(argumentType != null) {
|
||||||
|
displayStack = GuiDisplay.getDisplayStack(MinionRegistries.VALUE_SUPPLIER_TYPES, argumentType, viewer.getRegistryManager());
|
||||||
|
} else {
|
||||||
|
displayStack = new ItemStack(Items.BARRIER);
|
||||||
|
}
|
||||||
|
|
||||||
gui.setSlot(3, new GuiElementBuilder(displayStack)
|
gui.setSlot(3, new GuiElementBuilder(displayStack)
|
||||||
.setName(Text.translatable("minions.gui.instruction.argument.configure.type", Text.translatable(TranslationUtil.getTranslationKey(argument.getType(), MinionRegistries.VALUE_SUPPLIER_TYPES, "minions.gui.instruction.argument.configure.type.unset"))))
|
.setName(Text.translatable("minions.gui.instruction.argument.configure.type"))
|
||||||
.setCallback(() -> configureTypeAndValue(instructionName, instruction, parameter, minion, player))
|
.addLoreLine(Text.translatable(TranslationUtil.getTranslationKey(
|
||||||
|
argumentType,
|
||||||
|
MinionRegistries.VALUE_SUPPLIER_TYPES,
|
||||||
|
"minions.gui.not_set"
|
||||||
|
)))
|
||||||
|
.setCallback(this::selectArgumentType)
|
||||||
);
|
);
|
||||||
gui.setSlot(5, new GuiElementBuilder(Items.STRUCTURE_VOID)
|
|
||||||
.setName(Text.literal("Configure"))
|
|
||||||
.setCallback(() -> argument.getType().openConfiguration(player, argument.getValueType(), argument)
|
|
||||||
.thenAccept(newArgument -> {
|
|
||||||
instruction.getArguments().setArgument(parameter, newArgument);
|
|
||||||
configureArgumentMenu(instructionName, instruction, parameter, minion, player);
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
|
||||||
gui.open();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CompletableFuture<ValueSupplierType<MinionRuntime>> selectArgumentType(ServerPlayerEntity player, MinionFakePlayer minion, ConfiguredInstruction<MinionRuntime> instruction) {
|
private void updateArgumentConfiguration() {
|
||||||
CompletableFuture<ValueSupplierType<MinionRuntime>> future = new CompletableFuture<>();
|
if(argumentType != null) {
|
||||||
SimpleGui gui = new InstructionBoundSimpleGui(ScreenHandlerType.GENERIC_9X3, player, minion, instruction);
|
gui.setSlot(4, new GuiElementBuilder(Items.STRUCTURE_VOID)
|
||||||
for (ValueSupplierType<MinionRuntime> type : MinionRegistries.VALUE_SUPPLIER_TYPES) {
|
.setName(Text.translatable("minions.gui.instruction.argument.configure.data"))
|
||||||
gui.addSlot(new GuiElementBuilder(GuiDisplay.getDisplayStackWithName(MinionRegistries.VALUE_SUPPLIER_TYPES, type, player.getRegistryManager()))
|
.addLoreLine(getArgument() != null ? getArgument().getDisplayText() : Text.translatable("minions.gui.not_set"))
|
||||||
.setCallback(() -> future.complete(type))
|
.setCallback(() -> argumentType.openConfiguration(this, parameter.type(), getArgument())
|
||||||
|
.thenAccept(newArgument -> {
|
||||||
|
setArgument(newArgument);
|
||||||
|
if(child != null) {
|
||||||
|
child.close();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
gui.open();
|
|
||||||
return future;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> void configureTypeAndValue(String name, ConfiguredInstruction<MinionRuntime> instruction, Parameter<T> parameter, MinionFakePlayer minion, ServerPlayerEntity player) {
|
private void updateConverterConfiguration() {
|
||||||
selectArgumentType(player, minion, instruction)
|
if(entry != null) {
|
||||||
.thenApply(type -> type.openConfiguration(player, parameter.type(), null)
|
gui.setSlot(5, new GuiElementBuilder(Items.CRAFTER)
|
||||||
.thenAccept(v -> {
|
.setName(Text.translatable("minions.gui.instruction.converters"))
|
||||||
instruction.getArguments().setArgument(parameter, v);
|
.setCallback(this::configureConvertersMenu)
|
||||||
configureArgumentMenu(name, instruction, parameter, minion, player);
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void closeBacking() {
|
||||||
|
gui.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArgumentType(ValueSupplierType<MinionRuntime> type) {
|
||||||
|
this.argumentType = type;
|
||||||
|
if(entry != null && getArgument().getType() != argumentType) {
|
||||||
|
instruction.getArguments().removeEntry(parameter);
|
||||||
|
entry = null;
|
||||||
|
}
|
||||||
|
updateTypeConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArgument(ValueSupplier<?, MinionRuntime> argument) {
|
||||||
|
if(entry != null) {
|
||||||
|
entry.setSupplier(argument);
|
||||||
|
} else {
|
||||||
|
entry = instruction.getArguments().createEntry(parameter, argument);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectArgumentType() {
|
||||||
|
PaginatedList.createList(this, Text.translatable("minions.gui.instruction.argument.configure.type.title"), MinionRegistries.VALUE_SUPPLIER_TYPES, (type, me) ->
|
||||||
|
new GuiElementBuilder(GuiDisplay.getDisplayStackWithName(MinionRegistries.VALUE_SUPPLIER_TYPES, type, viewer.getRegistryManager()))
|
||||||
|
.setCallback(() -> {
|
||||||
|
setArgumentType(type);
|
||||||
|
me.close();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void configureConvertersMenu() {
|
||||||
|
if(entry != null) {
|
||||||
|
new ConverterListGui(this, entry.getConverters(), entry.getSupplier().getValueType(), entry.getParameter().type());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+55
-33
@@ -1,78 +1,100 @@
|
|||||||
package io.github.skippyall.minions.gui.instruction;
|
package io.github.skippyall.minions.gui.instruction;
|
||||||
|
|
||||||
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
||||||
|
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||||
|
import io.github.skippyall.minions.clipboard.ClipboardItem;
|
||||||
|
import io.github.skippyall.minions.gui.MinionsGui;
|
||||||
import io.github.skippyall.minions.gui.input.ChoiceInput;
|
import io.github.skippyall.minions.gui.input.ChoiceInput;
|
||||||
|
import io.github.skippyall.minions.gui.minion.GuiContext;
|
||||||
|
import io.github.skippyall.minions.minion.MinionListener;
|
||||||
import io.github.skippyall.minions.minion.MinionRuntime;
|
import io.github.skippyall.minions.minion.MinionRuntime;
|
||||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||||
import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
||||||
|
import io.github.skippyall.minions.program.instruction.ConfiguredInstructionListener;
|
||||||
import io.github.skippyall.minions.program.supplier.Parameter;
|
import io.github.skippyall.minions.program.supplier.Parameter;
|
||||||
import io.github.skippyall.minions.clipboard.ClipboardItem;
|
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.screen.ScreenHandlerType;
|
import net.minecraft.screen.ScreenHandlerType;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
public class ConfigureInstructionGui extends InstructionBoundSimpleGui {
|
public class ConfigureInstructionGui extends MinionsGui implements ConfiguredInstructionListener, MinionListener {
|
||||||
private String name;
|
private String name;
|
||||||
|
private final ConfiguredInstruction<MinionRuntime> instruction;
|
||||||
|
private final MinionFakePlayer minion;
|
||||||
|
|
||||||
private ConfigureInstructionGui(ScreenHandlerType<?> type, ServerPlayerEntity player, MinionFakePlayer minion, ConfiguredInstruction<MinionRuntime> configuredInstruction, String name) {
|
private final GuiContext.Instruction context;
|
||||||
super(type, player, minion, configuredInstruction);
|
|
||||||
this.name = name;
|
private SimpleGui gui;
|
||||||
init();
|
|
||||||
|
public ConfigureInstructionGui(MinionsGui parent, GuiContext.Instruction context) {
|
||||||
|
super(parent);
|
||||||
|
this.name = context.getName();
|
||||||
|
this.instruction = context.getInstruction();
|
||||||
|
this.minion = context.getMinion();
|
||||||
|
this.context = context;
|
||||||
|
minion.addMinionListener(this);
|
||||||
|
instruction.addListener(this);
|
||||||
|
open();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void configureInstructionMenu(String name, ConfiguredInstruction<MinionRuntime> instruction, MinionFakePlayer minion, ServerPlayerEntity player) {
|
@Override
|
||||||
if(!InstructionGui.checkInstructionExists(name, instruction, minion, player)) {
|
protected void open() {
|
||||||
return;
|
gui = new SimpleGui(ScreenHandlerType.GENERIC_9X3, viewer, false) {
|
||||||
}
|
@Override
|
||||||
|
public void onClose() {
|
||||||
|
onBackingClosed();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
ConfigureInstructionGui gui = new ConfigureInstructionGui(ScreenHandlerType.GENERIC_9X3, player, minion, instruction, name);
|
gui.setTitle(Text.literal(name));
|
||||||
|
|
||||||
gui.open();
|
gui.setSlot(7, new GuiElementBuilder(Items.ANVIL)
|
||||||
}
|
|
||||||
|
|
||||||
private void init() {
|
|
||||||
setTitle(Text.literal(name));
|
|
||||||
|
|
||||||
setSlot(7, new GuiElementBuilder(Items.ANVIL)
|
|
||||||
.setName(Text.translatable("minions.gui.instruction.configure.rename"))
|
.setName(Text.translatable("minions.gui.instruction.configure.rename"))
|
||||||
.setCallback(() -> InstructionGui.inputInstructionName(minion, player, name).thenAccept(newName -> {
|
.setCallback(() -> InstructionGui.inputInstructionName(this, context, name).thenAccept(newName -> {
|
||||||
minion.getInstructionManager().setInstructionName(name, newName);
|
minion.getInstructionManager().setInstructionName(name, newName);
|
||||||
configureInstructionMenu(newName, instruction, minion, player);
|
reopen();
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
|
|
||||||
setSlot(8, new GuiElementBuilder(Items.LAVA_BUCKET)
|
gui.setSlot(8, new GuiElementBuilder(Items.LAVA_BUCKET)
|
||||||
.setName(Text.translatable("minions.gui.instruction.configure.delete"))
|
.setName(Text.translatable("minions.gui.instruction.configure.delete"))
|
||||||
.setCallback(() -> ChoiceInput.confirm(player, Text.translatable("minions.gui.instruction.configure.delete.confirm", name))
|
.setCallback(() -> ChoiceInput.confirm(this, Text.translatable("minions.gui.instruction.configure.delete.confirm", name))
|
||||||
.thenAccept(v -> {
|
.thenAccept(v -> {
|
||||||
minion.getInstructionManager().removeInstruction(name);
|
minion.getInstructionManager().removeInstruction(name);
|
||||||
InstructionGui.instructionList(minion, player);
|
close();
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
|
|
||||||
updateSuppliers();
|
updateSuppliers();
|
||||||
|
|
||||||
setSlot(13, InstructionGui.createInstructionElement(instruction.getInstruction(), player.getRegistryManager()));
|
gui.setSlot(13, InstructionGui.createInstructionElement(instruction.getInstruction(), viewer.getRegistryManager()));
|
||||||
|
|
||||||
setSlot(25, new GuiElementBuilder(Items.FEATHER)
|
gui.setSlot(25, new GuiElementBuilder(Items.FEATHER)
|
||||||
.setName(Text.translatable("minions.gui.instruction.configure.copy"))
|
.setName(Text.translatable("minions.gui.instruction.configure.copy"))
|
||||||
.addLoreLine(Text.translatable("minions.gui.instruction.configure.copy.description"))
|
.addLoreLine(Text.translatable("minions.gui.instruction.configure.copy.description"))
|
||||||
.setCallback(() -> {
|
.setCallback(() -> {
|
||||||
player.getInventory().offer(ClipboardItem.createInstructionReference(minion, name), true);
|
viewer.getInventory().offer(ClipboardItem.createInstructionReference(minion, name), true);
|
||||||
player.playSoundToPlayer(SoundEvents.BLOCK_NOTE_BLOCK_CHIME.value(), SoundCategory.BLOCKS, 1, 1);
|
viewer.playSoundToPlayer(SoundEvents.BLOCK_NOTE_BLOCK_CHIME.value(), SoundCategory.BLOCKS, 1, 1);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
updateRunSlot();
|
updateRunSlot();
|
||||||
|
gui.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void closeBacking() {
|
||||||
|
gui.close();
|
||||||
|
minion.removeMinionListener(this);
|
||||||
|
instruction.removeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInstructionRename(MinionFakePlayer minion, ConfiguredInstruction<?> instruction, String oldName, String newName) {
|
public void onInstructionRename(MinionFakePlayer minion, ConfiguredInstruction<?> instruction, String oldName, String newName) {
|
||||||
this.setTitle(Text.literal(newName));
|
gui.setTitle(Text.literal(newName));
|
||||||
name = newName;
|
name = newName;
|
||||||
|
context.setName(newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -92,12 +114,12 @@ public class ConfigureInstructionGui extends InstructionBoundSimpleGui {
|
|||||||
|
|
||||||
private void updateRunSlot() {
|
private void updateRunSlot() {
|
||||||
if(!instruction.isRunning()) {
|
if(!instruction.isRunning()) {
|
||||||
setSlot(26, new GuiElementBuilder(Items.ARROW)
|
gui.setSlot(26, new GuiElementBuilder(Items.ARROW)
|
||||||
.setName(Text.translatable("minions.gui.instruction.run"))
|
.setName(Text.translatable("minions.gui.instruction.run"))
|
||||||
.setCallback(() -> instruction.run(minion.getInstructionManager()))
|
.setCallback(() -> instruction.run(minion.getInstructionManager()))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
setSlot(26, new GuiElementBuilder(Items.BARRIER)
|
gui.setSlot(26, new GuiElementBuilder(Items.BARRIER)
|
||||||
.setName(Text.translatable("minions.gui.instruction.stop"))
|
.setName(Text.translatable("minions.gui.instruction.stop"))
|
||||||
.setCallback(() -> instruction.stop(minion.getInstructionManager()))
|
.setCallback(() -> instruction.stop(minion.getInstructionManager()))
|
||||||
);
|
);
|
||||||
@@ -107,8 +129,8 @@ public class ConfigureInstructionGui extends InstructionBoundSimpleGui {
|
|||||||
private void updateSuppliers() {
|
private void updateSuppliers() {
|
||||||
int slot = 12;
|
int slot = 12;
|
||||||
for(Parameter<?> parameter : instruction.getInstruction().getParameters().reversed()) {
|
for(Parameter<?> parameter : instruction.getInstruction().getParameters().reversed()) {
|
||||||
setSlot(slot, InstructionGui.createParameterElement(parameter, instruction.getArguments().getArgument(parameter), player.getRegistryManager())
|
gui.setSlot(slot, InstructionGui.createParameterElement(parameter, instruction.getArguments().getArgument(parameter), viewer.getRegistryManager())
|
||||||
.setCallback(() -> ArgumentGui.configureArgumentMenu(name, instruction, parameter, minion, player))
|
.setCallback(() -> new ArgumentGui(this, GuiContext.ValueSupplier.create(context, parameter)))
|
||||||
);
|
);
|
||||||
slot--;
|
slot--;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,71 +1,131 @@
|
|||||||
package io.github.skippyall.minions.gui.instruction;
|
package io.github.skippyall.minions.gui.instruction;
|
||||||
|
|
||||||
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
||||||
|
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||||
import io.github.skippyall.minions.gui.GuiDisplay;
|
import io.github.skippyall.minions.gui.GuiDisplay;
|
||||||
|
import io.github.skippyall.minions.gui.MinionsGui;
|
||||||
import io.github.skippyall.minions.gui.PaginatedList;
|
import io.github.skippyall.minions.gui.PaginatedList;
|
||||||
import io.github.skippyall.minions.minion.MinionRuntime;
|
import io.github.skippyall.minions.program.conversion.ConverterList;
|
||||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
|
||||||
import io.github.skippyall.minions.program.conversion.ValueConverter;
|
import io.github.skippyall.minions.program.conversion.ValueConverter;
|
||||||
import io.github.skippyall.minions.program.conversion.ValueConverterType;
|
import io.github.skippyall.minions.program.conversion.ValueConverterType;
|
||||||
import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
|
||||||
import io.github.skippyall.minions.program.supplier.Parameter;
|
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplierList;
|
|
||||||
import io.github.skippyall.minions.program.value.ValueType;
|
import io.github.skippyall.minions.program.value.ValueType;
|
||||||
import io.github.skippyall.minions.registration.MinionRegistries;
|
import io.github.skippyall.minions.registration.MinionRegistries;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.registry.DynamicRegistryManager;
|
import net.minecraft.registry.DynamicRegistryManager;
|
||||||
import net.minecraft.screen.ScreenHandlerType;
|
import net.minecraft.screen.ScreenHandlerType;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.text.Text;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class ConverterGui {
|
public class ConverterGui extends MinionsGui {
|
||||||
public static void configureConvertersMenu(ServerPlayerEntity player, MinionFakePlayer minion, ConfiguredInstruction<MinionRuntime> instruction, Parameter<?> parameter, Runnable back) {
|
private @Nullable ValueConverterType<?> valueConverterType;
|
||||||
InstructionBoundSimpleGui gui = new InstructionBoundSimpleGui(ScreenHandlerType.GENERIC_9X4, player, minion, instruction);
|
private @Nullable ValueConverter<?,?> converter;
|
||||||
|
private ConverterList list;
|
||||||
|
private ValueType<?> from, to;
|
||||||
|
|
||||||
|
private SimpleGui gui;
|
||||||
|
private boolean isNew;
|
||||||
|
private int index;
|
||||||
|
|
||||||
|
public ConverterGui(MinionsGui parent, @Nullable ValueConverter<?,?> converter, ValueType<?> from, ValueType<?> to, ConverterList list, boolean isNew, int index) {
|
||||||
|
super(parent);
|
||||||
|
open();
|
||||||
|
this.converter = converter;
|
||||||
|
if(converter != null) {
|
||||||
|
this.valueConverterType = converter.getType();
|
||||||
|
}
|
||||||
|
this.from = from;
|
||||||
|
this.to = to;
|
||||||
|
this.list = list;
|
||||||
|
this.isNew = isNew;
|
||||||
|
this.index = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void open() {
|
||||||
|
gui = new SimpleGui(ScreenHandlerType.GENERIC_3X3, viewer, false) {
|
||||||
|
@Override
|
||||||
|
public void onClose() {
|
||||||
|
onBackingClosed();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
gui.setTitle(Text.translatable("minions.gui.instruction.converter.title"));
|
||||||
|
|
||||||
|
updateTypeDisplay();
|
||||||
|
updateConverterDisplay();
|
||||||
|
|
||||||
ValueSupplierList.ValueSupplierEntry<?,?,MinionRuntime> entry = instruction.getArguments().getEntry(parameter);
|
|
||||||
PaginatedList.createList(
|
|
||||||
gui,
|
|
||||||
entry.getConverters(),
|
|
||||||
converter -> createConverterElement(converter, player.getRegistryManager())
|
|
||||||
.setCallback(() -> configureConverter(player, minion, instruction, parameter, entry, converter)),
|
|
||||||
back
|
|
||||||
);
|
|
||||||
gui.open();
|
gui.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void reopen() {
|
||||||
|
gui.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTypeDisplay() {
|
||||||
|
gui.setSlot(3, new GuiElementBuilder(GuiDisplay.getDisplayStackWithName(MinionRegistries.VALUE_CONVERTER_TYPES, valueConverterType, viewer.getRegistryManager()))
|
||||||
|
.setCallback(this::configureType)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateConverterDisplay() {
|
||||||
|
gui.setSlot(5, new GuiElementBuilder(Items.STRUCTURE_VOID)
|
||||||
|
.setName(Text.translatable("minions.gui.instruction.converter.title"))
|
||||||
|
.addLoreLine(converter == null ? Text.translatable("minions.gui.not_set") : converter.getDisplayText())
|
||||||
|
.setCallback(this::configureData)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void closeBacking() {
|
||||||
|
gui.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setType(ValueConverterType<?> valueConverterType) {
|
||||||
|
this.valueConverterType = valueConverterType;
|
||||||
|
updateTypeDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConverter(ValueConverter<?,?> converter) {
|
||||||
|
this.converter = converter;
|
||||||
|
if(isNew) {
|
||||||
|
list.getConverters().add(index, converter);
|
||||||
|
isNew = false;
|
||||||
|
} else {
|
||||||
|
list.getConverters().set(index, converter);
|
||||||
|
}
|
||||||
|
updateConverterDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void configureType() {
|
||||||
|
PaginatedList.createList(
|
||||||
|
this,
|
||||||
|
Text.translatable("minions.gui.instruction.converter.type.title"),
|
||||||
|
MinionRegistries.VALUE_CONVERTER_TYPES,
|
||||||
|
(type, me) -> new GuiElementBuilder(
|
||||||
|
GuiDisplay.getDisplayStackWithName(MinionRegistries.VALUE_CONVERTER_TYPES, type, viewer.getRegistryManager())
|
||||||
|
).setCallback(() -> {
|
||||||
|
setType(type);
|
||||||
|
me.close();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void configureData() {
|
||||||
|
if(valueConverterType != null) {
|
||||||
|
valueConverterType.configure(this, from, to, converter)
|
||||||
|
.thenAccept(newConverter -> {
|
||||||
|
setConverter(newConverter);
|
||||||
|
if(child != null) {
|
||||||
|
child.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static GuiElementBuilder createConverterElement(ValueConverter<?,?> converter, DynamicRegistryManager manager) {
|
public static GuiElementBuilder createConverterElement(ValueConverter<?,?> converter, DynamicRegistryManager manager) {
|
||||||
GuiElementBuilder builder = new GuiElementBuilder(GuiDisplay.getDisplayStack(MinionRegistries.VALUE_CONVERTER_TYPES, converter.getType(), manager));
|
GuiElementBuilder builder = new GuiElementBuilder(GuiDisplay.getDisplayStack(MinionRegistries.VALUE_CONVERTER_TYPES, converter.getType(), manager));
|
||||||
builder.addLoreLine(converter.getDisplayText());
|
builder.addLoreLine(converter.getDisplayText());
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void configureConverter(ServerPlayerEntity player, MinionFakePlayer minion, ConfiguredInstruction<MinionRuntime> instruction, Parameter<?> parameter, ValueSupplierList.ValueSupplierEntry<?,?,MinionRuntime> entry, @Nullable ValueConverter<?,?> converter) {
|
|
||||||
InstructionBoundSimpleGui gui = new InstructionBoundSimpleGui(ScreenHandlerType.GENERIC_3X3, player, minion, instruction);
|
|
||||||
gui.setSlot(3, new GuiElementBuilder(GuiDisplay.getDisplayStackWithName(MinionRegistries.VALUE_CONVERTER_TYPES, converter.getType(), player.getRegistryManager()))
|
|
||||||
.setCallback(() -> {
|
|
||||||
InstructionBoundSimpleGui chooseTypeGui = new InstructionBoundSimpleGui(ScreenHandlerType.GENERIC_9X4, player, minion, instruction);
|
|
||||||
PaginatedList.createList(
|
|
||||||
chooseTypeGui,
|
|
||||||
MinionRegistries.VALUE_CONVERTER_TYPES,
|
|
||||||
type -> new GuiElementBuilder(GuiDisplay.getDisplayStackWithName(MinionRegistries.VALUE_CONVERTER_TYPES, type, player.getRegistryManager()))
|
|
||||||
.setCallback(() -> {
|
|
||||||
entry.set
|
|
||||||
}),
|
|
||||||
() -> configureConverter(player, minion, instruction, parameter, entry, converter)
|
|
||||||
);
|
|
||||||
}));
|
|
||||||
|
|
||||||
gui.setSlot(5, new GuiElementBuilder(Items.STRUCTURE_VOID));
|
|
||||||
|
|
||||||
gui.open();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <F,T> void selectConverterMenu(ValueType<F> from, ValueType<T> to, ServerPlayerEntity player, MinionFakePlayer minion, ConfiguredInstruction<MinionRuntime> instruction) {
|
|
||||||
InstructionBoundSimpleGui gui = new InstructionBoundSimpleGui(ScreenHandlerType.GENERIC_9X3, player, minion, instruction);
|
|
||||||
for(ValueConverterType<?> valueConverterType : MinionRegistries.VALUE_CONVERTER_TYPES) {
|
|
||||||
gui.addSlot(new GuiElementBuilder(GuiDisplay.getDisplayStackWithName(MinionRegistries.VALUE_CONVERTER_TYPES, valueConverterType, player.getRegistryManager()))
|
|
||||||
.setCallback(() -> valueConverterType.configure(player, from, to, null).thenAccept(c -> )));
|
|
||||||
}
|
|
||||||
gui.open();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,109 @@
|
|||||||
|
package io.github.skippyall.minions.gui.instruction;
|
||||||
|
|
||||||
|
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
||||||
|
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||||
|
import io.github.skippyall.minions.gui.GuiDisplay;
|
||||||
|
import io.github.skippyall.minions.gui.MinionsGui;
|
||||||
|
import io.github.skippyall.minions.program.conversion.ConverterList;
|
||||||
|
import io.github.skippyall.minions.program.conversion.ValueConverter;
|
||||||
|
import io.github.skippyall.minions.program.value.ValueType;
|
||||||
|
import io.github.skippyall.minions.registration.MinionRegistries;
|
||||||
|
import io.github.skippyall.minions.util.TranslationUtil;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.screen.ScreenHandlerType;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
|
public class ConverterListGui extends MinionsGui {
|
||||||
|
private ConverterList converters;
|
||||||
|
|
||||||
|
private SimpleGui gui;
|
||||||
|
private int page = 0;
|
||||||
|
|
||||||
|
private ValueType<?> inputType;
|
||||||
|
private ValueType<?> outputType;
|
||||||
|
|
||||||
|
public ConverterListGui(MinionsGui parent, ConverterList converters, ValueType<?> inputType, ValueType<?> outputType) {
|
||||||
|
super(parent);
|
||||||
|
this.converters = converters;
|
||||||
|
this.inputType = inputType;
|
||||||
|
this.outputType = outputType;
|
||||||
|
open();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void open() {
|
||||||
|
gui = new SimpleGui(ScreenHandlerType.GENERIC_9X3, viewer, false) {
|
||||||
|
@Override
|
||||||
|
public void onClose() {
|
||||||
|
onBackingClosed();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
gui.setTitle(Text.translatable("minions.gui.instruction.converters"));
|
||||||
|
|
||||||
|
updateConverters();
|
||||||
|
|
||||||
|
gui.setSlot(21, new GuiElementBuilder(Items.SPECTRAL_ARROW)
|
||||||
|
.setCallback(() -> {
|
||||||
|
if(page > 0) {
|
||||||
|
page--;
|
||||||
|
updateConverters();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
gui.setSlot(23, new GuiElementBuilder(Items.ARROW)
|
||||||
|
.setCallback(() -> {
|
||||||
|
if(page * 4 + 4 < converters.getConverters().size()) {
|
||||||
|
page++;
|
||||||
|
updateConverters();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
gui.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateConverters() {
|
||||||
|
int lastConverter = Math.min(5, converters.getConverters().size() + 2 - page * 4);
|
||||||
|
for(int i = 0; i < lastConverter; i++) {
|
||||||
|
//Each page has 5 converters, but the last is displayed on the next page as well
|
||||||
|
int converterIndex = page * 4 + i;
|
||||||
|
//without input element
|
||||||
|
int actualConverterIndex = converterIndex - 1;
|
||||||
|
int slot = 9 + 2 * i;
|
||||||
|
if(converterIndex == 0) {
|
||||||
|
gui.setSlot(slot, new GuiElementBuilder(Items.DROPPER));
|
||||||
|
} else if(converterIndex == converters.getConverters().size() + 1) {
|
||||||
|
gui.setSlot(slot, new GuiElementBuilder(Items.HOPPER));
|
||||||
|
} else {
|
||||||
|
ValueConverter<?, ?> converter = converters.getConverters().get(actualConverterIndex);
|
||||||
|
ValueType<?> fromType = actualConverterIndex >= 1 ? converters.getConverters().get(actualConverterIndex - 1).getTo() : inputType;
|
||||||
|
ValueType<?> toType = actualConverterIndex < converters.getConverters().size() - 1 ? converters.getConverters().get(actualConverterIndex + 1).getFrom() : outputType;
|
||||||
|
|
||||||
|
gui.setSlot(slot, new GuiElementBuilder(GuiDisplay.getDisplayStackWithName(MinionRegistries.VALUE_CONVERTER_TYPES, converter.getType(), viewer.getRegistryManager()))
|
||||||
|
.addLoreLine(converter.getDisplayText())
|
||||||
|
.setCallback(() -> new ConverterGui(this, converter, fromType, toType, converters, false, actualConverterIndex))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if(i != 4 && actualConverterIndex != converters.getConverters().size()) {
|
||||||
|
ValueType<?> fromType = actualConverterIndex >= 0 ? converters.getConverters().get(actualConverterIndex).getTo() : inputType;
|
||||||
|
ValueType<?> toType = actualConverterIndex < converters.getConverters().size() - 1 ? converters.getConverters().get(actualConverterIndex + 1).getFrom() : outputType;
|
||||||
|
|
||||||
|
gui.setSlot(slot + 1, new GuiElementBuilder(Items.MAGENTA_GLAZED_TERRACOTTA)
|
||||||
|
.setName(Text.translatable(
|
||||||
|
"minions.gui.instruction.converters.cast",
|
||||||
|
Text.translatable(TranslationUtil.getTranslationKey(fromType, MinionRegistries.VALUE_TYPES)),
|
||||||
|
Text.translatable(TranslationUtil.getTranslationKey(toType, MinionRegistries.VALUE_TYPES))
|
||||||
|
))
|
||||||
|
.setCallback(() -> new ConverterGui(this, null, fromType, toType, converters, true, actualConverterIndex + 1))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void closeBacking() {
|
||||||
|
gui.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
-30
@@ -1,30 +0,0 @@
|
|||||||
package io.github.skippyall.minions.gui.instruction;
|
|
||||||
|
|
||||||
import io.github.skippyall.minions.gui.MinionBoundSimpleGui;
|
|
||||||
import io.github.skippyall.minions.minion.MinionRuntime;
|
|
||||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
|
||||||
import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
|
||||||
import io.github.skippyall.minions.program.instruction.ConfiguredInstructionListener;
|
|
||||||
import net.minecraft.screen.ScreenHandlerType;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
public class InstructionBoundSimpleGui extends MinionBoundSimpleGui implements ConfiguredInstructionListener {
|
|
||||||
protected final ConfiguredInstruction<MinionRuntime> instruction;
|
|
||||||
|
|
||||||
public InstructionBoundSimpleGui(ScreenHandlerType<?> type, ServerPlayerEntity player, MinionFakePlayer minion, ConfiguredInstruction<MinionRuntime> instruction) {
|
|
||||||
super(type, player, minion);
|
|
||||||
this.instruction = instruction;
|
|
||||||
instruction.addListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInstructionRemove(ConfiguredInstruction<?> instruction) {
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClose() {
|
|
||||||
super.onClose();
|
|
||||||
instruction.removeListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,18 +3,20 @@ package io.github.skippyall.minions.gui.instruction;
|
|||||||
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
||||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||||
import io.github.skippyall.minions.gui.GuiDisplay;
|
import io.github.skippyall.minions.gui.GuiDisplay;
|
||||||
import io.github.skippyall.minions.gui.MinionBoundSimpleGui;
|
import io.github.skippyall.minions.gui.MinionsGui;
|
||||||
import io.github.skippyall.minions.registration.MinionComponentTypes;
|
|
||||||
import io.github.skippyall.minions.registration.MinionRegistries;
|
|
||||||
import io.github.skippyall.minions.gui.input.Result;
|
import io.github.skippyall.minions.gui.input.Result;
|
||||||
import io.github.skippyall.minions.gui.input.TextInput;
|
import io.github.skippyall.minions.gui.input.TextInput;
|
||||||
|
import io.github.skippyall.minions.gui.minion.GuiContext;
|
||||||
|
import io.github.skippyall.minions.gui.minion.SimpleMinionsGui;
|
||||||
import io.github.skippyall.minions.minion.MinionRuntime;
|
import io.github.skippyall.minions.minion.MinionRuntime;
|
||||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||||
import io.github.skippyall.minions.module.MinionModule;
|
import io.github.skippyall.minions.module.MinionModule;
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplier;
|
|
||||||
import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
||||||
import io.github.skippyall.minions.program.instruction.InstructionType;
|
import io.github.skippyall.minions.program.instruction.InstructionType;
|
||||||
import io.github.skippyall.minions.program.supplier.Parameter;
|
import io.github.skippyall.minions.program.supplier.Parameter;
|
||||||
|
import io.github.skippyall.minions.program.supplier.ValueSupplier;
|
||||||
|
import io.github.skippyall.minions.registration.MinionComponentTypes;
|
||||||
|
import io.github.skippyall.minions.registration.MinionRegistries;
|
||||||
import io.github.skippyall.minions.util.TranslationUtil;
|
import io.github.skippyall.minions.util.TranslationUtil;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
@@ -28,63 +30,50 @@ import java.util.NoSuchElementException;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class InstructionGui {
|
public class InstructionGui {
|
||||||
public static void openInstructionMainMenu(MinionFakePlayer minion, ServerPlayerEntity player) {
|
public static MinionsGui openInstructionMainMenu(MinionsGui parent, GuiContext.Minion context) {
|
||||||
SimpleGui gui = new MinionBoundSimpleGui(ScreenHandlerType.GENERIC_3X3, player, minion);
|
return new SimpleMinionsGui(parent, (onClose, me) -> {
|
||||||
gui.setTitle(Text.translatable("minions.gui.instruction.title"));
|
ServerPlayerEntity player = parent.getViewer();
|
||||||
|
|
||||||
gui.setSlot(3, new GuiElementBuilder()
|
SimpleGui gui = new SimpleGui(ScreenHandlerType.GENERIC_3X3, player, false) {
|
||||||
.setItem(Items.BOOK)
|
@Override
|
||||||
.setName(Text.translatable("minions.gui.instruction.list"))
|
public void onClose() {
|
||||||
.setCallback(() -> instructionList(minion, player))
|
onClose.run();
|
||||||
);
|
}
|
||||||
gui.setSlot(5, new GuiElementBuilder()
|
};
|
||||||
.setItem(Items.WRITABLE_BOOK)
|
gui.setTitle(Text.translatable("minions.gui.instruction.title"));
|
||||||
.setName(Text.translatable("minions.gui.instruction.create"))
|
|
||||||
.setCallback(() -> createNewInstruction(minion, player))
|
|
||||||
);
|
|
||||||
|
|
||||||
gui.open();
|
gui.setSlot(3, new GuiElementBuilder()
|
||||||
}
|
.setItem(Items.BOOK)
|
||||||
|
.setName(Text.translatable("minions.gui.instruction.list"))
|
||||||
public static void instructionList(MinionFakePlayer minion, ServerPlayerEntity player) {
|
.setCallback(() -> new InstructionListGui(me, context))
|
||||||
SimpleGui gui = new MinionBoundSimpleGui(ScreenHandlerType.GENERIC_9X3, player, minion) {
|
|
||||||
@Override
|
|
||||||
public void onInstructionsUpdate(MinionFakePlayer minion) {
|
|
||||||
resetInstructionList(this, minion, player);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
gui.setTitle(Text.translatable("minions.gui.instruction.title"));
|
|
||||||
resetInstructionList(gui, minion, player);
|
|
||||||
|
|
||||||
gui.open();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void resetInstructionList(SimpleGui gui, MinionFakePlayer minion, ServerPlayerEntity player) {
|
|
||||||
int i = 0;
|
|
||||||
for (String instructionName : minion.getInstructionManager().getInstructionNames()) {
|
|
||||||
ConfiguredInstruction<MinionRuntime> instruction = minion.getInstructionManager().getInstruction(instructionName);
|
|
||||||
gui.setSlot(i, new GuiElementBuilder(GuiDisplay.getGuiDisplayFor(MinionRegistries.INSTRUCTION_TYPES, instruction.getInstruction(), player.getRegistryManager()).createItemStack())
|
|
||||||
.setName(Text.literal(instructionName))
|
|
||||||
.setCallback(() -> ConfigureInstructionGui.configureInstructionMenu(instructionName, instruction, minion, player))
|
|
||||||
);
|
);
|
||||||
i++;
|
gui.setSlot(5, new GuiElementBuilder()
|
||||||
}
|
.setItem(Items.WRITABLE_BOOK)
|
||||||
|
.setName(Text.translatable("minions.gui.instruction.create"))
|
||||||
|
.setCallback(() -> createNewInstruction(me, context))
|
||||||
|
);
|
||||||
|
|
||||||
|
gui.open();
|
||||||
|
return gui;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createNewInstruction(MinionFakePlayer minion, ServerPlayerEntity player) {
|
public static void createNewInstruction(MinionsGui parent, GuiContext.Minion context) {
|
||||||
selectInstructionModuleMenu(minion, player).thenAccept(instructionType ->
|
MinionFakePlayer minion = context.getMinion();
|
||||||
inputInstructionName(minion, player, "Instruction").thenAccept(name -> {
|
ServerPlayerEntity viewer = parent.getViewer();
|
||||||
|
selectInstructionModuleMenu(parent, context).thenAccept(instructionType ->
|
||||||
|
inputInstructionName(parent, context, "Instruction").thenAccept(name -> {
|
||||||
if (!minion.isRemoved() && !minion.isDisconnected()) {
|
if (!minion.isRemoved() && !minion.isDisconnected()) {
|
||||||
ConfiguredInstruction<MinionRuntime> configuredInstruction = minion.getInstructionManager().createInstruction(name, instructionType);
|
ConfiguredInstruction<MinionRuntime> configuredInstruction = minion.getInstructionManager().createInstruction(name, instructionType);
|
||||||
ConfigureInstructionGui.configureInstructionMenu(name, configuredInstruction, minion, player);
|
new ConfigureInstructionGui(parent, GuiContext.Instruction.create(context, configuredInstruction, name));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CompletableFuture<String> inputInstructionName(MinionFakePlayer minion, ServerPlayerEntity player, String defaultValue) {
|
public static CompletableFuture<String> inputInstructionName(MinionsGui parent, GuiContext.Minion context, String defaultValue) {
|
||||||
return TextInput.inputSync(player, Text.translatable("minions.gui.instruction.enter_name"), defaultValue, name -> {
|
return TextInput.inputSync(parent, Text.translatable("minions.gui.instruction.enter_name"), defaultValue, name -> {
|
||||||
if (minion.getInstructionManager().hasInstruction(name)) {
|
if (context.getMinion().getInstructionManager().hasInstruction(name)) {
|
||||||
return new Result.Error<>(Text.translatable("minions.gui.instruction.name_already_used"));
|
return new Result.Error<>(Text.translatable("minions.gui.instruction.name_already_used"));
|
||||||
}
|
}
|
||||||
return new Result.Success<>(name);
|
return new Result.Success<>(name);
|
||||||
@@ -100,62 +89,71 @@ public class InstructionGui {
|
|||||||
return stillExists;
|
return stillExists;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CompletableFuture<InstructionType<MinionRuntime>> selectInstructionModuleMenu(MinionFakePlayer minion, ServerPlayerEntity player) {
|
public static CompletableFuture<InstructionType<MinionRuntime>> selectInstructionModuleMenu(MinionsGui parent, GuiContext.Minion context) {
|
||||||
|
MinionFakePlayer minion = context.getMinion();
|
||||||
|
ServerPlayerEntity viewer = parent.getViewer();
|
||||||
|
|
||||||
if (minion.getModuleInventory().getModules().isEmpty()) {
|
if (minion.getModuleInventory().getModules().isEmpty()) {
|
||||||
player.sendMessage(Text.translatable("minions.gui.instruction.no_modules"));
|
viewer.sendMessage(Text.translatable("minions.gui.instruction.no_modules"));
|
||||||
return CompletableFuture.failedFuture(new NoSuchElementException("No modules"));
|
return CompletableFuture.failedFuture(new NoSuchElementException("No modules"));
|
||||||
}
|
}
|
||||||
|
|
||||||
CompletableFuture<InstructionType<MinionRuntime>> future = new CompletableFuture<>();
|
CompletableFuture<InstructionType<MinionRuntime>> future = new CompletableFuture<>();
|
||||||
|
|
||||||
SimpleGui gui = new MinionBoundSimpleGui(ScreenHandlerType.GENERIC_9X3, player, minion) {
|
new SimpleMinionsGui(parent, (closeHandler, me) -> {
|
||||||
@Override
|
SimpleGui gui = new SimpleGui(ScreenHandlerType.GENERIC_9X3, viewer, false) {
|
||||||
public void onClose() {
|
@Override
|
||||||
if (!future.isDone()) {
|
public void onClose() {
|
||||||
future.cancel(false);
|
if (!future.isDone()) {
|
||||||
|
future.cancel(false);
|
||||||
|
}
|
||||||
|
closeHandler.run();
|
||||||
}
|
}
|
||||||
super.onClose();
|
};
|
||||||
}
|
gui.setTitle(Text.translatable("minions.gui.instruction.select_instruction"));
|
||||||
};
|
|
||||||
gui.setTitle(Text.translatable("minions.gui.instruction.select_instruction"));
|
|
||||||
|
|
||||||
for (int i = 0; i < minion.getModuleInventory().size(); i++) {
|
for (int i = 0; i < minion.getModuleInventory().size(); i++) {
|
||||||
ItemStack moduleItem = minion.getModuleInventory().getStack(i);
|
ItemStack moduleItem = minion.getModuleInventory().getStack(i);
|
||||||
MinionModule module = moduleItem.get(MinionComponentTypes.MODULE);
|
MinionModule module = moduleItem.get(MinionComponentTypes.MODULE);
|
||||||
if (module != null && !module.instructions().isEmpty()) {
|
if (module != null && !module.instructions().isEmpty()) {
|
||||||
gui.addSlot(new GuiElementBuilder(moduleItem)
|
gui.addSlot(new GuiElementBuilder(moduleItem)
|
||||||
.setCallback(() -> selectInstructionMenu(module, minion, player)
|
.setCallback(() -> selectInstructionMenu(parent, context, module)
|
||||||
.thenApply(future::complete)
|
.thenApply(future::complete)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
gui.open();
|
gui.open();
|
||||||
|
return gui;
|
||||||
|
});
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CompletableFuture<InstructionType<MinionRuntime>> selectInstructionMenu(MinionModule module, MinionFakePlayer minion, ServerPlayerEntity player) {
|
public static CompletableFuture<InstructionType<MinionRuntime>> selectInstructionMenu(MinionsGui parent, GuiContext.Minion context, MinionModule module) {
|
||||||
CompletableFuture<InstructionType<MinionRuntime>> future = new CompletableFuture<>();
|
CompletableFuture<InstructionType<MinionRuntime>> future = new CompletableFuture<>();
|
||||||
|
|
||||||
SimpleGui gui = new MinionBoundSimpleGui(ScreenHandlerType.GENERIC_9X3, player, minion) {
|
new SimpleMinionsGui(parent, (closeHandler, me) -> {
|
||||||
@Override
|
SimpleGui gui = new SimpleGui(ScreenHandlerType.GENERIC_9X3, parent.getViewer(), false) {
|
||||||
public void onClose() {
|
@Override
|
||||||
if (!future.isDone()) {
|
public void onClose() {
|
||||||
future.cancel(false);
|
if (!future.isDone()) {
|
||||||
|
future.cancel(false);
|
||||||
|
}
|
||||||
|
closeHandler.run();
|
||||||
}
|
}
|
||||||
super.onClose();
|
};
|
||||||
|
gui.setTitle(Text.translatable("minions.gui.instruction.select_instruction"));
|
||||||
|
|
||||||
|
for (InstructionType<MinionRuntime> instructionType : module.instructions()) {
|
||||||
|
gui.addSlot(createInstructionElement(instructionType, parent.getViewer().getRegistryManager())
|
||||||
|
.setCallback(() -> future.complete(instructionType))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
gui.setTitle(Text.translatable("minions.gui.instruction.select_instruction"));
|
|
||||||
|
|
||||||
for (InstructionType<MinionRuntime> instructionType : module.instructions()) {
|
gui.open();
|
||||||
gui.addSlot(createInstructionElement(instructionType, player.getRegistryManager())
|
return gui;
|
||||||
.setCallback(() -> future.complete(instructionType))
|
});
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
gui.open();
|
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package io.github.skippyall.minions.gui.instruction;
|
||||||
|
|
||||||
|
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
||||||
|
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||||
|
import io.github.skippyall.minions.gui.GuiDisplay;
|
||||||
|
import io.github.skippyall.minions.gui.MinionsGui;
|
||||||
|
import io.github.skippyall.minions.gui.minion.GuiContext;
|
||||||
|
import io.github.skippyall.minions.minion.MinionListener;
|
||||||
|
import io.github.skippyall.minions.minion.MinionRuntime;
|
||||||
|
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||||
|
import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
||||||
|
import io.github.skippyall.minions.registration.MinionRegistries;
|
||||||
|
import net.minecraft.screen.ScreenHandlerType;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
|
public class InstructionListGui extends MinionsGui implements MinionListener {
|
||||||
|
private final GuiContext.Minion context;
|
||||||
|
private final MinionFakePlayer minion;
|
||||||
|
private SimpleGui gui;
|
||||||
|
|
||||||
|
public InstructionListGui(MinionsGui parent, GuiContext.Minion context) {
|
||||||
|
super(parent);
|
||||||
|
this.context = context;
|
||||||
|
this.minion = context.getMinion();
|
||||||
|
open();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInstructionsUpdate(MinionFakePlayer minion) {
|
||||||
|
resetInstructionList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void open() {
|
||||||
|
minion.addMinionListener(this);
|
||||||
|
gui = new SimpleGui(ScreenHandlerType.GENERIC_9X3, viewer, false) {
|
||||||
|
@Override
|
||||||
|
public void onClose() {
|
||||||
|
onBackingClosed();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
gui.setTitle(Text.translatable("minions.gui.instruction.title"));
|
||||||
|
resetInstructionList();
|
||||||
|
gui.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void reopen() {
|
||||||
|
gui.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void closeBacking() {
|
||||||
|
minion.removeMinionListener(this);
|
||||||
|
gui.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resetInstructionList() {
|
||||||
|
int i = 0;
|
||||||
|
for (String instructionName : minion.getInstructionManager().getInstructionNames()) {
|
||||||
|
ConfiguredInstruction<MinionRuntime> instruction = minion.getInstructionManager().getInstruction(instructionName);
|
||||||
|
gui.setSlot(i, new GuiElementBuilder(GuiDisplay.getGuiDisplayFor(MinionRegistries.INSTRUCTION_TYPES, instruction.getInstruction(), viewer.getRegistryManager()).createItemStack())
|
||||||
|
.setName(Text.literal(instructionName))
|
||||||
|
.setCallback(() -> new ConfigureInstructionGui(this, GuiContext.Instruction.create(context, instruction, instructionName)))
|
||||||
|
);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package io.github.skippyall.minions.gui.minion;
|
||||||
|
|
||||||
|
import io.github.skippyall.minions.minion.MinionRuntime;
|
||||||
|
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||||
|
import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
||||||
|
import io.github.skippyall.minions.program.supplier.Parameter;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
|
||||||
|
public interface GuiContext {
|
||||||
|
ServerPlayerEntity getViewer();
|
||||||
|
|
||||||
|
static GuiContext create(ServerPlayerEntity viewer) {
|
||||||
|
return new GuiContextImpl(viewer);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Minion extends GuiContext {
|
||||||
|
MinionFakePlayer getMinion();
|
||||||
|
|
||||||
|
static GuiContext.Minion create(GuiContext context, MinionFakePlayer minion) {
|
||||||
|
return new GuiContextImpl.MinionImpl(context, minion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Instruction extends Minion {
|
||||||
|
ConfiguredInstruction<MinionRuntime> getInstruction();
|
||||||
|
|
||||||
|
String getName();
|
||||||
|
|
||||||
|
void setName(String name);
|
||||||
|
|
||||||
|
static GuiContext.Instruction create(GuiContext.Minion context, ConfiguredInstruction<MinionRuntime> instruction, String name) {
|
||||||
|
return new GuiContextImpl.InstructionImpl(context, instruction, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ValueSupplier extends Instruction {
|
||||||
|
Parameter<?> getParameter();
|
||||||
|
|
||||||
|
static GuiContext.ValueSupplier create(GuiContext.Instruction context, Parameter<?> parameter) {
|
||||||
|
return new GuiContextImpl.ValueSupplierImpl(context, parameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
package io.github.skippyall.minions.gui.minion;
|
||||||
|
|
||||||
|
import io.github.skippyall.minions.minion.MinionRuntime;
|
||||||
|
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||||
|
import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
||||||
|
import io.github.skippyall.minions.program.supplier.Parameter;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
|
||||||
|
//If only this mod was kotlin
|
||||||
|
public class GuiContextImpl implements GuiContext {
|
||||||
|
private final ServerPlayerEntity viewer;
|
||||||
|
|
||||||
|
public GuiContextImpl(ServerPlayerEntity viewer) {
|
||||||
|
this.viewer = viewer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ServerPlayerEntity getViewer() {
|
||||||
|
return viewer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MinionImpl extends DelegatingGuiContextImpl<GuiContext> implements GuiContext.Minion {
|
||||||
|
private final MinionFakePlayer minion;
|
||||||
|
|
||||||
|
public MinionImpl(GuiContext context, MinionFakePlayer minion) {
|
||||||
|
super(context);
|
||||||
|
this.minion = minion;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MinionFakePlayer getMinion() {
|
||||||
|
return minion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class InstructionImpl extends DelegatingMinionImpl<GuiContext.Minion> implements GuiContext.Instruction {
|
||||||
|
private final ConfiguredInstruction<MinionRuntime> instruction;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public InstructionImpl(GuiContext.Minion context, ConfiguredInstruction<MinionRuntime> instruction, String name) {
|
||||||
|
super(context);
|
||||||
|
this.instruction = instruction;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConfiguredInstruction<MinionRuntime> getInstruction() {
|
||||||
|
return instruction;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ValueSupplierImpl extends DelegatingInstructionImpl<GuiContext.Instruction> implements GuiContext.ValueSupplier {
|
||||||
|
private final Parameter<?> parameter;
|
||||||
|
|
||||||
|
public ValueSupplierImpl(GuiContext.Instruction context, Parameter<?> parameter) {
|
||||||
|
super(context);
|
||||||
|
this.parameter = parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Parameter<?> getParameter() {
|
||||||
|
return parameter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class DelegatingGuiContextImpl<C extends GuiContext> implements GuiContext {
|
||||||
|
protected final C context;
|
||||||
|
|
||||||
|
public DelegatingGuiContextImpl(C context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ServerPlayerEntity getViewer() {
|
||||||
|
return context.getViewer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class DelegatingMinionImpl<C extends GuiContext.Minion> extends DelegatingGuiContextImpl<C> implements GuiContext.Minion {
|
||||||
|
public DelegatingMinionImpl(C context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MinionFakePlayer getMinion() {
|
||||||
|
return context.getMinion();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class DelegatingInstructionImpl<C extends GuiContext.Instruction> extends DelegatingMinionImpl<C> implements GuiContext.Instruction {
|
||||||
|
public DelegatingInstructionImpl(C context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConfiguredInstruction<MinionRuntime> getInstruction() {
|
||||||
|
return context.getInstruction();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return context.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setName(String name) {
|
||||||
|
context.setName(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,13 +7,8 @@ import io.github.skippyall.minions.gui.instruction.InstructionGui;
|
|||||||
import io.github.skippyall.minions.minion.MinionListener;
|
import io.github.skippyall.minions.minion.MinionListener;
|
||||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||||
import io.github.skippyall.minions.module.ModuleInventory;
|
import io.github.skippyall.minions.module.ModuleInventory;
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.screen.ScreenHandlerType;
|
import net.minecraft.screen.ScreenHandlerType;
|
||||||
import net.minecraft.screen.slot.ArmorSlot;
|
|
||||||
import net.minecraft.screen.slot.Slot;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
@@ -25,6 +20,7 @@ public class MinionGui extends MinionsGui implements MinionListener {
|
|||||||
super(viewer);
|
super(viewer);
|
||||||
this.minion = minion;
|
this.minion = minion;
|
||||||
minion.addMinionListener(this);
|
minion.addMinionListener(this);
|
||||||
|
open();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MinionFakePlayer getMinion() {
|
public MinionFakePlayer getMinion() {
|
||||||
@@ -46,7 +42,7 @@ public class MinionGui extends MinionsGui implements MinionListener {
|
|||||||
.setItem(Items.COMMAND_BLOCK)
|
.setItem(Items.COMMAND_BLOCK)
|
||||||
.setName(Text.translatable("minions.gui.main.instructions"))
|
.setName(Text.translatable("minions.gui.main.instructions"))
|
||||||
.setCallback(() -> {
|
.setCallback(() -> {
|
||||||
InstructionGui.openInstructionMainMenu(minion, viewer);
|
InstructionGui.openInstructionMainMenu(this, GuiContext.Minion.create(GuiContext.create(viewer), minion));
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
gui.setSlot(3, new GuiElementBuilder()
|
gui.setSlot(3, new GuiElementBuilder()
|
||||||
@@ -75,7 +71,7 @@ public class MinionGui extends MinionsGui implements MinionListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onClose() {
|
protected void closeBacking() {
|
||||||
gui.close();
|
gui.close();
|
||||||
minion.removeMinionListener(this);
|
minion.removeMinionListener(this);
|
||||||
}
|
}
|
||||||
@@ -84,10 +80,4 @@ public class MinionGui extends MinionsGui implements MinionListener {
|
|||||||
public void onMinionRemove(MinionFakePlayer minion) {
|
public void onMinionRemove(MinionFakePlayer minion) {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GuiElementBuilder backButton(Runnable onBack) {
|
|
||||||
return new GuiElementBuilder(Items.COMPASS)
|
|
||||||
.setItemName(Text.translatable("gui.back"))
|
|
||||||
.setCallback(onBack);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ public class MinionInventoryGui extends MinionsGui {
|
|||||||
super(parent);
|
super(parent);
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.minion = parent.getMinion();
|
this.minion = parent.getMinion();
|
||||||
|
open();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -61,7 +62,7 @@ public class MinionInventoryGui extends MinionsGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onClose() {
|
protected void closeBacking() {
|
||||||
gui.close();
|
gui.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package io.github.skippyall.minions.gui.minion;
|
||||||
|
|
||||||
|
import eu.pb4.sgui.api.gui.GuiInterface;
|
||||||
|
import io.github.skippyall.minions.gui.MinionsGui;
|
||||||
|
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
public class SimpleMinionsGui extends MinionsGui {
|
||||||
|
private GuiInterface gui;
|
||||||
|
private final BiFunction<Runnable, SimpleMinionsGui, GuiInterface> guiFactory;
|
||||||
|
|
||||||
|
public SimpleMinionsGui(MinionsGui parent, BiFunction<Runnable, SimpleMinionsGui, GuiInterface> guiFactory) {
|
||||||
|
super(parent);
|
||||||
|
this.guiFactory = guiFactory;
|
||||||
|
open();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void open() {
|
||||||
|
gui = guiFactory.apply(this::onBackingClosed, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void closeBacking() {
|
||||||
|
gui.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,17 +3,17 @@ package io.github.skippyall.minions.listener;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
public class ListenerManager<T> implements Iterable<T> {
|
public class ListenerManager<T> implements Iterable<T> {
|
||||||
protected final List<T> listeners;
|
protected final Set<T> listeners;
|
||||||
|
|
||||||
public ListenerManager() {
|
public ListenerManager() {
|
||||||
this(new CopyOnWriteArrayList<>());
|
this(new CopyOnWriteArraySet<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ListenerManager(List<T> listeners) {
|
protected ListenerManager(Set<T> listeners) {
|
||||||
this.listeners = listeners;
|
this.listeners = listeners;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,34 +23,11 @@ public class ListenerManager<T> implements Iterable<T> {
|
|||||||
|
|
||||||
public void removeListener(T listener) {
|
public void removeListener(T listener) {
|
||||||
listeners.remove(listener);
|
listeners.remove(listener);
|
||||||
onRemove(listener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onRemove(T listener) {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Iterator<T> iterator() {
|
public @NotNull Iterator<T> iterator() {
|
||||||
return new Iterator<>() {
|
return listeners.iterator();
|
||||||
final Iterator<T> backing = listeners.iterator();
|
|
||||||
T last;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNext() {
|
|
||||||
return backing.hasNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T next() {
|
|
||||||
last = backing.next();
|
|
||||||
return last;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove() {
|
|
||||||
backing.remove();
|
|
||||||
onRemove(last);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+6
-41
@@ -2,25 +2,21 @@ package io.github.skippyall.minions.listener;
|
|||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import net.minecraft.registry.Registry;
|
import net.minecraft.registry.Registry;
|
||||||
import net.minecraft.storage.ReadView;
|
|
||||||
import net.minecraft.storage.WriteView;
|
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
public class SerializableListenerManager<T extends SerializableListenerManager.SerializableListener> extends ListenerManager<T> {
|
public class SerializableListenerManager<T extends SerializableListenerManager.SerializableListener> extends ListenerManager<T> {
|
||||||
private final Registry<Codec<? extends T>> registry;
|
public SerializableListenerManager() {
|
||||||
|
super();
|
||||||
public SerializableListenerManager(Registry<Codec<? extends T>> registry) {
|
|
||||||
this.registry = registry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SerializableListenerManager(Registry<Codec<? extends T>> registry, List<T> listeners) {
|
protected SerializableListenerManager(Set<T> listeners) {
|
||||||
super(listeners);
|
super(listeners);
|
||||||
this.registry = registry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends SerializableListener> Codec<SerializableListenerManager<T>> getCodec(Registry<Codec<? extends T>> registry) {
|
public static <T extends SerializableListener> Codec<SerializableListenerManager<T>> getCodec(Registry<Codec<? extends T>> registry) {
|
||||||
@@ -28,7 +24,7 @@ public class SerializableListenerManager<T extends SerializableListenerManager.S
|
|||||||
listener -> listener.getCodecId().map(registry::get).orElse(Codec.unit(null)),
|
listener -> listener.getCodecId().map(registry::get).orElse(Codec.unit(null)),
|
||||||
codec -> codec.fieldOf("data")
|
codec -> codec.fieldOf("data")
|
||||||
).listOf().xmap(
|
).listOf().xmap(
|
||||||
list -> new SerializableListenerManager<>(registry, new CopyOnWriteArrayList<>(list)),
|
list -> new SerializableListenerManager<>(new CopyOnWriteArraySet<>(list)),
|
||||||
manager -> {
|
manager -> {
|
||||||
List<T> serializableListeners = new ArrayList<>();
|
List<T> serializableListeners = new ArrayList<>();
|
||||||
for(T listener : manager.listeners) {
|
for(T listener : manager.listeners) {
|
||||||
@@ -41,37 +37,6 @@ public class SerializableListenerManager<T extends SerializableListenerManager.S
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(WriteView view) {
|
|
||||||
WriteView.ListView listView = view.getList("listeners");
|
|
||||||
for (T listener : listeners) {
|
|
||||||
if(listener.getCodecId().isPresent()) {
|
|
||||||
WriteView listenerView = listView.add();
|
|
||||||
Codec<? extends T> codec = registry.get(listener.getCodecId().get());
|
|
||||||
listenerView.put("id", Identifier.CODEC, listener.getCodecId().get());
|
|
||||||
//noinspection unchecked
|
|
||||||
listenerView.put("data", (Codec<T>) codec, listener);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void load(ReadView view) {
|
|
||||||
ReadView.ListReadView listView = view.getListReadView("listeners");
|
|
||||||
for (ReadView listenerView : listView) {
|
|
||||||
Optional<Identifier> id = listenerView.read("id", Identifier.CODEC);
|
|
||||||
if(id.isEmpty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Codec<? extends T> codec = registry.get(id.get());
|
|
||||||
|
|
||||||
Optional<? extends T> listener = listenerView.read("data", codec);
|
|
||||||
|
|
||||||
if(listener.isPresent()) {
|
|
||||||
listeners.add(listener.get());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface SerializableListener {
|
public interface SerializableListener {
|
||||||
default Optional<Identifier> getCodecId() {
|
default Optional<Identifier> getCodecId() {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package io.github.skippyall.minions.minion;
|
|||||||
import com.mojang.authlib.properties.PropertyMap;
|
import com.mojang.authlib.properties.PropertyMap;
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
import io.github.skippyall.minions.registration.MinionRegistries;
|
|
||||||
import io.github.skippyall.minions.listener.SerializableListenerManager;
|
import io.github.skippyall.minions.listener.SerializableListenerManager;
|
||||||
|
import io.github.skippyall.minions.registration.MinionRegistries;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.util.Uuids;
|
import net.minecraft.util.Uuids;
|
||||||
import net.minecraft.util.dynamic.Codecs;
|
import net.minecraft.util.dynamic.Codecs;
|
||||||
@@ -27,7 +27,7 @@ public record MinionData(
|
|||||||
Codecs.GAME_PROFILE_PROPERTY_MAP.optionalFieldOf("skin").forGetter(MinionData::skin),
|
Codecs.GAME_PROFILE_PROPERTY_MAP.optionalFieldOf("skin").forGetter(MinionData::skin),
|
||||||
Codec.BOOL.optionalFieldOf("isSpawned", false).forGetter(MinionData::isSpawned),
|
Codec.BOOL.optionalFieldOf("isSpawned", false).forGetter(MinionData::isSpawned),
|
||||||
SerializableListenerManager.getCodec(MinionRegistries.MINION_LISTENER_CODECS).optionalFieldOf("listeners").xmap(
|
SerializableListenerManager.getCodec(MinionRegistries.MINION_LISTENER_CODECS).optionalFieldOf("listeners").xmap(
|
||||||
optional -> optional.orElseGet(() -> new SerializableListenerManager<>(MinionRegistries.MINION_LISTENER_CODECS)),
|
optional -> optional.orElseGet(SerializableListenerManager::new),
|
||||||
Optional::of
|
Optional::of
|
||||||
).forGetter(MinionData::listeners),
|
).forGetter(MinionData::listeners),
|
||||||
MinionConfig.CODEC.optionalFieldOf("config", new MinionConfig()).forGetter(MinionData::config)
|
MinionConfig.CODEC.optionalFieldOf("config", new MinionConfig()).forGetter(MinionData::config)
|
||||||
@@ -40,7 +40,7 @@ public record MinionData(
|
|||||||
MinionProfileUtils.newDefaultMinionName(server),
|
MinionProfileUtils.newDefaultMinionName(server),
|
||||||
Optional.empty(),
|
Optional.empty(),
|
||||||
false,
|
false,
|
||||||
new SerializableListenerManager<>(MinionRegistries.MINION_LISTENER_CODECS),
|
new SerializableListenerManager<>(),
|
||||||
new MinionConfig()
|
new MinionConfig()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package io.github.skippyall.minions.minion;
|
package io.github.skippyall.minions.minion;
|
||||||
|
|
||||||
|
import io.github.skippyall.minions.listener.SerializableListenerManager;
|
||||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||||
import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
||||||
import io.github.skippyall.minions.listener.SerializableListenerManager;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public interface MinionListener extends SerializableListenerManager.SerializableListener {
|
public interface MinionListener extends SerializableListenerManager.SerializableListener {
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package io.github.skippyall.minions.minion;
|
package io.github.skippyall.minions.minion;
|
||||||
|
|
||||||
import io.github.skippyall.minions.registration.MinionRegistries;
|
|
||||||
import io.github.skippyall.minions.Minions;
|
import io.github.skippyall.minions.Minions;
|
||||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||||
import io.github.skippyall.minions.program.InstructionRuntime;
|
import io.github.skippyall.minions.program.InstructionRuntime;
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplierType;
|
import io.github.skippyall.minions.program.consumer.ValueConsumerType;
|
||||||
import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
import io.github.skippyall.minions.program.instruction.ConfiguredInstruction;
|
||||||
import io.github.skippyall.minions.program.instruction.InstructionType;
|
import io.github.skippyall.minions.program.instruction.InstructionType;
|
||||||
import io.github.skippyall.minions.program.consumer.ValueConsumerType;
|
import io.github.skippyall.minions.program.supplier.ValueSupplierType;
|
||||||
|
import io.github.skippyall.minions.registration.MinionRegistries;
|
||||||
import net.minecraft.registry.Registry;
|
import net.minecraft.registry.Registry;
|
||||||
import net.minecraft.storage.ReadView;
|
import net.minecraft.storage.ReadView;
|
||||||
import net.minecraft.storage.WriteView;
|
import net.minecraft.storage.WriteView;
|
||||||
|
|||||||
+5
-5
@@ -2,11 +2,6 @@
|
|||||||
package io.github.skippyall.minions.minion.fakeplayer;
|
package io.github.skippyall.minions.minion.fakeplayer;
|
||||||
|
|
||||||
|
|
||||||
import java.util.EnumMap;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import io.github.skippyall.minions.mixins.EntityAccessor;
|
import io.github.skippyall.minions.mixins.EntityAccessor;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.command.argument.EntityAnchorArgumentType;
|
import net.minecraft.command.argument.EntityAnchorArgumentType;
|
||||||
@@ -32,6 +27,11 @@ import net.minecraft.util.math.MathHelper;
|
|||||||
import net.minecraft.util.math.Vec2f;
|
import net.minecraft.util.math.Vec2f;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class EntityPlayerActionPack
|
public class EntityPlayerActionPack
|
||||||
{
|
{
|
||||||
private final MinionFakePlayer player;
|
private final MinionFakePlayer player;
|
||||||
|
|||||||
+1
-1
@@ -4,8 +4,8 @@ package io.github.skippyall.minions.minion.fakeplayer;
|
|||||||
import io.netty.channel.embedded.EmbeddedChannel;
|
import io.netty.channel.embedded.EmbeddedChannel;
|
||||||
import net.minecraft.network.ClientConnection;
|
import net.minecraft.network.ClientConnection;
|
||||||
import net.minecraft.network.NetworkSide;
|
import net.minecraft.network.NetworkSide;
|
||||||
import net.minecraft.network.state.NetworkState;
|
|
||||||
import net.minecraft.network.listener.PacketListener;
|
import net.minecraft.network.listener.PacketListener;
|
||||||
|
import net.minecraft.network.state.NetworkState;
|
||||||
|
|
||||||
public class FakeClientConnection extends ClientConnection {
|
public class FakeClientConnection extends ClientConnection {
|
||||||
public FakeClientConnection(NetworkSide p)
|
public FakeClientConnection(NetworkSide p)
|
||||||
|
|||||||
@@ -3,18 +3,18 @@ package io.github.skippyall.minions.minion.fakeplayer;
|
|||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.properties.PropertyMap;
|
import com.mojang.authlib.properties.PropertyMap;
|
||||||
import io.github.skippyall.minions.registration.MinionConfigOptions;
|
|
||||||
import io.github.skippyall.minions.registration.MinionItems;
|
|
||||||
import io.github.skippyall.minions.minion.MinionListener;
|
|
||||||
import io.github.skippyall.minions.minion.MinionData;
|
|
||||||
import io.github.skippyall.minions.gui.minion.MinionGui;
|
import io.github.skippyall.minions.gui.minion.MinionGui;
|
||||||
import io.github.skippyall.minions.minion.MinionRuntime;
|
import io.github.skippyall.minions.listener.SerializableListenerManager;
|
||||||
|
import io.github.skippyall.minions.minion.MinionData;
|
||||||
import io.github.skippyall.minions.minion.MinionItem;
|
import io.github.skippyall.minions.minion.MinionItem;
|
||||||
|
import io.github.skippyall.minions.minion.MinionListener;
|
||||||
import io.github.skippyall.minions.minion.MinionPersistentState;
|
import io.github.skippyall.minions.minion.MinionPersistentState;
|
||||||
import io.github.skippyall.minions.minion.MinionProfileUtils;
|
import io.github.skippyall.minions.minion.MinionProfileUtils;
|
||||||
|
import io.github.skippyall.minions.minion.MinionRuntime;
|
||||||
import io.github.skippyall.minions.module.ModuleInventory;
|
import io.github.skippyall.minions.module.ModuleInventory;
|
||||||
|
import io.github.skippyall.minions.registration.MinionConfigOptions;
|
||||||
|
import io.github.skippyall.minions.registration.MinionItems;
|
||||||
import io.github.skippyall.minions.registration.SpecialAbilities;
|
import io.github.skippyall.minions.registration.SpecialAbilities;
|
||||||
import io.github.skippyall.minions.listener.SerializableListenerManager;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
@@ -91,6 +91,7 @@ public class MinionFakePlayer extends ServerPlayerEntity {
|
|||||||
instance.setHealth(20.0F);
|
instance.setHealth(20.0F);
|
||||||
instance.unsetRemoved();
|
instance.unsetRemoved();
|
||||||
instance.getAttributeInstance(EntityAttributes.STEP_HEIGHT).setBaseValue(0.6F);
|
instance.getAttributeInstance(EntityAttributes.STEP_HEIGHT).setBaseValue(0.6F);
|
||||||
|
instance.getAttributeInstance(EntityAttributes.WAYPOINT_TRANSMIT_RANGE).setBaseValue(0);
|
||||||
instance.interactionManager.changeGameMode(GameMode.SURVIVAL);
|
instance.interactionManager.changeGameMode(GameMode.SURVIVAL);
|
||||||
server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(instance, (byte) (instance.headYaw * 256 / 360)), level.getRegistryKey());
|
server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(instance, (byte) (instance.headYaw * 256 / 360)), level.getRegistryKey());
|
||||||
server.getPlayerManager().sendToDimension(EntityPositionSyncS2CPacket.create(instance), level.getRegistryKey());
|
server.getPlayerManager().sendToDimension(EntityPositionSyncS2CPacket.create(instance), level.getRegistryKey());
|
||||||
@@ -281,7 +282,7 @@ public class MinionFakePlayer extends ServerPlayerEntity {
|
|||||||
@Override
|
@Override
|
||||||
public void drop(ServerWorld world, DamageSource damageSource) {
|
public void drop(ServerWorld world, DamageSource damageSource) {
|
||||||
super.drop(world, damageSource);
|
super.drop(world, damageSource);
|
||||||
ItemEntity entity = dropStack(world, toItemStack(getServer()));
|
ItemEntity entity = dropItem(toItemStack(world.getServer()), true, false);
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
entity.setNeverDespawn();
|
entity.setNeverDespawn();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
//code from https://github.com/gnembon/fabric-carpet
|
//code from https://github.com/gnembon/fabric-carpet
|
||||||
package io.github.skippyall.minions.minion.fakeplayer;
|
package io.github.skippyall.minions.minion.fakeplayer;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import net.minecraft.util.hit.EntityHitResult;
|
import net.minecraft.util.hit.EntityHitResult;
|
||||||
@@ -12,6 +10,9 @@ import net.minecraft.util.math.Vec3d;
|
|||||||
import net.minecraft.world.RaycastContext;
|
import net.minecraft.world.RaycastContext;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class Tracer
|
public class Tracer
|
||||||
{
|
{
|
||||||
public static HitResult rayTrace(Entity source, float partialTicks, double reach, boolean fluids)
|
public static HitResult rayTrace(Entity source, float partialTicks, double reach, boolean fluids)
|
||||||
|
|||||||
+2
-2
@@ -4,7 +4,7 @@ import io.github.skippyall.minions.minion.MinionRuntime;
|
|||||||
import io.github.skippyall.minions.minion.fakeplayer.EntityPlayerActionPack;
|
import io.github.skippyall.minions.minion.fakeplayer.EntityPlayerActionPack;
|
||||||
import io.github.skippyall.minions.program.consumer.ValueConsumerList;
|
import io.github.skippyall.minions.program.consumer.ValueConsumerList;
|
||||||
import io.github.skippyall.minions.program.instruction.execution.ContinuousInstructionExecution;
|
import io.github.skippyall.minions.program.instruction.execution.ContinuousInstructionExecution;
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplierList;
|
import io.github.skippyall.minions.program.supplier.ParameterValueList;
|
||||||
import net.minecraft.storage.ReadView;
|
import net.minecraft.storage.ReadView;
|
||||||
import net.minecraft.storage.WriteView;
|
import net.minecraft.storage.WriteView;
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ public class ActionExecution implements ContinuousInstructionExecution<MinionRun
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readArguments(ValueSupplierList<MinionRuntime> parameters, MinionRuntime minion) {}
|
public void readArguments(ParameterValueList parameters, MinionRuntime minion) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(WriteView view, MinionRuntime minion) {}
|
public void save(WriteView view, MinionRuntime minion) {}
|
||||||
|
|||||||
+2
-2
@@ -6,7 +6,7 @@ import io.github.skippyall.minions.minion.fakeplayer.EntityPlayerActionPack;
|
|||||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||||
import io.github.skippyall.minions.program.consumer.ValueConsumerList;
|
import io.github.skippyall.minions.program.consumer.ValueConsumerList;
|
||||||
import io.github.skippyall.minions.program.instruction.InstructionExecution;
|
import io.github.skippyall.minions.program.instruction.InstructionExecution;
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplierList;
|
import io.github.skippyall.minions.program.supplier.ParameterValueList;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
|
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
|
||||||
import net.minecraft.storage.ReadView;
|
import net.minecraft.storage.ReadView;
|
||||||
@@ -121,7 +121,7 @@ public class MineBlockExecution implements InstructionExecution<MinionRuntime> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readArguments(ValueSupplierList<MinionRuntime> arguments, MinionRuntime runtime) {
|
public void readArguments(ParameterValueList arguments, MinionRuntime runtime) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -5,7 +5,7 @@ import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
|||||||
import io.github.skippyall.minions.program.consumer.ValueConsumerList;
|
import io.github.skippyall.minions.program.consumer.ValueConsumerList;
|
||||||
import io.github.skippyall.minions.program.instruction.InstructionExecution;
|
import io.github.skippyall.minions.program.instruction.InstructionExecution;
|
||||||
import io.github.skippyall.minions.program.supplier.Parameter;
|
import io.github.skippyall.minions.program.supplier.Parameter;
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplierList;
|
import io.github.skippyall.minions.program.supplier.ParameterValueList;
|
||||||
import io.github.skippyall.minions.registration.ValueTypes;
|
import io.github.skippyall.minions.registration.ValueTypes;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.screen.ScreenHandler;
|
import net.minecraft.screen.ScreenHandler;
|
||||||
@@ -114,11 +114,11 @@ public class SwapItemExecution implements InstructionExecution<MinionRuntime> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readArguments(ValueSupplierList<MinionRuntime> arguments, MinionRuntime runtime) {
|
public void readArguments(ParameterValueList arguments, MinionRuntime runtime) {
|
||||||
fromSlot = Math.clamp(arguments.getValue(FROM_SLOT, runtime), 0, Integer.MAX_VALUE);
|
fromSlot = Math.clamp(arguments.getValue(FROM_SLOT), 0, Integer.MAX_VALUE);
|
||||||
fromScreen = arguments.getValue(FROM_SCREEN, runtime);
|
fromScreen = arguments.getValue(FROM_SCREEN);
|
||||||
toSlot = Math.clamp(arguments.getValue(TO_SLOT, runtime), 0, Integer.MAX_VALUE);
|
toSlot = Math.clamp(arguments.getValue(TO_SLOT), 0, Integer.MAX_VALUE);
|
||||||
toScreen = arguments.getValue(TO_SCREEN, runtime);
|
toScreen = arguments.getValue(TO_SCREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+4
-4
@@ -1,8 +1,8 @@
|
|||||||
package io.github.skippyall.minions.minion.program.instruction.move;
|
package io.github.skippyall.minions.minion.program.instruction.move;
|
||||||
|
|
||||||
import io.github.skippyall.minions.minion.MinionRuntime;
|
import io.github.skippyall.minions.minion.MinionRuntime;
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplierList;
|
|
||||||
import io.github.skippyall.minions.program.supplier.Parameter;
|
import io.github.skippyall.minions.program.supplier.Parameter;
|
||||||
|
import io.github.skippyall.minions.program.supplier.ParameterValueList;
|
||||||
import io.github.skippyall.minions.registration.ValueTypes;
|
import io.github.skippyall.minions.registration.ValueTypes;
|
||||||
|
|
||||||
public class TurnExecution extends AbstractTurnExecution {
|
public class TurnExecution extends AbstractTurnExecution {
|
||||||
@@ -10,9 +10,9 @@ public class TurnExecution extends AbstractTurnExecution {
|
|||||||
public static final Parameter<TurnDirection> DIRECTION = new Parameter<>("direction", ValueTypes.TURN_DIRECTION);
|
public static final Parameter<TurnDirection> DIRECTION = new Parameter<>("direction", ValueTypes.TURN_DIRECTION);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readArguments(ValueSupplierList<MinionRuntime> arguments, MinionRuntime minion) {
|
public void readArguments(ParameterValueList arguments, MinionRuntime minion) {
|
||||||
float maxAngle = arguments.getValue(ANGLE, minion).floatValue();
|
float maxAngle = arguments.getValue(ANGLE).floatValue();
|
||||||
TurnDirection direction = arguments.getValue(DIRECTION, minion);
|
TurnDirection direction = arguments.getValue(DIRECTION);
|
||||||
|
|
||||||
float turnYaw = maxAngle * direction.xFactor;
|
float turnYaw = maxAngle * direction.xFactor;
|
||||||
float turnPitch = maxAngle * direction.yFactor;
|
float turnPitch = maxAngle * direction.yFactor;
|
||||||
|
|||||||
+5
-5
@@ -2,7 +2,7 @@ package io.github.skippyall.minions.minion.program.instruction.move;
|
|||||||
|
|
||||||
import io.github.skippyall.minions.minion.MinionRuntime;
|
import io.github.skippyall.minions.minion.MinionRuntime;
|
||||||
import io.github.skippyall.minions.program.supplier.Parameter;
|
import io.github.skippyall.minions.program.supplier.Parameter;
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplierList;
|
import io.github.skippyall.minions.program.supplier.ParameterValueList;
|
||||||
import io.github.skippyall.minions.registration.ValueTypes;
|
import io.github.skippyall.minions.registration.ValueTypes;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec2f;
|
import net.minecraft.util.math.Vec2f;
|
||||||
@@ -14,10 +14,10 @@ public class TurnVectorExecution extends AbstractTurnExecution {
|
|||||||
public static final Parameter<Double> Z = new Parameter<>("z", ValueTypes.DOUBLE);
|
public static final Parameter<Double> Z = new Parameter<>("z", ValueTypes.DOUBLE);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readArguments(ValueSupplierList<MinionRuntime> arguments, MinionRuntime runtime) {
|
public void readArguments(ParameterValueList arguments, MinionRuntime runtime) {
|
||||||
double x = arguments.getValue(X, runtime);
|
double x = arguments.getValue(X);
|
||||||
double y = arguments.getValue(Y, runtime);
|
double y = arguments.getValue(Y);
|
||||||
double z = arguments.getValue(Z, runtime);
|
double z = arguments.getValue(Z);
|
||||||
|
|
||||||
Vec3d vector = new Vec3d(x, y, z);
|
Vec3d vector = new Vec3d(x, y, z);
|
||||||
Vec2f rotation = vectorToRotation(vector);
|
Vec2f rotation = vectorToRotation(vector);
|
||||||
|
|||||||
+3
-3
@@ -3,7 +3,7 @@ package io.github.skippyall.minions.minion.program.instruction.move;
|
|||||||
import io.github.skippyall.minions.minion.MinionRuntime;
|
import io.github.skippyall.minions.minion.MinionRuntime;
|
||||||
import io.github.skippyall.minions.program.instruction.InstructionExecution;
|
import io.github.skippyall.minions.program.instruction.InstructionExecution;
|
||||||
import io.github.skippyall.minions.program.supplier.Parameter;
|
import io.github.skippyall.minions.program.supplier.Parameter;
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplierList;
|
import io.github.skippyall.minions.program.supplier.ParameterValueList;
|
||||||
import io.github.skippyall.minions.registration.ValueTypes;
|
import io.github.skippyall.minions.registration.ValueTypes;
|
||||||
import net.minecraft.entity.MovementType;
|
import net.minecraft.entity.MovementType;
|
||||||
import net.minecraft.storage.ReadView;
|
import net.minecraft.storage.ReadView;
|
||||||
@@ -29,8 +29,8 @@ public class WalkExecution implements InstructionExecution<MinionRuntime> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readArguments(ValueSupplierList<MinionRuntime> parameters, MinionRuntime minion) {
|
public void readArguments(ParameterValueList parameters, MinionRuntime minion) {
|
||||||
totalBlocksToMove = parameters.getValue(blocksToMoveParam, minion).floatValue();
|
totalBlocksToMove = parameters.getValue(blocksToMoveParam).floatValue();
|
||||||
blocksMoved = 0;
|
blocksMoved = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+24
-16
@@ -5,6 +5,8 @@ import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|||||||
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
||||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||||
import io.github.skippyall.minions.clipboard.BlockPosClipboard;
|
import io.github.skippyall.minions.clipboard.BlockPosClipboard;
|
||||||
|
import io.github.skippyall.minions.gui.MinionsGui;
|
||||||
|
import io.github.skippyall.minions.gui.minion.SimpleMinionsGui;
|
||||||
import io.github.skippyall.minions.minion.MinionRuntime;
|
import io.github.skippyall.minions.minion.MinionRuntime;
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplier;
|
import io.github.skippyall.minions.program.supplier.ValueSupplier;
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplierType;
|
import io.github.skippyall.minions.program.supplier.ValueSupplierType;
|
||||||
@@ -17,7 +19,6 @@ import io.github.skippyall.minions.registration.ValueTypes;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.registry.RegistryKey;
|
import net.minecraft.registry.RegistryKey;
|
||||||
import net.minecraft.screen.ScreenHandlerType;
|
import net.minecraft.screen.ScreenHandlerType;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -62,7 +63,7 @@ public class AnalogInputSupplier implements ValueSupplier<Long, MinionRuntime> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Text getDisplayText() {
|
public Text getDisplayText() {
|
||||||
return Text.translatable("value_supplier_type.minions.analog_input.display", analogInputPos.toString(), analogInputWorld.getValue().toString());
|
return Text.translatable("value_supplier.minions.analog_input.display", analogInputPos.toShortString(), analogInputWorld.getValue().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AnalogInputSupplierType extends ValueSupplierType<MinionRuntime> {
|
public static class AnalogInputSupplierType extends ValueSupplierType<MinionRuntime> {
|
||||||
@@ -75,22 +76,29 @@ public class AnalogInputSupplier implements ValueSupplier<Long, MinionRuntime> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> CompletableFuture<ValueSupplier<?, MinionRuntime>> openConfiguration(ServerPlayerEntity player, ValueType<T> valueType, @Nullable ValueSupplier<T, MinionRuntime> previous) {
|
public <T> CompletableFuture<ValueSupplier<?, MinionRuntime>> openConfiguration(MinionsGui parent, ValueType<T> valueType, @Nullable ValueSupplier<?, MinionRuntime> previous) {
|
||||||
CompletableFuture<ValueSupplier<?, MinionRuntime>> future = new CompletableFuture<>();
|
CompletableFuture<ValueSupplier<?, MinionRuntime>> future = new CompletableFuture<>();
|
||||||
|
new SimpleMinionsGui(parent, (onClose, me) -> {
|
||||||
|
SimpleGui gui = new SimpleGui(ScreenHandlerType.GENERIC_3X3, parent.getViewer(), false) {
|
||||||
|
@Override
|
||||||
|
public void onClose() {
|
||||||
|
onClose.run();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
gui.setTitle(Text.translatable("value_supplier.minions.analog_input"));
|
||||||
|
|
||||||
SimpleGui gui = new SimpleGui(ScreenHandlerType.GENERIC_3X3, player, false);
|
gui.setSlot(4, new GuiElementBuilder(MinionItems.REFERENCE_ITEM)
|
||||||
gui.setTitle(Text.translatable("value_supplier_type.minions.analog_input"));
|
.setCallback(() -> {
|
||||||
|
ItemStack cursor = parent.getViewer().currentScreenHandler.getCursorStack();
|
||||||
gui.setSlot(4, new GuiElementBuilder(MinionItems.REFERENCE_ITEM)
|
if (cursor.isOf(MinionItems.REFERENCE_ITEM) && cursor.get(MinionComponentTypes.REFERENCE) instanceof BlockPosClipboard pos) {
|
||||||
.setCallback(() -> {
|
future.complete(new AnalogInputSupplier(pos.world(), pos.pos()));
|
||||||
ItemStack cursor = player.currentScreenHandler.getCursorStack();
|
}
|
||||||
if(cursor.isOf(MinionItems.REFERENCE_ITEM) && cursor.get(MinionComponentTypes.REFERENCE) instanceof BlockPosClipboard pos) {
|
})
|
||||||
future.complete(new AnalogInputSupplier(pos.world(), pos.pos()));
|
.setItemName(Text.translatable("value_supplier.minions.analog_input.config.click_with_reference"))
|
||||||
}
|
);
|
||||||
})
|
gui.open();
|
||||||
.setItemName(Text.translatable("value_supplier_type.minions.analog_input.config.click_with_reference"))
|
return gui;
|
||||||
);
|
});
|
||||||
gui.open();
|
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package io.github.skippyall.minions.module;
|
|||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
import io.github.skippyall.minions.registration.MinionRegistries;
|
|
||||||
import io.github.skippyall.minions.minion.MinionRuntime;
|
import io.github.skippyall.minions.minion.MinionRuntime;
|
||||||
import io.github.skippyall.minions.program.instruction.InstructionType;
|
import io.github.skippyall.minions.program.instruction.InstructionType;
|
||||||
|
import io.github.skippyall.minions.registration.MinionRegistries;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package io.github.skippyall.minions.program;
|
package io.github.skippyall.minions.program;
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplier;
|
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplierList;
|
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplierType;
|
|
||||||
import io.github.skippyall.minions.program.instruction.InstructionType;
|
|
||||||
import io.github.skippyall.minions.program.consumer.ValueConsumer;
|
import io.github.skippyall.minions.program.consumer.ValueConsumer;
|
||||||
import io.github.skippyall.minions.program.consumer.ValueConsumerList;
|
import io.github.skippyall.minions.program.consumer.ValueConsumerList;
|
||||||
import io.github.skippyall.minions.program.consumer.ValueConsumerType;
|
import io.github.skippyall.minions.program.consumer.ValueConsumerType;
|
||||||
|
import io.github.skippyall.minions.program.instruction.InstructionType;
|
||||||
|
import io.github.skippyall.minions.program.supplier.ValueSupplier;
|
||||||
|
import io.github.skippyall.minions.program.supplier.ValueSupplierList;
|
||||||
|
import io.github.skippyall.minions.program.supplier.ValueSupplierType;
|
||||||
import net.minecraft.registry.Registry;
|
import net.minecraft.registry.Registry;
|
||||||
|
|
||||||
public interface InstructionRuntime<R extends InstructionRuntime<R>> {
|
public interface InstructionRuntime<R extends InstructionRuntime<R>> {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package io.github.skippyall.minions.program.consumer;
|
package io.github.skippyall.minions.program.consumer;
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import io.github.skippyall.minions.registration.MinionRegistries;
|
|
||||||
import io.github.skippyall.minions.program.InstructionRuntime;
|
import io.github.skippyall.minions.program.InstructionRuntime;
|
||||||
import io.github.skippyall.minions.program.value.ValueType;
|
import io.github.skippyall.minions.program.value.ValueType;
|
||||||
|
import io.github.skippyall.minions.registration.MinionRegistries;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,10 +2,14 @@ package io.github.skippyall.minions.program.conversion;
|
|||||||
|
|
||||||
import com.mojang.serialization.MapCodec;
|
import com.mojang.serialization.MapCodec;
|
||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
|
import io.github.skippyall.minions.gui.MinionsGui;
|
||||||
|
import io.github.skippyall.minions.gui.input.Result;
|
||||||
|
import io.github.skippyall.minions.program.value.TypedValue;
|
||||||
import io.github.skippyall.minions.program.value.ValueType;
|
import io.github.skippyall.minions.program.value.ValueType;
|
||||||
import io.github.skippyall.minions.registration.MinionRegistries;
|
import io.github.skippyall.minions.registration.MinionRegistries;
|
||||||
import io.github.skippyall.minions.registration.ValueConverters;
|
import io.github.skippyall.minions.registration.ValueConverters;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import io.github.skippyall.minions.util.TranslationUtil;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@@ -26,8 +30,8 @@ public class CastConverter<F,T> implements ValueConverter<F,T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T convert(F fromValue) {
|
public Result<T, Text> convert(F fromValue) {
|
||||||
return Casts.getCast(from, to).cast(fromValue);
|
return Casts.castOrError(new TypedValue<>(fromValue, from), to);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -45,6 +49,11 @@ public class CastConverter<F,T> implements ValueConverter<F,T> {
|
|||||||
return ValueConverters.CAST_CONVERTER;
|
return ValueConverters.CAST_CONVERTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Text getDisplayText() {
|
||||||
|
return Text.translatable("value_converter.minions.cast.display", Text.translatable(TranslationUtil.getTranslationKey(from, MinionRegistries.VALUE_TYPES)), Text.translatable(TranslationUtil.getTranslationKey(to, MinionRegistries.VALUE_TYPES)));
|
||||||
|
}
|
||||||
|
|
||||||
public static class Type implements ValueConverterType<CastConverter<?,?>> {
|
public static class Type implements ValueConverterType<CastConverter<?,?>> {
|
||||||
@Override
|
@Override
|
||||||
public MapCodec<CastConverter<?, ?>> getCodec() {
|
public MapCodec<CastConverter<?, ?>> getCodec() {
|
||||||
@@ -57,7 +66,7 @@ public class CastConverter<F,T> implements ValueConverter<F,T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <F,T> CompletableFuture<CastConverter<?,?>> configure(ServerPlayerEntity player, ValueType<F> from, ValueType<T> to, @Nullable CastConverter<?, ?> old) {
|
public <F,T> CompletableFuture<CastConverter<?,?>> configure(MinionsGui parent, ValueType<F> from, ValueType<T> to, @Nullable ValueConverter<?, ?> old) {
|
||||||
return CompletableFuture.completedFuture(new CastConverter<>(from, to));
|
return CompletableFuture.completedFuture(new CastConverter<>(from, to));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package io.github.skippyall.minions.program.conversion;
|
package io.github.skippyall.minions.program.conversion;
|
||||||
|
|
||||||
|
import io.github.skippyall.minions.gui.input.Result;
|
||||||
|
import io.github.skippyall.minions.program.value.TypedValue;
|
||||||
import io.github.skippyall.minions.program.value.ValueType;
|
import io.github.skippyall.minions.program.value.ValueType;
|
||||||
|
import io.github.skippyall.minions.registration.MinionRegistries;
|
||||||
import io.github.skippyall.minions.registration.ValueTypes;
|
import io.github.skippyall.minions.registration.ValueTypes;
|
||||||
|
import io.github.skippyall.minions.util.TranslationUtil;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class Casts {
|
public class Casts {
|
||||||
@@ -12,11 +17,11 @@ public class Casts {
|
|||||||
}
|
}
|
||||||
if(from == ValueTypes.LONG && to == ValueTypes.DOUBLE) {
|
if(from == ValueTypes.LONG && to == ValueTypes.DOUBLE) {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return (Cast<F, T>) new Cast<>(ValueTypes.LONG, ValueTypes.DOUBLE, (v) -> (double)v);
|
return (Cast<F, T>) new Cast<>(ValueTypes.LONG, ValueTypes.DOUBLE, Long::doubleValue);
|
||||||
}
|
}
|
||||||
if(from == ValueTypes.DOUBLE && to == ValueTypes.LONG) {
|
if(from == ValueTypes.DOUBLE && to == ValueTypes.LONG) {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return (Cast<F, T>) new Cast.CastCrafter<>(ValueTypes.DOUBLE, ValueTypes.LONG, (v) -> (long)(double)v).lossy().craftCast();
|
return (Cast<F, T>) new Cast.CastCrafter<>(ValueTypes.DOUBLE, ValueTypes.LONG, Double::longValue).lossy().craftCast();
|
||||||
}
|
}
|
||||||
if((from == ValueTypes.DOUBLE || from == ValueTypes.LONG) && to == ValueTypes.STRING) {
|
if((from == ValueTypes.DOUBLE || from == ValueTypes.LONG) && to == ValueTypes.STRING) {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
@@ -26,6 +31,23 @@ public class Casts {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <F,T> @Nullable T cast(TypedValue<F> from, ValueType<T> to) {
|
||||||
|
@Nullable Cast<F,T> cast = getCast(from.type(), to);
|
||||||
|
if(cast != null) {
|
||||||
|
return cast.cast(from.value());
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <F,T> Result<T, Text> castOrError(TypedValue<F> from, ValueType<T> to) {
|
||||||
|
return Result.ofNullable(Casts.cast(from, to), () -> Text.translatable(
|
||||||
|
"value_converter.minions.cast.cast_failed",
|
||||||
|
from.type().getDisplayText(from.value()),
|
||||||
|
Text.translatable(TranslationUtil.getTranslationKey(to, MinionRegistries.VALUE_TYPES))
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean canCastSafely(ValueType<?> from, ValueType<?> to) {
|
public static boolean canCastSafely(ValueType<?> from, ValueType<?> to) {
|
||||||
if(from == to) {
|
if(from == to) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package io.github.skippyall.minions.program.conversion;
|
||||||
|
|
||||||
|
import com.mojang.serialization.Codec;
|
||||||
|
import io.github.skippyall.minions.gui.input.Result;
|
||||||
|
import io.github.skippyall.minions.program.value.TypedValue;
|
||||||
|
import io.github.skippyall.minions.program.value.ValueType;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ListIterator;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class ConverterList {
|
||||||
|
public static final Codec<ConverterList> CODEC = ValueConverter.CODEC.listOf().xmap(ConverterList::new, l -> l.converters);
|
||||||
|
|
||||||
|
private final List<ValueConverter<?,?>> converters;
|
||||||
|
|
||||||
|
public ConverterList() {
|
||||||
|
this.converters = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ConverterList(List<ValueConverter<?,?>> converters) {
|
||||||
|
this.converters = new ArrayList<>(converters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ConverterList of(List<ValueConverter<?,?>> converters) {
|
||||||
|
return new ConverterList(new ArrayList<>(converters));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ValueConverter<?,?>> getConverters() {
|
||||||
|
return converters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ValueType<?> getInputType() {
|
||||||
|
return converters.getFirst().getFrom();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ValueType<?> getOutputType() {
|
||||||
|
return converters.getLast().getTo();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Result<TypedValue<?>, Text> convert(TypedValue<?> input) {
|
||||||
|
if(converters.isEmpty()) {
|
||||||
|
return new Result.Success<>(input);
|
||||||
|
} else {
|
||||||
|
ListIterator<ValueConverter<?, ?>> iterator = converters.listIterator();
|
||||||
|
return convert(input, iterator.next(), iterator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private <F,I,T> Result<TypedValue<?>, Text> convert(TypedValue<F> from, ValueConverter<I,T> converter, ListIterator<ValueConverter<?,?>> iterator) {
|
||||||
|
Result<I, Text> inter = Casts.castOrError(from, converter.getFrom());
|
||||||
|
if(inter instanceof Result.Error<I, Text> error) {
|
||||||
|
return new Result.Error<>(Text.translatable("minions.converter.list.passing_error", iterator.previousIndex(), error.message()));
|
||||||
|
}
|
||||||
|
Result<T, Text> to = converter.convert(inter.getOrThrow());
|
||||||
|
|
||||||
|
if(iterator.hasNext() && to instanceof Result.Success<T, Text> success) {
|
||||||
|
return convert(new TypedValue<>(success.result(), converter.getTo()), iterator.next(), iterator);
|
||||||
|
} else {
|
||||||
|
return to.map(v -> new TypedValue<>(v, converter.getTo()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Result<@Nullable Void, Text> check() {
|
||||||
|
return new Result.Success<>(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (!(o instanceof ConverterList that)) return false;
|
||||||
|
return Objects.equals(converters, that.converters);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(converters);
|
||||||
|
}
|
||||||
|
}
|
||||||
+19
-11
@@ -1,16 +1,20 @@
|
|||||||
package io.github.skippyall.minions.program.conversion;
|
package io.github.skippyall.minions.program.conversion;
|
||||||
|
|
||||||
import com.mojang.serialization.MapCodec;
|
import com.mojang.serialization.MapCodec;
|
||||||
|
import io.github.skippyall.minions.gui.MinionsGui;
|
||||||
|
import io.github.skippyall.minions.gui.input.Result;
|
||||||
import io.github.skippyall.minions.program.value.ValueType;
|
import io.github.skippyall.minions.program.value.ValueType;
|
||||||
import io.github.skippyall.minions.registration.MinionRegistries;
|
import io.github.skippyall.minions.registration.MinionRegistries;
|
||||||
|
import io.github.skippyall.minions.registration.ValueConverters;
|
||||||
import io.github.skippyall.minions.registration.ValueTypes;
|
import io.github.skippyall.minions.registration.ValueTypes;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.text.Text;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class EqualityConverter<F> implements ValueConverter<F, Boolean> {
|
public class EqualityConverter<F> implements ValueConverter<F, Boolean> {
|
||||||
public static final MapCodec<EqualityConverter<?>> CODEC = MinionRegistries.VALUE_TYPES.getCodec().dispatchMap(
|
public static final MapCodec<EqualityConverter<?>> CODEC = MinionRegistries.VALUE_TYPES.getCodec().dispatchMap(
|
||||||
|
"value_type",
|
||||||
EqualityConverter::getFrom,
|
EqualityConverter::getFrom,
|
||||||
EqualityConverter::getCodec
|
EqualityConverter::getCodec
|
||||||
);
|
);
|
||||||
@@ -24,8 +28,8 @@ public class EqualityConverter<F> implements ValueConverter<F, Boolean> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean convert(F from) {
|
public Result<Boolean, Text> convert(F from) {
|
||||||
return compareValue.equals(from);
|
return new Result.Success<>(compareValue.equals(from));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -40,7 +44,12 @@ public class EqualityConverter<F> implements ValueConverter<F, Boolean> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ValueConverterType<?> getType() {
|
public ValueConverterType<?> getType() {
|
||||||
return null;
|
return ValueConverters.EQUALITY_CONVERTER;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Text getDisplayText() {
|
||||||
|
return Text.translatable("value_converter.minions.equality.display", fromType.getDisplayText(compareValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <F> MapCodec<EqualityConverter<F>> getCodec(ValueType<F> fromType) {
|
private static <F> MapCodec<EqualityConverter<F>> getCodec(ValueType<F> fromType) {
|
||||||
@@ -60,14 +69,13 @@ public class EqualityConverter<F> implements ValueConverter<F, Boolean> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <F,T> CompletableFuture<EqualityConverter<?>> configure(ServerPlayerEntity player, ValueType<F> from, ValueType<T> to, @Nullable EqualityConverter<?> old) {
|
public <F,T> CompletableFuture<EqualityConverter<?>> configure(MinionsGui parent, ValueType<F> from, ValueType<T> to, @Nullable ValueConverter<?,?> old) {
|
||||||
if(to == ValueTypes.BOOLEAN) {
|
F oldValue = null;
|
||||||
//noinspection unchecked
|
if(old instanceof EqualityConverter<?> eq && eq.fromType == from) {
|
||||||
return from.openValueDialog(player, old != null && old.fromType == from ? (F) old.compareValue : null)
|
oldValue = from.checkedCast(eq.compareValue);
|
||||||
.thenApply(compareValue -> new EqualityConverter<>(from, compareValue));
|
|
||||||
} else {
|
|
||||||
return CompletableFuture.failedFuture(new IllegalArgumentException("EqualityConverter does not support converting to " + to));
|
|
||||||
}
|
}
|
||||||
|
return from.openValueDialog(parent, oldValue)
|
||||||
|
.thenApply(compareValue -> new EqualityConverter<>(from, compareValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.github.skippyall.minions.program.conversion;
|
package io.github.skippyall.minions.program.conversion;
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
|
import io.github.skippyall.minions.gui.input.Result;
|
||||||
import io.github.skippyall.minions.program.value.ValueType;
|
import io.github.skippyall.minions.program.value.ValueType;
|
||||||
import io.github.skippyall.minions.registration.MinionRegistries;
|
import io.github.skippyall.minions.registration.MinionRegistries;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
@@ -8,7 +9,7 @@ import net.minecraft.text.Text;
|
|||||||
public interface ValueConverter<F,T> {
|
public interface ValueConverter<F,T> {
|
||||||
Codec<ValueConverter<?,?>> CODEC = MinionRegistries.VALUE_CONVERTER_TYPES.getCodec().dispatch(ValueConverter::getType, ValueConverterType::getCodec);
|
Codec<ValueConverter<?,?>> CODEC = MinionRegistries.VALUE_CONVERTER_TYPES.getCodec().dispatch(ValueConverter::getType, ValueConverterType::getCodec);
|
||||||
|
|
||||||
T convert(F from);
|
Result<T, Text> convert(F from);
|
||||||
|
|
||||||
ValueType<F> getFrom();
|
ValueType<F> getFrom();
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
package io.github.skippyall.minions.program.conversion;
|
package io.github.skippyall.minions.program.conversion;
|
||||||
|
|
||||||
import com.mojang.serialization.MapCodec;
|
import com.mojang.serialization.MapCodec;
|
||||||
|
import io.github.skippyall.minions.gui.MinionsGui;
|
||||||
import io.github.skippyall.minions.program.value.ValueType;
|
import io.github.skippyall.minions.program.value.ValueType;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@@ -12,5 +12,5 @@ public interface ValueConverterType<C extends ValueConverter<?,?>> {
|
|||||||
|
|
||||||
boolean isSupportedConversion(ValueType<?> from, ValueType<?> to);
|
boolean isSupportedConversion(ValueType<?> from, ValueType<?> to);
|
||||||
|
|
||||||
<F,T> CompletableFuture<C> configure(ServerPlayerEntity player, ValueType<F> from, ValueType<T> to, @Nullable C old);
|
<F,T> CompletableFuture<C> configure(MinionsGui parent, ValueType<F> from, ValueType<T> to, @Nullable ValueConverter<?,?> old);
|
||||||
}
|
}
|
||||||
|
|||||||
+36
-20
@@ -1,12 +1,13 @@
|
|||||||
package io.github.skippyall.minions.program.instruction;
|
package io.github.skippyall.minions.program.instruction;
|
||||||
|
|
||||||
import io.github.skippyall.minions.registration.MinionRegistries;
|
|
||||||
import io.github.skippyall.minions.Minions;
|
import io.github.skippyall.minions.Minions;
|
||||||
import io.github.skippyall.minions.program.InstructionRuntime;
|
|
||||||
import io.github.skippyall.minions.program.supplier.Parameter;
|
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplierList;
|
|
||||||
import io.github.skippyall.minions.program.consumer.ValueConsumerList;
|
|
||||||
import io.github.skippyall.minions.listener.SerializableListenerManager;
|
import io.github.skippyall.minions.listener.SerializableListenerManager;
|
||||||
|
import io.github.skippyall.minions.program.InstructionRuntime;
|
||||||
|
import io.github.skippyall.minions.program.consumer.ValueConsumerList;
|
||||||
|
import io.github.skippyall.minions.program.supplier.Parameter;
|
||||||
|
import io.github.skippyall.minions.program.supplier.ParameterValueList;
|
||||||
|
import io.github.skippyall.minions.program.supplier.ValueSupplierList;
|
||||||
|
import io.github.skippyall.minions.registration.MinionRegistries;
|
||||||
import net.minecraft.storage.ReadView;
|
import net.minecraft.storage.ReadView;
|
||||||
import net.minecraft.storage.WriteView;
|
import net.minecraft.storage.WriteView;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -22,15 +23,27 @@ public class ConfiguredInstruction<R extends InstructionRuntime<R>> {
|
|||||||
private @Nullable InstructionExecution<R> execution;
|
private @Nullable InstructionExecution<R> execution;
|
||||||
private boolean paused = false;
|
private boolean paused = false;
|
||||||
|
|
||||||
private SerializableListenerManager<ConfiguredInstructionListener> listeners = new SerializableListenerManager<>(MinionRegistries.INSTRUCTION_LISTENER_CODECS);
|
private SerializableListenerManager<ConfiguredInstructionListener> listeners = new SerializableListenerManager<>();
|
||||||
|
|
||||||
private ConfiguredInstruction(InstructionType<R> instruction, ValueSupplierList<R> arguments, ValueConsumerList<R> valueConsumers, @Nullable InstructionExecution<R> execution, SerializableListenerManager<ConfiguredInstructionListener> listeners, boolean paused) {
|
private ConfiguredInstruction(
|
||||||
|
InstructionType<R> instruction,
|
||||||
|
ValueSupplierList<R> arguments,
|
||||||
|
ValueConsumerList<R> valueConsumers,
|
||||||
|
@Nullable InstructionExecution<R> execution,
|
||||||
|
SerializableListenerManager<ConfiguredInstructionListener> listeners,
|
||||||
|
boolean paused
|
||||||
|
) {
|
||||||
this(instruction, arguments, valueConsumers, execution);
|
this(instruction, arguments, valueConsumers, execution);
|
||||||
this.listeners = listeners;
|
this.listeners = listeners;
|
||||||
this.paused = paused;
|
this.paused = paused;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConfiguredInstruction(InstructionType<R> instruction, ValueSupplierList<R> arguments, ValueConsumerList<R> valueConsumers, @Nullable InstructionExecution<R> execution) {
|
private ConfiguredInstruction(
|
||||||
|
InstructionType<R> instruction,
|
||||||
|
ValueSupplierList<R> arguments,
|
||||||
|
ValueConsumerList<R> valueConsumers,
|
||||||
|
@Nullable InstructionExecution<R> execution
|
||||||
|
) {
|
||||||
this.instruction = instruction;
|
this.instruction = instruction;
|
||||||
this.arguments = arguments;
|
this.arguments = arguments;
|
||||||
this.valueConsumers = valueConsumers;
|
this.valueConsumers = valueConsumers;
|
||||||
@@ -52,7 +65,7 @@ public class ConfiguredInstruction<R extends InstructionRuntime<R>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canRun() {
|
public boolean canRun() {
|
||||||
return instruction != null && arguments != null && arguments.checkRun(instruction).isSuccess();
|
return instruction != null && arguments != null && arguments.checkRun(instruction) == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRunning() {
|
public boolean isRunning() {
|
||||||
@@ -65,8 +78,9 @@ public class ConfiguredInstruction<R extends InstructionRuntime<R>> {
|
|||||||
|
|
||||||
public void run(R minion) {
|
public void run(R minion) {
|
||||||
if(canRun() && !isRunning()) {
|
if(canRun() && !isRunning()) {
|
||||||
|
ParameterValueList resolvedArguments = arguments.resolve(minion);
|
||||||
try {
|
try {
|
||||||
execution = instruction.createExecution(arguments, minion);
|
execution = instruction.createExecution(resolvedArguments, minion);
|
||||||
execution.start(minion);
|
execution.start(minion);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Minions.LOGGER.error("An error occurred while executing configured Instruction", e);
|
Minions.LOGGER.error("An error occurred while executing configured Instruction", e);
|
||||||
@@ -132,17 +146,17 @@ public class ConfiguredInstruction<R extends InstructionRuntime<R>> {
|
|||||||
listeners.removeListener(listener);
|
listeners.removeListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(WriteView view, R minion) {
|
public void save(WriteView view, R runtime) {
|
||||||
view.put("instruction", minion.getInstructionTypeRegistry().getCodec(), instruction);
|
view.put("instruction", runtime.getInstructionTypeRegistry().getCodec(), instruction);
|
||||||
view.put("arguments", minion.getArgumentListCodec(), arguments);
|
view.put("arguments", runtime.getArgumentListCodec(), arguments);
|
||||||
view.put("valueConsumers", minion.getValueConsumerListCodec(), valueConsumers);
|
view.put("valueConsumers", runtime.getValueConsumerListCodec(), valueConsumers);
|
||||||
view.putBoolean("running", isRunning());
|
view.putBoolean("running", isRunning());
|
||||||
view.putBoolean("paused", paused);
|
view.putBoolean("paused", paused);
|
||||||
if(execution != null) {
|
view.put("listeners", SerializableListenerManager.getCodec(MinionRegistries.INSTRUCTION_LISTENER_CODECS), listeners);
|
||||||
execution.save(view.get("execution"), minion);
|
|
||||||
}
|
|
||||||
|
|
||||||
listeners.save(view);
|
if(execution != null) {
|
||||||
|
execution.save(view.get("execution"), runtime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <R extends InstructionRuntime<R>> ConfiguredInstruction<R> load(ReadView view, R minion) {
|
public static <R extends InstructionRuntime<R>> ConfiguredInstruction<R> load(ReadView view, R minion) {
|
||||||
@@ -154,8 +168,10 @@ public class ConfiguredInstruction<R extends InstructionRuntime<R>> {
|
|||||||
boolean running = view.getBoolean("running", false);
|
boolean running = view.getBoolean("running", false);
|
||||||
boolean paused = view.getBoolean("paused", false);
|
boolean paused = view.getBoolean("paused", false);
|
||||||
|
|
||||||
SerializableListenerManager<ConfiguredInstructionListener> listeners = new SerializableListenerManager<>(MinionRegistries.INSTRUCTION_LISTENER_CODECS);
|
SerializableListenerManager<ConfiguredInstructionListener> listeners = view.read(
|
||||||
listeners.load(view);
|
"listeners",
|
||||||
|
SerializableListenerManager.getCodec(MinionRegistries.INSTRUCTION_LISTENER_CODECS)
|
||||||
|
).orElseGet(SerializableListenerManager::new);
|
||||||
|
|
||||||
if(running) {
|
if(running) {
|
||||||
ReadView executionView = view.getReadView("execution");
|
ReadView executionView = view.getReadView("execution");
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
package io.github.skippyall.minions.program.instruction;
|
package io.github.skippyall.minions.program.instruction;
|
||||||
|
|
||||||
import io.github.skippyall.minions.program.supplier.Parameter;
|
|
||||||
import io.github.skippyall.minions.listener.SerializableListenerManager;
|
import io.github.skippyall.minions.listener.SerializableListenerManager;
|
||||||
|
import io.github.skippyall.minions.program.supplier.Parameter;
|
||||||
|
|
||||||
public interface ConfiguredInstructionListener extends SerializableListenerManager.SerializableListener {
|
public interface ConfiguredInstructionListener extends SerializableListenerManager.SerializableListener {
|
||||||
default void onRun(ConfiguredInstruction<?> instruction) {}
|
default void onRun(ConfiguredInstruction<?> instruction) {}
|
||||||
|
|||||||
+4
-3
@@ -1,8 +1,9 @@
|
|||||||
package io.github.skippyall.minions.program.instruction;
|
package io.github.skippyall.minions.program.instruction;
|
||||||
|
|
||||||
import io.github.skippyall.minions.program.InstructionRuntime;
|
import io.github.skippyall.minions.program.InstructionRuntime;
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplierList;
|
|
||||||
import io.github.skippyall.minions.program.consumer.ValueConsumerList;
|
import io.github.skippyall.minions.program.consumer.ValueConsumerList;
|
||||||
|
import io.github.skippyall.minions.program.supplier.ParameterValueList;
|
||||||
|
import io.github.skippyall.minions.program.supplier.ValueSupplierList;
|
||||||
import net.minecraft.storage.ReadView;
|
import net.minecraft.storage.ReadView;
|
||||||
import net.minecraft.storage.WriteView;
|
import net.minecraft.storage.WriteView;
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ public interface InstructionExecution<R extends InstructionRuntime<R>> {
|
|||||||
* @param arguments The arguments to initialize the execution
|
* @param arguments The arguments to initialize the execution
|
||||||
* @param runtime The runtime should be used to resolve the arguments
|
* @param runtime The runtime should be used to resolve the arguments
|
||||||
*/
|
*/
|
||||||
void readArguments(ValueSupplierList<R> arguments, R runtime);
|
void readArguments(ParameterValueList arguments, R runtime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the execution, e.g. when the server is closed.
|
* Saves the execution, e.g. when the server is closed.
|
||||||
@@ -62,7 +63,7 @@ public interface InstructionExecution<R extends InstructionRuntime<R>> {
|
|||||||
|
|
||||||
interface Stateless<R extends InstructionRuntime<R>> extends InstructionExecution<R> {
|
interface Stateless<R extends InstructionRuntime<R>> extends InstructionExecution<R> {
|
||||||
@Override
|
@Override
|
||||||
default void readArguments(ValueSupplierList<R> arguments, R runtime) {}
|
default void readArguments(ParameterValueList arguments, R runtime) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void save(WriteView view, R runtime) {}
|
default void save(WriteView view, R runtime) {}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package io.github.skippyall.minions.program.instruction;
|
|||||||
|
|
||||||
import io.github.skippyall.minions.program.InstructionRuntime;
|
import io.github.skippyall.minions.program.InstructionRuntime;
|
||||||
import io.github.skippyall.minions.program.supplier.Parameter;
|
import io.github.skippyall.minions.program.supplier.Parameter;
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplierList;
|
import io.github.skippyall.minions.program.supplier.ParameterValueList;
|
||||||
import net.minecraft.storage.ReadView;
|
import net.minecraft.storage.ReadView;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -33,9 +33,9 @@ public class InstructionType<R extends InstructionRuntime<R>> {
|
|||||||
return returnParameters;
|
return returnParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstructionExecution<R> createExecution(ValueSupplierList<R> parameters, R minion) {
|
public InstructionExecution<R> createExecution(ParameterValueList arguments, R minion) {
|
||||||
InstructionExecution<R> execution = executionFactory.get();
|
InstructionExecution<R> execution = executionFactory.get();
|
||||||
execution.readArguments(parameters, minion);
|
execution.readArguments(arguments, minion);
|
||||||
return execution;
|
return execution;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,6 @@ public class FixedValueSupplier<T, R extends InstructionRuntime<R>> implements V
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Text getDisplayText() {
|
public Text getDisplayText() {
|
||||||
return Text.translatable("value_supplier_type.minions.fixed.display", valueType.getDisplayText(value));
|
return valueType.getDisplayText(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -1,9 +1,9 @@
|
|||||||
package io.github.skippyall.minions.program.supplier;
|
package io.github.skippyall.minions.program.supplier;
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
|
import io.github.skippyall.minions.gui.MinionsGui;
|
||||||
import io.github.skippyall.minions.program.InstructionRuntime;
|
import io.github.skippyall.minions.program.InstructionRuntime;
|
||||||
import io.github.skippyall.minions.program.value.ValueType;
|
import io.github.skippyall.minions.program.value.ValueType;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@@ -15,10 +15,10 @@ public class FixedValueSupplierType<R extends InstructionRuntime<R>> extends Val
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <V> CompletableFuture<FixedValueSupplier<V,R>> openConfiguration(ServerPlayerEntity player, ValueType<V> valueType, @Nullable ValueSupplier<V,R> previousValueSupplier) {
|
public <V> CompletableFuture<FixedValueSupplier<?,R>> openConfiguration(MinionsGui parent, ValueType<V> valueType, @Nullable ValueSupplier<?,R> previousValueSupplier) {
|
||||||
return valueType.openValueDialog(
|
return valueType.openValueDialog(
|
||||||
player,
|
parent,
|
||||||
previousValueSupplier instanceof FixedValueSupplier<V,R> val ? val.getValue() : valueType.defaultValue()
|
previousValueSupplier instanceof FixedValueSupplier<?,R> val && val.getValueType() == valueType ? valueType.checkedCast(val.getValue()) : valueType.defaultValue()
|
||||||
).thenApply(value -> new FixedValueSupplier<>(this, valueType, value));
|
).thenApply(value -> new FixedValueSupplier<>(this, valueType, value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ package io.github.skippyall.minions.program.supplier;
|
|||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.mojang.serialization.MapCodec;
|
import com.mojang.serialization.MapCodec;
|
||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
import io.github.skippyall.minions.program.value.SimpleValueType;
|
|
||||||
import io.github.skippyall.minions.registration.MinionRegistries;
|
|
||||||
import io.github.skippyall.minions.program.value.ValueType;
|
import io.github.skippyall.minions.program.value.ValueType;
|
||||||
|
import io.github.skippyall.minions.registration.MinionRegistries;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public record Parameter<T>(String name, ValueType<T> type) {
|
public record Parameter<T>(String name, ValueType<T> type) {
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package io.github.skippyall.minions.program.supplier;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ParameterValueList {
|
||||||
|
private final Map<Parameter<?>, Object> values;
|
||||||
|
|
||||||
|
public ParameterValueList() {
|
||||||
|
values = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> T getValue(Parameter<T> parameter) {
|
||||||
|
//noinspection unchecked
|
||||||
|
return (T) values.get(parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void setValue(Parameter<T> parameter, T value) {
|
||||||
|
values.put(parameter, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,9 +2,9 @@ package io.github.skippyall.minions.program.supplier;
|
|||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.mojang.serialization.DataResult;
|
import com.mojang.serialization.DataResult;
|
||||||
import io.github.skippyall.minions.registration.MinionRegistries;
|
|
||||||
import io.github.skippyall.minions.program.InstructionRuntime;
|
import io.github.skippyall.minions.program.InstructionRuntime;
|
||||||
import io.github.skippyall.minions.program.value.ValueType;
|
import io.github.skippyall.minions.program.value.ValueType;
|
||||||
|
import io.github.skippyall.minions.registration.MinionRegistries;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
|||||||
@@ -5,43 +5,40 @@ import com.mojang.serialization.MapCodec;
|
|||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
import io.github.skippyall.minions.gui.input.Result;
|
import io.github.skippyall.minions.gui.input.Result;
|
||||||
import io.github.skippyall.minions.program.InstructionRuntime;
|
import io.github.skippyall.minions.program.InstructionRuntime;
|
||||||
import io.github.skippyall.minions.program.conversion.Cast;
|
|
||||||
import io.github.skippyall.minions.program.conversion.Casts;
|
import io.github.skippyall.minions.program.conversion.Casts;
|
||||||
import io.github.skippyall.minions.program.conversion.ValueConverter;
|
import io.github.skippyall.minions.program.conversion.ConverterList;
|
||||||
import io.github.skippyall.minions.program.instruction.InstructionType;
|
import io.github.skippyall.minions.program.instruction.InstructionType;
|
||||||
import io.github.skippyall.minions.program.value.ValueType;
|
import io.github.skippyall.minions.program.value.TypedValue;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class ValueSupplierList<R extends InstructionRuntime<R>> {
|
public class ValueSupplierList<R extends InstructionRuntime<R>> {
|
||||||
private final Map<Parameter<?>, ValueSupplierEntry<?,?,R>> arguments = new HashMap<>();
|
private final Map<Parameter<?>, ValueSupplierEntry<?,R>> arguments = new HashMap<>();
|
||||||
private final List<Consumer<Parameter<?>>> changeListeners = new ArrayList<>();
|
private final List<Consumer<Parameter<?>>> changeListeners = new ArrayList<>();
|
||||||
|
|
||||||
public ValueSupplierList() {
|
public ValueSupplierList() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ValueSupplierList(List<ValueSupplierEntry<?,?,R>> arguments) {
|
private ValueSupplierList(List<ValueSupplierEntry<?,R>> arguments) {
|
||||||
for(ValueSupplierEntry<?,?,R> argument : arguments) {
|
for(ValueSupplierEntry<?,R> argument : arguments) {
|
||||||
this.arguments.put(argument.parameter, argument);
|
this.arguments.put(argument.parameter, argument);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ValueSupplierEntry<?,?,R>> toCodecList() {
|
private List<ValueSupplierEntry<?,R>> toCodecList() {
|
||||||
return List.copyOf(arguments.values());
|
return List.copyOf(arguments.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T getValue(Parameter<T> parameter, R runtime) {
|
public <T> T getValue(Parameter<T> parameter, R runtime) {
|
||||||
ValueSupplierEntry<?,?,R> entry = getEntry(parameter);
|
ValueSupplierEntry<?,R> entry = getEntry(parameter);
|
||||||
return parameter.type().checkedCast(entry.getValue(runtime));
|
return parameter.type().checkedCast(entry.getValue(runtime));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,47 +50,55 @@ public class ValueSupplierList<R extends InstructionRuntime<R>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public <P> ValueSupplierEntry<P,?,R> getEntry(Parameter<P> parameter) {
|
public <P> ValueSupplierEntry<P,R> getEntry(Parameter<P> parameter) {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return (ValueSupplierEntry<P, ?, R>) arguments.get(parameter);
|
return (ValueSupplierEntry<P,R>) arguments.get(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArgument(Parameter<?> parameter, ValueSupplier<?,R> valueSupplier) {
|
public <P> ValueSupplierEntry<P,R> createEntry(Parameter<P> parameter, ValueSupplier<?,R> supplier) {
|
||||||
arguments.put(parameter, new ValueSupplierEntry<>(parameter, valueSupplier, List.of()));
|
ValueSupplierEntry<P,R> entry = new ValueSupplierEntry<>(parameter, supplier, new ConverterList());
|
||||||
onChange(parameter);
|
arguments.put(parameter, entry);
|
||||||
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArgument(Parameter<?> parameter, ValueSupplier<?,R> valueSupplier, List<ValueConverter<?, ?>> converter) {
|
public void removeEntry(Parameter<?> parameter) {
|
||||||
arguments.put(parameter, new ValueSupplierEntry<>(parameter, valueSupplier, converter));
|
arguments.remove(parameter);
|
||||||
onChange(parameter);
|
}
|
||||||
|
|
||||||
|
public ParameterValueList resolve(R runtime) {
|
||||||
|
ParameterValueList list = new ParameterValueList();
|
||||||
|
for(ValueSupplierEntry<?,R> argument : arguments.values()) {
|
||||||
|
argument.addToList(list, runtime);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasArgumentFor(Parameter<?> parameter) {
|
public boolean hasArgumentFor(Parameter<?> parameter) {
|
||||||
return arguments.containsKey(parameter);
|
return arguments.containsKey(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result<@Nullable Void, Text> checkHasArguments(Collection<Parameter<?>> checkParameters) {
|
public @Nullable Text checkHasArguments(Collection<Parameter<?>> checkParameters) {
|
||||||
for(Parameter<?> parameter : checkParameters) {
|
for(Parameter<?> parameter : checkParameters) {
|
||||||
if(!hasArgumentFor(parameter)) {
|
if(!hasArgumentFor(parameter)) {
|
||||||
return new Result.Error<>(Text.translatable("minions.gui.instruction.check.argument_not_set", parameter.name()));
|
return Text.translatable("minions.gui.instruction.check.argument_not_set", parameter.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Result.Success<>(null);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result<@Nullable Void, Text> checkRun(InstructionType<R> instructionType) {
|
public @Nullable Text checkRun(InstructionType<R> instructionType) {
|
||||||
Result<@Nullable Void, Text> checkResult = checkHasArguments(instructionType.getParameters());
|
@Nullable Text checkResult = checkHasArguments(instructionType.getParameters());
|
||||||
if(!checkResult.isSuccess()) {
|
if(checkResult != null) {
|
||||||
return checkResult;
|
return checkResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(ValueSupplierEntry<?,?,R> entry : arguments.values()) {
|
for(ValueSupplierEntry<?,R> entry : arguments.values()) {
|
||||||
checkResult = entry.check();
|
checkResult = entry.check();
|
||||||
if(!checkResult.isSuccess()) {
|
if(checkResult != null) {
|
||||||
return checkResult;
|
return checkResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Result.Success<>(null);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onChange(Parameter<?> parameter) {
|
private void onChange(Parameter<?> parameter) {
|
||||||
@@ -117,18 +122,18 @@ public class ValueSupplierList<R extends InstructionRuntime<R>> {
|
|||||||
.xmap(ValueSupplierList::new, ValueSupplierList::toCodecList);
|
.xmap(ValueSupplierList::new, ValueSupplierList::toCodecList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ValueSupplierEntry<S, P, R extends InstructionRuntime<R>> {
|
public static class ValueSupplierEntry<P, R extends InstructionRuntime<R>> {
|
||||||
private Parameter<P> parameter;
|
private Parameter<P> parameter;
|
||||||
private ValueSupplier<S,R> supplier;
|
private ValueSupplier<?,R> supplier;
|
||||||
private List<ValueConverter<?,?>> converters;
|
private ConverterList converters;
|
||||||
|
|
||||||
public ValueSupplierEntry(Parameter<P> parameter, ValueSupplier<S, R> supplier, Collection<ValueConverter<?, ?>> converters) {
|
public ValueSupplierEntry(Parameter<P> parameter, ValueSupplier<?, R> supplier, ConverterList converters) {
|
||||||
this.parameter = parameter;
|
this.parameter = parameter;
|
||||||
this.supplier = supplier;
|
this.supplier = supplier;
|
||||||
this.converters = new LinkedList<>(converters);
|
this.converters = converters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ValueConverter<?,?>> getConverters() {
|
public ConverterList getConverters() {
|
||||||
return converters;
|
return converters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +141,7 @@ public class ValueSupplierList<R extends InstructionRuntime<R>> {
|
|||||||
return parameter;
|
return parameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ValueSupplier<S, R> getSupplier() {
|
public ValueSupplier<?, R> getSupplier() {
|
||||||
return supplier;
|
return supplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,64 +149,36 @@ public class ValueSupplierList<R extends InstructionRuntime<R>> {
|
|||||||
this.parameter = parameter;
|
this.parameter = parameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSupplier(ValueSupplier<S, R> supplier) {
|
public void setSupplier(ValueSupplier<?, R> supplier) {
|
||||||
this.supplier = supplier;
|
this.supplier = supplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConverters(List<ValueConverter<?, ?>> converters) {
|
private void addToList(ParameterValueList list, R runtime) {
|
||||||
this.converters = converters;
|
list.setValue(parameter, getValue(runtime));
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable P getValue(R runtime) {
|
public @Nullable P getValue(R runtime) {
|
||||||
S value = supplier.resolve(runtime);
|
return getValue(supplier, runtime);
|
||||||
Iterator<ValueConverter<?,?>> iterator = converters.iterator();
|
|
||||||
Object convertedValue = convert(supplier.getValueType(), value, iterator.next(), iterator);
|
|
||||||
|
|
||||||
return finalCast(convertedValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private <F> @Nullable P finalCast(Object value) {
|
//Ich liebe generische Typen (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
|
||||||
//noinspection unchecked
|
private <S> @Nullable P getValue(ValueSupplier<S, R> supplier, R runtime) {
|
||||||
ValueType<F> lastConvertedType = (ValueType<F>) converters.getLast().getTo();
|
S value = supplier.resolve(runtime);
|
||||||
F convertedValue = lastConvertedType.checkedCast(value);
|
Result<TypedValue<?>, Text> convertedResult = converters.convert(new TypedValue<>(value, supplier.getValueType()));
|
||||||
if(convertedValue == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Cast<F,P> cast = Casts.getCast(lastConvertedType, parameter.type());
|
return convertedResult.flatMap(convertedValue -> Casts.castOrError(convertedValue, parameter.type())).getOrDefault(null);
|
||||||
if(cast != null) {
|
}
|
||||||
return cast.cast(convertedValue);
|
|
||||||
}
|
public @Nullable Text check() {
|
||||||
|
//TODO check it
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private <F,I,T> @Nullable Object convert(ValueType<F> fromType, F from, ValueConverter<I,T> converter, Iterator<ValueConverter<?,?>> iterator) {
|
public static <R extends InstructionRuntime<R>> MapCodec<ValueSupplierEntry<?,R>> getCodec(Codec<ValueSupplier<?,R>> argumentCodec) {
|
||||||
Cast<F, I> cast = Casts.getCast(fromType, converter.getFrom());
|
|
||||||
if(cast == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
I inter = cast.cast(from);
|
|
||||||
if(inter == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
T to = converter.convert(inter);
|
|
||||||
|
|
||||||
if(iterator.hasNext() && to != null) {
|
|
||||||
return convert(converter.getTo(), to, iterator.next(), iterator);
|
|
||||||
} else {
|
|
||||||
return to;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result<@Nullable Void, Text> check() {
|
|
||||||
return new Result.Success<>(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <R extends InstructionRuntime<R>> MapCodec<ValueSupplierEntry<?,?,R>> getCodec(Codec<ValueSupplier<?,R>> argumentCodec) {
|
|
||||||
return RecordCodecBuilder.mapCodec(instance -> instance.group(
|
return RecordCodecBuilder.mapCodec(instance -> instance.group(
|
||||||
Parameter.CODEC.fieldOf("parameter").forGetter(e -> e.parameter),
|
Parameter.CODEC.fieldOf("parameter").forGetter(e -> e.parameter),
|
||||||
argumentCodec.fieldOf("argument").forGetter(e -> e.supplier),
|
argumentCodec.fieldOf("argument").forGetter(e -> e.supplier),
|
||||||
ValueConverter.CODEC.listOf().optionalFieldOf("converter", List.of()).forGetter(e -> e.converters)
|
ConverterList.CODEC.fieldOf("converter").forGetter(e -> e.converters)
|
||||||
).apply(instance, ValueSupplierEntry::new));
|
).apply(instance, ValueSupplierEntry::new));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package io.github.skippyall.minions.program.supplier;
|
package io.github.skippyall.minions.program.supplier;
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
|
import io.github.skippyall.minions.gui.MinionsGui;
|
||||||
import io.github.skippyall.minions.program.InstructionRuntime;
|
import io.github.skippyall.minions.program.InstructionRuntime;
|
||||||
import io.github.skippyall.minions.program.value.ValueType;
|
import io.github.skippyall.minions.program.value.ValueType;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@@ -11,5 +11,5 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
public abstract class ValueSupplierType<R extends InstructionRuntime<R>> {
|
public abstract class ValueSupplierType<R extends InstructionRuntime<R>> {
|
||||||
public abstract <T> Codec<? extends ValueSupplier<T,R>> getCodec(ValueType<T> type);
|
public abstract <T> Codec<? extends ValueSupplier<T,R>> getCodec(ValueType<T> type);
|
||||||
|
|
||||||
public abstract <T> CompletableFuture<? extends ValueSupplier<?,R>> openConfiguration(ServerPlayerEntity player, ValueType<T> valueType, @Nullable ValueSupplier<T,R> previous);
|
public abstract <T> CompletableFuture<? extends ValueSupplier<?,R>> openConfiguration(MinionsGui gui, ValueType<T> valueType, @Nullable ValueSupplier<?,R> previous);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
package io.github.skippyall.minions.program.value;
|
|
||||||
|
|
||||||
import io.github.skippyall.minions.gui.input.Result;
|
|
||||||
import net.minecraft.text.Text;
|
|
||||||
|
|
||||||
public interface RestrictionRule<T> {
|
|
||||||
Result<Void, Text> validate(T value);
|
|
||||||
|
|
||||||
default boolean matches(T value) {
|
|
||||||
return validate(value).isSuccess();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +1,17 @@
|
|||||||
package io.github.skippyall.minions.program.value;
|
package io.github.skippyall.minions.program.value;
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import io.github.skippyall.minions.gui.MinionsGui;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public record SimpleValueType<T>(Codec<T> codec, T defaultValue, Function<Object, T> checkedCast, BiFunction<ServerPlayerEntity, T, CompletableFuture<T>> valueDialogOpener, Function<T, Text> textDisplay) implements ValueType<T> {
|
public record SimpleValueType<T>(Codec<T> codec, T defaultValue, Function<Object, T> checkedCast, BiFunction<MinionsGui, T, CompletableFuture<T>> valueDialogOpener, Function<T, Text> textDisplay) implements ValueType<T> {
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<T> openValueDialog(ServerPlayerEntity player, T previousValue) {
|
public CompletableFuture<T> openValueDialog(MinionsGui parent, T previousValue) {
|
||||||
return valueDialogOpener.apply(player, previousValue);
|
return valueDialogOpener.apply(parent, previousValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
package io.github.skippyall.minions.program.value;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
public record TypeRestriction<T>(ValueType<T> type, Collection<RestrictionRule<T>> rules) {
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package io.github.skippyall.minions.program.value;
|
||||||
|
|
||||||
|
public record TypedValue<T>(T value, ValueType<T> type) {
|
||||||
|
public static <T> TypedValue<T> of(Object o, ValueType<T> type) {
|
||||||
|
return new TypedValue<>(type.checkedCast(o), type);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +1,14 @@
|
|||||||
package io.github.skippyall.minions.program.value;
|
package io.github.skippyall.minions.program.value;
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import io.github.skippyall.minions.gui.MinionsGui;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.function.BiFunction;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public interface ValueType<T> {
|
public interface ValueType<T> {
|
||||||
CompletableFuture<T> openValueDialog(ServerPlayerEntity player, T previousValue);
|
CompletableFuture<T> openValueDialog(MinionsGui gui, T previousValue);
|
||||||
|
|
||||||
Text getDisplayText(T value);
|
Text getDisplayText(T value);
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package io.github.skippyall.minions.registration;
|
|||||||
import com.mojang.serialization.MapCodec;
|
import com.mojang.serialization.MapCodec;
|
||||||
import io.github.skippyall.minions.Minions;
|
import io.github.skippyall.minions.Minions;
|
||||||
import io.github.skippyall.minions.clipboard.BlockPosClipboard;
|
import io.github.skippyall.minions.clipboard.BlockPosClipboard;
|
||||||
import io.github.skippyall.minions.clipboard.InstructionClipboard;
|
|
||||||
import io.github.skippyall.minions.clipboard.Clipboard;
|
import io.github.skippyall.minions.clipboard.Clipboard;
|
||||||
|
import io.github.skippyall.minions.clipboard.InstructionClipboard;
|
||||||
import net.minecraft.registry.Registry;
|
import net.minecraft.registry.Registry;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
package io.github.skippyall.minions.registration;
|
package io.github.skippyall.minions.registration;
|
||||||
|
|
||||||
import io.github.skippyall.minions.minion.program.instruction.inventory.SwapItemExecution;
|
|
||||||
import io.github.skippyall.minions.program.instruction.InstructionExecution;
|
|
||||||
import io.github.skippyall.minions.program.instruction.InstructionType;
|
|
||||||
import io.github.skippyall.minions.Minions;
|
import io.github.skippyall.minions.Minions;
|
||||||
import io.github.skippyall.minions.minion.MinionRuntime;
|
import io.github.skippyall.minions.minion.MinionRuntime;
|
||||||
import io.github.skippyall.minions.minion.fakeplayer.EntityPlayerActionPack;
|
import io.github.skippyall.minions.minion.fakeplayer.EntityPlayerActionPack;
|
||||||
import io.github.skippyall.minions.minion.program.instruction.ActionExecution;
|
import io.github.skippyall.minions.minion.program.instruction.ActionExecution;
|
||||||
import io.github.skippyall.minions.minion.program.instruction.MineBlockExecution;
|
import io.github.skippyall.minions.minion.program.instruction.MineBlockExecution;
|
||||||
|
import io.github.skippyall.minions.minion.program.instruction.inventory.SwapItemExecution;
|
||||||
import io.github.skippyall.minions.minion.program.instruction.move.ContinuousWalkExecution;
|
import io.github.skippyall.minions.minion.program.instruction.move.ContinuousWalkExecution;
|
||||||
import io.github.skippyall.minions.minion.program.instruction.move.TurnExecution;
|
import io.github.skippyall.minions.minion.program.instruction.move.TurnExecution;
|
||||||
import io.github.skippyall.minions.minion.program.instruction.move.TurnVectorExecution;
|
import io.github.skippyall.minions.minion.program.instruction.move.TurnVectorExecution;
|
||||||
import io.github.skippyall.minions.minion.program.instruction.move.WalkExecution;
|
import io.github.skippyall.minions.minion.program.instruction.move.WalkExecution;
|
||||||
|
import io.github.skippyall.minions.program.instruction.InstructionExecution;
|
||||||
|
import io.github.skippyall.minions.program.instruction.InstructionType;
|
||||||
import io.github.skippyall.minions.program.supplier.Parameter;
|
import io.github.skippyall.minions.program.supplier.Parameter;
|
||||||
import net.minecraft.registry.Registry;
|
import net.minecraft.registry.Registry;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityT
|
|||||||
import net.minecraft.block.AbstractBlock;
|
import net.minecraft.block.AbstractBlock;
|
||||||
import net.minecraft.block.entity.BlockEntityType;
|
import net.minecraft.block.entity.BlockEntityType;
|
||||||
import net.minecraft.block.piston.PistonBehavior;
|
import net.minecraft.block.piston.PistonBehavior;
|
||||||
import net.minecraft.network.packet.CustomPayload;
|
|
||||||
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;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package io.github.skippyall.minions.registration;
|
|||||||
|
|
||||||
import eu.pb4.polymer.core.api.other.PolymerComponent;
|
import eu.pb4.polymer.core.api.other.PolymerComponent;
|
||||||
import io.github.skippyall.minions.Minions;
|
import io.github.skippyall.minions.Minions;
|
||||||
import io.github.skippyall.minions.module.MinionModule;
|
|
||||||
import io.github.skippyall.minions.clipboard.Clipboard;
|
import io.github.skippyall.minions.clipboard.Clipboard;
|
||||||
|
import io.github.skippyall.minions.module.MinionModule;
|
||||||
import net.fabricmc.fabric.api.item.v1.ComponentTooltipAppenderRegistry;
|
import net.fabricmc.fabric.api.item.v1.ComponentTooltipAppenderRegistry;
|
||||||
import net.minecraft.component.ComponentType;
|
import net.minecraft.component.ComponentType;
|
||||||
import net.minecraft.registry.Registries;
|
import net.minecraft.registry.Registries;
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ package io.github.skippyall.minions.registration;
|
|||||||
import eu.pb4.polymer.core.api.item.PolymerBlockItem;
|
import eu.pb4.polymer.core.api.item.PolymerBlockItem;
|
||||||
import eu.pb4.polymer.core.api.item.SimplePolymerItem;
|
import eu.pb4.polymer.core.api.item.SimplePolymerItem;
|
||||||
import io.github.skippyall.minions.block.miniontrigger.MinionTriggerBlockItem;
|
import io.github.skippyall.minions.block.miniontrigger.MinionTriggerBlockItem;
|
||||||
|
import io.github.skippyall.minions.clipboard.ClipboardItem;
|
||||||
import io.github.skippyall.minions.minion.MinionItem;
|
import io.github.skippyall.minions.minion.MinionItem;
|
||||||
import io.github.skippyall.minions.minion.MinionRuntime;
|
import io.github.skippyall.minions.minion.MinionRuntime;
|
||||||
import io.github.skippyall.minions.module.MinionModule;
|
import io.github.skippyall.minions.module.MinionModule;
|
||||||
import io.github.skippyall.minions.module.SpecialAbility;
|
import io.github.skippyall.minions.module.SpecialAbility;
|
||||||
import io.github.skippyall.minions.program.instruction.InstructionType;
|
import io.github.skippyall.minions.program.instruction.InstructionType;
|
||||||
import io.github.skippyall.minions.clipboard.ClipboardItem;
|
|
||||||
import net.minecraft.component.DataComponentTypes;
|
import net.minecraft.component.DataComponentTypes;
|
||||||
import net.minecraft.component.type.DamageResistantComponent;
|
import net.minecraft.component.type.DamageResistantComponent;
|
||||||
import net.minecraft.entity.damage.DamageType;
|
import net.minecraft.entity.damage.DamageType;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.github.skippyall.minions.registration;
|
|||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.mojang.serialization.MapCodec;
|
import com.mojang.serialization.MapCodec;
|
||||||
import io.github.skippyall.minions.Minions;
|
import io.github.skippyall.minions.Minions;
|
||||||
|
import io.github.skippyall.minions.clipboard.Clipboard;
|
||||||
import io.github.skippyall.minions.docs.DocsEntry;
|
import io.github.skippyall.minions.docs.DocsEntry;
|
||||||
import io.github.skippyall.minions.docs.ReferenceEntry;
|
import io.github.skippyall.minions.docs.ReferenceEntry;
|
||||||
import io.github.skippyall.minions.gui.GuiDisplay;
|
import io.github.skippyall.minions.gui.GuiDisplay;
|
||||||
@@ -11,13 +12,12 @@ import io.github.skippyall.minions.minion.MinionListener;
|
|||||||
import io.github.skippyall.minions.minion.MinionRuntime;
|
import io.github.skippyall.minions.minion.MinionRuntime;
|
||||||
import io.github.skippyall.minions.minion.skin.SkinProvider;
|
import io.github.skippyall.minions.minion.skin.SkinProvider;
|
||||||
import io.github.skippyall.minions.module.SpecialAbility;
|
import io.github.skippyall.minions.module.SpecialAbility;
|
||||||
import io.github.skippyall.minions.program.instruction.ConfiguredInstructionListener;
|
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplierType;
|
|
||||||
import io.github.skippyall.minions.program.instruction.InstructionType;
|
|
||||||
import io.github.skippyall.minions.program.consumer.ValueConsumerType;
|
import io.github.skippyall.minions.program.consumer.ValueConsumerType;
|
||||||
import io.github.skippyall.minions.program.value.ValueType;
|
|
||||||
import io.github.skippyall.minions.clipboard.Clipboard;
|
|
||||||
import io.github.skippyall.minions.program.conversion.ValueConverterType;
|
import io.github.skippyall.minions.program.conversion.ValueConverterType;
|
||||||
|
import io.github.skippyall.minions.program.instruction.ConfiguredInstructionListener;
|
||||||
|
import io.github.skippyall.minions.program.instruction.InstructionType;
|
||||||
|
import io.github.skippyall.minions.program.supplier.ValueSupplierType;
|
||||||
|
import io.github.skippyall.minions.program.value.ValueType;
|
||||||
import net.fabricmc.fabric.api.event.registry.DynamicRegistries;
|
import net.fabricmc.fabric.api.event.registry.DynamicRegistries;
|
||||||
import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder;
|
import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder;
|
||||||
import net.fabricmc.fabric.api.event.registry.RegistryAttribute;
|
import net.fabricmc.fabric.api.event.registry.RegistryAttribute;
|
||||||
@@ -27,16 +27,16 @@ import net.minecraft.util.Identifier;
|
|||||||
|
|
||||||
public class MinionRegistries {
|
public class MinionRegistries {
|
||||||
public static final Registry<ValueType<?>> VALUE_TYPES = registry("value_type");
|
public static final Registry<ValueType<?>> VALUE_TYPES = registry("value_type");
|
||||||
public static final Registry<ValueSupplierType<MinionRuntime>> VALUE_SUPPLIER_TYPES = registry("value_supplier_type");
|
public static final Registry<ValueSupplierType<MinionRuntime>> VALUE_SUPPLIER_TYPES = registry("value_supplier");
|
||||||
public static final Registry<ValueConsumerType<MinionRuntime>> VALUE_CONSUMER_TYPES = registry("value_consumer_type");
|
public static final Registry<ValueConsumerType<MinionRuntime>> VALUE_CONSUMER_TYPES = registry("value_consumer");
|
||||||
public static final Registry<InstructionType<MinionRuntime>> INSTRUCTION_TYPES = registry("instruction_type");
|
public static final Registry<InstructionType<MinionRuntime>> INSTRUCTION_TYPES = registry("instruction");
|
||||||
public static final Registry<ValueConverterType<?>> VALUE_CONVERTER_TYPES = registry("value_converter_type");
|
public static final Registry<ValueConverterType<?>> VALUE_CONVERTER_TYPES = registry("value_converter");
|
||||||
|
|
||||||
public static final Registry<SkinProvider> SKIN_PROVIDERS = registry("skin_provider");
|
public static final Registry<SkinProvider> SKIN_PROVIDERS = registry("skin_provider");
|
||||||
public static final Registry<Codec<? extends GuiDisplay>> GUI_DISPLAY_TYPE = registry("gui_display_type");
|
public static final Registry<Codec<? extends GuiDisplay>> GUI_DISPLAY_TYPE = registry("gui_display_type");
|
||||||
public static final Registry<Codec<? extends ConfiguredInstructionListener>> INSTRUCTION_LISTENER_CODECS = registry("instruction_listener_codec");
|
public static final Registry<Codec<? extends ConfiguredInstructionListener>> INSTRUCTION_LISTENER_CODECS = registry("instruction_listener_codec");
|
||||||
public static final Registry<Codec<? extends MinionListener>> MINION_LISTENER_CODECS = registry("minion_listener_codec");
|
public static final Registry<Codec<? extends MinionListener>> MINION_LISTENER_CODECS = registry("minion_listener_codec");
|
||||||
public static final Registry<MapCodec<? extends Clipboard>> CLIPBOARD_TYPES = registry("clipboard_type");
|
public static final Registry<MapCodec<? extends Clipboard>> CLIPBOARD_TYPES = registry("clipboard");
|
||||||
public static final Registry<SpecialAbility> SPECIAL_ABILITIES = registry("special_ability");
|
public static final Registry<SpecialAbility> SPECIAL_ABILITIES = registry("special_ability");
|
||||||
public static final Registry<MinionConfig.Option<?>> MINION_CONFIG_OPTIONS = registry("minion_config_option");
|
public static final Registry<MinionConfig.Option<?>> MINION_CONFIG_OPTIONS = registry("minion_config_option");
|
||||||
public static final Registry<MapCodec<? extends DocsEntry>> DOCS_ENTRY_TYPES = registry("docs_entry_type");
|
public static final Registry<MapCodec<? extends DocsEntry>> DOCS_ENTRY_TYPES = registry("docs_entry_type");
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package io.github.skippyall.minions.registration;
|
package io.github.skippyall.minions.registration;
|
||||||
|
|
||||||
|
import io.github.skippyall.minions.Minions;
|
||||||
import io.github.skippyall.minions.minion.skin.Base64SkinProvider;
|
import io.github.skippyall.minions.minion.skin.Base64SkinProvider;
|
||||||
import io.github.skippyall.minions.minion.skin.NameSkinProvider;
|
import io.github.skippyall.minions.minion.skin.NameSkinProvider;
|
||||||
import io.github.skippyall.minions.minion.skin.SkinProvider;
|
import io.github.skippyall.minions.minion.skin.SkinProvider;
|
||||||
import io.github.skippyall.minions.minion.skin.UUIDSkinProvider;
|
import io.github.skippyall.minions.minion.skin.UUIDSkinProvider;
|
||||||
import io.github.skippyall.minions.Minions;
|
|
||||||
import net.minecraft.registry.Registry;
|
import net.minecraft.registry.Registry;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package io.github.skippyall.minions.registration;
|
package io.github.skippyall.minions.registration;
|
||||||
|
|
||||||
import io.github.skippyall.minions.module.MobSpawningAbility;
|
|
||||||
import io.github.skippyall.minions.Minions;
|
import io.github.skippyall.minions.Minions;
|
||||||
|
import io.github.skippyall.minions.module.MobSpawningAbility;
|
||||||
import io.github.skippyall.minions.module.SpecialAbility;
|
import io.github.skippyall.minions.module.SpecialAbility;
|
||||||
import net.minecraft.registry.Registry;
|
import net.minecraft.registry.Registry;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import net.minecraft.registry.Registry;
|
|||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class ValueConverters {
|
public class ValueConverters {
|
||||||
public static final EqualityConverter.EqualityConverterType EQUALITY_CONVERTER = register("equality_converter", new EqualityConverter.EqualityConverterType());
|
public static final EqualityConverter.EqualityConverterType EQUALITY_CONVERTER = register("equality", new EqualityConverter.EqualityConverterType());
|
||||||
public static final CastConverter.Type CAST_CONVERTER = register("cast_converter", new CastConverter.Type());
|
public static final CastConverter.Type CAST_CONVERTER = register("cast", new CastConverter.Type());
|
||||||
|
|
||||||
private static <T extends ValueConverterType<?>> T register(String name, T type) {
|
private static <T extends ValueConverterType<?>> T register(String name, T type) {
|
||||||
return Registry.register(MinionRegistries.VALUE_CONVERTER_TYPES, Identifier.of(Minions.MOD_ID, name), type);
|
return Registry.register(MinionRegistries.VALUE_CONVERTER_TYPES, Identifier.of(Minions.MOD_ID, name), type);
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package io.github.skippyall.minions.registration;
|
package io.github.skippyall.minions.registration;
|
||||||
|
|
||||||
|
import io.github.skippyall.minions.Minions;
|
||||||
|
import io.github.skippyall.minions.minion.MinionRuntime;
|
||||||
import io.github.skippyall.minions.minion.program.supplier.AnalogInputSupplier;
|
import io.github.skippyall.minions.minion.program.supplier.AnalogInputSupplier;
|
||||||
import io.github.skippyall.minions.program.supplier.FixedValueSupplierType;
|
import io.github.skippyall.minions.program.supplier.FixedValueSupplierType;
|
||||||
import io.github.skippyall.minions.program.supplier.ValueSupplierType;
|
import io.github.skippyall.minions.program.supplier.ValueSupplierType;
|
||||||
import io.github.skippyall.minions.Minions;
|
|
||||||
import io.github.skippyall.minions.minion.MinionRuntime;
|
|
||||||
import net.minecraft.registry.Registry;
|
import net.minecraft.registry.Registry;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
package io.github.skippyall.minions.registration;
|
package io.github.skippyall.minions.registration;
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import io.github.skippyall.minions.program.value.SimpleValueType;
|
|
||||||
import io.github.skippyall.minions.program.value.ValueType;
|
|
||||||
import io.github.skippyall.minions.Minions;
|
import io.github.skippyall.minions.Minions;
|
||||||
import io.github.skippyall.minions.gui.input.ChoiceInput;
|
|
||||||
import io.github.skippyall.minions.gui.input.TextInput;
|
import io.github.skippyall.minions.gui.input.TextInput;
|
||||||
import io.github.skippyall.minions.minion.program.instruction.move.TurnDirection;
|
import io.github.skippyall.minions.minion.program.instruction.move.TurnDirection;
|
||||||
|
import io.github.skippyall.minions.program.value.SimpleValueType;
|
||||||
|
import io.github.skippyall.minions.program.value.ValueType;
|
||||||
import net.minecraft.registry.Registry;
|
import net.minecraft.registry.Registry;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class ValueTypes {
|
public class ValueTypes {
|
||||||
public static ValueType<Long> LONG = register(
|
public static ValueType<Long> LONG = register(
|
||||||
"long",
|
"long",
|
||||||
@@ -18,8 +19,8 @@ public class ValueTypes {
|
|||||||
Codec.LONG,
|
Codec.LONG,
|
||||||
0L,
|
0L,
|
||||||
o -> o instanceof Long l ? l : null,
|
o -> o instanceof Long l ? l : null,
|
||||||
(player, oldValue) -> TextInput.inputLong(
|
(parent, oldValue) -> TextInput.inputLong(
|
||||||
player,
|
parent,
|
||||||
Text.literal("Integer"),
|
Text.literal("Integer"),
|
||||||
String.valueOf(oldValue)
|
String.valueOf(oldValue)
|
||||||
),
|
),
|
||||||
@@ -33,8 +34,8 @@ public class ValueTypes {
|
|||||||
Codec.DOUBLE,
|
Codec.DOUBLE,
|
||||||
0D,
|
0D,
|
||||||
o -> o instanceof Double d ? d : null,
|
o -> o instanceof Double d ? d : null,
|
||||||
(player, oldValue) -> TextInput.inputDouble(
|
(parent, oldValue) -> TextInput.inputDouble(
|
||||||
player,
|
parent,
|
||||||
Text.literal("Number"),
|
Text.literal("Number"),
|
||||||
String.valueOf(oldValue)
|
String.valueOf(oldValue)
|
||||||
),
|
),
|
||||||
@@ -48,7 +49,8 @@ public class ValueTypes {
|
|||||||
Codec.BOOL,
|
Codec.BOOL,
|
||||||
false,
|
false,
|
||||||
o -> o instanceof Boolean b ? b : null,
|
o -> o instanceof Boolean b ? b : null,
|
||||||
ChoiceInput.inputBoolean(Text.literal("")),
|
//TODO Properly implement ChoiceInput
|
||||||
|
(gui, value) -> CompletableFuture.completedFuture(value),//ChoiceInput.inputBoolean(Text.literal("")),
|
||||||
value -> Text.literal(value.toString())
|
value -> Text.literal(value.toString())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -59,8 +61,8 @@ public class ValueTypes {
|
|||||||
Codec.STRING,
|
Codec.STRING,
|
||||||
"",
|
"",
|
||||||
o -> o instanceof String s ? s : null,
|
o -> o instanceof String s ? s : null,
|
||||||
((player, oldValue) -> TextInput.inputString(
|
((parent, oldValue) -> TextInput.inputString(
|
||||||
player,
|
parent,
|
||||||
Text.literal("Text"),
|
Text.literal("Text"),
|
||||||
oldValue)
|
oldValue)
|
||||||
),
|
),
|
||||||
@@ -74,7 +76,8 @@ public class ValueTypes {
|
|||||||
TurnDirection.CODEC,
|
TurnDirection.CODEC,
|
||||||
TurnDirection.RIGHT,
|
TurnDirection.RIGHT,
|
||||||
o -> o instanceof TurnDirection d ? d : null,
|
o -> o instanceof TurnDirection d ? d : null,
|
||||||
ChoiceInput.createDialogOpener(TurnDirection.values()),
|
//TODO Properly implement ChoiceInput
|
||||||
|
(parent, oldValue) -> CompletableFuture.completedFuture(oldValue), // ChoiceInput.createDialogOpener(TurnDirection.values()),
|
||||||
value -> Text.literal(value.name)
|
value -> Text.literal(value.name)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
- Module:
|
|
||||||
- Bewegungsmodul <--
|
|
||||||
- Angriffsmodul <--
|
|
||||||
- Abbaumodul <--
|
|
||||||
- Platziermodul / Verwendungsmodul <--
|
|
||||||
- Werfmodul
|
|
||||||
- Inventarmanagementmodul <--
|
|
||||||
- Inventaropenmodul
|
|
||||||
|
|
||||||
- Detektoren:
|
|
||||||
- Blockdetektor <--
|
|
||||||
- Entitydetektor <
|
|
||||||
- Dimensiondetektor
|
|
||||||
- Positiondetektor
|
|
||||||
- Inventardetektor
|
|
||||||
|
|
||||||
- Programmieren:
|
|
||||||
- Variablen
|
|
||||||
- (Listen)
|
|
||||||
- Warten
|
|
||||||
- Wiederholen
|
|
||||||
- Wiederhole bis/während
|
|
||||||
- Wiederhole x mal/(für jedes Element)
|
|
||||||
- Bedingung
|
|
||||||
|
|
||||||
- VariableTypen:
|
|
||||||
- Integer
|
|
||||||
- String
|
|
||||||
- Position
|
|
||||||
- Block
|
|
||||||
- BlockType
|
|
||||||
- (NBT)
|
|
||||||
- (World)
|
|
||||||
- (Chunk)
|
|
||||||
- Inventory
|
|
||||||
+37
-17
@@ -9,6 +9,7 @@
|
|||||||
"minions.gui.confirm": "Confirm",
|
"minions.gui.confirm": "Confirm",
|
||||||
"minions.gui.abort": "Abort",
|
"minions.gui.abort": "Abort",
|
||||||
"minions.gui.back": "Back",
|
"minions.gui.back": "Back",
|
||||||
|
"minions.gui.not_set": "Not set",
|
||||||
|
|
||||||
"minions.gui.look.skin.name": "Name",
|
"minions.gui.look.skin.name": "Name",
|
||||||
"minions.gui.look.skin.name.title": "Enter a player name",
|
"minions.gui.look.skin.name.title": "Enter a player name",
|
||||||
@@ -35,13 +36,24 @@
|
|||||||
"minions.gui.instruction.configure.copy.description": "Click here and then use a Minion Trigger Block to bind it",
|
"minions.gui.instruction.configure.copy.description": "Click here and then use a Minion Trigger Block to bind it",
|
||||||
"minions.gui.instruction.run": "Run",
|
"minions.gui.instruction.run": "Run",
|
||||||
"minions.gui.instruction.stop": "Stop",
|
"minions.gui.instruction.stop": "Stop",
|
||||||
"minions.gui.instruction.argument.configure.type": "Type: %s",
|
"minions.gui.instruction.argument.title": "Argument for %s (%s)",
|
||||||
"minions.gui.instruction.argument.configure.type.unset": "Unset",
|
"minions.gui.instruction.argument.configure.type": "Argument Type",
|
||||||
|
"minions.gui.instruction.argument.configure.type.title": "Select an Argument Type",
|
||||||
|
"minions.gui.instruction.argument.configure.data": "Argument Data",
|
||||||
|
"minions.gui.instruction.argument.configure.data.title": "Configure Argument Data",
|
||||||
"minions.gui.instruction.parameter": "%s: %s",
|
"minions.gui.instruction.parameter": "%s: %s",
|
||||||
"minions.gui.instruction.argument": "Argument: %s",
|
"minions.gui.instruction.argument": "Argument: %s",
|
||||||
|
|
||||||
"minions.gui.instruction.check.argument_not_set": "Argument %s is not set",
|
"minions.gui.instruction.check.argument_not_set": "Argument %s is not set",
|
||||||
|
|
||||||
|
"minions.gui.instruction.converters": "Converters",
|
||||||
|
"minions.gui.instruction.converters.cast": "Cast from %s to %s",
|
||||||
|
"minions.gui.instruction.converter.title": "Configure Converter",
|
||||||
|
"minions.gui.instruction.converter.type.title": "Select a Converter Type",
|
||||||
|
"minions.gui.instruction.converter.data": "Converter Data",
|
||||||
|
|
||||||
|
"minions.converter.list.passing_error": "Error while passing previous value to converter #%s: %s",
|
||||||
|
|
||||||
"minions.command.input.int.fail": "Not an integer",
|
"minions.command.input.int.fail": "Not an integer",
|
||||||
"minions.command.input.float.fail": "Not a number",
|
"minions.command.input.float.fail": "Not a number",
|
||||||
"minions.command.action.details": "Set how to %s",
|
"minions.command.action.details": "Set how to %s",
|
||||||
@@ -60,25 +72,33 @@
|
|||||||
"minions.reference.instruction.tooltip": "Linked to instruction %s in %s",
|
"minions.reference.instruction.tooltip": "Linked to instruction %s in %s",
|
||||||
"minions.reference.block.tooltip": "Linked to block at %s",
|
"minions.reference.block.tooltip": "Linked to block at %s",
|
||||||
|
|
||||||
"instruction_type.minions.walk": "Walk",
|
"instruction.minions.walk": "Walk",
|
||||||
"instruction_type.minions.walk.description": "Walk forward a specified amount of blocks",
|
"instruction.minions.walk.description": "Walk forward a specified amount of blocks",
|
||||||
"instruction_type.minions.turn": "Turn",
|
"instruction.minions.turn": "Turn",
|
||||||
"instruction_type.minions.turn.description": "Turn the head by specific angle",
|
"instruction.minions.turn.description": "Turn the head by specific angle",
|
||||||
"instruction_type.minions.attack": "Attack",
|
"instruction.minions.attack": "Attack",
|
||||||
"instruction_type.minions.attack.description": "Attack and mine blocks\n Test",
|
"instruction.minions.attack.description": "Attack and mine blocks\n Test",
|
||||||
"instruction_type.minions.use": "Use",
|
"instruction.minions.use": "Use",
|
||||||
"instruction_type.minions.use.description": "Use and place blocks",
|
"instruction.minions.use.description": "Use and place blocks",
|
||||||
|
"instruction.minions.swap_item": "Swap Items",
|
||||||
|
|
||||||
"value_type.minions.integer": "Integer",
|
"value_type.minions.long": "Integer",
|
||||||
"value_type.minions.float": "Decimal",
|
"value_type.minions.double": "Decimal",
|
||||||
|
"value_type.minions.boolean": "Boolean",
|
||||||
"value_type.minions.string": "Text",
|
"value_type.minions.string": "Text",
|
||||||
"value_type.minions.turn_direction": "Turn Direction",
|
"value_type.minions.turn_direction": "Turn Direction",
|
||||||
|
|
||||||
"value_supplier_type.minions.fixed": "Fixed Value",
|
"value_supplier.minions.fixed": "Fixed Value",
|
||||||
"value_supplier_type.minions.fixed.display": "Fixed Value: %s",
|
"value_supplier.minions.analog_input": "Analog Input",
|
||||||
"value_supplier_type.minions.analog_input": "Analog Input",
|
"value_supplier.minions.analog_input.display": "Analog Input at %s in %s",
|
||||||
"value_supplier_type.minions.analog_input.display": "Analog Input at %s in %s",
|
"value_supplier.minions.analog_input.config.click_with_reference": "Click here with a position clipboard",
|
||||||
"value_supplier_type.minions.analog_input.config.click_with_reference": "Click here with a position clipboard",
|
|
||||||
|
"value_converter.minions.cast.display": "Cast from %s to %s",
|
||||||
|
"value_converter.minions.cast.cast_failed": "Cast of value %s to %s failed",
|
||||||
|
"value_converter.minions.equality.display": "Equal to %s",
|
||||||
|
|
||||||
|
"value_converter.minions.equality": "Equality",
|
||||||
|
"value_converter.minions.cast": "Cast",
|
||||||
|
|
||||||
"item.minions.attack_module": "Attack Module",
|
"item.minions.attack_module": "Attack Module",
|
||||||
"item.minions.interact_module": "Interact Module",
|
"item.minions.interact_module": "Interact Module",
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user