mirror of
https://github.com/TeamMidnightDust/PictureSign.git
synced 2025-12-16 14:15:10 +01:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
faaff873da | ||
|
|
69cf564ae7 | ||
|
|
b3249b9664 |
@@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '0.8-SNAPSHOT'
|
id 'fabric-loom' version '0.11-SNAPSHOT'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ archivesBaseName = project.archives_base_name
|
|||||||
version = project.mod_version
|
version = project.mod_version
|
||||||
group = project.maven_group
|
group = project.maven_group
|
||||||
|
|
||||||
minecraft {
|
loom {
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|||||||
@@ -5,15 +5,15 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
# check these on https://fabricmc.net/use
|
# check these on https://fabricmc.net/use
|
||||||
minecraft_version=1.17.1
|
minecraft_version=1.17.1
|
||||||
yarn_mappings=1.17.1+build.61
|
yarn_mappings=1.17.1+build.61
|
||||||
loader_version=0.11.7
|
loader_version=0.14.6
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.1.0
|
mod_version = 1.4.0
|
||||||
maven_group = eu.midnightdust
|
maven_group = eu.midnightdust
|
||||||
archives_base_name = picturesign
|
archives_base_name = picturesign
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||||
fabric_version=0.40.1+1.17
|
fabric_version=0.40.1+1.17
|
||||||
midnightlib_version=0.2.6
|
midnightlib_version=0.4.0
|
||||||
iris_version=mc1.17.1-1.1.2
|
iris_version=1.17.x-v1.2.2
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
269
gradlew
vendored
269
gradlew
vendored
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2015 the original author or authors.
|
# Copyright © 2015-2021 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -17,67 +17,101 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
#
|
||||||
## Gradle start up script for UN*X
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
##
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
PRG="$0"
|
app_path=$0
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
# Need this for daisy-chained symlinks.
|
||||||
ls=`ls -ld "$PRG"`
|
while
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
[ -h "$app_path" ]
|
||||||
PRG="$link"
|
do
|
||||||
else
|
ls=$( ls -ld "$app_path" )
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
link=${ls#*' -> '}
|
||||||
fi
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
APP_NAME="Gradle"
|
||||||
APP_BASE_NAME=`basename "$0"`
|
APP_BASE_NAME=${0##*/}
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# 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"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD=maximum
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "`uname`" in
|
case "$( uname )" in #(
|
||||||
CYGWIN* )
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
cygwin=true
|
Darwin* ) darwin=true ;; #(
|
||||||
;;
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
Darwin* )
|
NONSTOP* ) nonstop=true ;;
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
@@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
else
|
else
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
@@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD="java"
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
@@ -106,80 +140,95 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
case $MAX_FD in #(
|
||||||
if [ $? -eq 0 ] ; then
|
max*)
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
warn "Could not query maximum file descriptor limit"
|
||||||
fi
|
esac
|
||||||
ulimit -n $MAX_FD
|
case $MAX_FD in #(
|
||||||
if [ $? -ne 0 ] ; then
|
'' | soft) :;; #(
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
*)
|
||||||
fi
|
ulimit -n "$MAX_FD" ||
|
||||||
else
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Darwin, add options to specify how the application appears in the dock
|
|
||||||
if $darwin; then
|
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
||||||
SEP=""
|
|
||||||
for dir in $ROOTDIRSRAW ; do
|
|
||||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
||||||
SEP="|"
|
|
||||||
done
|
|
||||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
||||||
# Add a user-defined pattern to the cygpath arguments
|
|
||||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
||||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
||||||
fi
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
i=0
|
|
||||||
for arg in "$@" ; do
|
|
||||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
||||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
||||||
|
|
||||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
||||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
||||||
else
|
|
||||||
eval `echo args$i`="\"$arg\""
|
|
||||||
fi
|
|
||||||
i=`expr $i + 1`
|
|
||||||
done
|
|
||||||
case $i in
|
|
||||||
0) set -- ;;
|
|
||||||
1) set -- "$args0" ;;
|
|
||||||
2) set -- "$args0" "$args1" ;;
|
|
||||||
3) set -- "$args0" "$args1" "$args2" ;;
|
|
||||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
||||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
||||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
||||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
||||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
||||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Escape application args
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
save () {
|
# * args from the command line
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
# * the main class name
|
||||||
echo " "
|
# * -classpath
|
||||||
}
|
# * -D...appname settings
|
||||||
APP_ARGS=`save "$@"`
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# Collect all arguments for the java command;
|
||||||
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
|
# double quotes to make sure that they get re-expanded; and
|
||||||
|
# * put everything else in single quotes, so that it's not re-expanded.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|||||||
@@ -2,13 +2,72 @@ package eu.midnightdust.picturesign;
|
|||||||
|
|
||||||
import eu.midnightdust.picturesign.config.PictureSignConfig;
|
import eu.midnightdust.picturesign.config.PictureSignConfig;
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||||
|
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||||
|
import net.minecraft.block.entity.SignBlockEntity;
|
||||||
|
import net.minecraft.client.gui.screen.ingame.SignEditScreen;
|
||||||
|
import net.minecraft.client.option.KeyBinding;
|
||||||
|
import net.minecraft.client.util.InputUtil;
|
||||||
|
import net.minecraft.util.hit.HitResult;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
public class PictureSignClient implements ClientModInitializer {
|
public class PictureSignClient implements ClientModInitializer {
|
||||||
public static Logger LOGGER = LogManager.getLogger("PictureSign");
|
public static Logger LOGGER = LogManager.getLogger("PictureSign");
|
||||||
|
public static String[] clipboard = new String[4];
|
||||||
|
public static final KeyBinding BINDING_EDIT_SIGN = new KeyBinding("key.picturesign.edit_sign",
|
||||||
|
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_C, "key.categories.picturesign");
|
||||||
|
public static final KeyBinding BINDING_COPY_SIGN = new KeyBinding("key.picturesign.copy_sign",
|
||||||
|
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_U, "key.categories.picturesign");
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
PictureSignConfig.init("picturesign", PictureSignConfig.class);
|
PictureSignConfig.init("picturesign", PictureSignConfig.class);
|
||||||
|
|
||||||
|
KeyBindingHelper.registerKeyBinding(BINDING_COPY_SIGN);
|
||||||
|
|
||||||
|
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||||
|
if (!PictureSignClient.BINDING_COPY_SIGN.isPressed()) return;
|
||||||
|
PictureSignClient.BINDING_COPY_SIGN.setPressed(false);
|
||||||
|
if (client.player == null || client.crosshairTarget == null || client.crosshairTarget.getType() != HitResult.Type.BLOCK) return;
|
||||||
|
if (client.crosshairTarget.getType() == HitResult.Type.BLOCK && client.world.getBlockState(new BlockPos(client.crosshairTarget.getPos())).hasBlockEntity()) {
|
||||||
|
if (client.world.getBlockEntity(new BlockPos(client.crosshairTarget.getPos())) instanceof SignBlockEntity) {
|
||||||
|
SignBlockEntity sign = (SignBlockEntity) client.world.getBlockEntity(new BlockPos(client.crosshairTarget.getPos()));
|
||||||
|
clipboard[0] = sign.getTextOnRow(0, false).asString();
|
||||||
|
clipboard[1] = sign.getTextOnRow(1, false).asString();
|
||||||
|
clipboard[2] = sign.getTextOnRow(2, false).asString();
|
||||||
|
clipboard[3] = sign.getTextOnRow(3, false).asString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (PictureSignConfig.debug) {
|
||||||
|
KeyBindingHelper.registerKeyBinding(BINDING_EDIT_SIGN);
|
||||||
|
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||||
|
if (!PictureSignClient.BINDING_EDIT_SIGN.isPressed()) return;
|
||||||
|
PictureSignClient.BINDING_EDIT_SIGN.setPressed(false);
|
||||||
|
if (client.player == null || client.crosshairTarget == null || client.crosshairTarget.getType() != HitResult.Type.BLOCK) return;
|
||||||
|
if (client.crosshairTarget.getType() == HitResult.Type.BLOCK && client.world.getBlockState(new BlockPos(client.crosshairTarget.getPos())).hasBlockEntity()) {
|
||||||
|
if (client.world.getBlockEntity(new BlockPos(client.crosshairTarget.getPos())) instanceof SignBlockEntity) {
|
||||||
|
BlockPos pos = new BlockPos(client.crosshairTarget.getPos());
|
||||||
|
SignBlockEntity sign = (SignBlockEntity) client.world.getBlockEntity(pos);
|
||||||
|
sign.setEditable(true);
|
||||||
|
sign.setEditor(client.player.getUuid());
|
||||||
|
sign.toUpdatePacket();
|
||||||
|
sign.markDirty();
|
||||||
|
client.world.updateListeners(pos, sign.getCachedState(), sign.getCachedState(), 3);
|
||||||
|
client.setScreen(new SignEditScreen(sign,false));
|
||||||
|
// clipboard[0] = sign.getTextOnRow(0, false).asString();
|
||||||
|
// clipboard[1] = sign.getTextOnRow(1, false).asString();
|
||||||
|
// clipboard[2] = sign.getTextOnRow(2, false).asString();
|
||||||
|
// clipboard[3] = sign.getTextOnRow(3, false).asString();
|
||||||
|
// Block signBlock = sign.getCachedState().getBlock();
|
||||||
|
// client.interactionManager.breakBlock(pos);
|
||||||
|
// client.player.setStackInHand(client.player.preferredHand, new ItemStack(signBlock.asItem()));
|
||||||
|
// client.interactionManager.interactBlock(client.player, client.world, client.player.preferredHand, new BlockHitResult(new Vec3d(pos.getX(), pos.getY(), pos.getZ()), Direction.DOWN, pos,false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,13 @@ import eu.midnightdust.lib.config.MidnightConfig;
|
|||||||
|
|
||||||
public class PictureSignConfig extends MidnightConfig {
|
public class PictureSignConfig extends MidnightConfig {
|
||||||
@Entry public static boolean enabled = true;
|
@Entry public static boolean enabled = true;
|
||||||
|
@Entry public static boolean translucency = false;
|
||||||
|
@Entry public static boolean helperUi = true;
|
||||||
|
@Entry public static boolean exceedVanillaLineLength = false;
|
||||||
@Entry public static boolean debug = false;
|
@Entry public static boolean debug = false;
|
||||||
@Entry(min = 1, max = 10) public static int maxThreads = 4;
|
@Entry(min = 1, max = 10) public static int maxThreads = 4;
|
||||||
@Entry(min = 0, max = 1024) public static int signRenderDistance = 64;
|
@Entry(min = 0, max = 4096) public static int signRenderDistance = 64;
|
||||||
|
@Entry public static boolean safeMode = true;
|
||||||
|
@Comment public static Comment ebeWarning;
|
||||||
|
@Comment public static Comment ebeWarning2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,4 +33,9 @@ public abstract class MixinSignBlockEntityRenderer implements BlockEntityRendere
|
|||||||
public int getRenderDistance() {
|
public int getRenderDistance() {
|
||||||
return PictureSignConfig.signRenderDistance;
|
return PictureSignConfig.signRenderDistance;
|
||||||
}
|
}
|
||||||
|
@Unique
|
||||||
|
@Override
|
||||||
|
public boolean rendersOutsideBoundingBox(SignBlockEntity sign) {
|
||||||
|
return PictureSignConfig.enabled && sign.getTextOnRow(0, false).getString().matches("(!PS:.*)");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package eu.midnightdust.picturesign.mixin;
|
||||||
|
|
||||||
|
import eu.midnightdust.lib.util.screen.TexturedOverlayButtonWidget;
|
||||||
|
import eu.midnightdust.picturesign.PictureSignClient;
|
||||||
|
import eu.midnightdust.picturesign.config.PictureSignConfig;
|
||||||
|
import eu.midnightdust.picturesign.screen.PictureSignHelperScreen;
|
||||||
|
import net.minecraft.block.entity.SignBlockEntity;
|
||||||
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import net.minecraft.client.gui.screen.ingame.SignEditScreen;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Mixin(SignEditScreen.class)
|
||||||
|
public abstract class MixinSignEditScreen extends Screen {
|
||||||
|
private static final Identifier PICTURESIGN_ICON_TEXTURE = new Identifier("picturesign","textures/gui/picturesign_button.png");
|
||||||
|
private static final Identifier CLIPBOARD_ICON_TEXTURE = new Identifier("picturesign","textures/gui/clipboard_button.png");
|
||||||
|
private static final Identifier TRASHBIN_ICON_TEXTURE = new Identifier("picturesign","textures/gui/trashbin_button.png");
|
||||||
|
@Shadow @Final private SignBlockEntity sign;
|
||||||
|
|
||||||
|
@Shadow @Final private String[] text;
|
||||||
|
|
||||||
|
protected MixinSignEditScreen(Text title) {
|
||||||
|
super(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(at = @At("TAIL"),method = "init")
|
||||||
|
private void picturesign$init(CallbackInfo ci) {
|
||||||
|
if (PictureSignClient.clipboard != null && PictureSignClient.clipboard[0] != null)
|
||||||
|
this.addDrawableChild(new TexturedOverlayButtonWidget(this.width - 84, this.height - 40, 20, 20, 0, 0, 20, CLIPBOARD_ICON_TEXTURE, 32, 64, (buttonWidget) -> {
|
||||||
|
sign.setTextOnRow(0, Text.of(PictureSignClient.clipboard[0]));
|
||||||
|
sign.setTextOnRow(1, Text.of(PictureSignClient.clipboard[1]));
|
||||||
|
sign.setTextOnRow(2, Text.of(PictureSignClient.clipboard[2]));
|
||||||
|
sign.setTextOnRow(3, Text.of(PictureSignClient.clipboard[3]));
|
||||||
|
text[0] = PictureSignClient.clipboard[0];
|
||||||
|
text[1] = PictureSignClient.clipboard[1];
|
||||||
|
text[2] = PictureSignClient.clipboard[2];
|
||||||
|
text[3] = PictureSignClient.clipboard[3];
|
||||||
|
}, Text.of("")));
|
||||||
|
if (PictureSignConfig.helperUi)
|
||||||
|
this.addDrawableChild(new TexturedOverlayButtonWidget(this.width - 62, this.height - 40, 20, 20, 0, 0, 20, TRASHBIN_ICON_TEXTURE, 32, 64, (buttonWidget) -> {
|
||||||
|
sign.setTextOnRow(0, Text.of(""));
|
||||||
|
sign.setTextOnRow(1, Text.of(""));
|
||||||
|
sign.setTextOnRow(2, Text.of(""));
|
||||||
|
sign.setTextOnRow(3, Text.of(""));
|
||||||
|
text[0] = "";
|
||||||
|
text[1] = "";
|
||||||
|
text[2] = "";
|
||||||
|
text[3] = "";
|
||||||
|
}, Text.of("")));
|
||||||
|
if (PictureSignConfig.helperUi)
|
||||||
|
this.addDrawableChild(new TexturedOverlayButtonWidget(this.width - 40, this.height - 40, 20, 20, 0, 0, 20, PICTURESIGN_ICON_TEXTURE, 32, 64, (buttonWidget) -> {
|
||||||
|
sign.setEditable(true);
|
||||||
|
Objects.requireNonNull(client).setScreen(new PictureSignHelperScreen(this.sign,false));
|
||||||
|
}, Text.of("")));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,16 +2,17 @@ package eu.midnightdust.picturesign.render;
|
|||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import eu.midnightdust.picturesign.PictureDownloader;
|
import eu.midnightdust.picturesign.PictureDownloader;
|
||||||
import net.coderbot.iris.Iris;
|
import eu.midnightdust.picturesign.config.PictureSignConfig;
|
||||||
|
import eu.midnightdust.picturesign.util.PictureURLUtils;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
import net.irisshaders.iris.api.v0.IrisApi;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.entity.SignBlockEntity;
|
import net.minecraft.block.entity.SignBlockEntity;
|
||||||
import net.minecraft.client.render.*;
|
import net.minecraft.client.render.*;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.state.property.Properties;
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.*;
|
||||||
import net.minecraft.util.math.Matrix4f;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.util.math.Quaternion;
|
|
||||||
import net.minecraft.util.math.Vec3f;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -19,16 +20,22 @@ import java.util.List;
|
|||||||
public class PictureSignRenderer {
|
public class PictureSignRenderer {
|
||||||
|
|
||||||
public void render(SignBlockEntity signBlockEntity, MatrixStack matrixStack, int light, int overlay) {
|
public void render(SignBlockEntity signBlockEntity, MatrixStack matrixStack, int light, int overlay) {
|
||||||
String text = signBlockEntity.getTextOnRow(0, false).getString() +
|
String url = PictureURLUtils.getLink(signBlockEntity);
|
||||||
signBlockEntity.getTextOnRow(1, false).getString() +
|
if (!url.startsWith("https://") && !url.startsWith("http://")) {
|
||||||
signBlockEntity.getTextOnRow(2, false).getString();
|
|
||||||
String url = text.replaceAll("!PS:", "").replaceAll(" ","");
|
|
||||||
if (url.contains("imgur:")) url = url.replace("imgur:", "https://i.imgur.com/");
|
|
||||||
if (url.contains("imgbb:")) url = url.replace("imgbb:", "https://i.ibb.co/");
|
|
||||||
if (!url.contains("https://") && !url.contains("http://")) {
|
|
||||||
url = "https://" + url;
|
url = "https://" + url;
|
||||||
}
|
}
|
||||||
if (!url.contains(".png") && !url.contains(".jpg") && !url.contains(".jpeg")) return;
|
if (!url.contains(".png") && !url.contains(".jpg") && !url.contains(".jpeg")) return;
|
||||||
|
if (PictureSignConfig.safeMode && !url.startsWith("https://i.imgur.com/") && !url.startsWith("https://i.ibb.co/")
|
||||||
|
&& !url.startsWith("https://pictshare.net/") && !url.startsWith("https://iili.io/"))
|
||||||
|
return;
|
||||||
|
World world = signBlockEntity.getWorld();
|
||||||
|
BlockPos pos = signBlockEntity.getPos();
|
||||||
|
if (world != null && (world.getBlockState(pos.down()).getBlock().equals(Blocks.REDSTONE_TORCH) || world.getBlockState(pos.down()).getBlock().equals(Blocks.REDSTONE_WALL_TORCH))
|
||||||
|
&& world.getBlockState(pos.down()).get(Properties.LIT).equals(false)) return;
|
||||||
|
if (world != null && (world.getBlockState(pos.up()).getBlock().equals(Blocks.REDSTONE_TORCH) || world.getBlockState(pos.up()).getBlock().equals(Blocks.REDSTONE_WALL_TORCH))
|
||||||
|
&& world.getBlockState(pos.up()).get(Properties.LIT).equals(false)) return;
|
||||||
|
|
||||||
|
|
||||||
String lastLine = signBlockEntity.getTextOnRow(3, false).getString();
|
String lastLine = signBlockEntity.getTextOnRow(3, false).getString();
|
||||||
|
|
||||||
if (!lastLine.matches("(.*\\d:.*\\d:.*\\d:.*\\d:.*\\d)")) return;
|
if (!lastLine.matches("(.*\\d:.*\\d:.*\\d:.*\\d:.*\\d)")) return;
|
||||||
@@ -87,12 +94,12 @@ public class PictureSignRenderer {
|
|||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
BufferBuilder buffer = tessellator.getBuffer();
|
BufferBuilder buffer = tessellator.getBuffer();
|
||||||
|
|
||||||
matrixStack.push();
|
|
||||||
|
|
||||||
int l;
|
int l;
|
||||||
if (FabricLoader.getInstance().isModLoaded("iris") && Iris.getIrisConfig().areShadersEnabled() && Iris.getCurrentPack().isPresent()) {
|
if (FabricLoader.getInstance().isModLoaded("iris") && IrisApi.getInstance().isShaderPackInUse()) {
|
||||||
RenderSystem.setShader(GameRenderer::getRenderTypeCutoutShader);
|
RenderSystem.setShader(GameRenderer::getRenderTypeCutoutShader);
|
||||||
l = 230;
|
l = 15728880;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
RenderSystem.setShader(GameRenderer::getPositionColorTexLightmapShader);
|
RenderSystem.setShader(GameRenderer::getPositionColorTexLightmapShader);
|
||||||
@@ -100,10 +107,12 @@ public class PictureSignRenderer {
|
|||||||
}
|
}
|
||||||
RenderSystem.setShaderTexture(0, data.identifier);
|
RenderSystem.setShaderTexture(0, data.identifier);
|
||||||
|
|
||||||
RenderSystem.disableBlend();
|
if (PictureSignConfig.translucency) RenderSystem.enableBlend();
|
||||||
|
else RenderSystem.disableBlend();
|
||||||
RenderSystem.enableDepthTest();
|
RenderSystem.enableDepthTest();
|
||||||
RenderSystem.depthMask(true);
|
RenderSystem.depthMask(true);
|
||||||
|
|
||||||
|
matrixStack.push();
|
||||||
matrixStack.translate(xOffset + x, 0.00F + y, zOffset + z);
|
matrixStack.translate(xOffset + x, 0.00F + y, zOffset + z);
|
||||||
matrixStack.multiply(yRotation);
|
matrixStack.multiply(yRotation);
|
||||||
|
|
||||||
@@ -124,6 +133,7 @@ public class PictureSignRenderer {
|
|||||||
|
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
matrixStack.pop();
|
matrixStack.pop();
|
||||||
|
RenderSystem.disableBlend();
|
||||||
|
|
||||||
RenderSystem.disableDepthTest();
|
RenderSystem.disableDepthTest();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,305 @@
|
|||||||
|
package eu.midnightdust.picturesign.screen;
|
||||||
|
|
||||||
|
import eu.midnightdust.lib.util.MidnightColorUtil;
|
||||||
|
import eu.midnightdust.lib.util.screen.TexturedOverlayButtonWidget;
|
||||||
|
import eu.midnightdust.picturesign.PictureSignClient;
|
||||||
|
import eu.midnightdust.picturesign.config.PictureSignConfig;
|
||||||
|
import eu.midnightdust.picturesign.util.PictureURLUtils;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.SignBlock;
|
||||||
|
import net.minecraft.block.entity.SignBlockEntity;
|
||||||
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import net.minecraft.client.gui.screen.ScreenTexts;
|
||||||
|
import net.minecraft.client.gui.screen.ingame.SignEditScreen;
|
||||||
|
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||||
|
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||||
|
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||||
|
import net.minecraft.client.render.*;
|
||||||
|
import net.minecraft.client.render.block.entity.SignBlockEntityRenderer;
|
||||||
|
import net.minecraft.client.util.SpriteIdentifier;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.math.Matrix4f;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
public class PictureSignHelperScreen extends Screen {
|
||||||
|
private static final Identifier TEXTSIGN_ICON_TEXTURE = new Identifier("picturesign","textures/gui/textsign_button.png");
|
||||||
|
private static final Identifier CLIPBOARD_ICON_TEXTURE = new Identifier("picturesign","textures/gui/clipboard_button.png");
|
||||||
|
private static final Identifier TRASHBIN_ICON_TEXTURE = new Identifier("picturesign","textures/gui/trashbin_button.png");
|
||||||
|
private final SignBlockEntity sign;
|
||||||
|
private SignBlockEntityRenderer.SignModel model;
|
||||||
|
private String[] text;
|
||||||
|
|
||||||
|
public PictureSignHelperScreen(SignBlockEntity sign, boolean filtered) {
|
||||||
|
super(new TranslatableText("sign.edit"));
|
||||||
|
this.text = IntStream.range(0, 4).mapToObj((row) ->
|
||||||
|
sign.getTextOnRow(row, filtered)).map(Text::getString).toArray(String[]::new);
|
||||||
|
this.sign = sign;
|
||||||
|
}
|
||||||
|
protected void init() {
|
||||||
|
super.init();
|
||||||
|
sign.setEditable(false);
|
||||||
|
if (!sign.getTextOnRow(3,false).asString().matches("(.*\\d:.*\\d:.*\\d:.*\\d:.*\\d)")) sign.setTextOnRow(3, Text.of("1:1:0:0:0"));
|
||||||
|
if (!sign.getTextOnRow(0, false).asString().startsWith("!PS:")) sign.setTextOnRow(0, Text.of("!PS:"));
|
||||||
|
text = IntStream.range(0, 4).mapToObj((row) ->
|
||||||
|
sign.getTextOnRow(row, false)).map(Text::getString).toArray(String[]::new);
|
||||||
|
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 4 + 120, 200, 20, ScreenTexts.DONE, (button) -> {
|
||||||
|
this.finishEditing();
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (PictureSignClient.clipboard != null && PictureSignClient.clipboard[0] != null)
|
||||||
|
this.addDrawableChild(new TexturedOverlayButtonWidget(this.width - 84, this.height - 40, 20, 20, 0, 0, 20, CLIPBOARD_ICON_TEXTURE, 32, 64, (buttonWidget) -> {
|
||||||
|
sign.setTextOnRow(0, Text.of(PictureSignClient.clipboard[0]));
|
||||||
|
sign.setTextOnRow(1, Text.of(PictureSignClient.clipboard[1]));
|
||||||
|
sign.setTextOnRow(2, Text.of(PictureSignClient.clipboard[2]));
|
||||||
|
sign.setTextOnRow(3, Text.of(PictureSignClient.clipboard[3]));
|
||||||
|
text[0] = PictureSignClient.clipboard[0];
|
||||||
|
text[1] = PictureSignClient.clipboard[1];
|
||||||
|
text[2] = PictureSignClient.clipboard[2];
|
||||||
|
text[3] = PictureSignClient.clipboard[3];
|
||||||
|
assert client != null;
|
||||||
|
client.setScreen(this);
|
||||||
|
}, Text.of("")));
|
||||||
|
if (PictureSignConfig.helperUi)
|
||||||
|
this.addDrawableChild(new TexturedOverlayButtonWidget(this.width - 62, this.height - 40, 20, 20, 0, 0, 20, TRASHBIN_ICON_TEXTURE, 32, 64, (buttonWidget) -> {
|
||||||
|
sign.setTextOnRow(0, Text.of(""));
|
||||||
|
sign.setTextOnRow(1, Text.of(""));
|
||||||
|
sign.setTextOnRow(2, Text.of(""));
|
||||||
|
sign.setTextOnRow(3, Text.of(""));
|
||||||
|
text[0] = "";
|
||||||
|
text[1] = "";
|
||||||
|
text[2] = "";
|
||||||
|
text[3] = "";
|
||||||
|
assert client != null;
|
||||||
|
client.setScreen(this);
|
||||||
|
}, Text.of("")));
|
||||||
|
this.addDrawableChild(new TexturedOverlayButtonWidget(this.width - 40, this.height - 40, 20, 20, 0, 0, 20, TEXTSIGN_ICON_TEXTURE, 32, 64, (buttonWidget) -> {
|
||||||
|
sign.setEditable(true);
|
||||||
|
Objects.requireNonNull(client).setScreen(new SignEditScreen(this.sign,false));
|
||||||
|
}, Text.of("")));
|
||||||
|
TextFieldWidget linkWidget = new TextFieldWidget(textRenderer,this.width / 2 - 175,this.height / 5 + 13,210,40, Text.of("url"));
|
||||||
|
linkWidget.setMaxLength(90);
|
||||||
|
linkWidget.setText(PictureURLUtils.getLink(sign));
|
||||||
|
linkWidget.setChangedListener(s -> {
|
||||||
|
String[] lines = breakLink(PictureURLUtils.shortenLink(s));
|
||||||
|
sign.setTextOnRow(0, Text.of(lines[0]));
|
||||||
|
sign.setTextOnRow(1, Text.of(lines[1]));
|
||||||
|
sign.setTextOnRow(2, Text.of(lines[2]));
|
||||||
|
|
||||||
|
text = IntStream.range(0, 4).mapToObj((row) ->
|
||||||
|
sign.getTextOnRow(row, false)).map(Text::getString).toArray(String[]::new);
|
||||||
|
});
|
||||||
|
this.addDrawableChild(linkWidget);
|
||||||
|
String[] initialDimensions = sign.getTextOnRow(3, false).asString().split(":");
|
||||||
|
TextFieldWidget widthWidget = new TextFieldWidget(textRenderer,this.width / 2 - 175,this.height / 5 + 70,30,20, Text.of("width"));
|
||||||
|
widthWidget.setText(initialDimensions[0]);
|
||||||
|
widthWidget.setChangedListener(s -> {
|
||||||
|
String[] dimensions = new String[5];
|
||||||
|
for (int i = 0; i < dimensions.length; ++i){
|
||||||
|
if (sign.getTextOnRow(3, false).asString().split(":").length > i)
|
||||||
|
dimensions[i] = sign.getTextOnRow(3, false).asString().split(":")[i];
|
||||||
|
}
|
||||||
|
dimensions[0] = s;
|
||||||
|
StringBuilder mergedDimensions = new StringBuilder();
|
||||||
|
for (int i = 0; i < 5; ++i) {
|
||||||
|
if (dimensions[i] == null) dimensions[i] = "";
|
||||||
|
mergedDimensions.append(dimensions[i]);
|
||||||
|
if (i < 4)mergedDimensions.append(":");
|
||||||
|
}
|
||||||
|
sign.setTextOnRow(3, Text.of(String.valueOf(mergedDimensions)));
|
||||||
|
text = IntStream.range(0, 4).mapToObj((row) ->
|
||||||
|
sign.getTextOnRow(row, false)).map(Text::getString).toArray(String[]::new);
|
||||||
|
});
|
||||||
|
this.addDrawableChild(widthWidget);
|
||||||
|
TextFieldWidget heightWidget = new TextFieldWidget(textRenderer,this.width / 2 - 140,this.height / 5 + 70,30,20, Text.of("height"));
|
||||||
|
heightWidget.setText(initialDimensions[1]);
|
||||||
|
heightWidget.setChangedListener(s -> {
|
||||||
|
String[] dimensions = new String[5];
|
||||||
|
for (int i = 0; i < dimensions.length; ++i){
|
||||||
|
if (sign.getTextOnRow(3, false).asString().split(":").length > i)
|
||||||
|
dimensions[i] = sign.getTextOnRow(3, false).asString().split(":")[i];
|
||||||
|
}
|
||||||
|
dimensions[1] = s;
|
||||||
|
StringBuilder mergedDimensions = new StringBuilder();
|
||||||
|
for (int i = 0; i < 5; ++i) {
|
||||||
|
if (dimensions[i] == null) dimensions[i] = "";
|
||||||
|
mergedDimensions.append(dimensions[i]);
|
||||||
|
if (i < 4)mergedDimensions.append(":");
|
||||||
|
}
|
||||||
|
sign.setTextOnRow(3, Text.of(String.valueOf(mergedDimensions)));
|
||||||
|
text = IntStream.range(0, 4).mapToObj((row) ->
|
||||||
|
sign.getTextOnRow(row, false)).map(Text::getString).toArray(String[]::new);
|
||||||
|
});
|
||||||
|
this.addDrawableChild(heightWidget);
|
||||||
|
TextFieldWidget posXWidget = new TextFieldWidget(textRenderer,this.width / 2 - 105,this.height / 5 + 70,30,20, Text.of("posX"));
|
||||||
|
posXWidget.setText(initialDimensions[2]);
|
||||||
|
posXWidget.setChangedListener(s -> {
|
||||||
|
String[] dimensions = new String[5];
|
||||||
|
for (int i = 0; i < dimensions.length; ++i){
|
||||||
|
if (sign.getTextOnRow(3, false).asString().split(":").length > i)
|
||||||
|
dimensions[i] = sign.getTextOnRow(3, false).asString().split(":")[i];
|
||||||
|
}
|
||||||
|
dimensions[2] = s;
|
||||||
|
StringBuilder mergedDimensions = new StringBuilder();
|
||||||
|
for (int i = 0; i < 5; ++i) {
|
||||||
|
if (dimensions[i] == null) dimensions[i] = "";
|
||||||
|
mergedDimensions.append(dimensions[i]);
|
||||||
|
if (i < 4)mergedDimensions.append(":");
|
||||||
|
}
|
||||||
|
sign.setTextOnRow(3, Text.of(String.valueOf(mergedDimensions)));
|
||||||
|
text = IntStream.range(0, 4).mapToObj((row) ->
|
||||||
|
sign.getTextOnRow(row, false)).map(Text::getString).toArray(String[]::new);
|
||||||
|
});
|
||||||
|
this.addDrawableChild(posXWidget);
|
||||||
|
TextFieldWidget posYWidget = new TextFieldWidget(textRenderer,this.width / 2 - 70,this.height / 5 + 70,30,20, Text.of("posY"));
|
||||||
|
posYWidget.setText(initialDimensions[3]);
|
||||||
|
posYWidget.setChangedListener(s -> {
|
||||||
|
String[] dimensions = new String[5];
|
||||||
|
for (int i = 0; i < dimensions.length; ++i){
|
||||||
|
if (sign.getTextOnRow(3, false).asString().split(":").length > i)
|
||||||
|
dimensions[i] = sign.getTextOnRow(3, false).asString().split(":")[i];
|
||||||
|
}
|
||||||
|
dimensions[3] = s;
|
||||||
|
StringBuilder mergedDimensions = new StringBuilder();
|
||||||
|
for (int i = 0; i < 5; ++i) {
|
||||||
|
if (dimensions[i] == null) dimensions[i] = "";
|
||||||
|
mergedDimensions.append(dimensions[i]);
|
||||||
|
if (i < 4)mergedDimensions.append(":");
|
||||||
|
}
|
||||||
|
sign.setTextOnRow(3, Text.of(String.valueOf(mergedDimensions)));
|
||||||
|
text = IntStream.range(0, 4).mapToObj((row) ->
|
||||||
|
sign.getTextOnRow(row, false)).map(Text::getString).toArray(String[]::new);
|
||||||
|
});
|
||||||
|
this.addDrawableChild(posYWidget);
|
||||||
|
TextFieldWidget posZWidget = new TextFieldWidget(textRenderer,this.width / 2 - 35,this.height / 5 + 70,30,20, Text.of("posZ"));
|
||||||
|
posZWidget.setText(initialDimensions[4]);
|
||||||
|
posZWidget.setChangedListener(s -> {
|
||||||
|
String[] dimensions = new String[5];
|
||||||
|
for (int i = 0; i < dimensions.length; ++i){
|
||||||
|
if (sign.getTextOnRow(3, false).asString().split(":").length > i)
|
||||||
|
dimensions[i] = sign.getTextOnRow(3, false).asString().split(":")[i];
|
||||||
|
}
|
||||||
|
dimensions[4] = s;
|
||||||
|
StringBuilder mergedDimensions = new StringBuilder();
|
||||||
|
for (int i = 0; i < 5; ++i) {
|
||||||
|
if (dimensions[i] == null) dimensions[i] = "";
|
||||||
|
mergedDimensions.append(dimensions[i]);
|
||||||
|
if (i < 4)mergedDimensions.append(":");
|
||||||
|
}
|
||||||
|
sign.setTextOnRow(3, Text.of(String.valueOf(mergedDimensions)));
|
||||||
|
text = IntStream.range(0, 4).mapToObj((row) ->
|
||||||
|
sign.getTextOnRow(row, false)).map(Text::getString).toArray(String[]::new);
|
||||||
|
});
|
||||||
|
this.addDrawableChild(posZWidget);
|
||||||
|
this.model = SignBlockEntityRenderer.createSignModel(this.client.getEntityModelLoader(), SignBlockEntityRenderer.getSignType(sign.getCachedState().getBlock()));
|
||||||
|
}
|
||||||
|
public void removed() {
|
||||||
|
ClientPlayNetworkHandler clientPlayNetworkHandler = this.client.getNetworkHandler();
|
||||||
|
if (clientPlayNetworkHandler != null) {
|
||||||
|
clientPlayNetworkHandler.sendPacket(new UpdateSignC2SPacket(this.sign.getPos(), this.text[0], this.text[1], this.text[2], this.text[3]));
|
||||||
|
}
|
||||||
|
this.sign.setEditable(true);
|
||||||
|
}
|
||||||
|
private String[] breakLink(String link) {
|
||||||
|
Text linkText = Text.of("!PS:"+link);
|
||||||
|
String[] brokenLink = new String[3];
|
||||||
|
Text line0Text = linkText;
|
||||||
|
int line0width = line0Text.asString().length();
|
||||||
|
assert this.client != null;
|
||||||
|
while (this.client.textRenderer.getWidth(line0Text) >= 90) {
|
||||||
|
--line0width;
|
||||||
|
line0Text = Text.of(line0Text.asString().substring(0,line0width));
|
||||||
|
}
|
||||||
|
brokenLink[0] = line0Text.asString();
|
||||||
|
Text line1Text = Text.of(linkText.asString().substring(line0width));
|
||||||
|
int line1width = line1Text.asString().length();
|
||||||
|
assert this.client != null;
|
||||||
|
while (this.client.textRenderer.getWidth(line1Text) >= 90) {
|
||||||
|
--line1width;
|
||||||
|
line1Text = Text.of(line1Text.asString().substring(0,line1width));
|
||||||
|
}
|
||||||
|
brokenLink[1] = line1Text.asString();
|
||||||
|
Text line2Text = Text.of(linkText.asString().substring(line0width + line1width));
|
||||||
|
int line2width = line2Text.asString().length();
|
||||||
|
assert this.client != null;
|
||||||
|
if (!PictureSignConfig.exceedVanillaLineLength)
|
||||||
|
while (this.client.textRenderer.getWidth(line2Text) >= 90) {
|
||||||
|
--line2width;
|
||||||
|
line2Text = Text.of(line2Text.asString().substring(0,line2width));
|
||||||
|
}
|
||||||
|
brokenLink[2] = line2Text.asString();
|
||||||
|
|
||||||
|
return brokenLink;
|
||||||
|
}
|
||||||
|
public void tick() {
|
||||||
|
super.tick();
|
||||||
|
if (!this.sign.getType().supports(this.sign.getCachedState())) {
|
||||||
|
this.finishEditing();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void finishEditing() {
|
||||||
|
sign.setEditable(true);
|
||||||
|
sign.markDirty();
|
||||||
|
assert this.client != null;
|
||||||
|
this.client.setScreen(null);
|
||||||
|
}
|
||||||
|
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||||
|
DiffuseLighting.disableGuiDepthLighting();
|
||||||
|
this.renderBackground(matrices);
|
||||||
|
drawTextWithShadow(matrices,textRenderer, Text.of("Link" + (PictureSignConfig.safeMode ? " (imgur.com/imgbb.com/iili.io/pictshare.net)" : "")),this.width / 2 - 175, this.height / 5 + 3, -8816268);
|
||||||
|
drawTextWithShadow(matrices,textRenderer, Text.of("Width"),this.width / 2 - 175, this.height / 5 + 60, -8816268);
|
||||||
|
drawTextWithShadow(matrices,textRenderer, Text.of("Height"),this.width / 2 - 140, this.height / 5 + 60, -8816268);
|
||||||
|
drawTextWithShadow(matrices,textRenderer, Text.of("PosX"),this.width / 2 - 105, this.height / 5 + 60, -8816268);
|
||||||
|
drawTextWithShadow(matrices,textRenderer, Text.of("PosY"),this.width / 2 - 75, this.height / 5 + 60, -8816268);
|
||||||
|
drawTextWithShadow(matrices,textRenderer, Text.of("PosZ"),this.width / 2 - 35, this.height / 5 + 60, -8816268);
|
||||||
|
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 40, 16777215);
|
||||||
|
matrices.push();
|
||||||
|
matrices.translate(this.width / 2f + 100, this.height / 5f - 60, 50.0);
|
||||||
|
matrices.scale(93.75F, -93.75F, 93.75F);
|
||||||
|
matrices.translate(0.0, -1.3125, 0.0);
|
||||||
|
BlockState blockState = this.sign.getCachedState();
|
||||||
|
boolean bl = blockState.getBlock() instanceof SignBlock;
|
||||||
|
if (!bl) {
|
||||||
|
matrices.translate(0.0, -0.3125, 0.0);
|
||||||
|
}
|
||||||
|
matrices.push();
|
||||||
|
matrices.scale(0.6666667F, -0.6666667F, -0.6666667F);
|
||||||
|
VertexConsumerProvider.Immediate immediate = this.client.getBufferBuilders().getEntityVertexConsumers();
|
||||||
|
SpriteIdentifier spriteIdentifier = TexturedRenderLayers.getSignTextureId(SignBlockEntityRenderer.getSignType(sign.getCachedState().getBlock()));
|
||||||
|
SignBlockEntityRenderer.SignModel var10002 = this.model;
|
||||||
|
Objects.requireNonNull(var10002);
|
||||||
|
VertexConsumer vertexConsumer = spriteIdentifier.getVertexConsumer(immediate, var10002::getLayer);
|
||||||
|
this.model.stick.visible = bl;
|
||||||
|
this.model.root.render(matrices, vertexConsumer, 15728880, OverlayTexture.DEFAULT_UV);
|
||||||
|
matrices.pop();
|
||||||
|
matrices.translate(0.0, 0.3333333432674408, 0.046666666865348816);
|
||||||
|
matrices.scale(0.010416667F, -0.010416667F, 0.010416667F);
|
||||||
|
int i = this.sign.getTextColor().getSignColor();
|
||||||
|
Matrix4f matrix4f = matrices.peek().getModel();
|
||||||
|
|
||||||
|
int m;
|
||||||
|
String string;
|
||||||
|
for(m = 0; m < this.text.length; ++m) {
|
||||||
|
string = this.text[m];
|
||||||
|
if (string != null) {
|
||||||
|
if (this.textRenderer.isRightToLeft()) {
|
||||||
|
string = this.textRenderer.mirror(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
float n = (float)(-this.client.textRenderer.getWidth(string) / 2);
|
||||||
|
this.client.textRenderer.draw(string, n, (float)(m * 10 - this.text.length * 5), i, false, matrix4f, immediate, false, 0, 15728880, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
immediate.draw();
|
||||||
|
|
||||||
|
matrices.pop();
|
||||||
|
DiffuseLighting.enableGuiDepthLighting();
|
||||||
|
super.render(matrices, mouseX, mouseY, delta);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package eu.midnightdust.picturesign.util;
|
||||||
|
|
||||||
|
import net.minecraft.block.entity.SignBlockEntity;
|
||||||
|
|
||||||
|
public class PictureURLUtils {
|
||||||
|
public static String getLink(SignBlockEntity signBlockEntity) {
|
||||||
|
String text = signBlockEntity.getTextOnRow(0, false).getString() +
|
||||||
|
signBlockEntity.getTextOnRow(1, false).getString() +
|
||||||
|
signBlockEntity.getTextOnRow(2, false).getString();
|
||||||
|
String url = text.replaceAll("!PS:", "").replaceAll(" ","");
|
||||||
|
if (url.startsWith("ps:")) url = url.replace("ps:", "https://pictshare.net/");
|
||||||
|
if (url.startsWith("imgur:")) url = url.replace("imgur:", "https://i.imgur.com/");
|
||||||
|
if (url.startsWith("imgbb:")) url = url.replace("imgbb:", "https://i.ibb.co/");
|
||||||
|
if (url.startsWith("iili:")) url = url.replace("iili:", "https://iili.io/");
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
public static String shortenLink(String url) {
|
||||||
|
if (url.contains("pictshare.net/")) url = url.replace("pictshare.net/", "ps:");
|
||||||
|
if (url.contains("i.imgur.com/")) url = url.replace("i.imgur.com/", "imgur:");
|
||||||
|
if (url.contains("i.ibb.co/:")) url = url.replace("i.ibb.co/", "imgbb:");
|
||||||
|
if (url.contains("iili.io/")) url = url.replace("iili.io/", "iili:");
|
||||||
|
if (url.startsWith("https://")) {
|
||||||
|
url = url.replace("https://", "");
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package eu.midnightdust.picturesign.util;
|
||||||
|
|
||||||
|
import eu.midnightdust.picturesign.PictureSignClient;
|
||||||
|
import net.minecraft.block.entity.SignBlockEntity;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.gui.screen.ingame.SignEditScreen;
|
||||||
|
import net.minecraft.util.hit.HitResult;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class SignEditEvent {
|
||||||
|
public static void tick(@NotNull MinecraftClient client) {
|
||||||
|
if (!PictureSignClient.BINDING_EDIT_SIGN.isPressed()) return;
|
||||||
|
PictureSignClient.BINDING_EDIT_SIGN.setPressed(false);
|
||||||
|
if (client.player == null || client.crosshairTarget == null || client.crosshairTarget.getType() != HitResult.Type.BLOCK) return;
|
||||||
|
if (client.crosshairTarget.getType() == HitResult.Type.BLOCK && client.world.getBlockState(new BlockPos(client.crosshairTarget.getPos())).hasBlockEntity()) {
|
||||||
|
if (client.world.getBlockEntity(new BlockPos(client.crosshairTarget.getPos())) instanceof SignBlockEntity) {
|
||||||
|
client.setScreen(new SignEditScreen((SignBlockEntity) client.world.getBlockEntity(new BlockPos(client.crosshairTarget.getPos())), false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
src/main/resources/assets/picturesign/lang/de_de.json
Executable file
18
src/main/resources/assets/picturesign/lang/de_de.json
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"picturesign.midnightconfig.title":"PictureSign Konfiguration",
|
||||||
|
|
||||||
|
"picturesign.midnightconfig.enabled":"Aktiviere Bilder",
|
||||||
|
"picturesign.midnightconfig.translucency":"Aktiviere Lichtdurchlässigkeit",
|
||||||
|
"picturesign.midnightconfig.translucency.tooltip":"Lichtdurchlässigkeit funktioniert teilweise nicht richtig\nbei Block-Entities (und dementsprechend Schildern)",
|
||||||
|
"picturesign.midnightconfig.helperUi":"Aktiviere Hilfsoberfäche",
|
||||||
|
"picturesign.midnightconfig.exceedVanillaLineLength":"Überschreite die Vanilla Zeilenlänge",
|
||||||
|
"picturesign.midnightconfig.debug":"Debug-Modus",
|
||||||
|
"picturesign.midnightconfig.maxThreads":"Maximale Download-Threads",
|
||||||
|
"picturesign.midnightconfig.signRenderDistance":"Schildsichtweite",
|
||||||
|
"picturesign.midnightconfig.safeMode":"Sicherer Modus",
|
||||||
|
"picturesign.midnightconfig.safeMode.tooltip":"Lädt nur Bilder von vertrauten Seiten",
|
||||||
|
"picturesign.midnightconfig.ebeWarning":"§cWenn du die Mod 'Enhanced Block Entities' benutzt, stelle sicher,",
|
||||||
|
"picturesign.midnightconfig.ebeWarning2":"§cdass du alles in Relation zu Schildern in der EBE Config deaktiviert hast!",
|
||||||
|
"key.picturesign.copy_sign": "Text eines Schildes kopieren",
|
||||||
|
"key.picturesign.edit_sign":"Schild bearbeiten"
|
||||||
|
}
|
||||||
@@ -1,8 +1,19 @@
|
|||||||
{
|
{
|
||||||
"picturesign.midnightconfig.title":"PictureSign Config",
|
"picturesign.midnightconfig.title":"PictureSign Config",
|
||||||
|
|
||||||
"picturesign.midnightconfig.enabled":"Enabled",
|
"picturesign.midnightconfig.enabled":"Enable Pictures",
|
||||||
"picturesign.midnightconfig.debug":"Send debug info",
|
"picturesign.midnightconfig.translucency":"Enable Translucency",
|
||||||
|
"picturesign.midnightconfig.translucency.tooltip":"Translucency doesn't work too great on block entities\n(and therefore signs)",
|
||||||
|
"picturesign.midnightconfig.helperUi":"Enable Helper UI",
|
||||||
|
"picturesign.midnightconfig.exceedVanillaLineLength":"Exceed vanilla line length",
|
||||||
|
"picturesign.midnightconfig.debug":"Debug mode",
|
||||||
"picturesign.midnightconfig.maxThreads":"Max download threads",
|
"picturesign.midnightconfig.maxThreads":"Max download threads",
|
||||||
"picturesign.midnightconfig.signRenderDistance":"Sign render distance"
|
"picturesign.midnightconfig.signRenderDistance":"Sign render distance",
|
||||||
|
"picturesign.midnightconfig.safeMode":"Safe mode",
|
||||||
|
"picturesign.midnightconfig.safeMode.tooltip":"Only load images from trusted providers",
|
||||||
|
"picturesign.midnightconfig.ebeWarning":"§cIf you are using the mod 'Enhanced Block Entities'",
|
||||||
|
"picturesign.midnightconfig.ebeWarning2":"§cmake sure to disable anything sign-related in it's config!",
|
||||||
|
"key.picturesign.copy_sign":"Copy Text from Sign",
|
||||||
|
"key.picturesign.edit_sign":"Edit Sign",
|
||||||
|
"key.categories.picturesign":"PictureSign"
|
||||||
}
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 7.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 762 B |
Binary file not shown.
|
After Width: | Height: | Size: 5.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
@@ -3,7 +3,8 @@
|
|||||||
"package": "eu.midnightdust.picturesign.mixin",
|
"package": "eu.midnightdust.picturesign.mixin",
|
||||||
"compatibilityLevel": "JAVA_16",
|
"compatibilityLevel": "JAVA_16",
|
||||||
"client": [
|
"client": [
|
||||||
"MixinSignBlockEntityRenderer"
|
"MixinSignBlockEntityRenderer",
|
||||||
|
"MixinSignEditScreen"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|||||||
Reference in New Issue
Block a user