Worked on 1.17 branch, still has block lighting bug
This commit is contained in:
parent
61aba0c6a0
commit
3a8d938136
66
build.gradle
66
build.gradle
|
|
@ -1,20 +1,25 @@
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
maven { url = 'https://files.minecraftforge.net/maven' }
|
maven { url = 'https://maven.minecraftforge.net' }
|
||||||
|
maven { url = 'https://maven.parchmentmc.org' }
|
||||||
jcenter()
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
|
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
|
||||||
|
classpath 'org.parchmentmc:librarian:1.+'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
apply plugin: 'net.minecraftforge.gradle'
|
apply plugin: 'net.minecraftforge.gradle'
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
|
apply plugin: 'org.parchmentmc.librarian.forgegradle'
|
||||||
|
|
||||||
|
|
||||||
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/22e7d543a18cd30675277fbfa3669e3d9e206010/generic/secrets.gradle'
|
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/22e7d543a18cd30675277fbfa3669e3d9e206010/generic/secrets.gradle'
|
||||||
|
apply from: 'https://raw.githubusercontent.com/SizableShrimp/Forge-Class-Remapper/main/classremapper.gradle'
|
||||||
|
|
||||||
import net.minecraftforge.gradle.common.task.SignJar
|
//import net.minecraftforge.gradle.common.task.SignJar
|
||||||
import groovy.json.JsonSlurper
|
import groovy.json.JsonSlurper
|
||||||
import groovy.json.JsonOutput
|
import groovy.json.JsonOutput
|
||||||
|
|
||||||
|
|
@ -26,15 +31,18 @@ version = "${version}"
|
||||||
group = "tschipp.carryon"
|
group = "tschipp.carryon"
|
||||||
archivesBaseName = "carryon-${minecraft_version}"
|
archivesBaseName = "carryon-${minecraft_version}"
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
|
//sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.16'
|
||||||
|
|
||||||
|
|
||||||
if (System.getenv('BUILD_NUMBER') != null) {
|
if (System.getenv('BUILD_NUMBER') != null) {
|
||||||
version += "." + System.getenv('BUILD_NUMBER')
|
version += "." + System.getenv('BUILD_NUMBER')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
java.toolchain.languageVersion = JavaLanguageVersion.of(16)
|
||||||
|
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
mappings channel: 'official', version: "1.16.5"
|
mappings channel: 'parchment', version: '2021.12.12-1.17.1'
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
client {
|
client {
|
||||||
|
|
@ -111,19 +119,19 @@ repositories {
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||||
|
|
||||||
implementation fg.deobf("net.darkhax.gamestages:GameStages-1.16.4:6.0.1")
|
//implementation fg.deobf("net.darkhax.gamestages:GameStages-1.16.4:6.0.1")
|
||||||
implementation fg.deobf("net.darkhax.bookshelf:Bookshelf-1.16.4:9.3.18")
|
//implementation fg.deobf("net.darkhax.bookshelf:Bookshelf-1.16.4:9.3.18")
|
||||||
implementation fg.deobf("curse.maven:obfuscate-289380:3169370")
|
//implementation fg.deobf("curse.maven:obfuscate-289380:3169370")
|
||||||
|
|
||||||
fileTree("libs").matching {
|
//fileTree("libs").matching {
|
||||||
include "*.jar"
|
// include "*.jar"
|
||||||
}.each {
|
//}.each {
|
||||||
String filename = it.getName();
|
// String filename = it.getName();
|
||||||
filename = filename.substring(0, filename.length() - 4);
|
// filename = filename.substring(0, filename.length() - 4);
|
||||||
int lastDash = filename.lastIndexOf("-");
|
// int lastDash = filename.lastIndexOf("-");
|
||||||
filename = filename.substring(0, lastDash) + ":" + filename.substring(lastDash+1, filename.length());
|
// filename = filename.substring(0, lastDash) + ":" + filename.substring(lastDash+1, filename.length());
|
||||||
implementation fg.deobf("blank:${filename}")
|
// implementation fg.deobf("blank:${filename}")
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -215,22 +223,22 @@ publishing {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task signJar(type: SignJar, dependsOn: jar) {
|
//task signJar(type: SignJar, dependsOn: jar) {
|
||||||
// Skips if the keyStore property is missing.
|
// Skips if the keyStore property is missing.
|
||||||
onlyIf {
|
// onlyIf {
|
||||||
project.hasProperty('modkeyStore')
|
// project.hasProperty('modkeyStore')
|
||||||
}
|
// }
|
||||||
|
|
||||||
// findProperty allows us to reference the property without it existing.
|
// findProperty allows us to reference the property without it existing.
|
||||||
// Using project.propName would cause the script to fail validation if
|
// Using project.propName would cause the script to fail validation if
|
||||||
// the property did not exist.
|
// the property did not exist.
|
||||||
keyStore = project.findProperty('modkeyStore')
|
// keyStore = project.findProperty('modkeyStore')
|
||||||
alias = project.findProperty('modkeyStoreAlias')
|
// alias = project.findProperty('modkeyStoreAlias')
|
||||||
storePass = project.findProperty('modkeyStorePass')
|
// storePass = project.findProperty('modkeyStorePass')
|
||||||
keyPass = project.findProperty('modkeyStoreKeyPass')
|
// keyPass = project.findProperty('modkeyStoreKeyPass')
|
||||||
inputFile = jar.archivePath
|
// inputFile = jar.archivePath
|
||||||
outputFile = jar.archivePath
|
// outputFile = jar.archivePath
|
||||||
}
|
//}
|
||||||
|
|
||||||
// Runs this task automatically when build is ran.
|
// Runs this task automatically when build is ran.
|
||||||
build.dependsOn signJar
|
//build.dependsOn signJar
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
# This is required to provide enough memory for the Minecraft decompilation process.
|
# This is required to provide enough memory for the Minecraft decompilation process.
|
||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
version=1.15.5
|
version=1.15.5
|
||||||
minecraft_version=1.16.5
|
minecraft_version=1.17.1
|
||||||
mcp_mappings=20201028-1.16.3
|
mcp_mappings=20201028-1.16.3
|
||||||
forge_version=36.0.22
|
forge_version=37.1.1
|
||||||
|
org.gradle.daemon=false
|
||||||
|
# chorg.gradle.java.home=C:/Program Files/AdoptOpenJDK/jdk-16.0.1.9-hotspot/
|
||||||
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.1.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
|
|
||||||
|
|
|
||||||
55
gradlew
vendored
55
gradlew
vendored
|
|
@ -1,5 +1,21 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2015 the original author or authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
##
|
||||||
## Gradle start up script for UN*X
|
## Gradle start up script for UN*X
|
||||||
|
|
@ -28,7 +44,7 @@ APP_NAME="Gradle"
|
||||||
APP_BASE_NAME=`basename "$0"`
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS=""
|
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"
|
||||||
|
|
@ -56,7 +72,7 @@ case "`uname`" in
|
||||||
Darwin* )
|
Darwin* )
|
||||||
darwin=true
|
darwin=true
|
||||||
;;
|
;;
|
||||||
MINGW* )
|
MSYS* | MINGW* )
|
||||||
msys=true
|
msys=true
|
||||||
;;
|
;;
|
||||||
NONSTOP* )
|
NONSTOP* )
|
||||||
|
|
@ -66,6 +82,7 @@ esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
|
@ -109,10 +126,11 @@ if $darwin; then
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# For Cygwin, switch paths to Windows format before running java
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if $cygwin ; then
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
|
@ -138,19 +156,19 @@ if $cygwin ; then
|
||||||
else
|
else
|
||||||
eval `echo args$i`="\"$arg\""
|
eval `echo args$i`="\"$arg\""
|
||||||
fi
|
fi
|
||||||
i=$((i+1))
|
i=`expr $i + 1`
|
||||||
done
|
done
|
||||||
case $i in
|
case $i in
|
||||||
(0) set -- ;;
|
0) set -- ;;
|
||||||
(1) set -- "$args0" ;;
|
1) set -- "$args0" ;;
|
||||||
(2) set -- "$args0" "$args1" ;;
|
2) set -- "$args0" "$args1" ;;
|
||||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -159,14 +177,9 @@ save () {
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
echo " "
|
echo " "
|
||||||
}
|
}
|
||||||
APP_ARGS=$(save "$@")
|
APP_ARGS=`save "$@"`
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
|
||||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|
|
||||||
43
gradlew.bat
vendored
43
gradlew.bat
vendored
|
|
@ -1,3 +1,19 @@
|
||||||
|
@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
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
|
|
@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
set DEFAULT_JVM_OPTS=
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto init
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
@ -35,7 +54,7 @@ goto fail
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto init
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
|
@ -45,28 +64,14 @@ echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:init
|
|
||||||
@rem Get command-line arguments, handling Windows variants
|
|
||||||
|
|
||||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
|
||||||
|
|
||||||
:win9xME_args
|
|
||||||
@rem Slurp the command line arguments.
|
|
||||||
set CMD_LINE_ARGS=
|
|
||||||
set _SKIP=2
|
|
||||||
|
|
||||||
:win9xME_args_slurp
|
|
||||||
if "x%~1" == "x" goto execute
|
|
||||||
|
|
||||||
set CMD_LINE_ARGS=%*
|
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ import java.util.Optional;
|
||||||
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 net.minecraft.item.Item;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraftforge.event.RegistryEvent;
|
import net.minecraftforge.event.RegistryEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
|
|
@ -17,9 +17,9 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
import net.minecraftforge.fml.config.ModConfig;
|
import net.minecraftforge.fml.config.ModConfig;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
import net.minecraftforge.fml.network.NetworkDirection;
|
import net.minecraftforge.fmllegacy.network.NetworkDirection;
|
||||||
import net.minecraftforge.fml.network.NetworkRegistry;
|
import net.minecraftforge.fmllegacy.network.NetworkRegistry;
|
||||||
import net.minecraftforge.fml.network.simple.SimpleChannel;
|
import net.minecraftforge.fmllegacy.network.simple.SimpleChannel;
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
import tschipp.carryon.common.config.Configs;
|
import tschipp.carryon.common.config.Configs;
|
||||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||||
|
|
|
||||||
|
|
@ -4,22 +4,22 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.platform.Lighting;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.math.Vector3f;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.client.event.RenderHandEvent;
|
import net.minecraftforge.client.event.RenderHandEvent;
|
||||||
|
|
@ -37,7 +37,7 @@ public class RenderEntityEvents
|
||||||
|
|
||||||
public static final Map<String, Entity> nbtEntityMap = new HashMap<>();
|
public static final Map<String, Entity> nbtEntityMap = new HashMap<>();
|
||||||
|
|
||||||
public static Entity getEntity(ItemStack carried, World world)
|
public static Entity getEntity(ItemStack carried, Level world)
|
||||||
{
|
{
|
||||||
String nbt = ItemCarryonEntity.getPersistentData(carried).toString();
|
String nbt = ItemCarryonEntity.getPersistentData(carried).toString();
|
||||||
if(nbtEntityMap.containsKey(nbt))
|
if(nbtEntityMap.containsKey(nbt))
|
||||||
|
|
@ -66,15 +66,15 @@ public class RenderEntityEvents
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void renderHand(RenderHandEvent event)
|
public void renderHand(RenderHandEvent event)
|
||||||
{
|
{
|
||||||
World world = Minecraft.getInstance().level;
|
Level world = Minecraft.getInstance().level;
|
||||||
PlayerEntity player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
int perspective = CarryRenderHelper.getPerspective();
|
int perspective = CarryRenderHelper.getPerspective();
|
||||||
float partialticks = event.getPartialTicks();
|
float partialticks = event.getPartialTicks();
|
||||||
MatrixStack matrix = event.getMatrixStack();
|
PoseStack matrix = event.getMatrixStack();
|
||||||
int light = event.getLight();
|
int light = event.getLight();
|
||||||
IRenderTypeBuffer buffer = event.getBuffers();
|
MultiBufferSource buffer = event.getBuffers();
|
||||||
EntityRendererManager manager = Minecraft.getInstance().getEntityRenderDispatcher();
|
EntityRenderDispatcher manager = Minecraft.getInstance().getEntityRenderDispatcher();
|
||||||
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||||
{
|
{
|
||||||
|
|
@ -85,10 +85,10 @@ public class RenderEntityEvents
|
||||||
|
|
||||||
if (entity != null)
|
if (entity != null)
|
||||||
{
|
{
|
||||||
Vector3d playerpos = CarryRenderHelper.getExactPos(player, partialticks);
|
Vec3 playerpos = CarryRenderHelper.getExactPos(player, partialticks);
|
||||||
|
|
||||||
entity.setPos(playerpos.x, playerpos.y, playerpos.z);
|
entity.setPos(playerpos.x, playerpos.y, playerpos.z);
|
||||||
entity.yRot = 0.0f;
|
entity.xRotO = 0.0f;
|
||||||
entity.yRotO = 0.0f;
|
entity.yRotO = 0.0f;
|
||||||
entity.setYHeadRot(0.0f);
|
entity.setYHeadRot(0.0f);
|
||||||
|
|
||||||
|
|
@ -100,11 +100,11 @@ public class RenderEntityEvents
|
||||||
matrix.mulPose(Vector3f.YP.rotationDegrees(180));
|
matrix.mulPose(Vector3f.YP.rotationDegrees(180));
|
||||||
matrix.translate(0.0, -height - .1, width + 0.1);
|
matrix.translate(0.0, -height - .1, width + 0.1);
|
||||||
|
|
||||||
RenderSystem.enableAlphaTest();
|
// RenderSystem.enableAlphaTest();
|
||||||
|
|
||||||
if (perspective == 0)
|
if (perspective == 0)
|
||||||
{
|
{
|
||||||
RenderHelper.turnBackOn();
|
// Lighting.en
|
||||||
manager.setRenderShadow(false);
|
manager.setRenderShadow(false);
|
||||||
|
|
||||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||||
|
|
@ -123,12 +123,12 @@ public class RenderEntityEvents
|
||||||
|
|
||||||
if (newEntity != null)
|
if (newEntity != null)
|
||||||
{
|
{
|
||||||
CompoundNBT nbttag = carryOverride.getRenderNBT();
|
CompoundTag nbttag = carryOverride.getRenderNBT();
|
||||||
if (nbttag != null)
|
if (nbttag != null)
|
||||||
newEntity.deserializeNBT(nbttag);
|
newEntity.deserializeNBT(nbttag);
|
||||||
entity = newEntity;
|
entity = newEntity;
|
||||||
entity.setPos(playerpos.x, playerpos.y, playerpos.z);
|
entity.setPos(playerpos.x, playerpos.y, playerpos.z);
|
||||||
entity.yRot = 0.0f;
|
entity.xRotO = 0.0f;
|
||||||
entity.yRotO = 0.0f;
|
entity.yRotO = 0.0f;
|
||||||
entity.setYHeadRot(0.0f);
|
entity.setYHeadRot(0.0f);
|
||||||
}
|
}
|
||||||
|
|
@ -142,11 +142,12 @@ public class RenderEntityEvents
|
||||||
manager.setRenderShadow(true);
|
manager.setRenderShadow(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderSystem.disableAlphaTest();
|
// RenderSystem.disableAlphaTest();
|
||||||
matrix.popPose();
|
matrix.popPose();
|
||||||
|
|
||||||
RenderHelper.turnOff();
|
// Lighting.turnOff();
|
||||||
RenderSystem.disableRescaleNormal();
|
// TODO
|
||||||
|
// RenderSystem.disableRescaleNormal();
|
||||||
|
|
||||||
if (perspective == 0)
|
if (perspective == 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,53 +3,53 @@ package tschipp.carryon.client.event;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.platform.Lighting;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.blaze3d.vertex.Tesselator;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
|
import com.mojang.math.Quaternion;
|
||||||
|
import com.mojang.math.Vector3f;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.client.KeyMapping;
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import net.minecraft.client.GameSettings;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
|
import net.minecraft.client.Options;
|
||||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.model.PlayerModel;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer.Impl;
|
import net.minecraft.client.model.geom.ModelPart;
|
||||||
|
import net.minecraft.client.player.AbstractClientPlayer;
|
||||||
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
|
import net.minecraft.client.renderer.MultiBufferSource.BufferSource;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
import net.minecraft.client.renderer.entity.player.PlayerRenderer;
|
||||||
import net.minecraft.client.renderer.entity.PlayerRenderer;
|
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||||
import net.minecraft.client.renderer.entity.model.PlayerModel;
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
import net.minecraft.network.chat.ClickEvent;
|
||||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
import net.minecraft.network.chat.ClickEvent.Action;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.entity.Pose;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.world.entity.Pose;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.util.math.vector.Quaternion;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
import net.minecraft.util.text.event.ClickEvent;
|
|
||||||
import net.minecraft.util.text.event.ClickEvent.Action;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
|
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
|
||||||
import net.minecraftforge.client.event.RenderHandEvent;
|
import net.minecraftforge.client.event.RenderHandEvent;
|
||||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||||
import net.minecraftforge.client.event.ClientPlayerNetworkEvent.LoggedInEvent;
|
|
||||||
import net.minecraftforge.event.TickEvent.PlayerTickEvent;
|
import net.minecraftforge.event.TickEvent.PlayerTickEvent;
|
||||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||||
import net.minecraftforge.eventbus.api.EventPriority;
|
import net.minecraftforge.eventbus.api.EventPriority;
|
||||||
|
|
@ -60,7 +60,6 @@ import tschipp.carryon.CarryOn;
|
||||||
import tschipp.carryon.client.helper.CarryRenderHelper;
|
import tschipp.carryon.client.helper.CarryRenderHelper;
|
||||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||||
import tschipp.carryon.common.config.Configs.Settings;
|
import tschipp.carryon.common.config.Configs.Settings;
|
||||||
import tschipp.carryon.common.handler.ListHandler;
|
|
||||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||||
import tschipp.carryon.common.helper.KeyboardCallbackWrapper.KeyPressedEvent;
|
import tschipp.carryon.common.helper.KeyboardCallbackWrapper.KeyPressedEvent;
|
||||||
|
|
@ -82,7 +81,8 @@ public class RenderEvents
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onScroll(MouseScrolledEvent event)
|
public void onScroll(MouseScrolledEvent event)
|
||||||
{
|
{
|
||||||
PlayerEntity player = Minecraft.getInstance().player;
|
@SuppressWarnings("resource")
|
||||||
|
Player player = Minecraft.getInstance().player;
|
||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
|
|
@ -103,7 +103,7 @@ public class RenderEvents
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void onPlayerTick(PlayerTickEvent event) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
|
public void onPlayerTick(PlayerTickEvent event) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
|
||||||
{
|
{
|
||||||
PlayerEntity player = event.player;
|
Player player = event.player;
|
||||||
|
|
||||||
if (player != null && event.side == LogicalSide.CLIENT)
|
if (player != null && event.side == LogicalSide.CLIENT)
|
||||||
{
|
{
|
||||||
|
|
@ -127,9 +127,9 @@ public class RenderEvents
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void onJoinWorld(EntityJoinWorldEvent event)
|
public void onJoinWorld(EntityJoinWorldEvent event)
|
||||||
{
|
{
|
||||||
if (event.getEntity() instanceof PlayerEntity)
|
if (event.getEntity() instanceof Player)
|
||||||
{
|
{
|
||||||
PlayerEntity player = (PlayerEntity) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
if (player.level.isClientSide)
|
if (player.level.isClientSide)
|
||||||
{
|
{
|
||||||
CarryOnKeybinds.setKeyPressed(player, false);
|
CarryOnKeybinds.setKeyPressed(player, false);
|
||||||
|
|
@ -137,10 +137,10 @@ public class RenderEvents
|
||||||
|
|
||||||
if (CarryOn.FINGERPRINT_VIOLATED)
|
if (CarryOn.FINGERPRINT_VIOLATED)
|
||||||
{
|
{
|
||||||
StringTextComponent cf = new StringTextComponent(TextFormatting.AQUA + "Curseforge" + TextFormatting.RED);
|
TextComponent cf = new TextComponent(ChatFormatting.AQUA + "Curseforge" + ChatFormatting.RED);
|
||||||
cf.getStyle().withClickEvent(new ClickEvent(Action.OPEN_URL, "https://minecraft.curseforge.com/projects/carry-on"));
|
cf.getStyle().withClickEvent(new ClickEvent(Action.OPEN_URL, "https://minecraft.curseforge.com/projects/carry-on"));
|
||||||
|
|
||||||
player.displayClientMessage(new StringTextComponent(TextFormatting.RED + "[CarryOn] WARNING! Invalid fingerprint detected! The Carry On mod file may have been tampered with! If you didn't download the file from ").append(cf).append(TextFormatting.RED + " or through any kind of mod launcher, immediately delete the file and re-download it from ").append(cf), false);
|
player.displayClientMessage(new TextComponent(ChatFormatting.RED + "[CarryOn] WARNING! Invalid fingerprint detected! The Carry On mod file may have been tampered with! If you didn't download the file from ").append(cf).append(ChatFormatting.RED + " or through any kind of mod launcher, immediately delete the file and re-download it from ").append(cf), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,18 +150,19 @@ public class RenderEvents
|
||||||
/*
|
/*
|
||||||
* Prevents the Player from opening Guis
|
* Prevents the Player from opening Guis
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("resource")
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onGuiInit(InitGuiEvent.Pre event)
|
public void onGuiInit(InitGuiEvent.Pre event)
|
||||||
{
|
{
|
||||||
if (event.getGui() != null)
|
if (event.getGui() != null)
|
||||||
{
|
{
|
||||||
boolean inventory = event.getGui() instanceof ContainerScreen;
|
boolean inventory = event.getGui() instanceof AbstractContainerScreen;
|
||||||
PlayerEntity player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
|
|
||||||
if (player != null && inventory)
|
if (player != null && inventory)
|
||||||
{
|
{
|
||||||
ItemStack stack = player.getItemInHand(Hand.MAIN_HAND);
|
ItemStack stack = player.getItemInHand(InteractionHand.MAIN_HAND);
|
||||||
|
|
||||||
if (!stack.isEmpty() && ((stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack)) || (stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))))
|
if (!stack.isEmpty() && ((stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack)) || (stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))))
|
||||||
{
|
{
|
||||||
|
|
@ -178,14 +179,15 @@ public class RenderEvents
|
||||||
/*
|
/*
|
||||||
* Prevents the Player from switching Slots
|
* Prevents the Player from switching Slots
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("resource")
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void inputEvent(KeyPressedEvent event) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException
|
public void inputEvent(KeyPressedEvent event) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException
|
||||||
{
|
{
|
||||||
GameSettings settings = Minecraft.getInstance().options;
|
Options settings = Minecraft.getInstance().options;
|
||||||
int key = event.key;
|
int key = event.key;
|
||||||
int scancode = event.scancode;
|
int scancode = event.scancode;
|
||||||
PlayerEntity player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
|
|
@ -205,7 +207,7 @@ public class RenderEvents
|
||||||
{
|
{
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
for (KeyBinding keyBind : settings.keyHotbarSlots)
|
for (KeyMapping keyBind : settings.keyHotbarSlots)
|
||||||
{
|
{
|
||||||
if (keyBind.matches(key, scancode))
|
if (keyBind.matches(key, scancode))
|
||||||
{
|
{
|
||||||
|
|
@ -214,11 +216,11 @@ public class RenderEvents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int current = player.inventory.selected;
|
int current = player.getInventory().selected;
|
||||||
|
|
||||||
if (player.getPersistentData().contains("carrySlot") ? player.getPersistentData().getInt("carrySlot") != current : false)
|
if (player.getPersistentData().contains("carrySlot") ? player.getPersistentData().getInt("carrySlot") != current : false)
|
||||||
{
|
{
|
||||||
player.inventory.selected = player.getPersistentData().getInt("carrySlot");
|
player.getInventory().selected = player.getPersistentData().getInt("carrySlot");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -226,18 +228,18 @@ public class RenderEvents
|
||||||
/*
|
/*
|
||||||
* Renders the Block in First Person
|
* Renders the Block in First Person
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings({ "resource", "deprecation" })
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void renderHand(RenderHandEvent event)
|
public void renderHand(RenderHandEvent event)
|
||||||
{
|
{
|
||||||
World world = Minecraft.getInstance().level;
|
Level world = Minecraft.getInstance().level;
|
||||||
PlayerEntity player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
int perspective = CarryRenderHelper.getPerspective();
|
int perspective = CarryRenderHelper.getPerspective();
|
||||||
boolean f1 = Minecraft.getInstance().options.hideGui;
|
boolean f1 = Minecraft.getInstance().options.hideGui;
|
||||||
IRenderTypeBuffer buffer = event.getBuffers();
|
MultiBufferSource buffer = event.getBuffers();
|
||||||
MatrixStack matrix = event.getMatrixStack();
|
PoseStack matrix = event.getMatrixStack();
|
||||||
int light = event.getLight();
|
int light = event.getLight();
|
||||||
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) && perspective == 0 && !f1)
|
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) && perspective == 0 && !f1)
|
||||||
|
|
@ -246,7 +248,7 @@ public class RenderEvents
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Block block = ItemCarryonBlock.getBlock(stack);
|
Block block = ItemCarryonBlock.getBlock(stack);
|
||||||
CompoundNBT tag = ItemCarryonBlock.getTileData(stack);
|
CompoundTag tag = ItemCarryonBlock.getTileData(stack);
|
||||||
BlockState state = ItemCarryonBlock.getBlockState(stack);
|
BlockState state = ItemCarryonBlock.getBlockState(stack);
|
||||||
ItemStack tileStack = ItemCarryonBlock.getItemStack(stack);
|
ItemStack tileStack = ItemCarryonBlock.getItemStack(stack);
|
||||||
|
|
||||||
|
|
@ -266,7 +268,7 @@ public class RenderEvents
|
||||||
matrix.mulPose(Vector3f.XP.rotationDegrees(8));
|
matrix.mulPose(Vector3f.XP.rotationDegrees(8));
|
||||||
}
|
}
|
||||||
|
|
||||||
IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : (tileStack.isEmpty() ? Minecraft.getInstance().getBlockRenderer().getBlockModel(state) : Minecraft.getInstance().getItemRenderer().getModel(tileStack, world, player));
|
BakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : (tileStack.isEmpty() ? Minecraft.getInstance().getBlockRenderer().getBlockModel(state) : Minecraft.getInstance().getItemRenderer().getModel(tileStack, world, player, 0));
|
||||||
|
|
||||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||||
if (carryOverride != null)
|
if (carryOverride != null)
|
||||||
|
|
@ -280,12 +282,12 @@ public class RenderEvents
|
||||||
{
|
{
|
||||||
ItemStack s = new ItemStack(b, 1);
|
ItemStack s = new ItemStack(b, 1);
|
||||||
s.setTag(carryOverride.getRenderNBT());
|
s.setTag(carryOverride.getRenderNBT());
|
||||||
model = Minecraft.getInstance().getItemRenderer().getModel(s, world, player);
|
model = Minecraft.getInstance().getItemRenderer().getModel(s, world, player, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Minecraft.getInstance().getTextureManager().bind(AtlasTexture.LOCATION_BLOCKS);
|
RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_BLOCKS);
|
||||||
|
|
||||||
CarryRenderHelper.renderItem(state, tag, stack, tileStack, matrix, buffer, light, model);
|
CarryRenderHelper.renderItem(state, tag, stack, tileStack, matrix, buffer, light, model);
|
||||||
|
|
||||||
|
|
@ -299,35 +301,34 @@ public class RenderEvents
|
||||||
matrix.popPose();
|
matrix.popPose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @SubscribeEvent
|
// @SubscribeEvent
|
||||||
// public void onJoinServer(LoggedInEvent event)
|
// public void onJoinServer(LoggedInEvent event)
|
||||||
// {
|
// {
|
||||||
// ListHandler.initConfigLists();
|
// ListHandler.initConfigLists();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Render blocks and entities in third person
|
* Render blocks and entities in third person
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings({ "deprecation", "resource" })
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onRenderWorld(RenderWorldLastEvent event)
|
public void onRenderWorld(RenderWorldLastEvent event)
|
||||||
{
|
{
|
||||||
World world = Minecraft.getInstance().level;
|
Level world = Minecraft.getInstance().level;
|
||||||
float partialticks = event.getPartialTicks();
|
float partialticks = event.getPartialTicks();
|
||||||
Impl buffer = IRenderTypeBuffer.immediate(Tessellator.getInstance().getBuilder());
|
BufferSource buffer = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
|
||||||
MatrixStack matrix = event.getMatrixStack();
|
PoseStack matrix = event.getMatrixStack();
|
||||||
int light = 0;
|
int light = 0;
|
||||||
int perspective = CarryRenderHelper.getPerspective();
|
int perspective = CarryRenderHelper.getPerspective();
|
||||||
EntityRendererManager manager = Minecraft.getInstance().getEntityRenderDispatcher();
|
EntityRenderDispatcher manager = Minecraft.getInstance().getEntityRenderDispatcher();
|
||||||
|
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.disableCull();
|
RenderSystem.disableCull();
|
||||||
RenderSystem.disableDepthTest();
|
RenderSystem.disableDepthTest();
|
||||||
|
|
||||||
for (PlayerEntity player : world.players())
|
for (Player player : world.players())
|
||||||
{
|
{
|
||||||
if (perspective == 0 && player == Minecraft.getInstance().player)
|
if (perspective == 0 && player == Minecraft.getInstance().player)
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -339,12 +340,12 @@ public class RenderEvents
|
||||||
{
|
{
|
||||||
Block block = ItemCarryonBlock.getBlock(stack);
|
Block block = ItemCarryonBlock.getBlock(stack);
|
||||||
BlockState state = ItemCarryonBlock.getBlockState(stack);
|
BlockState state = ItemCarryonBlock.getBlockState(stack);
|
||||||
CompoundNBT tag = ItemCarryonBlock.getTileData(stack);
|
CompoundTag tag = ItemCarryonBlock.getTileData(stack);
|
||||||
ItemStack tileItem = ItemCarryonBlock.getItemStack(stack);
|
ItemStack tileItem = ItemCarryonBlock.getItemStack(stack);
|
||||||
|
|
||||||
applyBlockTransformations(player, partialticks, matrix, block);
|
applyBlockTransformations(player, partialticks, matrix, block);
|
||||||
|
|
||||||
IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : (tileItem.isEmpty() ? Minecraft.getInstance().getBlockRenderer().getBlockModel(state) : Minecraft.getInstance().getItemRenderer().getModel(tileItem, world, player));
|
BakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : (tileItem.isEmpty() ? Minecraft.getInstance().getBlockRenderer().getBlockModel(state) : Minecraft.getInstance().getItemRenderer().getModel(tileItem, world, player, 0));
|
||||||
|
|
||||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||||
if (carryOverride != null)
|
if (carryOverride != null)
|
||||||
|
|
@ -358,19 +359,26 @@ public class RenderEvents
|
||||||
{
|
{
|
||||||
ItemStack s = new ItemStack(b, 1);
|
ItemStack s = new ItemStack(b, 1);
|
||||||
s.setTag(carryOverride.getRenderNBT());
|
s.setTag(carryOverride.getRenderNBT());
|
||||||
model = Minecraft.getInstance().getItemRenderer().getModel(s, world, player);
|
model = Minecraft.getInstance().getItemRenderer().getModel(s, world, player, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Minecraft.getInstance().getTextureManager().bind(AtlasTexture.LOCATION_BLOCKS);
|
RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_BLOCKS);
|
||||||
CarryRenderHelper.renderItem(state, tag, stack, tileItem, matrix, buffer, light, model);
|
//TODO: Fix block light
|
||||||
buffer.endBatch();
|
RenderSystem.enableCull();
|
||||||
|
|
||||||
|
PoseStack.Pose p = matrix.last();
|
||||||
|
PoseStack copy = new PoseStack();
|
||||||
|
copy.mulPoseMatrix(p.pose());
|
||||||
matrix.popPose();
|
matrix.popPose();
|
||||||
|
|
||||||
drawArms(player, partialticks, matrix, buffer, light);
|
drawArms(player, partialticks, matrix, buffer, light);
|
||||||
|
|
||||||
|
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
||||||
|
CarryRenderHelper.renderItem(state, tag, stack, tileItem, copy, buffer, light, model);
|
||||||
|
buffer.endBatch();
|
||||||
|
|
||||||
matrix.popPose();
|
matrix.popPose();
|
||||||
}
|
}
|
||||||
else if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
else if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||||
|
|
@ -399,14 +407,14 @@ public class RenderEvents
|
||||||
|
|
||||||
if (newEntity != null)
|
if (newEntity != null)
|
||||||
{
|
{
|
||||||
CompoundNBT nbttag = carryOverride.getRenderNBT();
|
CompoundTag nbttag = carryOverride.getRenderNBT();
|
||||||
if (nbttag != null)
|
if (nbttag != null)
|
||||||
newEntity.deserializeNBT(nbttag);
|
newEntity.deserializeNBT(nbttag);
|
||||||
entity = newEntity;
|
entity = newEntity;
|
||||||
entity.yRot = 0.0f;
|
entity.yo = 0.0f;
|
||||||
entity.yRotO = 0.0f;
|
entity.yRotO = 0.0f;
|
||||||
entity.setYHeadRot(0.0f);
|
entity.setYHeadRot(0.0f);
|
||||||
entity.xRot = 0.0f;
|
entity.xo = 0.0f;
|
||||||
entity.xRotO = 0.0f;
|
entity.xRotO = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -415,6 +423,8 @@ public class RenderEvents
|
||||||
if (entity instanceof LivingEntity)
|
if (entity instanceof LivingEntity)
|
||||||
((LivingEntity) entity).hurtTime = 0;
|
((LivingEntity) entity).hurtTime = 0;
|
||||||
|
|
||||||
|
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
||||||
manager.render(entity, 0, 0, 0, 0f, 0, matrix, buffer, light);
|
manager.render(entity, 0, 0, 0, 0f, 0, matrix, buffer, light);
|
||||||
buffer.endBatch();
|
buffer.endBatch();
|
||||||
|
|
||||||
|
|
@ -434,13 +444,14 @@ public class RenderEvents
|
||||||
RenderSystem.disableBlend();
|
RenderSystem.disableBlend();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyGeneralTransformations(PlayerEntity player, float partialticks, MatrixStack matrix)
|
@SuppressWarnings("resource")
|
||||||
|
private void applyGeneralTransformations(Player player, float partialticks, PoseStack matrix)
|
||||||
{
|
{
|
||||||
int perspective = CarryRenderHelper.getPerspective();
|
int perspective = CarryRenderHelper.getPerspective();
|
||||||
Quaternion playerrot = CarryRenderHelper.getExactBodyRotation(player, partialticks);
|
Quaternion playerrot = CarryRenderHelper.getExactBodyRotation(player, partialticks);
|
||||||
Vector3d playerpos = CarryRenderHelper.getExactPos(player, partialticks);
|
Vec3 playerpos = CarryRenderHelper.getExactPos(player, partialticks);
|
||||||
Vector3d cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
|
Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
|
||||||
Vector3d offset = playerpos.subtract(cameraPos);
|
Vec3 offset = playerpos.subtract(cameraPos);
|
||||||
Pose pose = player.getPose();
|
Pose pose = player.getPose();
|
||||||
|
|
||||||
matrix.pushPose();
|
matrix.pushPose();
|
||||||
|
|
@ -464,8 +475,8 @@ public class RenderEvents
|
||||||
if (pose == Pose.SWIMMING)
|
if (pose == Pose.SWIMMING)
|
||||||
{
|
{
|
||||||
float f = player.getSwimAmount(partialticks);
|
float f = player.getSwimAmount(partialticks);
|
||||||
float f3 = player.isInWater() ? -90.0F - player.xRot : -90.0F;
|
float f3 = player.isInWater() ? -90.0F - player.xRotO : -90.0F;
|
||||||
float f4 = MathHelper.lerp(f, 0.0F, f3);
|
float f4 = Mth.lerp(f, 0.0F, f3);
|
||||||
if (perspective == 2)
|
if (perspective == 2)
|
||||||
{
|
{
|
||||||
matrix.translate(0, 0, 1.35);
|
matrix.translate(0, 0, 1.35);
|
||||||
|
|
@ -482,22 +493,22 @@ public class RenderEvents
|
||||||
if (pose == Pose.FALL_FLYING)
|
if (pose == Pose.FALL_FLYING)
|
||||||
{
|
{
|
||||||
float f1 = (float) player.getFallFlyingTicks() + partialticks;
|
float f1 = (float) player.getFallFlyingTicks() + partialticks;
|
||||||
float f2 = MathHelper.clamp(f1 * f1 / 100.0F, 0.0F, 1.0F);
|
float f2 = Mth.clamp(f1 * f1 / 100.0F, 0.0F, 1.0F);
|
||||||
if (!player.isAutoSpinAttack())
|
if (!player.isAutoSpinAttack())
|
||||||
{
|
{
|
||||||
if (perspective == 2)
|
if (perspective == 2)
|
||||||
matrix.translate(0, 0, 1.35);
|
matrix.translate(0, 0, 1.35);
|
||||||
|
|
||||||
if (perspective == 2)
|
if (perspective == 2)
|
||||||
matrix.mulPose(Vector3f.XP.rotationDegrees(f2 * (-90.0F - player.xRot)));
|
matrix.mulPose(Vector3f.XP.rotationDegrees(f2 * (-90.0F - player.xRotO)));
|
||||||
else
|
else
|
||||||
matrix.mulPose(Vector3f.XN.rotationDegrees(f2 * (-90.0F - player.xRot)));
|
matrix.mulPose(Vector3f.XN.rotationDegrees(f2 * (-90.0F - player.xRotO)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3d Vector3d = player.getViewVector(partialticks);
|
Vec3 Vector3d = player.getViewVector(partialticks);
|
||||||
Vector3d Vector3d1 = player.getDeltaMovement();
|
Vec3 Vector3d1 = player.getDeltaMovement();
|
||||||
double d0 = Entity.getHorizontalDistanceSqr(Vector3d1);
|
double d0 = Vector3d1.horizontalDistanceSqr();
|
||||||
double d1 = Entity.getHorizontalDistanceSqr(Vector3d);
|
double d1 = Vector3d1.horizontalDistanceSqr();
|
||||||
if (d0 > 0.0D && d1 > 0.0D)
|
if (d0 > 0.0D && d1 > 0.0D)
|
||||||
{
|
{
|
||||||
double d2 = (Vector3d1.x * Vector3d.x + Vector3d1.z * Vector3d.z) / (Math.sqrt(d0) * Math.sqrt(d1));
|
double d2 = (Vector3d1.x * Vector3d.x + Vector3d1.z * Vector3d.z) / (Math.sqrt(d0) * Math.sqrt(d1));
|
||||||
|
|
@ -514,7 +525,7 @@ public class RenderEvents
|
||||||
matrix.translate(0, 1.6, 0.65);
|
matrix.translate(0, 1.6, 0.65);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyBlockTransformations(PlayerEntity player, float partialticks, MatrixStack matrix, Block block)
|
private void applyBlockTransformations(Player player, float partialticks, PoseStack matrix, Block block)
|
||||||
{
|
{
|
||||||
int perspective = CarryRenderHelper.getPerspective();
|
int perspective = CarryRenderHelper.getPerspective();
|
||||||
|
|
||||||
|
|
@ -533,7 +544,7 @@ public class RenderEvents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyEntityTransformations(PlayerEntity player, float partialticks, MatrixStack matrix, Entity entity)
|
private void applyEntityTransformations(Player player, float partialticks, PoseStack matrix, Entity entity)
|
||||||
{
|
{
|
||||||
int perspective = CarryRenderHelper.getPerspective();
|
int perspective = CarryRenderHelper.getPerspective();
|
||||||
Pose pose = player.getPose();
|
Pose pose = player.getPose();
|
||||||
|
|
@ -549,10 +560,10 @@ public class RenderEvents
|
||||||
float height = entity.getBbHeight();
|
float height = entity.getBbHeight();
|
||||||
float width = entity.getBbWidth();
|
float width = entity.getBbWidth();
|
||||||
float multiplier = height * width;
|
float multiplier = height * width;
|
||||||
entity.yRot = 0.0f;
|
entity.yo = 0.0f;
|
||||||
entity.yRotO = 0.0f;
|
entity.yRotO = 0.0f;
|
||||||
entity.setYHeadRot(0.0f);
|
entity.setYHeadRot(0.0f);
|
||||||
entity.xRot = 0.0f;
|
entity.xo = 0.0f;
|
||||||
entity.xRotO = 0.0f;
|
entity.xRotO = 0.0f;
|
||||||
|
|
||||||
if (perspective == 2)
|
if (perspective == 2)
|
||||||
|
|
@ -576,7 +587,7 @@ public class RenderEvents
|
||||||
* Renders correct arm rotation
|
* Renders correct arm rotation
|
||||||
*/
|
*/
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void drawArms(PlayerEntity player, float partialticks, MatrixStack matrix, IRenderTypeBuffer buffer, int light)
|
public void drawArms(Player player, float partialticks, PoseStack matrix, MultiBufferSource buffer, int light)
|
||||||
{
|
{
|
||||||
int perspective = CarryRenderHelper.getPerspective();
|
int perspective = CarryRenderHelper.getPerspective();
|
||||||
Pose pose = player.getPose();
|
Pose pose = player.getPose();
|
||||||
|
|
@ -592,19 +603,19 @@ public class RenderEvents
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||||
{
|
{
|
||||||
PlayerModel<AbstractClientPlayerEntity> model = getPlayerModel((AbstractClientPlayerEntity) player);
|
PlayerModel<AbstractClientPlayer> model = getPlayerModel((AbstractClientPlayer) player);
|
||||||
|
|
||||||
AbstractClientPlayerEntity aplayer = (AbstractClientPlayerEntity) player;
|
AbstractClientPlayer aplayer = (AbstractClientPlayer) player;
|
||||||
ResourceLocation skinLoc = aplayer.getSkinTextureLocation();
|
ResourceLocation skinLoc = aplayer.getSkinTextureLocation();
|
||||||
|
|
||||||
matrix.pushPose();
|
matrix.pushPose();
|
||||||
if (perspective == 2)
|
if (perspective == 2)
|
||||||
matrix.mulPose(Vector3f.YP.rotationDegrees(180));
|
matrix.mulPose(Vector3f.YP.rotationDegrees(180));
|
||||||
|
|
||||||
Minecraft.getInstance().getTextureManager().bind(skinLoc);
|
RenderSystem.setShaderTexture(0, skinLoc);
|
||||||
|
|
||||||
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
||||||
IVertexBuilder builder = buffer.getBuffer(RenderType.entityCutout(skinLoc));
|
VertexConsumer builder = buffer.getBuffer(RenderType.entityCutout(skinLoc));
|
||||||
|
|
||||||
if (overrider != null)
|
if (overrider != null)
|
||||||
{
|
{
|
||||||
|
|
@ -648,8 +659,8 @@ public class RenderEvents
|
||||||
renderArmPost(model.rightSleeve, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), true, doSneakCheck(player), light, matrix, builder);
|
renderArmPost(model.rightSleeve, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), true, doSneakCheck(player), light, matrix, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer instanceof Impl)
|
if (buffer instanceof BufferSource)
|
||||||
((Impl) buffer).endBatch();
|
((BufferSource) buffer).endBatch();
|
||||||
|
|
||||||
matrix.popPose();
|
matrix.popPose();
|
||||||
}
|
}
|
||||||
|
|
@ -668,12 +679,12 @@ public class RenderEvents
|
||||||
|
|
||||||
if (handleMobends() && !ModList.get().isLoaded("obfuscate"))
|
if (handleMobends() && !ModList.get().isLoaded("obfuscate"))
|
||||||
{
|
{
|
||||||
PlayerEntity player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Pose pose = player.getPose();
|
Pose pose = player.getPose();
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (pose != Pose.SWIMMING && pose != Pose.FALL_FLYING && !stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack)))
|
if (pose != Pose.SWIMMING && pose != Pose.FALL_FLYING && !stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack)))
|
||||||
{
|
{
|
||||||
PlayerModel<AbstractClientPlayerEntity> model = event.getRenderer().getModel();
|
PlayerModel<AbstractClientPlayer> model = event.getRenderer().getModel();
|
||||||
|
|
||||||
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
||||||
if (overrider != null)
|
if (overrider != null)
|
||||||
|
|
@ -706,7 +717,7 @@ public class RenderEvents
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
private void renderArmPost(ModelRenderer arm, float x, float z, boolean right, boolean sneaking, int light, MatrixStack matrix, IVertexBuilder builder)
|
private void renderArmPost(ModelPart arm, float x, float z, boolean right, boolean sneaking, int light, PoseStack matrix, VertexConsumer builder)
|
||||||
{
|
{
|
||||||
matrix.pushPose();
|
matrix.pushPose();
|
||||||
arm.visible = true;
|
arm.visible = true;
|
||||||
|
|
@ -729,7 +740,7 @@ public class RenderEvents
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
private void renderArmPre(ModelRenderer arm)
|
private void renderArmPre(ModelPart arm)
|
||||||
{
|
{
|
||||||
arm.visible = false;
|
arm.visible = false;
|
||||||
}
|
}
|
||||||
|
|
@ -750,9 +761,9 @@ public class RenderEvents
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean doSneakCheck(PlayerEntity player)
|
public static boolean doSneakCheck(Player player)
|
||||||
{
|
{
|
||||||
if (player.abilities.flying)
|
if (player.getAbilities().flying)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return (player.isShiftKeyDown() || player.isCrouching());
|
return (player.isShiftKeyDown() || player.isCrouching());
|
||||||
|
|
@ -764,15 +775,15 @@ public class RenderEvents
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
private static PlayerRenderer getRenderPlayer(AbstractClientPlayerEntity player)
|
private static PlayerRenderer getRenderPlayer(AbstractClientPlayer player)
|
||||||
{
|
{
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
EntityRendererManager manager = mc.getEntityRenderDispatcher();
|
EntityRenderDispatcher manager = mc.getEntityRenderDispatcher();
|
||||||
return manager.getSkinMap().get(player.getModelName());
|
return (PlayerRenderer) manager.getSkinMap().get(player.getModelName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
private static PlayerModel<AbstractClientPlayerEntity> getPlayerModel(AbstractClientPlayerEntity player)
|
private static PlayerModel<AbstractClientPlayer> getPlayerModel(AbstractClientPlayer player)
|
||||||
{
|
{
|
||||||
return getRenderPlayer(player).getModel();
|
return getRenderPlayer(player).getModel();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,28 @@
|
||||||
package tschipp.carryon.client.helper;
|
package tschipp.carryon.client.helper;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.math.Quaternion;
|
||||||
|
import com.mojang.math.Vector3f;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
||||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.util.math.vector.Quaternion;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
|
||||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||||
import tschipp.carryon.common.helper.ScriptParseHelper;
|
import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||||
|
|
||||||
public class CarryRenderHelper
|
public class CarryRenderHelper
|
||||||
{
|
{
|
||||||
public static Vector3d getExactPos(Entity entity, float partialticks)
|
public static Vec3 getExactPos(Entity entity, float partialticks)
|
||||||
{
|
{
|
||||||
return new Vector3d(entity.xOld + (entity.getX() - entity.xOld) * partialticks, entity.yOld + (entity.getY() - entity.yOld) * partialticks, entity.zOld + (entity.getZ() - entity.zOld) * partialticks);
|
return new Vec3(entity.xOld + (entity.getX() - entity.xOld) * partialticks, entity.yOld + (entity.getY() - entity.yOld) * partialticks, entity.zOld + (entity.getZ() - entity.zOld) * partialticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getExactBodyRotationDegrees(LivingEntity entity, float partialticks)
|
public static float getExactBodyRotationDegrees(LivingEntity entity, float partialticks)
|
||||||
|
|
@ -38,7 +38,7 @@ public class CarryRenderHelper
|
||||||
return Vector3f.YP.rotationDegrees(getExactBodyRotationDegrees(entity, partialticks));
|
return Vector3f.YP.rotationDegrees(getExactBodyRotationDegrees(entity, partialticks));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void performOverrideTransformation(MatrixStack matrix, CarryOnOverride override)
|
public static void performOverrideTransformation(PoseStack matrix, CarryOnOverride override)
|
||||||
{
|
{
|
||||||
int perspective = getPerspective();
|
int perspective = getPerspective();
|
||||||
|
|
||||||
|
|
@ -56,7 +56,7 @@ public class CarryRenderHelper
|
||||||
matrix.scale(scaled[0], scaled[1], scaled[2]);
|
matrix.scale(scaled[0], scaled[1], scaled[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renderItem(BlockState state, CompoundNBT tag, ItemStack stack, ItemStack tileStack, MatrixStack matrix, IRenderTypeBuffer buffer, int light, IBakedModel model)
|
public static void renderItem(BlockState state, CompoundTag tag, ItemStack stack, ItemStack tileStack, PoseStack matrix, MultiBufferSource buffer, int light, BakedModel model)
|
||||||
{
|
{
|
||||||
if (ModelOverridesHandler.hasCustomOverrideModel(state, tag))
|
if (ModelOverridesHandler.hasCustomOverrideModel(state, tag))
|
||||||
{
|
{
|
||||||
|
|
@ -72,6 +72,7 @@ public class CarryRenderHelper
|
||||||
Minecraft.getInstance().getItemRenderer().render(tileStack.isEmpty() ? stack : tileStack, TransformType.NONE, false, matrix, buffer, light, 0xFFFFFF, model);
|
Minecraft.getInstance().getItemRenderer().render(tileStack.isEmpty() ? stack : tileStack, TransformType.NONE, false, matrix, buffer, light, 0xFFFFFF, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public static int getPerspective()
|
public static int getPerspective()
|
||||||
{
|
{
|
||||||
boolean isThirdPerson = !Minecraft.getInstance().options.getCameraType().isFirstPerson(); //isThirdPerson
|
boolean isThirdPerson = !Minecraft.getInstance().options.getCameraType().isFirstPerson(); //isThirdPerson
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,29 @@
|
||||||
package tschipp.carryon.client.keybinds;
|
package tschipp.carryon.client.keybinds;
|
||||||
|
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.KeyMapping;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
import net.minecraftforge.fmlclient.registry.ClientRegistry;
|
||||||
|
|
||||||
public class CarryOnKeybinds
|
public class CarryOnKeybinds
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final String KEYBIND_KEY = "carryOnKeyPressed";
|
public static final String KEYBIND_KEY = "carryOnKeyPressed";
|
||||||
public static KeyBinding carryKey;
|
public static KeyMapping carryKey;
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public static void init()
|
public static void init()
|
||||||
{
|
{
|
||||||
carryKey = new KeyBinding("key.carry.desc", 340, "key.carry.category");
|
carryKey = new KeyMapping("key.carry.desc", 340, "key.carry.category");
|
||||||
|
|
||||||
ClientRegistry.registerKeyBinding(carryKey);
|
ClientRegistry.registerKeyBinding(carryKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isKeyPressed(PlayerEntity player)
|
public static boolean isKeyPressed(Player player)
|
||||||
{
|
{
|
||||||
CompoundNBT tag = player.getPersistentData();
|
CompoundTag tag = player.getPersistentData();
|
||||||
if(tag != null && tag.contains(KEYBIND_KEY))
|
if(tag != null && tag.contains(KEYBIND_KEY))
|
||||||
{
|
{
|
||||||
return tag.getBoolean(KEYBIND_KEY);
|
return tag.getBoolean(KEYBIND_KEY);
|
||||||
|
|
@ -31,9 +31,9 @@ public class CarryOnKeybinds
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setKeyPressed(PlayerEntity player, boolean pressed)
|
public static void setKeyPressed(Player player, boolean pressed)
|
||||||
{
|
{
|
||||||
CompoundNBT tag = player.getPersistentData();
|
CompoundTag tag = player.getPersistentData();
|
||||||
tag.putBoolean(KEYBIND_KEY, pressed);
|
tag.putBoolean(KEYBIND_KEY, pressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package tschipp.carryon.common.capabilities;
|
package tschipp.carryon.common.capabilities;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
||||||
public interface IPosition {
|
public interface IPosition {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,20 @@
|
||||||
package tschipp.carryon.common.capabilities;
|
package tschipp.carryon.common.capabilities;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||||
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
|
|
||||||
public class PositionProvider implements ICapabilitySerializable<CompoundNBT>
|
public class PositionProvider implements ICapabilitySerializable<CompoundTag>
|
||||||
{
|
{
|
||||||
|
|
||||||
@CapabilityInject(IPosition.class)
|
@CapabilityInject(IPosition.class)
|
||||||
public static final Capability<IPosition> POSITION_CAPABILITY = null;
|
public static final Capability<IPosition> POSITION_CAPABILITY = null;
|
||||||
|
|
||||||
private IPosition instance = POSITION_CAPABILITY.getDefaultInstance();
|
private IPosition instance = new TEPosition();//POSITION_CAPABILITY.getDefaultInstance();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -23,19 +24,36 @@ public class PositionProvider implements ICapabilitySerializable<CompoundNBT>
|
||||||
return (LazyOptional<T>) LazyOptional.of(() -> {
|
return (LazyOptional<T>) LazyOptional.of(() -> {
|
||||||
return new TEPosition();
|
return new TEPosition();
|
||||||
});
|
});
|
||||||
|
|
||||||
return LazyOptional.empty();
|
return LazyOptional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundNBT serializeNBT()
|
public CompoundTag serializeNBT()
|
||||||
{
|
{
|
||||||
return (CompoundNBT) POSITION_CAPABILITY.getStorage().writeNBT(POSITION_CAPABILITY, instance, null);
|
CompoundTag tag = new CompoundTag();
|
||||||
|
|
||||||
|
tag.putBoolean("blockActivated", instance.isBlockActivated());
|
||||||
|
tag.putInt("x", instance.getPos().getX());
|
||||||
|
tag.putInt("y", instance.getPos().getY());
|
||||||
|
tag.putInt("z", instance.getPos().getZ());
|
||||||
|
|
||||||
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deserializeNBT(CompoundNBT nbt)
|
public void deserializeNBT(CompoundTag nbt)
|
||||||
{
|
{
|
||||||
POSITION_CAPABILITY.getStorage().readNBT(POSITION_CAPABILITY, instance, null, nbt);
|
CompoundTag tag = (CompoundTag) nbt;
|
||||||
|
|
||||||
|
int x = tag.getInt("x");
|
||||||
|
int y = tag.getInt("y");
|
||||||
|
int z = tag.getInt("z");
|
||||||
|
|
||||||
|
BlockPos pos = new BlockPos(x,y,z);
|
||||||
|
|
||||||
|
instance.setPos(pos);
|
||||||
|
instance.setBlockActivated(tag.getBoolean("blockActivated"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
package tschipp.carryon.common.capabilities;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.nbt.INBT;
|
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability.IStorage;
|
|
||||||
|
|
||||||
public class PositionStorage implements IStorage<IPosition> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public INBT writeNBT(Capability<IPosition> capability, IPosition instance, Direction side) {
|
|
||||||
|
|
||||||
CompoundNBT tag = new CompoundNBT();
|
|
||||||
|
|
||||||
tag.putBoolean("blockActivated", instance.isBlockActivated());
|
|
||||||
tag.putInt("x", instance.getPos().getX());
|
|
||||||
tag.putInt("y", instance.getPos().getY());
|
|
||||||
tag.putInt("z", instance.getPos().getZ());
|
|
||||||
|
|
||||||
return tag;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readNBT(Capability<IPosition> capability, IPosition instance, Direction side, INBT nbt) {
|
|
||||||
|
|
||||||
CompoundNBT tag = (CompoundNBT) nbt;
|
|
||||||
|
|
||||||
int x = tag.getInt("x");
|
|
||||||
int y = tag.getInt("y");
|
|
||||||
int z = tag.getInt("z");
|
|
||||||
|
|
||||||
BlockPos pos = new BlockPos(x,y,z);
|
|
||||||
|
|
||||||
instance.setPos(pos);
|
|
||||||
instance.setBlockActivated(tag.getBoolean("blockActivated"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package tschipp.carryon.common.capabilities;
|
package tschipp.carryon.common.capabilities;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
||||||
public class TEPosition implements IPosition {
|
public class TEPosition implements IPosition {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
package tschipp.carryon.common.capabilities.event;
|
package tschipp.carryon.common.capabilities.event;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||||
|
|
@ -26,8 +26,8 @@ public class PositionClientEvents
|
||||||
{
|
{
|
||||||
if (event.getGui() != null)
|
if (event.getGui() != null)
|
||||||
{
|
{
|
||||||
PlayerEntity player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
boolean inventory = event.getGui() instanceof ContainerScreen;
|
boolean inventory = event.getGui() instanceof AbstractContainerScreen;
|
||||||
|
|
||||||
if (player != null && inventory)
|
if (player != null && inventory)
|
||||||
{
|
{
|
||||||
|
|
@ -36,11 +36,11 @@ public class PositionClientEvents
|
||||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
||||||
if(cap.isBlockActivated())
|
if(cap.isBlockActivated())
|
||||||
{
|
{
|
||||||
World world = player.level;
|
Level world = player.level;
|
||||||
BlockPos pos = cap.getPos();
|
BlockPos pos = cap.getPos();
|
||||||
if(world != null)
|
if(world != null)
|
||||||
{
|
{
|
||||||
TileEntity te = world.getBlockEntity(pos);
|
BlockEntity te = world.getBlockEntity(pos);
|
||||||
if(te == null)
|
if(te == null)
|
||||||
{
|
{
|
||||||
// player.openContainer = null;
|
// player.openContainer = null;
|
||||||
|
|
@ -60,7 +60,7 @@ public class PositionClientEvents
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onGuiClose(PlayerContainerEvent.Close event)
|
public void onGuiClose(PlayerContainerEvent.Close event)
|
||||||
{
|
{
|
||||||
PlayerEntity player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if(player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
if(player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
||||||
{
|
{
|
||||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
||||||
|
|
@ -76,7 +76,7 @@ public class PositionClientEvents
|
||||||
{
|
{
|
||||||
if (event.side == LogicalSide.CLIENT)
|
if (event.side == LogicalSide.CLIENT)
|
||||||
{
|
{
|
||||||
PlayerEntity player = event.player;
|
Player player = event.player;
|
||||||
if(player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
if(player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
||||||
{
|
{
|
||||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
package tschipp.carryon.common.capabilities.event;
|
package tschipp.carryon.common.capabilities.event;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraftforge.common.util.FakePlayer;
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
||||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||||
|
|
@ -21,7 +21,7 @@ public class PositionCommonEvents
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onAttachCaps(AttachCapabilitiesEvent<Entity> event)
|
public void onAttachCaps(AttachCapabilitiesEvent<Entity> event)
|
||||||
{
|
{
|
||||||
if (event.getObject() instanceof PlayerEntity)
|
if (event.getObject() instanceof Player)
|
||||||
{
|
{
|
||||||
event.addCapability(new ResourceLocation(CarryOn.MODID, "position"), new PositionProvider());
|
event.addCapability(new ResourceLocation(CarryOn.MODID, "position"), new PositionProvider());
|
||||||
}
|
}
|
||||||
|
|
@ -32,8 +32,8 @@ public class PositionCommonEvents
|
||||||
public void onBlockRight(PlayerInteractEvent.RightClickBlock event)
|
public void onBlockRight(PlayerInteractEvent.RightClickBlock event)
|
||||||
{
|
{
|
||||||
BlockPos pos = event.getPos();
|
BlockPos pos = event.getPos();
|
||||||
World world = event.getWorld();
|
Level world = event.getWorld();
|
||||||
PlayerEntity player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (event.isCanceled())
|
if (event.isCanceled())
|
||||||
return;
|
return;
|
||||||
|
|
@ -44,7 +44,7 @@ public class PositionCommonEvents
|
||||||
if (player instanceof FakePlayer)
|
if (player instanceof FakePlayer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TileEntity te = world.getBlockEntity(pos);
|
BlockEntity te = world.getBlockEntity(pos);
|
||||||
if (te != null)
|
if (te != null)
|
||||||
{
|
{
|
||||||
if(player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
if(player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,13 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
|
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.command.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.command.arguments.EntityArgument;
|
import net.minecraft.commands.arguments.EntityArgument;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.fml.network.PacketDistributor;
|
import net.minecraftforge.fmllegacy.network.PacketDistributor;
|
||||||
import tschipp.carryon.CarryOn;
|
import tschipp.carryon.CarryOn;
|
||||||
import tschipp.carryon.common.handler.CustomPickupOverrideHandler;
|
import tschipp.carryon.common.handler.CustomPickupOverrideHandler;
|
||||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||||
|
|
@ -24,9 +24,9 @@ import tschipp.carryon.network.client.CarrySlotPacket;
|
||||||
|
|
||||||
public class CommandCarryOn
|
public class CommandCarryOn
|
||||||
{
|
{
|
||||||
public static void register(CommandDispatcher<CommandSource> dispatcher)
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||||
{
|
{
|
||||||
LiteralArgumentBuilder<CommandSource> builder = Commands.literal("carryon")
|
LiteralArgumentBuilder<CommandSourceStack> builder = Commands.literal("carryon")
|
||||||
|
|
||||||
.then(Commands.literal("debug").executes((cmd) -> {
|
.then(Commands.literal("debug").executes((cmd) -> {
|
||||||
return handleDebug(cmd.getSource());
|
return handleDebug(cmd.getSource());
|
||||||
|
|
@ -46,26 +46,26 @@ public class CommandCarryOn
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int handleDebug(CommandSource source)
|
private static int handleDebug(CommandSourceStack source)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (source.getEntityOrException() != null)
|
if (source.getEntityOrException() != null)
|
||||||
{
|
{
|
||||||
ServerPlayerEntity player = source.getPlayerOrException();
|
ServerPlayer player = source.getPlayerOrException();
|
||||||
|
|
||||||
ItemStack main = player.getMainHandItem();
|
ItemStack main = player.getMainHandItem();
|
||||||
if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemTile)
|
if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemTile)
|
||||||
{
|
{
|
||||||
source.sendSuccess(new StringTextComponent("Block: " + ItemCarryonBlock.getBlock(main)), true);
|
source.sendSuccess(new TextComponent("Block: " + ItemCarryonBlock.getBlock(main)), true);
|
||||||
source.sendSuccess(new StringTextComponent("BlockState: " + ItemCarryonBlock.getBlockState(main)), true);
|
source.sendSuccess(new TextComponent("BlockState: " + ItemCarryonBlock.getBlockState(main)), true);
|
||||||
source.sendSuccess(new StringTextComponent("ItemStack: " + ItemCarryonBlock.getItemStack(main)), true);
|
source.sendSuccess(new TextComponent("ItemStack: " + ItemCarryonBlock.getItemStack(main)), true);
|
||||||
|
|
||||||
if (ModelOverridesHandler.hasCustomOverrideModel(ItemCarryonBlock.getBlockState(main), ItemCarryonBlock.getTileData(main)))
|
if (ModelOverridesHandler.hasCustomOverrideModel(ItemCarryonBlock.getBlockState(main), ItemCarryonBlock.getTileData(main)))
|
||||||
source.sendSuccess(new StringTextComponent("Override Model: " + ModelOverridesHandler.getOverrideObject(ItemCarryonBlock.getBlockState(main), ItemCarryonBlock.getTileData(main))), true);
|
source.sendSuccess(new TextComponent("Override Model: " + ModelOverridesHandler.getOverrideObject(ItemCarryonBlock.getBlockState(main), ItemCarryonBlock.getTileData(main))), true);
|
||||||
|
|
||||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemCarryonBlock.getBlockState(main)))
|
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemCarryonBlock.getBlockState(main)))
|
||||||
source.sendSuccess(new StringTextComponent("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemCarryonBlock.getBlockState(main))), true);
|
source.sendSuccess(new TextComponent("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemCarryonBlock.getBlockState(main))), true);
|
||||||
|
|
||||||
CarryOn.LOGGER.info("Block: " + ItemCarryonBlock.getBlock(main));
|
CarryOn.LOGGER.info("Block: " + ItemCarryonBlock.getBlock(main));
|
||||||
CarryOn.LOGGER.info("BlockState: " + ItemCarryonBlock.getBlockState(main));
|
CarryOn.LOGGER.info("BlockState: " + ItemCarryonBlock.getBlockState(main));
|
||||||
|
|
@ -81,11 +81,11 @@ public class CommandCarryOn
|
||||||
}
|
}
|
||||||
else if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity)
|
else if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity)
|
||||||
{
|
{
|
||||||
source.sendSuccess(new StringTextComponent("Entity: " + ItemCarryonEntity.getEntity(main, player.level)), true);
|
source.sendSuccess(new TextComponent("Entity: " + ItemCarryonEntity.getEntity(main, player.level)), true);
|
||||||
source.sendSuccess(new StringTextComponent("Entity Name: " + ItemCarryonEntity.getEntityName(main)), true);
|
source.sendSuccess(new TextComponent("Entity Name: " + ItemCarryonEntity.getEntityName(main)), true);
|
||||||
|
|
||||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemCarryonEntity.getEntity(main, player.level)))
|
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemCarryonEntity.getEntity(main, player.level)))
|
||||||
source.sendSuccess(new StringTextComponent("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemCarryonEntity.getEntity(main, player.level))), true);
|
source.sendSuccess(new TextComponent("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemCarryonEntity.getEntity(main, player.level))), true);
|
||||||
|
|
||||||
CarryOn.LOGGER.info("Entity: " + ItemCarryonEntity.getEntity(main, player.level));
|
CarryOn.LOGGER.info("Entity: " + ItemCarryonEntity.getEntity(main, player.level));
|
||||||
CarryOn.LOGGER.info("Entity Name: " + ItemCarryonEntity.getEntityName(main));
|
CarryOn.LOGGER.info("Entity Name: " + ItemCarryonEntity.getEntityName(main));
|
||||||
|
|
@ -106,20 +106,20 @@ public class CommandCarryOn
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int handleClear(CommandSource source, Collection<ServerPlayerEntity> players)
|
private static int handleClear(CommandSourceStack source, Collection<ServerPlayer> players)
|
||||||
{
|
{
|
||||||
for (ServerPlayerEntity player : players)
|
for (ServerPlayer player : players)
|
||||||
{
|
{
|
||||||
int cleared = 0;
|
int cleared = 0;
|
||||||
cleared += player.inventory.clearOrCountMatchingItems(stack -> !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile, 64, player.inventoryMenu.getCraftSlots()); // TODO
|
cleared += player.getInventory().clearOrCountMatchingItems(stack -> !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile, 64, player.inventoryMenu.getCraftSlots()); // TODO
|
||||||
cleared += player.inventory.clearOrCountMatchingItems(stack -> !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity, 64, player.inventoryMenu.getCraftSlots());
|
cleared += player.getInventory().clearOrCountMatchingItems(stack -> !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity, 64, player.inventoryMenu.getCraftSlots());
|
||||||
|
|
||||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new CarrySlotPacket(9, player.getId()));
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new CarrySlotPacket(9, player.getId()));
|
||||||
|
|
||||||
if (cleared != 1)
|
if (cleared != 1)
|
||||||
source.sendSuccess(new StringTextComponent("Cleared " + cleared + " Items!"), true);
|
source.sendSuccess(new TextComponent("Cleared " + cleared + " Items!"), true);
|
||||||
else
|
else
|
||||||
source.sendSuccess(new StringTextComponent("Cleared " + cleared + " Item!"), true);
|
source.sendSuccess(new TextComponent("Cleared " + cleared + " Item!"), true);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import net.minecraftforge.common.ForgeConfigSpec.IntValue;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
||||||
import net.minecraftforge.fml.config.ModConfig;
|
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||||
import tschipp.carryon.CarryOn;
|
import tschipp.carryon.CarryOn;
|
||||||
import tschipp.carryon.common.handler.ListHandler;
|
import tschipp.carryon.common.handler.ListHandler;
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ public class Configs {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onLoad(final ModConfig.Loading event)
|
public static void onLoad(final ModConfigEvent.Loading event)
|
||||||
{
|
{
|
||||||
if (event.getConfig().getModId().equals(CarryOn.MODID))
|
if (event.getConfig().getModId().equals(CarryOn.MODID))
|
||||||
{
|
{
|
||||||
|
|
@ -54,7 +54,7 @@ public class Configs {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onConfigChanged(ModConfig.Reloading event)
|
public static void onConfigChanged(ModConfigEvent.Reloading event)
|
||||||
{
|
{
|
||||||
if (event.getConfig().getModId().equals(CarryOn.MODID))
|
if (event.getConfig().getModId().equals(CarryOn.MODID))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import net.minecraftforge.eventbus.api.EventPriority;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.InterModComms;
|
import net.minecraftforge.fml.InterModComms;
|
||||||
import net.minecraftforge.fml.InterModComms.IMCMessage;
|
import net.minecraftforge.fml.InterModComms.IMCMessage;
|
||||||
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
import net.minecraftforge.fmlserverevents.FMLServerStartingEvent;
|
||||||
import tschipp.carryon.CarryOn;
|
import tschipp.carryon.CarryOn;
|
||||||
import tschipp.carryon.common.handler.ListHandler;
|
import tschipp.carryon.common.handler.ListHandler;
|
||||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||||
|
|
@ -21,8 +21,8 @@ public class IMCEvents
|
||||||
|
|
||||||
messages.forEach((msg) -> {
|
messages.forEach((msg) -> {
|
||||||
|
|
||||||
String method = msg.getMethod();
|
String method = msg.method();
|
||||||
Object obj = msg.getMessageSupplier().get();
|
Object obj = msg.messageSupplier().get();
|
||||||
|
|
||||||
if(!(obj instanceof String))
|
if(!(obj instanceof String))
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -2,22 +2,22 @@ package tschipp.carryon.common.event;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.entity.passive.AnimalEntity;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.entity.passive.horse.HorseEntity;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.world.entity.animal.Animal;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.world.entity.animal.horse.Horse;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.util.SoundCategory;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.util.SoundEvents;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||||
|
|
@ -42,7 +42,7 @@ public class ItemEntityEvents
|
||||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||||
public void onBlockClick(PlayerInteractEvent.RightClickBlock event)
|
public void onBlockClick(PlayerInteractEvent.RightClickBlock event)
|
||||||
{
|
{
|
||||||
PlayerEntity player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||||
{
|
{
|
||||||
|
|
@ -68,10 +68,10 @@ public class ItemEntityEvents
|
||||||
public void onItemDropped(EntityJoinWorldEvent event)
|
public void onItemDropped(EntityJoinWorldEvent event)
|
||||||
{
|
{
|
||||||
Entity e = event.getEntity();
|
Entity e = event.getEntity();
|
||||||
World world = event.getWorld();
|
Level world = event.getWorld();
|
||||||
if (e instanceof net.minecraft.entity.item.ItemEntity)
|
if (e instanceof net.minecraft.world.entity.item.ItemEntity)
|
||||||
{
|
{
|
||||||
net.minecraft.entity.item.ItemEntity eitem = (net.minecraft.entity.item.ItemEntity) e;
|
net.minecraft.world.entity.item.ItemEntity eitem = (net.minecraft.world.entity.item.ItemEntity) e;
|
||||||
ItemStack stack = eitem.getItem();
|
ItemStack stack = eitem.getItem();
|
||||||
Item item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
if (item == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
if (item == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||||
|
|
@ -90,13 +90,13 @@ public class ItemEntityEvents
|
||||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||||
public void onEntityRightClick(PlayerInteractEvent.EntityInteract event)
|
public void onEntityRightClick(PlayerInteractEvent.EntityInteract event)
|
||||||
{
|
{
|
||||||
PlayerEntity player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (player instanceof ServerPlayerEntity)
|
if (player instanceof ServerPlayer)
|
||||||
{
|
{
|
||||||
ItemStack main = player.getMainHandItem();
|
ItemStack main = player.getMainHandItem();
|
||||||
ItemStack off = player.getOffhandItem();
|
ItemStack off = player.getOffhandItem();
|
||||||
World world = event.getWorld();
|
Level world = event.getWorld();
|
||||||
Entity entity = event.getTarget();
|
Entity entity = event.getTarget();
|
||||||
BlockPos pos = entity.blockPosition();
|
BlockPos pos = entity.blockPosition();
|
||||||
|
|
||||||
|
|
@ -106,10 +106,10 @@ public class ItemEntityEvents
|
||||||
|
|
||||||
if (entity.invulnerableTime == 0)
|
if (entity.invulnerableTime == 0)
|
||||||
{
|
{
|
||||||
if (entity instanceof AnimalEntity)
|
if (entity instanceof Animal)
|
||||||
((AnimalEntity) entity).dropLeash(true, true);
|
((Animal) entity).dropLeash(true, true);
|
||||||
|
|
||||||
if (PickupHandler.canPlayerPickUpEntity((ServerPlayerEntity) player, entity))
|
if (PickupHandler.canPlayerPickUpEntity((ServerPlayer) player, entity))
|
||||||
{
|
{
|
||||||
if (ItemCarryonEntity.storeEntityData(entity, world, stack))
|
if (ItemCarryonEntity.storeEntityData(entity, world, stack))
|
||||||
{
|
{
|
||||||
|
|
@ -127,17 +127,17 @@ public class ItemEntityEvents
|
||||||
if (override != null)
|
if (override != null)
|
||||||
overrideHash = override.hashCode();
|
overrideHash = override.hashCode();
|
||||||
|
|
||||||
ItemEvents.sendPacket(player, player.inventory.selected, overrideHash);
|
ItemEvents.sendPacket(player, player.getInventory().selected, overrideHash);
|
||||||
|
|
||||||
if (entity instanceof LivingEntity)
|
if (entity instanceof LivingEntity)
|
||||||
((LivingEntity) entity).setHealth(0);
|
((LivingEntity) entity).setHealth(0);
|
||||||
|
|
||||||
entity.ejectPassengers();
|
entity.ejectPassengers();
|
||||||
entity.setPos(entity.getX(), 0, entity.getZ());
|
entity.setPos(entity.getX(), 0, entity.getZ());
|
||||||
entity.remove();
|
entity.discard();
|
||||||
player.setItemInHand(Hand.MAIN_HAND, stack);
|
player.setItemInHand(InteractionHand.MAIN_HAND, stack);
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
event.setCancellationResult(ActionResultType.FAIL);
|
event.setCancellationResult(InteractionResult.FAIL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -165,9 +165,9 @@ public class ItemEntityEvents
|
||||||
double sizeEntity = topEntity.getBbHeight() * topEntity.getBbWidth();
|
double sizeEntity = topEntity.getBbHeight() * topEntity.getBbWidth();
|
||||||
if ((Settings.entitySizeMattersStacking.get() && sizeHeldEntity <= sizeEntity) || !Settings.entitySizeMattersStacking.get())
|
if ((Settings.entitySizeMattersStacking.get() && sizeHeldEntity <= sizeEntity) || !Settings.entitySizeMattersStacking.get())
|
||||||
{
|
{
|
||||||
if (topEntity instanceof HorseEntity)
|
if (topEntity instanceof Horse)
|
||||||
{
|
{
|
||||||
HorseEntity horse = (HorseEntity) topEntity;
|
Horse horse = (Horse) topEntity;
|
||||||
horse.setTamed(true);
|
horse.setTamed(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -188,20 +188,20 @@ public class ItemEntityEvents
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemCarryonEntity.clearEntityData(main);
|
ItemCarryonEntity.clearEntityData(main);
|
||||||
player.setItemInHand(Hand.MAIN_HAND, ItemStack.EMPTY);
|
player.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);
|
||||||
ItemEvents.sendPacket(player, 9, 0);
|
ItemEvents.sendPacket(player, 9, 0);
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
event.setCancellationResult(ActionResultType.FAIL);
|
event.setCancellationResult(InteractionResult.FAIL);
|
||||||
world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.HORSE_SADDLE, SoundCategory.PLAYERS, 0.5F, 1.5F);
|
world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.HORSE_SADDLE, SoundSource.PLAYERS, 0.5F, 1.5F);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.NOTE_BLOCK_BASS, SoundCategory.PLAYERS, 0.5F, 1.5F);
|
world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.NOTE_BLOCK_BASS, SoundSource.PLAYERS, 0.5F, 1.5F);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.NOTE_BLOCK_BASS, SoundCategory.PLAYERS, 0.5F, 1.5F);
|
world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.NOTE_BLOCK_BASS, SoundSource.PLAYERS, 0.5F, 1.5F);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -249,7 +249,7 @@ public class ItemEntityEvents
|
||||||
public void onLivingUpdate(LivingUpdateEvent event)
|
public void onLivingUpdate(LivingUpdateEvent event)
|
||||||
{
|
{
|
||||||
LivingEntity entity = event.getEntityLiving();
|
LivingEntity entity = event.getEntityLiving();
|
||||||
World world = entity.level;
|
Level world = entity.level;
|
||||||
ItemStack main = entity.getMainHandItem();
|
ItemStack main = entity.getMainHandItem();
|
||||||
if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(main))
|
if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(main))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,28 +2,28 @@ package tschipp.carryon.common.event;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.network.chat.ClickEvent;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.network.chat.ClickEvent.Action;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.item.DirectionalPlaceContext;
|
import net.minecraft.world.Container;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.world.entity.item.ItemEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.world.item.context.DirectionalPlaceContext;
|
||||||
import net.minecraft.util.text.event.ClickEvent;
|
import net.minecraft.world.level.GameRules;
|
||||||
import net.minecraft.util.text.event.ClickEvent.Action;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.GameRules;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||||
import net.minecraftforge.event.TagsUpdatedEvent;
|
import net.minecraftforge.event.TagsUpdatedEvent;
|
||||||
|
|
@ -41,9 +41,9 @@ import net.minecraftforge.eventbus.api.Event.Result;
|
||||||
import net.minecraftforge.eventbus.api.EventPriority;
|
import net.minecraftforge.eventbus.api.EventPriority;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
import net.minecraftforge.fmllegacy.network.PacketDistributor;
|
||||||
import net.minecraftforge.fml.network.PacketDistributor;
|
import net.minecraftforge.fmllegacy.network.PacketDistributor.TargetPoint;
|
||||||
import net.minecraftforge.fml.network.PacketDistributor.TargetPoint;
|
import net.minecraftforge.fmlserverevents.FMLServerStartingEvent;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import tschipp.carryon.CarryOn;
|
import tschipp.carryon.CarryOn;
|
||||||
|
|
@ -71,7 +71,7 @@ public class ItemEvents
|
||||||
if (event.isCanceled())
|
if (event.isCanceled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PlayerEntity player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack))
|
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack))
|
||||||
{
|
{
|
||||||
|
|
@ -97,24 +97,24 @@ public class ItemEvents
|
||||||
public void onItemDropped(EntityJoinWorldEvent event)
|
public void onItemDropped(EntityJoinWorldEvent event)
|
||||||
{
|
{
|
||||||
Entity e = event.getEntity();
|
Entity e = event.getEntity();
|
||||||
World world = event.getWorld();
|
Level world = event.getWorld();
|
||||||
if (e instanceof net.minecraft.entity.item.ItemEntity)
|
if (e instanceof net.minecraft.world.entity.item.ItemEntity)
|
||||||
{
|
{
|
||||||
net.minecraft.entity.item.ItemEntity eitem = (net.minecraft.entity.item.ItemEntity) e;
|
net.minecraft.world.entity.item.ItemEntity eitem = (net.minecraft.world.entity.item.ItemEntity) e;
|
||||||
ItemStack stack = eitem.getItem();
|
ItemStack stack = eitem.getItem();
|
||||||
Item item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
if (item == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack))
|
if (item == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack))
|
||||||
{
|
{
|
||||||
BlockPos pos = eitem.blockPosition();
|
BlockPos pos = eitem.blockPosition();
|
||||||
BlockPos finalPos = pos;
|
BlockPos finalPos = pos;
|
||||||
BlockItemUseContext context = new DirectionalPlaceContext(world, pos, Direction.DOWN, stack, Direction.UP);
|
BlockPlaceContext context = new DirectionalPlaceContext(world, pos, Direction.DOWN, stack, Direction.UP);
|
||||||
|
|
||||||
if (!world.getBlockState(pos).canBeReplaced(context) || !context.canPlace())
|
if (!world.getBlockState(pos).canBeReplaced(context) || !context.canPlace())
|
||||||
{
|
{
|
||||||
for (Direction facing : Direction.values())
|
for (Direction facing : Direction.values())
|
||||||
{
|
{
|
||||||
BlockPos offsetPos = pos.relative(facing);
|
BlockPos offsetPos = pos.relative(facing);
|
||||||
BlockItemUseContext newContext = new DirectionalPlaceContext(world, offsetPos, Direction.DOWN, stack, Direction.UP);
|
BlockPlaceContext newContext = new DirectionalPlaceContext(world, offsetPos, Direction.DOWN, stack, Direction.UP);
|
||||||
if (world.getBlockState(offsetPos).canBeReplaced(newContext) && newContext.canPlace())
|
if (world.getBlockState(offsetPos).canBeReplaced(newContext) && newContext.canPlace())
|
||||||
{
|
{
|
||||||
finalPos = offsetPos;
|
finalPos = offsetPos;
|
||||||
|
|
@ -123,11 +123,12 @@ public class ItemEvents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
world.setBlockAndUpdate(finalPos, ItemCarryonBlock.getBlockState(stack));
|
world.setBlockAndUpdate(finalPos, ItemCarryonBlock.getBlockState(stack));
|
||||||
TileEntity tile = world.getBlockEntity(finalPos);
|
BlockEntity tile = world.getBlockEntity(finalPos);
|
||||||
if (tile != null)
|
if (tile != null)
|
||||||
{
|
{
|
||||||
tile.deserializeNBT(ItemCarryonBlock.getTileData(stack));
|
var nbt = ItemCarryonBlock.getTileData(stack);
|
||||||
tile.setPosition(finalPos);
|
ItemCarryonBlock.updateTileLocation(nbt, finalPos);
|
||||||
|
tile.load(nbt);
|
||||||
}
|
}
|
||||||
ItemCarryonBlock.clearTileData(stack);
|
ItemCarryonBlock.clearTileData(stack);
|
||||||
eitem.setItem(ItemStack.EMPTY);
|
eitem.setItem(ItemStack.EMPTY);
|
||||||
|
|
@ -145,10 +146,10 @@ public class ItemEvents
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onPlayerLogin(PlayerLoggedInEvent event)
|
public void onPlayerLogin(PlayerLoggedInEvent event)
|
||||||
{
|
{
|
||||||
if (event.getPlayer() instanceof PlayerEntity)
|
if (event.getPlayer() instanceof Player)
|
||||||
{
|
{
|
||||||
PlayerEntity player = (PlayerEntity) event.getPlayer();
|
Player player = (Player) event.getPlayer();
|
||||||
World world = player.getCommandSenderWorld();
|
Level world = player.getCommandSenderWorld();
|
||||||
|
|
||||||
ItemStack carried = player.getMainHandItem();
|
ItemStack carried = player.getMainHandItem();
|
||||||
if (!carried.isEmpty() && carried.getItem() == RegistrationHandler.itemTile || carried.getItem() == RegistrationHandler.itemEntity)
|
if (!carried.isEmpty() && carried.getItem() == RegistrationHandler.itemTile || carried.getItem() == RegistrationHandler.itemEntity)
|
||||||
|
|
@ -157,24 +158,24 @@ public class ItemEvents
|
||||||
{
|
{
|
||||||
CarryOnOverride override = ScriptChecker.inspectBlock(ItemCarryonBlock.getBlockState(carried), world, player.blockPosition(), ItemCarryonBlock.getTileData(carried));
|
CarryOnOverride override = ScriptChecker.inspectBlock(ItemCarryonBlock.getBlockState(carried), world, player.blockPosition(), ItemCarryonBlock.getTileData(carried));
|
||||||
if (override != null)
|
if (override != null)
|
||||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new CarrySlotPacket(player.inventory.selected, player.getId(), override.hashCode()));
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new CarrySlotPacket(player.getInventory().selected, player.getId(), override.hashCode()));
|
||||||
else
|
else
|
||||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new CarrySlotPacket(player.inventory.selected, player.getId()));
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new CarrySlotPacket(player.getInventory().selected, player.getId()));
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
CarryOnOverride override = ScriptChecker.inspectEntity(ItemCarryonEntity.getEntity(carried, world));
|
CarryOnOverride override = ScriptChecker.inspectEntity(ItemCarryonEntity.getEntity(carried, world));
|
||||||
if (override != null)
|
if (override != null)
|
||||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new CarrySlotPacket(player.inventory.selected, player.getId(), override.hashCode()));
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new CarrySlotPacket(player.getInventory().selected, player.getId(), override.hashCode()));
|
||||||
else
|
else
|
||||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new CarrySlotPacket(player.inventory.selected, player.getId()));
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new CarrySlotPacket(player.getInventory().selected, player.getId()));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(event.getPlayer() instanceof ServerPlayerEntity)
|
if(event.getPlayer() instanceof ServerPlayer)
|
||||||
{
|
{
|
||||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity)event.getPlayer()), new ScriptReloadPacket(ScriptReader.OVERRIDES.values()));
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)event.getPlayer()), new ScriptReloadPacket(ScriptReader.OVERRIDES.values()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -201,12 +202,12 @@ public class ItemEvents
|
||||||
public void onEntityStartTracking(StartTracking event)
|
public void onEntityStartTracking(StartTracking event)
|
||||||
{
|
{
|
||||||
Entity e = event.getTarget();
|
Entity e = event.getTarget();
|
||||||
PlayerEntity tracker = event.getPlayer();
|
Player tracker = event.getPlayer();
|
||||||
|
|
||||||
if (e instanceof PlayerEntity && tracker instanceof ServerPlayerEntity)
|
if (e instanceof Player && tracker instanceof ServerPlayer)
|
||||||
{
|
{
|
||||||
PlayerEntity player = (PlayerEntity) e;
|
Player player = (Player) e;
|
||||||
World world = player.getCommandSenderWorld();
|
Level world = player.getCommandSenderWorld();
|
||||||
|
|
||||||
ItemStack carried = player.getMainHandItem();
|
ItemStack carried = player.getMainHandItem();
|
||||||
if (!carried.isEmpty() && carried.getItem() == RegistrationHandler.itemTile || carried.getItem() == RegistrationHandler.itemEntity)
|
if (!carried.isEmpty() && carried.getItem() == RegistrationHandler.itemTile || carried.getItem() == RegistrationHandler.itemEntity)
|
||||||
|
|
@ -215,16 +216,16 @@ public class ItemEvents
|
||||||
{
|
{
|
||||||
CarryOnOverride override = ScriptChecker.inspectBlock(ItemCarryonBlock.getBlockState(carried), world, player.blockPosition(), ItemCarryonBlock.getTileData(carried));
|
CarryOnOverride override = ScriptChecker.inspectBlock(ItemCarryonBlock.getBlockState(carried), world, player.blockPosition(), ItemCarryonBlock.getTileData(carried));
|
||||||
if (override != null)
|
if (override != null)
|
||||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) tracker), new CarrySlotPacket(player.inventory.selected, player.getId(), override.hashCode()));
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) tracker), new CarrySlotPacket(player.getInventory().selected, player.getId(), override.hashCode()));
|
||||||
else
|
else
|
||||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) tracker), new CarrySlotPacket(player.inventory.selected, player.getId()));
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) tracker), new CarrySlotPacket(player.getInventory().selected, player.getId()));
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
CarryOnOverride override = ScriptChecker.inspectEntity(ItemCarryonEntity.getEntity(carried, world));
|
CarryOnOverride override = ScriptChecker.inspectEntity(ItemCarryonEntity.getEntity(carried, world));
|
||||||
if (override != null)
|
if (override != null)
|
||||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) tracker), new CarrySlotPacket(player.inventory.selected, player.getId(), override.hashCode()));
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) tracker), new CarrySlotPacket(player.getInventory().selected, player.getId(), override.hashCode()));
|
||||||
else
|
else
|
||||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) tracker), new CarrySlotPacket(player.inventory.selected, player.getId()));
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) tracker), new CarrySlotPacket(player.getInventory().selected, player.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -234,7 +235,7 @@ public class ItemEvents
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void harvestSpeed(BreakSpeed event)
|
public void harvestSpeed(BreakSpeed event)
|
||||||
{
|
{
|
||||||
PlayerEntity player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player != null && !Settings.hitWhileCarrying.get())
|
if (player != null && !Settings.hitWhileCarrying.get())
|
||||||
{
|
{
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
@ -246,7 +247,7 @@ public class ItemEvents
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void attackEntity(AttackEntityEvent event)
|
public void attackEntity(AttackEntityEvent event)
|
||||||
{
|
{
|
||||||
PlayerEntity player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!stack.isEmpty() && !Settings.hitWhileCarrying.get() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
if (!stack.isEmpty() && !Settings.hitWhileCarrying.get() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
||||||
{
|
{
|
||||||
|
|
@ -257,7 +258,7 @@ public class ItemEvents
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void harvestSpeed(BreakEvent event)
|
public void harvestSpeed(BreakEvent event)
|
||||||
{
|
{
|
||||||
PlayerEntity player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player != null && !Settings.hitWhileCarrying.get())
|
if (player != null && !Settings.hitWhileCarrying.get())
|
||||||
{
|
{
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
@ -270,15 +271,15 @@ public class ItemEvents
|
||||||
public void playerAttack(LivingAttackEvent event)
|
public void playerAttack(LivingAttackEvent event)
|
||||||
{
|
{
|
||||||
LivingEntity eliving = event.getEntityLiving();
|
LivingEntity eliving = event.getEntityLiving();
|
||||||
if (eliving instanceof PlayerEntity && Settings.dropCarriedWhenHit.get())
|
if (eliving instanceof Player && Settings.dropCarriedWhenHit.get())
|
||||||
{
|
{
|
||||||
PlayerEntity player = (PlayerEntity) eliving;
|
Player player = (Player) eliving;
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
||||||
{
|
{
|
||||||
if (!player.level.isClientSide)
|
if (!player.level.isClientSide)
|
||||||
{
|
{
|
||||||
player.setItemInHand(Hand.MAIN_HAND, ItemStack.EMPTY);
|
player.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);
|
||||||
ItemEntity item = new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), stack);
|
ItemEntity item = new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), stack);
|
||||||
sendPacket(player, 9, 0);
|
sendPacket(player, 9, 0);
|
||||||
player.level.addFreshEntity(item);
|
player.level.addFreshEntity(item);
|
||||||
|
|
@ -291,7 +292,7 @@ public class ItemEvents
|
||||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||||
public static void onBlockRightClick(PlayerInteractEvent.RightClickBlock event)
|
public static void onBlockRightClick(PlayerInteractEvent.RightClickBlock event)
|
||||||
{
|
{
|
||||||
PlayerEntity player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if(event.isCanceled())
|
if(event.isCanceled())
|
||||||
return;
|
return;
|
||||||
|
|
@ -301,7 +302,7 @@ public class ItemEvents
|
||||||
|
|
||||||
ItemStack main = player.getMainHandItem();
|
ItemStack main = player.getMainHandItem();
|
||||||
ItemStack off = player.getOffhandItem();
|
ItemStack off = player.getOffhandItem();
|
||||||
World world = event.getWorld();
|
Level world = event.getWorld();
|
||||||
BlockPos pos = event.getPos();
|
BlockPos pos = event.getPos();
|
||||||
BlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
|
|
||||||
|
|
@ -310,8 +311,8 @@ public class ItemEvents
|
||||||
|
|
||||||
ItemStack stack = new ItemStack(RegistrationHandler.itemTile);
|
ItemStack stack = new ItemStack(RegistrationHandler.itemTile);
|
||||||
|
|
||||||
TileEntity te = world.getBlockEntity(pos);
|
BlockEntity te = world.getBlockEntity(pos);
|
||||||
if (PickupHandler.canPlayerPickUpBlock((ServerPlayerEntity) player, te, world, pos))
|
if (PickupHandler.canPlayerPickUpBlock((ServerPlayer) player, te, world, pos))
|
||||||
{
|
{
|
||||||
player.closeContainer();
|
player.closeContainer();
|
||||||
world.levelEvent(1010, pos, 0);
|
world.levelEvent(1010, pos, 0);
|
||||||
|
|
@ -321,8 +322,8 @@ public class ItemEvents
|
||||||
{
|
{
|
||||||
|
|
||||||
BlockState statee = world.getBlockState(pos);
|
BlockState statee = world.getBlockState(pos);
|
||||||
CompoundNBT tag = new CompoundNBT();
|
CompoundTag tag = new CompoundTag();
|
||||||
tag = world.getBlockEntity(pos) != null ? world.getBlockEntity(pos).save(tag) : new CompoundNBT();
|
tag = world.getBlockEntity(pos) != null ? world.getBlockEntity(pos).save(tag) : new CompoundTag();
|
||||||
CarryOnOverride override = ScriptChecker.inspectBlock(state, world, pos, tag);
|
CarryOnOverride override = ScriptChecker.inspectBlock(state, world, pos, tag);
|
||||||
int overrideHash = 0;
|
int overrideHash = 0;
|
||||||
if (override != null)
|
if (override != null)
|
||||||
|
|
@ -332,11 +333,11 @@ public class ItemEvents
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
sendPacket(player, player.inventory.selected, overrideHash);
|
sendPacket(player, player.getInventory().selected, overrideHash);
|
||||||
|
|
||||||
world.removeBlockEntity(pos);
|
world.removeBlockEntity(pos);
|
||||||
world.removeBlock(pos, false);
|
world.removeBlock(pos, false);
|
||||||
player.setItemInHand(Hand.MAIN_HAND, stack);
|
player.setItemInHand(InteractionHand.MAIN_HAND, stack);
|
||||||
event.setUseBlock(Result.DENY);
|
event.setUseBlock(Result.DENY);
|
||||||
event.setUseItem(Result.DENY);
|
event.setUseItem(Result.DENY);
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
|
|
@ -345,10 +346,10 @@ public class ItemEvents
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
sendPacket(player, player.inventory.selected, overrideHash);
|
sendPacket(player, player.getInventory().selected, overrideHash);
|
||||||
emptyTileEntity(te);
|
emptyTileEntity(te);
|
||||||
world.removeBlock(pos,false);
|
world.removeBlock(pos,false);
|
||||||
player.setItemInHand(Hand.MAIN_HAND, stack);
|
player.setItemInHand(InteractionHand.MAIN_HAND, stack);
|
||||||
event.setUseBlock(Result.DENY);
|
event.setUseBlock(Result.DENY);
|
||||||
event.setUseItem(Result.DENY);
|
event.setUseItem(Result.DENY);
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
|
|
@ -359,13 +360,13 @@ public class ItemEvents
|
||||||
world.setBlockAndUpdate(pos, statee);
|
world.setBlockAndUpdate(pos, statee);
|
||||||
if (!tag.isEmpty())
|
if (!tag.isEmpty())
|
||||||
{
|
{
|
||||||
TileEntity.loadStatic(statee, tag);
|
BlockEntity.loadStatic(pos, statee, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.displayClientMessage(new StringTextComponent(TextFormatting.RED + "Error detected. Cannot pick up block."), false);
|
player.displayClientMessage(new TextComponent(ChatFormatting.RED + "Error detected. Cannot pick up block."), false);
|
||||||
StringTextComponent s = new StringTextComponent(TextFormatting.GOLD + "here");
|
TextComponent s = new TextComponent(ChatFormatting.GOLD + "here");
|
||||||
s.getStyle().withClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/Tschipp/CarryOn/issues"));
|
s.getStyle().withClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/Tschipp/CarryOn/issues"));
|
||||||
player.displayClientMessage(new StringTextComponent(TextFormatting.RED + "Please report this error ").append(s), false);
|
player.displayClientMessage(new TextComponent(ChatFormatting.RED + "Please report this error ").append(s), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -384,7 +385,7 @@ public class ItemEvents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void emptyTileEntity(TileEntity te)
|
public static void emptyTileEntity(BlockEntity te)
|
||||||
{
|
{
|
||||||
if (te != null)
|
if (te != null)
|
||||||
{
|
{
|
||||||
|
|
@ -414,9 +415,9 @@ public class ItemEvents
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (te instanceof IInventory)
|
if (te instanceof Container)
|
||||||
{
|
{
|
||||||
IInventory inv = (IInventory) te;
|
Container inv = (Container) te;
|
||||||
inv.clearContent();
|
inv.clearContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -436,22 +437,21 @@ public class ItemEvents
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onRespawn(PlayerEvent.Clone event)
|
public void onRespawn(PlayerEvent.Clone event)
|
||||||
{
|
{
|
||||||
PlayerEntity original = event.getOriginal();
|
Player original = event.getOriginal();
|
||||||
PlayerEntity player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
boolean wasDead = event.isWasDeath();
|
boolean wasDead = event.isWasDeath();
|
||||||
GameRules rules = player.level.getGameRules();
|
GameRules rules = player.level.getGameRules();
|
||||||
boolean keepInv = rules.getBoolean(GameRules.RULE_KEEPINVENTORY);
|
boolean keepInv = rules.getBoolean(GameRules.RULE_KEEPINVENTORY);
|
||||||
boolean wasCarrying = player.inventory.contains(new ItemStack(RegistrationHandler.itemTile)) || player.inventory.contains(new ItemStack(RegistrationHandler.itemEntity));
|
boolean wasCarrying = player.getInventory().contains(new ItemStack(RegistrationHandler.itemTile)) || player.getInventory().contains(new ItemStack(RegistrationHandler.itemEntity));
|
||||||
|
|
||||||
if ((wasDead ? keepInv : true) && wasCarrying)
|
if ((wasDead ? keepInv : true) && wasCarrying)
|
||||||
{
|
{
|
||||||
int carrySlot = original.inventory.selected;
|
int carrySlot = original.getInventory().selected;
|
||||||
|
|
||||||
ItemStack stack = player.inventory.removeItemNoUpdate(carrySlot);
|
ItemStack stack = player.getInventory().removeItemNoUpdate(carrySlot);
|
||||||
World world = player.level;
|
Level world = player.level;
|
||||||
|
|
||||||
ItemEntity item = new ItemEntity(world, 0, 0, 0);
|
ItemEntity item = new ItemEntity(world, 0, 0, 0, stack);
|
||||||
item.setItem(stack);
|
|
||||||
BlockPos pos = null;
|
BlockPos pos = null;
|
||||||
Optional<BlockPos> bedpos = original.getSleepingPos();
|
Optional<BlockPos> bedpos = original.getSleepingPos();
|
||||||
if(bedpos.isPresent())
|
if(bedpos.isPresent())
|
||||||
|
|
@ -468,13 +468,13 @@ public class ItemEvents
|
||||||
public void dropNonHotbarItems(LivingUpdateEvent event)
|
public void dropNonHotbarItems(LivingUpdateEvent event)
|
||||||
{
|
{
|
||||||
LivingEntity entity = event.getEntityLiving();
|
LivingEntity entity = event.getEntityLiving();
|
||||||
if (entity instanceof PlayerEntity)
|
if (entity instanceof Player)
|
||||||
{
|
{
|
||||||
PlayerEntity player = (PlayerEntity) entity;
|
Player player = (Player) entity;
|
||||||
|
|
||||||
if (!entity.level.isClientSide)
|
if (!entity.level.isClientSide)
|
||||||
{
|
{
|
||||||
boolean hasCarried = player.inventory.contains(new ItemStack(RegistrationHandler.itemTile)) || player.inventory.contains(new ItemStack(RegistrationHandler.itemEntity));
|
boolean hasCarried = player.getInventory().contains(new ItemStack(RegistrationHandler.itemTile)) || player.getInventory().contains(new ItemStack(RegistrationHandler.itemEntity));
|
||||||
ItemStack inHand = player.getMainHandItem();
|
ItemStack inHand = player.getMainHandItem();
|
||||||
|
|
||||||
if (hasCarried)
|
if (hasCarried)
|
||||||
|
|
@ -489,12 +489,12 @@ public class ItemEvents
|
||||||
ItemEntity item = null;
|
ItemEntity item = null;
|
||||||
if (slotBlock != -1)
|
if (slotBlock != -1)
|
||||||
{
|
{
|
||||||
ItemStack dropped = player.inventory.removeItemNoUpdate(slotBlock);
|
ItemStack dropped = player.getInventory().removeItemNoUpdate(slotBlock);
|
||||||
item = new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), dropped);
|
item = new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), dropped);
|
||||||
}
|
}
|
||||||
if (slotEntity != -1)
|
if (slotEntity != -1)
|
||||||
{
|
{
|
||||||
ItemStack dropped = player.inventory.removeItemNoUpdate(slotEntity);
|
ItemStack dropped = player.getInventory().removeItemNoUpdate(slotEntity);
|
||||||
item = new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), dropped);
|
item = new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), dropped);
|
||||||
}
|
}
|
||||||
if (item != null)
|
if (item != null)
|
||||||
|
|
@ -519,23 +519,23 @@ public class ItemEvents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSlot(PlayerEntity player, Item item)
|
public int getSlot(Player player, Item item)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < player.inventory.getContainerSize(); i++)
|
for (int i = 0; i < player.getInventory().getContainerSize(); i++)
|
||||||
{
|
{
|
||||||
ItemStack stack = player.inventory.getItem(i);
|
ItemStack stack = player.getInventory().getItem(i);
|
||||||
if (stack.getItem() == item)
|
if (stack.getItem() == item)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendPacket(PlayerEntity player, int currentItem, int hash)
|
public static void sendPacket(Player player, int currentItem, int hash)
|
||||||
{
|
{
|
||||||
if (player instanceof ServerPlayerEntity)
|
if (player instanceof ServerPlayer)
|
||||||
{
|
{
|
||||||
CarryOn.network.send(PacketDistributor.NEAR.with(() -> new TargetPoint(player.getX(), player.getY(), player.getZ(), 128, player.level.dimension())), new CarrySlotPacket(currentItem, player.getId(), hash));
|
CarryOn.network.send(PacketDistributor.NEAR.with(() -> new TargetPoint(player.getX(), player.getY(), player.getZ(), 128, player.level.dimension())), new CarrySlotPacket(currentItem, player.getId(), hash));
|
||||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new CarrySlotPacket(currentItem, player.getId(), hash));
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new CarrySlotPacket(currentItem, player.getId(), hash));
|
||||||
|
|
||||||
if (currentItem >= 9)
|
if (currentItem >= 9)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ import java.util.List;
|
||||||
import com.mojang.brigadier.StringReader;
|
import com.mojang.brigadier.StringReader;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.commands.arguments.blocks.BlockStateParser;
|
||||||
import net.minecraft.command.arguments.BlockStateParser;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraftforge.fml.ModList;
|
import net.minecraftforge.fml.ModList;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import tschipp.carryon.common.config.Configs.CustomPickupConditions;
|
import tschipp.carryon.common.config.Configs.CustomPickupConditions;
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,14 @@ package tschipp.carryon.common.handler;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.EntityType;
|
|
||||||
import net.minecraft.tags.BlockTags;
|
import net.minecraft.tags.BlockTags;
|
||||||
import net.minecraft.tags.EntityTypeTags;
|
import net.minecraft.tags.EntityTypeTags;
|
||||||
import net.minecraft.tags.ITag;
|
import net.minecraft.tags.Tag;
|
||||||
import net.minecraft.tags.ITagCollection;
|
import net.minecraft.tags.TagCollection;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import tschipp.carryon.common.config.Configs.Blacklist;
|
import tschipp.carryon.common.config.Configs.Blacklist;
|
||||||
import tschipp.carryon.common.config.Configs.WhiteList;
|
import tschipp.carryon.common.config.Configs.WhiteList;
|
||||||
|
|
@ -24,12 +24,12 @@ public class ListHandler
|
||||||
public static List<String> FORBIDDEN_STACKING = new ArrayList<>();
|
public static List<String> FORBIDDEN_STACKING = new ArrayList<>();
|
||||||
public static List<String> ALLOWED_STACKING = new ArrayList<>();
|
public static List<String> ALLOWED_STACKING = new ArrayList<>();
|
||||||
|
|
||||||
public static List<ITag<Block>> FORBIDDEN_TILES_TAGS = new ArrayList<>();
|
public static List<Tag<Block>> FORBIDDEN_TILES_TAGS = new ArrayList<>();
|
||||||
public static List<ITag<EntityType<?>>> FORBIDDEN_ENTITIES_TAGS = new ArrayList<>();
|
public static List<Tag<EntityType<?>>> FORBIDDEN_ENTITIES_TAGS = new ArrayList<>();
|
||||||
public static List<ITag<EntityType<?>>> ALLOWED_ENTITIES_TAGS = new ArrayList<>();
|
public static List<Tag<EntityType<?>>> ALLOWED_ENTITIES_TAGS = new ArrayList<>();
|
||||||
public static List<ITag<Block>> ALLOWED_TILES_TAGS = new ArrayList<>();
|
public static List<Tag<Block>> ALLOWED_TILES_TAGS = new ArrayList<>();
|
||||||
public static List<ITag<EntityType<?>>> FORBIDDEN_STACKING_TAGS = new ArrayList<>();
|
public static List<Tag<EntityType<?>>> FORBIDDEN_STACKING_TAGS = new ArrayList<>();
|
||||||
public static List<ITag<EntityType<?>>> ALLOWED_STACKING_TAGS = new ArrayList<>();
|
public static List<Tag<EntityType<?>>> ALLOWED_STACKING_TAGS = new ArrayList<>();
|
||||||
|
|
||||||
public static boolean isForbidden(Block block)
|
public static boolean isForbidden(Block block)
|
||||||
{
|
{
|
||||||
|
|
@ -49,7 +49,7 @@ public class ListHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(ITag<Block> tag : FORBIDDEN_TILES_TAGS)
|
for(Tag<Block> tag : FORBIDDEN_TILES_TAGS)
|
||||||
{
|
{
|
||||||
if(tag.contains(block))
|
if(tag.contains(block))
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -64,7 +64,7 @@ public class ListHandler
|
||||||
String name = entity.getType().getRegistryName().toString();
|
String name = entity.getType().getRegistryName().toString();
|
||||||
boolean contains = FORBIDDEN_ENTITIES.contains(name);
|
boolean contains = FORBIDDEN_ENTITIES.contains(name);
|
||||||
|
|
||||||
for(ITag<EntityType<?>> tag : FORBIDDEN_ENTITIES_TAGS)
|
for(Tag<EntityType<?>> tag : FORBIDDEN_ENTITIES_TAGS)
|
||||||
{
|
{
|
||||||
if(tag.contains(entity.getType()))
|
if(tag.contains(entity.getType()))
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -78,7 +78,7 @@ public class ListHandler
|
||||||
String name = entity.getType().getRegistryName().toString();
|
String name = entity.getType().getRegistryName().toString();
|
||||||
boolean contains = ALLOWED_ENTITIES.contains(name);
|
boolean contains = ALLOWED_ENTITIES.contains(name);
|
||||||
|
|
||||||
for(ITag<EntityType<?>> tag : ALLOWED_ENTITIES_TAGS)
|
for(Tag<EntityType<?>> tag : ALLOWED_ENTITIES_TAGS)
|
||||||
{
|
{
|
||||||
if(tag.contains(entity.getType()))
|
if(tag.contains(entity.getType()))
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -92,7 +92,7 @@ public class ListHandler
|
||||||
String name = entity.getType().getRegistryName().toString();
|
String name = entity.getType().getRegistryName().toString();
|
||||||
boolean contains = FORBIDDEN_STACKING.contains(name);
|
boolean contains = FORBIDDEN_STACKING.contains(name);
|
||||||
|
|
||||||
for(ITag<EntityType<?>> tag : FORBIDDEN_STACKING_TAGS)
|
for(Tag<EntityType<?>> tag : FORBIDDEN_STACKING_TAGS)
|
||||||
{
|
{
|
||||||
if(tag.contains(entity.getType()))
|
if(tag.contains(entity.getType()))
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -106,7 +106,7 @@ public class ListHandler
|
||||||
String name = entity.getType().getRegistryName().toString();
|
String name = entity.getType().getRegistryName().toString();
|
||||||
boolean contains = ALLOWED_STACKING.contains(name);
|
boolean contains = ALLOWED_STACKING.contains(name);
|
||||||
|
|
||||||
for(ITag<EntityType<?>> tag : ALLOWED_STACKING_TAGS)
|
for(Tag<EntityType<?>> tag : ALLOWED_STACKING_TAGS)
|
||||||
{
|
{
|
||||||
if(tag.contains(entity.getType()))
|
if(tag.contains(entity.getType()))
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -133,7 +133,7 @@ public class ListHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(ITag<Block> tag : ALLOWED_TILES_TAGS)
|
for(Tag<Block> tag : ALLOWED_TILES_TAGS)
|
||||||
{
|
{
|
||||||
if(tag.contains(block))
|
if(tag.contains(block))
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -276,8 +276,8 @@ public class ListHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ITagCollection<Block> blocktags = BlockTags.getAllTags();
|
TagCollection<Block> blocktags = BlockTags.getAllTags();
|
||||||
ITagCollection<EntityType<?>> entitytags = EntityTypeTags.getAllTags();
|
TagCollection<EntityType<?>> entitytags = EntityTypeTags.getAllTags();
|
||||||
|
|
||||||
System.out.println(blocktags.getAvailableTags());
|
System.out.println(blocktags.getAvailableTags());
|
||||||
|
|
||||||
|
|
@ -286,7 +286,7 @@ public class ListHandler
|
||||||
if (s.startsWith("#"))
|
if (s.startsWith("#"))
|
||||||
{
|
{
|
||||||
String sub = s.substring(1, s.length());
|
String sub = s.substring(1, s.length());
|
||||||
ITag<Block> tag = blocktags.getTag(new ResourceLocation(sub));
|
Tag<Block> tag = blocktags.getTag(new ResourceLocation(sub));
|
||||||
if (tag != null)
|
if (tag != null)
|
||||||
FORBIDDEN_TILES_TAGS.add(tag);
|
FORBIDDEN_TILES_TAGS.add(tag);
|
||||||
}
|
}
|
||||||
|
|
@ -296,7 +296,7 @@ public class ListHandler
|
||||||
{
|
{
|
||||||
if (s.startsWith("#"))
|
if (s.startsWith("#"))
|
||||||
{
|
{
|
||||||
ITag<Block> tag = blocktags.getTag(new ResourceLocation(s.substring(1, s.length())));
|
Tag<Block> tag = blocktags.getTag(new ResourceLocation(s.substring(1, s.length())));
|
||||||
if (tag != null)
|
if (tag != null)
|
||||||
ALLOWED_TILES_TAGS.add(tag);
|
ALLOWED_TILES_TAGS.add(tag);
|
||||||
}
|
}
|
||||||
|
|
@ -306,7 +306,7 @@ public class ListHandler
|
||||||
{
|
{
|
||||||
if (s.startsWith("#"))
|
if (s.startsWith("#"))
|
||||||
{
|
{
|
||||||
ITag<EntityType<?>> tag = entitytags.getTag(new ResourceLocation(s.substring(1, s.length())));
|
Tag<EntityType<?>> tag = entitytags.getTag(new ResourceLocation(s.substring(1, s.length())));
|
||||||
if (tag != null)
|
if (tag != null)
|
||||||
FORBIDDEN_ENTITIES_TAGS.add(tag);
|
FORBIDDEN_ENTITIES_TAGS.add(tag);
|
||||||
}
|
}
|
||||||
|
|
@ -316,7 +316,7 @@ public class ListHandler
|
||||||
{
|
{
|
||||||
if (s.startsWith("#"))
|
if (s.startsWith("#"))
|
||||||
{
|
{
|
||||||
ITag<EntityType<?>> tag = entitytags.getTag(new ResourceLocation(s.substring(1, s.length())));
|
Tag<EntityType<?>> tag = entitytags.getTag(new ResourceLocation(s.substring(1, s.length())));
|
||||||
if (tag != null)
|
if (tag != null)
|
||||||
ALLOWED_ENTITIES_TAGS.add(tag);
|
ALLOWED_ENTITIES_TAGS.add(tag);
|
||||||
}
|
}
|
||||||
|
|
@ -326,7 +326,7 @@ public class ListHandler
|
||||||
{
|
{
|
||||||
if (s.startsWith("#"))
|
if (s.startsWith("#"))
|
||||||
{
|
{
|
||||||
ITag<EntityType<?>> tag = entitytags.getTag(new ResourceLocation(s.substring(1, s.length())));
|
Tag<EntityType<?>> tag = entitytags.getTag(new ResourceLocation(s.substring(1, s.length())));
|
||||||
if (tag != null)
|
if (tag != null)
|
||||||
FORBIDDEN_STACKING_TAGS.add(tag);
|
FORBIDDEN_STACKING_TAGS.add(tag);
|
||||||
}
|
}
|
||||||
|
|
@ -336,7 +336,7 @@ public class ListHandler
|
||||||
{
|
{
|
||||||
if (s.startsWith("#"))
|
if (s.startsWith("#"))
|
||||||
{
|
{
|
||||||
ITag<EntityType<?>> tag = entitytags.getTag(new ResourceLocation(s.substring(1, s.length())));
|
Tag<EntityType<?>> tag = entitytags.getTag(new ResourceLocation(s.substring(1, s.length())));
|
||||||
if (tag != null)
|
if (tag != null)
|
||||||
ALLOWED_STACKING_TAGS.add(tag);
|
ALLOWED_STACKING_TAGS.add(tag);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,16 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.nbt.NbtUtils;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.TagParser;
|
||||||
import net.minecraft.nbt.JsonToNBT;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.nbt.NBTUtil;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.fml.ModList;
|
import net.minecraftforge.fml.ModList;
|
||||||
|
|
@ -25,7 +25,7 @@ import tschipp.carryon.common.helper.StringParser;
|
||||||
|
|
||||||
public class ModelOverridesHandler
|
public class ModelOverridesHandler
|
||||||
{
|
{
|
||||||
public static HashMap<CompoundNBT, Object> OVERRIDE_OBJECTS = new HashMap<CompoundNBT, Object>();
|
public static HashMap<CompoundTag, Object> OVERRIDE_OBJECTS = new HashMap<CompoundTag, Object>();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This class is really ugly, will probably be replaced by something else -
|
* This class is really ugly, will probably be replaced by something else -
|
||||||
|
|
@ -37,7 +37,7 @@ public class ModelOverridesHandler
|
||||||
|
|
||||||
Object toOverrideObject;
|
Object toOverrideObject;
|
||||||
Object overrideObject;
|
Object overrideObject;
|
||||||
CompoundNBT tag = new CompoundNBT();
|
CompoundTag tag = new CompoundTag();
|
||||||
|
|
||||||
String currentline = overrideString;
|
String currentline = overrideString;
|
||||||
if (StringUtils.isEmpty(currentline) || !StringUtils.contains(currentline, "->"))
|
if (StringUtils.isEmpty(currentline) || !StringUtils.contains(currentline, "->"))
|
||||||
|
|
@ -69,7 +69,7 @@ public class ModelOverridesHandler
|
||||||
toOverride = toOverride.replace(nbt, "");
|
toOverride = toOverride.replace(nbt, "");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tag = JsonToNBT.parseTag(nbt);
|
tag = TagParser.parseTag(nbt);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
@ -127,7 +127,7 @@ public class ModelOverridesHandler
|
||||||
|
|
||||||
if (overrideObject != null)
|
if (overrideObject != null)
|
||||||
{
|
{
|
||||||
CompoundNBT keyComp = new CompoundNBT();
|
CompoundTag keyComp = new CompoundTag();
|
||||||
keyComp.put("nbttag", tag);
|
keyComp.put("nbttag", tag);
|
||||||
if (toOverrideObject instanceof Block)
|
if (toOverrideObject instanceof Block)
|
||||||
{
|
{
|
||||||
|
|
@ -156,21 +156,21 @@ public class ModelOverridesHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasCustomOverrideModel(BlockState state, CompoundNBT tag)
|
public static boolean hasCustomOverrideModel(BlockState state, CompoundTag tag)
|
||||||
{
|
{
|
||||||
if (OVERRIDE_OBJECTS.isEmpty())
|
if (OVERRIDE_OBJECTS.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int stateid = Block.getId(state);
|
int stateid = Block.getId(state);
|
||||||
CompoundNBT[] keys = new CompoundNBT[OVERRIDE_OBJECTS.size()];
|
CompoundTag[] keys = new CompoundTag[OVERRIDE_OBJECTS.size()];
|
||||||
OVERRIDE_OBJECTS.keySet().toArray(keys);
|
OVERRIDE_OBJECTS.keySet().toArray(keys);
|
||||||
for (CompoundNBT key : keys)
|
for (CompoundTag key : keys)
|
||||||
{
|
{
|
||||||
int id = key.getInt("stateid");
|
int id = key.getInt("stateid");
|
||||||
Block block = StringParser.getBlock(key.getString("block"));
|
Block block = StringParser.getBlock(key.getString("block"));
|
||||||
if (id == 0 ? block == state.getBlock() : id == stateid)
|
if (id == 0 ? block == state.getBlock() : id == stateid)
|
||||||
{
|
{
|
||||||
CompoundNBT toCheckForCompound = key.getCompound("nbttag");
|
CompoundTag toCheckForCompound = key.getCompound("nbttag");
|
||||||
Set<String> kSetToCheck = toCheckForCompound.getAllKeys();
|
Set<String> kSetToCheck = toCheckForCompound.getAllKeys();
|
||||||
Set<String> kSetTile = tag.getAllKeys();
|
Set<String> kSetTile = tag.getAllKeys();
|
||||||
|
|
||||||
|
|
@ -179,7 +179,7 @@ public class ModelOverridesHandler
|
||||||
{
|
{
|
||||||
for (String skey : kSetToCheck)
|
for (String skey : kSetToCheck)
|
||||||
{
|
{
|
||||||
if (!NBTUtil.compareNbt(tag.get(skey), toCheckForCompound.get(skey), true))
|
if (!NbtUtils.compareNbt(tag.get(skey), toCheckForCompound.get(skey), true))
|
||||||
flag = false;
|
flag = false;
|
||||||
}
|
}
|
||||||
if (flag)
|
if (flag)
|
||||||
|
|
@ -192,18 +192,18 @@ public class ModelOverridesHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public static IBakedModel getCustomOverrideModel(BlockState state, CompoundNBT tag, World world, PlayerEntity player)
|
public static BakedModel getCustomOverrideModel(BlockState state, CompoundTag tag, Level world, Player player)
|
||||||
{
|
{
|
||||||
int stateid = Block.getId(state);
|
int stateid = Block.getId(state);
|
||||||
CompoundNBT[] keys = new CompoundNBT[OVERRIDE_OBJECTS.size()];
|
CompoundTag[] keys = new CompoundTag[OVERRIDE_OBJECTS.size()];
|
||||||
OVERRIDE_OBJECTS.keySet().toArray(keys);
|
OVERRIDE_OBJECTS.keySet().toArray(keys);
|
||||||
for (CompoundNBT key : keys)
|
for (CompoundTag key : keys)
|
||||||
{
|
{
|
||||||
int id = key.getInt("stateid");
|
int id = key.getInt("stateid");
|
||||||
Block block = StringParser.getBlock(key.getString("block"));
|
Block block = StringParser.getBlock(key.getString("block"));
|
||||||
if (id == 0 ? block == state.getBlock() : id == stateid)
|
if (id == 0 ? block == state.getBlock() : id == stateid)
|
||||||
{
|
{
|
||||||
CompoundNBT toCheckForCompound = key.getCompound("nbttag");
|
CompoundTag toCheckForCompound = key.getCompound("nbttag");
|
||||||
Set<String> kSetToCheck = toCheckForCompound.getAllKeys();
|
Set<String> kSetToCheck = toCheckForCompound.getAllKeys();
|
||||||
Set<String> kSetTile = tag.getAllKeys();
|
Set<String> kSetTile = tag.getAllKeys();
|
||||||
|
|
||||||
|
|
@ -212,7 +212,7 @@ public class ModelOverridesHandler
|
||||||
{
|
{
|
||||||
for (String skey : kSetToCheck)
|
for (String skey : kSetToCheck)
|
||||||
{
|
{
|
||||||
if (!NBTUtil.compareNbt(tag.get(skey), toCheckForCompound.get(skey), true))
|
if (!NbtUtils.compareNbt(tag.get(skey), toCheckForCompound.get(skey), true))
|
||||||
flag = false;
|
flag = false;
|
||||||
}
|
}
|
||||||
if (flag)
|
if (flag)
|
||||||
|
|
@ -225,7 +225,7 @@ public class ModelOverridesHandler
|
||||||
if (override instanceof BlockState)
|
if (override instanceof BlockState)
|
||||||
return Minecraft.getInstance().getBlockRenderer().getBlockModel((BlockState) override);
|
return Minecraft.getInstance().getBlockRenderer().getBlockModel((BlockState) override);
|
||||||
else
|
else
|
||||||
return Minecraft.getInstance().getItemRenderer().getModel((ItemStack) override, world, player);
|
return Minecraft.getInstance().getItemRenderer().getModel((ItemStack) override, world, player, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -234,18 +234,18 @@ public class ModelOverridesHandler
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getOverrideObject(BlockState state, CompoundNBT tag)
|
public static Object getOverrideObject(BlockState state, CompoundTag tag)
|
||||||
{
|
{
|
||||||
int stateid = Block.getId(state);
|
int stateid = Block.getId(state);
|
||||||
CompoundNBT[] keys = new CompoundNBT[OVERRIDE_OBJECTS.size()];
|
CompoundTag[] keys = new CompoundTag[OVERRIDE_OBJECTS.size()];
|
||||||
OVERRIDE_OBJECTS.keySet().toArray(keys);
|
OVERRIDE_OBJECTS.keySet().toArray(keys);
|
||||||
for (CompoundNBT key : keys)
|
for (CompoundTag key : keys)
|
||||||
{
|
{
|
||||||
int id = key.getInt("stateid");
|
int id = key.getInt("stateid");
|
||||||
Block block = StringParser.getBlock(key.getString("block"));
|
Block block = StringParser.getBlock(key.getString("block"));
|
||||||
if (id == 0 ? block == state.getBlock() : id == stateid)
|
if (id == 0 ? block == state.getBlock() : id == stateid)
|
||||||
{
|
{
|
||||||
CompoundNBT toCheckForCompound = key.getCompound("nbttag");
|
CompoundTag toCheckForCompound = key.getCompound("nbttag");
|
||||||
Set<String> kSetToCheck = toCheckForCompound.getAllKeys();
|
Set<String> kSetToCheck = toCheckForCompound.getAllKeys();
|
||||||
Set<String> kSetTile = tag.getAllKeys();
|
Set<String> kSetTile = tag.getAllKeys();
|
||||||
|
|
||||||
|
|
@ -254,7 +254,7 @@ public class ModelOverridesHandler
|
||||||
{
|
{
|
||||||
for (String skey : kSetToCheck)
|
for (String skey : kSetToCheck)
|
||||||
{
|
{
|
||||||
if (!NBTUtil.compareNbt(tag.get(skey), toCheckForCompound.get(skey), true))
|
if (!NbtUtils.compareNbt(tag.get(skey), toCheckForCompound.get(skey), true))
|
||||||
flag = false;
|
flag = false;
|
||||||
}
|
}
|
||||||
if (flag)
|
if (flag)
|
||||||
|
|
|
||||||
|
|
@ -4,19 +4,19 @@ import java.util.UUID;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.entity.AgeableEntity;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.entity.EntityClassification;
|
import net.minecraft.world.entity.AgeableMob;
|
||||||
import net.minecraft.entity.passive.TameableEntity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.entity.MobCategory;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.world.entity.TamableAnimal;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.world.level.GameType;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.GameType;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||||
import net.minecraftforge.event.world.BlockEvent;
|
import net.minecraftforge.event.world.BlockEvent;
|
||||||
|
|
@ -29,21 +29,21 @@ import tschipp.carryon.common.scripting.ScriptChecker;
|
||||||
public class PickupHandler
|
public class PickupHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
public static boolean canPlayerPickUpBlock(ServerPlayerEntity player, @Nullable TileEntity tile, World world, BlockPos pos)
|
public static boolean canPlayerPickUpBlock(ServerPlayer player, @Nullable BlockEntity tile, Level world, BlockPos pos)
|
||||||
{
|
{
|
||||||
if(player.gameMode.getGameModeForPlayer() == GameType.SPECTATOR || player.gameMode.getGameModeForPlayer() == GameType.ADVENTURE)
|
if(player.gameMode.getGameModeForPlayer() == GameType.SPECTATOR || player.gameMode.getGameModeForPlayer() == GameType.ADVENTURE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
BlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
CompoundNBT tag = new CompoundNBT();
|
CompoundTag tag = new CompoundTag();
|
||||||
if (tile != null)
|
if (tile != null)
|
||||||
tile.save(tag);
|
tile.save(tag);
|
||||||
|
|
||||||
CarryOnOverride override = ScriptChecker.inspectBlock(world.getBlockState(pos), world, pos, tag);
|
CarryOnOverride override = ScriptChecker.inspectBlock(world.getBlockState(pos), world, pos, tag);
|
||||||
if (override != null)
|
if (override != null)
|
||||||
{
|
{
|
||||||
return (ScriptChecker.fulfillsConditions(override, player)) && handleProtections((ServerPlayerEntity) player, world, pos, state);
|
return (ScriptChecker.fulfillsConditions(override, player)) && handleProtections((ServerPlayer) player, world, pos, state);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -64,7 +64,7 @@ public class PickupHandler
|
||||||
|
|
||||||
if ((state.getDestroySpeed(world, pos) != -1 || player.isCreative()))
|
if ((state.getDestroySpeed(world, pos) != -1 || player.isCreative()))
|
||||||
{
|
{
|
||||||
double distance = Vector3d.atLowerCornerOf(pos).distanceTo(player.position());
|
double distance = Vec3.atLowerCornerOf(pos).distanceTo(player.position());
|
||||||
double maxDist = Settings.maxDistance.get();
|
double maxDist = Settings.maxDistance.get();
|
||||||
|
|
||||||
if (distance < maxDist)
|
if (distance < maxDist)
|
||||||
|
|
@ -75,7 +75,7 @@ public class PickupHandler
|
||||||
|
|
||||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(state))
|
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(state))
|
||||||
{
|
{
|
||||||
return CarryonGamestageHelper.hasGamestage(CustomPickupOverrideHandler.getPickupCondition(state), player) && handleProtections((ServerPlayerEntity) player, world, pos, state);
|
return CarryonGamestageHelper.hasGamestage(CustomPickupOverrideHandler.getPickupCondition(state), player) && handleProtections((ServerPlayer) player, world, pos, state);
|
||||||
}
|
}
|
||||||
else if (Settings.pickupAllBlocks.get() ? true : tile != null)
|
else if (Settings.pickupAllBlocks.get() ? true : tile != null)
|
||||||
{
|
{
|
||||||
|
|
@ -90,14 +90,14 @@ public class PickupHandler
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canPlayerPickUpEntity(ServerPlayerEntity player, Entity toPickUp)
|
public static boolean canPlayerPickUpEntity(ServerPlayer player, Entity toPickUp)
|
||||||
{
|
{
|
||||||
if(player.gameMode.getGameModeForPlayer() == GameType.SPECTATOR || player.gameMode.getGameModeForPlayer() == GameType.ADVENTURE)
|
if(player.gameMode.getGameModeForPlayer() == GameType.SPECTATOR || player.gameMode.getGameModeForPlayer() == GameType.ADVENTURE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
BlockPos pos = toPickUp.blockPosition();
|
Vec3 pos = toPickUp.position();
|
||||||
|
|
||||||
if (toPickUp instanceof PlayerEntity)
|
if (toPickUp instanceof Player)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CarryOnOverride override = ScriptChecker.inspectEntity(toPickUp);
|
CarryOnOverride override = ScriptChecker.inspectEntity(toPickUp);
|
||||||
|
|
@ -107,29 +107,29 @@ public class PickupHandler
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (toPickUp instanceof AgeableEntity && Settings.allowBabies.get())
|
if (toPickUp instanceof AgeableMob && Settings.allowBabies.get())
|
||||||
{
|
{
|
||||||
AgeableEntity living = (AgeableEntity) toPickUp;
|
AgeableMob living = (AgeableMob) toPickUp;
|
||||||
if (living.getAge() < 0 || living.isBaby())
|
if (living.getAge() < 0 || living.isBaby())
|
||||||
{
|
{
|
||||||
|
|
||||||
double distance = pos.distSqr(player.blockPosition());
|
double distance = pos.distanceToSqr(player.position());
|
||||||
if (distance < Math.pow(Settings.maxDistance.get(), 2))
|
if (distance <= Math.pow(Settings.maxDistance.get(), 2))
|
||||||
{
|
{
|
||||||
if (toPickUp instanceof TameableEntity)
|
if (toPickUp instanceof TamableAnimal)
|
||||||
{
|
{
|
||||||
TameableEntity tame = (TameableEntity) toPickUp;
|
TamableAnimal tame = (TamableAnimal) toPickUp;
|
||||||
if (tame.getOwnerUUID() != null && tame.getOwnerUUID() != PlayerEntity.createPlayerUUID(player.getGameProfile()))
|
if (tame.getOwnerUUID() != null && tame.getOwnerUUID() != Player.createPlayerUUID(player.getGameProfile()))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
|
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
|
||||||
{
|
{
|
||||||
return CarryonGamestageHelper.hasGamestage(CustomPickupOverrideHandler.getPickupCondition(toPickUp), player) && handleProtections((ServerPlayerEntity) player, toPickUp);
|
return CarryonGamestageHelper.hasGamestage(CustomPickupOverrideHandler.getPickupCondition(toPickUp), player) && handleProtections((ServerPlayer) player, toPickUp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return handleProtections((ServerPlayerEntity) player, toPickUp);
|
return handleProtections((ServerPlayer) player, toPickUp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,30 +148,30 @@ public class PickupHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Settings.pickupHostileMobs.get() ? true : toPickUp.getType().getCategory() != EntityClassification.MONSTER || player.isCreative()))
|
if ((Settings.pickupHostileMobs.get() ? true : toPickUp.getType().getCategory() != MobCategory.MONSTER || player.isCreative()))
|
||||||
{
|
{
|
||||||
if ((Settings.pickupHostileMobs.get() ? true : toPickUp.getType().getCategory() != EntityClassification.MONSTER || player.isCreative()))
|
if ((Settings.pickupHostileMobs.get() ? true : toPickUp.getType().getCategory() != MobCategory.MONSTER || player.isCreative()))
|
||||||
{
|
{
|
||||||
if ((toPickUp.getBbHeight() <= Settings.maxEntityHeight.get() && toPickUp.getBbWidth() <= Settings.maxEntityWidth.get() || player.isCreative()))
|
if ((toPickUp.getBbHeight() <= Settings.maxEntityHeight.get() && toPickUp.getBbWidth() <= Settings.maxEntityWidth.get() || player.isCreative()))
|
||||||
{
|
{
|
||||||
double distance = pos.distSqr(player.blockPosition());
|
double distance = pos.distanceToSqr(player.position());
|
||||||
if (distance < Math.pow(Settings.maxDistance.get(), 2))
|
if (distance < Math.pow(Settings.maxDistance.get(), 2))
|
||||||
{
|
{
|
||||||
if (toPickUp instanceof TameableEntity)
|
if (toPickUp instanceof TamableAnimal)
|
||||||
{
|
{
|
||||||
TameableEntity tame = (TameableEntity) toPickUp;
|
TamableAnimal tame = (TamableAnimal) toPickUp;
|
||||||
UUID owner = tame.getOwnerUUID();
|
UUID owner = tame.getOwnerUUID();
|
||||||
UUID playerID = PlayerEntity.createPlayerUUID(player.getGameProfile());
|
UUID playerID = Player.createPlayerUUID(player.getGameProfile());
|
||||||
if (owner != null && !owner.equals(playerID))
|
if (owner != null && !owner.equals(playerID))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
|
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
|
||||||
{
|
{
|
||||||
return CarryonGamestageHelper.hasGamestage(CustomPickupOverrideHandler.getPickupCondition(toPickUp), player) && handleProtections((ServerPlayerEntity) player, toPickUp);
|
return CarryonGamestageHelper.hasGamestage(CustomPickupOverrideHandler.getPickupCondition(toPickUp), player) && handleProtections((ServerPlayer) player, toPickUp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return handleProtections((ServerPlayerEntity) player, toPickUp);
|
return handleProtections((ServerPlayer) player, toPickUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -186,7 +186,7 @@ public class PickupHandler
|
||||||
|
|
||||||
public static class PickUpBlockEvent extends BlockEvent.BreakEvent
|
public static class PickUpBlockEvent extends BlockEvent.BreakEvent
|
||||||
{
|
{
|
||||||
public PickUpBlockEvent(World world, BlockPos pos, BlockState state, PlayerEntity player)
|
public PickUpBlockEvent(Level world, BlockPos pos, BlockState state, Player player)
|
||||||
{
|
{
|
||||||
super(world, pos, state, player);
|
super(world, pos, state, player);
|
||||||
}
|
}
|
||||||
|
|
@ -194,13 +194,13 @@ public class PickupHandler
|
||||||
|
|
||||||
public static class PickUpEntityEvent extends AttackEntityEvent
|
public static class PickUpEntityEvent extends AttackEntityEvent
|
||||||
{
|
{
|
||||||
public PickUpEntityEvent(PlayerEntity player, Entity target)
|
public PickUpEntityEvent(Player player, Entity target)
|
||||||
{
|
{
|
||||||
super(player, target);
|
super(player, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean handleProtections(ServerPlayerEntity player, World world, BlockPos pos, BlockState state)
|
private static boolean handleProtections(ServerPlayer player, Level world, BlockPos pos, BlockState state)
|
||||||
{
|
{
|
||||||
boolean breakable = true;
|
boolean breakable = true;
|
||||||
|
|
||||||
|
|
@ -213,7 +213,7 @@ public class PickupHandler
|
||||||
return breakable;
|
return breakable;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean handleProtections(ServerPlayerEntity player, Entity entity)
|
private static boolean handleProtections(ServerPlayer player, Entity entity)
|
||||||
{
|
{
|
||||||
boolean canPickup = true;
|
boolean canPickup = true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,21 @@
|
||||||
package tschipp.carryon.common.handler;
|
package tschipp.carryon.common.handler;
|
||||||
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||||
import net.minecraftforge.fml.ModList;
|
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
import net.minecraftforge.registries.ObjectHolder;
|
import net.minecraftforge.registries.ObjectHolder;
|
||||||
import tschipp.carryon.CarryOn;
|
import tschipp.carryon.CarryOn;
|
||||||
import tschipp.carryon.client.event.RenderEntityEvents;
|
import tschipp.carryon.client.event.RenderEntityEvents;
|
||||||
import tschipp.carryon.client.event.RenderEvents;
|
import tschipp.carryon.client.event.RenderEvents;
|
||||||
import tschipp.carryon.common.capabilities.IPosition;
|
import tschipp.carryon.common.capabilities.IPosition;
|
||||||
import tschipp.carryon.common.capabilities.PositionStorage;
|
|
||||||
import tschipp.carryon.common.capabilities.TEPosition;
|
|
||||||
import tschipp.carryon.common.capabilities.event.PositionClientEvents;
|
import tschipp.carryon.common.capabilities.event.PositionClientEvents;
|
||||||
import tschipp.carryon.common.capabilities.event.PositionCommonEvents;
|
import tschipp.carryon.common.capabilities.event.PositionCommonEvents;
|
||||||
import tschipp.carryon.common.event.IMCEvents;
|
import tschipp.carryon.common.event.IMCEvents;
|
||||||
import tschipp.carryon.common.event.ItemEntityEvents;
|
import tschipp.carryon.common.event.ItemEntityEvents;
|
||||||
import tschipp.carryon.common.event.ItemEvents;
|
import tschipp.carryon.common.event.ItemEvents;
|
||||||
import tschipp.carryon.common.item.ItemCarryonEntity;
|
|
||||||
import tschipp.carryon.common.item.ItemCarryonBlock;
|
import tschipp.carryon.common.item.ItemCarryonBlock;
|
||||||
import tschipp.carryon.compat.obfuscate.ObfuscateEvents;
|
import tschipp.carryon.common.item.ItemCarryonEntity;
|
||||||
|
|
||||||
@EventBusSubscriber(modid = CarryOn.MODID)
|
@EventBusSubscriber(modid = CarryOn.MODID)
|
||||||
public class RegistrationHandler
|
public class RegistrationHandler
|
||||||
|
|
@ -51,8 +47,8 @@ public class RegistrationHandler
|
||||||
MinecraftForge.EVENT_BUS.register(new PositionClientEvents());
|
MinecraftForge.EVENT_BUS.register(new PositionClientEvents());
|
||||||
|
|
||||||
|
|
||||||
if(ModList.get().isLoaded("obfuscate"))
|
// if(ModList.get().isLoaded("obfuscate"))
|
||||||
MinecraftForge.EVENT_BUS.register(new ObfuscateEvents());
|
// MinecraftForge.EVENT_BUS.register(new ObfuscateEvents());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,7 +61,7 @@ public class RegistrationHandler
|
||||||
|
|
||||||
public static void regCaps()
|
public static void regCaps()
|
||||||
{
|
{
|
||||||
CapabilityManager.INSTANCE.register(IPosition.class, new PositionStorage(), TEPosition::new);
|
CapabilityManager.INSTANCE.register(IPosition.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
package tschipp.carryon.common.helper;
|
package tschipp.carryon.common.helper;
|
||||||
|
|
||||||
import net.darkhax.gamestages.GameStageHelper;
|
//import net.darkhax.gamestages.GameStageHelper;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
|
||||||
public class CarryonGamestageHelper
|
public class CarryonGamestageHelper
|
||||||
{
|
{
|
||||||
public static boolean hasGamestage(String stage, PlayerEntity player)
|
public static boolean hasGamestage(String stage, Player player)
|
||||||
{
|
{
|
||||||
return GameStageHelper.hasStage(player, stage);
|
// return GameStageHelper.hasStage(player, stage);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import java.lang.reflect.Method;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility methods for reflection.
|
* Utility methods for reflection.
|
||||||
|
|
|
||||||
|
|
@ -1,65 +1,53 @@
|
||||||
package tschipp.carryon.common.helper;
|
package tschipp.carryon.common.helper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.nbt.INBT;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.potion.EffectInstance;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.scoreboard.Score;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.scoreboard.ScoreObjective;
|
import net.minecraft.world.scores.Objective;
|
||||||
import net.minecraft.scoreboard.Scoreboard;
|
import net.minecraft.world.scores.Score;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.world.scores.Scoreboard;
|
||||||
|
|
||||||
public class ScriptParseHelper
|
public class ScriptParseHelper {
|
||||||
{
|
|
||||||
|
|
||||||
public static boolean matches(double number, String cond)
|
public static boolean matches(double number, String cond) {
|
||||||
{
|
|
||||||
if (cond == null || cond.isEmpty())
|
if (cond == null || cond.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
if (cond.contains("<=")) {
|
||||||
if (cond.contains("<="))
|
|
||||||
{
|
|
||||||
return number <= Double.parseDouble(cond.replace("<=", ""));
|
return number <= Double.parseDouble(cond.replace("<=", ""));
|
||||||
}
|
}
|
||||||
if (cond.contains(">="))
|
if (cond.contains(">=")) {
|
||||||
{
|
|
||||||
return number >= Double.parseDouble(cond.replace(">=", ""));
|
return number >= Double.parseDouble(cond.replace(">=", ""));
|
||||||
}
|
}
|
||||||
if (cond.contains("<"))
|
if (cond.contains("<")) {
|
||||||
{
|
|
||||||
return number < Double.parseDouble(cond.replace("<", ""));
|
return number < Double.parseDouble(cond.replace("<", ""));
|
||||||
}
|
}
|
||||||
if (cond.contains(">"))
|
if (cond.contains(">")) {
|
||||||
{
|
|
||||||
return number > Double.parseDouble(cond.replace(">", ""));
|
return number > Double.parseDouble(cond.replace(">", ""));
|
||||||
}
|
}
|
||||||
if (cond.contains("="))
|
if (cond.contains("=")) {
|
||||||
{
|
|
||||||
return number == Double.parseDouble(cond.replace("=", ""));
|
return number == Double.parseDouble(cond.replace("=", ""));
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
return number == Double.parseDouble(cond);
|
return number == Double.parseDouble(cond);
|
||||||
|
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
new InvalidConfigException(e.getMessage()).printException();
|
new InvalidConfigException(e.getMessage()).printException();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean matches(Block block, String cond)
|
public static boolean matches(Block block, String cond) {
|
||||||
{
|
|
||||||
if (cond == null || cond.isEmpty())
|
if (cond == null || cond.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
@ -70,26 +58,23 @@ public class ScriptParseHelper
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean matches(CompoundNBT toCheck, CompoundNBT toMatch)
|
public static boolean matches(CompoundTag toCheck, CompoundTag toMatch) {
|
||||||
{
|
|
||||||
if (toCheck == null || toMatch == null || toMatch.isEmpty())
|
if (toCheck == null || toMatch == null || toMatch.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
boolean matching = true;
|
boolean matching = true;
|
||||||
for (String key : toMatch.getAllKeys())
|
for (String key : toMatch.getAllKeys()) {
|
||||||
{
|
Tag tag = toMatch.get(key);
|
||||||
INBT tag = toMatch.get(key);
|
|
||||||
key = key.replace("\"", "");
|
key = key.replace("\"", "");
|
||||||
INBT tagToCheck = toCheck.get(key);
|
Tag tagToCheck = toCheck.get(key);
|
||||||
if (!tag.equals(tagToCheck))
|
if (!tag.equals(tagToCheck))
|
||||||
matching = false;
|
matching = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return matching;
|
return matching;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float[] getXYZArray(String s)
|
public static float[] getXYZArray(String s) {
|
||||||
{
|
|
||||||
float[] d = new float[3];
|
float[] d = new float[3];
|
||||||
d[0] = getValueFromString(s, "x");
|
d[0] = getValueFromString(s, "x");
|
||||||
d[1] = getValueFromString(s, "y");
|
d[1] = getValueFromString(s, "y");
|
||||||
|
|
@ -97,10 +82,8 @@ public class ScriptParseHelper
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static float[] getScaled(String s)
|
public static float[] getScaled(String s) {
|
||||||
{
|
|
||||||
float[] d = new float[3];
|
float[] d = new float[3];
|
||||||
d[0] = getScaledValueFromString(s, "x");
|
d[0] = getScaledValueFromString(s, "x");
|
||||||
d[1] = getScaledValueFromString(s, "y");
|
d[1] = getScaledValueFromString(s, "y");
|
||||||
|
|
@ -109,25 +92,19 @@ public class ScriptParseHelper
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getScaledValueFromString(String toGetFrom, String key)
|
public static float getScaledValueFromString(String toGetFrom, String key) {
|
||||||
{
|
if (toGetFrom == null || toGetFrom.isEmpty())
|
||||||
if(toGetFrom == null || toGetFrom.isEmpty())
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
String[] s = toGetFrom.split(",");
|
String[] s = toGetFrom.split(",");
|
||||||
for (String string : s)
|
for (String string : s) {
|
||||||
{
|
if (string.contains(key) && string.contains("=")) {
|
||||||
if (string.contains(key) && string.contains("="))
|
|
||||||
{
|
|
||||||
float numb = 1;
|
float numb = 1;
|
||||||
string = string.replace(key + "=", "");
|
string = string.replace(key + "=", "");
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
numb = Float.parseFloat(string);
|
numb = Float.parseFloat(string);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return numb;
|
return numb;
|
||||||
|
|
@ -137,8 +114,7 @@ public class ScriptParseHelper
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean matchesScore(PlayerEntity player, String cond)
|
public static boolean matchesScore(Player player, String cond) {
|
||||||
{
|
|
||||||
if (cond == null || cond.isEmpty())
|
if (cond == null || cond.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
@ -149,20 +125,18 @@ public class ScriptParseHelper
|
||||||
int iG = cond.indexOf(">");
|
int iG = cond.indexOf(">");
|
||||||
int iL = cond.indexOf("<");
|
int iL = cond.indexOf("<");
|
||||||
|
|
||||||
if (iG == -1 ? true : iE < iG && iL == -1 ? true : iE < iL && iE != -1)
|
if (iG == -1 ? true : iE < iG && iL == -1 ? true : iE < iL && iE != -1)
|
||||||
numb = cond.substring(iE);
|
numb = cond.substring(iE);
|
||||||
else if (iE == -1 ? true : iG < iE && iL == -1 ? true : iG < iL && iG != -1)
|
else if (iE == -1 ? true : iG < iE && iL == -1 ? true : iG < iL && iG != -1)
|
||||||
numb = cond.substring(iG);
|
numb = cond.substring(iG);
|
||||||
else
|
else
|
||||||
numb = cond.substring(iL);
|
numb = cond.substring(iL);
|
||||||
|
|
||||||
scorename = cond.replace(numb, "");
|
scorename = cond.replace(numb, "");
|
||||||
Map<ScoreObjective, Score> o = score.getPlayerScores(player.getGameProfile().getName());
|
Map<Objective, Score> o = score.getPlayerScores(player.getGameProfile().getName());
|
||||||
if (o != null)
|
if (o != null) {
|
||||||
{
|
|
||||||
Score sc = o.get(score.getObjective(scorename));
|
Score sc = o.get(score.getObjective(scorename));
|
||||||
if (sc != null)
|
if (sc != null) {
|
||||||
{
|
|
||||||
int points = sc.getScore();
|
int points = sc.getScore();
|
||||||
|
|
||||||
return matches(points, numb);
|
return matches(points, numb);
|
||||||
|
|
@ -172,13 +146,14 @@ public class ScriptParseHelper
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean matches(BlockPos pos, String cond)
|
public static boolean matches(BlockPos pos, String cond) {
|
||||||
{
|
|
||||||
if (cond == null || cond.isEmpty())
|
if (cond == null || cond.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
BlockPos blockpos = new BlockPos(getValueFromString(cond, "x"), getValueFromString(cond, "y"), getValueFromString(cond, "z"));
|
BlockPos blockpos = new BlockPos(getValueFromString(cond, "x"), getValueFromString(cond, "y"),
|
||||||
BlockPos expand = new BlockPos(getValueFromString(cond, "dx"), getValueFromString(cond, "dy"), getValueFromString(cond, "dz"));
|
getValueFromString(cond, "z"));
|
||||||
|
BlockPos expand = new BlockPos(getValueFromString(cond, "dx"), getValueFromString(cond, "dy"),
|
||||||
|
getValueFromString(cond, "dz"));
|
||||||
BlockPos expanded = blockpos.offset(expand);
|
BlockPos expanded = blockpos.offset(expand);
|
||||||
|
|
||||||
boolean x = (pos.getX() >= blockpos.getX() && pos.getX() <= expanded.getX()) || blockpos.getX() == 0;
|
boolean x = (pos.getX() >= blockpos.getX() && pos.getX() <= expanded.getX()) || blockpos.getX() == 0;
|
||||||
|
|
@ -188,25 +163,19 @@ public class ScriptParseHelper
|
||||||
return x && y && z;
|
return x && y && z;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getValueFromString(String toGetFrom, String key)
|
public static float getValueFromString(String toGetFrom, String key) {
|
||||||
{
|
if (toGetFrom == null || toGetFrom.isEmpty())
|
||||||
if(toGetFrom == null || toGetFrom.isEmpty())
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
String[] s = toGetFrom.split(",");
|
String[] s = toGetFrom.split(",");
|
||||||
for (String string : s)
|
for (String string : s) {
|
||||||
{
|
if (string.contains(key) && string.contains("=")) {
|
||||||
if (string.contains(key) && string.contains("="))
|
|
||||||
{
|
|
||||||
float numb = 0;
|
float numb = 0;
|
||||||
string = string.replace(key + "=", "");
|
string = string.replace(key + "=", "");
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
numb = Float.parseFloat(string);
|
numb = Float.parseFloat(string);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return numb;
|
return numb;
|
||||||
|
|
@ -215,70 +184,59 @@ public class ScriptParseHelper
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasEffects(PlayerEntity player, String cond)
|
public static boolean hasEffects(Player player, String cond) {
|
||||||
{
|
if (cond == null || cond.isEmpty())
|
||||||
if(cond == null || cond.isEmpty())
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Collection<EffectInstance> effects = player.getActiveEffects();
|
Collection<MobEffectInstance> effects = player.getActiveEffects();
|
||||||
String[] potions = cond.split(",");
|
String[] potions = cond.split(",");
|
||||||
|
|
||||||
List<String> names = new ArrayList<String>();
|
List<String> names = new ArrayList<String>();
|
||||||
List<Integer> levels = new ArrayList<Integer>();
|
List<Integer> levels = new ArrayList<Integer>();
|
||||||
|
|
||||||
for(int i = 0; i < potions.length; i++)
|
for (int i = 0; i < potions.length; i++) {
|
||||||
{
|
|
||||||
String pot = potions[i];
|
String pot = potions[i];
|
||||||
if(pot.contains("#"))
|
if (pot.contains("#")) {
|
||||||
{
|
|
||||||
String level = pot.substring(pot.indexOf("#"));
|
String level = pot.substring(pot.indexOf("#"));
|
||||||
String name = pot.substring(0, pot.indexOf("#"));
|
String name = pot.substring(0, pot.indexOf("#"));
|
||||||
level = level.replace("#", "");
|
level = level.replace("#", "");
|
||||||
int lev = 0;
|
int lev = 0;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
lev = Integer.parseInt(level);
|
lev = Integer.parseInt(level);
|
||||||
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
|
||||||
{}
|
|
||||||
|
|
||||||
levels.add(lev);
|
levels.add(lev);
|
||||||
names.add(name);
|
names.add(name);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
levels.add(0);
|
levels.add(0);
|
||||||
names.add(pot);
|
names.add(pot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int matches = 0;
|
int matches = 0;
|
||||||
for(EffectInstance effect : effects)
|
for (MobEffectInstance effect : effects) {
|
||||||
{
|
|
||||||
int amp = effect.getAmplifier();
|
int amp = effect.getAmplifier();
|
||||||
String name = effect.getEffect().getRegistryName().toString();
|
String name = effect.getEffect().getRegistryName().toString();
|
||||||
|
|
||||||
if(names.contains(name))
|
if (names.contains(name)) {
|
||||||
{
|
|
||||||
int idx = names.indexOf(name);
|
int idx = names.indexOf(name);
|
||||||
int lev = levels.get(idx);
|
int lev = levels.get(idx);
|
||||||
|
|
||||||
if(lev == amp)
|
if (lev == amp)
|
||||||
matches++;
|
matches++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return matches == potions.length;
|
return matches == potions.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean matches(Material material, String cond)
|
public static boolean matches(Material material, String cond) {
|
||||||
{
|
|
||||||
if (cond == null || cond.isEmpty())
|
if (cond == null || cond.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
switch (cond)
|
switch (cond) {
|
||||||
{
|
|
||||||
case "air":
|
case "air":
|
||||||
return material == Material.AIR;
|
return material == Material.AIR;
|
||||||
case "anvil":
|
case "anvil":
|
||||||
|
|
@ -295,8 +253,6 @@ public class ScriptParseHelper
|
||||||
return material == Material.CLAY;
|
return material == Material.CLAY;
|
||||||
case "cloth":
|
case "cloth":
|
||||||
return material == Material.WOOL;
|
return material == Material.WOOL;
|
||||||
case "coral":
|
|
||||||
return material == Material.CORAL;
|
|
||||||
case "dragon_egg":
|
case "dragon_egg":
|
||||||
return material == Material.EGG;
|
return material == Material.EGG;
|
||||||
case "fire":
|
case "fire":
|
||||||
|
|
@ -347,8 +303,9 @@ public class ScriptParseHelper
|
||||||
return material == Material.WEB;
|
return material == Material.WEB;
|
||||||
case "wood":
|
case "wood":
|
||||||
return material == Material.WOOD;
|
return material == Material.WOOD;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,14 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.mojang.brigadier.StringReader;
|
import com.mojang.brigadier.StringReader;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.commands.arguments.blocks.BlockStateParser;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.commands.arguments.item.ItemParser;
|
||||||
import net.minecraft.command.arguments.BlockStateParser;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.command.arguments.ItemParser;
|
import net.minecraft.nbt.TagParser;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.nbt.JsonToNBT;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
public class StringParser
|
public class StringParser
|
||||||
{
|
{
|
||||||
|
|
@ -78,7 +78,7 @@ public class StringParser
|
||||||
{
|
{
|
||||||
parser.parse();
|
parser.parse();
|
||||||
Item item = parser.getItem();
|
Item item = parser.getItem();
|
||||||
CompoundNBT nbt = parser.getNbt();
|
CompoundTag nbt = parser.getNbt();
|
||||||
|
|
||||||
ItemStack stack = new ItemStack(item, 1);
|
ItemStack stack = new ItemStack(item, 1);
|
||||||
|
|
||||||
|
|
@ -99,9 +99,9 @@ public class StringParser
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static CompoundNBT getTagCompound(String string)
|
public static CompoundTag getTagCompound(String string)
|
||||||
{
|
{
|
||||||
CompoundNBT tag = null;
|
CompoundTag tag = null;
|
||||||
if(string == null)
|
if(string == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
@ -114,7 +114,7 @@ public class StringParser
|
||||||
string = string.replace(nbt, "");
|
string = string.replace(nbt, "");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tag = JsonToNBT.parseTag(nbt);
|
tag = TagParser.parseTag(nbt);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,31 +6,31 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.CharMatcher;
|
import com.google.common.base.CharMatcher;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.network.chat.ClickEvent;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.network.chat.ClickEvent.Action;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.item.ItemUseContext;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.potion.EffectInstance;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
import net.minecraft.potion.Effects;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.world.item.context.UseOnContext;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.util.text.event.ClickEvent;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.util.text.event.ClickEvent.Action;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.util.BlockSnapshot;
|
import net.minecraftforge.common.util.BlockSnapshot;
|
||||||
import net.minecraftforge.event.world.BlockEvent.EntityPlaceEvent;
|
import net.minecraftforge.event.world.BlockEvent.EntityPlaceEvent;
|
||||||
|
|
@ -55,12 +55,12 @@ public class ItemCarryonBlock extends Item
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITextComponent getName(ItemStack stack)
|
public Component getName(ItemStack stack)
|
||||||
{
|
{
|
||||||
if (hasTileData(stack))
|
if (hasTileData(stack))
|
||||||
{
|
{
|
||||||
BlockState state = getBlockState(stack);
|
BlockState state = getBlockState(stack);
|
||||||
CompoundNBT nbt = getTileData(stack);
|
CompoundTag nbt = getTileData(stack);
|
||||||
|
|
||||||
if (ModelOverridesHandler.hasCustomOverrideModel(state, nbt))
|
if (ModelOverridesHandler.hasCustomOverrideModel(state, nbt))
|
||||||
{
|
{
|
||||||
|
|
@ -77,39 +77,39 @@ public class ItemCarryonBlock extends Item
|
||||||
return getItemStack(stack).getHoverName();
|
return getItemStack(stack).getHoverName();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new StringTextComponent("");
|
return new TextComponent("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType useOn(ItemUseContext context)
|
public InteractionResult useOn(UseOnContext context)
|
||||||
{
|
{
|
||||||
Direction facing = context.getClickedFace();
|
Direction facing = context.getClickedFace();
|
||||||
PlayerEntity player = context.getPlayer();
|
Player player = context.getPlayer();
|
||||||
World world = context.getLevel();
|
Level world = context.getLevel();
|
||||||
BlockPos pos = context.getClickedPos();
|
BlockPos pos = context.getClickedPos();
|
||||||
ItemStack stack = context.getItemInHand();
|
ItemStack stack = context.getItemInHand();
|
||||||
|
|
||||||
if (ModList.get().isLoaded("betterplacement"))
|
if (ModList.get().isLoaded("betterplacement"))
|
||||||
{
|
{
|
||||||
if (CarryOnKeybinds.isKeyPressed(player))
|
if (CarryOnKeybinds.isKeyPressed(player))
|
||||||
return ActionResultType.FAIL;
|
return InteractionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasTileData(stack))
|
if (hasTileData(stack))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Vector3d vec = player.getLookAngle();
|
Vec3 vec = player.getLookAngle();
|
||||||
Direction facing2 = Direction.getNearest((float) vec.x, 0f, (float) vec.z);
|
Direction facing2 = Direction.getNearest((float) vec.x, 0f, (float) vec.z);
|
||||||
BlockPos pos2 = pos;
|
BlockPos pos2 = pos;
|
||||||
Block containedblock = getBlock(stack);
|
Block containedblock = getBlock(stack);
|
||||||
BlockState containedstate = getBlockState(stack);
|
BlockState containedstate = getBlockState(stack);
|
||||||
if (!world.getBlockState(pos2).canBeReplaced(new BlockItemUseContext(context)))
|
if (!world.getBlockState(pos2).canBeReplaced(new BlockPlaceContext(context)))
|
||||||
{
|
{
|
||||||
pos2 = pos.relative(facing);
|
pos2 = pos.relative(facing);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (world.getBlockState(pos2).canBeReplaced(new BlockItemUseContext(context)) && containedblock != null)
|
if (world.getBlockState(pos2).canBeReplaced(new BlockPlaceContext(context)) && containedblock != null)
|
||||||
{
|
{
|
||||||
boolean canPlace = containedstate.canSurvive(world, pos2);
|
boolean canPlace = containedstate.canSurvive(world, pos2);
|
||||||
|
|
||||||
|
|
@ -118,7 +118,7 @@ public class ItemCarryonBlock extends Item
|
||||||
if (player.mayUseItemAt(pos, facing, stack) && world.mayInteract(player, pos2))
|
if (player.mayUseItemAt(pos, facing, stack) && world.mayInteract(player, pos2))
|
||||||
{
|
{
|
||||||
|
|
||||||
BlockState placementState = containedblock.getStateForPlacement(new BlockItemUseContext(context));
|
BlockState placementState = containedblock.getStateForPlacement(new BlockPlaceContext(context));
|
||||||
|
|
||||||
BlockState actualState = placementState == null ? containedstate : placementState;
|
BlockState actualState = placementState == null ? containedstate : placementState;
|
||||||
|
|
||||||
|
|
@ -152,7 +152,7 @@ public class ItemCarryonBlock extends Item
|
||||||
// change rotation via NBT
|
// change rotation via NBT
|
||||||
if (!getTileData(stack).isEmpty())
|
if (!getTileData(stack).isEmpty())
|
||||||
{
|
{
|
||||||
CompoundNBT tag = getTileData(stack);
|
CompoundTag tag = getTileData(stack);
|
||||||
Set<String> keys = tag.getAllKeys();
|
Set<String> keys = tag.getAllKeys();
|
||||||
keytester: for (String key : keys)
|
keytester: for (String key : keys)
|
||||||
{
|
{
|
||||||
|
|
@ -182,19 +182,19 @@ public class ItemCarryonBlock extends Item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntity tile = world.getBlockEntity(pos2);
|
BlockEntity tile = world.getBlockEntity(pos2);
|
||||||
if (tile != null)
|
if (tile != null)
|
||||||
{
|
{
|
||||||
CompoundNBT data = getTileData(stack);
|
CompoundTag data = getTileData(stack);
|
||||||
updateTileLocation(data, pos2);
|
updateTileLocation(data, pos2);
|
||||||
tile.load(actualState, data);
|
tile.load(data);
|
||||||
}
|
}
|
||||||
clearTileData(stack);
|
clearTileData(stack);
|
||||||
player.playSound(actualState.getSoundType(world, pos2, player).getPlaceSound(), 1.0f, 0.5f);
|
player.playSound(actualState.getSoundType(world, pos2, player).getPlaceSound(), 1.0f, 0.5f);
|
||||||
player.setItemInHand(Hand.MAIN_HAND, ItemStack.EMPTY);
|
player.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);
|
||||||
player.getPersistentData().remove("overrideKey");
|
player.getPersistentData().remove("overrideKey");
|
||||||
ItemEvents.sendPacket(player, 9, 0);
|
ItemEvents.sendPacket(player, 9, 0);
|
||||||
return ActionResultType.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -219,30 +219,30 @@ public class ItemCarryonBlock extends Item
|
||||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemCarryonBlock.getBlockState(stack)))
|
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemCarryonBlock.getBlockState(stack)))
|
||||||
CarryOn.LOGGER.info("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemCarryonBlock.getBlockState(stack)));
|
CarryOn.LOGGER.info("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemCarryonBlock.getBlockState(stack)));
|
||||||
|
|
||||||
player.displayClientMessage(new StringTextComponent(TextFormatting.RED + "Error detected. Cannot place block. Execute \"/carryon clear\" to remove the item"), false);
|
player.displayClientMessage(new TextComponent(ChatFormatting.RED + "Error detected. Cannot place block. Execute \"/carryon clear\" to remove the item"), false);
|
||||||
StringTextComponent s = new StringTextComponent(TextFormatting.GOLD + "here");
|
TextComponent s = new TextComponent(ChatFormatting.GOLD + "here");
|
||||||
s.getStyle().withClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/Tschipp/CarryOn/issues"));
|
s.getStyle().withClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/Tschipp/CarryOn/issues"));
|
||||||
player.displayClientMessage(new StringTextComponent(TextFormatting.RED + "Please report this error ").append(s), false);
|
player.displayClientMessage(new TextComponent(ChatFormatting.RED + "Please report this error ").append(s), false);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ActionResultType.FAIL;
|
return InteractionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inventoryTick(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected)
|
public void inventoryTick(ItemStack stack, Level world, Entity entity, int itemSlot, boolean isSelected)
|
||||||
{
|
{
|
||||||
if (hasTileData(stack))
|
if (hasTileData(stack))
|
||||||
{
|
{
|
||||||
if (entity instanceof LivingEntity)
|
if (entity instanceof LivingEntity)
|
||||||
{
|
{
|
||||||
if (entity instanceof PlayerEntity && Settings.slownessInCreative.get() ? false : ((PlayerEntity) entity).isCreative())
|
if (entity instanceof Player && Settings.slownessInCreative.get() ? false : ((Player) entity).isCreative())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
((LivingEntity) entity).addEffect(new EffectInstance(Effects.MOVEMENT_SLOWDOWN, 1, potionLevel(stack), false, false));
|
((LivingEntity) entity).addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 1, potionLevel(stack), false, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -255,22 +255,22 @@ public class ItemCarryonBlock extends Item
|
||||||
{
|
{
|
||||||
if (stack.hasTag())
|
if (stack.hasTag())
|
||||||
{
|
{
|
||||||
CompoundNBT tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
return tag.contains(TILE_DATA_KEY) && tag.contains("block") && tag.contains("stateid");
|
return tag.contains(TILE_DATA_KEY) && tag.contains("block") && tag.contains("stateid");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean storeTileData(@Nullable TileEntity tile, World world, BlockPos pos, BlockState state, ItemStack stack)
|
public static boolean storeTileData(@Nullable BlockEntity tile, Level world, BlockPos pos, BlockState state, ItemStack stack)
|
||||||
{
|
{
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CompoundNBT tileTag = new CompoundNBT();
|
CompoundTag tileTag = new CompoundTag();
|
||||||
if (tile != null)
|
if (tile != null)
|
||||||
tileTag = tile.save(tileTag);
|
tileTag = tile.save(tileTag);
|
||||||
|
|
||||||
CompoundNBT tag = stack.hasTag() ? stack.getTag() : new CompoundNBT();
|
CompoundTag tag = stack.hasTag() ? stack.getTag() : new CompoundTag();
|
||||||
if (tag.contains(TILE_DATA_KEY))
|
if (tag.contains(TILE_DATA_KEY))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -287,7 +287,7 @@ public class ItemCarryonBlock extends Item
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateTileLocation(CompoundNBT tag, BlockPos pos)
|
public static void updateTileLocation(CompoundTag tag, BlockPos pos)
|
||||||
{
|
{
|
||||||
tag.putInt("x", pos.getX());
|
tag.putInt("x", pos.getX());
|
||||||
tag.putInt("y", pos.getY());
|
tag.putInt("y", pos.getY());
|
||||||
|
|
@ -298,18 +298,18 @@ public class ItemCarryonBlock extends Item
|
||||||
{
|
{
|
||||||
if (stack.hasTag())
|
if (stack.hasTag())
|
||||||
{
|
{
|
||||||
CompoundNBT tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
tag.remove(TILE_DATA_KEY);
|
tag.remove(TILE_DATA_KEY);
|
||||||
tag.remove("block");
|
tag.remove("block");
|
||||||
tag.remove("stateid");
|
tag.remove("stateid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CompoundNBT getTileData(ItemStack stack)
|
public static CompoundTag getTileData(ItemStack stack)
|
||||||
{
|
{
|
||||||
if (stack.hasTag())
|
if (stack.hasTag())
|
||||||
{
|
{
|
||||||
CompoundNBT tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
return tag.getCompound(TILE_DATA_KEY);
|
return tag.getCompound(TILE_DATA_KEY);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -319,7 +319,7 @@ public class ItemCarryonBlock extends Item
|
||||||
{
|
{
|
||||||
if (stack.hasTag())
|
if (stack.hasTag())
|
||||||
{
|
{
|
||||||
CompoundNBT tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
int id = tag.getInt("stateid");
|
int id = tag.getInt("stateid");
|
||||||
return Block.stateById(id).getBlock();
|
return Block.stateById(id).getBlock();
|
||||||
}
|
}
|
||||||
|
|
@ -346,19 +346,19 @@ public class ItemCarryonBlock extends Item
|
||||||
{
|
{
|
||||||
if (stack.hasTag())
|
if (stack.hasTag())
|
||||||
{
|
{
|
||||||
CompoundNBT tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
int id = tag.getInt("stateid");
|
int id = tag.getInt("stateid");
|
||||||
return Block.stateById(id);
|
return Block.stateById(id);
|
||||||
}
|
}
|
||||||
return Blocks.AIR.defaultBlockState();
|
return Blocks.AIR.defaultBlockState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLocked(BlockPos pos, World world)
|
public static boolean isLocked(BlockPos pos, Level world)
|
||||||
{
|
{
|
||||||
TileEntity te = world.getBlockEntity(pos);
|
BlockEntity te = world.getBlockEntity(pos);
|
||||||
if (te != null)
|
if (te != null)
|
||||||
{
|
{
|
||||||
CompoundNBT tag = new CompoundNBT();
|
CompoundTag tag = new CompoundTag();
|
||||||
te.save(tag);
|
te.save(tag);
|
||||||
return tag.contains("Lock") ? !tag.getString("Lock").equals("") : false;
|
return tag.contains("Lock") ? !tag.getString("Lock").equals("") : false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,29 +5,29 @@ import java.util.Optional;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.entity.MobEntity;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.network.chat.TranslatableComponent;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.item.ItemUseContext;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.potion.EffectInstance;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.potion.Effects;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.world.entity.Mob;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.world.item.context.UseOnContext;
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraftforge.fml.ModList;
|
import net.minecraftforge.fml.ModList;
|
||||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
|
||||||
import tschipp.carryon.CarryOn;
|
import tschipp.carryon.CarryOn;
|
||||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||||
import tschipp.carryon.common.config.Configs.Settings;
|
import tschipp.carryon.common.config.Configs.Settings;
|
||||||
|
|
@ -39,7 +39,7 @@ public class ItemCarryonEntity extends Item {
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
initGoals = ObfuscationReflectionHelper.findMethod(MobEntity.class, "func_184651_r");
|
initGoals = ObfuscationReflectionHelper.findMethod(Mob.class, "m_8099_");
|
||||||
initGoals.setAccessible(true);
|
initGoals.setAccessible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,37 +51,37 @@ public class ItemCarryonEntity extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITextComponent getName(ItemStack stack)
|
public Component getName(ItemStack stack)
|
||||||
{
|
{
|
||||||
if (hasEntityData(stack)) {
|
if (hasEntityData(stack)) {
|
||||||
|
|
||||||
return new TranslationTextComponent(getEntityType(stack).getDescriptionId());
|
return new TranslatableComponent(getEntityType(stack).getDescriptionId());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new StringTextComponent("");
|
return new TextComponent("");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasEntityData(ItemStack stack) {
|
public static boolean hasEntityData(ItemStack stack) {
|
||||||
if (stack.hasTag()) {
|
if (stack.hasTag()) {
|
||||||
CompoundNBT tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
return tag.contains(ENTITY_DATA_KEY) && tag.contains("entity");
|
return tag.contains(ENTITY_DATA_KEY) && tag.contains("entity");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean storeEntityData(@Nonnull Entity entity, World world, ItemStack stack) {
|
public static boolean storeEntityData(@Nonnull Entity entity, Level world, ItemStack stack) {
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CompoundNBT entityData = new CompoundNBT();
|
CompoundTag entityData = new CompoundTag();
|
||||||
entityData = entity.serializeNBT();
|
entityData = entity.serializeNBT();
|
||||||
|
|
||||||
String name = EntityType.getKey(entity.getType()).toString();
|
String name = EntityType.getKey(entity.getType()).toString();
|
||||||
|
|
||||||
CompoundNBT tag = stack.hasTag() ? stack.getTag() : new CompoundNBT();
|
CompoundTag tag = stack.hasTag() ? stack.getTag() : new CompoundTag();
|
||||||
if (tag.contains(ENTITY_DATA_KEY))
|
if (tag.contains(ENTITY_DATA_KEY))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -92,9 +92,9 @@ public class ItemCarryonEntity extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType useOn(ItemUseContext context) {
|
public InteractionResult useOn(UseOnContext context) {
|
||||||
PlayerEntity player = context.getPlayer();
|
Player player = context.getPlayer();
|
||||||
World world = context.getLevel();
|
Level world = context.getLevel();
|
||||||
BlockPos pos = context.getClickedPos();
|
BlockPos pos = context.getClickedPos();
|
||||||
Direction facing = context.getClickedFace();
|
Direction facing = context.getClickedFace();
|
||||||
|
|
||||||
|
|
@ -104,13 +104,13 @@ public class ItemCarryonEntity extends Item {
|
||||||
|
|
||||||
if (ModList.get().isLoaded("betterplacement")) {
|
if (ModList.get().isLoaded("betterplacement")) {
|
||||||
if (CarryOnKeybinds.isKeyPressed(player))
|
if (CarryOnKeybinds.isKeyPressed(player))
|
||||||
return ActionResultType.FAIL;
|
return InteractionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasEntityData(stack)) {
|
if (hasEntityData(stack)) {
|
||||||
BlockPos finalPos = pos;
|
BlockPos finalPos = pos;
|
||||||
|
|
||||||
if (!state.canBeReplaced(new BlockItemUseContext(context))) {
|
if (!state.canBeReplaced(new BlockPlaceContext(context))) {
|
||||||
finalPos = pos.relative(facing);
|
finalPos = pos.relative(facing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,35 +120,35 @@ public class ItemCarryonEntity extends Item {
|
||||||
entity.absMoveTo(finalPos.getX() + 0.5, finalPos.getY(), finalPos.getZ() + 0.5,
|
entity.absMoveTo(finalPos.getX() + 0.5, finalPos.getY(), finalPos.getZ() + 0.5,
|
||||||
180 + player.yHeadRot, 0.0f);
|
180 + player.yHeadRot, 0.0f);
|
||||||
world.addFreshEntity(entity);
|
world.addFreshEntity(entity);
|
||||||
if (entity instanceof MobEntity) {
|
if (entity instanceof Mob) {
|
||||||
((MobEntity) entity).playAmbientSound();
|
((Mob) entity).playAmbientSound();
|
||||||
}
|
}
|
||||||
clearEntityData(stack);
|
clearEntityData(stack);
|
||||||
player.setItemInHand(Hand.MAIN_HAND, ItemStack.EMPTY);
|
player.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);
|
||||||
ItemEvents.sendPacket(player, 9, 0);
|
ItemEvents.sendPacket(player, 9, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
player.getPersistentData().remove("overrideKey");
|
player.getPersistentData().remove("overrideKey");
|
||||||
return ActionResultType.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ActionResultType.FAIL;
|
return InteractionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inventoryTick(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
|
public void inventoryTick(ItemStack stack, Level world, Entity entity, int itemSlot, boolean isSelected) {
|
||||||
if (hasEntityData(stack)) {
|
if (hasEntityData(stack)) {
|
||||||
if (getEntity(stack, world) == null)
|
if (getEntity(stack, world) == null)
|
||||||
stack = ItemStack.EMPTY;
|
stack = ItemStack.EMPTY;
|
||||||
|
|
||||||
if (entity instanceof LivingEntity) {
|
if (entity instanceof LivingEntity) {
|
||||||
if (entity instanceof PlayerEntity && Settings.slownessInCreative.get() ? false
|
if (entity instanceof Player && Settings.slownessInCreative.get() ? false
|
||||||
: ((PlayerEntity) entity).isCreative())
|
: ((Player) entity).isCreative())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
((LivingEntity) entity).addEffect(
|
((LivingEntity) entity).addEffect(
|
||||||
new EffectInstance(Effects.MOVEMENT_SLOWDOWN, 1, potionLevel(stack, world), false, false));
|
new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 1, potionLevel(stack, world), false, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -158,27 +158,27 @@ public class ItemCarryonEntity extends Item {
|
||||||
|
|
||||||
public static void clearEntityData(ItemStack stack) {
|
public static void clearEntityData(ItemStack stack) {
|
||||||
if (stack.hasTag()) {
|
if (stack.hasTag()) {
|
||||||
CompoundNBT tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
tag.remove(ENTITY_DATA_KEY);
|
tag.remove(ENTITY_DATA_KEY);
|
||||||
tag.remove("entity");
|
tag.remove("entity");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CompoundNBT getPersistentData(ItemStack stack) {
|
public static CompoundTag getPersistentData(ItemStack stack) {
|
||||||
if (stack.hasTag()) {
|
if (stack.hasTag()) {
|
||||||
CompoundNBT tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
return tag.getCompound(ENTITY_DATA_KEY);
|
return tag.getCompound(ENTITY_DATA_KEY);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Entity getEntity(ItemStack stack, World world) {
|
public static Entity getEntity(ItemStack stack, Level world) {
|
||||||
if (world == null)
|
if (world == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
String name = getEntityName(stack);
|
String name = getEntityName(stack);
|
||||||
|
|
||||||
CompoundNBT e = getPersistentData(stack);
|
CompoundTag e = getPersistentData(stack);
|
||||||
Optional<EntityType<?>> type = EntityType.byString(name);
|
Optional<EntityType<?>> type = EntityType.byString(name);
|
||||||
Entity entity = null;
|
Entity entity = null;
|
||||||
|
|
||||||
|
|
@ -203,7 +203,7 @@ public class ItemCarryonEntity extends Item {
|
||||||
|
|
||||||
public static String getEntityName(ItemStack stack) {
|
public static String getEntityName(ItemStack stack) {
|
||||||
if (stack.hasTag()) {
|
if (stack.hasTag()) {
|
||||||
CompoundNBT tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
return tag.getString("entity");
|
return tag.getString("entity");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -211,7 +211,7 @@ public class ItemCarryonEntity extends Item {
|
||||||
|
|
||||||
public static String getCustomName(ItemStack stack) {
|
public static String getCustomName(ItemStack stack) {
|
||||||
if (stack.hasTag()) {
|
if (stack.hasTag()) {
|
||||||
CompoundNBT tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
if (tag.contains("CustomName") && !tag.getString("CustomName").isEmpty()) {
|
if (tag.contains("CustomName") && !tag.getString("CustomName").isEmpty()) {
|
||||||
return tag.toString();
|
return tag.toString();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -223,7 +223,7 @@ public class ItemCarryonEntity extends Item {
|
||||||
|
|
||||||
public static EntityType<?> getEntityType(ItemStack stack) {
|
public static EntityType<?> getEntityType(ItemStack stack) {
|
||||||
if (stack.hasTag()) {
|
if (stack.hasTag()) {
|
||||||
CompoundNBT tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
String name = tag.getString("entity");
|
String name = tag.getString("entity");
|
||||||
Optional<EntityType<?>> type = EntityType.byString(name);
|
Optional<EntityType<?>> type = EntityType.byString(name);
|
||||||
if (type.isPresent())
|
if (type.isPresent())
|
||||||
|
|
@ -232,7 +232,7 @@ public class ItemCarryonEntity extends Item {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int potionLevel(ItemStack stack, World world) {
|
private int potionLevel(ItemStack stack, Level world) {
|
||||||
Entity e = getEntity(stack, world);
|
Entity e = getEntity(stack, world);
|
||||||
if (e == null)
|
if (e == null)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
|
|
@ -3,23 +3,23 @@ package tschipp.carryon.common.scripting;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.JsonToNBT;
|
import net.minecraft.nbt.TagParser;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import tschipp.carryon.common.helper.InvalidConfigException;
|
import tschipp.carryon.common.helper.InvalidConfigException;
|
||||||
|
|
||||||
public class CarryOnOverride
|
public class CarryOnOverride
|
||||||
{
|
{
|
||||||
// BLOCKS
|
// BLOCKS
|
||||||
private CompoundNBT typeBlockTag = new CompoundNBT();
|
private CompoundTag typeBlockTag = new CompoundTag();
|
||||||
private String typeNameBlock = "";
|
private String typeNameBlock = "";
|
||||||
private String typeMaterial = "";
|
private String typeMaterial = "";
|
||||||
private String typeHardness = "";
|
private String typeHardness = "";
|
||||||
private String typeResistance = "";
|
private String typeResistance = "";
|
||||||
|
|
||||||
// ENTITIES
|
// ENTITIES
|
||||||
private CompoundNBT typeEntityTag;
|
private CompoundTag typeEntityTag;
|
||||||
private String typeNameEntity = "";
|
private String typeNameEntity = "";
|
||||||
private String typeHeight = "";
|
private String typeHeight = "";
|
||||||
private String typeWidth = "";
|
private String typeWidth = "";
|
||||||
|
|
@ -37,7 +37,7 @@ public class CarryOnOverride
|
||||||
// RENDER
|
// RENDER
|
||||||
private String renderNameBlock = "";
|
private String renderNameBlock = "";
|
||||||
private String renderNameEntity = "";
|
private String renderNameEntity = "";
|
||||||
private CompoundNBT renderNBT = new CompoundNBT();
|
private CompoundTag renderNBT = new CompoundTag();
|
||||||
private String renderTranslation = "";
|
private String renderTranslation = "";
|
||||||
private String renderRotation = "";
|
private String renderRotation = "";
|
||||||
private String renderscaled = "";
|
private String renderscaled = "";
|
||||||
|
|
@ -104,7 +104,7 @@ public class CarryOnOverride
|
||||||
if (resistance != null)
|
if (resistance != null)
|
||||||
setTypeResistance(resistance.getAsString());
|
setTypeResistance(resistance.getAsString());
|
||||||
if (nbt != null)
|
if (nbt != null)
|
||||||
setTypeBlockTag(JsonToNBT.parseTag(nbt.toString()));
|
setTypeBlockTag(TagParser.parseTag(nbt.toString()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -124,7 +124,7 @@ public class CarryOnOverride
|
||||||
if (width != null)
|
if (width != null)
|
||||||
setTypeWidth(width.getAsString());
|
setTypeWidth(width.getAsString());
|
||||||
if (nbt != null)
|
if (nbt != null)
|
||||||
setTypeEntityTag(JsonToNBT.parseTag(nbt.toString()));
|
setTypeEntityTag(TagParser.parseTag(nbt.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conditions != null)
|
if (conditions != null)
|
||||||
|
|
@ -177,7 +177,7 @@ public class CarryOnOverride
|
||||||
if (scaled != null)
|
if (scaled != null)
|
||||||
setRenderscaled(scaled.getAsString());
|
setRenderscaled(scaled.getAsString());
|
||||||
if (nbt != null)
|
if (nbt != null)
|
||||||
setRenderNBT(JsonToNBT.parseTag(nbt.toString()));
|
setRenderNBT(TagParser.parseTag(nbt.toString()));
|
||||||
if (rotationLeftArm != null)
|
if (rotationLeftArm != null)
|
||||||
setRenderRotationLeftArm(rotationLeftArm.getAsString());
|
setRenderRotationLeftArm(rotationLeftArm.getAsString());
|
||||||
if (rotationRightArm != null)
|
if (rotationRightArm != null)
|
||||||
|
|
@ -550,7 +550,7 @@ public class CarryOnOverride
|
||||||
this.isEntity = isEntity;
|
this.isEntity = isEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompoundNBT getTypeBlockTag()
|
public CompoundTag getTypeBlockTag()
|
||||||
{
|
{
|
||||||
return typeBlockTag;
|
return typeBlockTag;
|
||||||
}
|
}
|
||||||
|
|
@ -575,7 +575,7 @@ public class CarryOnOverride
|
||||||
return typeResistance;
|
return typeResistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompoundNBT getTypeEntityTag()
|
public CompoundTag getTypeEntityTag()
|
||||||
{
|
{
|
||||||
return typeEntityTag;
|
return typeEntityTag;
|
||||||
}
|
}
|
||||||
|
|
@ -640,7 +640,7 @@ public class CarryOnOverride
|
||||||
return renderNameEntity;
|
return renderNameEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompoundNBT getRenderNBT()
|
public CompoundTag getRenderNBT()
|
||||||
{
|
{
|
||||||
return renderNBT;
|
return renderNBT;
|
||||||
}
|
}
|
||||||
|
|
@ -660,7 +660,7 @@ public class CarryOnOverride
|
||||||
return renderscaled;
|
return renderscaled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTypeBlockTag(CompoundNBT typeBlockTag)
|
public void setTypeBlockTag(CompoundTag typeBlockTag)
|
||||||
{
|
{
|
||||||
this.typeBlockTag = typeBlockTag;
|
this.typeBlockTag = typeBlockTag;
|
||||||
}
|
}
|
||||||
|
|
@ -685,7 +685,7 @@ public class CarryOnOverride
|
||||||
this.typeResistance = typeResistance;
|
this.typeResistance = typeResistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTypeEntityTag(CompoundNBT typeEntityTag)
|
public void setTypeEntityTag(CompoundTag typeEntityTag)
|
||||||
{
|
{
|
||||||
this.typeEntityTag = typeEntityTag;
|
this.typeEntityTag = typeEntityTag;
|
||||||
}
|
}
|
||||||
|
|
@ -750,7 +750,7 @@ public class CarryOnOverride
|
||||||
this.renderNameEntity = renderNameEntity;
|
this.renderNameEntity = renderNameEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRenderNBT(CompoundNBT renderNBT)
|
public void setRenderNBT(CompoundTag renderNBT)
|
||||||
{
|
{
|
||||||
this.renderNBT = renderNBT;
|
this.renderNBT = renderNBT;
|
||||||
}
|
}
|
||||||
|
|
@ -780,7 +780,7 @@ public class CarryOnOverride
|
||||||
this.commandPlace = commandPlace;
|
this.commandPlace = commandPlace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(PacketBuffer buf)
|
public void serialize(FriendlyByteBuf buf)
|
||||||
{
|
{
|
||||||
// BLOCKS
|
// BLOCKS
|
||||||
buf.writeNbt(typeBlockTag);
|
buf.writeNbt(typeBlockTag);
|
||||||
|
|
@ -827,7 +827,7 @@ public class CarryOnOverride
|
||||||
buf.writeUtf(resourceLocation);
|
buf.writeUtf(resourceLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CarryOnOverride deserialize(PacketBuffer buf)
|
public static CarryOnOverride deserialize(FriendlyByteBuf buf)
|
||||||
{
|
{
|
||||||
CarryOnOverride override = new CarryOnOverride("");
|
CarryOnOverride override = new CarryOnOverride("");
|
||||||
override.typeBlockTag = buf.readNbt();
|
override.typeBlockTag = buf.readNbt();
|
||||||
|
|
|
||||||
|
|
@ -5,20 +5,20 @@ import java.lang.reflect.Method;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import net.minecraft.advancements.Advancement;
|
import net.minecraft.advancements.Advancement;
|
||||||
import net.minecraft.advancements.AdvancementManager;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.server.ServerAdvancementManager;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraftforge.fml.ModList;
|
import net.minecraftforge.fml.ModList;
|
||||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
|
||||||
import tschipp.carryon.common.config.Configs.Settings;
|
import tschipp.carryon.common.config.Configs.Settings;
|
||||||
import tschipp.carryon.common.handler.ListHandler;
|
import tschipp.carryon.common.handler.ListHandler;
|
||||||
import tschipp.carryon.common.helper.ScriptParseHelper;
|
import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||||
|
|
@ -26,7 +26,7 @@ import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||||
public class ScriptChecker
|
public class ScriptChecker
|
||||||
{
|
{
|
||||||
@Nullable
|
@Nullable
|
||||||
public static CarryOnOverride inspectBlock(BlockState state, World world, BlockPos pos, @Nullable CompoundNBT tag)
|
public static CarryOnOverride inspectBlock(BlockState state, Level world, BlockPos pos, @Nullable CompoundTag tag)
|
||||||
{
|
{
|
||||||
if (!Settings.useScripts.get())
|
if (!Settings.useScripts.get())
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -36,7 +36,7 @@ public class ScriptChecker
|
||||||
float hardness = state.getDestroySpeed(world, pos);
|
float hardness = state.getDestroySpeed(world, pos);
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
float resistance = block.getExplosionResistance();
|
float resistance = block.getExplosionResistance();
|
||||||
CompoundNBT nbt = tag;
|
CompoundTag nbt = tag;
|
||||||
|
|
||||||
boolean isAllowed = Settings.useWhitelistBlocks.get() ? ListHandler.isAllowed(block) : !ListHandler.isForbidden(block);
|
boolean isAllowed = Settings.useWhitelistBlocks.get() ? ListHandler.isAllowed(block) : !ListHandler.isForbidden(block);
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ public class ScriptChecker
|
||||||
float height = entity.getBbHeight();
|
float height = entity.getBbHeight();
|
||||||
float width = entity.getBbWidth();
|
float width = entity.getBbWidth();
|
||||||
float health = entity instanceof LivingEntity ? ((LivingEntity) entity).getHealth() : 0.0f;
|
float health = entity instanceof LivingEntity ? ((LivingEntity) entity).getHealth() : 0.0f;
|
||||||
CompoundNBT tag = entity.serializeNBT();
|
CompoundTag tag = entity.serializeNBT();
|
||||||
|
|
||||||
|
|
||||||
boolean isAllowed = Settings.useWhitelistEntities.get() ? ListHandler.isAllowed(entity) : !ListHandler.isForbidden(entity);
|
boolean isAllowed = Settings.useWhitelistEntities.get() ? ListHandler.isAllowed(entity) : !ListHandler.isForbidden(entity);
|
||||||
|
|
@ -85,7 +85,7 @@ public class ScriptChecker
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean matchesAll(CarryOnOverride override, String name, float height, float width, float health, CompoundNBT tag)
|
public static boolean matchesAll(CarryOnOverride override, String name, float height, float width, float health, CompoundTag tag)
|
||||||
{
|
{
|
||||||
boolean matchname = override.getTypeNameEntity().isEmpty() ? true : name.equals(override.getTypeNameEntity());
|
boolean matchname = override.getTypeNameEntity().isEmpty() ? true : name.equals(override.getTypeNameEntity());
|
||||||
boolean matchheight = ScriptParseHelper.matches(height, override.getTypeHeight());
|
boolean matchheight = ScriptParseHelper.matches(height, override.getTypeHeight());
|
||||||
|
|
@ -96,7 +96,7 @@ public class ScriptChecker
|
||||||
return (matchname && matchheight && matchwidth && matchhealth && matchnbt);
|
return (matchname && matchheight && matchwidth && matchhealth && matchnbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean matchesAll(CarryOnOverride override, Block block, Material material, float hardness, float resistance, CompoundNBT nbt)
|
public static boolean matchesAll(CarryOnOverride override, Block block, Material material, float hardness, float resistance, CompoundTag nbt)
|
||||||
{
|
{
|
||||||
boolean matchnbt = ScriptParseHelper.matches(nbt, override.getTypeBlockTag());
|
boolean matchnbt = ScriptParseHelper.matches(nbt, override.getTypeBlockTag());
|
||||||
boolean matchblock = ScriptParseHelper.matches(block, override.getTypeNameBlock());
|
boolean matchblock = ScriptParseHelper.matches(block, override.getTypeNameBlock());
|
||||||
|
|
@ -107,13 +107,13 @@ public class ScriptChecker
|
||||||
return (matchnbt && matchblock && matchmaterial && matchhardness && matchresistance);
|
return (matchnbt && matchblock && matchmaterial && matchhardness && matchresistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean fulfillsConditions(CarryOnOverride override, PlayerEntity player)
|
public static boolean fulfillsConditions(CarryOnOverride override, Player player)
|
||||||
{
|
{
|
||||||
AdvancementManager manager = ((ServerPlayerEntity) player).server.getAdvancements();
|
ServerAdvancementManager manager = ((ServerPlayer) player).server.getAdvancements();
|
||||||
Advancement adv = manager.getAdvancement(new ResourceLocation((override.getConditionAchievement()).isEmpty() ? "" : override.getConditionAchievement()));
|
Advancement adv = manager.getAdvancement(new ResourceLocation((override.getConditionAchievement()).isEmpty() ? "" : override.getConditionAchievement()));
|
||||||
|
|
||||||
boolean achievement = adv == null ? true : ((ServerPlayerEntity) player).getAdvancements().getOrStartProgress(adv).isDone();
|
boolean achievement = adv == null ? true : ((ServerPlayer) player).getAdvancements().getOrStartProgress(adv).isDone();
|
||||||
boolean gamemode = ScriptParseHelper.matches(((ServerPlayerEntity) player).gameMode.getGameModeForPlayer().getId(), override.getConditionGamemode());
|
boolean gamemode = ScriptParseHelper.matches(((ServerPlayer) player).gameMode.getGameModeForPlayer().getId(), override.getConditionGamemode());
|
||||||
boolean gamestage = true;
|
boolean gamestage = true;
|
||||||
if (ModList.get().isLoaded("gamestages"))
|
if (ModList.get().isLoaded("gamestages"))
|
||||||
{
|
{
|
||||||
|
|
@ -124,7 +124,7 @@ public class ScriptChecker
|
||||||
Class<?> gameStageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper");
|
Class<?> gameStageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper");
|
||||||
Class<?> iStageData = Class.forName("net.darkhax.gamestages.data.IStageData");
|
Class<?> iStageData = Class.forName("net.darkhax.gamestages.data.IStageData");
|
||||||
|
|
||||||
Method getPlayerData = ObfuscationReflectionHelper.findMethod(gameStageHelper, "getPlayerData", PlayerEntity.class);
|
Method getPlayerData = ObfuscationReflectionHelper.findMethod(gameStageHelper, "getPlayerData", Player.class);
|
||||||
Method hasStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasStage", String.class);
|
Method hasStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasStage", String.class);
|
||||||
|
|
||||||
Object stageData = getPlayerData.invoke(null, player);
|
Object stageData = getPlayerData.invoke(null, player);
|
||||||
|
|
@ -138,7 +138,7 @@ public class ScriptChecker
|
||||||
Class<?> playerDataHandler = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler");
|
Class<?> playerDataHandler = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler");
|
||||||
Class<?> iStageData = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler$IStageData");
|
Class<?> iStageData = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler$IStageData");
|
||||||
|
|
||||||
Method getStageData = ObfuscationReflectionHelper.findMethod(playerDataHandler, "getStageData", PlayerEntity.class);
|
Method getStageData = ObfuscationReflectionHelper.findMethod(playerDataHandler, "getStageData", Player.class);
|
||||||
Method hasUnlockedStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasUnlockedStage", String.class);
|
Method hasUnlockedStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasUnlockedStage", String.class);
|
||||||
|
|
||||||
Object stageData = getStageData.invoke(null, player);
|
Object stageData = getStageData.invoke(null, player);
|
||||||
|
|
@ -163,9 +163,9 @@ public class ScriptChecker
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static CarryOnOverride getOverride(PlayerEntity player)
|
public static CarryOnOverride getOverride(Player player)
|
||||||
{
|
{
|
||||||
CompoundNBT tag = player.getPersistentData();
|
CompoundTag tag = player.getPersistentData();
|
||||||
|
|
||||||
if (tag != null && tag.contains("overrideKey"))
|
if (tag != null && tag.contains("overrideKey"))
|
||||||
{
|
{
|
||||||
|
|
@ -177,9 +177,9 @@ public class ScriptChecker
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setCarryOnOverride(PlayerEntity player, int i)
|
public static void setCarryOnOverride(Player player, int i)
|
||||||
{
|
{
|
||||||
CompoundNBT tag = player.getPersistentData();
|
CompoundTag tag = player.getPersistentData();
|
||||||
|
|
||||||
if (tag != null)
|
if (tag != null)
|
||||||
tag.putInt("overrideKey", i);
|
tag.putInt("overrideKey", i);
|
||||||
|
|
|
||||||
|
|
@ -6,22 +6,22 @@ import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
|
|
||||||
import net.minecraft.client.resources.JsonReloadListener;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.profiler.IProfiler;
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
import net.minecraft.resources.IResourceManager;
|
import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.profiling.ProfilerFiller;
|
||||||
import net.minecraftforge.event.AddReloadListenerEvent;
|
import net.minecraftforge.event.AddReloadListenerEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
||||||
import net.minecraftforge.fml.common.thread.EffectiveSide;
|
import net.minecraftforge.fml.util.thread.EffectiveSide;
|
||||||
import net.minecraftforge.fml.network.PacketDistributor;
|
import net.minecraftforge.fmllegacy.network.PacketDistributor;
|
||||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks;
|
||||||
import tschipp.carryon.CarryOn;
|
import tschipp.carryon.CarryOn;
|
||||||
import tschipp.carryon.network.client.ScriptReloadPacket;
|
import tschipp.carryon.network.client.ScriptReloadPacket;
|
||||||
|
|
||||||
@EventBusSubscriber(modid = CarryOn.MODID, bus = Bus.FORGE)
|
@EventBusSubscriber(modid = CarryOn.MODID, bus = Bus.FORGE)
|
||||||
public class ScriptReloadListener extends JsonReloadListener
|
public class ScriptReloadListener extends SimpleJsonResourceReloadListener
|
||||||
{
|
{
|
||||||
private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
|
private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
|
||||||
|
|
||||||
|
|
@ -31,7 +31,7 @@ public class ScriptReloadListener extends JsonReloadListener
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void apply(Map<ResourceLocation, JsonElement> objects, IResourceManager manager, IProfiler profiler)
|
protected void apply(Map<ResourceLocation, JsonElement> objects, ResourceManager manager, ProfilerFiller profiler)
|
||||||
{
|
{
|
||||||
ScriptReader.OVERRIDES.clear();
|
ScriptReader.OVERRIDES.clear();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,101 +1,100 @@
|
||||||
package tschipp.carryon.compat.obfuscate;
|
//package tschipp.carryon.compat.obfuscate;
|
||||||
|
//
|
||||||
import com.mrcrayfish.obfuscate.client.event.PlayerModelEvent;
|
//import com.mrcrayfish.obfuscate.client.event.PlayerModelEvent;
|
||||||
|
//
|
||||||
import net.minecraft.client.renderer.entity.model.PlayerModel;
|
//import net.minecraft.client.model.PlayerModel;
|
||||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
//import net.minecraft.client.renderer.model.ModelRenderer;
|
||||||
import net.minecraft.entity.Pose;
|
//import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
//import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.item.ItemStack;
|
//import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
//import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
//import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
//import tschipp.carryon.common.config.Configs.Settings;
|
||||||
import tschipp.carryon.common.config.Configs.Settings;
|
//import tschipp.carryon.common.handler.RegistrationHandler;
|
||||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
//import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||||
import tschipp.carryon.common.helper.ScriptParseHelper;
|
//import tschipp.carryon.common.item.ItemCarryonBlock;
|
||||||
import tschipp.carryon.common.item.ItemCarryonBlock;
|
//import tschipp.carryon.common.item.ItemCarryonEntity;
|
||||||
import tschipp.carryon.common.item.ItemCarryonEntity;
|
//import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
//import tschipp.carryon.common.scripting.ScriptChecker;
|
||||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
//
|
||||||
|
//public class ObfuscateEvents
|
||||||
public class ObfuscateEvents
|
//{
|
||||||
{
|
//
|
||||||
|
// @SubscribeEvent
|
||||||
@SubscribeEvent
|
// public void preModelPlayerEvent(PlayerModelEvent.SetupAngles.Post event)
|
||||||
public void preModelPlayerEvent(PlayerModelEvent.SetupAngles.Post event)
|
// {
|
||||||
{
|
// if(!Settings.renderArms.get())
|
||||||
if(!Settings.renderArms.get())
|
// return;
|
||||||
return;
|
//
|
||||||
|
// PlayerEntity player = event.getPlayer();
|
||||||
PlayerEntity player = event.getPlayer();
|
//
|
||||||
|
// Pose pose = player.getPose();
|
||||||
Pose pose = player.getPose();
|
// if (pose == Pose.SWIMMING || pose == Pose.FALL_FLYING)
|
||||||
if (pose == Pose.SWIMMING || pose == Pose.FALL_FLYING)
|
// return;
|
||||||
return;
|
//
|
||||||
|
// PlayerModel<?> model = event.getModelPlayer();
|
||||||
PlayerModel<?> model = event.getModelPlayer();
|
// ItemStack stack = player.getMainHandItem();
|
||||||
ItemStack stack = player.getMainHandItem();
|
// if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
// {
|
||||||
{
|
//
|
||||||
|
// float rotation = 0;
|
||||||
float rotation = 0;
|
//
|
||||||
|
// CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
||||||
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
// if (overrider != null)
|
||||||
if (overrider != null)
|
// {
|
||||||
{
|
// float[] rotLeft = null;
|
||||||
float[] rotLeft = null;
|
// float[] rotRight = null;
|
||||||
float[] rotRight = null;
|
// if (overrider.getRenderRotationLeftArm() != null)
|
||||||
if (overrider.getRenderRotationLeftArm() != null)
|
// rotLeft = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
|
||||||
rotLeft = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
|
// if (overrider.getRenderRotationRightArm() != null)
|
||||||
if (overrider.getRenderRotationRightArm() != null)
|
// rotRight = ScriptParseHelper.getXYZArray(overrider.getRenderRotationRightArm());
|
||||||
rotRight = ScriptParseHelper.getXYZArray(overrider.getRenderRotationRightArm());
|
//
|
||||||
|
// boolean renderRight = overrider.isRenderRightArm();
|
||||||
boolean renderRight = overrider.isRenderRightArm();
|
// boolean renderLeft = overrider.isRenderLeftArm();
|
||||||
boolean renderLeft = overrider.isRenderLeftArm();
|
//
|
||||||
|
// if (renderLeft && rotLeft != null)
|
||||||
if (renderLeft && rotLeft != null)
|
// {
|
||||||
{
|
// renderArmPre(model.leftArm, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
||||||
renderArmPre(model.leftArm, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
// renderArmPre(model.leftSleeve, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
||||||
renderArmPre(model.leftSleeve, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
// }
|
||||||
}
|
// else if (renderLeft)
|
||||||
else if (renderLeft)
|
// {
|
||||||
{
|
// renderArmPre(model.leftArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||||
renderArmPre(model.leftArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
// renderArmPre(model.leftSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||||
renderArmPre(model.leftSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
// }
|
||||||
}
|
//
|
||||||
|
// if (renderRight && rotRight != null)
|
||||||
if (renderRight && rotRight != null)
|
// {
|
||||||
{
|
// renderArmPre(model.rightArm, (float) rotRight[0], (float) rotRight[2], rotation);
|
||||||
renderArmPre(model.rightArm, (float) rotRight[0], (float) rotRight[2], rotation);
|
// renderArmPre(model.rightSleeve, (float) rotRight[0], (float) rotRight[2], rotation);
|
||||||
renderArmPre(model.rightSleeve, (float) rotRight[0], (float) rotRight[2], rotation);
|
// }
|
||||||
}
|
// else if (renderRight)
|
||||||
else if (renderRight)
|
// {
|
||||||
{
|
// renderArmPre(model.rightArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||||
renderArmPre(model.rightArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
// renderArmPre(model.rightSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||||
renderArmPre(model.rightSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
// }
|
||||||
}
|
//
|
||||||
|
// }
|
||||||
}
|
// else
|
||||||
else
|
// {
|
||||||
{
|
// renderArmPre(model.rightArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||||
renderArmPre(model.rightArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
// renderArmPre(model.rightSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||||
renderArmPre(model.rightSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
// renderArmPre(model.leftArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||||
renderArmPre(model.leftArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
// renderArmPre(model.leftSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||||
renderArmPre(model.leftSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
// }
|
||||||
}
|
//
|
||||||
|
// }
|
||||||
}
|
//
|
||||||
|
// }
|
||||||
}
|
//
|
||||||
|
//
|
||||||
|
// @OnlyIn(Dist.CLIENT)
|
||||||
@OnlyIn(Dist.CLIENT)
|
// private void renderArmPre(ModelRenderer arm, float x, float z, float rotation)
|
||||||
private void renderArmPre(ModelRenderer arm, float x, float z, float rotation)
|
// {
|
||||||
{
|
// arm.xRot = (float) -x;
|
||||||
arm.xRot = (float) -x;
|
// arm.yRot = (float) -Math.toRadians(rotation);
|
||||||
arm.yRot = (float) -Math.toRadians(rotation);
|
// arm.zRot = (float) z;
|
||||||
arm.zRot = (float) z;
|
// }
|
||||||
}
|
//
|
||||||
|
//
|
||||||
|
//}
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@ package tschipp.carryon.network.client;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.fml.network.NetworkEvent;
|
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
||||||
import tschipp.carryon.CarryOn;
|
import tschipp.carryon.CarryOn;
|
||||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||||
|
|
||||||
|
|
@ -49,15 +49,15 @@ public class CarrySlotPacket
|
||||||
{
|
{
|
||||||
ctx.get().enqueueWork(() -> {
|
ctx.get().enqueueWork(() -> {
|
||||||
|
|
||||||
World world = CarryOn.proxy.getWorld();
|
Level world = CarryOn.proxy.getWorld();
|
||||||
|
|
||||||
if (world != null)
|
if (world != null)
|
||||||
{
|
{
|
||||||
Entity e = world.getEntity(entityid);
|
Entity e = world.getEntity(entityid);
|
||||||
|
|
||||||
if (e != null && e instanceof PlayerEntity)
|
if (e != null && e instanceof Player)
|
||||||
{
|
{
|
||||||
PlayerEntity player = (PlayerEntity) e;
|
Player player = (Player) e;
|
||||||
|
|
||||||
ctx.get().setPacketHandled(true);
|
ctx.get().setPacketHandled(true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.fml.network.NetworkEvent;
|
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
||||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||||
import tschipp.carryon.common.scripting.ScriptReader;
|
import tschipp.carryon.common.scripting.ScriptReader;
|
||||||
|
|
||||||
|
|
@ -23,7 +23,7 @@ public class ScriptReloadPacket
|
||||||
overrides.addAll(collection);
|
overrides.addAll(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScriptReloadPacket(PacketBuffer buf)
|
public ScriptReloadPacket(FriendlyByteBuf buf)
|
||||||
{
|
{
|
||||||
int size = buf.readInt();
|
int size = buf.readInt();
|
||||||
for(int i = 0; i < size; i++)
|
for(int i = 0; i < size; i++)
|
||||||
|
|
@ -32,7 +32,7 @@ public class ScriptReloadPacket
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toBytes(PacketBuffer buf)
|
public void toBytes(FriendlyByteBuf buf)
|
||||||
{
|
{
|
||||||
buf.writeInt(overrides.size());
|
buf.writeInt(overrides.size());
|
||||||
overrides.forEach(override -> override.serialize(buf));
|
overrides.forEach(override -> override.serialize(buf));
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ package tschipp.carryon.network.server;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.fml.network.NetworkEvent;
|
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
||||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||||
|
|
||||||
public class SyncKeybindPacket
|
public class SyncKeybindPacket
|
||||||
|
|
@ -32,7 +32,7 @@ public class SyncKeybindPacket
|
||||||
{
|
{
|
||||||
ctx.get().enqueueWork(() -> {
|
ctx.get().enqueueWork(() -> {
|
||||||
|
|
||||||
ServerPlayerEntity player = ctx.get().getSender();
|
ServerPlayer player = ctx.get().getSender();
|
||||||
|
|
||||||
CarryOnKeybinds.setKeyPressed(player, pressed);
|
CarryOnKeybinds.setKeyPressed(player, pressed);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
package tschipp.carryon.proxy;
|
package tschipp.carryon.proxy;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||||
|
|
@ -24,14 +24,14 @@ public class ClientProxy implements IProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlayerEntity getPlayer()
|
public Player getPlayer()
|
||||||
{
|
{
|
||||||
|
|
||||||
return Minecraft.getInstance().player;
|
return Minecraft.getInstance().player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public World getWorld()
|
public Level getWorld()
|
||||||
{
|
{
|
||||||
return Minecraft.getInstance().level;
|
return Minecraft.getInstance().level;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package tschipp.carryon.proxy;
|
package tschipp.carryon.proxy;
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
|
|
||||||
public interface IProxy
|
public interface IProxy
|
||||||
|
|
@ -9,7 +9,7 @@ public interface IProxy
|
||||||
|
|
||||||
public void setup(final FMLCommonSetupEvent event);
|
public void setup(final FMLCommonSetupEvent event);
|
||||||
|
|
||||||
public PlayerEntity getPlayer();
|
public Player getPlayer();
|
||||||
|
|
||||||
public World getWorld();
|
public Level getWorld();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package tschipp.carryon.proxy;
|
package tschipp.carryon.proxy;
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
|
|
||||||
public class ServerProxy implements IProxy
|
public class ServerProxy implements IProxy
|
||||||
|
|
@ -14,13 +14,13 @@ public class ServerProxy implements IProxy
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlayerEntity getPlayer()
|
public Player getPlayer()
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public World getWorld()
|
public Level getWorld()
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
modLoader="javafml"
|
modLoader="javafml"
|
||||||
loaderVersion="[34,)"
|
loaderVersion="[37,)"
|
||||||
issueTrackerURL="https://github.com/Tschipp/CarryOn/issues"
|
issueTrackerURL="https://github.com/Tschipp/CarryOn/issues"
|
||||||
logoFile="logo.png"
|
logoFile="logo.png"
|
||||||
license="GNU LGPLv3"
|
license="GNU LGPLv3"
|
||||||
|
|
@ -18,7 +18,7 @@ license="GNU LGPLv3"
|
||||||
# Does this dependency have to exist - if not, ordering below must be specified
|
# Does this dependency have to exist - if not, ordering below must be specified
|
||||||
mandatory=true #mandatory
|
mandatory=true #mandatory
|
||||||
# The version range of the dependency
|
# The version range of the dependency
|
||||||
versionRange="[34.1.10,)" #mandatory
|
versionRange="[37.0.1,)" #mandatory
|
||||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||||
|
|
@ -27,6 +27,6 @@ license="GNU LGPLv3"
|
||||||
[[dependencies.carryon]]
|
[[dependencies.carryon]]
|
||||||
modId="minecraft"
|
modId="minecraft"
|
||||||
mandatory=true
|
mandatory=true
|
||||||
versionRange="[1.16.3,1.17)"
|
versionRange="[1.17.1,1.18)"
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
side="BOTH"
|
side="BOTH"
|
||||||
Loading…
Reference in New Issue
Block a user