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 {
|
||||
repositories {
|
||||
maven { url = 'https://files.minecraftforge.net/maven' }
|
||||
maven { url = 'https://maven.minecraftforge.net' }
|
||||
maven { url = 'https://maven.parchmentmc.org' }
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
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: 'eclipse'
|
||||
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/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.JsonOutput
|
||||
|
||||
|
|
@ -26,15 +31,18 @@ version = "${version}"
|
|||
group = "tschipp.carryon"
|
||||
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) {
|
||||
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 {
|
||||
mappings channel: 'official', version: "1.16.5"
|
||||
mappings channel: 'parchment', version: '2021.12.12-1.17.1'
|
||||
|
||||
runs {
|
||||
client {
|
||||
|
|
@ -111,19 +119,19 @@ repositories {
|
|||
dependencies {
|
||||
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.bookshelf:Bookshelf-1.16.4:9.3.18")
|
||||
implementation fg.deobf("curse.maven:obfuscate-289380:3169370")
|
||||
//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("curse.maven:obfuscate-289380:3169370")
|
||||
|
||||
fileTree("libs").matching {
|
||||
include "*.jar"
|
||||
}.each {
|
||||
String filename = it.getName();
|
||||
filename = filename.substring(0, filename.length() - 4);
|
||||
int lastDash = filename.lastIndexOf("-");
|
||||
filename = filename.substring(0, lastDash) + ":" + filename.substring(lastDash+1, filename.length());
|
||||
implementation fg.deobf("blank:${filename}")
|
||||
}
|
||||
//fileTree("libs").matching {
|
||||
// include "*.jar"
|
||||
//}.each {
|
||||
// String filename = it.getName();
|
||||
// filename = filename.substring(0, filename.length() - 4);
|
||||
// int lastDash = filename.lastIndexOf("-");
|
||||
// filename = filename.substring(0, lastDash) + ":" + filename.substring(lastDash+1, filename.length());
|
||||
// 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.
|
||||
onlyIf {
|
||||
project.hasProperty('modkeyStore')
|
||||
}
|
||||
// onlyIf {
|
||||
// project.hasProperty('modkeyStore')
|
||||
// }
|
||||
|
||||
// findProperty allows us to reference the property without it existing.
|
||||
// Using project.propName would cause the script to fail validation if
|
||||
// the property did not exist.
|
||||
keyStore = project.findProperty('modkeyStore')
|
||||
alias = project.findProperty('modkeyStoreAlias')
|
||||
storePass = project.findProperty('modkeyStorePass')
|
||||
keyPass = project.findProperty('modkeyStoreKeyPass')
|
||||
inputFile = jar.archivePath
|
||||
outputFile = jar.archivePath
|
||||
}
|
||||
// keyStore = project.findProperty('modkeyStore')
|
||||
// alias = project.findProperty('modkeyStoreAlias')
|
||||
// storePass = project.findProperty('modkeyStorePass')
|
||||
// keyPass = project.findProperty('modkeyStoreKeyPass')
|
||||
// inputFile = jar.archivePath
|
||||
// outputFile = jar.archivePath
|
||||
//}
|
||||
|
||||
// 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.
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
version=1.15.5
|
||||
minecraft_version=1.16.5
|
||||
minecraft_version=1.17.1
|
||||
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
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
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
|
||||
|
||||
#
|
||||
# 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
|
||||
|
|
@ -28,7 +44,7 @@ APP_NAME="Gradle"
|
|||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
|
@ -56,7 +72,7 @@ case "`uname`" in
|
|||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
MSYS* | MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
|
|
@ -66,6 +82,7 @@ esac
|
|||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
|
|
@ -109,10 +126,11 @@ if $darwin; then
|
|||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
|
|
@ -138,19 +156,19 @@ if $cygwin ; then
|
|||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
|
@ -159,14 +177,9 @@ save () {
|
|||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# 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"
|
||||
|
||||
# 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" "$@"
|
||||
|
|
|
|||
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
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
|
|
@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
|
|||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
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_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
|
|
@ -45,28 +64,14 @@ echo location of your Java installation.
|
|||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %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
|
||||
@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.Logger;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
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.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.network.NetworkDirection;
|
||||
import net.minecraftforge.fml.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.network.simple.SimpleChannel;
|
||||
import net.minecraftforge.fmllegacy.network.NetworkDirection;
|
||||
import net.minecraftforge.fmllegacy.network.NetworkRegistry;
|
||||
import net.minecraftforge.fmllegacy.network.simple.SimpleChannel;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
import tschipp.carryon.common.config.Configs;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
|
|
|
|||
|
|
@ -4,22 +4,22 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
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.vertex.PoseStack;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
|
|
@ -37,7 +37,7 @@ public class RenderEntityEvents
|
|||
|
||||
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();
|
||||
if(nbtEntityMap.containsKey(nbt))
|
||||
|
|
@ -66,15 +66,15 @@ public class RenderEntityEvents
|
|||
@SubscribeEvent
|
||||
public void renderHand(RenderHandEvent event)
|
||||
{
|
||||
World world = Minecraft.getInstance().level;
|
||||
PlayerEntity player = Minecraft.getInstance().player;
|
||||
Level world = Minecraft.getInstance().level;
|
||||
Player player = Minecraft.getInstance().player;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
int perspective = CarryRenderHelper.getPerspective();
|
||||
float partialticks = event.getPartialTicks();
|
||||
MatrixStack matrix = event.getMatrixStack();
|
||||
PoseStack matrix = event.getMatrixStack();
|
||||
int light = event.getLight();
|
||||
IRenderTypeBuffer buffer = event.getBuffers();
|
||||
EntityRendererManager manager = Minecraft.getInstance().getEntityRenderDispatcher();
|
||||
MultiBufferSource buffer = event.getBuffers();
|
||||
EntityRenderDispatcher manager = Minecraft.getInstance().getEntityRenderDispatcher();
|
||||
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||
{
|
||||
|
|
@ -85,10 +85,10 @@ public class RenderEntityEvents
|
|||
|
||||
if (entity != null)
|
||||
{
|
||||
Vector3d playerpos = CarryRenderHelper.getExactPos(player, partialticks);
|
||||
Vec3 playerpos = CarryRenderHelper.getExactPos(player, partialticks);
|
||||
|
||||
entity.setPos(playerpos.x, playerpos.y, playerpos.z);
|
||||
entity.yRot = 0.0f;
|
||||
entity.xRotO = 0.0f;
|
||||
entity.yRotO = 0.0f;
|
||||
entity.setYHeadRot(0.0f);
|
||||
|
||||
|
|
@ -100,11 +100,11 @@ public class RenderEntityEvents
|
|||
matrix.mulPose(Vector3f.YP.rotationDegrees(180));
|
||||
matrix.translate(0.0, -height - .1, width + 0.1);
|
||||
|
||||
RenderSystem.enableAlphaTest();
|
||||
// RenderSystem.enableAlphaTest();
|
||||
|
||||
if (perspective == 0)
|
||||
{
|
||||
RenderHelper.turnBackOn();
|
||||
// Lighting.en
|
||||
manager.setRenderShadow(false);
|
||||
|
||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||
|
|
@ -123,12 +123,12 @@ public class RenderEntityEvents
|
|||
|
||||
if (newEntity != null)
|
||||
{
|
||||
CompoundNBT nbttag = carryOverride.getRenderNBT();
|
||||
CompoundTag nbttag = carryOverride.getRenderNBT();
|
||||
if (nbttag != null)
|
||||
newEntity.deserializeNBT(nbttag);
|
||||
entity = newEntity;
|
||||
entity.setPos(playerpos.x, playerpos.y, playerpos.z);
|
||||
entity.yRot = 0.0f;
|
||||
entity.xRotO = 0.0f;
|
||||
entity.yRotO = 0.0f;
|
||||
entity.setYHeadRot(0.0f);
|
||||
}
|
||||
|
|
@ -142,11 +142,12 @@ public class RenderEntityEvents
|
|||
manager.setRenderShadow(true);
|
||||
}
|
||||
|
||||
RenderSystem.disableAlphaTest();
|
||||
// RenderSystem.disableAlphaTest();
|
||||
matrix.popPose();
|
||||
|
||||
RenderHelper.turnOff();
|
||||
RenderSystem.disableRescaleNormal();
|
||||
// Lighting.turnOff();
|
||||
// TODO
|
||||
// RenderSystem.disableRescaleNormal();
|
||||
|
||||
if (perspective == 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,53 +3,53 @@ package tschipp.carryon.client.event;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
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.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.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.GameSettings;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer.Impl;
|
||||
import net.minecraft.client.Options;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.model.PlayerModel;
|
||||
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.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||
import net.minecraft.client.renderer.entity.PlayerRenderer;
|
||||
import net.minecraft.client.renderer.entity.model.PlayerModel;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.Pose;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
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.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.entity.player.PlayerRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.ClickEvent.Action;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Pose;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.client.event.ClientPlayerNetworkEvent.LoggedInEvent;
|
||||
import net.minecraftforge.event.TickEvent.PlayerTickEvent;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
|
|
@ -60,7 +60,6 @@ import tschipp.carryon.CarryOn;
|
|||
import tschipp.carryon.client.helper.CarryRenderHelper;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
import tschipp.carryon.common.config.Configs.Settings;
|
||||
import tschipp.carryon.common.handler.ListHandler;
|
||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.helper.KeyboardCallbackWrapper.KeyPressedEvent;
|
||||
|
|
@ -82,7 +81,8 @@ public class RenderEvents
|
|||
@SubscribeEvent
|
||||
public void onScroll(MouseScrolledEvent event)
|
||||
{
|
||||
PlayerEntity player = Minecraft.getInstance().player;
|
||||
@SuppressWarnings("resource")
|
||||
Player player = Minecraft.getInstance().player;
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
|
|
@ -103,7 +103,7 @@ public class RenderEvents
|
|||
@OnlyIn(Dist.CLIENT)
|
||||
public void onPlayerTick(PlayerTickEvent event) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
|
||||
{
|
||||
PlayerEntity player = event.player;
|
||||
Player player = event.player;
|
||||
|
||||
if (player != null && event.side == LogicalSide.CLIENT)
|
||||
{
|
||||
|
|
@ -127,9 +127,9 @@ public class RenderEvents
|
|||
@OnlyIn(Dist.CLIENT)
|
||||
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)
|
||||
{
|
||||
CarryOnKeybinds.setKeyPressed(player, false);
|
||||
|
|
@ -137,10 +137,10 @@ public class RenderEvents
|
|||
|
||||
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"));
|
||||
|
||||
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
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onGuiInit(InitGuiEvent.Pre event)
|
||||
{
|
||||
if (event.getGui() != null)
|
||||
{
|
||||
boolean inventory = event.getGui() instanceof ContainerScreen;
|
||||
PlayerEntity player = Minecraft.getInstance().player;
|
||||
boolean inventory = event.getGui() instanceof AbstractContainerScreen;
|
||||
Player player = Minecraft.getInstance().player;
|
||||
|
||||
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))))
|
||||
{
|
||||
|
|
@ -178,14 +179,15 @@ public class RenderEvents
|
|||
/*
|
||||
* Prevents the Player from switching Slots
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
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 scancode = event.scancode;
|
||||
PlayerEntity player = Minecraft.getInstance().player;
|
||||
Player player = Minecraft.getInstance().player;
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
|
|
@ -205,7 +207,7 @@ public class RenderEvents
|
|||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
for (KeyBinding keyBind : settings.keyHotbarSlots)
|
||||
for (KeyMapping keyBind : settings.keyHotbarSlots)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressWarnings({ "resource", "deprecation" })
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void renderHand(RenderHandEvent event)
|
||||
{
|
||||
World world = Minecraft.getInstance().level;
|
||||
PlayerEntity player = Minecraft.getInstance().player;
|
||||
Level world = Minecraft.getInstance().level;
|
||||
Player player = Minecraft.getInstance().player;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
int perspective = CarryRenderHelper.getPerspective();
|
||||
boolean f1 = Minecraft.getInstance().options.hideGui;
|
||||
IRenderTypeBuffer buffer = event.getBuffers();
|
||||
MatrixStack matrix = event.getMatrixStack();
|
||||
MultiBufferSource buffer = event.getBuffers();
|
||||
PoseStack matrix = event.getMatrixStack();
|
||||
int light = event.getLight();
|
||||
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) && perspective == 0 && !f1)
|
||||
|
|
@ -246,7 +248,7 @@ public class RenderEvents
|
|||
return;
|
||||
|
||||
Block block = ItemCarryonBlock.getBlock(stack);
|
||||
CompoundNBT tag = ItemCarryonBlock.getTileData(stack);
|
||||
CompoundTag tag = ItemCarryonBlock.getTileData(stack);
|
||||
BlockState state = ItemCarryonBlock.getBlockState(stack);
|
||||
ItemStack tileStack = ItemCarryonBlock.getItemStack(stack);
|
||||
|
||||
|
|
@ -266,7 +268,7 @@ public class RenderEvents
|
|||
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);
|
||||
if (carryOverride != null)
|
||||
|
|
@ -280,12 +282,12 @@ public class RenderEvents
|
|||
{
|
||||
ItemStack s = new ItemStack(b, 1);
|
||||
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);
|
||||
|
||||
|
|
@ -299,35 +301,34 @@ public class RenderEvents
|
|||
matrix.popPose();
|
||||
}
|
||||
}
|
||||
|
||||
// @SubscribeEvent
|
||||
// public void onJoinServer(LoggedInEvent event)
|
||||
// {
|
||||
// ListHandler.initConfigLists();
|
||||
// }
|
||||
|
||||
|
||||
// @SubscribeEvent
|
||||
// public void onJoinServer(LoggedInEvent event)
|
||||
// {
|
||||
// ListHandler.initConfigLists();
|
||||
// }
|
||||
|
||||
/*
|
||||
* Render blocks and entities in third person
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressWarnings({ "deprecation", "resource" })
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onRenderWorld(RenderWorldLastEvent event)
|
||||
{
|
||||
World world = Minecraft.getInstance().level;
|
||||
Level world = Minecraft.getInstance().level;
|
||||
float partialticks = event.getPartialTicks();
|
||||
Impl buffer = IRenderTypeBuffer.immediate(Tessellator.getInstance().getBuilder());
|
||||
MatrixStack matrix = event.getMatrixStack();
|
||||
BufferSource buffer = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
|
||||
PoseStack matrix = event.getMatrixStack();
|
||||
int light = 0;
|
||||
int perspective = CarryRenderHelper.getPerspective();
|
||||
EntityRendererManager manager = Minecraft.getInstance().getEntityRenderDispatcher();
|
||||
|
||||
EntityRenderDispatcher manager = Minecraft.getInstance().getEntityRenderDispatcher();
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.disableCull();
|
||||
RenderSystem.disableDepthTest();
|
||||
|
||||
for (PlayerEntity player : world.players())
|
||||
for (Player player : world.players())
|
||||
{
|
||||
if (perspective == 0 && player == Minecraft.getInstance().player)
|
||||
continue;
|
||||
|
|
@ -339,12 +340,12 @@ public class RenderEvents
|
|||
{
|
||||
Block block = ItemCarryonBlock.getBlock(stack);
|
||||
BlockState state = ItemCarryonBlock.getBlockState(stack);
|
||||
CompoundNBT tag = ItemCarryonBlock.getTileData(stack);
|
||||
CompoundTag tag = ItemCarryonBlock.getTileData(stack);
|
||||
ItemStack tileItem = ItemCarryonBlock.getItemStack(stack);
|
||||
|
||||
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);
|
||||
if (carryOverride != null)
|
||||
|
|
@ -358,19 +359,26 @@ public class RenderEvents
|
|||
{
|
||||
ItemStack s = new ItemStack(b, 1);
|
||||
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);
|
||||
CarryRenderHelper.renderItem(state, tag, stack, tileItem, matrix, buffer, light, model);
|
||||
buffer.endBatch();
|
||||
RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_BLOCKS);
|
||||
//TODO: Fix block light
|
||||
RenderSystem.enableCull();
|
||||
|
||||
PoseStack.Pose p = matrix.last();
|
||||
PoseStack copy = new PoseStack();
|
||||
copy.mulPoseMatrix(p.pose());
|
||||
matrix.popPose();
|
||||
|
||||
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();
|
||||
}
|
||||
else if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||
|
|
@ -399,14 +407,14 @@ public class RenderEvents
|
|||
|
||||
if (newEntity != null)
|
||||
{
|
||||
CompoundNBT nbttag = carryOverride.getRenderNBT();
|
||||
CompoundTag nbttag = carryOverride.getRenderNBT();
|
||||
if (nbttag != null)
|
||||
newEntity.deserializeNBT(nbttag);
|
||||
entity = newEntity;
|
||||
entity.yRot = 0.0f;
|
||||
entity.yo = 0.0f;
|
||||
entity.yRotO = 0.0f;
|
||||
entity.setYHeadRot(0.0f);
|
||||
entity.xRot = 0.0f;
|
||||
entity.xo = 0.0f;
|
||||
entity.xRotO = 0.0f;
|
||||
}
|
||||
}
|
||||
|
|
@ -415,6 +423,8 @@ public class RenderEvents
|
|||
if (entity instanceof LivingEntity)
|
||||
((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);
|
||||
buffer.endBatch();
|
||||
|
||||
|
|
@ -434,13 +444,14 @@ public class RenderEvents
|
|||
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();
|
||||
Quaternion playerrot = CarryRenderHelper.getExactBodyRotation(player, partialticks);
|
||||
Vector3d playerpos = CarryRenderHelper.getExactPos(player, partialticks);
|
||||
Vector3d cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
|
||||
Vector3d offset = playerpos.subtract(cameraPos);
|
||||
Vec3 playerpos = CarryRenderHelper.getExactPos(player, partialticks);
|
||||
Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
|
||||
Vec3 offset = playerpos.subtract(cameraPos);
|
||||
Pose pose = player.getPose();
|
||||
|
||||
matrix.pushPose();
|
||||
|
|
@ -464,8 +475,8 @@ public class RenderEvents
|
|||
if (pose == Pose.SWIMMING)
|
||||
{
|
||||
float f = player.getSwimAmount(partialticks);
|
||||
float f3 = player.isInWater() ? -90.0F - player.xRot : -90.0F;
|
||||
float f4 = MathHelper.lerp(f, 0.0F, f3);
|
||||
float f3 = player.isInWater() ? -90.0F - player.xRotO : -90.0F;
|
||||
float f4 = Mth.lerp(f, 0.0F, f3);
|
||||
if (perspective == 2)
|
||||
{
|
||||
matrix.translate(0, 0, 1.35);
|
||||
|
|
@ -482,22 +493,22 @@ public class RenderEvents
|
|||
if (pose == Pose.FALL_FLYING)
|
||||
{
|
||||
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 (perspective == 2)
|
||||
matrix.translate(0, 0, 1.35);
|
||||
|
||||
if (perspective == 2)
|
||||
matrix.mulPose(Vector3f.XP.rotationDegrees(f2 * (-90.0F - player.xRot)));
|
||||
matrix.mulPose(Vector3f.XP.rotationDegrees(f2 * (-90.0F - player.xRotO)));
|
||||
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);
|
||||
Vector3d Vector3d1 = player.getDeltaMovement();
|
||||
double d0 = Entity.getHorizontalDistanceSqr(Vector3d1);
|
||||
double d1 = Entity.getHorizontalDistanceSqr(Vector3d);
|
||||
Vec3 Vector3d = player.getViewVector(partialticks);
|
||||
Vec3 Vector3d1 = player.getDeltaMovement();
|
||||
double d0 = Vector3d1.horizontalDistanceSqr();
|
||||
double d1 = Vector3d1.horizontalDistanceSqr();
|
||||
if (d0 > 0.0D && d1 > 0.0D)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
|
|
@ -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();
|
||||
Pose pose = player.getPose();
|
||||
|
|
@ -549,10 +560,10 @@ public class RenderEvents
|
|||
float height = entity.getBbHeight();
|
||||
float width = entity.getBbWidth();
|
||||
float multiplier = height * width;
|
||||
entity.yRot = 0.0f;
|
||||
entity.yo = 0.0f;
|
||||
entity.yRotO = 0.0f;
|
||||
entity.setYHeadRot(0.0f);
|
||||
entity.xRot = 0.0f;
|
||||
entity.xo = 0.0f;
|
||||
entity.xRotO = 0.0f;
|
||||
|
||||
if (perspective == 2)
|
||||
|
|
@ -576,7 +587,7 @@ public class RenderEvents
|
|||
* Renders correct arm rotation
|
||||
*/
|
||||
@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();
|
||||
Pose pose = player.getPose();
|
||||
|
|
@ -592,19 +603,19 @@ public class RenderEvents
|
|||
ItemStack stack = player.getMainHandItem();
|
||||
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();
|
||||
|
||||
matrix.pushPose();
|
||||
if (perspective == 2)
|
||||
matrix.mulPose(Vector3f.YP.rotationDegrees(180));
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bind(skinLoc);
|
||||
RenderSystem.setShaderTexture(0, skinLoc);
|
||||
|
||||
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
||||
IVertexBuilder builder = buffer.getBuffer(RenderType.entityCutout(skinLoc));
|
||||
VertexConsumer builder = buffer.getBuffer(RenderType.entityCutout(skinLoc));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (buffer instanceof Impl)
|
||||
((Impl) buffer).endBatch();
|
||||
if (buffer instanceof BufferSource)
|
||||
((BufferSource) buffer).endBatch();
|
||||
|
||||
matrix.popPose();
|
||||
}
|
||||
|
|
@ -668,12 +679,12 @@ public class RenderEvents
|
|||
|
||||
if (handleMobends() && !ModList.get().isLoaded("obfuscate"))
|
||||
{
|
||||
PlayerEntity player = event.getPlayer();
|
||||
Player player = event.getPlayer();
|
||||
Pose pose = player.getPose();
|
||||
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)))
|
||||
{
|
||||
PlayerModel<AbstractClientPlayerEntity> model = event.getRenderer().getModel();
|
||||
PlayerModel<AbstractClientPlayer> model = event.getRenderer().getModel();
|
||||
|
||||
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
||||
if (overrider != null)
|
||||
|
|
@ -706,7 +717,7 @@ public class RenderEvents
|
|||
}
|
||||
|
||||
@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();
|
||||
arm.visible = true;
|
||||
|
|
@ -729,7 +740,7 @@ public class RenderEvents
|
|||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private void renderArmPre(ModelRenderer arm)
|
||||
private void renderArmPre(ModelPart arm)
|
||||
{
|
||||
arm.visible = false;
|
||||
}
|
||||
|
|
@ -750,9 +761,9 @@ public class RenderEvents
|
|||
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 (player.isShiftKeyDown() || player.isCrouching());
|
||||
|
|
@ -764,15 +775,15 @@ public class RenderEvents
|
|||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static PlayerRenderer getRenderPlayer(AbstractClientPlayerEntity player)
|
||||
private static PlayerRenderer getRenderPlayer(AbstractClientPlayer player)
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
EntityRendererManager manager = mc.getEntityRenderDispatcher();
|
||||
return manager.getSkinMap().get(player.getModelName());
|
||||
EntityRenderDispatcher manager = mc.getEntityRenderDispatcher();
|
||||
return (PlayerRenderer) manager.getSkinMap().get(player.getModelName());
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static PlayerModel<AbstractClientPlayerEntity> getPlayerModel(AbstractClientPlayerEntity player)
|
||||
private static PlayerModel<AbstractClientPlayer> getPlayerModel(AbstractClientPlayer player)
|
||||
{
|
||||
return getRenderPlayer(player).getModel();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,28 @@
|
|||
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.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||
import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||
|
||||
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)
|
||||
|
|
@ -38,7 +38,7 @@ public class CarryRenderHelper
|
|||
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();
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ public class CarryRenderHelper
|
|||
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))
|
||||
{
|
||||
|
|
@ -72,6 +72,7 @@ public class CarryRenderHelper
|
|||
Minecraft.getInstance().getItemRenderer().render(tileStack.isEmpty() ? stack : tileStack, TransformType.NONE, false, matrix, buffer, light, 0xFFFFFF, model);
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public static int getPerspective()
|
||||
{
|
||||
boolean isThirdPerson = !Minecraft.getInstance().options.getCameraType().isFirstPerson(); //isThirdPerson
|
||||
|
|
|
|||
|
|
@ -1,29 +1,29 @@
|
|||
package tschipp.carryon.client.keybinds;
|
||||
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fmlclient.registry.ClientRegistry;
|
||||
|
||||
public class CarryOnKeybinds
|
||||
{
|
||||
|
||||
public static final String KEYBIND_KEY = "carryOnKeyPressed";
|
||||
public static KeyBinding carryKey;
|
||||
public static KeyMapping carryKey;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
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);
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
return tag.getBoolean(KEYBIND_KEY);
|
||||
|
|
@ -31,9 +31,9 @@ public class CarryOnKeybinds
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package tschipp.carryon.common.capabilities;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public interface IPosition {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,20 @@
|
|||
package tschipp.carryon.common.capabilities;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
|
||||
public class PositionProvider implements ICapabilitySerializable<CompoundNBT>
|
||||
public class PositionProvider implements ICapabilitySerializable<CompoundTag>
|
||||
{
|
||||
|
||||
@CapabilityInject(IPosition.class)
|
||||
public static final Capability<IPosition> POSITION_CAPABILITY = null;
|
||||
|
||||
private IPosition instance = POSITION_CAPABILITY.getDefaultInstance();
|
||||
private IPosition instance = new TEPosition();//POSITION_CAPABILITY.getDefaultInstance();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
|
|
@ -23,19 +24,36 @@ public class PositionProvider implements ICapabilitySerializable<CompoundNBT>
|
|||
return (LazyOptional<T>) LazyOptional.of(() -> {
|
||||
return new TEPosition();
|
||||
});
|
||||
|
||||
return LazyOptional.empty();
|
||||
}
|
||||
|
||||
@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
|
||||
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;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public class TEPosition implements IPosition {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
package tschipp.carryon.common.capabilities.event;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
|
|
@ -26,8 +26,8 @@ public class PositionClientEvents
|
|||
{
|
||||
if (event.getGui() != null)
|
||||
{
|
||||
PlayerEntity player = Minecraft.getInstance().player;
|
||||
boolean inventory = event.getGui() instanceof ContainerScreen;
|
||||
Player player = Minecraft.getInstance().player;
|
||||
boolean inventory = event.getGui() instanceof AbstractContainerScreen;
|
||||
|
||||
if (player != null && inventory)
|
||||
{
|
||||
|
|
@ -36,11 +36,11 @@ public class PositionClientEvents
|
|||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
||||
if(cap.isBlockActivated())
|
||||
{
|
||||
World world = player.level;
|
||||
Level world = player.level;
|
||||
BlockPos pos = cap.getPos();
|
||||
if(world != null)
|
||||
{
|
||||
TileEntity te = world.getBlockEntity(pos);
|
||||
BlockEntity te = world.getBlockEntity(pos);
|
||||
if(te == null)
|
||||
{
|
||||
// player.openContainer = null;
|
||||
|
|
@ -60,7 +60,7 @@ public class PositionClientEvents
|
|||
@SubscribeEvent
|
||||
public void onGuiClose(PlayerContainerEvent.Close event)
|
||||
{
|
||||
PlayerEntity player = event.getPlayer();
|
||||
Player player = event.getPlayer();
|
||||
if(player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
||||
{
|
||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
||||
|
|
@ -76,7 +76,7 @@ public class PositionClientEvents
|
|||
{
|
||||
if (event.side == LogicalSide.CLIENT)
|
||||
{
|
||||
PlayerEntity player = event.player;
|
||||
Player player = event.player;
|
||||
if(player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
||||
{
|
||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
package tschipp.carryon.common.capabilities.event;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
|
|
@ -21,7 +21,7 @@ public class PositionCommonEvents
|
|||
@SubscribeEvent
|
||||
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());
|
||||
}
|
||||
|
|
@ -32,8 +32,8 @@ public class PositionCommonEvents
|
|||
public void onBlockRight(PlayerInteractEvent.RightClickBlock event)
|
||||
{
|
||||
BlockPos pos = event.getPos();
|
||||
World world = event.getWorld();
|
||||
PlayerEntity player = event.getPlayer();
|
||||
Level world = event.getWorld();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (event.isCanceled())
|
||||
return;
|
||||
|
|
@ -44,7 +44,7 @@ public class PositionCommonEvents
|
|||
if (player instanceof FakePlayer)
|
||||
return;
|
||||
|
||||
TileEntity te = world.getBlockEntity(pos);
|
||||
BlockEntity te = world.getBlockEntity(pos);
|
||||
if (te != null)
|
||||
{
|
||||
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.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.Commands;
|
||||
import net.minecraft.command.arguments.EntityArgument;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fmllegacy.network.PacketDistributor;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.handler.CustomPickupOverrideHandler;
|
||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||
|
|
@ -24,9 +24,9 @@ import tschipp.carryon.network.client.CarrySlotPacket;
|
|||
|
||||
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) -> {
|
||||
return handleDebug(cmd.getSource());
|
||||
|
|
@ -46,26 +46,26 @@ public class CommandCarryOn
|
|||
|
||||
}
|
||||
|
||||
private static int handleDebug(CommandSource source)
|
||||
private static int handleDebug(CommandSourceStack source)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (source.getEntityOrException() != null)
|
||||
{
|
||||
ServerPlayerEntity player = source.getPlayerOrException();
|
||||
ServerPlayer player = source.getPlayerOrException();
|
||||
|
||||
ItemStack main = player.getMainHandItem();
|
||||
if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemTile)
|
||||
{
|
||||
source.sendSuccess(new StringTextComponent("Block: " + ItemCarryonBlock.getBlock(main)), true);
|
||||
source.sendSuccess(new StringTextComponent("BlockState: " + ItemCarryonBlock.getBlockState(main)), true);
|
||||
source.sendSuccess(new StringTextComponent("ItemStack: " + ItemCarryonBlock.getItemStack(main)), true);
|
||||
source.sendSuccess(new TextComponent("Block: " + ItemCarryonBlock.getBlock(main)), true);
|
||||
source.sendSuccess(new TextComponent("BlockState: " + ItemCarryonBlock.getBlockState(main)), true);
|
||||
source.sendSuccess(new TextComponent("ItemStack: " + ItemCarryonBlock.getItemStack(main)), true);
|
||||
|
||||
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)))
|
||||
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("BlockState: " + ItemCarryonBlock.getBlockState(main));
|
||||
|
|
@ -81,11 +81,11 @@ public class CommandCarryOn
|
|||
}
|
||||
else if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity)
|
||||
{
|
||||
source.sendSuccess(new StringTextComponent("Entity: " + ItemCarryonEntity.getEntity(main, player.level)), true);
|
||||
source.sendSuccess(new StringTextComponent("Entity Name: " + ItemCarryonEntity.getEntityName(main)), true);
|
||||
source.sendSuccess(new TextComponent("Entity: " + ItemCarryonEntity.getEntity(main, player.level)), true);
|
||||
source.sendSuccess(new TextComponent("Entity Name: " + ItemCarryonEntity.getEntityName(main)), true);
|
||||
|
||||
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 Name: " + ItemCarryonEntity.getEntityName(main));
|
||||
|
|
@ -106,20 +106,20 @@ public class CommandCarryOn
|
|||
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;
|
||||
cleared += player.inventory.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.itemTile, 64, player.inventoryMenu.getCraftSlots()); // TODO
|
||||
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)
|
||||
source.sendSuccess(new StringTextComponent("Cleared " + cleared + " Items!"), true);
|
||||
source.sendSuccess(new TextComponent("Cleared " + cleared + " Items!"), true);
|
||||
else
|
||||
source.sendSuccess(new StringTextComponent("Cleared " + cleared + " Item!"), true);
|
||||
source.sendSuccess(new TextComponent("Cleared " + cleared + " Item!"), true);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import net.minecraftforge.common.ForgeConfigSpec.IntValue;
|
|||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
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.common.handler.ListHandler;
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ public class Configs {
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onLoad(final ModConfig.Loading event)
|
||||
public static void onLoad(final ModConfigEvent.Loading event)
|
||||
{
|
||||
if (event.getConfig().getModId().equals(CarryOn.MODID))
|
||||
{
|
||||
|
|
@ -54,7 +54,7 @@ public class Configs {
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onConfigChanged(ModConfig.Reloading event)
|
||||
public static void onConfigChanged(ModConfigEvent.Reloading event)
|
||||
{
|
||||
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.fml.InterModComms;
|
||||
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.common.handler.ListHandler;
|
||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||
|
|
@ -21,8 +21,8 @@ public class IMCEvents
|
|||
|
||||
messages.forEach((msg) -> {
|
||||
|
||||
String method = msg.getMethod();
|
||||
Object obj = msg.getMessageSupplier().get();
|
||||
String method = msg.method();
|
||||
Object obj = msg.messageSupplier().get();
|
||||
|
||||
if(!(obj instanceof String))
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -2,22 +2,22 @@ package tschipp.carryon.common.event;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.passive.AnimalEntity;
|
||||
import net.minecraft.entity.passive.horse.HorseEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.animal.Animal;
|
||||
import net.minecraft.world.entity.animal.horse.Horse;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
|
|
@ -42,7 +42,7 @@ public class ItemEntityEvents
|
|||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public void onBlockClick(PlayerInteractEvent.RightClickBlock event)
|
||||
{
|
||||
PlayerEntity player = event.getPlayer();
|
||||
Player player = event.getPlayer();
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||
{
|
||||
|
|
@ -68,10 +68,10 @@ public class ItemEntityEvents
|
|||
public void onItemDropped(EntityJoinWorldEvent event)
|
||||
{
|
||||
Entity e = event.getEntity();
|
||||
World world = event.getWorld();
|
||||
if (e instanceof net.minecraft.entity.item.ItemEntity)
|
||||
Level world = event.getWorld();
|
||||
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();
|
||||
Item item = stack.getItem();
|
||||
if (item == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||
|
|
@ -90,13 +90,13 @@ public class ItemEntityEvents
|
|||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
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 off = player.getOffhandItem();
|
||||
World world = event.getWorld();
|
||||
Level world = event.getWorld();
|
||||
Entity entity = event.getTarget();
|
||||
BlockPos pos = entity.blockPosition();
|
||||
|
||||
|
|
@ -106,10 +106,10 @@ public class ItemEntityEvents
|
|||
|
||||
if (entity.invulnerableTime == 0)
|
||||
{
|
||||
if (entity instanceof AnimalEntity)
|
||||
((AnimalEntity) entity).dropLeash(true, true);
|
||||
if (entity instanceof Animal)
|
||||
((Animal) entity).dropLeash(true, true);
|
||||
|
||||
if (PickupHandler.canPlayerPickUpEntity((ServerPlayerEntity) player, entity))
|
||||
if (PickupHandler.canPlayerPickUpEntity((ServerPlayer) player, entity))
|
||||
{
|
||||
if (ItemCarryonEntity.storeEntityData(entity, world, stack))
|
||||
{
|
||||
|
|
@ -127,17 +127,17 @@ public class ItemEntityEvents
|
|||
if (override != null)
|
||||
overrideHash = override.hashCode();
|
||||
|
||||
ItemEvents.sendPacket(player, player.inventory.selected, overrideHash);
|
||||
ItemEvents.sendPacket(player, player.getInventory().selected, overrideHash);
|
||||
|
||||
if (entity instanceof LivingEntity)
|
||||
((LivingEntity) entity).setHealth(0);
|
||||
|
||||
entity.ejectPassengers();
|
||||
entity.setPos(entity.getX(), 0, entity.getZ());
|
||||
entity.remove();
|
||||
player.setItemInHand(Hand.MAIN_HAND, stack);
|
||||
entity.discard();
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, stack);
|
||||
event.setCanceled(true);
|
||||
event.setCancellationResult(ActionResultType.FAIL);
|
||||
event.setCancellationResult(InteractionResult.FAIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -165,9 +165,9 @@ public class ItemEntityEvents
|
|||
double sizeEntity = topEntity.getBbHeight() * topEntity.getBbWidth();
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -188,20 +188,20 @@ public class ItemEntityEvents
|
|||
}
|
||||
|
||||
ItemCarryonEntity.clearEntityData(main);
|
||||
player.setItemInHand(Hand.MAIN_HAND, ItemStack.EMPTY);
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);
|
||||
ItemEvents.sendPacket(player, 9, 0);
|
||||
event.setCanceled(true);
|
||||
event.setCancellationResult(ActionResultType.FAIL);
|
||||
world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.HORSE_SADDLE, SoundCategory.PLAYERS, 0.5F, 1.5F);
|
||||
event.setCancellationResult(InteractionResult.FAIL);
|
||||
world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.HORSE_SADDLE, SoundSource.PLAYERS, 0.5F, 1.5F);
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -249,7 +249,7 @@ public class ItemEntityEvents
|
|||
public void onLivingUpdate(LivingUpdateEvent event)
|
||||
{
|
||||
LivingEntity entity = event.getEntityLiving();
|
||||
World world = entity.level;
|
||||
Level world = entity.level;
|
||||
ItemStack main = entity.getMainHandItem();
|
||||
if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(main))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,28 +2,28 @@ package tschipp.carryon.common.event;
|
|||
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.DirectionalPlaceContext;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
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.GameRules;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.ClickEvent.Action;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.item.context.DirectionalPlaceContext;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
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.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
import net.minecraftforge.fml.network.PacketDistributor.TargetPoint;
|
||||
import net.minecraftforge.fmllegacy.network.PacketDistributor;
|
||||
import net.minecraftforge.fmllegacy.network.PacketDistributor.TargetPoint;
|
||||
import net.minecraftforge.fmlserverevents.FMLServerStartingEvent;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import tschipp.carryon.CarryOn;
|
||||
|
|
@ -71,7 +71,7 @@ public class ItemEvents
|
|||
if (event.isCanceled())
|
||||
return;
|
||||
|
||||
PlayerEntity player = event.getPlayer();
|
||||
Player player = event.getPlayer();
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack))
|
||||
{
|
||||
|
|
@ -97,24 +97,24 @@ public class ItemEvents
|
|||
public void onItemDropped(EntityJoinWorldEvent event)
|
||||
{
|
||||
Entity e = event.getEntity();
|
||||
World world = event.getWorld();
|
||||
if (e instanceof net.minecraft.entity.item.ItemEntity)
|
||||
Level world = event.getWorld();
|
||||
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();
|
||||
Item item = stack.getItem();
|
||||
if (item == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack))
|
||||
{
|
||||
BlockPos pos = eitem.blockPosition();
|
||||
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())
|
||||
{
|
||||
for (Direction facing : Direction.values())
|
||||
{
|
||||
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())
|
||||
{
|
||||
finalPos = offsetPos;
|
||||
|
|
@ -123,11 +123,12 @@ public class ItemEvents
|
|||
}
|
||||
}
|
||||
world.setBlockAndUpdate(finalPos, ItemCarryonBlock.getBlockState(stack));
|
||||
TileEntity tile = world.getBlockEntity(finalPos);
|
||||
BlockEntity tile = world.getBlockEntity(finalPos);
|
||||
if (tile != null)
|
||||
{
|
||||
tile.deserializeNBT(ItemCarryonBlock.getTileData(stack));
|
||||
tile.setPosition(finalPos);
|
||||
var nbt = ItemCarryonBlock.getTileData(stack);
|
||||
ItemCarryonBlock.updateTileLocation(nbt, finalPos);
|
||||
tile.load(nbt);
|
||||
}
|
||||
ItemCarryonBlock.clearTileData(stack);
|
||||
eitem.setItem(ItemStack.EMPTY);
|
||||
|
|
@ -145,10 +146,10 @@ public class ItemEvents
|
|||
@SubscribeEvent
|
||||
public void onPlayerLogin(PlayerLoggedInEvent event)
|
||||
{
|
||||
if (event.getPlayer() instanceof PlayerEntity)
|
||||
if (event.getPlayer() instanceof Player)
|
||||
{
|
||||
PlayerEntity player = (PlayerEntity) event.getPlayer();
|
||||
World world = player.getCommandSenderWorld();
|
||||
Player player = (Player) event.getPlayer();
|
||||
Level world = player.getCommandSenderWorld();
|
||||
|
||||
ItemStack carried = player.getMainHandItem();
|
||||
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));
|
||||
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
|
||||
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
|
||||
{
|
||||
CarryOnOverride override = ScriptChecker.inspectEntity(ItemCarryonEntity.getEntity(carried, world));
|
||||
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
|
||||
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)
|
||||
{
|
||||
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;
|
||||
World world = player.getCommandSenderWorld();
|
||||
Player player = (Player) e;
|
||||
Level world = player.getCommandSenderWorld();
|
||||
|
||||
ItemStack carried = player.getMainHandItem();
|
||||
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));
|
||||
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
|
||||
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
|
||||
{
|
||||
CarryOnOverride override = ScriptChecker.inspectEntity(ItemCarryonEntity.getEntity(carried, world));
|
||||
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
|
||||
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
|
||||
public void harvestSpeed(BreakSpeed event)
|
||||
{
|
||||
PlayerEntity player = event.getPlayer();
|
||||
Player player = event.getPlayer();
|
||||
if (player != null && !Settings.hitWhileCarrying.get())
|
||||
{
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
|
|
@ -246,7 +247,7 @@ public class ItemEvents
|
|||
@SubscribeEvent
|
||||
public void attackEntity(AttackEntityEvent event)
|
||||
{
|
||||
PlayerEntity player = event.getPlayer();
|
||||
Player player = event.getPlayer();
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (!stack.isEmpty() && !Settings.hitWhileCarrying.get() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
||||
{
|
||||
|
|
@ -257,7 +258,7 @@ public class ItemEvents
|
|||
@SubscribeEvent
|
||||
public void harvestSpeed(BreakEvent event)
|
||||
{
|
||||
PlayerEntity player = event.getPlayer();
|
||||
Player player = event.getPlayer();
|
||||
if (player != null && !Settings.hitWhileCarrying.get())
|
||||
{
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
|
|
@ -270,15 +271,15 @@ public class ItemEvents
|
|||
public void playerAttack(LivingAttackEvent event)
|
||||
{
|
||||
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();
|
||||
if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
||||
{
|
||||
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);
|
||||
sendPacket(player, 9, 0);
|
||||
player.level.addFreshEntity(item);
|
||||
|
|
@ -291,7 +292,7 @@ public class ItemEvents
|
|||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void onBlockRightClick(PlayerInteractEvent.RightClickBlock event)
|
||||
{
|
||||
PlayerEntity player = event.getPlayer();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(event.isCanceled())
|
||||
return;
|
||||
|
|
@ -301,7 +302,7 @@ public class ItemEvents
|
|||
|
||||
ItemStack main = player.getMainHandItem();
|
||||
ItemStack off = player.getOffhandItem();
|
||||
World world = event.getWorld();
|
||||
Level world = event.getWorld();
|
||||
BlockPos pos = event.getPos();
|
||||
BlockState state = world.getBlockState(pos);
|
||||
|
||||
|
|
@ -310,8 +311,8 @@ public class ItemEvents
|
|||
|
||||
ItemStack stack = new ItemStack(RegistrationHandler.itemTile);
|
||||
|
||||
TileEntity te = world.getBlockEntity(pos);
|
||||
if (PickupHandler.canPlayerPickUpBlock((ServerPlayerEntity) player, te, world, pos))
|
||||
BlockEntity te = world.getBlockEntity(pos);
|
||||
if (PickupHandler.canPlayerPickUpBlock((ServerPlayer) player, te, world, pos))
|
||||
{
|
||||
player.closeContainer();
|
||||
world.levelEvent(1010, pos, 0);
|
||||
|
|
@ -321,8 +322,8 @@ public class ItemEvents
|
|||
{
|
||||
|
||||
BlockState statee = world.getBlockState(pos);
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
tag = world.getBlockEntity(pos) != null ? world.getBlockEntity(pos).save(tag) : new CompoundNBT();
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag = world.getBlockEntity(pos) != null ? world.getBlockEntity(pos).save(tag) : new CompoundTag();
|
||||
CarryOnOverride override = ScriptChecker.inspectBlock(state, world, pos, tag);
|
||||
int overrideHash = 0;
|
||||
if (override != null)
|
||||
|
|
@ -332,11 +333,11 @@ public class ItemEvents
|
|||
|
||||
try
|
||||
{
|
||||
sendPacket(player, player.inventory.selected, overrideHash);
|
||||
sendPacket(player, player.getInventory().selected, overrideHash);
|
||||
|
||||
world.removeBlockEntity(pos);
|
||||
world.removeBlock(pos, false);
|
||||
player.setItemInHand(Hand.MAIN_HAND, stack);
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, stack);
|
||||
event.setUseBlock(Result.DENY);
|
||||
event.setUseItem(Result.DENY);
|
||||
event.setCanceled(true);
|
||||
|
|
@ -345,10 +346,10 @@ public class ItemEvents
|
|||
{
|
||||
try
|
||||
{
|
||||
sendPacket(player, player.inventory.selected, overrideHash);
|
||||
sendPacket(player, player.getInventory().selected, overrideHash);
|
||||
emptyTileEntity(te);
|
||||
world.removeBlock(pos,false);
|
||||
player.setItemInHand(Hand.MAIN_HAND, stack);
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, stack);
|
||||
event.setUseBlock(Result.DENY);
|
||||
event.setUseItem(Result.DENY);
|
||||
event.setCanceled(true);
|
||||
|
|
@ -359,13 +360,13 @@ public class ItemEvents
|
|||
world.setBlockAndUpdate(pos, statee);
|
||||
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);
|
||||
StringTextComponent s = new StringTextComponent(TextFormatting.GOLD + "here");
|
||||
player.displayClientMessage(new TextComponent(ChatFormatting.RED + "Error detected. Cannot pick up block."), false);
|
||||
TextComponent s = new TextComponent(ChatFormatting.GOLD + "here");
|
||||
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)
|
||||
{
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
@ -436,22 +437,21 @@ public class ItemEvents
|
|||
@SubscribeEvent
|
||||
public void onRespawn(PlayerEvent.Clone event)
|
||||
{
|
||||
PlayerEntity original = event.getOriginal();
|
||||
PlayerEntity player = event.getPlayer();
|
||||
Player original = event.getOriginal();
|
||||
Player player = event.getPlayer();
|
||||
boolean wasDead = event.isWasDeath();
|
||||
GameRules rules = player.level.getGameRules();
|
||||
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)
|
||||
{
|
||||
int carrySlot = original.inventory.selected;
|
||||
int carrySlot = original.getInventory().selected;
|
||||
|
||||
ItemStack stack = player.inventory.removeItemNoUpdate(carrySlot);
|
||||
World world = player.level;
|
||||
ItemStack stack = player.getInventory().removeItemNoUpdate(carrySlot);
|
||||
Level world = player.level;
|
||||
|
||||
ItemEntity item = new ItemEntity(world, 0, 0, 0);
|
||||
item.setItem(stack);
|
||||
ItemEntity item = new ItemEntity(world, 0, 0, 0, stack);
|
||||
BlockPos pos = null;
|
||||
Optional<BlockPos> bedpos = original.getSleepingPos();
|
||||
if(bedpos.isPresent())
|
||||
|
|
@ -468,13 +468,13 @@ public class ItemEvents
|
|||
public void dropNonHotbarItems(LivingUpdateEvent event)
|
||||
{
|
||||
LivingEntity entity = event.getEntityLiving();
|
||||
if (entity instanceof PlayerEntity)
|
||||
if (entity instanceof Player)
|
||||
{
|
||||
PlayerEntity player = (PlayerEntity) entity;
|
||||
Player player = (Player) entity;
|
||||
|
||||
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();
|
||||
|
||||
if (hasCarried)
|
||||
|
|
@ -489,12 +489,12 @@ public class ItemEvents
|
|||
ItemEntity item = null;
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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)
|
||||
return i;
|
||||
}
|
||||
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.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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ import java.util.List;
|
|||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.command.arguments.BlockStateParser;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.commands.arguments.blocks.BlockStateParser;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import tschipp.carryon.common.config.Configs.CustomPickupConditions;
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ package tschipp.carryon.common.handler;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.EntityTypeTags;
|
||||
import net.minecraft.tags.ITag;
|
||||
import net.minecraft.tags.ITagCollection;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.tags.TagCollection;
|
||||
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 tschipp.carryon.common.config.Configs.Blacklist;
|
||||
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> ALLOWED_STACKING = new ArrayList<>();
|
||||
|
||||
public static List<ITag<Block>> FORBIDDEN_TILES_TAGS = new ArrayList<>();
|
||||
public static List<ITag<EntityType<?>>> FORBIDDEN_ENTITIES_TAGS = new ArrayList<>();
|
||||
public static List<ITag<EntityType<?>>> ALLOWED_ENTITIES_TAGS = new ArrayList<>();
|
||||
public static List<ITag<Block>> ALLOWED_TILES_TAGS = new ArrayList<>();
|
||||
public static List<ITag<EntityType<?>>> FORBIDDEN_STACKING_TAGS = new ArrayList<>();
|
||||
public static List<ITag<EntityType<?>>> ALLOWED_STACKING_TAGS = new ArrayList<>();
|
||||
public static List<Tag<Block>> FORBIDDEN_TILES_TAGS = new ArrayList<>();
|
||||
public static List<Tag<EntityType<?>>> FORBIDDEN_ENTITIES_TAGS = new ArrayList<>();
|
||||
public static List<Tag<EntityType<?>>> ALLOWED_ENTITIES_TAGS = new ArrayList<>();
|
||||
public static List<Tag<Block>> ALLOWED_TILES_TAGS = new ArrayList<>();
|
||||
public static List<Tag<EntityType<?>>> FORBIDDEN_STACKING_TAGS = new ArrayList<>();
|
||||
public static List<Tag<EntityType<?>>> ALLOWED_STACKING_TAGS = new ArrayList<>();
|
||||
|
||||
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))
|
||||
return true;
|
||||
|
|
@ -64,7 +64,7 @@ public class ListHandler
|
|||
String name = entity.getType().getRegistryName().toString();
|
||||
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()))
|
||||
return true;
|
||||
|
|
@ -78,7 +78,7 @@ public class ListHandler
|
|||
String name = entity.getType().getRegistryName().toString();
|
||||
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()))
|
||||
return true;
|
||||
|
|
@ -92,7 +92,7 @@ public class ListHandler
|
|||
String name = entity.getType().getRegistryName().toString();
|
||||
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()))
|
||||
return true;
|
||||
|
|
@ -106,7 +106,7 @@ public class ListHandler
|
|||
String name = entity.getType().getRegistryName().toString();
|
||||
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()))
|
||||
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))
|
||||
return true;
|
||||
|
|
@ -276,8 +276,8 @@ public class ListHandler
|
|||
}
|
||||
}
|
||||
|
||||
ITagCollection<Block> blocktags = BlockTags.getAllTags();
|
||||
ITagCollection<EntityType<?>> entitytags = EntityTypeTags.getAllTags();
|
||||
TagCollection<Block> blocktags = BlockTags.getAllTags();
|
||||
TagCollection<EntityType<?>> entitytags = EntityTypeTags.getAllTags();
|
||||
|
||||
System.out.println(blocktags.getAvailableTags());
|
||||
|
||||
|
|
@ -286,7 +286,7 @@ public class ListHandler
|
|||
if (s.startsWith("#"))
|
||||
{
|
||||
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)
|
||||
FORBIDDEN_TILES_TAGS.add(tag);
|
||||
}
|
||||
|
|
@ -296,7 +296,7 @@ public class ListHandler
|
|||
{
|
||||
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)
|
||||
ALLOWED_TILES_TAGS.add(tag);
|
||||
}
|
||||
|
|
@ -306,7 +306,7 @@ public class ListHandler
|
|||
{
|
||||
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)
|
||||
FORBIDDEN_ENTITIES_TAGS.add(tag);
|
||||
}
|
||||
|
|
@ -316,7 +316,7 @@ public class ListHandler
|
|||
{
|
||||
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)
|
||||
ALLOWED_ENTITIES_TAGS.add(tag);
|
||||
}
|
||||
|
|
@ -326,7 +326,7 @@ public class ListHandler
|
|||
{
|
||||
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)
|
||||
FORBIDDEN_STACKING_TAGS.add(tag);
|
||||
}
|
||||
|
|
@ -336,7 +336,7 @@ public class ListHandler
|
|||
{
|
||||
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)
|
||||
ALLOWED_STACKING_TAGS.add(tag);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,16 +6,16 @@ import java.util.Set;
|
|||
|
||||
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.renderer.model.IBakedModel;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.nbt.TagParser;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
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.OnlyIn;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
|
|
@ -25,7 +25,7 @@ import tschipp.carryon.common.helper.StringParser;
|
|||
|
||||
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 -
|
||||
|
|
@ -37,7 +37,7 @@ public class ModelOverridesHandler
|
|||
|
||||
Object toOverrideObject;
|
||||
Object overrideObject;
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
CompoundTag tag = new CompoundTag();
|
||||
|
||||
String currentline = overrideString;
|
||||
if (StringUtils.isEmpty(currentline) || !StringUtils.contains(currentline, "->"))
|
||||
|
|
@ -69,7 +69,7 @@ public class ModelOverridesHandler
|
|||
toOverride = toOverride.replace(nbt, "");
|
||||
try
|
||||
{
|
||||
tag = JsonToNBT.parseTag(nbt);
|
||||
tag = TagParser.parseTag(nbt);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -127,7 +127,7 @@ public class ModelOverridesHandler
|
|||
|
||||
if (overrideObject != null)
|
||||
{
|
||||
CompoundNBT keyComp = new CompoundNBT();
|
||||
CompoundTag keyComp = new CompoundTag();
|
||||
keyComp.put("nbttag", tag);
|
||||
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())
|
||||
return false;
|
||||
|
||||
int stateid = Block.getId(state);
|
||||
CompoundNBT[] keys = new CompoundNBT[OVERRIDE_OBJECTS.size()];
|
||||
CompoundTag[] keys = new CompoundTag[OVERRIDE_OBJECTS.size()];
|
||||
OVERRIDE_OBJECTS.keySet().toArray(keys);
|
||||
for (CompoundNBT key : keys)
|
||||
for (CompoundTag key : keys)
|
||||
{
|
||||
int id = key.getInt("stateid");
|
||||
Block block = StringParser.getBlock(key.getString("block"));
|
||||
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> kSetTile = tag.getAllKeys();
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ public class ModelOverridesHandler
|
|||
{
|
||||
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;
|
||||
}
|
||||
if (flag)
|
||||
|
|
@ -192,18 +192,18 @@ public class ModelOverridesHandler
|
|||
}
|
||||
|
||||
@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);
|
||||
CompoundNBT[] keys = new CompoundNBT[OVERRIDE_OBJECTS.size()];
|
||||
CompoundTag[] keys = new CompoundTag[OVERRIDE_OBJECTS.size()];
|
||||
OVERRIDE_OBJECTS.keySet().toArray(keys);
|
||||
for (CompoundNBT key : keys)
|
||||
for (CompoundTag key : keys)
|
||||
{
|
||||
int id = key.getInt("stateid");
|
||||
Block block = StringParser.getBlock(key.getString("block"));
|
||||
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> kSetTile = tag.getAllKeys();
|
||||
|
||||
|
|
@ -212,7 +212,7 @@ public class ModelOverridesHandler
|
|||
{
|
||||
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;
|
||||
}
|
||||
if (flag)
|
||||
|
|
@ -225,7 +225,7 @@ public class ModelOverridesHandler
|
|||
if (override instanceof BlockState)
|
||||
return Minecraft.getInstance().getBlockRenderer().getBlockModel((BlockState) override);
|
||||
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);
|
||||
CompoundNBT[] keys = new CompoundNBT[OVERRIDE_OBJECTS.size()];
|
||||
CompoundTag[] keys = new CompoundTag[OVERRIDE_OBJECTS.size()];
|
||||
OVERRIDE_OBJECTS.keySet().toArray(keys);
|
||||
for (CompoundNBT key : keys)
|
||||
for (CompoundTag key : keys)
|
||||
{
|
||||
int id = key.getInt("stateid");
|
||||
Block block = StringParser.getBlock(key.getString("block"));
|
||||
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> kSetTile = tag.getAllKeys();
|
||||
|
||||
|
|
@ -254,7 +254,7 @@ public class ModelOverridesHandler
|
|||
{
|
||||
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;
|
||||
}
|
||||
if (flag)
|
||||
|
|
|
|||
|
|
@ -4,19 +4,19 @@ import java.util.UUID;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.AgeableEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.passive.TameableEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.GameType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.AgeableMob;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.entity.TamableAnimal;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
|
|
@ -29,21 +29,21 @@ import tschipp.carryon.common.scripting.ScriptChecker;
|
|||
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)
|
||||
return false;
|
||||
|
||||
|
||||
BlockState state = world.getBlockState(pos);
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
CompoundTag tag = new CompoundTag();
|
||||
if (tile != null)
|
||||
tile.save(tag);
|
||||
|
||||
CarryOnOverride override = ScriptChecker.inspectBlock(world.getBlockState(pos), world, pos, tag);
|
||||
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
|
||||
{
|
||||
|
|
@ -64,7 +64,7 @@ public class PickupHandler
|
|||
|
||||
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();
|
||||
|
||||
if (distance < maxDist)
|
||||
|
|
@ -75,7 +75,7 @@ public class PickupHandler
|
|||
|
||||
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)
|
||||
{
|
||||
|
|
@ -90,14 +90,14 @@ public class PickupHandler
|
|||
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)
|
||||
return false;
|
||||
|
||||
BlockPos pos = toPickUp.blockPosition();
|
||||
Vec3 pos = toPickUp.position();
|
||||
|
||||
if (toPickUp instanceof PlayerEntity)
|
||||
if (toPickUp instanceof Player)
|
||||
return false;
|
||||
|
||||
CarryOnOverride override = ScriptChecker.inspectEntity(toPickUp);
|
||||
|
|
@ -107,29 +107,29 @@ public class PickupHandler
|
|||
}
|
||||
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())
|
||||
{
|
||||
|
||||
double distance = pos.distSqr(player.blockPosition());
|
||||
if (distance < Math.pow(Settings.maxDistance.get(), 2))
|
||||
double distance = pos.distanceToSqr(player.position());
|
||||
if (distance <= Math.pow(Settings.maxDistance.get(), 2))
|
||||
{
|
||||
if (toPickUp instanceof TameableEntity)
|
||||
if (toPickUp instanceof TamableAnimal)
|
||||
{
|
||||
TameableEntity tame = (TameableEntity) toPickUp;
|
||||
if (tame.getOwnerUUID() != null && tame.getOwnerUUID() != PlayerEntity.createPlayerUUID(player.getGameProfile()))
|
||||
TamableAnimal tame = (TamableAnimal) toPickUp;
|
||||
if (tame.getOwnerUUID() != null && tame.getOwnerUUID() != Player.createPlayerUUID(player.getGameProfile()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
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()))
|
||||
{
|
||||
double distance = pos.distSqr(player.blockPosition());
|
||||
double distance = pos.distanceToSqr(player.position());
|
||||
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 playerID = PlayerEntity.createPlayerUUID(player.getGameProfile());
|
||||
UUID playerID = Player.createPlayerUUID(player.getGameProfile());
|
||||
if (owner != null && !owner.equals(playerID))
|
||||
return false;
|
||||
}
|
||||
|
||||
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
|
||||
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 PickUpBlockEvent(World world, BlockPos pos, BlockState state, PlayerEntity player)
|
||||
public PickUpBlockEvent(Level world, BlockPos pos, BlockState state, Player player)
|
||||
{
|
||||
super(world, pos, state, player);
|
||||
}
|
||||
|
|
@ -194,13 +194,13 @@ public class PickupHandler
|
|||
|
||||
public static class PickUpEntityEvent extends AttackEntityEvent
|
||||
{
|
||||
public PickUpEntityEvent(PlayerEntity player, Entity target)
|
||||
public PickUpEntityEvent(Player player, Entity 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;
|
||||
|
||||
|
|
@ -213,7 +213,7 @@ public class PickupHandler
|
|||
return breakable;
|
||||
}
|
||||
|
||||
private static boolean handleProtections(ServerPlayerEntity player, Entity entity)
|
||||
private static boolean handleProtections(ServerPlayer player, Entity entity)
|
||||
{
|
||||
boolean canPickup = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +1,21 @@
|
|||
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.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.client.event.RenderEntityEvents;
|
||||
import tschipp.carryon.client.event.RenderEvents;
|
||||
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.PositionCommonEvents;
|
||||
import tschipp.carryon.common.event.IMCEvents;
|
||||
import tschipp.carryon.common.event.ItemEntityEvents;
|
||||
import tschipp.carryon.common.event.ItemEvents;
|
||||
import tschipp.carryon.common.item.ItemCarryonEntity;
|
||||
import tschipp.carryon.common.item.ItemCarryonBlock;
|
||||
import tschipp.carryon.compat.obfuscate.ObfuscateEvents;
|
||||
import tschipp.carryon.common.item.ItemCarryonEntity;
|
||||
|
||||
@EventBusSubscriber(modid = CarryOn.MODID)
|
||||
public class RegistrationHandler
|
||||
|
|
@ -51,8 +47,8 @@ public class RegistrationHandler
|
|||
MinecraftForge.EVENT_BUS.register(new PositionClientEvents());
|
||||
|
||||
|
||||
if(ModList.get().isLoaded("obfuscate"))
|
||||
MinecraftForge.EVENT_BUS.register(new ObfuscateEvents());
|
||||
// if(ModList.get().isLoaded("obfuscate"))
|
||||
// MinecraftForge.EVENT_BUS.register(new ObfuscateEvents());
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -65,7 +61,7 @@ public class RegistrationHandler
|
|||
|
||||
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;
|
||||
|
||||
import net.darkhax.gamestages.GameStageHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
//import net.darkhax.gamestages.GameStageHelper;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
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 net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
|
||||
|
||||
/**
|
||||
* 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.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.potion.EffectInstance;
|
||||
import net.minecraft.scoreboard.Score;
|
||||
import net.minecraft.scoreboard.ScoreObjective;
|
||||
import net.minecraft.scoreboard.Scoreboard;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.scores.Objective;
|
||||
import net.minecraft.world.scores.Score;
|
||||
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())
|
||||
return true;
|
||||
|
||||
try
|
||||
{
|
||||
if (cond.contains("<="))
|
||||
{
|
||||
try {
|
||||
if (cond.contains("<=")) {
|
||||
return number <= Double.parseDouble(cond.replace("<=", ""));
|
||||
}
|
||||
if (cond.contains(">="))
|
||||
{
|
||||
if (cond.contains(">=")) {
|
||||
return number >= Double.parseDouble(cond.replace(">=", ""));
|
||||
}
|
||||
if (cond.contains("<"))
|
||||
{
|
||||
if (cond.contains("<")) {
|
||||
return number < Double.parseDouble(cond.replace("<", ""));
|
||||
}
|
||||
if (cond.contains(">"))
|
||||
{
|
||||
if (cond.contains(">")) {
|
||||
return number > Double.parseDouble(cond.replace(">", ""));
|
||||
}
|
||||
if (cond.contains("="))
|
||||
{
|
||||
if (cond.contains("=")) {
|
||||
return number == Double.parseDouble(cond.replace("=", ""));
|
||||
}
|
||||
else
|
||||
} else
|
||||
return number == Double.parseDouble(cond);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
new InvalidConfigException(e.getMessage()).printException();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean matches(Block block, String cond)
|
||||
{
|
||||
public static boolean matches(Block block, String cond) {
|
||||
if (cond == null || cond.isEmpty())
|
||||
return true;
|
||||
|
||||
|
|
@ -70,26 +58,23 @@ public class ScriptParseHelper
|
|||
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())
|
||||
return true;
|
||||
|
||||
boolean matching = true;
|
||||
for (String key : toMatch.getAllKeys())
|
||||
{
|
||||
INBT tag = toMatch.get(key);
|
||||
for (String key : toMatch.getAllKeys()) {
|
||||
Tag tag = toMatch.get(key);
|
||||
key = key.replace("\"", "");
|
||||
INBT tagToCheck = toCheck.get(key);
|
||||
Tag tagToCheck = toCheck.get(key);
|
||||
if (!tag.equals(tagToCheck))
|
||||
matching = false;
|
||||
}
|
||||
|
||||
return matching;
|
||||
}
|
||||
|
||||
public static float[] getXYZArray(String s)
|
||||
{
|
||||
|
||||
public static float[] getXYZArray(String s) {
|
||||
float[] d = new float[3];
|
||||
d[0] = getValueFromString(s, "x");
|
||||
d[1] = getValueFromString(s, "y");
|
||||
|
|
@ -97,10 +82,8 @@ public class ScriptParseHelper
|
|||
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
public static float[] getScaled(String s)
|
||||
{
|
||||
public static float[] getScaled(String s) {
|
||||
float[] d = new float[3];
|
||||
d[0] = getScaledValueFromString(s, "x");
|
||||
d[1] = getScaledValueFromString(s, "y");
|
||||
|
|
@ -109,25 +92,19 @@ public class ScriptParseHelper
|
|||
return d;
|
||||
}
|
||||
|
||||
public static float getScaledValueFromString(String toGetFrom, String key)
|
||||
{
|
||||
if(toGetFrom == null || toGetFrom.isEmpty())
|
||||
public static float getScaledValueFromString(String toGetFrom, String key) {
|
||||
if (toGetFrom == null || toGetFrom.isEmpty())
|
||||
return 1;
|
||||
|
||||
|
||||
String[] s = toGetFrom.split(",");
|
||||
for (String string : s)
|
||||
{
|
||||
if (string.contains(key) && string.contains("="))
|
||||
{
|
||||
for (String string : s) {
|
||||
if (string.contains(key) && string.contains("=")) {
|
||||
float numb = 1;
|
||||
string = string.replace(key + "=", "");
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
numb = Float.parseFloat(string);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
return numb;
|
||||
|
|
@ -137,8 +114,7 @@ public class ScriptParseHelper
|
|||
return 1;
|
||||
}
|
||||
|
||||
public static boolean matchesScore(PlayerEntity player, String cond)
|
||||
{
|
||||
public static boolean matchesScore(Player player, String cond) {
|
||||
if (cond == null || cond.isEmpty())
|
||||
return true;
|
||||
|
||||
|
|
@ -149,20 +125,18 @@ public class ScriptParseHelper
|
|||
int iG = 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);
|
||||
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);
|
||||
else
|
||||
numb = cond.substring(iL);
|
||||
|
||||
scorename = cond.replace(numb, "");
|
||||
Map<ScoreObjective, Score> o = score.getPlayerScores(player.getGameProfile().getName());
|
||||
if (o != null)
|
||||
{
|
||||
Map<Objective, Score> o = score.getPlayerScores(player.getGameProfile().getName());
|
||||
if (o != null) {
|
||||
Score sc = o.get(score.getObjective(scorename));
|
||||
if (sc != null)
|
||||
{
|
||||
if (sc != null) {
|
||||
int points = sc.getScore();
|
||||
|
||||
return matches(points, numb);
|
||||
|
|
@ -172,13 +146,14 @@ public class ScriptParseHelper
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean matches(BlockPos pos, String cond)
|
||||
{
|
||||
public static boolean matches(BlockPos pos, String cond) {
|
||||
if (cond == null || cond.isEmpty())
|
||||
return true;
|
||||
|
||||
BlockPos blockpos = new BlockPos(getValueFromString(cond, "x"), getValueFromString(cond, "y"), getValueFromString(cond, "z"));
|
||||
BlockPos expand = new BlockPos(getValueFromString(cond, "dx"), getValueFromString(cond, "dy"), getValueFromString(cond, "dz"));
|
||||
BlockPos blockpos = new BlockPos(getValueFromString(cond, "x"), getValueFromString(cond, "y"),
|
||||
getValueFromString(cond, "z"));
|
||||
BlockPos expand = new BlockPos(getValueFromString(cond, "dx"), getValueFromString(cond, "dy"),
|
||||
getValueFromString(cond, "dz"));
|
||||
BlockPos expanded = blockpos.offset(expand);
|
||||
|
||||
boolean x = (pos.getX() >= blockpos.getX() && pos.getX() <= expanded.getX()) || blockpos.getX() == 0;
|
||||
|
|
@ -188,25 +163,19 @@ public class ScriptParseHelper
|
|||
return x && y && z;
|
||||
}
|
||||
|
||||
public static float getValueFromString(String toGetFrom, String key)
|
||||
{
|
||||
if(toGetFrom == null || toGetFrom.isEmpty())
|
||||
public static float getValueFromString(String toGetFrom, String key) {
|
||||
if (toGetFrom == null || toGetFrom.isEmpty())
|
||||
return 0;
|
||||
|
||||
|
||||
String[] s = toGetFrom.split(",");
|
||||
for (String string : s)
|
||||
{
|
||||
if (string.contains(key) && string.contains("="))
|
||||
{
|
||||
for (String string : s) {
|
||||
if (string.contains(key) && string.contains("=")) {
|
||||
float numb = 0;
|
||||
string = string.replace(key + "=", "");
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
numb = Float.parseFloat(string);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
return numb;
|
||||
|
|
@ -215,70 +184,59 @@ public class ScriptParseHelper
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean hasEffects(PlayerEntity player, String cond)
|
||||
{
|
||||
if(cond == null || cond.isEmpty())
|
||||
|
||||
public static boolean hasEffects(Player player, String cond) {
|
||||
if (cond == null || cond.isEmpty())
|
||||
return true;
|
||||
|
||||
Collection<EffectInstance> effects = player.getActiveEffects();
|
||||
|
||||
Collection<MobEffectInstance> effects = player.getActiveEffects();
|
||||
String[] potions = cond.split(",");
|
||||
|
||||
|
||||
List<String> names = new ArrayList<String>();
|
||||
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];
|
||||
if(pot.contains("#"))
|
||||
{
|
||||
if (pot.contains("#")) {
|
||||
String level = pot.substring(pot.indexOf("#"));
|
||||
String name = pot.substring(0, pot.indexOf("#"));
|
||||
level = level.replace("#", "");
|
||||
int lev = 0;
|
||||
try
|
||||
{
|
||||
try {
|
||||
lev = Integer.parseInt(level);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch(Exception e)
|
||||
{}
|
||||
|
||||
|
||||
levels.add(lev);
|
||||
names.add(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
levels.add(0);
|
||||
names.add(pot);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int matches = 0;
|
||||
for(EffectInstance effect : effects)
|
||||
{
|
||||
for (MobEffectInstance effect : effects) {
|
||||
int amp = effect.getAmplifier();
|
||||
String name = effect.getEffect().getRegistryName().toString();
|
||||
|
||||
if(names.contains(name))
|
||||
{
|
||||
|
||||
if (names.contains(name)) {
|
||||
int idx = names.indexOf(name);
|
||||
int lev = levels.get(idx);
|
||||
|
||||
if(lev == amp)
|
||||
|
||||
if (lev == amp)
|
||||
matches++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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())
|
||||
return true;
|
||||
|
||||
switch (cond)
|
||||
{
|
||||
|
||||
switch (cond) {
|
||||
case "air":
|
||||
return material == Material.AIR;
|
||||
case "anvil":
|
||||
|
|
@ -295,8 +253,6 @@ public class ScriptParseHelper
|
|||
return material == Material.CLAY;
|
||||
case "cloth":
|
||||
return material == Material.WOOL;
|
||||
case "coral":
|
||||
return material == Material.CORAL;
|
||||
case "dragon_egg":
|
||||
return material == Material.EGG;
|
||||
case "fire":
|
||||
|
|
@ -347,8 +303,9 @@ public class ScriptParseHelper
|
|||
return material == Material.WEB;
|
||||
case "wood":
|
||||
return material == Material.WOOD;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@ import javax.annotation.Nullable;
|
|||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.command.arguments.BlockStateParser;
|
||||
import net.minecraft.command.arguments.ItemParser;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.commands.arguments.blocks.BlockStateParser;
|
||||
import net.minecraft.commands.arguments.item.ItemParser;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.TagParser;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class StringParser
|
||||
{
|
||||
|
|
@ -78,7 +78,7 @@ public class StringParser
|
|||
{
|
||||
parser.parse();
|
||||
Item item = parser.getItem();
|
||||
CompoundNBT nbt = parser.getNbt();
|
||||
CompoundTag nbt = parser.getNbt();
|
||||
|
||||
ItemStack stack = new ItemStack(item, 1);
|
||||
|
||||
|
|
@ -99,9 +99,9 @@ public class StringParser
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public static CompoundNBT getTagCompound(String string)
|
||||
public static CompoundTag getTagCompound(String string)
|
||||
{
|
||||
CompoundNBT tag = null;
|
||||
CompoundTag tag = null;
|
||||
if(string == null)
|
||||
return null;
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ public class StringParser
|
|||
string = string.replace(nbt, "");
|
||||
try
|
||||
{
|
||||
tag = JsonToNBT.parseTag(nbt);
|
||||
tag = TagParser.parseTag(nbt);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,31 +6,31 @@ import javax.annotation.Nullable;
|
|||
|
||||
import com.google.common.base.CharMatcher;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.potion.EffectInstance;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
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.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.ClickEvent.Action;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.event.world.BlockEvent.EntityPlaceEvent;
|
||||
|
|
@ -55,12 +55,12 @@ public class ItemCarryonBlock extends Item
|
|||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getName(ItemStack stack)
|
||||
public Component getName(ItemStack stack)
|
||||
{
|
||||
if (hasTileData(stack))
|
||||
{
|
||||
BlockState state = getBlockState(stack);
|
||||
CompoundNBT nbt = getTileData(stack);
|
||||
CompoundTag nbt = getTileData(stack);
|
||||
|
||||
if (ModelOverridesHandler.hasCustomOverrideModel(state, nbt))
|
||||
{
|
||||
|
|
@ -77,39 +77,39 @@ public class ItemCarryonBlock extends Item
|
|||
return getItemStack(stack).getHoverName();
|
||||
}
|
||||
|
||||
return new StringTextComponent("");
|
||||
return new TextComponent("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType useOn(ItemUseContext context)
|
||||
public InteractionResult useOn(UseOnContext context)
|
||||
{
|
||||
Direction facing = context.getClickedFace();
|
||||
PlayerEntity player = context.getPlayer();
|
||||
World world = context.getLevel();
|
||||
Player player = context.getPlayer();
|
||||
Level world = context.getLevel();
|
||||
BlockPos pos = context.getClickedPos();
|
||||
ItemStack stack = context.getItemInHand();
|
||||
|
||||
if (ModList.get().isLoaded("betterplacement"))
|
||||
{
|
||||
if (CarryOnKeybinds.isKeyPressed(player))
|
||||
return ActionResultType.FAIL;
|
||||
return InteractionResult.FAIL;
|
||||
}
|
||||
|
||||
if (hasTileData(stack))
|
||||
{
|
||||
try
|
||||
{
|
||||
Vector3d vec = player.getLookAngle();
|
||||
Vec3 vec = player.getLookAngle();
|
||||
Direction facing2 = Direction.getNearest((float) vec.x, 0f, (float) vec.z);
|
||||
BlockPos pos2 = pos;
|
||||
Block containedblock = getBlock(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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ public class ItemCarryonBlock extends Item
|
|||
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;
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ public class ItemCarryonBlock extends Item
|
|||
// change rotation via NBT
|
||||
if (!getTileData(stack).isEmpty())
|
||||
{
|
||||
CompoundNBT tag = getTileData(stack);
|
||||
CompoundTag tag = getTileData(stack);
|
||||
Set<String> keys = tag.getAllKeys();
|
||||
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)
|
||||
{
|
||||
CompoundNBT data = getTileData(stack);
|
||||
CompoundTag data = getTileData(stack);
|
||||
updateTileLocation(data, pos2);
|
||||
tile.load(actualState, data);
|
||||
tile.load(data);
|
||||
}
|
||||
clearTileData(stack);
|
||||
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");
|
||||
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)))
|
||||
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);
|
||||
StringTextComponent s = new StringTextComponent(TextFormatting.GOLD + "here");
|
||||
player.displayClientMessage(new TextComponent(ChatFormatting.RED + "Error detected. Cannot place block. Execute \"/carryon clear\" to remove the item"), false);
|
||||
TextComponent s = new TextComponent(ChatFormatting.GOLD + "here");
|
||||
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
|
||||
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 (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;
|
||||
|
||||
((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
|
||||
|
|
@ -255,22 +255,22 @@ public class ItemCarryonBlock extends Item
|
|||
{
|
||||
if (stack.hasTag())
|
||||
{
|
||||
CompoundNBT tag = stack.getTag();
|
||||
CompoundTag tag = stack.getTag();
|
||||
return tag.contains(TILE_DATA_KEY) && tag.contains("block") && tag.contains("stateid");
|
||||
}
|
||||
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())
|
||||
return false;
|
||||
|
||||
CompoundNBT tileTag = new CompoundNBT();
|
||||
CompoundTag tileTag = new CompoundTag();
|
||||
if (tile != null)
|
||||
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))
|
||||
return false;
|
||||
|
||||
|
|
@ -287,7 +287,7 @@ public class ItemCarryonBlock extends Item
|
|||
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("y", pos.getY());
|
||||
|
|
@ -298,18 +298,18 @@ public class ItemCarryonBlock extends Item
|
|||
{
|
||||
if (stack.hasTag())
|
||||
{
|
||||
CompoundNBT tag = stack.getTag();
|
||||
CompoundTag tag = stack.getTag();
|
||||
tag.remove(TILE_DATA_KEY);
|
||||
tag.remove("block");
|
||||
tag.remove("stateid");
|
||||
}
|
||||
}
|
||||
|
||||
public static CompoundNBT getTileData(ItemStack stack)
|
||||
public static CompoundTag getTileData(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTag())
|
||||
{
|
||||
CompoundNBT tag = stack.getTag();
|
||||
CompoundTag tag = stack.getTag();
|
||||
return tag.getCompound(TILE_DATA_KEY);
|
||||
}
|
||||
return null;
|
||||
|
|
@ -319,7 +319,7 @@ public class ItemCarryonBlock extends Item
|
|||
{
|
||||
if (stack.hasTag())
|
||||
{
|
||||
CompoundNBT tag = stack.getTag();
|
||||
CompoundTag tag = stack.getTag();
|
||||
int id = tag.getInt("stateid");
|
||||
return Block.stateById(id).getBlock();
|
||||
}
|
||||
|
|
@ -346,19 +346,19 @@ public class ItemCarryonBlock extends Item
|
|||
{
|
||||
if (stack.hasTag())
|
||||
{
|
||||
CompoundNBT tag = stack.getTag();
|
||||
CompoundTag tag = stack.getTag();
|
||||
int id = tag.getInt("stateid");
|
||||
return Block.stateById(id);
|
||||
}
|
||||
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)
|
||||
{
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
CompoundTag tag = new CompoundTag();
|
||||
te.save(tag);
|
||||
return tag.contains("Lock") ? !tag.getString("Lock").equals("") : false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,29 +5,29 @@ import java.util.Optional;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.potion.EffectInstance;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
import tschipp.carryon.common.config.Configs.Settings;
|
||||
|
|
@ -39,7 +39,7 @@ public class ItemCarryonEntity extends Item {
|
|||
|
||||
static
|
||||
{
|
||||
initGoals = ObfuscationReflectionHelper.findMethod(MobEntity.class, "func_184651_r");
|
||||
initGoals = ObfuscationReflectionHelper.findMethod(Mob.class, "m_8099_");
|
||||
initGoals.setAccessible(true);
|
||||
}
|
||||
|
||||
|
|
@ -51,37 +51,37 @@ public class ItemCarryonEntity extends Item {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getName(ItemStack stack)
|
||||
public Component getName(ItemStack 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) {
|
||||
if (stack.hasTag()) {
|
||||
CompoundNBT tag = stack.getTag();
|
||||
CompoundTag tag = stack.getTag();
|
||||
return tag.contains(ENTITY_DATA_KEY) && tag.contains("entity");
|
||||
}
|
||||
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)
|
||||
return false;
|
||||
|
||||
if (stack.isEmpty())
|
||||
return false;
|
||||
|
||||
CompoundNBT entityData = new CompoundNBT();
|
||||
CompoundTag entityData = new CompoundTag();
|
||||
entityData = entity.serializeNBT();
|
||||
|
||||
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))
|
||||
return false;
|
||||
|
||||
|
|
@ -92,9 +92,9 @@ public class ItemCarryonEntity extends Item {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType useOn(ItemUseContext context) {
|
||||
PlayerEntity player = context.getPlayer();
|
||||
World world = context.getLevel();
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
Player player = context.getPlayer();
|
||||
Level world = context.getLevel();
|
||||
BlockPos pos = context.getClickedPos();
|
||||
Direction facing = context.getClickedFace();
|
||||
|
||||
|
|
@ -104,13 +104,13 @@ public class ItemCarryonEntity extends Item {
|
|||
|
||||
if (ModList.get().isLoaded("betterplacement")) {
|
||||
if (CarryOnKeybinds.isKeyPressed(player))
|
||||
return ActionResultType.FAIL;
|
||||
return InteractionResult.FAIL;
|
||||
}
|
||||
|
||||
if (hasEntityData(stack)) {
|
||||
BlockPos finalPos = pos;
|
||||
|
||||
if (!state.canBeReplaced(new BlockItemUseContext(context))) {
|
||||
if (!state.canBeReplaced(new BlockPlaceContext(context))) {
|
||||
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,
|
||||
180 + player.yHeadRot, 0.0f);
|
||||
world.addFreshEntity(entity);
|
||||
if (entity instanceof MobEntity) {
|
||||
((MobEntity) entity).playAmbientSound();
|
||||
if (entity instanceof Mob) {
|
||||
((Mob) entity).playAmbientSound();
|
||||
}
|
||||
clearEntityData(stack);
|
||||
player.setItemInHand(Hand.MAIN_HAND, ItemStack.EMPTY);
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);
|
||||
ItemEvents.sendPacket(player, 9, 0);
|
||||
|
||||
}
|
||||
player.getPersistentData().remove("overrideKey");
|
||||
return ActionResultType.SUCCESS;
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return ActionResultType.FAIL;
|
||||
return InteractionResult.FAIL;
|
||||
}
|
||||
|
||||
@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 (getEntity(stack, world) == null)
|
||||
stack = ItemStack.EMPTY;
|
||||
|
||||
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;
|
||||
|
||||
((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 {
|
||||
|
|
@ -158,27 +158,27 @@ public class ItemCarryonEntity extends Item {
|
|||
|
||||
public static void clearEntityData(ItemStack stack) {
|
||||
if (stack.hasTag()) {
|
||||
CompoundNBT tag = stack.getTag();
|
||||
CompoundTag tag = stack.getTag();
|
||||
tag.remove(ENTITY_DATA_KEY);
|
||||
tag.remove("entity");
|
||||
}
|
||||
}
|
||||
|
||||
public static CompoundNBT getPersistentData(ItemStack stack) {
|
||||
public static CompoundTag getPersistentData(ItemStack stack) {
|
||||
if (stack.hasTag()) {
|
||||
CompoundNBT tag = stack.getTag();
|
||||
CompoundTag tag = stack.getTag();
|
||||
return tag.getCompound(ENTITY_DATA_KEY);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Entity getEntity(ItemStack stack, World world) {
|
||||
public static Entity getEntity(ItemStack stack, Level world) {
|
||||
if (world == null)
|
||||
return null;
|
||||
|
||||
String name = getEntityName(stack);
|
||||
|
||||
CompoundNBT e = getPersistentData(stack);
|
||||
CompoundTag e = getPersistentData(stack);
|
||||
Optional<EntityType<?>> type = EntityType.byString(name);
|
||||
Entity entity = null;
|
||||
|
||||
|
|
@ -203,7 +203,7 @@ public class ItemCarryonEntity extends Item {
|
|||
|
||||
public static String getEntityName(ItemStack stack) {
|
||||
if (stack.hasTag()) {
|
||||
CompoundNBT tag = stack.getTag();
|
||||
CompoundTag tag = stack.getTag();
|
||||
return tag.getString("entity");
|
||||
}
|
||||
return null;
|
||||
|
|
@ -211,7 +211,7 @@ public class ItemCarryonEntity extends Item {
|
|||
|
||||
public static String getCustomName(ItemStack stack) {
|
||||
if (stack.hasTag()) {
|
||||
CompoundNBT tag = stack.getTag();
|
||||
CompoundTag tag = stack.getTag();
|
||||
if (tag.contains("CustomName") && !tag.getString("CustomName").isEmpty()) {
|
||||
return tag.toString();
|
||||
} else {
|
||||
|
|
@ -223,7 +223,7 @@ public class ItemCarryonEntity extends Item {
|
|||
|
||||
public static EntityType<?> getEntityType(ItemStack stack) {
|
||||
if (stack.hasTag()) {
|
||||
CompoundNBT tag = stack.getTag();
|
||||
CompoundTag tag = stack.getTag();
|
||||
String name = tag.getString("entity");
|
||||
Optional<EntityType<?>> type = EntityType.byString(name);
|
||||
if (type.isPresent())
|
||||
|
|
@ -232,7 +232,7 @@ public class ItemCarryonEntity extends Item {
|
|||
return null;
|
||||
}
|
||||
|
||||
private int potionLevel(ItemStack stack, World world) {
|
||||
private int potionLevel(ItemStack stack, Level world) {
|
||||
Entity e = getEntity(stack, world);
|
||||
if (e == null)
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -3,23 +3,23 @@ package tschipp.carryon.common.scripting;
|
|||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.TagParser;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import tschipp.carryon.common.helper.InvalidConfigException;
|
||||
|
||||
public class CarryOnOverride
|
||||
{
|
||||
// BLOCKS
|
||||
private CompoundNBT typeBlockTag = new CompoundNBT();
|
||||
private CompoundTag typeBlockTag = new CompoundTag();
|
||||
private String typeNameBlock = "";
|
||||
private String typeMaterial = "";
|
||||
private String typeHardness = "";
|
||||
private String typeResistance = "";
|
||||
|
||||
// ENTITIES
|
||||
private CompoundNBT typeEntityTag;
|
||||
private CompoundTag typeEntityTag;
|
||||
private String typeNameEntity = "";
|
||||
private String typeHeight = "";
|
||||
private String typeWidth = "";
|
||||
|
|
@ -37,7 +37,7 @@ public class CarryOnOverride
|
|||
// RENDER
|
||||
private String renderNameBlock = "";
|
||||
private String renderNameEntity = "";
|
||||
private CompoundNBT renderNBT = new CompoundNBT();
|
||||
private CompoundTag renderNBT = new CompoundTag();
|
||||
private String renderTranslation = "";
|
||||
private String renderRotation = "";
|
||||
private String renderscaled = "";
|
||||
|
|
@ -104,7 +104,7 @@ public class CarryOnOverride
|
|||
if (resistance != null)
|
||||
setTypeResistance(resistance.getAsString());
|
||||
if (nbt != null)
|
||||
setTypeBlockTag(JsonToNBT.parseTag(nbt.toString()));
|
||||
setTypeBlockTag(TagParser.parseTag(nbt.toString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -124,7 +124,7 @@ public class CarryOnOverride
|
|||
if (width != null)
|
||||
setTypeWidth(width.getAsString());
|
||||
if (nbt != null)
|
||||
setTypeEntityTag(JsonToNBT.parseTag(nbt.toString()));
|
||||
setTypeEntityTag(TagParser.parseTag(nbt.toString()));
|
||||
}
|
||||
|
||||
if (conditions != null)
|
||||
|
|
@ -177,7 +177,7 @@ public class CarryOnOverride
|
|||
if (scaled != null)
|
||||
setRenderscaled(scaled.getAsString());
|
||||
if (nbt != null)
|
||||
setRenderNBT(JsonToNBT.parseTag(nbt.toString()));
|
||||
setRenderNBT(TagParser.parseTag(nbt.toString()));
|
||||
if (rotationLeftArm != null)
|
||||
setRenderRotationLeftArm(rotationLeftArm.getAsString());
|
||||
if (rotationRightArm != null)
|
||||
|
|
@ -550,7 +550,7 @@ public class CarryOnOverride
|
|||
this.isEntity = isEntity;
|
||||
}
|
||||
|
||||
public CompoundNBT getTypeBlockTag()
|
||||
public CompoundTag getTypeBlockTag()
|
||||
{
|
||||
return typeBlockTag;
|
||||
}
|
||||
|
|
@ -575,7 +575,7 @@ public class CarryOnOverride
|
|||
return typeResistance;
|
||||
}
|
||||
|
||||
public CompoundNBT getTypeEntityTag()
|
||||
public CompoundTag getTypeEntityTag()
|
||||
{
|
||||
return typeEntityTag;
|
||||
}
|
||||
|
|
@ -640,7 +640,7 @@ public class CarryOnOverride
|
|||
return renderNameEntity;
|
||||
}
|
||||
|
||||
public CompoundNBT getRenderNBT()
|
||||
public CompoundTag getRenderNBT()
|
||||
{
|
||||
return renderNBT;
|
||||
}
|
||||
|
|
@ -660,7 +660,7 @@ public class CarryOnOverride
|
|||
return renderscaled;
|
||||
}
|
||||
|
||||
public void setTypeBlockTag(CompoundNBT typeBlockTag)
|
||||
public void setTypeBlockTag(CompoundTag typeBlockTag)
|
||||
{
|
||||
this.typeBlockTag = typeBlockTag;
|
||||
}
|
||||
|
|
@ -685,7 +685,7 @@ public class CarryOnOverride
|
|||
this.typeResistance = typeResistance;
|
||||
}
|
||||
|
||||
public void setTypeEntityTag(CompoundNBT typeEntityTag)
|
||||
public void setTypeEntityTag(CompoundTag typeEntityTag)
|
||||
{
|
||||
this.typeEntityTag = typeEntityTag;
|
||||
}
|
||||
|
|
@ -750,7 +750,7 @@ public class CarryOnOverride
|
|||
this.renderNameEntity = renderNameEntity;
|
||||
}
|
||||
|
||||
public void setRenderNBT(CompoundNBT renderNBT)
|
||||
public void setRenderNBT(CompoundTag renderNBT)
|
||||
{
|
||||
this.renderNBT = renderNBT;
|
||||
}
|
||||
|
|
@ -780,7 +780,7 @@ public class CarryOnOverride
|
|||
this.commandPlace = commandPlace;
|
||||
}
|
||||
|
||||
public void serialize(PacketBuffer buf)
|
||||
public void serialize(FriendlyByteBuf buf)
|
||||
{
|
||||
// BLOCKS
|
||||
buf.writeNbt(typeBlockTag);
|
||||
|
|
@ -827,7 +827,7 @@ public class CarryOnOverride
|
|||
buf.writeUtf(resourceLocation);
|
||||
}
|
||||
|
||||
public static CarryOnOverride deserialize(PacketBuffer buf)
|
||||
public static CarryOnOverride deserialize(FriendlyByteBuf buf)
|
||||
{
|
||||
CarryOnOverride override = new CarryOnOverride("");
|
||||
override.typeBlockTag = buf.readNbt();
|
||||
|
|
|
|||
|
|
@ -5,20 +5,20 @@ import java.lang.reflect.Method;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementManager;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.ServerAdvancementManager;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
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.handler.ListHandler;
|
||||
import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||
|
|
@ -26,7 +26,7 @@ import tschipp.carryon.common.helper.ScriptParseHelper;
|
|||
public class ScriptChecker
|
||||
{
|
||||
@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())
|
||||
return null;
|
||||
|
|
@ -36,7 +36,7 @@ public class ScriptChecker
|
|||
float hardness = state.getDestroySpeed(world, pos);
|
||||
@SuppressWarnings("deprecation")
|
||||
float resistance = block.getExplosionResistance();
|
||||
CompoundNBT nbt = tag;
|
||||
CompoundTag nbt = tag;
|
||||
|
||||
boolean isAllowed = Settings.useWhitelistBlocks.get() ? ListHandler.isAllowed(block) : !ListHandler.isForbidden(block);
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ public class ScriptChecker
|
|||
float height = entity.getBbHeight();
|
||||
float width = entity.getBbWidth();
|
||||
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);
|
||||
|
|
@ -85,7 +85,7 @@ public class ScriptChecker
|
|||
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 matchheight = ScriptParseHelper.matches(height, override.getTypeHeight());
|
||||
|
|
@ -96,7 +96,7 @@ public class ScriptChecker
|
|||
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 matchblock = ScriptParseHelper.matches(block, override.getTypeNameBlock());
|
||||
|
|
@ -107,13 +107,13 @@ public class ScriptChecker
|
|||
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()));
|
||||
|
||||
boolean achievement = adv == null ? true : ((ServerPlayerEntity) player).getAdvancements().getOrStartProgress(adv).isDone();
|
||||
boolean gamemode = ScriptParseHelper.matches(((ServerPlayerEntity) player).gameMode.getGameModeForPlayer().getId(), override.getConditionGamemode());
|
||||
boolean achievement = adv == null ? true : ((ServerPlayer) player).getAdvancements().getOrStartProgress(adv).isDone();
|
||||
boolean gamemode = ScriptParseHelper.matches(((ServerPlayer) player).gameMode.getGameModeForPlayer().getId(), override.getConditionGamemode());
|
||||
boolean gamestage = true;
|
||||
if (ModList.get().isLoaded("gamestages"))
|
||||
{
|
||||
|
|
@ -124,7 +124,7 @@ public class ScriptChecker
|
|||
Class<?> gameStageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper");
|
||||
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);
|
||||
|
||||
Object stageData = getPlayerData.invoke(null, player);
|
||||
|
|
@ -138,7 +138,7 @@ public class ScriptChecker
|
|||
Class<?> playerDataHandler = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler");
|
||||
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);
|
||||
|
||||
Object stageData = getStageData.invoke(null, player);
|
||||
|
|
@ -163,9 +163,9 @@ public class ScriptChecker
|
|||
}
|
||||
|
||||
@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"))
|
||||
{
|
||||
|
|
@ -177,9 +177,9 @@ public class ScriptChecker
|
|||
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)
|
||||
tag.putInt("overrideKey", i);
|
||||
|
|
|
|||
|
|
@ -6,22 +6,22 @@ import com.google.gson.Gson;
|
|||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import net.minecraft.client.resources.JsonReloadListener;
|
||||
import net.minecraft.profiler.IProfiler;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraftforge.event.AddReloadListenerEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
||||
import net.minecraftforge.fml.common.thread.EffectiveSide;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
import net.minecraftforge.fml.util.thread.EffectiveSide;
|
||||
import net.minecraftforge.fmllegacy.network.PacketDistributor;
|
||||
import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.network.client.ScriptReloadPacket;
|
||||
|
||||
@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();
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ public class ScriptReloadListener extends JsonReloadListener
|
|||
}
|
||||
|
||||
@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();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,101 +1,100 @@
|
|||
package tschipp.carryon.compat.obfuscate;
|
||||
|
||||
import com.mrcrayfish.obfuscate.client.event.PlayerModelEvent;
|
||||
|
||||
import net.minecraft.client.renderer.entity.model.PlayerModel;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.entity.Pose;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import tschipp.carryon.common.config.Configs.Settings;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||
import tschipp.carryon.common.item.ItemCarryonBlock;
|
||||
import tschipp.carryon.common.item.ItemCarryonEntity;
|
||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
|
||||
public class ObfuscateEvents
|
||||
{
|
||||
|
||||
@SubscribeEvent
|
||||
public void preModelPlayerEvent(PlayerModelEvent.SetupAngles.Post event)
|
||||
{
|
||||
if(!Settings.renderArms.get())
|
||||
return;
|
||||
|
||||
PlayerEntity player = event.getPlayer();
|
||||
|
||||
Pose pose = player.getPose();
|
||||
if (pose == Pose.SWIMMING || pose == Pose.FALL_FLYING)
|
||||
return;
|
||||
|
||||
PlayerModel<?> model = event.getModelPlayer();
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||
{
|
||||
|
||||
float rotation = 0;
|
||||
|
||||
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
||||
if (overrider != null)
|
||||
{
|
||||
float[] rotLeft = null;
|
||||
float[] rotRight = null;
|
||||
if (overrider.getRenderRotationLeftArm() != null)
|
||||
rotLeft = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
|
||||
if (overrider.getRenderRotationRightArm() != null)
|
||||
rotRight = ScriptParseHelper.getXYZArray(overrider.getRenderRotationRightArm());
|
||||
|
||||
boolean renderRight = overrider.isRenderRightArm();
|
||||
boolean renderLeft = overrider.isRenderLeftArm();
|
||||
|
||||
if (renderLeft && rotLeft != null)
|
||||
{
|
||||
renderArmPre(model.leftArm, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
||||
renderArmPre(model.leftSleeve, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
||||
}
|
||||
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.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)
|
||||
{
|
||||
renderArmPre(model.rightArm, (float) rotRight[0], (float) rotRight[2], rotation);
|
||||
renderArmPre(model.rightSleeve, (float) rotRight[0], (float) rotRight[2], rotation);
|
||||
}
|
||||
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.rightSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
}
|
||||
|
||||
}
|
||||
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.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.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)
|
||||
private void renderArmPre(ModelRenderer arm, float x, float z, float rotation)
|
||||
{
|
||||
arm.xRot = (float) -x;
|
||||
arm.yRot = (float) -Math.toRadians(rotation);
|
||||
arm.zRot = (float) z;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//package tschipp.carryon.compat.obfuscate;
|
||||
//
|
||||
//import com.mrcrayfish.obfuscate.client.event.PlayerModelEvent;
|
||||
//
|
||||
//import net.minecraft.client.model.PlayerModel;
|
||||
//import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
//import net.minecraft.entity.player.PlayerEntity;
|
||||
//import net.minecraft.world.item.ItemStack;
|
||||
//import net.minecraftforge.api.distmarker.Dist;
|
||||
//import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
//import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
//import tschipp.carryon.common.config.Configs.Settings;
|
||||
//import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
//import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||
//import tschipp.carryon.common.item.ItemCarryonBlock;
|
||||
//import tschipp.carryon.common.item.ItemCarryonEntity;
|
||||
//import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||
//import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
//
|
||||
//public class ObfuscateEvents
|
||||
//{
|
||||
//
|
||||
// @SubscribeEvent
|
||||
// public void preModelPlayerEvent(PlayerModelEvent.SetupAngles.Post event)
|
||||
// {
|
||||
// if(!Settings.renderArms.get())
|
||||
// return;
|
||||
//
|
||||
// PlayerEntity player = event.getPlayer();
|
||||
//
|
||||
// Pose pose = player.getPose();
|
||||
// if (pose == Pose.SWIMMING || pose == Pose.FALL_FLYING)
|
||||
// return;
|
||||
//
|
||||
// PlayerModel<?> model = event.getModelPlayer();
|
||||
// ItemStack stack = player.getMainHandItem();
|
||||
// if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||
// {
|
||||
//
|
||||
// float rotation = 0;
|
||||
//
|
||||
// CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
||||
// if (overrider != null)
|
||||
// {
|
||||
// float[] rotLeft = null;
|
||||
// float[] rotRight = null;
|
||||
// if (overrider.getRenderRotationLeftArm() != null)
|
||||
// rotLeft = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
|
||||
// if (overrider.getRenderRotationRightArm() != null)
|
||||
// rotRight = ScriptParseHelper.getXYZArray(overrider.getRenderRotationRightArm());
|
||||
//
|
||||
// boolean renderRight = overrider.isRenderRightArm();
|
||||
// boolean renderLeft = overrider.isRenderLeftArm();
|
||||
//
|
||||
// if (renderLeft && rotLeft != null)
|
||||
// {
|
||||
// renderArmPre(model.leftArm, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
||||
// renderArmPre(model.leftSleeve, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
||||
// }
|
||||
// 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.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)
|
||||
// {
|
||||
// renderArmPre(model.rightArm, (float) rotRight[0], (float) rotRight[2], rotation);
|
||||
// renderArmPre(model.rightSleeve, (float) rotRight[0], (float) rotRight[2], rotation);
|
||||
// }
|
||||
// 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.rightSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// 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.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.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)
|
||||
// private void renderArmPre(ModelRenderer arm, float x, float z, float rotation)
|
||||
// {
|
||||
// arm.xRot = (float) -x;
|
||||
// arm.yRot = (float) -Math.toRadians(rotation);
|
||||
// arm.zRot = (float) z;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ package tschipp.carryon.network.client;
|
|||
import java.util.function.Supplier;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
|
||||
|
|
@ -49,15 +49,15 @@ public class CarrySlotPacket
|
|||
{
|
||||
ctx.get().enqueueWork(() -> {
|
||||
|
||||
World world = CarryOn.proxy.getWorld();
|
||||
Level world = CarryOn.proxy.getWorld();
|
||||
|
||||
if (world != null)
|
||||
{
|
||||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||
import tschipp.carryon.common.scripting.ScriptReader;
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ public class ScriptReloadPacket
|
|||
overrides.addAll(collection);
|
||||
}
|
||||
|
||||
public ScriptReloadPacket(PacketBuffer buf)
|
||||
public ScriptReloadPacket(FriendlyByteBuf buf)
|
||||
{
|
||||
int size = buf.readInt();
|
||||
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());
|
||||
overrides.forEach(override -> override.serialize(buf));
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ package tschipp.carryon.network.server;
|
|||
import java.util.function.Supplier;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.fmllegacy.network.NetworkEvent;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
|
||||
public class SyncKeybindPacket
|
||||
|
|
@ -32,7 +32,7 @@ public class SyncKeybindPacket
|
|||
{
|
||||
ctx.get().enqueueWork(() -> {
|
||||
|
||||
ServerPlayerEntity player = ctx.get().getSender();
|
||||
ServerPlayer player = ctx.get().getSender();
|
||||
|
||||
CarryOnKeybinds.setKeyPressed(player, pressed);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package tschipp.carryon.proxy;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
|
|
@ -24,14 +24,14 @@ public class ClientProxy implements IProxy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PlayerEntity getPlayer()
|
||||
public Player getPlayer()
|
||||
{
|
||||
|
||||
return Minecraft.getInstance().player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
public Level getWorld()
|
||||
{
|
||||
return Minecraft.getInstance().level;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package tschipp.carryon.proxy;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
|
||||
public interface IProxy
|
||||
|
|
@ -9,7 +9,7 @@ public interface IProxy
|
|||
|
||||
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;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
|
||||
public class ServerProxy implements IProxy
|
||||
|
|
@ -14,13 +14,13 @@ public class ServerProxy implements IProxy
|
|||
}
|
||||
|
||||
@Override
|
||||
public PlayerEntity getPlayer()
|
||||
public Player getPlayer()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
public Level getWorld()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
modLoader="javafml"
|
||||
loaderVersion="[34,)"
|
||||
loaderVersion="[37,)"
|
||||
issueTrackerURL="https://github.com/Tschipp/CarryOn/issues"
|
||||
logoFile="logo.png"
|
||||
license="GNU LGPLv3"
|
||||
|
|
@ -18,7 +18,7 @@ license="GNU LGPLv3"
|
|||
# Does this dependency have to exist - if not, ordering below must be specified
|
||||
mandatory=true #mandatory
|
||||
# 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
|
||||
ordering="NONE"
|
||||
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||
|
|
@ -27,6 +27,6 @@ license="GNU LGPLv3"
|
|||
[[dependencies.carryon]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
versionRange="[1.16.3,1.17)"
|
||||
versionRange="[1.17.1,1.18)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
Loading…
Reference in New Issue
Block a user