Update to 1.13.2
This commit is contained in:
parent
cb5edc3061
commit
65d3f58eaa
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -5,7 +5,6 @@ bin
|
|||
.metadata
|
||||
.classpath
|
||||
.project
|
||||
.DS_Store
|
||||
|
||||
# idea
|
||||
out
|
||||
|
|
@ -22,4 +21,5 @@ build
|
|||
eclipse
|
||||
run
|
||||
|
||||
gradle\.properties
|
||||
# Files from Forge MDK
|
||||
forge*changelog.txt
|
||||
|
|
|
|||
159
build.gradle
159
build.gradle
|
|
@ -1,88 +1,113 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
maven { url = 'https://files.minecraftforge.net/maven' }
|
||||
jcenter()
|
||||
maven { url = "http://files.minecraftforge.net/maven" }
|
||||
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
|
||||
version = "1.0"
|
||||
group = "tschipp.carryon"
|
||||
archivesBaseName = "carryon"
|
||||
|
||||
sourceCompatibility = targetCompatibility = '1.8'
|
||||
compileJava {
|
||||
sourceCompatibility = targetCompatibility = '1.8'
|
||||
}
|
||||
|
||||
minecraft {
|
||||
version = "1.12.2-14.23.4.2765"
|
||||
runDir = "run"
|
||||
|
||||
mappings = "snapshot_20171003"
|
||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
||||
maven { url 'http://maven.epoxide.org' }
|
||||
|
||||
maven { url = "https://mrcrayfish.com/maven" }
|
||||
maven { url = "https://minecraft.curseforge.com/api/maven/" }
|
||||
|
||||
}
|
||||
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
|
||||
apply plugin: 'eclipse'
|
||||
|
||||
version = '1.0'
|
||||
group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'modid'
|
||||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
|
||||
|
||||
minecraft {
|
||||
|
||||
mappings channel: 'snapshot', version: '20180921-1.13'
|
||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
||||
|
||||
// accessTransformer = file('build/resources/main/META-INF/accesstransformer.cfg')
|
||||
|
||||
// Default run configurations.
|
||||
// These can be tweaked, removed, or duplicated as needed.
|
||||
runs {
|
||||
client {
|
||||
workingDirectory project.file('run')
|
||||
|
||||
// Recommended logging data for a userdev environment
|
||||
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
|
||||
|
||||
// Recommended logging level for the console
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
mods {
|
||||
examplemod {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
workingDirectory project.file('run')
|
||||
|
||||
// Recommended logging data for a userdev environment
|
||||
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
|
||||
|
||||
// Recommended logging level for the console
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
mods {
|
||||
examplemod {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
dependencies {
|
||||
|
||||
// deobfCompile "net.darkhax.gamestages:GameStages-1.12.2:2.0.91"
|
||||
|
||||
compile "com.mrcrayfish:obfuscate:0.2.6-1.12.2"
|
||||
minecraft 'net.minecraftforge:forge:1.13.2-25.0.85'
|
||||
|
||||
// You may put jars on which you depend on in ./libs or you may define them like so..
|
||||
// compile "some.group:artifact:version:classifier"
|
||||
// compile "some.group:artifact:version"
|
||||
|
||||
// Real examples
|
||||
// compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
|
||||
// compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
|
||||
|
||||
// compile "obfuscate:Obfuscate:0.3.0"
|
||||
|
||||
// The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
|
||||
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
|
||||
|
||||
// These dependencies get remapped to your current MCP mappings
|
||||
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
|
||||
|
||||
// For more info...
|
||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
||||
inputs.property "version", project.version
|
||||
inputs.property "mcversion", project.minecraft.version
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
|
||||
expand 'version':project.version, 'mcversion':project.minecraft.version
|
||||
// Example for how to get properties into the manifest for reading by the runtime..
|
||||
jar {
|
||||
manifest {
|
||||
attributes([
|
||||
"Specification-Title": "examplemod",
|
||||
"Specification-Vendor": "examplemodsareus",
|
||||
"Specification-Version": "1", // We are version 1 of ourselves
|
||||
"Implementation-Title": project.name,
|
||||
"Implementation-Version": "${version}",
|
||||
"Implementation-Vendor" :"examplemodsareus",
|
||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||
])
|
||||
}
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
}
|
||||
}
|
||||
|
||||
task signJar(type: SignJar, dependsOn: reobfJar) {
|
||||
|
||||
// Skips if the keyStore property is missing.
|
||||
onlyIf {
|
||||
project.hasProperty('keyStore')
|
||||
}
|
||||
|
||||
// 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('keyStore')
|
||||
alias = project.findProperty('keyStoreAlias')
|
||||
storePass = project.findProperty('keyStorePass')
|
||||
keyPass = project.findProperty('keyStoreKeyPass')
|
||||
inputFile = jar.archivePath
|
||||
outputFile = jar.archivePath
|
||||
}
|
||||
|
||||
// Runs this task automatically when build is ran.
|
||||
build.dependsOn signJar
|
||||
|
||||
}
|
||||
4
gradle.properties
Normal file
4
gradle.properties
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
|
||||
# This is required to provide enough memory for the Minecraft decompilation process.
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
|
|
@ -1,6 +1,5 @@
|
|||
#Mon Sep 14 12:28:28 PDT 2015
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
|
||||
|
|
|
|||
110
gradlew
vendored
110
gradlew
vendored
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
|
|
@ -6,47 +6,6 @@
|
|||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
|
|
@ -61,9 +20,49 @@ while [ -h "$PRG" ] ; do
|
|||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
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=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
|
@ -90,7 +89,7 @@ location of your Java installation."
|
|||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
|
|
@ -114,6 +113,7 @@ fi
|
|||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
|
|
@ -154,11 +154,19 @@ if $cygwin ; then
|
|||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
# 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" "$@"
|
||||
|
|
|
|||
14
gradlew.bat
vendored
14
gradlew.bat
vendored
|
|
@ -8,14 +8,14 @@
|
|||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@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 DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@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=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
|
|
@ -46,10 +46,9 @@ echo location of your Java installation.
|
|||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
|
|
@ -60,11 +59,6 @@ set _SKIP=2
|
|||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
|
|
|||
|
|
@ -5,70 +5,101 @@ import java.io.File;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.Mod.Instance;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.FMLFingerprintViolationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import tschipp.carryon.common.CommonProxy;
|
||||
import tschipp.carryon.common.command.CommandCarryOn;
|
||||
import tschipp.carryon.common.command.CommandCarryOnReload;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLFingerprintViolationEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
import net.minecraftforge.fml.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.network.simple.SimpleChannel;
|
||||
import tschipp.carryon.common.config.Configs;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.scripting.ScriptReader;
|
||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
||||
import tschipp.carryon.network.client.ScriptReloadPacket;
|
||||
import tschipp.carryon.network.server.SyncKeybindPacket;
|
||||
import tschipp.carryon.proxy.ClientProxy;
|
||||
import tschipp.carryon.proxy.IProxy;
|
||||
import tschipp.carryon.proxy.ServerProxy;
|
||||
|
||||
@EventBusSubscriber
|
||||
@Mod(modid = CarryOn.MODID, name = CarryOn.NAME, version = CarryOn.VERSION, guiFactory = "tschipp.carryon.client.gui.GuiFactoryCarryOn", dependencies = CarryOn.DEPENDENCIES, updateJSON = CarryOn.UPDATE_JSON, acceptedMinecraftVersions = CarryOn.ACCEPTED_VERSIONS, certificateFingerprint = CarryOn.CERTIFICATE_FINGERPRINT)
|
||||
public class CarryOn {
|
||||
@Mod(CarryOn.MODID)
|
||||
@EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class CarryOn
|
||||
{
|
||||
|
||||
@SidedProxy(clientSide = "tschipp.carryon.client.ClientProxy", serverSide = "tschipp.carryon.common.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
// Instance
|
||||
@Instance(CarryOn.MODID)
|
||||
public static CarryOn instance;
|
||||
public static IProxy proxy = DistExecutor.runForDist(() -> () -> new ClientProxy(), () -> () -> new ServerProxy());
|
||||
|
||||
public static final String MODID = "carryon";
|
||||
public static final String VERSION = "1.12";
|
||||
public static final String NAME = "Carry On";
|
||||
public static final String ACCEPTED_VERSIONS = "[1.12.2,1.13)";
|
||||
public static final String UPDATE_JSON = "https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/";
|
||||
public static final String VERSION = "1.12.2";
|
||||
public static final Logger LOGGER = LogManager.getFormatterLogger("CarryOn");
|
||||
public static final String DEPENDENCIES = "required-after:forge@[13.20.1.2386,);after:gamestages;";
|
||||
public static final String CERTIFICATE_FINGERPRINT = "55e88f24d04398481ae6f1ce76f65fd776f14227";
|
||||
public static File CONFIGURATION_FILE;
|
||||
|
||||
public static SimpleNetworkWrapper network;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event){
|
||||
CarryOn.proxy.preInit(event);
|
||||
}
|
||||
public static boolean FINGERPRINT_VIOLATED = false;
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
CarryOn.proxy.init(event);
|
||||
}
|
||||
public static SimpleChannel network;
|
||||
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
CarryOn.proxy.postInit(event);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void serverLoad(FMLServerStartingEvent event)
|
||||
public CarryOn()
|
||||
{
|
||||
event.registerServerCommand(new CommandCarryOn());
|
||||
event.registerServerCommand(new CommandCarryOnReload());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
|
||||
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, Configs.CLIENT_CONFIG);
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, Configs.SERVER_CONFIG);
|
||||
|
||||
Configs.loadConfig(Configs.CLIENT_CONFIG, FMLPaths.CONFIGDIR.get().resolve("carryon-client.toml"));
|
||||
Configs.loadConfig(Configs.SERVER_CONFIG, FMLPaths.CONFIGDIR.get().resolve("carryon-server.toml"));
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFingerprintViolation(FMLFingerprintViolationEvent event) {
|
||||
|
||||
|
||||
private void setup(final FMLCommonSetupEvent event)
|
||||
{
|
||||
// PreInitevent.
|
||||
ScriptReader.preInit();
|
||||
CarryOn.network = NetworkRegistry.newSimpleChannel(new ResourceLocation(CarryOn.MODID, "carryonpackets"), () -> CarryOn.VERSION, s -> true, s -> true);
|
||||
|
||||
// CLIENT PACKETS
|
||||
CarryOn.network.registerMessage(0, CarrySlotPacket.class, CarrySlotPacket::toBytes, CarrySlotPacket::new, CarrySlotPacket::handle);
|
||||
CarryOn.network.registerMessage(1, ScriptReloadPacket.class, ScriptReloadPacket::toBytes, ScriptReloadPacket::new, ScriptReloadPacket::handle);
|
||||
|
||||
// SERVER PACKETS
|
||||
CarryOn.network.registerMessage(2, SyncKeybindPacket.class, SyncKeybindPacket::toBytes, SyncKeybindPacket::new, SyncKeybindPacket::handle);
|
||||
|
||||
|
||||
RegistrationHandler.regCommonEvents();
|
||||
|
||||
// Init
|
||||
ScriptReader.parseScripts();
|
||||
RegistrationHandler.regOverrideList();
|
||||
RegistrationHandler.regCaps();
|
||||
|
||||
|
||||
proxy.setup(event);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onRegistry(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
RegistrationHandler.regItems();
|
||||
|
||||
event.getRegistry().register(RegistrationHandler.itemEntity);
|
||||
event.getRegistry().register(RegistrationHandler.itemTile);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onFingerprintViolation(FMLFingerprintViolationEvent event)
|
||||
{
|
||||
|
||||
LOGGER.error("WARNING! Invalid fingerprint detected! The file " + event.getSource().getName() + " may have been tampered with! If you didn't download the file from https://minecraft.curseforge.com/projects/carry-on or through any kind of mod launcher, immediately delete the file and re-download it from https://minecraft.curseforge.com/projects/carry-on");
|
||||
}
|
||||
FINGERPRINT_VIOLATED = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
package tschipp.carryon.client;
|
||||
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
import tschipp.carryon.common.CommonProxy;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
super.preInit(event);
|
||||
RegistrationHandler.regItemRenders();
|
||||
RegistrationHandler.regClientEvents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
CarryOnKeybinds.init();
|
||||
super.init(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit(FMLPostInitializationEvent e)
|
||||
{
|
||||
super.postInit(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,150 +1,52 @@
|
|||
package tschipp.carryon.client.event;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.GuiOpenEvent;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||
import tschipp.carryon.common.item.ItemEntity;
|
||||
import tschipp.carryon.common.item.ItemTile;
|
||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
|
||||
public class RenderEntityEvents
|
||||
{
|
||||
/*
|
||||
* Prevents the Player from scrolling
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onScroll(MouseEvent event) throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (event.getDwheel() > 0 || event.getDwheel() < 0 || Minecraft.getMinecraft().gameSettings.keyBindPickBlock.isPressed())
|
||||
{
|
||||
ItemStack stack = Minecraft.getMinecraft().player.getHeldItemMainhand();
|
||||
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity)
|
||||
{
|
||||
if (ItemEntity.hasEntityData(stack))
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Prevents the Player from opening Guis
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onGuiInit(InitGuiEvent.Pre event)
|
||||
{
|
||||
if (event.getGui() != null)
|
||||
{
|
||||
boolean inventory = event.getGui() instanceof GuiContainer;
|
||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
|
||||
if (player != null && inventory)
|
||||
{
|
||||
ItemStack stack = player.getHeldItem(EnumHand.MAIN_HAND);
|
||||
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))
|
||||
{
|
||||
Minecraft.getMinecraft().player.closeScreen();
|
||||
Minecraft.getMinecraft().currentScreen = null;
|
||||
Minecraft.getMinecraft().setIngameFocus();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Prevents the Player from switching Slots
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void inputEvent(InputEvent event) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
|
||||
{
|
||||
GameSettings settings = Minecraft.getMinecraft().gameSettings;
|
||||
Field field = KeyBinding.class.getDeclaredFields()[8];
|
||||
field.setAccessible(true);
|
||||
ItemStack stack = Minecraft.getMinecraft().player.getHeldItemMainhand();
|
||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))
|
||||
{
|
||||
if (settings.keyBindDrop.isPressed())
|
||||
{
|
||||
field.set(settings.keyBindDrop, false);
|
||||
}
|
||||
if (settings.keyBindSwapHands.isPressed())
|
||||
{
|
||||
field.set(settings.keyBindSwapHands, false);
|
||||
}
|
||||
for (KeyBinding keyBind : settings.keyBindsHotbar)
|
||||
{
|
||||
if (keyBind.isPressed())
|
||||
{
|
||||
field.set(keyBind, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int current = player.inventory.currentItem;
|
||||
|
||||
if (player.getEntityData().hasKey("carrySlot") ? player.getEntityData().getInteger("carrySlot") != current : false)
|
||||
{
|
||||
player.inventory.currentItem = player.getEntityData().getInteger("carrySlot");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Renders the Entity in First Person
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void renderHand(RenderHandEvent event)
|
||||
{
|
||||
World world = Minecraft.getMinecraft().world;
|
||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
World world = Minecraft.getInstance().world;
|
||||
EntityPlayer player = Minecraft.getInstance().player;
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
int perspective = Minecraft.getMinecraft().gameSettings.thirdPersonView;
|
||||
int perspective = Minecraft.getInstance().gameSettings.thirdPersonView;
|
||||
float partialticks = event.getPartialTicks();
|
||||
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))
|
||||
{
|
||||
if(Loader.isModLoaded("realrender") || Loader.isModLoaded("rfpr"))
|
||||
if(ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr"))
|
||||
return;
|
||||
|
||||
|
||||
|
|
@ -160,35 +62,35 @@ public class RenderEntityEvents
|
|||
entity.rotationYaw = 0.0f;
|
||||
entity.prevRotationYaw = 0.0f;
|
||||
entity.setRotationYawHead(0.0f);
|
||||
|
||||
|
||||
float height = entity.height;
|
||||
float width = entity.width;
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(.8, .8, .8);
|
||||
GlStateManager.rotate(180, 0, 1, 0);
|
||||
GlStateManager.translate(0.0, -height - .1, width + 0.1);
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.scaled(.8, .8, .8);
|
||||
GlStateManager.rotatef(180, 0, 1, 0);
|
||||
GlStateManager.translated(0.0, -height - .1, width + 0.1);
|
||||
GlStateManager.enableAlphaTest();
|
||||
|
||||
if (perspective == 0)
|
||||
{
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
Minecraft.getMinecraft().getRenderManager().setRenderShadow(false);
|
||||
Minecraft.getInstance().getRenderManager().setRenderShadow(false);
|
||||
|
||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||
if (carryOverride != null)
|
||||
{
|
||||
double[] translation = ScriptParseHelper.getXYZArray(carryOverride.getRenderTranslation());
|
||||
double[] rotation = ScriptParseHelper.getXYZArray(carryOverride.getRenderRotation());
|
||||
double[] scale = ScriptParseHelper.getScale(carryOverride.getRenderScale());
|
||||
double[] scaled = ScriptParseHelper.getscaled(carryOverride.getRenderscaled());
|
||||
String entityname = carryOverride.getRenderNameEntity();
|
||||
if (entityname != null)
|
||||
{
|
||||
Entity newEntity = EntityList.createEntityByIDFromName(new ResourceLocation(entityname), world);
|
||||
Entity newEntity = EntityType.create(world, new ResourceLocation(entityname));
|
||||
if (newEntity != null)
|
||||
{
|
||||
NBTTagCompound nbttag = carryOverride.getRenderNBT();
|
||||
if (nbttag != null)
|
||||
newEntity.readFromNBT(nbttag);
|
||||
newEntity.deserializeNBT(nbttag);
|
||||
entity = newEntity;
|
||||
entity.setPosition(d0, d1, d2);
|
||||
entity.rotationYaw = 0.0f;
|
||||
|
|
@ -197,27 +99,30 @@ public class RenderEntityEvents
|
|||
}
|
||||
}
|
||||
|
||||
GlStateManager.translate(translation[0], translation[1], translation[2]);
|
||||
GlStateManager.rotate((float) rotation[0], 1, 0, 0);
|
||||
GlStateManager.rotate((float) rotation[1], 0, 1, 0);
|
||||
GlStateManager.rotate((float) rotation[2], 0, 0, 1);
|
||||
GlStateManager.scale(scale[0], scale[1], scale[2]);
|
||||
GlStateManager.translated(translation[0], translation[1], translation[2]);
|
||||
GlStateManager.rotatef((float) rotation[0], 1, 0, 0);
|
||||
GlStateManager.rotatef((float) rotation[1], 0, 1, 0);
|
||||
GlStateManager.rotatef((float) rotation[2], 0, 0, 1);
|
||||
GlStateManager.scaled(scaled[0], scaled[1], scaled[2]);
|
||||
|
||||
}
|
||||
|
||||
if(entity instanceof EntityLiving)
|
||||
((EntityLiving) entity).hurtTime = 0;
|
||||
|
||||
this.renderEntityStatic(entity);
|
||||
Minecraft.getMinecraft().getRenderManager().setRenderShadow(true);
|
||||
Minecraft.getInstance().getRenderManager().setRenderShadow(true);
|
||||
}
|
||||
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.scale(1, 1, 1);
|
||||
GlStateManager.disableAlphaTest();
|
||||
GlStateManager.scaled(1, 1, 1);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.disableRescaleNormal();
|
||||
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GlStateManager.activeTexture(OpenGlHelper.GL_TEXTURE1);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
GlStateManager.activeTexture(OpenGlHelper.GL_TEXTURE0);
|
||||
|
||||
if (perspective == 0)
|
||||
{
|
||||
|
|
@ -227,7 +132,7 @@ public class RenderEntityEvents
|
|||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private void renderEntityStatic(Entity entity)
|
||||
{
|
||||
if (entity.ticksExisted == 0)
|
||||
|
|
@ -238,7 +143,7 @@ public class RenderEntityEvents
|
|||
}
|
||||
|
||||
float f = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw);
|
||||
int i = this.getBrightnessForRender(entity, Minecraft.getMinecraft().player);
|
||||
int i = this.getBrightnessForRender(entity, Minecraft.getInstance().player);
|
||||
|
||||
if (entity.isBurning())
|
||||
{
|
||||
|
|
@ -247,18 +152,19 @@ public class RenderEntityEvents
|
|||
|
||||
int j = i % 65536;
|
||||
int k = i / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j, k);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, j, k);
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
|
||||
this.setLightmapDisabled(false);
|
||||
|
||||
|
||||
|
||||
Minecraft.getMinecraft().getRenderManager().renderEntity(entity, 0.0D, 0.0D, 0.0D, f, 0.0F, true);
|
||||
Minecraft.getInstance().getRenderManager().renderEntity(entity, 0.0D, 0.0D, 0.0D, f, 0.0F, true);
|
||||
this.setLightmapDisabled(true);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private int getBrightnessForRender(Entity entity, EntityPlayer player)
|
||||
{
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor(player.posX), 0, MathHelper.floor(player.posZ));
|
||||
|
|
@ -274,10 +180,10 @@ public class RenderEntityEvents
|
|||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private void setLightmapDisabled(boolean disabled)
|
||||
{
|
||||
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GlStateManager.activeTexture(OpenGlHelper.GL_TEXTURE1);
|
||||
|
||||
if (disabled)
|
||||
{
|
||||
|
|
@ -288,20 +194,20 @@ public class RenderEntityEvents
|
|||
GlStateManager.enableTexture2D();
|
||||
}
|
||||
|
||||
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
GlStateManager.activeTexture(OpenGlHelper.GL_TEXTURE0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Renders the Entity in Third Person
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onPlayerRenderPost(RenderPlayerEvent.Post event)
|
||||
{
|
||||
World world = Minecraft.getMinecraft().world;
|
||||
World world = Minecraft.getInstance().world;
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
event.getRenderer().getMainModel();
|
||||
EntityPlayerSP clientPlayer = Minecraft.getMinecraft().player;
|
||||
EntityPlayerSP clientPlayer = Minecraft.getInstance().player;
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
float partialticks = event.getPartialRenderTick();
|
||||
|
||||
|
|
@ -310,7 +216,7 @@ public class RenderEntityEvents
|
|||
Entity entity = ItemEntity.getEntity(stack, world);
|
||||
float rotation = 0;
|
||||
|
||||
if (player.isRiding() && player.getRidingEntity() instanceof EntityLivingBase)
|
||||
if (player.getRidingEntity() != null && player.getRidingEntity() instanceof EntityLivingBase)
|
||||
rotation = -(player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialticks);
|
||||
else
|
||||
rotation = -(player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialticks);
|
||||
|
|
@ -339,36 +245,36 @@ public class RenderEntityEvents
|
|||
entity.setRotationYawHead(0.0f);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(xOffset, yOffset, zOffset);
|
||||
GlStateManager.scale((10 - multiplier) * 0.08, (10 - multiplier) * 0.08, (10 - multiplier) * 0.08);
|
||||
GlStateManager.rotate(rotation, 0, 1f, 0);
|
||||
GlStateManager.translate(0.0, height / 2 + -(height / 2) + 1, width - 0.1 < 0.7 ? width - 0.1 + (0.7 - (width - 0.1)) : width - 0.1);
|
||||
GlStateManager.translated(xOffset, yOffset, zOffset);
|
||||
GlStateManager.scaled((10 - multiplier) * 0.08, (10 - multiplier) * 0.08, (10 - multiplier) * 0.08);
|
||||
GlStateManager.rotatef(rotation, 0, 1f, 0);
|
||||
GlStateManager.translated(0.0, height / 2 + -(height / 2) + 1, width - 0.1 < 0.7 ? width - 0.1 + (0.7 - (width - 0.1)) : width - 0.1);
|
||||
|
||||
if((Loader.isModLoaded("realrender") || Loader.isModLoaded("rfpr")) && Minecraft.getMinecraft().gameSettings.thirdPersonView == 0)
|
||||
GlStateManager.translate(0, 0, -0.3);
|
||||
if((ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr")) && Minecraft.getInstance().gameSettings.thirdPersonView == 0)
|
||||
GlStateManager.translated(0, 0, -0.3);
|
||||
|
||||
if (player.isSneaking())
|
||||
{
|
||||
GlStateManager.translate(0, -0.3, 0);
|
||||
GlStateManager.translated(0, -0.3, 0);
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().getRenderManager().setRenderShadow(false);
|
||||
Minecraft.getInstance().getRenderManager().setRenderShadow(false);
|
||||
|
||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||
if (carryOverride != null)
|
||||
{
|
||||
double[] translation = ScriptParseHelper.getXYZArray(carryOverride.getRenderTranslation());
|
||||
double[] rot = ScriptParseHelper.getXYZArray(carryOverride.getRenderRotation());
|
||||
double[] scale = ScriptParseHelper.getScale(carryOverride.getRenderScale());
|
||||
double[] scaled = ScriptParseHelper.getscaled(carryOverride.getRenderscaled());
|
||||
String entityname = carryOverride.getRenderNameEntity();
|
||||
if (entityname != null)
|
||||
{
|
||||
Entity newEntity = EntityList.createEntityByIDFromName(new ResourceLocation(entityname), world);
|
||||
Entity newEntity = EntityType.create(world, new ResourceLocation(entityname));
|
||||
if (newEntity != null)
|
||||
{
|
||||
NBTTagCompound nbttag = carryOverride.getRenderNBT();
|
||||
if (nbttag != null)
|
||||
newEntity.readFromNBT(nbttag);
|
||||
newEntity.deserializeNBT(nbttag);
|
||||
entity = newEntity;
|
||||
entity.setPosition(c0, c1, c2);
|
||||
entity.rotationYaw = 0.0f;
|
||||
|
|
@ -377,18 +283,21 @@ public class RenderEntityEvents
|
|||
}
|
||||
}
|
||||
|
||||
GlStateManager.translate(translation[0], translation[1], translation[2]);
|
||||
GlStateManager.rotate((float) rot[0], 1, 0, 0);
|
||||
GlStateManager.rotate((float) rot[1], 0, 1, 0);
|
||||
GlStateManager.rotate((float) rot[2], 0, 0, 1);
|
||||
GlStateManager.scale(scale[0], scale[1], scale[2]);
|
||||
GlStateManager.translated(translation[0], translation[1], translation[2]);
|
||||
GlStateManager.rotatef((float) rot[0], 1, 0, 0);
|
||||
GlStateManager.rotatef((float) rot[1], 0, 1, 0);
|
||||
GlStateManager.rotatef((float) rot[2], 0, 0, 1);
|
||||
GlStateManager.scaled(scaled[0], scaled[1], scaled[2]);
|
||||
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().getRenderManager().renderEntityStatic(entity, 0.0f, false);
|
||||
Minecraft.getMinecraft().getRenderManager().setRenderShadow(true);
|
||||
if(entity instanceof EntityLiving)
|
||||
((EntityLiving) entity).hurtTime = 0;
|
||||
|
||||
Minecraft.getInstance().getRenderManager().renderEntityStatic(entity, 0.0f, false);
|
||||
Minecraft.getInstance().getRenderManager().setRenderShadow(true);
|
||||
|
||||
GlStateManager.scale(1, 1, 1);
|
||||
GlStateManager.scaled(1, 1, 1);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,22 @@
|
|||
package tschipp.carryon.client.event;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.GameSettings;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.model.ModelPlayer;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
import net.minecraft.client.renderer.entity.model.ModelPlayer;
|
||||
import net.minecraft.client.renderer.entity.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
|
@ -29,26 +27,31 @@ import net.minecraft.util.EnumHand;
|
|||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.util.text.event.ClickEvent.Action;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.client.event.RenderSpecificHandEvent;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import tschipp.carryon.common.config.Configs.Settings;
|
||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.helper.KeyboardCallbackWrapper.KeyPressedEvent;
|
||||
import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||
import tschipp.carryon.common.helper.ScrollCallbackWrapper.MouseScrolledEvent;
|
||||
import tschipp.carryon.common.helper.StringParser;
|
||||
import tschipp.carryon.common.item.ItemEntity;
|
||||
import tschipp.carryon.common.item.ItemTile;
|
||||
|
|
@ -58,36 +61,37 @@ import tschipp.carryon.network.server.SyncKeybindPacket;
|
|||
|
||||
public class RenderEvents
|
||||
{
|
||||
private static boolean initModels;
|
||||
|
||||
/*
|
||||
* Prevents the Player from scrolling
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onScroll(MouseEvent event)
|
||||
public void onScroll(MouseScrolledEvent event)
|
||||
{
|
||||
if (event.getDwheel() > 0 || event.getDwheel() < 0 || Minecraft.getMinecraft().gameSettings.keyBindPickBlock.isPressed())
|
||||
{
|
||||
ItemStack stack = Minecraft.getMinecraft().player.getHeldItemMainhand();
|
||||
EntityPlayer player = Minecraft.getInstance().player;
|
||||
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile)
|
||||
if (player != null)
|
||||
{
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
|
||||
if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
||||
{
|
||||
if (ItemTile.hasTileData(stack))
|
||||
if (ItemTile.hasTileData(stack) || ItemEntity.hasEntityData(stack))
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void onPlayerTick(PlayerTickEvent event) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
|
||||
{
|
||||
EntityPlayer player = event.player;
|
||||
|
||||
if (player != null && event.side == Side.CLIENT)
|
||||
if (player != null && event.side == LogicalSide.CLIENT)
|
||||
{
|
||||
boolean keyPressed = CarryOnKeybinds.carryKey.isKeyDown();
|
||||
boolean playerKeyPressed = CarryOnKeybinds.isKeyPressed(player);
|
||||
|
|
@ -96,8 +100,7 @@ public class RenderEvents
|
|||
{
|
||||
CarryOnKeybinds.setKeyPressed(player, true);
|
||||
CarryOn.network.sendToServer(new SyncKeybindPacket(true));
|
||||
}
|
||||
else if (!keyPressed && playerKeyPressed)
|
||||
} else if (!keyPressed && playerKeyPressed)
|
||||
{
|
||||
CarryOnKeybinds.setKeyPressed(player, false);
|
||||
CarryOn.network.sendToServer(new SyncKeybindPacket(false));
|
||||
|
|
@ -106,7 +109,7 @@ public class RenderEvents
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void onJoinWorld(EntityJoinWorldEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof EntityPlayer)
|
||||
|
|
@ -116,31 +119,40 @@ public class RenderEvents
|
|||
{
|
||||
CarryOnKeybinds.setKeyPressed(player, false);
|
||||
CarryOn.network.sendToServer(new SyncKeybindPacket(false));
|
||||
|
||||
if (CarryOn.FINGERPRINT_VIOLATED)
|
||||
{
|
||||
TextComponentString cf = new TextComponentString(TextFormatting.AQUA + "Curseforge" + TextFormatting.RED);
|
||||
cf.getStyle().setClickEvent(new ClickEvent(Action.OPEN_URL, "https://minecraft.curseforge.com/projects/carry-on"));
|
||||
|
||||
player.sendMessage(new TextComponentString(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 ").appendSibling(cf).appendText(TextFormatting.RED + " or through any kind of mod launcher, immediately delete the file and re-download it from ").appendSibling(cf));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Prevents the Player from opening Guis
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onGuiInit(InitGuiEvent.Pre event)
|
||||
{
|
||||
if (event.getGui() != null)
|
||||
{
|
||||
boolean inventory = event.getGui() instanceof GuiContainer;
|
||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
EntityPlayer player = Minecraft.getInstance().player;
|
||||
|
||||
if (player != null && inventory)
|
||||
{
|
||||
ItemStack stack = player.getHeldItem(EnumHand.MAIN_HAND);
|
||||
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack))
|
||||
if (!stack.isEmpty() && ((stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack)) || (stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))))
|
||||
{
|
||||
Minecraft.getMinecraft().player.closeScreen();
|
||||
Minecraft.getMinecraft().currentScreen = null;
|
||||
Minecraft.getMinecraft().setIngameFocus();
|
||||
Minecraft.getInstance().player.closeScreen();
|
||||
Minecraft.getInstance().currentScreen = null;
|
||||
Minecraft.getInstance().mouseHelper.grabMouse();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -151,60 +163,67 @@ public class RenderEvents
|
|||
/*
|
||||
* Prevents the Player from switching Slots
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void inputEvent(InputEvent event) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException
|
||||
public void inputEvent(KeyPressedEvent event) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
GameSettings settings = Minecraft.getMinecraft().gameSettings;
|
||||
Field field = KeyBinding.class.getDeclaredFields()[8];
|
||||
field.setAccessible(true);
|
||||
ItemStack stack = Minecraft.getMinecraft().player.getHeldItemMainhand();
|
||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
GameSettings settings = Minecraft.getInstance().gameSettings;
|
||||
int key = event.key;
|
||||
int scancode = event.scancode;
|
||||
EntityPlayer player = Minecraft.getInstance().player;
|
||||
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack))
|
||||
if (player != null)
|
||||
{
|
||||
if (settings.keyBindDrop.isPressed())
|
||||
ItemStack stack = Minecraft.getInstance().player.getHeldItemMainhand();
|
||||
|
||||
if (!stack.isEmpty() && ((stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack)) || (stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))))
|
||||
{
|
||||
field.set(settings.keyBindDrop, false);
|
||||
}
|
||||
if (settings.keyBindSwapHands.isPressed())
|
||||
{
|
||||
field.set(settings.keyBindSwapHands, false);
|
||||
}
|
||||
for (KeyBinding keyBind : settings.keyBindsHotbar)
|
||||
{
|
||||
if (keyBind.isPressed())
|
||||
if (settings.keyBindDrop.matchesKey(key, scancode))
|
||||
{
|
||||
field.set(keyBind, false);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
if (settings.keyBindSwapHands.matchesKey(key, scancode))
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
if (settings.keyBindPickBlock.matchesKey(key, scancode))
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
for (KeyBinding keyBind : settings.keyBindsHotbar)
|
||||
{
|
||||
if (keyBind.matchesKey(key, scancode))
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int current = player.inventory.currentItem;
|
||||
int current = player.inventory.currentItem;
|
||||
|
||||
if (player.getEntityData().hasKey("carrySlot") ? player.getEntityData().getInteger("carrySlot") != current : false)
|
||||
{
|
||||
player.inventory.currentItem = player.getEntityData().getInteger("carrySlot");
|
||||
if (player.getEntityData().hasKey("carrySlot") ? player.getEntityData().getInt("carrySlot") != current : false)
|
||||
{
|
||||
player.inventory.currentItem = player.getEntityData().getInt("carrySlot");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Renders the Block in First Person
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void renderHand(RenderHandEvent event)
|
||||
{
|
||||
World world = Minecraft.getMinecraft().world;
|
||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
AbstractClientPlayer aplayer = (AbstractClientPlayer) player;
|
||||
World world = Minecraft.getInstance().world;
|
||||
EntityPlayer player = Minecraft.getInstance().player;
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
int perspective = Minecraft.getMinecraft().gameSettings.thirdPersonView;
|
||||
boolean f1 = Minecraft.getMinecraft().gameSettings.hideGUI;
|
||||
int perspective = Minecraft.getInstance().gameSettings.thirdPersonView;
|
||||
boolean f1 = Minecraft.getInstance().gameSettings.hideGUI;
|
||||
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack) && perspective == 0 && !f1)
|
||||
{
|
||||
if (Loader.isModLoaded("realrender") || Loader.isModLoaded("rfpr"))
|
||||
if (ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr"))
|
||||
return;
|
||||
|
||||
Block block = ItemTile.getBlock(stack);
|
||||
|
|
@ -213,52 +232,51 @@ public class RenderEvents
|
|||
ItemStack tileStack = ItemTile.getItemStack(stack);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(2.5, 2.5, 2.5);
|
||||
GlStateManager.translate(0, -0.6, -1);
|
||||
GlStateManager.scaled(2.5, 2.5, 2.5);
|
||||
GlStateManager.translated(0, -0.6, -1);
|
||||
GlStateManager.enableBlend();
|
||||
|
||||
if (CarryOnConfig.settings.facePlayer ? !isChest(block) : isChest(block))
|
||||
if (Settings.facePlayer.get() ? !isChest(block) : isChest(block))
|
||||
{
|
||||
GlStateManager.rotate(180, 0, 1f, 0);
|
||||
GlStateManager.rotate(-8, 1f, 0, 0);
|
||||
}
|
||||
else
|
||||
GlStateManager.rotatef(180, 0, 1f, 0);
|
||||
GlStateManager.rotatef(-8, 1f, 0, 0);
|
||||
} else
|
||||
{
|
||||
GlStateManager.rotate(8, 1f, 0, 0);
|
||||
GlStateManager.rotatef(8, 1f, 0, 0);
|
||||
}
|
||||
|
||||
IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(tileStack, world, player);
|
||||
IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : (tileStack.isEmpty() ? Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(state) : Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(tileStack, world, player));
|
||||
|
||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||
if (carryOverride != null)
|
||||
{
|
||||
double[] translation = ScriptParseHelper.getXYZArray(carryOverride.getRenderTranslation());
|
||||
double[] rotation = ScriptParseHelper.getXYZArray(carryOverride.getRenderRotation());
|
||||
double[] scale = ScriptParseHelper.getScale(carryOverride.getRenderScale());
|
||||
double[] scaled = ScriptParseHelper.getscaled(carryOverride.getRenderscaled());
|
||||
Block b = StringParser.getBlock(carryOverride.getRenderNameBlock());
|
||||
if (b != null)
|
||||
{
|
||||
ItemStack s = new ItemStack(b, 1, carryOverride.getRenderMeta());
|
||||
s.setTagCompound(carryOverride.getRenderNBT());
|
||||
model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(s, world, player);
|
||||
ItemStack s = new ItemStack(b, 1);
|
||||
s.setTag(carryOverride.getRenderNBT());
|
||||
model = Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(s, world, player);
|
||||
}
|
||||
|
||||
GlStateManager.translate(translation[0], translation[1], translation[2]);
|
||||
GlStateManager.rotate((float) rotation[0], 1, 0, 0);
|
||||
GlStateManager.rotate((float) rotation[1], 0, 1, 0);
|
||||
GlStateManager.rotate((float) rotation[2], 0, 0, 1);
|
||||
GlStateManager.scale(scale[0], scale[1], scale[2]);
|
||||
GlStateManager.translated(translation[0], translation[1], translation[2]);
|
||||
GlStateManager.rotatef((float) rotation[0], 1, 0, 0);
|
||||
GlStateManager.rotatef((float) rotation[1], 0, 1, 0);
|
||||
GlStateManager.rotatef((float) rotation[2], 0, 0, 1);
|
||||
GlStateManager.scaled(scaled[0], scaled[1], scaled[2]);
|
||||
|
||||
}
|
||||
|
||||
int i = this.getBrightnessForRender(Minecraft.getMinecraft().player);
|
||||
int i = this.getBrightnessForRender(Minecraft.getInstance().player);
|
||||
int j = i % 65536;
|
||||
int k = i / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j, k);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, j, k);
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.setLightmapDisabled(false);
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
|
||||
if (ModelOverridesHandler.hasCustomOverrideModel(state, tag))
|
||||
{
|
||||
|
|
@ -267,16 +285,14 @@ public class RenderEvents
|
|||
if (override instanceof ItemStack)
|
||||
{
|
||||
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem((ItemStack) override, model);
|
||||
}
|
||||
else
|
||||
Minecraft.getInstance().getItemRenderer().renderItem((ItemStack) override, model);
|
||||
} else
|
||||
{
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem(tileStack.isEmpty() ? stack : tileStack, model);
|
||||
Minecraft.getInstance().getItemRenderer().renderItem(tileStack.isEmpty() ? stack : tileStack, model);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem(tileStack.isEmpty() ? stack : tileStack, model);
|
||||
Minecraft.getInstance().getItemRenderer().renderItem(tileStack.isEmpty() ? stack : tileStack, model);
|
||||
}
|
||||
|
||||
this.setLightmapDisabled(true);
|
||||
|
|
@ -287,13 +303,13 @@ public class RenderEvents
|
|||
}
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.scale(1, 1, 1);
|
||||
GlStateManager.scaled(1, 1, 1);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private int getBrightnessForRender(EntityPlayer player)
|
||||
{
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor(player.posX), 0, MathHelper.floor(player.posZ));
|
||||
|
|
@ -302,40 +318,38 @@ public class RenderEvents
|
|||
{
|
||||
blockpos$mutableblockpos.setY(MathHelper.floor(player.posY + player.getEyeHeight()));
|
||||
return player.world.getCombinedLight(blockpos$mutableblockpos, 0);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private void setLightmapDisabled(boolean disabled)
|
||||
{
|
||||
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GlStateManager.activeTexture(OpenGlHelper.GL_TEXTURE1);
|
||||
|
||||
if (disabled)
|
||||
{
|
||||
GlStateManager.disableTexture2D();
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
GlStateManager.enableTexture2D();
|
||||
}
|
||||
|
||||
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
GlStateManager.activeTexture(OpenGlHelper.GL_TEXTURE0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Renders the Block in Third Person
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onPlayerRenderPost(RenderPlayerEvent.Post event)
|
||||
{
|
||||
World world = Minecraft.getMinecraft().world;
|
||||
World world = Minecraft.getInstance().world;
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
EntityPlayerSP clientPlayer = Minecraft.getMinecraft().player;
|
||||
EntityPlayerSP clientPlayer = Minecraft.getInstance().player;
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
float partialticks = event.getPartialRenderTick();
|
||||
|
||||
|
|
@ -348,7 +362,7 @@ public class RenderEvents
|
|||
|
||||
float rotation = 0f;
|
||||
|
||||
if (player.isRiding() && player.getRidingEntity() instanceof EntityLivingBase)
|
||||
if (player.getRidingEntity() != null && player.getRidingEntity() instanceof EntityLivingBase)
|
||||
rotation = -(player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialticks);
|
||||
else
|
||||
rotation = -(player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialticks);
|
||||
|
|
@ -366,55 +380,54 @@ public class RenderEvents
|
|||
double zOffset = d2 - c2;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(xOffset, yOffset, zOffset);
|
||||
GlStateManager.scale(0.6, 0.6, 0.6);
|
||||
GlStateManager.translated(xOffset, yOffset, zOffset);
|
||||
GlStateManager.scaled(0.6, 0.6, 0.6);
|
||||
GlStateManager.enableBlend();
|
||||
|
||||
if (CarryOnConfig.settings.facePlayer ? !isChest(block) : isChest(block))
|
||||
if (Settings.facePlayer.get() ? !isChest(block) : isChest(block))
|
||||
{
|
||||
GlStateManager.rotate(rotation, 0, 1.0f, 0);
|
||||
GlStateManager.translate(0, 1.6, 0.65);
|
||||
if ((Loader.isModLoaded("realrender") || Loader.isModLoaded("rfpr")) && Minecraft.getMinecraft().gameSettings.thirdPersonView == 0)
|
||||
GlStateManager.translate(0, 0, -0.4);
|
||||
}
|
||||
else
|
||||
GlStateManager.rotatef(rotation, 0, 1.0f, 0);
|
||||
GlStateManager.translated(0, 1.6, 0.65);
|
||||
if ((ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr")) && Minecraft.getInstance().gameSettings.thirdPersonView == 0)
|
||||
GlStateManager.translated(0, 0, -0.4);
|
||||
} else
|
||||
{
|
||||
GlStateManager.rotate(rotation + 180, 0, 1.0f, 0);
|
||||
GlStateManager.translate(0, 1.6, -0.65);
|
||||
if ((Loader.isModLoaded("realrender") || Loader.isModLoaded("rfpr")) && Minecraft.getMinecraft().gameSettings.thirdPersonView == 0)
|
||||
GlStateManager.translate(0, 0, 0.4);
|
||||
GlStateManager.rotatef(rotation + 180, 0, 1.0f, 0);
|
||||
GlStateManager.translated(0, 1.6, -0.65);
|
||||
if ((ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr")) && Minecraft.getInstance().gameSettings.thirdPersonView == 0)
|
||||
GlStateManager.translated(0, 0, 0.4);
|
||||
}
|
||||
|
||||
if (player.isSneaking())
|
||||
{
|
||||
GlStateManager.translate(0, -0.3, 0);
|
||||
GlStateManager.translated(0, -0.3, 0);
|
||||
}
|
||||
|
||||
IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(tileItem, world, player);
|
||||
IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : (tileItem.isEmpty() ? Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(state) : Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(tileItem, world, player));
|
||||
|
||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||
if (carryOverride != null)
|
||||
{
|
||||
double[] translation = ScriptParseHelper.getXYZArray(carryOverride.getRenderTranslation());
|
||||
double[] rot = ScriptParseHelper.getXYZArray(carryOverride.getRenderRotation());
|
||||
double[] scale = ScriptParseHelper.getScale(carryOverride.getRenderScale());
|
||||
double[] scaled = ScriptParseHelper.getscaled(carryOverride.getRenderscaled());
|
||||
Block b = StringParser.getBlock(carryOverride.getRenderNameBlock());
|
||||
if (b != null)
|
||||
{
|
||||
ItemStack s = new ItemStack(b, 1, carryOverride.getRenderMeta());
|
||||
s.setTagCompound(carryOverride.getRenderNBT());
|
||||
model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(s, world, player);
|
||||
ItemStack s = new ItemStack(b, 1);
|
||||
s.setTag(carryOverride.getRenderNBT());
|
||||
model = Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(s, world, player);
|
||||
}
|
||||
|
||||
GlStateManager.translate(translation[0], translation[1], translation[2]);
|
||||
GlStateManager.rotate((float) rot[0], 1, 0, 0);
|
||||
GlStateManager.rotate((float) rot[1], 0, 1, 0);
|
||||
GlStateManager.rotate((float) rot[2], 0, 0, 1);
|
||||
GlStateManager.scale(scale[0], scale[1], scale[2]);
|
||||
GlStateManager.translated(translation[0], translation[1], translation[2]);
|
||||
GlStateManager.rotatef((float) rot[0], 1, 0, 0);
|
||||
GlStateManager.rotatef((float) rot[1], 0, 1, 0);
|
||||
GlStateManager.rotatef((float) rot[2], 0, 0, 1);
|
||||
GlStateManager.scaled(scaled[0], scaled[1], scaled[2]);
|
||||
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
|
||||
if (ModelOverridesHandler.hasCustomOverrideModel(state, tag))
|
||||
{
|
||||
|
|
@ -422,20 +435,18 @@ public class RenderEvents
|
|||
|
||||
if (override instanceof ItemStack)
|
||||
{
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem((ItemStack) override, model);
|
||||
}
|
||||
else
|
||||
Minecraft.getInstance().getItemRenderer().renderItem((ItemStack) override, model);
|
||||
} else
|
||||
{
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem(tileItem.isEmpty() ? stack : tileItem, model);
|
||||
Minecraft.getInstance().getItemRenderer().renderItem(tileItem.isEmpty() ? stack : tileItem, model);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem(tileItem.isEmpty() ? stack : tileItem, model);
|
||||
Minecraft.getInstance().getItemRenderer().renderItem(tileItem.isEmpty() ? stack : tileItem, model);
|
||||
}
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.scale(1, 1, 1);
|
||||
GlStateManager.scaled(1, 1, 1);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
|
@ -443,28 +454,26 @@ public class RenderEvents
|
|||
/*
|
||||
* Renders correct arm rotation
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public void onEvent(RenderPlayerEvent.Post event)
|
||||
{
|
||||
if(!CarryOnConfig.settings.renderArms)
|
||||
if (!Settings.renderArms.get())
|
||||
return;
|
||||
|
||||
if (handleMobends() && !Loader.isModLoaded("obfuscate"))
|
||||
|
||||
if (handleMobends() && !ModList.get().isLoaded("obfuscate"))
|
||||
{
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
EntityPlayerSP clientPlayer = Minecraft.getMinecraft().player;
|
||||
EntityPlayerSP clientPlayer = Minecraft.getInstance().player;
|
||||
float partialticks = event.getPartialRenderTick();
|
||||
|
||||
RenderPlayer render = event.getRenderer();
|
||||
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))
|
||||
{
|
||||
ModelPlayer model = event.getRenderer().getMainModel();
|
||||
float rotation = 0;
|
||||
|
||||
if (player.isRiding() && player.getRidingEntity() instanceof EntityLivingBase)
|
||||
if (player.getRidingEntity() != null && player.getRidingEntity() instanceof EntityLivingBase)
|
||||
rotation = (player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialticks);
|
||||
else
|
||||
rotation = (player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialticks);
|
||||
|
|
@ -485,9 +494,9 @@ public class RenderEvents
|
|||
double zOffset = d2 - c2;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(xOffset, yOffset, zOffset);
|
||||
GlStateManager.translated(xOffset, yOffset, zOffset);
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(skinLoc);
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(skinLoc);
|
||||
|
||||
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
||||
if (overrider != null)
|
||||
|
|
@ -506,8 +515,7 @@ public class RenderEvents
|
|||
{
|
||||
renderArmPost(model.bipedLeftArm, (float) rotLeft[0], (float) rotLeft[2], rotation, false, player.isSneaking());
|
||||
renderArmPost(model.bipedLeftArmwear, (float) rotLeft[0], (float) rotLeft[2], rotation, false, player.isSneaking());
|
||||
}
|
||||
else if (renderLeft)
|
||||
} else if (renderLeft)
|
||||
{
|
||||
renderArmPost(model.bipedLeftArm, 2.0F + (player.isSneaking() ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation, false, player.isSneaking());
|
||||
renderArmPost(model.bipedLeftArmwear, 2.0F + (player.isSneaking() ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation, false, player.isSneaking());
|
||||
|
|
@ -517,15 +525,13 @@ public class RenderEvents
|
|||
{
|
||||
renderArmPost(model.bipedRightArm, (float) rotRight[0], (float) rotRight[2], rotation, true, player.isSneaking());
|
||||
renderArmPost(model.bipedRightArmwear, (float) rotRight[0], (float) rotRight[2], rotation, true, player.isSneaking());
|
||||
}
|
||||
else if (renderRight)
|
||||
} else if (renderRight)
|
||||
{
|
||||
renderArmPost(model.bipedRightArm, 2.0F + (player.isSneaking() ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation, true, player.isSneaking());
|
||||
renderArmPost(model.bipedRightArmwear, 2.0F + (player.isSneaking() ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation, true, player.isSneaking());
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
renderArmPost(model.bipedRightArm, 2.0F + (player.isSneaking() ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation, true, player.isSneaking());
|
||||
renderArmPost(model.bipedLeftArm, 2.0F + (player.isSneaking() ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation, false, player.isSneaking());
|
||||
|
|
@ -540,21 +546,21 @@ public class RenderEvents
|
|||
/*
|
||||
* Hides the vanilla arm for rendering the rotation
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent(priority = EventPriority.NORMAL)
|
||||
public void onEvent(RenderPlayerEvent.Pre event)
|
||||
{
|
||||
if(!CarryOnConfig.settings.renderArms)
|
||||
if (!Settings.renderArms.get())
|
||||
return;
|
||||
|
||||
if (handleMobends() && !Loader.isModLoaded("obfuscate"))
|
||||
|
||||
if (handleMobends() && !ModList.get().isLoaded("obfuscate"))
|
||||
{
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))
|
||||
{
|
||||
ModelPlayer model = event.getRenderer().getMainModel();
|
||||
|
||||
|
||||
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
||||
if (overrider != null)
|
||||
{
|
||||
|
|
@ -565,8 +571,7 @@ public class RenderEvents
|
|||
{
|
||||
renderArmPre(model.bipedRightArm);
|
||||
renderArmPre(model.bipedRightArmwear);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (renderLeft)
|
||||
|
|
@ -574,8 +579,7 @@ public class RenderEvents
|
|||
renderArmPre(model.bipedLeftArm);
|
||||
renderArmPre(model.bipedLeftArmwear);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
renderArmPre(model.bipedRightArm);
|
||||
renderArmPre(model.bipedLeftArm);
|
||||
|
|
@ -586,7 +590,7 @@ public class RenderEvents
|
|||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void renderArmPost(ModelRenderer arm, float x, float z, float rotation, boolean right, boolean sneaking)
|
||||
{
|
||||
arm.isHidden = false;
|
||||
|
|
@ -594,8 +598,7 @@ public class RenderEvents
|
|||
{
|
||||
arm.rotationPointZ = -MathHelper.sin((float) Math.toRadians(rotation)) * 4.75F;
|
||||
arm.rotationPointX = -MathHelper.cos((float) Math.toRadians(rotation)) * 4.75F;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
arm.rotationPointZ = MathHelper.sin((float) Math.toRadians(rotation)) * 4.75F;
|
||||
arm.rotationPointX = MathHelper.cos((float) Math.toRadians(rotation)) * 4.75F;
|
||||
|
|
@ -613,7 +616,7 @@ public class RenderEvents
|
|||
arm.rotationPointY = 2;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void renderArmPre(ModelRenderer arm)
|
||||
{
|
||||
arm.isHidden = true;
|
||||
|
|
@ -621,13 +624,17 @@ public class RenderEvents
|
|||
|
||||
public boolean handleMobends()
|
||||
{
|
||||
if (Loader.isModLoaded("mobends"))
|
||||
{
|
||||
Configuration config = new Configuration(new File(CarryOn.CONFIGURATION_FILE.getPath().substring(0, CarryOn.CONFIGURATION_FILE.getPath().length() - 16), "mobends.cfg"));
|
||||
|
||||
boolean renderPlayer = config.get("animated", "player", true).getBoolean();
|
||||
return !renderPlayer;
|
||||
}
|
||||
// TODO MOBENDS
|
||||
// if (ModList.get().isLoaded("mobends"))
|
||||
// {
|
||||
// Configuration config = new Configuration(new
|
||||
// File(CarryOn.CONFIGURATION_FILE.getPath().substring(0,
|
||||
// CarryOn.CONFIGURATION_FILE.getPath().length() - 16), "mobends.cfg"));
|
||||
//
|
||||
// boolean renderPlayer = config.get("animated", "player",
|
||||
// true).getBoolean();
|
||||
// return !renderPlayer;
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -636,30 +643,29 @@ public class RenderEvents
|
|||
return block == Blocks.CHEST || block == Blocks.ENDER_CHEST || block == Blocks.TRAPPED_CHEST;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static RenderPlayer getRenderPlayer(AbstractClientPlayer player)
|
||||
{
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
RenderManager manager = mc.getRenderManager();
|
||||
return manager.getSkinMap().get(player.getSkinType());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static ModelPlayer getPlayerModel(AbstractClientPlayer player)
|
||||
{
|
||||
return getRenderPlayer(player).getMainModel();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void hideItems(RenderPlayerEvent.Specials.Pre event)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void hideItems(RenderSpecificHandEvent event)
|
||||
{
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
ItemStack stack = event.getItemStack();
|
||||
|
||||
if (stack != null && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
||||
{
|
||||
event.setRenderItem(false);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,48 +1,48 @@
|
|||
package tschipp.carryon.client.gui;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
import net.minecraftforge.common.config.ConfigElement;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.fml.client.config.GuiConfig;
|
||||
import net.minecraftforge.fml.client.config.IConfigElement;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
|
||||
public class GuiConfigCarryOn extends GuiConfig
|
||||
{
|
||||
private static final String LANG_PREFIX = CarryOn.MODID + ".category.";
|
||||
|
||||
public GuiConfigCarryOn(GuiScreen parent) {
|
||||
super(parent, getConfigElements(), CarryOn.MODID, false, false, "Carry On Configuration");
|
||||
}
|
||||
|
||||
private static List<IConfigElement> getConfigElements() {
|
||||
|
||||
final Configuration configuration = CarryOnConfig.EventHandler.getConfiguration();
|
||||
|
||||
final ConfigCategory topLevelCategory = configuration.getCategory(Configuration.CATEGORY_GENERAL);
|
||||
topLevelCategory.getChildren()
|
||||
.forEach(configCategory -> configCategory.setLanguageKey(GuiConfigCarryOn.LANG_PREFIX + configCategory.getName()));
|
||||
|
||||
return new ConfigElement(topLevelCategory).getChildElements();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
super.actionPerformed(button);
|
||||
}
|
||||
}
|
||||
//package tschipp.carryon.client.gui;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//import net.minecraft.client.gui.GuiButton;
|
||||
//import net.minecraft.client.gui.GuiScreen;
|
||||
//import net.minecraftforge.common.config.ConfigCategory;
|
||||
//import net.minecraftforge.common.config.ConfigElement;
|
||||
//import net.minecraftforge.common.config.Configuration;
|
||||
//import net.minecraftforge.fml.client.config.GuiConfig;
|
||||
//import net.minecraftforge.fml.client.config.IConfigElement;
|
||||
//import tschipp.carryon.CarryOn;
|
||||
//import tschipp.carryon.common.config.CarryOnConfig;
|
||||
//
|
||||
//public class GuiConfigCarryOn extends GuiConfig
|
||||
//{
|
||||
// private static final String LANG_PREFIX = CarryOn.MODID + ".category.";
|
||||
//
|
||||
// public GuiConfigCarryOn(GuiScreen parent) {
|
||||
// super(parent, getConfigElements(), CarryOn.MODID, false, false, "Carry On Configuration");
|
||||
// }
|
||||
//
|
||||
// private static List<IConfigElement> getConfigElements() {
|
||||
//
|
||||
// final Configuration configuration = CarryOnConfig.EventHandler.getConfiguration.get()();
|
||||
//
|
||||
// final ConfigCategory topLevelCategory = configuration.getCategory(Configuration.CATEGORY_GENERAL);
|
||||
// topLevelCategory.getChildren()
|
||||
// .forEach(configCategory -> configCategory.setLanguageKey(GuiConfigCarryOn.LANG_PREFIX + configCategory.getName()));
|
||||
//
|
||||
// return new ConfigElement(topLevelCategory).getChildElements();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void initGui() {
|
||||
// super.initGui();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
// super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void actionPerformed(GuiButton button) {
|
||||
// super.actionPerformed(button);
|
||||
// }
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -1,49 +1,49 @@
|
|||
package tschipp.carryon.client.gui;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.client.IModGuiFactory;
|
||||
|
||||
public class GuiFactoryCarryOn implements IModGuiFactory
|
||||
{
|
||||
@Override
|
||||
public void initialize(Minecraft minecraftInstance) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public Class<? extends GuiScreen> mainConfigGuiClass() {
|
||||
return GuiConfigCarryOn.class;
|
||||
} */
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
|
||||
return null;
|
||||
} */
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasConfigGui()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiScreen createConfigGui(GuiScreen parentScreen)
|
||||
{
|
||||
|
||||
return new GuiConfigCarryOn(parentScreen);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
//package tschipp.carryon.client.gui;
|
||||
//
|
||||
//import java.util.Set;
|
||||
//
|
||||
//import net.minecraft.client.Minecraft;
|
||||
//import net.minecraft.client.gui.GuiScreen;
|
||||
//import net.minecraftforge.fml.client.IModGuiFactory;
|
||||
//
|
||||
//public class GuiFactoryCarryOn implements IModGuiFactory
|
||||
//{
|
||||
// @Override
|
||||
// public void initialize(Minecraft minecraftInstance) {
|
||||
// // Do nothing
|
||||
// }
|
||||
//
|
||||
// /*
|
||||
// @Override
|
||||
// public Class<? extends GuiScreen> mainConfigGuiClass() {
|
||||
// return GuiConfigCarryOn.class;
|
||||
// } */
|
||||
//
|
||||
// @Override
|
||||
// public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// /*
|
||||
// @Override
|
||||
// public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
|
||||
// return null;
|
||||
// } */
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public boolean hasConfigGui()
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public GuiScreen createConfigGui(GuiScreen parentScreen)
|
||||
// {
|
||||
//
|
||||
// return new GuiConfigCarryOn(parentScreen);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
|
@ -1,13 +1,11 @@
|
|||
package tschipp.carryon.client.keybinds;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CarryOnKeybinds
|
||||
{
|
||||
|
|
@ -15,10 +13,10 @@ public class CarryOnKeybinds
|
|||
public static final String KEYBIND_KEY = "carryOnKeyPressed";
|
||||
public static KeyBinding carryKey;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void init()
|
||||
{
|
||||
carryKey = new KeyBinding("key.carry.desc", Keyboard.KEY_LSHIFT, "key.carry.category");
|
||||
carryKey = new KeyBinding("key.carry.desc", 340, "key.carry.category");
|
||||
|
||||
ClientRegistry.registerKeyBinding(carryKey);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
package tschipp.carryon.common;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import com.google.gson.JsonIOException;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.scripting.ScriptReader;
|
||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
||||
import tschipp.carryon.network.client.CarrySlotPacketHandler;
|
||||
import tschipp.carryon.network.client.ScriptReloadPacket;
|
||||
import tschipp.carryon.network.client.ScriptReloadPacketHandler;
|
||||
import tschipp.carryon.network.server.SyncKeybindPacket;
|
||||
import tschipp.carryon.network.server.SyncKeybindPacketHandler;
|
||||
|
||||
public class CommonProxy
|
||||
{
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
ScriptReader.preInit(event);
|
||||
|
||||
CarryOn.network = NetworkRegistry.INSTANCE.newSimpleChannel("CarryOn");
|
||||
|
||||
CarryOn.network.registerMessage(SyncKeybindPacketHandler.class, SyncKeybindPacket.class, 0, Side.SERVER);
|
||||
CarryOn.network.registerMessage(CarrySlotPacketHandler.class, CarrySlotPacket.class, 1, Side.CLIENT);
|
||||
CarryOn.network.registerMessage(ScriptReloadPacketHandler.class, ScriptReloadPacket.class, 2, Side.CLIENT);
|
||||
|
||||
RegistrationHandler.regItems();
|
||||
RegistrationHandler.regCommonEvents();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ScriptReader.parseScripts();
|
||||
}
|
||||
catch (JsonIOException | JsonSyntaxException | FileNotFoundException | NBTException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
RegistrationHandler.regOverrideList();
|
||||
RegistrationHandler.regCaps();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent e)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,37 +1,36 @@
|
|||
package tschipp.carryon.common.capabilities;
|
||||
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
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 {
|
||||
public class PositionProvider implements ICapabilitySerializable<NBTTagCompound> {
|
||||
|
||||
@CapabilityInject(IPosition.class)
|
||||
public static final Capability<IPosition> POSITION_CAPABILITY = null;
|
||||
|
||||
private IPosition instance = POSITION_CAPABILITY.getDefaultInstance();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> cap, EnumFacing side)
|
||||
{
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> {return new TEPosition();});
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound serializeNBT()
|
||||
{
|
||||
return (NBTTagCompound) POSITION_CAPABILITY.getStorage().writeNBT(POSITION_CAPABILITY, instance, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(NBTTagCompound nbt)
|
||||
{
|
||||
POSITION_CAPABILITY.getStorage().readNBT(POSITION_CAPABILITY, instance, null, nbt);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
return capability == POSITION_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
return capability == POSITION_CAPABILITY ? POSITION_CAPABILITY.cast(instance) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTBase serializeNBT() {
|
||||
return POSITION_CAPABILITY.getStorage().writeNBT(POSITION_CAPABILITY, instance, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(NBTBase nbt) {
|
||||
POSITION_CAPABILITY.getStorage().readNBT(POSITION_CAPABILITY, instance, null, nbt);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package tschipp.carryon.common.capabilities;
|
||||
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.INBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
|
@ -10,27 +10,27 @@ import net.minecraftforge.common.capabilities.Capability.IStorage;
|
|||
public class PositionStorage implements IStorage<IPosition> {
|
||||
|
||||
@Override
|
||||
public NBTBase writeNBT(Capability<IPosition> capability, IPosition instance, EnumFacing side) {
|
||||
public INBTBase writeNBT(Capability<IPosition> capability, IPosition instance, EnumFacing side) {
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
|
||||
tag.setBoolean("blockActivated", instance.isBlockActivated());
|
||||
tag.setInteger("x", instance.getPos().getX());
|
||||
tag.setInteger("y", instance.getPos().getY());
|
||||
tag.setInteger("z", instance.getPos().getZ());
|
||||
tag.setInt("x", instance.getPos().getX());
|
||||
tag.setInt("y", instance.getPos().getY());
|
||||
tag.setInt("z", instance.getPos().getZ());
|
||||
|
||||
return tag;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(Capability<IPosition> capability, IPosition instance, EnumFacing side, NBTBase nbt) {
|
||||
public void readNBT(Capability<IPosition> capability, IPosition instance, EnumFacing side, INBTBase nbt) {
|
||||
|
||||
NBTTagCompound tag = (NBTTagCompound) nbt;
|
||||
|
||||
int x = tag.getInteger("x");
|
||||
int y = tag.getInteger("y");
|
||||
int z = tag.getInteger("z");
|
||||
int x = tag.getInt("x");
|
||||
int y = tag.getInt("y");
|
||||
int z = tag.getInt("z");
|
||||
|
||||
BlockPos pos = new BlockPos(x,y,z);
|
||||
|
||||
|
|
@ -38,4 +38,6 @@ public class PositionStorage implements IStorage<IPosition> {
|
|||
instance.setBlockActivated(tag.getBoolean("blockActivated"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,5 @@ public class TEPosition implements IPosition {
|
|||
this.blockActivated = b;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,32 +6,34 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerContainerEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import tschipp.carryon.common.capabilities.IPosition;
|
||||
import tschipp.carryon.common.capabilities.PositionProvider;
|
||||
import tschipp.carryon.common.capabilities.TEPosition;
|
||||
|
||||
public class PositionClientEvents
|
||||
{
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onGui(GuiScreenEvent.DrawScreenEvent event)
|
||||
{
|
||||
if (event.getGui() != null)
|
||||
{
|
||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
EntityPlayer player = Minecraft.getInstance().player;
|
||||
boolean inventory = event.getGui() instanceof GuiContainer;
|
||||
|
||||
if (player != null && inventory)
|
||||
{
|
||||
if(player.hasCapability(PositionProvider.POSITION_CAPABILITY, null))
|
||||
if(player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
||||
{
|
||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY, null);
|
||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
||||
if(cap.isBlockActivated())
|
||||
{
|
||||
World world = player.world;
|
||||
|
|
@ -42,8 +44,8 @@ public class PositionClientEvents
|
|||
if(te == null)
|
||||
{
|
||||
// player.openContainer = null;
|
||||
Minecraft.getMinecraft().currentScreen = null;
|
||||
Minecraft.getMinecraft().setIngameFocus();
|
||||
Minecraft.getInstance().currentScreen = null;
|
||||
// Minecraft.getInstance().fo;
|
||||
cap.setBlockActivated(false);
|
||||
cap.setPos(new BlockPos(0,0,0));
|
||||
}
|
||||
|
|
@ -54,31 +56,31 @@ public class PositionClientEvents
|
|||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onGuiClose(PlayerContainerEvent.Close event)
|
||||
{
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
if(player.hasCapability(PositionProvider.POSITION_CAPABILITY, null))
|
||||
if(player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
||||
{
|
||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY, null);
|
||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
||||
cap.setBlockActivated(false);
|
||||
cap.setPos(new BlockPos(0,0,0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onPlayerTick(PlayerTickEvent event)
|
||||
{
|
||||
if (event.side == Side.CLIENT)
|
||||
if (event.side == LogicalSide.CLIENT)
|
||||
{
|
||||
EntityPlayer player = event.player;
|
||||
if (player.hasCapability(PositionProvider.POSITION_CAPABILITY, null))
|
||||
if(player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
||||
{
|
||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY, null);
|
||||
if (cap.isBlockActivated() && Minecraft.getMinecraft().currentScreen == null)
|
||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
||||
if (cap.isBlockActivated() && Minecraft.getInstance().currentScreen == null)
|
||||
{
|
||||
cap.setBlockActivated(false);
|
||||
cap.setPos(new BlockPos(0, 0, 0));
|
||||
|
|
|
|||
|
|
@ -9,10 +9,11 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.capabilities.IPosition;
|
||||
import tschipp.carryon.common.capabilities.PositionProvider;
|
||||
import tschipp.carryon.common.capabilities.TEPosition;
|
||||
|
||||
public class PositionCommonEvents
|
||||
{
|
||||
|
|
@ -46,9 +47,9 @@ public class PositionCommonEvents
|
|||
TileEntity te = world.getTileEntity(pos);
|
||||
if (te != null)
|
||||
{
|
||||
if (player.hasCapability(PositionProvider.POSITION_CAPABILITY, null))
|
||||
if(player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
||||
{
|
||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY, null);
|
||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
||||
cap.setBlockActivated(true);
|
||||
cap.setPos(pos);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,21 @@
|
|||
package tschipp.carryon.common.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
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.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.config.Configs.Settings;
|
||||
import tschipp.carryon.common.handler.CustomPickupOverrideHandler;
|
||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
|
|
@ -24,171 +23,136 @@ import tschipp.carryon.common.item.ItemEntity;
|
|||
import tschipp.carryon.common.item.ItemTile;
|
||||
import tschipp.carryon.common.scripting.ScriptReader;
|
||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
||||
import tschipp.carryon.network.client.ScriptReloadPacket;
|
||||
|
||||
public class CommandCarryOn extends CommandBase implements ICommand
|
||||
public class CommandCarryOn
|
||||
{
|
||||
|
||||
private final List names;
|
||||
|
||||
public CommandCarryOn()
|
||||
public static void register(CommandDispatcher<CommandSource> dispatcher)
|
||||
{
|
||||
names = new ArrayList();
|
||||
names.add("carryon");
|
||||
LiteralArgumentBuilder<CommandSource> builder = Commands.literal("carryon")
|
||||
|
||||
.then(Commands.literal("debug").executes((cmd) -> {
|
||||
return handleDebug(cmd.getSource());
|
||||
}))
|
||||
|
||||
.then(Commands.literal("clear").executes((cmd) -> {
|
||||
return handleClear(cmd.getSource(), Collections.singleton(cmd.getSource().asPlayer()));
|
||||
}))
|
||||
|
||||
.then(Commands.literal("clear").then(Commands.argument("target", EntityArgument.multiplePlayers()).requires(src -> src.hasPermissionLevel(2)).executes((cmd) -> {
|
||||
return handleClear(cmd.getSource(), EntityArgument.getPlayers(cmd, "target"));
|
||||
})))
|
||||
|
||||
.then(Commands.literal("reload").requires(src -> src.hasPermissionLevel(2)).executes((cmd) -> {
|
||||
return handleReload(cmd.getSource());
|
||||
}));
|
||||
|
||||
dispatcher.register(builder);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ICommand o)
|
||||
private static int handleDebug(CommandSource source)
|
||||
{
|
||||
return this.getName().compareTo(o.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "carryon";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage(ICommandSender sender)
|
||||
{
|
||||
|
||||
return "/carryon <mode>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases()
|
||||
{
|
||||
return this.names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
|
||||
{
|
||||
if (args.length > 0)
|
||||
try
|
||||
{
|
||||
// Handling clear
|
||||
if (args[0].toLowerCase().equals("clear"))
|
||||
if (source.assertIsEntity() != null)
|
||||
{
|
||||
if (sender instanceof EntityPlayer)
|
||||
EntityPlayerMP player = source.asPlayer();
|
||||
|
||||
ItemStack main = player.getHeldItemMainhand();
|
||||
if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemTile)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) sender;
|
||||
source.sendFeedback(new TextComponentString("Block: " + ItemTile.getBlock(main)), true);
|
||||
source.sendFeedback(new TextComponentString("BlockState: " + ItemTile.getBlockState(main)), true);
|
||||
source.sendFeedback(new TextComponentString("ItemStack: " + ItemTile.getItemStack(main)), true);
|
||||
|
||||
if (ModelOverridesHandler.hasCustomOverrideModel(ItemTile.getBlockState(main), ItemTile.getTileData(main)))
|
||||
source.sendFeedback(new TextComponentString("Override Model: " + ModelOverridesHandler.getOverrideObject(ItemTile.getBlockState(main), ItemTile.getTileData(main))), true);
|
||||
|
||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemTile.getBlockState(main)))
|
||||
source.sendFeedback(new TextComponentString("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemTile.getBlockState(main))), true);
|
||||
|
||||
CarryOn.LOGGER.info("Block: " + ItemTile.getBlock(main));
|
||||
CarryOn.LOGGER.info("BlockState: " + ItemTile.getBlockState(main));
|
||||
CarryOn.LOGGER.info("ItemStack: " + ItemTile.getItemStack(main));
|
||||
|
||||
if (ModelOverridesHandler.hasCustomOverrideModel(ItemTile.getBlockState(main), ItemTile.getTileData(main)))
|
||||
CarryOn.LOGGER.info("Override Model: " + ModelOverridesHandler.getOverrideObject(ItemTile.getBlockState(main), ItemTile.getTileData(main)));
|
||||
|
||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemTile.getBlockState(main)))
|
||||
CarryOn.LOGGER.info("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemTile.getBlockState(main)));
|
||||
|
||||
return 1;
|
||||
} else if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity)
|
||||
{
|
||||
source.sendFeedback(new TextComponentString("Entity: " + ItemEntity.getEntity(main, player.world)), true);
|
||||
source.sendFeedback(new TextComponentString("Entity Name: " + ItemEntity.getEntityName(main)), true);
|
||||
|
||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemEntity.getEntity(main, player.world)))
|
||||
source.sendFeedback(new TextComponentString("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemEntity.getEntity(main, player.world))), true);
|
||||
|
||||
CarryOn.LOGGER.info("Entity: " + ItemEntity.getEntity(main, player.world));
|
||||
CarryOn.LOGGER.info("Entity Name: " + ItemEntity.getEntityName(main));
|
||||
|
||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemEntity.getEntity(main, player.world)))
|
||||
CarryOn.LOGGER.info("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemEntity.getEntity(main, player.world)));
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (CommandSyntaxException e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int handleClear(CommandSource source, Collection<EntityPlayerMP> players)
|
||||
{
|
||||
for (EntityPlayerMP player : players)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (source.assertIsEntity() != null)
|
||||
{
|
||||
int cleared = 0;
|
||||
cleared += player.inventory.clearMatchingItems(RegistrationHandler.itemTile, 0, 64, null);
|
||||
cleared += player.inventory.clearMatchingItems(RegistrationHandler.itemEntity, 0, 64, null);
|
||||
cleared += player.inventory.clearMatchingItems(stack -> !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile, 64);
|
||||
cleared += player.inventory.clearMatchingItems(stack -> !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity, 64);
|
||||
|
||||
CarryOn.network.sendTo(new CarrySlotPacket(9, player.getEntityId()), (EntityPlayerMP) player);
|
||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (EntityPlayerMP) player), new CarrySlotPacket(9, player.getEntityId()));
|
||||
|
||||
if (cleared != 1)
|
||||
player.sendMessage(new TextComponentString("Cleared " + cleared + " Items!"));
|
||||
source.sendFeedback(new TextComponentString("Cleared " + cleared + " Items!"), true);
|
||||
else
|
||||
player.sendMessage(new TextComponentString("Cleared " + cleared + " Item!"));
|
||||
}
|
||||
source.sendFeedback(new TextComponentString("Cleared " + cleared + " Item!"), true);
|
||||
|
||||
}
|
||||
// Handling debug
|
||||
else if (args[0].toLowerCase().equals("debug"))
|
||||
return 1;
|
||||
} else
|
||||
throw EntityArgument.ONLY_PLAYERS_ALLOWED.create();
|
||||
|
||||
} catch (CommandSyntaxException e)
|
||||
{
|
||||
|
||||
if (sender instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) sender;
|
||||
ItemStack main = player.getHeldItemMainhand();
|
||||
if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemTile)
|
||||
{
|
||||
player.sendMessage(new TextComponentString("Block: " + ItemTile.getBlock(main)));
|
||||
player.sendMessage(new TextComponentString("BlockState: " + ItemTile.getBlockState(main)));
|
||||
player.sendMessage(new TextComponentString("Meta: " + ItemTile.getMeta(main)));
|
||||
player.sendMessage(new TextComponentString("ItemStack: " + ItemTile.getItemStack(main)));
|
||||
|
||||
if(ModelOverridesHandler.hasCustomOverrideModel(ItemTile.getBlockState(main), ItemTile.getTileData(main)))
|
||||
player.sendMessage(new TextComponentString("Override Model: " + ModelOverridesHandler.getOverrideObject(ItemTile.getBlockState(main), ItemTile.getTileData(main))));
|
||||
|
||||
if(CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemTile.getBlockState(main)))
|
||||
player.sendMessage(new TextComponentString("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemTile.getBlockState(main))));
|
||||
|
||||
|
||||
CarryOn.LOGGER.info("Block: " + ItemTile.getBlock(main));
|
||||
CarryOn.LOGGER.info("BlockState: " + ItemTile.getBlockState(main));
|
||||
CarryOn.LOGGER.info("Meta: " + ItemTile.getMeta(main));
|
||||
CarryOn.LOGGER.info("ItemStack: " + ItemTile.getItemStack(main));
|
||||
|
||||
if(ModelOverridesHandler.hasCustomOverrideModel(ItemTile.getBlockState(main), ItemTile.getTileData(main)))
|
||||
CarryOn.LOGGER.info("Override Model: " + ModelOverridesHandler.getOverrideObject(ItemTile.getBlockState(main), ItemTile.getTileData(main)));
|
||||
|
||||
if(CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemTile.getBlockState(main)))
|
||||
CarryOn.LOGGER.info("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemTile.getBlockState(main)));
|
||||
|
||||
}
|
||||
else if(!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity)
|
||||
{
|
||||
player.sendMessage(new TextComponentString("Entity: " + ItemEntity.getEntity(main, server.getEntityWorld())));
|
||||
player.sendMessage(new TextComponentString("Entity Name: " + ItemEntity.getEntityName(main)));
|
||||
|
||||
if(CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemEntity.getEntity(main, server.getEntityWorld())))
|
||||
player.sendMessage(new TextComponentString("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemEntity.getEntity(main, server.getEntityWorld()))));
|
||||
|
||||
CarryOn.LOGGER.info("Entity: " + ItemEntity.getEntity(main, server.getEntityWorld()));
|
||||
CarryOn.LOGGER.info("Entity Name: " + ItemEntity.getEntityName(main));
|
||||
|
||||
if(CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemEntity.getEntity(main, server.getEntityWorld())))
|
||||
CarryOn.LOGGER.info("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemEntity.getEntity(main, server.getEntityWorld())));
|
||||
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(this.getUsage(sender));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int handleReload(CommandSource source)
|
||||
{
|
||||
if (Settings.useScripts.get())
|
||||
{
|
||||
throw new WrongUsageException(this.getUsage(sender));
|
||||
}
|
||||
ScriptReader.reloadScripts();
|
||||
CarryOn.network.send(PacketDistributor.ALL.noArg(), new ScriptReloadPacket());
|
||||
|
||||
source.sendFeedback(new TextComponentString("Successfully reloaded scripts!"), true);
|
||||
} else
|
||||
source.sendErrorMessage(new TextComponentString("To use custom Carry On scripts, enable them in the config!"));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkPermission(MinecraftServer server, ICommandSender sender)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos)
|
||||
{
|
||||
|
||||
if (args.length > 0)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, "debug", "clear");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return Collections.<String>emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Collections.<String>emptyList();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsernameIndex(String[] args, int index)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,80 +0,0 @@
|
|||
package tschipp.carryon.common.command;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import tschipp.carryon.common.scripting.ScriptReader;
|
||||
import tschipp.carryon.network.client.ScriptReloadPacket;
|
||||
|
||||
public class CommandCarryOnReload extends CommandBase
|
||||
{
|
||||
|
||||
@Override
|
||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
|
||||
{
|
||||
|
||||
if (CarryOnConfig.settings.useScripts)
|
||||
{
|
||||
ScriptReader.reloadScripts();
|
||||
CarryOn.network.sendToAll(new ScriptReloadPacket());
|
||||
sender.sendMessage(new TextComponentString("Successfully reloaded scripts!"));
|
||||
}
|
||||
else
|
||||
sender.sendMessage(new TextComponentString("To use custom Carry On scripts, enable them in the config!"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkPermission(MinecraftServer server, ICommandSender sender)
|
||||
{
|
||||
return sender.canUseCommand(this.getRequiredPermissionLevel(), this.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos)
|
||||
{
|
||||
|
||||
if (args.length > 0)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, "reload");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return Collections.<String>emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Collections.<String>emptyList();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "reloadscripts";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage(ICommandSender sender)
|
||||
{
|
||||
return "/reloadscripts";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,104 +1,87 @@
|
|||
package tschipp.carryon.common.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraftforge.common.config.Config;
|
||||
import net.minecraftforge.common.config.ConfigManager;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.fml.client.config.IConfigElement;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.helper.ReflectionUtil;
|
||||
|
||||
@Config(modid = CarryOn.MODID)
|
||||
public class CarryOnConfig
|
||||
{
|
||||
|
||||
@Config.LangKey(CarryOn.MODID)
|
||||
@Config.Comment("General Mod Settings")
|
||||
// @Config.LangKey(CarryOn.MODID)
|
||||
// @Config.Comment("General Mod Settings")
|
||||
public static Configs.Settings settings = new Configs.Settings();
|
||||
|
||||
@Config.LangKey(CarryOn.MODID)
|
||||
@Config.Comment("Blacklist for Blocks and Entities")
|
||||
// @Config.LangKey(CarryOn.MODID)
|
||||
// @Config.Comment("Blacklist for Blocks and Entities")
|
||||
public static Configs.Blacklist blacklist = new Configs.Blacklist();
|
||||
|
||||
@Config.LangKey(CarryOn.MODID)
|
||||
@Config.Comment("Whitelist for Blocks and Entities (useWhitelist must be true!)")
|
||||
// @Config.LangKey(CarryOn.MODID)
|
||||
// @Config.Comment("Whitelist for Blocks and Entities (useWhitelist must be true!)")
|
||||
public static Configs.WhiteList whitelist = new Configs.WhiteList();
|
||||
|
||||
@Config.LangKey(CarryOn.MODID)
|
||||
@Config.Comment("Model Overrides based on NBT or on Meta. Advanced Users Only!")
|
||||
// @Config.LangKey(CarryOn.MODID)
|
||||
// @Config.Comment("Model Overrides based on NBT or on Meta. Advanced Users Only!")
|
||||
public static Configs.ModelOverrides modelOverrides = new Configs.ModelOverrides();
|
||||
|
||||
@Config.LangKey(CarryOn.MODID)
|
||||
@Config.Comment("Custom Pickup Conditions for certain blocks. ONLY WORKS WHEN GAMESTAGES IS INSTALLED! Advanced Users Only!")
|
||||
// @Config.LangKey(CarryOn.MODID)
|
||||
// @Config.Comment("Custom Pickup Conditions for certain blocks. ONLY WORKS WHEN GAMESTAGES IS INSTALLED! Advanced Users Only!")
|
||||
public static Configs.CustomPickupConditions customPickupConditions = new Configs.CustomPickupConditions();
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public static class EventHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* The {@link ConfigManager#CONFIGS} getter.
|
||||
*/
|
||||
private static final MethodHandle CONFIGS_GETTER = ReflectionUtil.findFieldGetter(ConfigManager.class, "CONFIGS");
|
||||
|
||||
/**
|
||||
* The {@link Configuration} instance.
|
||||
*/
|
||||
private static Configuration configuration;
|
||||
|
||||
/**
|
||||
* Get the {@link Configuration} instance from {@link ConfigManager}.
|
||||
* <p>
|
||||
* TODO: Use a less hackish method of getting the
|
||||
* {@link Configuration}/{@link IConfigElement}s when possible.
|
||||
*
|
||||
* @return The Configuration instance
|
||||
*/
|
||||
public static Configuration getConfiguration()
|
||||
{
|
||||
if (EventHandler.configuration == null)
|
||||
try
|
||||
{
|
||||
final String fileName = CarryOn.MODID + ".cfg";
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final Map<String, Configuration> configsMap = (Map<String, Configuration>) EventHandler.CONFIGS_GETTER.invokeExact();
|
||||
|
||||
final Optional<Map.Entry<String, Configuration>> entryOptional = configsMap.entrySet().stream().filter(entry -> fileName.equals(new File(entry.getKey()).getName())).findFirst();
|
||||
|
||||
entryOptional.ifPresent(stringConfigurationEntry -> EventHandler.configuration = stringConfigurationEntry.getValue());
|
||||
}
|
||||
catch (Throwable throwable)
|
||||
{
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
|
||||
return EventHandler.configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject the new values and save to the config file when the config has
|
||||
* been changed from the GUI.
|
||||
*
|
||||
* @param event
|
||||
* The event
|
||||
*/
|
||||
@SubscribeEvent
|
||||
public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event)
|
||||
{
|
||||
if (event.getModID().equals(CarryOn.MODID))
|
||||
ConfigManager.load(CarryOn.MODID, Config.Type.INSTANCE);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// @Mod.EventBusSubscriber
|
||||
// public static class EventHandler
|
||||
// {
|
||||
//
|
||||
// /**
|
||||
// * The {@link ConfigManager#CONFIGS} getter.
|
||||
// */
|
||||
// private static final MethodHandle CONFIGS_GETTER = ReflectionUtil.findFieldGetter(ConfigManager.class, "CONFIGS");
|
||||
//
|
||||
// /**
|
||||
// * The {@link Configuration} instance.
|
||||
// */
|
||||
// private static Configuration configuration;
|
||||
//
|
||||
// /**
|
||||
// * Get the {@link Configuration} instance from {@link ConfigManager}.
|
||||
// * <p>
|
||||
// * TODO: Use a less hackish method of getting the
|
||||
// * {@link Configuration}/{@link IConfigElement}s when possible.
|
||||
// *
|
||||
// * @return The Configuration instance
|
||||
// */
|
||||
// public static Configuration getConfiguration()
|
||||
// {
|
||||
// if (EventHandler.configuration == null)
|
||||
// try
|
||||
// {
|
||||
// final String fileName = CarryOn.MODID + ".cfg";
|
||||
//
|
||||
// @SuppressWarnings("unchecked")
|
||||
// final Map<String, Configuration> configsMap = (Map<String, Configuration>) EventHandler.CONFIGS_GETTER.invokeExact();
|
||||
//
|
||||
// final Optional<Map.Entry<String, Configuration>> entryOptional = configsMap.entrySet().stream().filter(entry -> fileName.equals(new File(entry.getKey()).getName())).findFirst();
|
||||
//
|
||||
// entryOptional.ifPresent(stringConfigurationEntry -> EventHandler.configuration = stringConfigurationEntry.getValue());
|
||||
// }
|
||||
// catch (Throwable throwable)
|
||||
// {
|
||||
// throwable.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// return EventHandler.configuration;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Inject the new values and save to the config file when the config has
|
||||
// * been changed from the GUI.
|
||||
// *
|
||||
// * @param event
|
||||
// * The event
|
||||
// */
|
||||
// @SubscribeEvent
|
||||
// public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event)
|
||||
// {
|
||||
// if (event.getModID().equals(CarryOn.MODID))
|
||||
// ConfigManager.load(CarryOn.MODID, Config.Type.INSTANCE);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,303 +1,485 @@
|
|||
package tschipp.carryon.common.config;
|
||||
|
||||
import net.minecraftforge.common.config.Config;
|
||||
import net.minecraftforge.common.config.Config.Comment;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
import com.electronwill.nightconfig.core.io.WritingMode;
|
||||
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.DoubleValue;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.IntValue;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.handler.ListHandler;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class Configs {
|
||||
|
||||
private static final ForgeConfigSpec.Builder SERVER_BUILDER = new ForgeConfigSpec.Builder();
|
||||
private static final ForgeConfigSpec.Builder CLIENT_BUILDER = new ForgeConfigSpec.Builder();
|
||||
|
||||
public static final ForgeConfigSpec SERVER_CONFIG;
|
||||
public static final ForgeConfigSpec CLIENT_CONFIG;
|
||||
|
||||
static {
|
||||
|
||||
Settings.init(SERVER_BUILDER, CLIENT_BUILDER);
|
||||
Blacklist.init(SERVER_BUILDER, CLIENT_BUILDER);
|
||||
WhiteList.init(SERVER_BUILDER, CLIENT_BUILDER);
|
||||
ModelOverrides.init(SERVER_BUILDER, CLIENT_BUILDER);
|
||||
CustomPickupConditions.init(SERVER_BUILDER, CLIENT_BUILDER);
|
||||
|
||||
SERVER_CONFIG = SERVER_BUILDER.build();
|
||||
CLIENT_CONFIG = CLIENT_BUILDER.build();
|
||||
}
|
||||
|
||||
public static void loadConfig(ForgeConfigSpec spec, Path path)
|
||||
{
|
||||
final CommentedFileConfig configData = CommentedFileConfig.builder(path)
|
||||
.sync()
|
||||
.autosave()
|
||||
.autoreload()
|
||||
.writingMode(WritingMode.REPLACE)
|
||||
.build();
|
||||
|
||||
CarryOn.LOGGER.debug("Loading CarryOn Config");
|
||||
configData.load();
|
||||
spec.setConfig(configData);
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onLoad(final ModConfig.Loading event)
|
||||
{
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onChange(final ModConfig.ConfigReloading event)
|
||||
{
|
||||
if(event.getConfig().getModId().equals(CarryOn.MODID))
|
||||
{
|
||||
ListHandler.initLists();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Settings
|
||||
{
|
||||
@Comment("If the front of the Tile Entities should face the player or should face outward")
|
||||
public boolean facePlayer = false;
|
||||
public static BooleanValue facePlayer;
|
||||
|
||||
@Comment("More complex Tile Entities slow down the player more")
|
||||
public boolean heavyTiles = true;
|
||||
public static BooleanValue heavyTiles;
|
||||
|
||||
@Comment("Allow all blocks to be picked up, not just Tile Entites")
|
||||
public boolean pickupAllBlocks = false;
|
||||
public static BooleanValue pickupAllBlocks;
|
||||
|
||||
@Comment("Whether Blocks and Entities slow the creative player down when carried")
|
||||
public boolean slownessInCreative = true;
|
||||
public static BooleanValue slownessInCreative;
|
||||
|
||||
@Config.RangeDouble(min = 0)
|
||||
@Comment("Maximum distance from where Blocks and Entities can be picked up")
|
||||
public double maxDistance = 2.5;
|
||||
public static DoubleValue maxDistance;
|
||||
|
||||
@Config.RangeDouble(min = 0, max = 10)
|
||||
@Comment("Max width of entities that can be picked up in survival mode")
|
||||
public float maxEntityWidth = 1.5f;
|
||||
public static DoubleValue maxEntityWidth;
|
||||
|
||||
@Config.RangeDouble(min = 0, max = 10)
|
||||
@Comment("Max height of entities that can be picked up in survival mode")
|
||||
public float maxEntityHeight = 1.5f;
|
||||
public static DoubleValue maxEntityHeight;
|
||||
|
||||
@Comment("Whether hostile mobs should be able to picked up in survival mode")
|
||||
public boolean pickupHostileMobs = false;
|
||||
public static BooleanValue pickupHostileMobs;
|
||||
|
||||
@Comment("Larger Entities slow down the player more")
|
||||
public boolean heavyEntities = true;
|
||||
public static BooleanValue heavyEntities;
|
||||
|
||||
@Comment("Slowness multiplier for blocks")
|
||||
public double blockSlownessMultiplier = 1.0;
|
||||
public static DoubleValue blockSlownessMultiplier;
|
||||
|
||||
@Comment("Slowness multiplier for entities")
|
||||
public double entitySlownessMultiplier = 1.0;
|
||||
public static DoubleValue entitySlownessMultiplier;
|
||||
|
||||
@Comment("Arms should render on sides when carrying")
|
||||
public boolean renderArms = true;
|
||||
public static BooleanValue renderArms;
|
||||
|
||||
@Comment("Allow babies to be carried even when adult mob is blacklisted (or not whitelisted)")
|
||||
public boolean allowBabies = false;
|
||||
public static BooleanValue allowBabies;
|
||||
|
||||
@Comment("Use Whitelist instead of Blacklist for Blocks")
|
||||
public boolean useWhitelistBlocks=false;
|
||||
public static BooleanValue useWhitelistBlocks;
|
||||
|
||||
@Comment("Use Whitelist instead of Blacklist for Entities")
|
||||
public boolean useWhitelistEntities=false;
|
||||
public static BooleanValue useWhitelistEntities;
|
||||
|
||||
@Comment("Use Whitelist instead of Blacklist for Stacking")
|
||||
public boolean useWhitelistStacking=false;
|
||||
public static BooleanValue useWhitelistStacking;
|
||||
|
||||
@Comment("Whether the player can hit blocks and entities while carrying or not")
|
||||
public boolean hitWhileCarrying=false;
|
||||
public static BooleanValue hitWhileCarrying;
|
||||
|
||||
@Comment("Whether the player drops the carried object when hit or not")
|
||||
public boolean dropCarriedWhenHit=false;
|
||||
public static BooleanValue dropCarriedWhenHit;
|
||||
|
||||
@Config.RequiresMcRestart()
|
||||
@Comment("Use custom Pickup Scripts. Having this set to false, will not allow you to run scripts, but will increase your performance")
|
||||
public boolean useScripts=false;
|
||||
public static BooleanValue useScripts;
|
||||
|
||||
@Comment("Allows entities to be stacked using Carry On")
|
||||
public boolean stackableEntities = true;
|
||||
public static BooleanValue stackableEntities;
|
||||
|
||||
@Config.RangeInt(min = 1)
|
||||
@Comment("Maximum stack limit for entities")
|
||||
public int maxEntityStackLimit = 10;
|
||||
public static IntValue maxEntityStackLimit;
|
||||
|
||||
public static BooleanValue entitySizeMattersStacking;
|
||||
|
||||
public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c)
|
||||
{
|
||||
c.comment("Settings");
|
||||
s.comment("Settings");
|
||||
|
||||
|
||||
maxDistance = s
|
||||
.comment("Maximum distance from where Blocks and Entities can be picked up")
|
||||
.defineInRange("settings.maxDistance", 2.5, 0, Double.MAX_VALUE);
|
||||
|
||||
maxEntityWidth = s
|
||||
.comment("Max width of entities that can be picked up in survival mode")
|
||||
.defineInRange("settings.maxEntityWidth", 1.5, 0, 10);
|
||||
|
||||
maxEntityHeight = s
|
||||
.comment("Max height of entities that can be picked up in survival mode")
|
||||
.defineInRange("settings.maxEntityHeight", 1.5, 0, 10);
|
||||
|
||||
maxEntityWidth = s
|
||||
.comment("Max width of entities that can be picked up in survival mode")
|
||||
.defineInRange("settings.maxEntityWidth", 1.5, 0, 10);
|
||||
|
||||
blockSlownessMultiplier = s
|
||||
.comment("Slowness multiplier for blocks")
|
||||
.defineInRange("settings.blockSlownessMultiplier", 1, 0, Double.MAX_VALUE);
|
||||
|
||||
entitySlownessMultiplier = s
|
||||
.comment("Slowness multiplier for entities")
|
||||
.defineInRange("settings.entitySlownessMultiplier", 1, 0, Double.MAX_VALUE);
|
||||
|
||||
maxEntityStackLimit = s
|
||||
.comment("Maximum stack limit for entities")
|
||||
.defineInRange("settings.maxEntityStackLimit", 10, 1, Integer.MAX_VALUE);
|
||||
|
||||
facePlayer = c
|
||||
.comment("If the front of the Tile Entities should face the player or should face outward")
|
||||
.define("settings.facePlayer", false);
|
||||
|
||||
heavyTiles = s
|
||||
.comment("More complex Tile Entities slow down the player more")
|
||||
.define("settings.heavyTiles", true);
|
||||
|
||||
pickupAllBlocks = s
|
||||
.comment("Allow all blocks to be picked up, not just Tile Entites")
|
||||
.define("settings.pickupAllBlocks", false);
|
||||
|
||||
slownessInCreative = s
|
||||
.comment("Whether Blocks and Entities slow the creative player down when carried")
|
||||
.define("settings.slownessInCreative", true);
|
||||
|
||||
pickupHostileMobs = s
|
||||
.comment("Whether hostile mobs should be able to picked up in survival mode")
|
||||
.define("settings.pickupHostileMobs", false);
|
||||
|
||||
heavyEntities = s
|
||||
.comment("Larger Entities slow down the player more")
|
||||
.define("settings.heavyEntities", true);
|
||||
|
||||
renderArms = c
|
||||
.comment("Arms should render on sides when carrying")
|
||||
.define("settings.renderArms", true);
|
||||
|
||||
allowBabies = s
|
||||
.comment("Allow babies to be carried even when adult mob is blacklisted (or not whitelisted)")
|
||||
.define("settings.allowBabies", false);
|
||||
|
||||
useWhitelistBlocks = s
|
||||
.comment("Use Whitelist instead of Blacklist for Blocks")
|
||||
.define("settings.useWhitelistBlocks", false);
|
||||
|
||||
useWhitelistEntities = s
|
||||
.comment("Use Whitelist instead of Blacklist for Entities")
|
||||
.define("settings.useWhitelistEntities", false);
|
||||
|
||||
useWhitelistStacking = s
|
||||
.comment("Use Whitelist instead of Blacklist for Stacking")
|
||||
.define("settings.useWhitelistStacking", false);
|
||||
|
||||
hitWhileCarrying = s
|
||||
.comment("Whether the player can hit blocks and entities while carrying or not")
|
||||
.define("settings.hitWhileCarrying", false);
|
||||
|
||||
dropCarriedWhenHit = s
|
||||
.comment("Whether the player drops the carried object when hit or not")
|
||||
.define("settings.dropCarriedWhenHit", false);
|
||||
|
||||
useScripts = s
|
||||
.comment("Use custom Pickup Scripts. Having this set to false, will not allow you to run scripts, but will increase your performance")
|
||||
.worldRestart()
|
||||
.define("settings.useScripts", false);
|
||||
|
||||
stackableEntities = s
|
||||
.comment("Allows entities to be stacked using Carry On")
|
||||
.define("settings.stackableEntities", true);
|
||||
|
||||
entitySizeMattersStacking = s
|
||||
.comment("Whether entities' size matters when stacking or not")
|
||||
.define("settings.stackableEntities", true);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Comment("Whether entities' size matters when stacking or not")
|
||||
public boolean entitySizeMattersStacking = true;
|
||||
}
|
||||
|
||||
public static class WhiteList
|
||||
{
|
||||
@Comment("Entities that CAN be picked up")
|
||||
public String[] allowedEntities=new String[]
|
||||
{
|
||||
};
|
||||
public static ConfigValue<List<? extends String>> allowedEntities;
|
||||
|
||||
@Comment("Blocks that CAN be picked up")
|
||||
public String[] allowedBlocks=new String[]
|
||||
{
|
||||
};
|
||||
public static ConfigValue<List<? extends String>> allowedBlocks;
|
||||
|
||||
@Comment("Entities that CAN have other entities stacked on top of them")
|
||||
public String[] allowedStacking = new String[]
|
||||
{
|
||||
};
|
||||
public static ConfigValue<List<? extends String>> allowedStacking;
|
||||
|
||||
public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c)
|
||||
{
|
||||
s.comment("Whitelist");
|
||||
|
||||
allowedEntities = s
|
||||
.comment("Entities that CAN be picked up (useWhitelistEntities must be true)")
|
||||
.defineList("whitelist.allowedEntities", Arrays.asList(new String[]{}), (obj) -> obj instanceof String ? true : false);
|
||||
|
||||
allowedBlocks = s
|
||||
.comment("Blocks that CAN be picked up (useWhitelistBlocks must be true)")
|
||||
.defineList("whitelist.allowedBlocks", Arrays.asList(new String[]{}), (obj) -> obj instanceof String ? true : false);
|
||||
|
||||
allowedStacking = s
|
||||
.comment("Entities that CAN have other entities stacked on top of them (useWhitelistStacking must be true)")
|
||||
.defineList("whitelist.allowedStacking", Arrays.asList(new String[]{}), (obj) -> obj instanceof String ? true : false);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Blacklist
|
||||
{
|
||||
@Comment("Tile Entities that cannot be picked up")
|
||||
public String[] forbiddenTiles = new String[]
|
||||
{
|
||||
"minecraft:end_portal",
|
||||
"minecraft:end_gateway",
|
||||
"minecraft:double_plant",
|
||||
"minecraft:bed",
|
||||
"minecraft:wooden_door",
|
||||
"minecraft:iron_door",
|
||||
"minecraft:spruce_door",
|
||||
"minecraft:birch_door",
|
||||
"minecraft:jungle_door",
|
||||
"minecraft:acacia_door",
|
||||
"minecraft:dark_oak_door",
|
||||
"minecraft:waterlily",
|
||||
"minecraft:cake",
|
||||
"animania:block_trough",
|
||||
"animania:block_invisiblock",
|
||||
"colossalchests:*",
|
||||
"ic2:*",
|
||||
"bigreactors:*",
|
||||
"forestry:*",
|
||||
"tconstruct:*",
|
||||
"rustic:*",
|
||||
"botania:*",
|
||||
"astralsorcery:*",
|
||||
"quark:colored_bed_*",
|
||||
"immersiveengineering:*",
|
||||
"embers:block_furnace",
|
||||
"embers:ember_bore",
|
||||
"embers:ember_activator",
|
||||
"embers:mixer",
|
||||
"embers:heat_coil",
|
||||
"embers:large_tank",
|
||||
"embers:crystal_cell",
|
||||
"embers:alchemy_pedestal",
|
||||
"embers:boiler",
|
||||
"embers:combustor",
|
||||
"embers:catalzyer",
|
||||
"embers:field_chart",
|
||||
"embers:inferno_forge",
|
||||
"storagedrawers:framingtable",
|
||||
"skyresources:*",
|
||||
"lootbags:*",
|
||||
"exsartagine:*",
|
||||
"aquamunda:tank",
|
||||
"opencomputers:*",
|
||||
"malisisdoors:*",
|
||||
"industrialforegoing:*",
|
||||
"minecolonies:*",
|
||||
"thaumcraft:pillar*",
|
||||
"thaumcraft:infernal_furnace",
|
||||
"thaumcraft:placeholder*",
|
||||
"thaumcraft:infusion_matrix",
|
||||
"thaumcraft:golem_builder",
|
||||
"thaumcraft:thaumatorium*",
|
||||
"magneticraft:oil_heater",
|
||||
"magneticraft:solar_panel",
|
||||
"magneticraft:steam_engine",
|
||||
"magneticraft:shelving_unit",
|
||||
"magneticraft:grinder",
|
||||
"magneticraft:sieve",
|
||||
"magneticraft:solar_tower",
|
||||
"magneticraft:solar_mirror",
|
||||
"magneticraft:container",
|
||||
"magneticraft:pumpjack",
|
||||
"magneticraft:solar_panel",
|
||||
"magneticraft:refinery",
|
||||
"magneticraft:oil_heater",
|
||||
"magneticraft:hydraulic_press",
|
||||
"magneticraft:multiblock_gap",
|
||||
"refinedstorage:*",
|
||||
"practicallogistics2:*",
|
||||
"mcmultipart:*",
|
||||
"enderstorage:*",
|
||||
"betterstorage:*",
|
||||
"practicallogistics2:*"
|
||||
public static ConfigValue<List<? extends String>> forbiddenTiles;
|
||||
|
||||
public static ConfigValue<List<? extends String>> forbiddenEntities;
|
||||
|
||||
public static ConfigValue<List<? extends String>> forbiddenStacking;
|
||||
|
||||
public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c)
|
||||
{
|
||||
s.comment("Blacklist");
|
||||
|
||||
forbiddenTiles = s
|
||||
.comment("Tile Entities that cannot be picked up")
|
||||
.defineList("blacklist.forbiddenTiles", Arrays.asList(new String[]
|
||||
{
|
||||
"minecraft:end_portal",
|
||||
"minecraft:end_gateway",
|
||||
"minecraft:tall_grass",
|
||||
"minecraft:large_fern",
|
||||
"minecraft:peony",
|
||||
"minecraft:rose_bush",
|
||||
"minecraft:lilac",
|
||||
"minecraft:sunflower",
|
||||
"minecraft:*_bed",
|
||||
"minecraft:wooden_door",
|
||||
"minecraft:iron_door",
|
||||
"minecraft:spruce_door",
|
||||
"minecraft:birch_door",
|
||||
"minecraft:jungle_door",
|
||||
"minecraft:acacia_door",
|
||||
"minecraft:dark_oak_door",
|
||||
"minecraft:waterlily",
|
||||
"minecraft:cake",
|
||||
"minecraft:portal",
|
||||
"minecraft:tall_seagrass",
|
||||
"animania:block_trough",
|
||||
"animania:block_invisiblock",
|
||||
"colossalchests:*",
|
||||
"ic2:*",
|
||||
"bigreactors:*",
|
||||
"forestry:*",
|
||||
"tconstruct:*",
|
||||
"rustic:*",
|
||||
"botania:*",
|
||||
"astralsorcery:*",
|
||||
"quark:colored_bed_*",
|
||||
"immersiveengineering:*",
|
||||
"embers:block_furnace",
|
||||
"embers:ember_bore",
|
||||
"embers:ember_activator",
|
||||
"embers:mixer",
|
||||
"embers:heat_coil",
|
||||
"embers:large_tank",
|
||||
"embers:crystal_cell",
|
||||
"embers:alchemy_pedestal",
|
||||
"embers:boiler",
|
||||
"embers:combustor",
|
||||
"embers:catalzyer",
|
||||
"embers:field_chart",
|
||||
"embers:inferno_forge",
|
||||
"storagedrawers:framingtable",
|
||||
"skyresources:*",
|
||||
"lootbags:*",
|
||||
"exsartagine:*",
|
||||
"aquamunda:tank",
|
||||
"opencomputers:*",
|
||||
"malisisdoors:*",
|
||||
"industrialforegoing:*",
|
||||
"minecolonies:*",
|
||||
"thaumcraft:pillar*",
|
||||
"thaumcraft:infernal_furnace",
|
||||
"thaumcraft:placeholder*",
|
||||
"thaumcraft:infusion_matrix",
|
||||
"thaumcraft:golem_builder",
|
||||
"thaumcraft:thaumatorium*",
|
||||
"magneticraft:oil_heater",
|
||||
"magneticraft:solar_panel",
|
||||
"magneticraft:steam_engine",
|
||||
"magneticraft:shelving_unit",
|
||||
"magneticraft:grinder",
|
||||
"magneticraft:sieve",
|
||||
"magneticraft:solar_tower",
|
||||
"magneticraft:solar_mirror",
|
||||
"magneticraft:container",
|
||||
"magneticraft:pumpjack",
|
||||
"magneticraft:solar_panel",
|
||||
"magneticraft:refinery",
|
||||
"magneticraft:oil_heater",
|
||||
"magneticraft:hydraulic_press",
|
||||
"magneticraft:multiblock_gap",
|
||||
"refinedstorage:*",
|
||||
"mcmultipart:*",
|
||||
"enderstorage:*",
|
||||
"betterstorage:*",
|
||||
"practicallogistics2:*",
|
||||
"wearablebackpacks:*"
|
||||
|
||||
};
|
||||
|
||||
@Comment("Entities that cannot be picked up")
|
||||
public String[] forbiddenEntities = new String[]
|
||||
{
|
||||
"minecraft:ender_crystal",
|
||||
"minecraft:ender_dragon",
|
||||
"minecraft:ghast",
|
||||
"minecraft:shulker",
|
||||
"minecraft:leash_knot",
|
||||
"minecraft:armor_stand",
|
||||
"minecraft:item_frame",
|
||||
"minecraft:painting",
|
||||
"minecraft:shulker_bullet",
|
||||
"animania:textures/entity/pigs/hamster_tarou.png",
|
||||
"animania:hamster",
|
||||
"animania:ferret*",
|
||||
"animania:hedgehog*",
|
||||
"animania:cart",
|
||||
"animania:wagon",
|
||||
"mynko:*"
|
||||
};
|
||||
|
||||
|
||||
@Comment("Entities that cannot have other entities stacked on top of them")
|
||||
public String[] forbiddenStacking = new String[]
|
||||
{
|
||||
"minecraft:horse"
|
||||
};
|
||||
}), (obj) -> obj instanceof String ? true : false);
|
||||
|
||||
forbiddenEntities = s
|
||||
.comment("Entities that cannot be picked up")
|
||||
.defineList("blacklist.forbiddenEntities", Arrays.asList(new String[]
|
||||
{
|
||||
"minecraft:ender_crystal",
|
||||
"minecraft:ender_dragon",
|
||||
"minecraft:ghast",
|
||||
"minecraft:shulker",
|
||||
"minecraft:leash_knot",
|
||||
"minecraft:armor_stand",
|
||||
"minecraft:item_frame",
|
||||
"minecraft:painting",
|
||||
"minecraft:shulker_bullet",
|
||||
"animania:hamster",
|
||||
"animania:ferret*",
|
||||
"animania:hedgehog*",
|
||||
"animania:cart",
|
||||
"animania:wagon",
|
||||
"mynko:*"
|
||||
}), (obj) -> obj instanceof String ? true : false);
|
||||
|
||||
forbiddenStacking = s
|
||||
.comment("Entities that cannot have other entities stacked on top of them")
|
||||
.defineList("blacklist.forbiddenStacking", Arrays.asList(new String[]
|
||||
{
|
||||
"minecraft:horse"
|
||||
}), (obj) -> obj instanceof String ? true : false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class ModelOverrides
|
||||
{
|
||||
@Comment("Model Overrides based on NBT or on Meta. Advanced Users Only!")
|
||||
public String[] modelOverrides = new String[]
|
||||
{
|
||||
"minecraft:lit_furnace->minecraft:furnace",
|
||||
"minecraft:hopper->(block)minecraft:hopper",
|
||||
"minecraft:unpowered_comparator->(block)minecraft:unpowered_comparator",
|
||||
"minecraft:unpowered_repeater->(block)minecraft:unpowered_repeater",
|
||||
"minecraft:powered_comparator->(block)minecraft:powered_comparator",
|
||||
"minecraft:powered_repeater->(block)minecraft:powered_repeater",
|
||||
"minecraft:cauldron->(block)minecraft:cauldron",
|
||||
"minecraft:brewing_stand->(item)minecraft:brewing_stand",
|
||||
"minecraft:tallgrass;1->(item)minecraft:tallgrass;1",
|
||||
"minecraft:tallgrass;2->(item)minecraft:tallgrass;2",
|
||||
"minecraft:flower_pot->(block)minecraft:flower_pot",
|
||||
"minecraft:leaves2->(item)minecraft:leaves2",
|
||||
"minecraft:reeds->(block)minecraft:reeds",
|
||||
"minecraft:daylight_detector_inverted->minecraft:daylight_detector",
|
||||
"minecraft:standing_sign->(item)minecraft:sign",
|
||||
"minecraft:wall_sign->(item)minecraft:sign",
|
||||
"minecraft:redstone_wire->(item)minecraft:redstone",
|
||||
"quark:custom_chest{type:\"spruce\"}->quark:custom_chest;0",
|
||||
"quark:custom_chest{type:\"birch\"}->quark:custom_chest;1",
|
||||
"quark:custom_chest{type:\"jungle\"}->quark:custom_chest;2",
|
||||
"quark:custom_chest{type:\"acacia\"}->quark:custom_chest;3",
|
||||
"quark:custom_chest{type:\"dark_oak\"}->quark:custom_chest;4",
|
||||
"quark:custom_chest_trap{type:\"spruce\"}->quark:custom_chest_trap;0",
|
||||
"quark:custom_chest_trap{type:\"birch\"}->quark:custom_chest_trap;1",
|
||||
"quark:custom_chest_trap{type:\"jungle\"}->quark:custom_chest_trap;2",
|
||||
"quark:custom_chest_trap{type:\"acacia\"}->quark:custom_chest_trap;3",
|
||||
"quark:custom_chest_trap{type:\"dark_oak\"}->quark:custom_chest_trap;4",
|
||||
"storagedrawers:basicdrawers;0{Mat:\"spruce\"}->storagedrawers:basicdrawers;0{material:\"spruce\"}",
|
||||
"storagedrawers:basicdrawers;0{Mat:\"birch\"}->storagedrawers:basicdrawers;0{material:\"birch\"}",
|
||||
"storagedrawers:basicdrawers;0{Mat:\"jungle\"}->storagedrawers:basicdrawers;0{material:\"jungle\"}",
|
||||
"storagedrawers:basicdrawers;0{Mat:\"acacia\"}->storagedrawers:basicdrawers;0{material:\"acacia\"}",
|
||||
"storagedrawers:basicdrawers;0{Mat:\"dark_oak\"}->storagedrawers:basicdrawers;0{material:\"dark_oak\"}",
|
||||
"storagedrawers:basicdrawers;1{Mat:\"spruce\"}->storagedrawers:basicdrawers;1{material:\"spruce\"}",
|
||||
"storagedrawers:basicdrawers;1{Mat:\"birch\"}->storagedrawers:basicdrawers;1{material:\"birch\"}",
|
||||
"storagedrawers:basicdrawers;1{Mat:\"jungle\"}->storagedrawers:basicdrawers;1{material:\"jungle\"}",
|
||||
"storagedrawers:basicdrawers;1{Mat:\"acacia\"}->storagedrawers:basicdrawers;1{material:\"acacia\"}",
|
||||
"storagedrawers:basicdrawers;1{Mat:\"dark_oak\"}->storagedrawers:basicdrawers;1{material:\"dark_oak\"}",
|
||||
"storagedrawers:basicdrawers;2{Mat:\"spruce\"}->storagedrawers:basicdrawers;2{material:\"spruce\"}",
|
||||
"storagedrawers:basicdrawers;2{Mat:\"birch\"}->storagedrawers:basicdrawers;2{material:\"birch\"}",
|
||||
"storagedrawers:basicdrawers;2{Mat:\"jungle\"}->storagedrawers:basicdrawers;2{material:\"jungle\"}",
|
||||
"storagedrawers:basicdrawers;2{Mat:\"acacia\"}->storagedrawers:basicdrawers;2{material:\"acacia\"}",
|
||||
"storagedrawers:basicdrawers;2{Mat:\"dark_oak\"}->storagedrawers:basicdrawers;2{material:\"dark_oak\"}",
|
||||
"storagedrawers:basicdrawers;3{Mat:\"spruce\"}->storagedrawers:basicdrawers;3{material:\"spruce\"}",
|
||||
"storagedrawers:basicdrawers;3{Mat:\"birch\"}->storagedrawers:basicdrawers;3{material:\"birch\"}",
|
||||
"storagedrawers:basicdrawers;3{Mat:\"jungle\"}->storagedrawers:basicdrawers;3{material:\"jungle\"}",
|
||||
"storagedrawers:basicdrawers;3{Mat:\"acacia\"}->storagedrawers:basicdrawers;3{material:\"acacia\"}",
|
||||
"storagedrawers:basicdrawers;3{Mat:\"dark_oak\"}->storagedrawers:basicdrawers;3{material:\"dark_oak\"}",
|
||||
"storagedrawers:basicdrawers;4{Mat:\"spruce\"}->storagedrawers:basicdrawers;4{material:\"spruce\"}",
|
||||
"storagedrawers:basicdrawers;4{Mat:\"birch\"}->storagedrawers:basicdrawers;4{material:\"birch\"}",
|
||||
"storagedrawers:basicdrawers;4{Mat:\"jungle\"}->storagedrawers:basicdrawers;4{material:\"jungle\"}",
|
||||
"storagedrawers:basicdrawers;4{Mat:\"acacia\"}->storagedrawers:basicdrawers;4{material:\"acacia\"}",
|
||||
"storagedrawers:basicdrawers;4{Mat:\"dark_oak\"}->storagedrawers:basicdrawers;4{material:\"dark_oak\"}",
|
||||
"animania:block_nest->(block)animania:block_nest",
|
||||
"animania:cheese_mold;0->(block)animania:cheese_mold;0",
|
||||
"animania:cheese_mold;1->(block)animania:cheese_mold;1",
|
||||
"animania:cheese_mold;2->(block)animania:cheese_mold;2",
|
||||
"animania:cheese_mold;3->(block)animania:cheese_mold;3",
|
||||
"animania:cheese_mold;4->(block)animania:cheese_mold;4",
|
||||
"animania:cheese_mold;5->(block)animania:cheese_mold;5",
|
||||
"animania:cheese_mold;6->(block)animania:cheese_mold;6",
|
||||
"animania:cheese_mold;7->(block)animania:cheese_mold;7",
|
||||
"animania:cheese_mold;8->(block)animania:cheese_mold;8",
|
||||
"animania:cheese_mold;9->(block)animania:cheese_mold;9",
|
||||
"animania:cheese_mold;10->(block)animania:cheese_mold;10",
|
||||
};
|
||||
public static ConfigValue<List<? extends String>> modelOverrides;
|
||||
|
||||
public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c)
|
||||
{
|
||||
c.comment("Model Overrides");
|
||||
|
||||
|
||||
modelOverrides = c
|
||||
.comment("Model Overrides based on NBT or on Meta. Advanced Users Only!")
|
||||
.defineList("modeloverrides.overrides", Arrays.asList(new String[]
|
||||
{
|
||||
"minecraft:lit_furnace->minecraft:furnace",
|
||||
"minecraft:hopper->(block)minecraft:hopper",
|
||||
"minecraft:unpowered_comparator->(block)minecraft:unpowered_comparator",
|
||||
"minecraft:unpowered_repeater->(block)minecraft:unpowered_repeater",
|
||||
"minecraft:powered_comparator->(block)minecraft:powered_comparator",
|
||||
"minecraft:powered_repeater->(block)minecraft:powered_repeater",
|
||||
"minecraft:cauldron->(block)minecraft:cauldron",
|
||||
"minecraft:brewing_stand->(item)minecraft:brewing_stand",
|
||||
"minecraft:tallgrass;1->(item)minecraft:tallgrass;1",
|
||||
"minecraft:tallgrass;2->(item)minecraft:tallgrass;2",
|
||||
"minecraft:flower_pot->(block)minecraft:flower_pot",
|
||||
"minecraft:leaves2->(item)minecraft:leaves2",
|
||||
"minecraft:reeds->(block)minecraft:reeds",
|
||||
"minecraft:daylight_detector_inverted->minecraft:daylight_detector",
|
||||
"minecraft:standing_sign->(item)minecraft:sign",
|
||||
"minecraft:wall_sign->(item)minecraft:sign",
|
||||
"minecraft:redstone_wire->(item)minecraft:redstone",
|
||||
"quark:custom_chest{type:\"spruce\"}->quark:custom_chest;0",
|
||||
"quark:custom_chest{type:\"birch\"}->quark:custom_chest;1",
|
||||
"quark:custom_chest{type:\"jungle\"}->quark:custom_chest;2",
|
||||
"quark:custom_chest{type:\"acacia\"}->quark:custom_chest;3",
|
||||
"quark:custom_chest{type:\"dark_oak\"}->quark:custom_chest;4",
|
||||
"quark:custom_chest_trap{type:\"spruce\"}->quark:custom_chest_trap;0",
|
||||
"quark:custom_chest_trap{type:\"birch\"}->quark:custom_chest_trap;1",
|
||||
"quark:custom_chest_trap{type:\"jungle\"}->quark:custom_chest_trap;2",
|
||||
"quark:custom_chest_trap{type:\"acacia\"}->quark:custom_chest_trap;3",
|
||||
"quark:custom_chest_trap{type:\"dark_oak\"}->quark:custom_chest_trap;4",
|
||||
"storagedrawers:basicdrawers;0{Mat:\"spruce\"}->storagedrawers:basicdrawers;0{material:\"spruce\"}",
|
||||
"storagedrawers:basicdrawers;0{Mat:\"birch\"}->storagedrawers:basicdrawers;0{material:\"birch\"}",
|
||||
"storagedrawers:basicdrawers;0{Mat:\"jungle\"}->storagedrawers:basicdrawers;0{material:\"jungle\"}",
|
||||
"storagedrawers:basicdrawers;0{Mat:\"acacia\"}->storagedrawers:basicdrawers;0{material:\"acacia\"}",
|
||||
"storagedrawers:basicdrawers;0{Mat:\"dark_oak\"}->storagedrawers:basicdrawers;0{material:\"dark_oak\"}",
|
||||
"storagedrawers:basicdrawers;1{Mat:\"spruce\"}->storagedrawers:basicdrawers;1{material:\"spruce\"}",
|
||||
"storagedrawers:basicdrawers;1{Mat:\"birch\"}->storagedrawers:basicdrawers;1{material:\"birch\"}",
|
||||
"storagedrawers:basicdrawers;1{Mat:\"jungle\"}->storagedrawers:basicdrawers;1{material:\"jungle\"}",
|
||||
"storagedrawers:basicdrawers;1{Mat:\"acacia\"}->storagedrawers:basicdrawers;1{material:\"acacia\"}",
|
||||
"storagedrawers:basicdrawers;1{Mat:\"dark_oak\"}->storagedrawers:basicdrawers;1{material:\"dark_oak\"}",
|
||||
"storagedrawers:basicdrawers;2{Mat:\"spruce\"}->storagedrawers:basicdrawers;2{material:\"spruce\"}",
|
||||
"storagedrawers:basicdrawers;2{Mat:\"birch\"}->storagedrawers:basicdrawers;2{material:\"birch\"}",
|
||||
"storagedrawers:basicdrawers;2{Mat:\"jungle\"}->storagedrawers:basicdrawers;2{material:\"jungle\"}",
|
||||
"storagedrawers:basicdrawers;2{Mat:\"acacia\"}->storagedrawers:basicdrawers;2{material:\"acacia\"}",
|
||||
"storagedrawers:basicdrawers;2{Mat:\"dark_oak\"}->storagedrawers:basicdrawers;2{material:\"dark_oak\"}",
|
||||
"storagedrawers:basicdrawers;3{Mat:\"spruce\"}->storagedrawers:basicdrawers;3{material:\"spruce\"}",
|
||||
"storagedrawers:basicdrawers;3{Mat:\"birch\"}->storagedrawers:basicdrawers;3{material:\"birch\"}",
|
||||
"storagedrawers:basicdrawers;3{Mat:\"jungle\"}->storagedrawers:basicdrawers;3{material:\"jungle\"}",
|
||||
"storagedrawers:basicdrawers;3{Mat:\"acacia\"}->storagedrawers:basicdrawers;3{material:\"acacia\"}",
|
||||
"storagedrawers:basicdrawers;3{Mat:\"dark_oak\"}->storagedrawers:basicdrawers;3{material:\"dark_oak\"}",
|
||||
"storagedrawers:basicdrawers;4{Mat:\"spruce\"}->storagedrawers:basicdrawers;4{material:\"spruce\"}",
|
||||
"storagedrawers:basicdrawers;4{Mat:\"birch\"}->storagedrawers:basicdrawers;4{material:\"birch\"}",
|
||||
"storagedrawers:basicdrawers;4{Mat:\"jungle\"}->storagedrawers:basicdrawers;4{material:\"jungle\"}",
|
||||
"storagedrawers:basicdrawers;4{Mat:\"acacia\"}->storagedrawers:basicdrawers;4{material:\"acacia\"}",
|
||||
"storagedrawers:basicdrawers;4{Mat:\"dark_oak\"}->storagedrawers:basicdrawers;4{material:\"dark_oak\"}",
|
||||
"animania:block_nest->(block)animania:block_nest",
|
||||
"animania:cheese_mold;0->(block)animania:cheese_mold;0",
|
||||
"animania:cheese_mold;1->(block)animania:cheese_mold;1",
|
||||
"animania:cheese_mold;2->(block)animania:cheese_mold;2",
|
||||
"animania:cheese_mold;3->(block)animania:cheese_mold;3",
|
||||
"animania:cheese_mold;4->(block)animania:cheese_mold;4",
|
||||
"animania:cheese_mold;5->(block)animania:cheese_mold;5",
|
||||
"animania:cheese_mold;6->(block)animania:cheese_mold;6",
|
||||
"animania:cheese_mold;7->(block)animania:cheese_mold;7",
|
||||
"animania:cheese_mold;8->(block)animania:cheese_mold;8",
|
||||
"animania:cheese_mold;9->(block)animania:cheese_mold;9",
|
||||
"animania:cheese_mold;10->(block)animania:cheese_mold;10",
|
||||
}), (obj) -> obj instanceof String ? true : false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class CustomPickupConditions
|
||||
{
|
||||
@Config.RequiresMcRestart()
|
||||
@Comment("Custom Pickup Conditions for Blocks")
|
||||
public String[] customPickupConditionsBlocks = new String[]
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
public static ConfigValue<List<? extends String>> customPickupConditionsBlocks;
|
||||
|
||||
@Config.RequiresMcRestart()
|
||||
@Comment("Custom Pickup Conditions for Entities")
|
||||
public String[] customPickupConditionsEntities = new String[]
|
||||
{
|
||||
|
||||
};
|
||||
public static ConfigValue<List<? extends String>> customPickupConditionsEntities;
|
||||
|
||||
public static void init(ForgeConfigSpec.Builder s, ForgeConfigSpec.Builder c)
|
||||
{
|
||||
s.comment("Custom Pickup Conditions");
|
||||
|
||||
|
||||
customPickupConditionsBlocks = s
|
||||
.comment("Custom Pickup Conditions for Blocks")
|
||||
.defineList("custom_pickup_conditions.customPickupConditionsBlocks", Arrays.asList(new String[]{}), (obj) -> obj instanceof String ? true : false);
|
||||
|
||||
customPickupConditionsEntities = s
|
||||
.comment("Custom Pickup Conditions for Entities")
|
||||
.defineList("custom_pickup_conditions.customPickupConditionsEntities", Arrays.asList(new String[]{}), (obj) -> obj instanceof String ? true : false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
61
src/main/java/tschipp/carryon/common/event/IMCEvents.java
Normal file
61
src/main/java/tschipp/carryon/common/event/IMCEvents.java
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
package tschipp.carryon.common.event;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
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 tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.handler.ListHandler;
|
||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||
|
||||
public class IMCEvents
|
||||
{
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
public void serverLoad(FMLServerStartingEvent event)
|
||||
{
|
||||
Stream<IMCMessage> messages = InterModComms.getMessages(CarryOn.MODID);
|
||||
|
||||
messages.forEach((msg) -> {
|
||||
|
||||
String method = msg.getMethod();
|
||||
Object obj = msg.getMessageSupplier().get();
|
||||
|
||||
if(!(obj instanceof String))
|
||||
return;
|
||||
|
||||
String str = (String)obj;
|
||||
|
||||
switch (method)
|
||||
{
|
||||
case "blacklistBlock":
|
||||
ListHandler.FORBIDDEN_TILES.add(str);
|
||||
break;
|
||||
case "blacklistEntity":
|
||||
ListHandler.FORBIDDEN_ENTITIES.add(str);
|
||||
break;
|
||||
case "whitelistBlock":
|
||||
ListHandler.ALLOWED_TILES.add(str);
|
||||
break;
|
||||
case "whitelistEntity":
|
||||
ListHandler.ALLOWED_ENTITIES.add(str);
|
||||
break;
|
||||
case "blacklistStacking":
|
||||
ListHandler.FORBIDDEN_STACKING.add(str);
|
||||
break;
|
||||
case "whitelistStacking":
|
||||
ListHandler.ALLOWED_STACKING.add(str);
|
||||
break;
|
||||
case "addModelOverride":
|
||||
ModelOverridesHandler.parseOverride(str, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -20,16 +20,17 @@ import net.minecraft.util.EnumHand;
|
|||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.Event.Result;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import tschipp.carryon.common.config.Configs.Settings;
|
||||
import tschipp.carryon.common.handler.ListHandler;
|
||||
import tschipp.carryon.common.handler.PickupHandler;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
|
|
@ -56,8 +57,9 @@ public class ItemEntityEvents
|
|||
if (override != null)
|
||||
{
|
||||
String command = override.getCommandPlace();
|
||||
|
||||
if (command != null)
|
||||
player.getServer().getCommandManager().executeCommand(player.getServer(), "/execute " + player.getGameProfile().getName() + " ~ ~ ~ " + command);
|
||||
player.getServer().getCommandManager().handleCommand(player.getServer().getCommandSource(), "/execute as " + player.getGameProfile().getName() + " run " + command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -113,14 +115,14 @@ public class ItemEntityEvents
|
|||
{
|
||||
if (ItemEntity.storeEntityData(entity, world, stack))
|
||||
{
|
||||
if (entity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null))
|
||||
{
|
||||
IItemHandler handler = entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
||||
for (int i = 0; i < handler.getSlots(); i++)
|
||||
LazyOptional<IItemHandler> handler = entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY);
|
||||
|
||||
handler.ifPresent((hand) -> {
|
||||
for (int i = 0; i < hand.getSlots(); i++)
|
||||
{
|
||||
handler.extractItem(i, 64, false);
|
||||
hand.extractItem(i, 64, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
CarryOnOverride override = ScriptChecker.inspectEntity(entity);
|
||||
int overrideHash = 0;
|
||||
|
|
@ -132,7 +134,7 @@ public class ItemEntityEvents
|
|||
if (entity instanceof EntityLiving)
|
||||
((EntityLiving) entity).setHealth(0);
|
||||
|
||||
entity.setDead();
|
||||
entity.remove();
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
||||
event.setCanceled(true);
|
||||
event.setCancellationResult(EnumActionResult.FAIL);
|
||||
|
|
@ -140,29 +142,28 @@ public class ItemEntityEvents
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(main) && !CarryOnKeybinds.isKeyPressed(player) && CarryOnConfig.settings.stackableEntities)
|
||||
} else if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(main) && !CarryOnKeybinds.isKeyPressed(player) && Settings.stackableEntities.get())
|
||||
{
|
||||
Entity entityHeld = ItemEntity.getEntity(main, world);
|
||||
|
||||
if (entity.hurtResistantTime == 0 && entityHeld instanceof EntityLivingBase)
|
||||
{
|
||||
|
||||
if (!world.isRemote && entityHeld.getUniqueID() != entity.getUniqueID() && !entityHeld.isDead && !entity.isDead)
|
||||
if (!world.isRemote && entityHeld.getUniqueID() != entity.getUniqueID() && !entityHeld.removed && !entity.removed)
|
||||
{
|
||||
|
||||
double sizeHeldEntity = entityHeld.height * entityHeld.width;
|
||||
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
|
||||
Entity lowestEntity = entity.getLowestRidingEntity();
|
||||
int numPassengers = getAllPassengers(lowestEntity);
|
||||
if (numPassengers < CarryOnConfig.settings.maxEntityStackLimit - 1)
|
||||
if (numPassengers < Settings.maxEntityStackLimit.get() - 1)
|
||||
{
|
||||
Entity topEntity = getTopPassenger(lowestEntity);
|
||||
|
||||
if (CarryOnConfig.settings.useWhitelistStacking ? ListHandler.isStackingAllowed(topEntity) : !ListHandler.isStackingForbidden(topEntity))
|
||||
if (Settings.useWhitelistStacking.get() ? ListHandler.isStackingAllowed(topEntity) : !ListHandler.isStackingForbidden(topEntity))
|
||||
{
|
||||
double sizeEntity = topEntity.height * topEntity.width;
|
||||
if ((CarryOnConfig.settings.entitySizeMattersStacking && sizeHeldEntity <= sizeEntity) || !CarryOnConfig.settings.entitySizeMattersStacking)
|
||||
if ((Settings.entitySizeMattersStacking.get() && sizeHeldEntity <= sizeEntity) || !Settings.entitySizeMattersStacking.get())
|
||||
{
|
||||
if (topEntity instanceof EntityHorse)
|
||||
{
|
||||
|
|
@ -179,8 +180,7 @@ public class ItemEntityEvents
|
|||
world.spawnEntity(entityHeld);
|
||||
entityHeld.startRiding(topEntity, false);
|
||||
entityHeld.setPositionAndUpdate(tempX, tempY, tempZ);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
entityHeld.setPosition(entity.posX, entity.posY, entity.posZ);
|
||||
world.spawnEntity(entityHeld);
|
||||
|
|
@ -193,17 +193,15 @@ public class ItemEntityEvents
|
|||
event.setCanceled(true);
|
||||
event.setCancellationResult(EnumActionResult.FAIL);
|
||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_HORSE_SADDLE, SoundCategory.PLAYERS, 0.5F, 1.5F);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_NOTE_BASS, SoundCategory.PLAYERS, 0.5F, 1.5F);
|
||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_NOTE_BLOCK_BASS, SoundCategory.PLAYERS, 0.5F, 1.5F);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_NOTE_BASS, SoundCategory.PLAYERS, 0.5F, 1.5F);
|
||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_NOTE_BLOCK_BASS, SoundCategory.PLAYERS, 0.5F, 1.5F);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,15 +4,14 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
|
@ -26,8 +25,7 @@ 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.minecraftforge.common.config.Config;
|
||||
import net.minecraftforge.common.config.ConfigManager;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
|
|
@ -38,18 +36,24 @@ import net.minecraftforge.event.entity.player.PlayerEvent.StartTracking;
|
|||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.Event.Result;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
import net.minecraftforge.fml.network.PacketDistributor.TargetPoint;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import tschipp.carryon.common.command.CommandCarryOn;
|
||||
import tschipp.carryon.common.config.Configs;
|
||||
import tschipp.carryon.common.config.Configs.Settings;
|
||||
import tschipp.carryon.common.handler.CustomPickupOverrideHandler;
|
||||
import tschipp.carryon.common.handler.ListHandler;
|
||||
import tschipp.carryon.common.handler.PickupHandler;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
|
|
@ -57,6 +61,7 @@ import tschipp.carryon.common.item.ItemEntity;
|
|||
import tschipp.carryon.common.item.ItemTile;
|
||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
import tschipp.carryon.common.scripting.ScriptReader;
|
||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
||||
|
||||
public class ItemEvents
|
||||
|
|
@ -83,8 +88,9 @@ public class ItemEvents
|
|||
if (override != null)
|
||||
{
|
||||
String command = override.getCommandPlace();
|
||||
|
||||
if (command != null)
|
||||
player.getServer().getCommandManager().executeCommand(player.getServer(), "/execute " + player.getGameProfile().getName() + " ~ ~ ~ " + command);
|
||||
player.getServer().getCommandManager().handleCommand(player.getServer().getCommandSource(), "/execute as " + player.getGameProfile().getName() + " run " + command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -105,13 +111,15 @@ public class ItemEvents
|
|||
{
|
||||
BlockPos pos = eitem.getPosition();
|
||||
BlockPos finalPos = pos;
|
||||
Block block = ItemTile.getBlock(stack);
|
||||
if (!world.getBlockState(pos).getBlock().isReplaceable(world, pos) || !block.canPlaceBlockAt(world, pos))
|
||||
BlockItemUseContext context = new BlockItemUseContext(world, null, stack, pos, EnumFacing.DOWN, 0f, 0f, 0f);
|
||||
|
||||
if (!world.getBlockState(pos).isReplaceable(context) || !context.canPlace())
|
||||
{
|
||||
for (EnumFacing facing : EnumFacing.VALUES)
|
||||
for (EnumFacing facing : EnumFacing.values())
|
||||
{
|
||||
BlockPos offsetPos = pos.offset(facing);
|
||||
if (world.getBlockState(offsetPos).getBlock().isReplaceable(world, offsetPos) && block.canPlaceBlockAt(world, offsetPos))
|
||||
BlockItemUseContext newContext = new BlockItemUseContext(world, null, stack, offsetPos, EnumFacing.DOWN, 0, 0, 0);
|
||||
if (world.getBlockState(offsetPos).isReplaceable(newContext) && newContext.canPlace())
|
||||
{
|
||||
finalPos = offsetPos;
|
||||
break;
|
||||
|
|
@ -122,7 +130,7 @@ public class ItemEvents
|
|||
TileEntity tile = world.getTileEntity(finalPos);
|
||||
if (tile != null)
|
||||
{
|
||||
tile.readFromNBT(ItemTile.getTileData(stack));
|
||||
tile.deserializeNBT(ItemTile.getTileData(stack));
|
||||
tile.setPos(finalPos);
|
||||
}
|
||||
ItemTile.clearTileData(stack);
|
||||
|
|
@ -141,9 +149,9 @@ public class ItemEvents
|
|||
@SubscribeEvent
|
||||
public void onPlayerLogin(PlayerLoggedInEvent event)
|
||||
{
|
||||
if (event.player instanceof EntityPlayer)
|
||||
if (event.getPlayer() instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) event.player;
|
||||
EntityPlayer player = (EntityPlayer) event.getPlayer();
|
||||
World world = player.getEntityWorld();
|
||||
|
||||
ItemStack carried = player.getHeldItemMainhand();
|
||||
|
|
@ -151,25 +159,35 @@ public class ItemEvents
|
|||
{
|
||||
if (carried.getItem() == RegistrationHandler.itemTile)
|
||||
{
|
||||
CarryOnOverride override = ScriptChecker.inspectBlock(((ItemTile) carried.getItem()).getBlockState(carried), world, player.getPosition(), ((ItemTile) carried.getItem()).getTileData(carried));
|
||||
CarryOnOverride override = ScriptChecker.inspectBlock(ItemTile.getBlockState(carried), world, player.getPosition(), ItemTile.getTileData(carried));
|
||||
if (override != null)
|
||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId(), override.hashCode()), (EntityPlayerMP) player);
|
||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (EntityPlayerMP) player), new CarrySlotPacket(player.inventory.currentItem, player.getEntityId(), override.hashCode()));
|
||||
else
|
||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId()), (EntityPlayerMP) player);
|
||||
}
|
||||
else
|
||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (EntityPlayerMP) player), new CarrySlotPacket(player.inventory.currentItem, player.getEntityId()));
|
||||
} else
|
||||
{
|
||||
CarryOnOverride override = ScriptChecker.inspectEntity(((ItemEntity) carried.getItem()).getEntity(carried, world));
|
||||
CarryOnOverride override = ScriptChecker.inspectEntity(ItemEntity.getEntity(carried, world));
|
||||
if (override != null)
|
||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId(), override.hashCode()), (EntityPlayerMP) player);
|
||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (EntityPlayerMP) player), new CarrySlotPacket(player.inventory.currentItem, player.getEntityId(), override.hashCode()));
|
||||
else
|
||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId()), (EntityPlayerMP) player);
|
||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (EntityPlayerMP) player), new CarrySlotPacket(player.inventory.currentItem, player.getEntityId()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverLoad(FMLServerStartingEvent event)
|
||||
{
|
||||
CommandCarryOn.register(event.getCommandDispatcher());
|
||||
ScriptReader.reloadScripts();
|
||||
CustomPickupOverrideHandler.initPickupOverrides();
|
||||
ListHandler.initLists();
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityStartTracking(StartTracking event)
|
||||
{
|
||||
|
|
@ -186,19 +204,18 @@ public class ItemEvents
|
|||
{
|
||||
if (carried.getItem() == RegistrationHandler.itemTile)
|
||||
{
|
||||
CarryOnOverride override = ScriptChecker.inspectBlock(((ItemTile) carried.getItem()).getBlockState(carried), world, player.getPosition(), ((ItemTile) carried.getItem()).getTileData(carried));
|
||||
CarryOnOverride override = ScriptChecker.inspectBlock(ItemTile.getBlockState(carried), world, player.getPosition(), ItemTile.getTileData(carried));
|
||||
if (override != null)
|
||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId(), override.hashCode()), (EntityPlayerMP) tracker);
|
||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (EntityPlayerMP) tracker), new CarrySlotPacket(player.inventory.currentItem, player.getEntityId(), override.hashCode()));
|
||||
else
|
||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId()), (EntityPlayerMP) tracker);
|
||||
}
|
||||
else
|
||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (EntityPlayerMP) tracker), new CarrySlotPacket(player.inventory.currentItem, player.getEntityId()));
|
||||
} else
|
||||
{
|
||||
CarryOnOverride override = ScriptChecker.inspectEntity(((ItemEntity) carried.getItem()).getEntity(carried, world));
|
||||
CarryOnOverride override = ScriptChecker.inspectEntity(ItemEntity.getEntity(carried, world));
|
||||
if (override != null)
|
||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId(), override.hashCode()), (EntityPlayerMP) tracker);
|
||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (EntityPlayerMP) tracker), new CarrySlotPacket(player.inventory.currentItem, player.getEntityId(), override.hashCode()));
|
||||
else
|
||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId()), (EntityPlayerMP) tracker);
|
||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (EntityPlayerMP) tracker), new CarrySlotPacket(player.inventory.currentItem, player.getEntityId()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -209,7 +226,7 @@ public class ItemEvents
|
|||
public void harvestSpeed(BreakSpeed event)
|
||||
{
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
if (player != null && !CarryOnConfig.settings.hitWhileCarrying)
|
||||
if (player != null && !Settings.hitWhileCarrying.get())
|
||||
{
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
||||
|
|
@ -222,7 +239,7 @@ public class ItemEvents
|
|||
{
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
if (!stack.isEmpty() && !CarryOnConfig.settings.hitWhileCarrying && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
||||
if (!stack.isEmpty() && !Settings.hitWhileCarrying.get() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
|
@ -232,7 +249,7 @@ public class ItemEvents
|
|||
public void harvestSpeed(BreakEvent event)
|
||||
{
|
||||
EntityPlayer player = event.getPlayer();
|
||||
if (player != null && !CarryOnConfig.settings.hitWhileCarrying)
|
||||
if (player != null && !Settings.hitWhileCarrying.get())
|
||||
{
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
||||
|
|
@ -244,7 +261,7 @@ public class ItemEvents
|
|||
public void playerAttack(LivingAttackEvent event)
|
||||
{
|
||||
EntityLivingBase eliving = event.getEntityLiving();
|
||||
if (eliving instanceof EntityPlayer && CarryOnConfig.settings.dropCarriedWhenHit)
|
||||
if (eliving instanceof EntityPlayer && Settings.dropCarriedWhenHit.get())
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) eliving;
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
|
|
@ -295,7 +312,6 @@ public class ItemEvents
|
|||
ItemStack off = player.getHeldItemOffhand();
|
||||
World world = event.getWorld();
|
||||
BlockPos pos = event.getPos();
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
|
||||
if (main.isEmpty() && off.isEmpty() && CarryOnKeybinds.isKeyPressed(player))
|
||||
|
|
@ -308,12 +324,12 @@ public class ItemEvents
|
|||
{
|
||||
player.closeScreen();
|
||||
|
||||
if (ItemTile.storeTileData(te, world, pos, state.getActualState(world, pos), stack))
|
||||
if (ItemTile.storeTileData(te, world, pos, state, stack))
|
||||
{
|
||||
|
||||
IBlockState statee = world.getBlockState(pos);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag = world.getTileEntity(pos) != null ? world.getTileEntity(pos).writeToNBT(tag) : new NBTTagCompound();
|
||||
tag = world.getTileEntity(pos) != null ? world.getTileEntity(pos).write(tag) : new NBTTagCompound();
|
||||
CarryOnOverride override = ScriptChecker.inspectBlock(state, world, pos, tag);
|
||||
int overrideHash = 0;
|
||||
if (override != null)
|
||||
|
|
@ -328,32 +344,30 @@ public class ItemEvents
|
|||
sendPacket(player, player.inventory.currentItem, overrideHash);
|
||||
|
||||
world.removeTileEntity(pos);
|
||||
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 3);
|
||||
world.removeBlock(pos);
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
||||
event.setUseBlock(Result.DENY);
|
||||
event.setUseItem(Result.DENY);
|
||||
event.setCanceled(true);
|
||||
success = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
} catch (Exception e)
|
||||
{
|
||||
try
|
||||
{
|
||||
sendPacket(player, player.inventory.currentItem, overrideHash);
|
||||
emptyTileEntity(te);
|
||||
world.setBlockToAir(pos);
|
||||
world.removeBlock(pos);
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
||||
event.setUseBlock(Result.DENY);
|
||||
event.setUseItem(Result.DENY);
|
||||
event.setCanceled(true);
|
||||
success = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
} catch (Exception ex)
|
||||
{
|
||||
sendPacket(player, 9, 0);
|
||||
world.setBlockState(pos, statee);
|
||||
if (!tag.hasNoTags())
|
||||
TileEntity.create(world, tag);
|
||||
if (!tag.isEmpty())
|
||||
TileEntity.create(tag);
|
||||
|
||||
player.sendMessage(new TextComponentString(TextFormatting.RED + "Error detected. Cannot pick up block."));
|
||||
TextComponentString s = new TextComponentString(TextFormatting.GOLD + "here");
|
||||
|
|
@ -366,8 +380,9 @@ public class ItemEvents
|
|||
if (success && override != null)
|
||||
{
|
||||
String command = override.getCommandInit();
|
||||
|
||||
if (command != null)
|
||||
player.getServer().getCommandManager().executeCommand(player.getServer(), "/execute " + player.getGameProfile().getName() + " ~ ~ ~ " + command);
|
||||
player.getServer().getCommandManager().handleCommand(player.getServer().getCommandSource(), "/execute as " + player.getGameProfile().getName() + " run " + command);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -380,26 +395,31 @@ public class ItemEvents
|
|||
{
|
||||
if (te != null)
|
||||
{
|
||||
for (EnumFacing facing : EnumFacing.VALUES)
|
||||
for (EnumFacing facing : EnumFacing.values())
|
||||
{
|
||||
if (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing))
|
||||
{
|
||||
IItemHandler itemHandler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing);
|
||||
for (int i = 0; i < itemHandler.getSlots(); i++)
|
||||
LazyOptional<IItemHandler> itemHandler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing);
|
||||
|
||||
itemHandler.ifPresent((handler) -> {
|
||||
|
||||
for (int i = 0; i < handler.getSlots(); i++)
|
||||
{
|
||||
itemHandler.extractItem(i, 64, false);
|
||||
handler.extractItem(i, 64, false);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null))
|
||||
{
|
||||
IItemHandler itemHandler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
||||
for (int i = 0; i < itemHandler.getSlots(); i++)
|
||||
LazyOptional<IItemHandler> itemHandler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
||||
|
||||
itemHandler.ifPresent((handler) -> {
|
||||
|
||||
for (int i = 0; i < handler.getSlots(); i++)
|
||||
{
|
||||
itemHandler.extractItem(i, 64, false);
|
||||
handler.extractItem(i, 64, false);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (te instanceof IInventory)
|
||||
{
|
||||
|
|
@ -409,10 +429,10 @@ public class ItemEvents
|
|||
|
||||
if (te instanceof IItemHandler)
|
||||
{
|
||||
IItemHandler itemHandler = (IItemHandler) te;
|
||||
for (int i = 0; i < itemHandler.getSlots(); i++)
|
||||
IItemHandler itemHandler1 = (IItemHandler) te;
|
||||
for (int i = 0; i < itemHandler1.getSlots(); i++)
|
||||
{
|
||||
itemHandler.extractItem(i, 64, false);
|
||||
itemHandler1.extractItem(i, 64, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -439,7 +459,7 @@ public class ItemEvents
|
|||
|
||||
EntityItem item = new EntityItem(world);
|
||||
item.setItem(stack);
|
||||
BlockPos pos = original.getBedLocation();
|
||||
BlockPos pos = original.getBedLocation(original.dimension);
|
||||
if (pos == null)
|
||||
pos = player.getPosition();
|
||||
item.setPosition(pos.getX(), pos.getY(), pos.getZ());
|
||||
|
|
@ -463,11 +483,13 @@ public class ItemEvents
|
|||
|
||||
if (hasCarried)
|
||||
{
|
||||
if (inHand.getItem() != RegistrationHandler.itemTile && inHand.getItem() != RegistrationHandler.itemEntity)
|
||||
if ((inHand.getItem() != RegistrationHandler.itemTile && inHand.getItem() != RegistrationHandler.itemEntity) && player.getPortalCooldown() == 0)
|
||||
{
|
||||
int slotBlock = getSlot(player, RegistrationHandler.itemTile);
|
||||
int slotEntity = getSlot(player, RegistrationHandler.itemEntity);
|
||||
|
||||
|
||||
|
||||
EntityItem item = null;
|
||||
if (slotBlock != -1)
|
||||
{
|
||||
|
|
@ -492,8 +514,9 @@ public class ItemEvents
|
|||
if (override != null)
|
||||
{
|
||||
String command = override.getCommandLoop();
|
||||
|
||||
if (command != null)
|
||||
player.getServer().getCommandManager().executeCommand(player.getServer(), "/execute " + player.getGameProfile().getName() + " ~ ~ ~ " + command);
|
||||
player.getServer().getCommandManager().handleCommand(player.getServer().getCommandSource(), "/execute as " + player.getGameProfile().getName() + " run " + command);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -501,12 +524,14 @@ public class ItemEvents
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event)
|
||||
public void onConfigChanged(ModConfig.ConfigReloading event)
|
||||
{
|
||||
if (event.getModID().equals(CarryOn.MODID))
|
||||
if (event.getConfig().getModId().equals(CarryOn.MODID))
|
||||
{
|
||||
ListHandler.initLists();
|
||||
ConfigManager.load(CarryOn.MODID, Config.Type.INSTANCE);
|
||||
|
||||
Configs.loadConfig(Configs.CLIENT_CONFIG, FMLPaths.CONFIGDIR.get().resolve("carryon-client.toml"));
|
||||
Configs.loadConfig(Configs.CLIENT_CONFIG, FMLPaths.CONFIGDIR.get().resolve("carryon-server.toml"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -525,18 +550,16 @@ public class ItemEvents
|
|||
{
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
CarryOn.network.sendToAllAround(new CarrySlotPacket(currentItem, player.getEntityId(), hash), new TargetPoint(player.world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));
|
||||
CarryOn.network.sendTo(new CarrySlotPacket(currentItem, player.getEntityId(), hash), (EntityPlayerMP) player);
|
||||
CarryOn.network.send(PacketDistributor.NEAR.with(() -> new TargetPoint(player.posX, player.posY, player.posZ, 128, player.world.getDimension().getType())), new CarrySlotPacket(currentItem, player.getEntityId(), hash));
|
||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (EntityPlayerMP) player), new CarrySlotPacket(currentItem, player.getEntityId(), hash));
|
||||
|
||||
if (currentItem >= 9)
|
||||
{
|
||||
player.getEntityData().removeTag("carrySlot");
|
||||
player.getEntityData().removeTag("overrideKey");
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
|
||||
player.getEntityData().setInteger("carrySlot", currentItem);
|
||||
player.getEntityData().setInt("carrySlot", currentItem);
|
||||
if (hash != 0)
|
||||
ScriptChecker.setCarryOnOverride(player, hash);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
package tschipp.carryon.common.handler;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import tschipp.carryon.common.config.Configs.CustomPickupConditions;
|
||||
import tschipp.carryon.common.helper.InvalidConfigException;
|
||||
|
||||
public class CustomPickupOverrideHandler
|
||||
|
|
@ -16,16 +16,17 @@ public class CustomPickupOverrideHandler
|
|||
public static HashMap<String, String> PICKUP_CONDITIONS = new HashMap<String, String>();
|
||||
public static HashMap<String, String> PICKUP_CONDITIONS_ENTITIES = new HashMap<String, String>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void initPickupOverrides()
|
||||
{
|
||||
if (Loader.isModLoaded("gamestages"))
|
||||
if (ModList.get().isLoaded("gamestages"))
|
||||
{
|
||||
|
||||
String[] conditions = CarryOnConfig.customPickupConditions.customPickupConditionsBlocks;
|
||||
List<String> conditions = (List<String>) CustomPickupConditions.customPickupConditionsBlocks.get();
|
||||
|
||||
for (int i = 0; i < conditions.length; i++)
|
||||
for (int i = 0; i < conditions.size(); i++)
|
||||
{
|
||||
String line = conditions[i];
|
||||
String line = conditions.get(i);
|
||||
|
||||
if (!line.contains("(") || !line.contains(")"))
|
||||
new InvalidConfigException("Invalid Condition at line " + i + ": " + line).printException();
|
||||
|
|
@ -38,28 +39,26 @@ public class CustomPickupOverrideHandler
|
|||
if (blockname.contains("*"))
|
||||
{
|
||||
String modid = blockname.replace("*", "");
|
||||
for (int k = 0; k < Block.REGISTRY.getKeys().size(); k++)
|
||||
for (int k = 0; k < ForgeRegistries.BLOCKS.getKeys().size(); k++)
|
||||
{
|
||||
if (Block.REGISTRY.getKeys().toArray()[k].toString().contains(modid))
|
||||
if (ForgeRegistries.BLOCKS.getKeys().toArray()[k].toString().contains(modid))
|
||||
{
|
||||
PICKUP_CONDITIONS.put(Block.REGISTRY.getKeys().toArray()[k].toString() + ";any", condition);
|
||||
PICKUP_CONDITIONS.put(ForgeRegistries.BLOCKS.getKeys().toArray()[k].toString(), condition);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!blockname.contains(";"))
|
||||
blockname = blockname + ";any";
|
||||
|
||||
PICKUP_CONDITIONS.put(blockname, condition);
|
||||
}
|
||||
}
|
||||
|
||||
String[] entityConditions = CarryOnConfig.customPickupConditions.customPickupConditionsEntities;
|
||||
List<String> entityConditions = (List<String>) CustomPickupConditions.customPickupConditionsEntities.get();
|
||||
|
||||
for (int i = 0; i < entityConditions.length; i++)
|
||||
for (int i = 0; i < entityConditions.size(); i++)
|
||||
{
|
||||
String line = entityConditions[i];
|
||||
String line = entityConditions.get(i);
|
||||
|
||||
if (!line.contains("(") || !line.contains(")"))
|
||||
new InvalidConfigException("Invalid Condition at line " + i + ": " + line).printException();
|
||||
|
|
@ -77,47 +76,43 @@ public class CustomPickupOverrideHandler
|
|||
|
||||
public static boolean hasSpecialPickupConditions(IBlockState state)
|
||||
{
|
||||
if (!Loader.isModLoaded("gamestages"))
|
||||
if (!ModList.get().isLoaded("gamestages"))
|
||||
return false;
|
||||
|
||||
String block = state.getBlock().getRegistryName().toString();
|
||||
String meta = "" + state.getBlock().getMetaFromState(state);
|
||||
|
||||
boolean absolute = PICKUP_CONDITIONS.containsKey(block);
|
||||
|
||||
boolean absolute = PICKUP_CONDITIONS.containsKey(block + ";" + meta);
|
||||
boolean any = PICKUP_CONDITIONS.containsKey(block + ";any");
|
||||
|
||||
return absolute || any;
|
||||
return absolute;
|
||||
}
|
||||
|
||||
public static String getPickupCondition(IBlockState state)
|
||||
{
|
||||
String block = state.getBlock().getRegistryName().toString();
|
||||
String meta = "" + state.getBlock().getMetaFromState(state);
|
||||
|
||||
String absolute = PICKUP_CONDITIONS.get(block + ";" + meta);
|
||||
String any = PICKUP_CONDITIONS.get(block + ";any");
|
||||
String absolute = PICKUP_CONDITIONS.get(block);
|
||||
|
||||
if (absolute != null)
|
||||
return absolute;
|
||||
else
|
||||
return any;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean hasSpecialPickupConditions(Entity entity)
|
||||
{
|
||||
if (!Loader.isModLoaded("gamestages"))
|
||||
if (!ModList.get().isLoaded("gamestages"))
|
||||
return false;
|
||||
|
||||
String entityname = EntityList.getKey(entity).toString();
|
||||
boolean condition = PICKUP_CONDITIONS_ENTITIES.containsKey(entityname);
|
||||
String name = entity.getType().getRegistryName().toString();
|
||||
boolean condition = PICKUP_CONDITIONS_ENTITIES.containsKey(name);
|
||||
|
||||
return condition;
|
||||
}
|
||||
|
||||
public static String getPickupCondition(Entity entity)
|
||||
{
|
||||
String entityname = EntityList.getKey(entity).toString();
|
||||
String condition = PICKUP_CONDITIONS_ENTITIES.get(entityname);
|
||||
String name = entity.getType().getRegistryName().toString();
|
||||
String condition = PICKUP_CONDITIONS_ENTITIES.get(name);
|
||||
|
||||
return condition;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ import java.util.List;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import tschipp.carryon.common.config.Configs.Blacklist;
|
||||
import tschipp.carryon.common.config.Configs.WhiteList;
|
||||
|
||||
public class ListHandler
|
||||
{
|
||||
|
|
@ -17,7 +18,7 @@ public class ListHandler
|
|||
public static List<String> ALLOWED_TILES;
|
||||
public static List<String> FORBIDDEN_STACKING;
|
||||
public static List<String> ALLOWED_STACKING;
|
||||
|
||||
|
||||
public static boolean isForbidden(Block block)
|
||||
{
|
||||
String name = block.getRegistryName().toString();
|
||||
|
|
@ -30,61 +31,44 @@ public class ListHandler
|
|||
{
|
||||
if (s.contains("*"))
|
||||
{
|
||||
if(name.contains(s.replace("*", "")))
|
||||
String[] filter = s.replace("*", ",").split(",");
|
||||
if (containsAll(name, filter))
|
||||
contains = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return contains;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isForbidden(Entity entity)
|
||||
{
|
||||
if (EntityList.getKey(entity) != null)
|
||||
{
|
||||
String name = EntityList.getKey(entity).toString();
|
||||
boolean contains = FORBIDDEN_ENTITIES.contains(name);
|
||||
return contains;
|
||||
}
|
||||
|
||||
return true;
|
||||
String name = entity.getType().getRegistryName().toString();
|
||||
boolean contains = FORBIDDEN_ENTITIES.contains(name);
|
||||
return contains;
|
||||
}
|
||||
|
||||
public static boolean isAllowed(Entity entity)
|
||||
{
|
||||
if (EntityList.getKey(entity) != null)
|
||||
{
|
||||
String name = EntityList.getKey(entity).toString();
|
||||
boolean contains = ALLOWED_ENTITIES.contains(name);
|
||||
return contains;
|
||||
}
|
||||
return true;
|
||||
String name = entity.getType().getRegistryName().toString();
|
||||
boolean contains = ALLOWED_ENTITIES.contains(name);
|
||||
return contains;
|
||||
}
|
||||
|
||||
public static boolean isStackingForbidden(Entity entity)
|
||||
{
|
||||
if (EntityList.getKey(entity) != null)
|
||||
{
|
||||
String name = EntityList.getKey(entity).toString();
|
||||
boolean contains = FORBIDDEN_STACKING.contains(name);
|
||||
return contains;
|
||||
}
|
||||
|
||||
return true;
|
||||
String name = entity.getType().getRegistryName().toString();
|
||||
boolean contains = FORBIDDEN_STACKING.contains(name);
|
||||
return contains;
|
||||
}
|
||||
|
||||
public static boolean isStackingAllowed(Entity entity)
|
||||
{
|
||||
if (EntityList.getKey(entity) != null)
|
||||
{
|
||||
String name = EntityList.getKey(entity).toString();
|
||||
boolean contains = ALLOWED_STACKING.contains(name);
|
||||
return contains;
|
||||
}
|
||||
return true;
|
||||
String name = entity.getType().getRegistryName().toString();
|
||||
boolean contains = ALLOWED_STACKING.contains(name);
|
||||
return contains;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isAllowed(Block block)
|
||||
{
|
||||
String name = block.getRegistryName().toString();
|
||||
|
|
@ -97,105 +81,129 @@ public class ListHandler
|
|||
{
|
||||
if (s.contains("*"))
|
||||
{
|
||||
if(name.contains(s.replace("*", "")))
|
||||
String[] filter = s.replace("*", ",").split(",");
|
||||
if (containsAll(name, filter))
|
||||
contains = true;
|
||||
}
|
||||
}
|
||||
|
||||
return contains;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void initLists()
|
||||
{
|
||||
String[] forbidden = CarryOnConfig.blacklist.forbiddenTiles;
|
||||
List<String> forbidden = (List<String>) Blacklist.forbiddenTiles.get();
|
||||
FORBIDDEN_TILES = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < forbidden.length; i++)
|
||||
for (int i = 0; i < forbidden.size(); i++)
|
||||
{
|
||||
FORBIDDEN_TILES.add(forbidden[i]);
|
||||
FORBIDDEN_TILES.add(forbidden.get(i));
|
||||
}
|
||||
|
||||
String[] forbiddenEntity = CarryOnConfig.blacklist.forbiddenEntities;
|
||||
List<String> forbiddenEntity = (List<String>) Blacklist.forbiddenEntities.get();
|
||||
FORBIDDEN_ENTITIES = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < forbiddenEntity.length; i++)
|
||||
for (int i = 0; i < forbiddenEntity.size(); i++)
|
||||
{
|
||||
if (forbiddenEntity[i].contains("*"))
|
||||
if (forbiddenEntity.get(i).contains("*"))
|
||||
{
|
||||
String modid = forbiddenEntity[i].replace("*", "");
|
||||
for (int k = 0; k < ForgeRegistries.ENTITIES.getKeys().size(); k++)
|
||||
String[] filter = forbiddenEntity.get(i).replace("*", ",").split(",");
|
||||
|
||||
ResourceLocation[] keys = ForgeRegistries.ENTITIES.getKeys().toArray(new ResourceLocation[0]);
|
||||
for (ResourceLocation key : keys)
|
||||
{
|
||||
if (ForgeRegistries.ENTITIES.getKeys().toArray()[k].toString().contains(modid))
|
||||
if (containsAll(key.toString(), filter))
|
||||
{
|
||||
FORBIDDEN_ENTITIES.add(ForgeRegistries.ENTITIES.getKeys().toArray()[k].toString());
|
||||
FORBIDDEN_ENTITIES.add(key.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
FORBIDDEN_ENTITIES.add(forbiddenEntity[i]);
|
||||
FORBIDDEN_ENTITIES.add(forbiddenEntity.get(i));
|
||||
}
|
||||
|
||||
String[] allowedEntities = CarryOnConfig.whitelist.allowedEntities;
|
||||
List<String> allowedEntities = (List<String>) WhiteList.allowedEntities.get();
|
||||
ALLOWED_ENTITIES = new ArrayList<String>();
|
||||
for (int i = 0; i < allowedEntities.length; i++)
|
||||
for (int i = 0; i < allowedEntities.size(); i++)
|
||||
{
|
||||
if (allowedEntities[i].contains("*"))
|
||||
if (allowedEntities.get(i).contains("*"))
|
||||
{
|
||||
String modid = allowedEntities[i].replace("*", "");
|
||||
for (int k = 0; k < ForgeRegistries.ENTITIES.getKeys().size(); k++)
|
||||
String[] filter = allowedEntities.get(i).replace("*", ",").split(",");
|
||||
|
||||
ResourceLocation[] keys = ForgeRegistries.ENTITIES.getKeys().toArray(new ResourceLocation[0]);
|
||||
for (ResourceLocation key : keys)
|
||||
{
|
||||
if (ForgeRegistries.ENTITIES.getKeys().toArray()[k].toString().contains(modid))
|
||||
if (containsAll(key.toString(), filter))
|
||||
{
|
||||
ALLOWED_ENTITIES.add(ForgeRegistries.ENTITIES.getKeys().toArray()[k].toString());
|
||||
ALLOWED_ENTITIES.add(key.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
ALLOWED_ENTITIES.add(allowedEntities[i]);
|
||||
ALLOWED_ENTITIES.add(allowedEntities.get(i));
|
||||
}
|
||||
|
||||
String[] allowedBlocks = CarryOnConfig.whitelist.allowedBlocks;
|
||||
List<String> allowedBlocks = (List<String>) WhiteList.allowedBlocks.get();
|
||||
ALLOWED_TILES = new ArrayList<String>();
|
||||
for (int i = 0; i < allowedBlocks.length; i++)
|
||||
for (int i = 0; i < allowedBlocks.size(); i++)
|
||||
{
|
||||
ALLOWED_TILES.add(allowedBlocks[i]);
|
||||
ALLOWED_TILES.add(allowedBlocks.get(i));
|
||||
}
|
||||
|
||||
String[] forbiddenStacking = CarryOnConfig.blacklist.forbiddenStacking;
|
||||
|
||||
List<String> forbiddenStacking = (List<String>) Blacklist.forbiddenStacking.get();
|
||||
FORBIDDEN_STACKING = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < forbiddenStacking.length; i++)
|
||||
for (int i = 0; i < forbiddenStacking.size(); i++)
|
||||
{
|
||||
if (forbiddenStacking[i].contains("*"))
|
||||
if (forbiddenStacking.get(i).contains("*"))
|
||||
{
|
||||
String modid = forbiddenStacking[i].replace("*", "");
|
||||
for (int k = 0; k < ForgeRegistries.ENTITIES.getKeys().size(); k++)
|
||||
String[] filter = forbiddenStacking.get(i).replace("*", ",").split(",");
|
||||
|
||||
ResourceLocation[] keys = ForgeRegistries.ENTITIES.getKeys().toArray(new ResourceLocation[0]);
|
||||
for (ResourceLocation key : keys)
|
||||
{
|
||||
if (ForgeRegistries.ENTITIES.getKeys().toArray()[k].toString().contains(modid))
|
||||
if (containsAll(key.toString(), filter))
|
||||
{
|
||||
FORBIDDEN_STACKING.add(ForgeRegistries.ENTITIES.getKeys().toArray()[k].toString());
|
||||
FORBIDDEN_STACKING.add(key.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
FORBIDDEN_STACKING.add(forbiddenStacking[i]);
|
||||
FORBIDDEN_STACKING.add(forbiddenStacking.get(i));
|
||||
}
|
||||
|
||||
String[] allowedStacking = CarryOnConfig.whitelist.allowedStacking;
|
||||
List<String> allowedStacking = (List<String>) WhiteList.allowedStacking.get();
|
||||
ALLOWED_STACKING = new ArrayList<String>();
|
||||
for (int i = 0; i < allowedStacking.length; i++)
|
||||
for (int i = 0; i < allowedStacking.size(); i++)
|
||||
{
|
||||
if (allowedStacking[i].contains("*"))
|
||||
if (allowedStacking.get(i).contains("*"))
|
||||
{
|
||||
String modid = allowedStacking[i].replace("*", "");
|
||||
for (int k = 0; k < ForgeRegistries.ENTITIES.getKeys().size(); k++)
|
||||
String[] filter = allowedStacking.get(i).replace("*", ",").split(",");
|
||||
|
||||
ResourceLocation[] keys = ForgeRegistries.ENTITIES.getKeys().toArray(new ResourceLocation[0]);
|
||||
for (ResourceLocation key : keys)
|
||||
{
|
||||
if (ForgeRegistries.ENTITIES.getKeys().toArray()[k].toString().contains(modid))
|
||||
if (containsAll(key.toString(), filter))
|
||||
{
|
||||
ALLOWED_STACKING.add(ForgeRegistries.ENTITIES.getKeys().toArray()[k].toString());
|
||||
ALLOWED_STACKING.add(key.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
ALLOWED_STACKING.add(allowedStacking[i]);
|
||||
ALLOWED_STACKING.add(allowedStacking.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean containsAll(String str, String... strings)
|
||||
{
|
||||
boolean containsAll = true;
|
||||
|
||||
for(String s : strings)
|
||||
{
|
||||
if(!str.contains(s))
|
||||
containsAll = false;
|
||||
}
|
||||
|
||||
return containsAll;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package tschipp.carryon.common.handler;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -8,18 +9,17 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import tschipp.carryon.common.config.Configs.ModelOverrides;
|
||||
import tschipp.carryon.common.helper.InvalidConfigException;
|
||||
import tschipp.carryon.common.helper.StringParser;
|
||||
|
||||
|
|
@ -30,129 +30,131 @@ public class ModelOverridesHandler
|
|||
/*
|
||||
* This class is really ugly, will probably be replaced by something else -
|
||||
* Tschipp
|
||||
*/
|
||||
public static void initOverrides()
|
||||
*/
|
||||
public static void parseOverride(String overrideString, int i)
|
||||
{
|
||||
String[] overrides = CarryOnConfig.modelOverrides.modelOverrides;
|
||||
boolean errored = false;
|
||||
|
||||
for (int i = 0; i < overrides.length; i++)
|
||||
Object toOverrideObject;
|
||||
Object overrideObject;
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
|
||||
String currentline = overrideString;
|
||||
if (StringUtils.isEmpty(currentline) || !StringUtils.contains(currentline, "->"))
|
||||
new InvalidConfigException("Missing Override Model at line " + i + " : " + currentline).printException();
|
||||
|
||||
String[] sa = currentline.split("->");
|
||||
String toOverride = "";
|
||||
String override = "";
|
||||
try
|
||||
{
|
||||
boolean errored = false;
|
||||
toOverride = sa[0];
|
||||
override = sa[1];
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e)
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing Override Model at line " + i + " : " + currentline).printException();
|
||||
}
|
||||
|
||||
Object toOverrideObject;
|
||||
Object overrideObject;
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
if (toOverride.contains("{"))
|
||||
{
|
||||
if (!toOverride.contains("}"))
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing } at line " + i + " : " + currentline).printException();
|
||||
}
|
||||
|
||||
String currentline = overrides[i];
|
||||
if (StringUtils.isEmpty(currentline) || !StringUtils.contains(currentline, "->"))
|
||||
new InvalidConfigException("Missing Override Model at line " + i + " : " + currentline).printException();
|
||||
|
||||
String[] sa = currentline.split("->");
|
||||
String toOverride = "";
|
||||
String override = "";
|
||||
String nbt = toOverride.substring(toOverride.indexOf("{"));
|
||||
toOverride = toOverride.replace(nbt, "");
|
||||
try
|
||||
{
|
||||
toOverride = sa[0];
|
||||
override = sa[1];
|
||||
tag = JsonToNBT.getTagFromJson(nbt);
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e)
|
||||
catch (Exception e)
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing Override Model at line " + i + " : " + currentline).printException();
|
||||
new InvalidConfigException("Error while parsing NBT at line " + i + " : " + e.getMessage()).printException();
|
||||
}
|
||||
|
||||
if (toOverride.contains("{"))
|
||||
{
|
||||
if (!toOverride.contains("}"))
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing } at line " + i + " : " + currentline).printException();
|
||||
}
|
||||
}
|
||||
else if (toOverride.contains("}"))
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing { at line " + i + " : " + currentline).printException();
|
||||
}
|
||||
|
||||
String nbt = toOverride.substring(toOverride.indexOf("{"));
|
||||
toOverride = toOverride.replace(nbt, "");
|
||||
try
|
||||
{
|
||||
tag = JsonToNBT.getTagFromJson(nbt);
|
||||
}
|
||||
catch (NBTException e)
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Error while parsing NBT at line " + i + " : " + e.getMessage()).printException();
|
||||
}
|
||||
|
||||
}
|
||||
else if (toOverride.contains("}"))
|
||||
String overridetype = "item";
|
||||
if (override.contains("("))
|
||||
{
|
||||
if (!override.contains(")"))
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing { at line " + i + " : " + currentline).printException();
|
||||
new InvalidConfigException("Missing ) at line " + i + " : " + currentline).printException();
|
||||
}
|
||||
|
||||
String overridetype = "item";
|
||||
if (override.contains("("))
|
||||
overridetype = override.substring(0, override.indexOf(")") + 1);
|
||||
override =override.replace(overridetype, "");
|
||||
overridetype = overridetype.replace("(", "");
|
||||
overridetype = overridetype.replace(")", "");
|
||||
|
||||
}
|
||||
else if (override.contains(")"))
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing ( at line " + i + " : " + currentline).printException();
|
||||
}
|
||||
|
||||
String modidToOverride = "minecraft";
|
||||
String modidOverride = "minecraft";
|
||||
|
||||
if (toOverride.contains(":"))
|
||||
modidToOverride = toOverride.replace(toOverride.substring(toOverride.indexOf(":")), "");
|
||||
|
||||
if (override.contains(":"))
|
||||
modidOverride = override.replace(override.substring(override.indexOf(":")), "");
|
||||
|
||||
if ((ModList.get().isLoaded(modidOverride) || modidOverride.equals("minecraft")) && (ModList.get().isLoaded(modidToOverride) || modidToOverride.equals("minecraft")) && !errored)
|
||||
{
|
||||
toOverrideObject = StringParser.getBlockState(toOverride);
|
||||
|
||||
if (toOverrideObject != null)
|
||||
{
|
||||
if (!override.contains(")"))
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing ) at line " + i + " : " + currentline).printException();
|
||||
}
|
||||
|
||||
overridetype = override.substring(0, override.indexOf(")") + 1);
|
||||
override =override.replace(overridetype, "");
|
||||
overridetype = overridetype.replace("(", "");
|
||||
overridetype = overridetype.replace(")", "");
|
||||
|
||||
}
|
||||
else if (override.contains(")"))
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing ( at line " + i + " : " + currentline).printException();
|
||||
}
|
||||
|
||||
String modidToOverride = "minecraft";
|
||||
String modidOverride = "minecraft";
|
||||
|
||||
if (toOverride.contains(":"))
|
||||
modidToOverride = toOverride.replace(toOverride.substring(toOverride.indexOf(":")), "");
|
||||
|
||||
if (override.contains(":"))
|
||||
modidOverride = override.replace(override.substring(override.indexOf(":")), "");
|
||||
|
||||
if (Loader.isModLoaded(modidOverride) && Loader.isModLoaded(modidToOverride) && !errored)
|
||||
{
|
||||
|
||||
int meta = StringParser.getMeta(toOverride);
|
||||
if (meta == 0)
|
||||
toOverrideObject = StringParser.getBlock(toOverride);
|
||||
if (overridetype.equals("block"))
|
||||
overrideObject = StringParser.getBlockState(override);
|
||||
else
|
||||
toOverrideObject = StringParser.getBlockState(toOverride);
|
||||
overrideObject = StringParser.getItemStack(override);
|
||||
|
||||
if (toOverrideObject != null)
|
||||
if (overrideObject != null)
|
||||
{
|
||||
if (overridetype.equals("block"))
|
||||
overrideObject = StringParser.getBlockState(override);
|
||||
else
|
||||
overrideObject = StringParser.getItemStack(override);
|
||||
|
||||
if (overrideObject != null)
|
||||
NBTTagCompound keyComp = new NBTTagCompound();
|
||||
keyComp.setTag("nbttag", tag);
|
||||
if (toOverrideObject instanceof Block)
|
||||
{
|
||||
NBTTagCompound keyComp = new NBTTagCompound();
|
||||
keyComp.setTag("nbttag", tag);
|
||||
if (toOverrideObject instanceof Block)
|
||||
{
|
||||
keyComp.setString("block", ((Block) toOverrideObject).getRegistryName().toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
keyComp.setInteger("stateid", Block.getStateId((IBlockState) toOverrideObject));
|
||||
keyComp.setString("block", ((IBlockState) toOverrideObject).getBlock().getRegistryName().toString());
|
||||
}
|
||||
OVERRIDE_OBJECTS.put(keyComp, overrideObject);
|
||||
keyComp.setString("block", ((Block) toOverrideObject).getRegistryName().toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
keyComp.setInt("stateid", Block.getStateId((IBlockState) toOverrideObject));
|
||||
keyComp.setString("block", ((IBlockState) toOverrideObject).getBlock().getRegistryName().toString());
|
||||
}
|
||||
OVERRIDE_OBJECTS.put(keyComp, overrideObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void initOverrides()
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> overrides = (List<String>) ModelOverrides.modelOverrides.get();
|
||||
|
||||
for (int i = 0; i < overrides.size(); i++)
|
||||
{
|
||||
parseOverride(overrides.get(i), i);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasCustomOverrideModel(IBlockState state, NBTTagCompound tag)
|
||||
{
|
||||
|
|
@ -164,13 +166,13 @@ public class ModelOverridesHandler
|
|||
OVERRIDE_OBJECTS.keySet().toArray(keys);
|
||||
for (NBTTagCompound key : keys)
|
||||
{
|
||||
int id = key.getInteger("stateid");
|
||||
int id = key.getInt("stateid");
|
||||
Block block = StringParser.getBlock(key.getString("block"));
|
||||
if (id == 0 ? block == state.getBlock() : id == stateid)
|
||||
{
|
||||
NBTTagCompound toCheckForCompound = key.getCompoundTag("nbttag");
|
||||
Set<String> kSetToCheck = toCheckForCompound.getKeySet();
|
||||
Set<String> kSetTile = tag.getKeySet();
|
||||
NBTTagCompound toCheckForCompound = key.getCompound("nbttag");
|
||||
Set<String> kSetToCheck = toCheckForCompound.keySet();
|
||||
Set<String> kSetTile = tag.keySet();
|
||||
|
||||
boolean flag = true;
|
||||
if (kSetTile.containsAll(kSetToCheck))
|
||||
|
|
@ -189,7 +191,7 @@ public class ModelOverridesHandler
|
|||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static IBakedModel getCustomOverrideModel(IBlockState state, NBTTagCompound tag, World world, EntityPlayer player)
|
||||
{
|
||||
int stateid = Block.getStateId(state);
|
||||
|
|
@ -197,13 +199,13 @@ public class ModelOverridesHandler
|
|||
OVERRIDE_OBJECTS.keySet().toArray(keys);
|
||||
for (NBTTagCompound key : keys)
|
||||
{
|
||||
int id = key.getInteger("stateid");
|
||||
int id = key.getInt("stateid");
|
||||
Block block = StringParser.getBlock(key.getString("block"));
|
||||
if (id == 0 ? block == state.getBlock() : id == stateid)
|
||||
{
|
||||
NBTTagCompound toCheckForCompound = key.getCompoundTag("nbttag");
|
||||
Set<String> kSetToCheck = toCheckForCompound.getKeySet();
|
||||
Set<String> kSetTile = tag.getKeySet();
|
||||
NBTTagCompound toCheckForCompound = key.getCompound("nbttag");
|
||||
Set<String> kSetToCheck = toCheckForCompound.keySet();
|
||||
Set<String> kSetTile = tag.keySet();
|
||||
|
||||
boolean flag = true;
|
||||
if (kSetTile.containsAll(kSetToCheck))
|
||||
|
|
@ -221,9 +223,9 @@ public class ModelOverridesHandler
|
|||
return null;
|
||||
|
||||
if (override instanceof IBlockState)
|
||||
return Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState((IBlockState) override);
|
||||
return Minecraft.getInstance().getBlockRendererDispatcher().getModelForState((IBlockState) override);
|
||||
else
|
||||
return Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides((ItemStack) override, world, player);
|
||||
return Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides((ItemStack) override, world, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -239,13 +241,13 @@ public class ModelOverridesHandler
|
|||
OVERRIDE_OBJECTS.keySet().toArray(keys);
|
||||
for (NBTTagCompound key : keys)
|
||||
{
|
||||
int id = key.getInteger("stateid");
|
||||
int id = key.getInt("stateid");
|
||||
Block block = StringParser.getBlock(key.getString("block"));
|
||||
if (id == 0 ? block == state.getBlock() : id == stateid)
|
||||
{
|
||||
NBTTagCompound toCheckForCompound = key.getCompoundTag("nbttag");
|
||||
Set<String> kSetToCheck = toCheckForCompound.getKeySet();
|
||||
Set<String> kSetTile = tag.getKeySet();
|
||||
NBTTagCompound toCheckForCompound = key.getCompound("nbttag");
|
||||
Set<String> kSetToCheck = toCheckForCompound.keySet();
|
||||
Set<String> kSetTile = tag.keySet();
|
||||
|
||||
boolean flag = true;
|
||||
if (kSetTile.containsAll(kSetToCheck))
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ import java.util.UUID;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityAgeable;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
|
|
@ -18,13 +16,11 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import tschipp.carryon.common.config.Configs.Settings;
|
||||
import tschipp.carryon.common.item.ItemTile;
|
||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
|
|
@ -36,12 +32,10 @@ public class PickupHandler
|
|||
{
|
||||
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
Block block = state.getBlock();
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
if (tile != null)
|
||||
tile.writeToNBT(tag);
|
||||
|
||||
tile.write(tag);
|
||||
|
||||
CarryOnOverride override = ScriptChecker.inspectBlock(world.getBlockState(pos), world, pos, tag);
|
||||
if (override != null)
|
||||
{
|
||||
|
|
@ -49,7 +43,7 @@ public class PickupHandler
|
|||
}
|
||||
else
|
||||
{
|
||||
if (CarryOnConfig.settings.useWhitelistBlocks)
|
||||
if (Settings.useWhitelistBlocks.get())
|
||||
{
|
||||
if (!ListHandler.isAllowed(world.getBlockState(pos).getBlock()))
|
||||
{
|
||||
|
|
@ -64,11 +58,11 @@ public class PickupHandler
|
|||
}
|
||||
}
|
||||
|
||||
if ((block.getBlockHardness(state, world, pos) != -1 || player.isCreative()))
|
||||
if ((state.getBlockHardness(world, pos) != -1 || player.isCreative()))
|
||||
{
|
||||
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
|
||||
|
||||
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
|
||||
if (distance < Math.pow(Settings.maxDistance.get(), 2))
|
||||
{
|
||||
|
||||
if (!ItemTile.isLocked(pos, world))
|
||||
|
|
@ -81,8 +75,8 @@ public class PickupHandler
|
|||
Class<?> gameStageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper");
|
||||
Class<?> iStageData = Class.forName("net.darkhax.gamestages.data.IStageData");
|
||||
|
||||
Method getPlayerData = ReflectionHelper.findMethod(gameStageHelper, "getPlayerData", null, EntityPlayer.class);
|
||||
Method hasStage = ReflectionHelper.findMethod(iStageData, "hasStage", null, String.class);
|
||||
Method getPlayerData = ObfuscationReflectionHelper.findMethod(gameStageHelper, "getPlayerData", EntityPlayer.class);
|
||||
Method hasStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasStage", String.class);
|
||||
|
||||
Object stageData = getPlayerData.invoke(null, player);
|
||||
String condition = CustomPickupOverrideHandler.getPickupCondition(state);
|
||||
|
|
@ -98,8 +92,8 @@ public class PickupHandler
|
|||
Class<?> playerDataHandler = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler");
|
||||
Class<?> iStageData = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler$IStageData");
|
||||
|
||||
Method getStageData = ReflectionHelper.findMethod(playerDataHandler, "getStageData", null, EntityPlayer.class);
|
||||
Method hasUnlockedStage = ReflectionHelper.findMethod(iStageData, "hasUnlockedStage", null, String.class);
|
||||
Method getStageData = ObfuscationReflectionHelper.findMethod(playerDataHandler, "getStageData", EntityPlayer.class);
|
||||
Method hasUnlockedStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasUnlockedStage", String.class);
|
||||
|
||||
Object stageData = getStageData.invoke(null, player);
|
||||
String condition = CustomPickupOverrideHandler.getPickupCondition(state);
|
||||
|
|
@ -115,7 +109,7 @@ public class PickupHandler
|
|||
}
|
||||
|
||||
}
|
||||
else if (CarryOnConfig.settings.pickupAllBlocks ? true : tile != null)
|
||||
else if (Settings.pickupAllBlocks.get() ? true : tile != null)
|
||||
{
|
||||
return handleProtections((EntityPlayerMP) player, world, pos, state);
|
||||
}
|
||||
|
|
@ -142,19 +136,19 @@ public class PickupHandler
|
|||
}
|
||||
else
|
||||
{
|
||||
if (toPickUp instanceof EntityAgeable && CarryOnConfig.settings.allowBabies)
|
||||
if (toPickUp instanceof EntityAgeable && Settings.allowBabies.get())
|
||||
{
|
||||
EntityAgeable living = (EntityAgeable) toPickUp;
|
||||
if (living.getGrowingAge() < 0 || living.isChild())
|
||||
{
|
||||
|
||||
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
|
||||
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
|
||||
if (distance < Math.pow(Settings.maxDistance.get(), 2))
|
||||
{
|
||||
if (toPickUp instanceof EntityTameable)
|
||||
{
|
||||
EntityTameable tame = (EntityTameable) toPickUp;
|
||||
if (tame.getOwnerId() != null && tame.getOwnerId() != player.getUUID(player.getGameProfile()))
|
||||
if (tame.getOwnerId() != null && tame.getOwnerId() != EntityPlayer.getUUID(player.getGameProfile()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -166,8 +160,8 @@ public class PickupHandler
|
|||
Class<?> gameStageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper");
|
||||
Class<?> iStageData = Class.forName("net.darkhax.gamestages.data.IStageData");
|
||||
|
||||
Method getPlayerData = ReflectionHelper.findMethod(gameStageHelper, "getPlayerData", null, EntityPlayer.class);
|
||||
Method hasStage = ReflectionHelper.findMethod(iStageData, "hasStage", null, String.class);
|
||||
Method getPlayerData = ObfuscationReflectionHelper.findMethod(gameStageHelper, "getPlayerData", EntityPlayer.class);
|
||||
Method hasStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasStage", String.class);
|
||||
|
||||
Object stageData = getPlayerData.invoke(null, player);
|
||||
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
|
||||
|
|
@ -183,8 +177,8 @@ public class PickupHandler
|
|||
Class<?> playerDataHandler = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler");
|
||||
Class<?> iStageData = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler$IStageData");
|
||||
|
||||
Method getStageData = ReflectionHelper.findMethod(playerDataHandler, "getStageData", null, EntityPlayer.class);
|
||||
Method hasUnlockedStage = ReflectionHelper.findMethod(iStageData, "hasUnlockedStage", null, String.class);
|
||||
Method getStageData = ObfuscationReflectionHelper.findMethod(playerDataHandler, "getStageData", EntityPlayer.class);
|
||||
Method hasUnlockedStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasUnlockedStage", String.class);
|
||||
|
||||
Object stageData = getStageData.invoke(null, player);
|
||||
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
|
||||
|
|
@ -204,7 +198,7 @@ public class PickupHandler
|
|||
}
|
||||
}
|
||||
|
||||
if (CarryOnConfig.settings.useWhitelistEntities)
|
||||
if (Settings.useWhitelistEntities.get())
|
||||
{
|
||||
if (!ListHandler.isAllowed(toPickUp))
|
||||
{
|
||||
|
|
@ -219,20 +213,20 @@ public class PickupHandler
|
|||
}
|
||||
}
|
||||
|
||||
if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()))
|
||||
if ((Settings.pickupHostileMobs.get() ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()))
|
||||
{
|
||||
if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()))
|
||||
if ((Settings.pickupHostileMobs.get() ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()))
|
||||
{
|
||||
if ((toPickUp.height <= CarryOnConfig.settings.maxEntityHeight && toPickUp.width <= CarryOnConfig.settings.maxEntityWidth || player.isCreative()))
|
||||
if ((toPickUp.height <= Settings.maxEntityHeight.get() && toPickUp.width <= Settings.maxEntityWidth.get() || player.isCreative()))
|
||||
{
|
||||
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
|
||||
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
|
||||
if (distance < Math.pow(Settings.maxDistance.get(), 2))
|
||||
{
|
||||
if (toPickUp instanceof EntityTameable)
|
||||
{
|
||||
EntityTameable tame = (EntityTameable) toPickUp;
|
||||
UUID owner = tame.getOwnerId();
|
||||
UUID playerID = player.getUUID(player.getGameProfile());
|
||||
UUID playerID = EntityPlayer.getUUID(player.getGameProfile());
|
||||
if (owner != null && !owner.equals(playerID))
|
||||
return false;
|
||||
}
|
||||
|
|
@ -244,8 +238,8 @@ public class PickupHandler
|
|||
Class<?> gameStageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper");
|
||||
Class<?> iStageData = Class.forName("net.darkhax.gamestages.data.IStageData");
|
||||
|
||||
Method getPlayerData = ReflectionHelper.findMethod(gameStageHelper, "getPlayerData", null, EntityPlayer.class);
|
||||
Method hasStage = ReflectionHelper.findMethod(iStageData, "hasStage", null, String.class);
|
||||
Method getPlayerData = ObfuscationReflectionHelper.findMethod(gameStageHelper, "getPlayerData", EntityPlayer.class);
|
||||
Method hasStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasStage", String.class);
|
||||
|
||||
Object stageData = getPlayerData.invoke(null, player);
|
||||
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
|
||||
|
|
@ -261,8 +255,8 @@ public class PickupHandler
|
|||
Class<?> playerDataHandler = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler");
|
||||
Class<?> iStageData = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler$IStageData");
|
||||
|
||||
Method getStageData = ReflectionHelper.findMethod(playerDataHandler, "getStageData", null, EntityPlayer.class);
|
||||
Method hasUnlockedStage = ReflectionHelper.findMethod(iStageData, "hasUnlockedStage", null, String.class);
|
||||
Method getStageData = ObfuscationReflectionHelper.findMethod(playerDataHandler, "getStageData", EntityPlayer.class);
|
||||
Method hasUnlockedStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasUnlockedStage", String.class);
|
||||
|
||||
Object stageData = getStageData.invoke(null, player);
|
||||
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
package tschipp.carryon.common.handler;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
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;
|
||||
|
|
@ -14,15 +14,20 @@ 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.ItemEntity;
|
||||
import tschipp.carryon.common.item.ItemTile;
|
||||
import tschipp.carryon.compat.obfuscate.ObfuscateEvents;
|
||||
|
||||
@EventBusSubscriber(modid = CarryOn.MODID)
|
||||
public class RegistrationHandler
|
||||
{
|
||||
{
|
||||
@ObjectHolder("carryon:tile_item")
|
||||
public static Item itemTile;
|
||||
|
||||
@ObjectHolder("carryon:entity_item")
|
||||
public static Item itemEntity;
|
||||
|
||||
public static void regItems()
|
||||
|
|
@ -31,17 +36,12 @@ public class RegistrationHandler
|
|||
itemEntity = new ItemEntity();
|
||||
}
|
||||
|
||||
public static void regItemRenders()
|
||||
{
|
||||
ModelLoader.setCustomModelResourceLocation(itemTile, 0, new ModelResourceLocation(CarryOn.MODID + ":" + "tile", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(itemEntity, 0, new ModelResourceLocation(CarryOn.MODID + ":" + "tile", "inventory"));
|
||||
}
|
||||
|
||||
public static void regCommonEvents()
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(new ItemEvents());
|
||||
MinecraftForge.EVENT_BUS.register(new ItemEntityEvents());
|
||||
MinecraftForge.EVENT_BUS.register(new PositionCommonEvents());
|
||||
MinecraftForge.EVENT_BUS.register(new IMCEvents());
|
||||
}
|
||||
|
||||
public static void regClientEvents()
|
||||
|
|
@ -50,7 +50,8 @@ public class RegistrationHandler
|
|||
MinecraftForge.EVENT_BUS.register(new RenderEntityEvents());
|
||||
MinecraftForge.EVENT_BUS.register(new PositionClientEvents());
|
||||
|
||||
if(Loader.isModLoaded("obfuscate"))
|
||||
|
||||
if(ModList.get().isLoaded("obfuscate"))
|
||||
MinecraftForge.EVENT_BUS.register(new ObfuscateEvents());
|
||||
|
||||
}
|
||||
|
|
@ -66,5 +67,8 @@ public class RegistrationHandler
|
|||
{
|
||||
CapabilityManager.INSTANCE.register(IPosition.class, new PositionStorage(), TEPosition::new);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import tschipp.carryon.CarryOn;
|
|||
public class InvalidConfigException extends Exception
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = -7161004674405185407L;
|
||||
|
||||
public InvalidConfigException(String cause)
|
||||
{
|
||||
super(cause);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
package tschipp.carryon.common.helper;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.glfw.GLFWKeyCallback;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class KeyboardCallbackWrapper
|
||||
{
|
||||
GLFWKeyCallback oldCallback;
|
||||
|
||||
public void setup(Minecraft mc)
|
||||
{
|
||||
oldCallback = GLFW.glfwSetKeyCallback(mc.mainWindow.getHandle(), this::keyCallback);
|
||||
}
|
||||
|
||||
private void keyCallback(long window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
KeyPressedEvent event = new KeyPressedEvent(key, scancode);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
if (event.isCanceled())
|
||||
return;
|
||||
|
||||
if (oldCallback != null)
|
||||
oldCallback.invoke(window, key, scancode, action, mods);
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class KeyPressedEvent extends Event
|
||||
{
|
||||
public int key;
|
||||
public int scancode;
|
||||
|
||||
public KeyPressedEvent(int key, int scancode)
|
||||
{
|
||||
this.key = key;
|
||||
this.scancode = scancode;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,246 @@
|
|||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package tschipp.carryon.common.helper;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
/**
|
||||
* Some reflection helper code.
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class ReflectionHelper
|
||||
{
|
||||
public static class UnableToFindMethodException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
//private String[] methodNames;
|
||||
|
||||
public UnableToFindMethodException(String[] methodNames, Exception failed)
|
||||
{
|
||||
super(failed);
|
||||
//this.methodNames = methodNames;
|
||||
}
|
||||
|
||||
public UnableToFindMethodException(Throwable failed)
|
||||
{
|
||||
super(failed);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class UnableToFindClassException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
//private String[] classNames;
|
||||
|
||||
public UnableToFindClassException(String[] classNames, @Nullable Exception err)
|
||||
{
|
||||
super(err);
|
||||
//this.classNames = classNames;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class UnableToAccessFieldException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
//private String[] fieldNameList;
|
||||
|
||||
public UnableToAccessFieldException(String[] fieldNames, Exception e)
|
||||
{
|
||||
super(e);
|
||||
//this.fieldNameList = fieldNames;
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnableToFindFieldException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
//private String[] fieldNameList;
|
||||
public UnableToFindFieldException(String[] fieldNameList, Exception e)
|
||||
{
|
||||
super(e);
|
||||
//this.fieldNameList = fieldNameList;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class UnknownConstructorException extends RuntimeException
|
||||
{
|
||||
public UnknownConstructorException(final String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static Field findField(Class<?> clazz, String... fieldNames)
|
||||
{
|
||||
Exception failed = null;
|
||||
for (String fieldName : fieldNames)
|
||||
{
|
||||
try
|
||||
{
|
||||
Field f = clazz.getDeclaredField(fieldName);
|
||||
f.setAccessible(true);
|
||||
return f;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
failed = e;
|
||||
}
|
||||
}
|
||||
throw new UnableToFindFieldException(fieldNames, failed);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T, E> T getPrivateValue(Class <? super E > classToAccess, @Nullable E instance, int fieldIndex)
|
||||
{
|
||||
try
|
||||
{
|
||||
Field f = classToAccess.getDeclaredFields()[fieldIndex];
|
||||
f.setAccessible(true);
|
||||
return (T) f.get(instance);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new UnableToAccessFieldException(new String[0], e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T, E> T getPrivateValue(Class <? super E > classToAccess, E instance, String... fieldNames)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (T) findField(classToAccess, fieldNames).get(instance);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new UnableToAccessFieldException(fieldNames, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T, E> void setPrivateValue(Class <? super T > classToAccess, T instance, E value, int fieldIndex)
|
||||
{
|
||||
try
|
||||
{
|
||||
Field f = classToAccess.getDeclaredFields()[fieldIndex];
|
||||
f.setAccessible(true);
|
||||
f.set(instance, value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new UnableToAccessFieldException(new String[0] , e);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T, E> void setPrivateValue(Class <? super T > classToAccess, T instance, E value, String... fieldNames)
|
||||
{
|
||||
try
|
||||
{
|
||||
findField(classToAccess, fieldNames).set(instance, value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new UnableToAccessFieldException(fieldNames, e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Class<? super Object> getClass(ClassLoader loader, String... classNames)
|
||||
{
|
||||
Exception err = null;
|
||||
for (String className : classNames)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (Class<? super Object>) Class.forName(className, false, loader);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
err = e;
|
||||
}
|
||||
}
|
||||
|
||||
throw new UnableToFindClassException(classNames, err);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a method with the specified name and parameters in the given class and makes it accessible.
|
||||
* Note: for performance, store the returned value and avoid calling this repeatedly.
|
||||
* <p>
|
||||
* Throws an exception if the method is not found.
|
||||
*
|
||||
* @param clazz The class to find the method on.
|
||||
* @param methodName The name of the method to find (used in developer environments, i.e. "getWorldTime").
|
||||
* @param methodObfName The obfuscated name of the method to find (used in obfuscated environments, i.e. "getWorldTime").
|
||||
* If the name you are looking for is on a class that is never obfuscated, this should be null.
|
||||
* @param parameterTypes The parameter types of the method to find.
|
||||
* @return The method with the specified name and parameters in the given class.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Finds a constructor in the specified class that has matching parameter types.
|
||||
*
|
||||
* @param klass The class to find the constructor in
|
||||
* @param parameterTypes The parameter types of the constructor.
|
||||
* @param <T> The type
|
||||
* @return The constructor
|
||||
* @throws NullPointerException if {@code klass} is null
|
||||
* @throws NullPointerException if {@code parameterTypes} is null
|
||||
* @throws UnknownConstructorException if the constructor could not be found
|
||||
*/
|
||||
@Nonnull
|
||||
public static <T> Constructor<T> findConstructor(@Nonnull final Class<T> klass, @Nonnull final Class<?>... parameterTypes)
|
||||
{
|
||||
Preconditions.checkNotNull(klass, "class");
|
||||
Preconditions.checkNotNull(parameterTypes, "parameter types");
|
||||
|
||||
final Constructor<T> constructor;
|
||||
try
|
||||
{
|
||||
constructor = klass.getDeclaredConstructor(parameterTypes);
|
||||
constructor.setAccessible(true);
|
||||
}
|
||||
catch (final NoSuchMethodException e)
|
||||
{
|
||||
final StringBuilder desc = new StringBuilder();
|
||||
desc.append(klass.getSimpleName()).append('(');
|
||||
for (int i = 0, length = parameterTypes.length; i < length; i++)
|
||||
{
|
||||
desc.append(parameterTypes[i].getName());
|
||||
if (i > length)
|
||||
{
|
||||
desc.append(',').append(' ');
|
||||
}
|
||||
}
|
||||
desc.append(')');
|
||||
throw new UnknownConstructorException("Could not find constructor '" + desc.toString() + "' in " + klass);
|
||||
}
|
||||
return constructor;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ import java.lang.reflect.Method;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
|
||||
/**
|
||||
* Utility methods for reflection.
|
||||
|
|
@ -31,14 +31,14 @@ public class ReflectionUtil
|
|||
*/
|
||||
public static MethodHandle findMethod(final Class<?> clazz, final String methodName, @Nullable final String methodObfName, final Class<?>... parameterTypes)
|
||||
{
|
||||
final Method method = ReflectionHelper.findMethod(clazz, methodName, methodObfName, parameterTypes);
|
||||
final Method method = ObfuscationReflectionHelper.findMethod(clazz, methodName, parameterTypes);
|
||||
try
|
||||
{
|
||||
return MethodHandles.lookup().unreflect(method);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
throw new ReflectionHelper.UnableToFindMethodException(e);
|
||||
throw new ObfuscationReflectionHelper.UnableToFindMethodException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import java.util.Map;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.INBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.scoreboard.Score;
|
||||
|
|
@ -76,11 +76,11 @@ public class ScriptParseHelper
|
|||
return true;
|
||||
|
||||
boolean matching = true;
|
||||
for (String key : toMatch.getKeySet())
|
||||
for (String key : toMatch.keySet())
|
||||
{
|
||||
NBTBase tag = toMatch.getTag(key);
|
||||
INBTBase tag = toMatch.getTag(key);
|
||||
key = key.replace("\"", "");
|
||||
NBTBase tagToCheck = toCheck.getTag(key);
|
||||
INBTBase tagToCheck = toCheck.getTag(key);
|
||||
if (!tag.equals(tagToCheck))
|
||||
matching = false;
|
||||
}
|
||||
|
|
@ -99,17 +99,17 @@ public class ScriptParseHelper
|
|||
}
|
||||
|
||||
|
||||
public static double[] getScale(String s)
|
||||
public static double[] getscaled(String s)
|
||||
{
|
||||
double[] d = new double[3];
|
||||
d[0] = getScaleValueFromString(s, "x");
|
||||
d[1] = getScaleValueFromString(s, "y");
|
||||
d[2] = getScaleValueFromString(s, "z");
|
||||
d[0] = getscaledValueFromString(s, "x");
|
||||
d[1] = getscaledValueFromString(s, "y");
|
||||
d[2] = getscaledValueFromString(s, "z");
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
public static double getScaleValueFromString(String toGetFrom, String key)
|
||||
public static double getscaledValueFromString(String toGetFrom, String key)
|
||||
{
|
||||
if(toGetFrom == null)
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
package tschipp.carryon.common.helper;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.glfw.GLFWScrollCallback;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
//Thanks to gigaherz for the help!
|
||||
public class ScrollCallbackWrapper
|
||||
{
|
||||
GLFWScrollCallback oldCallback;
|
||||
|
||||
public void setup(Minecraft mc)
|
||||
{
|
||||
oldCallback = GLFW.glfwSetScrollCallback(mc.mainWindow.getHandle(), this::scrollCallback);
|
||||
}
|
||||
|
||||
private void scrollCallback(long window, double xoffset, double yoffset)
|
||||
{
|
||||
MouseScrolledEvent event = new MouseScrolledEvent();
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
if (event.isCanceled())
|
||||
return;
|
||||
|
||||
if (oldCallback != null)
|
||||
oldCallback.invoke(window, xoffset, yoffset);
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class MouseScrolledEvent extends Event
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -2,16 +2,16 @@ package tschipp.carryon.common.helper;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
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.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tschipp.carryon.CarryOn;
|
||||
|
||||
public class StringParser
|
||||
{
|
||||
|
|
@ -19,69 +19,26 @@ public class StringParser
|
|||
@Nullable
|
||||
public static Block getBlock(String string)
|
||||
{
|
||||
if(string == null)
|
||||
return null;
|
||||
|
||||
NBTTagCompound tag = getTagCompound(string);
|
||||
if (tag != null)
|
||||
string = string.replace(tag.toString(), "");
|
||||
|
||||
if (string.contains(";"))
|
||||
string = string.replace(string.substring(string.indexOf(";")), "");
|
||||
|
||||
Block block = Block.getBlockFromName(string);
|
||||
if (block == null)
|
||||
new InvalidConfigException("Block Parsing Error. Invalid Name: " + string).printException();
|
||||
|
||||
return block;
|
||||
IBlockState state = getBlockState(string);
|
||||
if(state != null)
|
||||
return state.getBlock();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getMeta(String string)
|
||||
{
|
||||
if(string == null)
|
||||
return 0;
|
||||
|
||||
NBTTagCompound tag = getTagCompound(string);
|
||||
if (tag != null)
|
||||
string = string.replace(tag.toString(), "");
|
||||
|
||||
if (string.contains(";"))
|
||||
{
|
||||
int meta = 0;
|
||||
try
|
||||
{
|
||||
meta = Integer.parseInt(string.substring(string.indexOf(";")).replace(";", ""));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
new InvalidConfigException("Meta Parsing Error at: " + string + " : " + e.getMessage()).printException();
|
||||
}
|
||||
|
||||
return meta;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IBlockState getBlockState(String string)
|
||||
{
|
||||
if(string == null)
|
||||
return null;
|
||||
|
||||
NBTTagCompound tag = getTagCompound(string);
|
||||
if (tag != null)
|
||||
string = string.replace(tag.toString(), "");
|
||||
|
||||
BlockStateParser parser = new BlockStateParser(new StringReader(string), false);
|
||||
|
||||
int meta = getMeta(string);
|
||||
if (meta == 0)
|
||||
{
|
||||
Block block = getBlock(string);
|
||||
if(block != null)
|
||||
return block.getDefaultState();
|
||||
}
|
||||
try
|
||||
{
|
||||
return getBlock(string).getStateFromMeta(meta);
|
||||
parser.parse(false);
|
||||
return parser.getState();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -95,15 +52,19 @@ public class StringParser
|
|||
{
|
||||
if(string == null)
|
||||
return null;
|
||||
|
||||
NBTTagCompound tag = getTagCompound(string);
|
||||
if (tag != null)
|
||||
string = string.replace(tag.toString(), "");
|
||||
|
||||
if (string.contains(";"))
|
||||
string = string.replace(string.substring(string.indexOf(";")), "");
|
||||
|
||||
return Item.getByNameOrId(string);
|
||||
|
||||
ItemParser parser = new ItemParser(new StringReader(string), false);
|
||||
|
||||
try
|
||||
{
|
||||
parser.parse();
|
||||
return parser.getItem();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
new InvalidConfigException("Item parsing Exception at: " + string + " : " + e.getMessage()).printException();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getItemStack(String string)
|
||||
|
|
@ -111,17 +72,30 @@ public class StringParser
|
|||
if(string == null)
|
||||
return null;
|
||||
|
||||
Item item = getItem(string);
|
||||
ItemParser parser = new ItemParser(new StringReader(string), false);
|
||||
|
||||
if(item == null)
|
||||
try
|
||||
{
|
||||
parser.parse();
|
||||
Item item = parser.getItem();
|
||||
NBTTagCompound nbt = parser.getNbt();
|
||||
|
||||
ItemStack stack = new ItemStack(item, 1);
|
||||
|
||||
if(nbt != null)
|
||||
{
|
||||
stack.setTag(nbt);
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
new InvalidConfigException("Item parsing Exception at: " + string + " : " + e.getMessage()).printException();
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
ItemStack stack = new ItemStack(item, 1, getMeta(string));
|
||||
NBTTagCompound tag = getTagCompound(string);
|
||||
if (tag != null)
|
||||
stack.setTagCompound(tag);
|
||||
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
@ -142,7 +116,7 @@ public class StringParser
|
|||
{
|
||||
tag = JsonToNBT.getTagFromJson(nbt);
|
||||
}
|
||||
catch (NBTException e)
|
||||
catch (Exception e)
|
||||
{
|
||||
new InvalidConfigException("Error while parsing NBT: " + e.getMessage()).printException();
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -2,15 +2,17 @@ package tschipp.carryon.common.item;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
|
|
@ -18,17 +20,15 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import tschipp.carryon.common.config.Configs.Settings;
|
||||
import tschipp.carryon.common.event.ItemEvents;
|
||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
||||
|
||||
public class ItemEntity extends Item
|
||||
{
|
||||
|
|
@ -37,28 +37,26 @@ public class ItemEntity extends Item
|
|||
|
||||
public ItemEntity()
|
||||
{
|
||||
this.setUnlocalizedName("entity_item");
|
||||
super(new Item.Properties().maxStackSize(1));
|
||||
this.setRegistryName(CarryOn.MODID, "entity_item");
|
||||
ForgeRegistries.ITEMS.register(this);
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack)
|
||||
public ITextComponent getDisplayName(ItemStack stack)
|
||||
{
|
||||
if (hasEntityData(stack))
|
||||
{
|
||||
return I18n.translateToLocal("entity."+EntityList.getTranslationName(new ResourceLocation(getEntityName(stack))) + ".name");
|
||||
if (hasEntityData(stack)) {
|
||||
|
||||
return new TextComponentTranslation(getEntityType(stack).getTranslationKey());
|
||||
}
|
||||
|
||||
return "";
|
||||
return new TextComponentString("");
|
||||
}
|
||||
|
||||
public static boolean hasEntityData(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
if (stack.hasTag())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
NBTTagCompound tag = stack.getTag();
|
||||
return tag.hasKey(ENTITY_DATA_KEY) && tag.hasKey("entity");
|
||||
}
|
||||
return false;
|
||||
|
|
@ -73,27 +71,33 @@ public class ItemEntity extends Item
|
|||
return false;
|
||||
|
||||
NBTTagCompound entityData = new NBTTagCompound();
|
||||
entityData = entity.writeToNBT(entityData);
|
||||
entityData = entity.serializeNBT();
|
||||
|
||||
String name = EntityList.getKey(entity).toString();
|
||||
String name = EntityType.getId(entity.getType()).toString();
|
||||
|
||||
NBTTagCompound tag = stack.hasTagCompound() ? stack.getTagCompound() : new NBTTagCompound();
|
||||
NBTTagCompound tag = stack.hasTag() ? stack.getTag() : new NBTTagCompound();
|
||||
if (tag.hasKey(ENTITY_DATA_KEY))
|
||||
return false;
|
||||
|
||||
tag.setTag(ENTITY_DATA_KEY, entityData);
|
||||
tag.setString("entity", name);
|
||||
stack.setTagCompound(tag);
|
||||
stack.setTag(tag);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||
public EnumActionResult onItemUse(ItemUseContext context)
|
||||
{
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
EntityPlayer player = context.getPlayer();
|
||||
World world = context.getWorld();
|
||||
BlockPos pos = context.getPos();
|
||||
EnumFacing facing = context.getFace();
|
||||
|
||||
ItemStack stack = context.getItem();
|
||||
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
|
||||
if(Loader.isModLoaded("betterplacement"))
|
||||
if(ModList.get().isLoaded("betterplacement"))
|
||||
{
|
||||
if(CarryOnKeybinds.isKeyPressed(player))
|
||||
return EnumActionResult.FAIL;
|
||||
|
|
@ -103,7 +107,7 @@ public class ItemEntity extends Item
|
|||
{
|
||||
BlockPos finalPos = pos;
|
||||
|
||||
if (!block.isReplaceable(world, pos))
|
||||
if (!state.isReplaceable(new BlockItemUseContext(context)))
|
||||
{
|
||||
finalPos = pos.offset(facing);
|
||||
}
|
||||
|
|
@ -117,10 +121,10 @@ public class ItemEntity extends Item
|
|||
world.spawnEntity(entity);
|
||||
if (entity instanceof EntityLiving)
|
||||
{
|
||||
((EntityLiving) entity).playLivingSound();
|
||||
((EntityLiving) entity).playAmbientSound();
|
||||
}
|
||||
clearEntityData(stack);
|
||||
player.setHeldItem(hand, ItemStack.EMPTY);
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY);
|
||||
ItemEvents.sendPacket(player, 9, 0);
|
||||
|
||||
}
|
||||
|
|
@ -133,7 +137,7 @@ public class ItemEntity extends Item
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected)
|
||||
public void inventoryTick(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if (hasEntityData(stack))
|
||||
{
|
||||
|
|
@ -142,7 +146,7 @@ public class ItemEntity extends Item
|
|||
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
if(entity instanceof EntityPlayer && CarryOnConfig.settings.slownessInCreative ? false : ((EntityPlayer)entity).isCreative())
|
||||
if(entity instanceof EntityPlayer && Settings.slownessInCreative.get() ? false : ((EntityPlayer)entity).isCreative())
|
||||
return;
|
||||
|
||||
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 1, potionLevel(stack, world), false, false));
|
||||
|
|
@ -157,9 +161,9 @@ public class ItemEntity extends Item
|
|||
|
||||
public static void clearEntityData(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
if (stack.hasTag())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
NBTTagCompound tag = stack.getTag();
|
||||
tag.removeTag(ENTITY_DATA_KEY);
|
||||
tag.removeTag("entity");
|
||||
}
|
||||
|
|
@ -167,10 +171,10 @@ public class ItemEntity extends Item
|
|||
|
||||
public static NBTTagCompound getEntityData(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
if (stack.hasTag())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getCompoundTag(ENTITY_DATA_KEY);
|
||||
NBTTagCompound tag = stack.getTag();
|
||||
return tag.getCompound(ENTITY_DATA_KEY);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -183,18 +187,18 @@ public class ItemEntity extends Item
|
|||
String name = getEntityName(stack);
|
||||
|
||||
NBTTagCompound e = getEntityData(stack);
|
||||
Entity entity = EntityList.createEntityByIDFromName(new ResourceLocation(name), world);
|
||||
Entity entity = EntityType.create(world, new ResourceLocation(name));
|
||||
if (entity != null)
|
||||
entity.readFromNBT(e);
|
||||
entity.deserializeNBT(e);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public static String getEntityName(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
if (stack.hasTag())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
NBTTagCompound tag = stack.getTag();
|
||||
return tag.getString("entity");
|
||||
}
|
||||
return null;
|
||||
|
|
@ -202,9 +206,9 @@ public class ItemEntity extends Item
|
|||
|
||||
public static String getCustomName(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
if (stack.hasTag())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
NBTTagCompound tag = stack.getTag();
|
||||
if (tag.hasKey("CustomName") && !tag.getString("CustomName").isEmpty()) {
|
||||
return tag.toString();
|
||||
} else {
|
||||
|
|
@ -214,6 +218,16 @@ public class ItemEntity extends Item
|
|||
return null;
|
||||
}
|
||||
|
||||
public static EntityType<?> getEntityType(ItemStack stack) {
|
||||
if (stack.hasTag()) {
|
||||
NBTTagCompound tag = stack.getTag();
|
||||
String name = tag.getString("entity");
|
||||
EntityType<?> type = EntityType.getById(name);
|
||||
return type;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private int potionLevel(ItemStack stack, World world)
|
||||
{
|
||||
Entity e = getEntity(stack, world);
|
||||
|
|
@ -224,9 +238,11 @@ public class ItemEntity extends Item
|
|||
if (i > 4)
|
||||
i = 4;
|
||||
|
||||
if (!CarryOnConfig.settings.heavyEntities)
|
||||
if (!Settings.heavyEntities.get())
|
||||
i = 1;
|
||||
|
||||
return (int) (i * CarryOnConfig.settings.entitySlownessMultiplier);
|
||||
double multiplier = Settings.entitySlownessMultiplier.get();
|
||||
|
||||
return (int) (multiplier * i);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,22 @@
|
|||
package tschipp.carryon.common.item;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.CharMatcher;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
|
@ -27,16 +25,19 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.util.text.event.ClickEvent.Action;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.event.world.BlockEvent.PlaceEvent;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import tschipp.carryon.common.config.Configs.Settings;
|
||||
import tschipp.carryon.common.event.ItemEvents;
|
||||
import tschipp.carryon.common.handler.CustomPickupOverrideHandler;
|
||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||
|
|
@ -45,18 +46,16 @@ public class ItemTile extends Item
|
|||
{
|
||||
|
||||
public static final String TILE_DATA_KEY = "tileData";
|
||||
public static final String[] FACING_KEYS = new String[] { "rotation", "rot", "facing", "face", "direction", "dir", "front" };
|
||||
public static final String[] FACING_KEYS = new String[] { "rotation", "rot", "facing", "face", "direction", "dir", "front", "forward" };
|
||||
|
||||
public ItemTile()
|
||||
{
|
||||
this.setUnlocalizedName("tile_item");
|
||||
super(new Item.Properties().maxStackSize(1));
|
||||
this.setRegistryName(CarryOn.MODID, "tile_item");
|
||||
ForgeRegistries.ITEMS.register(this);
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack)
|
||||
public ITextComponent getDisplayName(ItemStack stack)
|
||||
{
|
||||
if (hasTileData(stack))
|
||||
{
|
||||
|
|
@ -71,28 +70,31 @@ public class ItemTile extends Item
|
|||
else
|
||||
{
|
||||
IBlockState ostate = (IBlockState) override;
|
||||
ItemStack itemstack = new ItemStack(ostate.getBlock().getItemDropped(ostate, this.itemRand, 0), 1, state.getBlock().damageDropped(ostate));
|
||||
return itemstack.getDisplayName();
|
||||
return ostate.getBlock().getNameTextComponent();
|
||||
}
|
||||
}
|
||||
|
||||
return getItemStack(stack).getDisplayName();
|
||||
}
|
||||
|
||||
return "";
|
||||
return new TextComponentString("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||
public EnumActionResult onItemUse(ItemUseContext context)
|
||||
{
|
||||
if (Loader.isModLoaded("betterplacement"))
|
||||
EnumFacing facing = context.getFace();
|
||||
EntityPlayer player = context.getPlayer();
|
||||
World world = context.getWorld();
|
||||
BlockPos pos = context.getPos();
|
||||
ItemStack stack = context.getItem();
|
||||
|
||||
if (ModList.get().isLoaded("betterplacement"))
|
||||
{
|
||||
if (CarryOnKeybinds.isKeyPressed(player))
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (hasTileData(stack))
|
||||
{
|
||||
try
|
||||
|
|
@ -101,99 +103,84 @@ public class ItemTile extends Item
|
|||
EnumFacing facing2 = EnumFacing.getFacingFromVector((float) vec.x, 0f, (float) vec.z);
|
||||
BlockPos pos2 = pos;
|
||||
Block containedblock = getBlock(stack);
|
||||
int meta = getMeta(stack);
|
||||
IBlockState containedstate = getBlockState(stack);
|
||||
if (!world.getBlockState(pos2).getBlock().isReplaceable(world, pos2))
|
||||
if (!world.getBlockState(pos2).isReplaceable(new BlockItemUseContext(context)))
|
||||
{
|
||||
pos2 = pos.offset(facing);
|
||||
}
|
||||
|
||||
if (world.getBlockState(pos2).getBlock().isReplaceable(world, pos2) && containedblock != null)
|
||||
if (world.getBlockState(pos2).isReplaceable(new BlockItemUseContext(context)) && containedblock != null)
|
||||
{
|
||||
boolean canPlace = containedblock.canPlaceBlockAt(world, pos2);
|
||||
boolean canPlace = containedstate.isValidPosition(world, pos2);
|
||||
|
||||
if (canPlace)
|
||||
{
|
||||
if (player.canPlayerEdit(pos, facing, stack) && world.mayPlace(containedblock, pos2, false, facing, (Entity) null))
|
||||
if (player.canPlayerEdit(pos, facing, stack) && world.isBlockModifiable(player, pos2))
|
||||
{
|
||||
boolean set = false;
|
||||
|
||||
IBlockState actualState = containedblock.getStateForPlacement(new BlockItemUseContext(context));
|
||||
BlockSnapshot snapshot = new BlockSnapshot(world, pos2, containedstate);
|
||||
PlaceEvent event = new PlaceEvent(snapshot, world.getBlockState(pos), player, EnumHand.MAIN_HAND);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
// Handles Blockstate rotation
|
||||
Iterator<IProperty<?>> iterator = containedblock.getDefaultState().getPropertyKeys().iterator();
|
||||
while (iterator.hasNext())
|
||||
if (!event.isCanceled())
|
||||
{
|
||||
IProperty prop = iterator.next();
|
||||
Object[] allowedValues = prop.getAllowedValues().toArray();
|
||||
world.setBlockState(pos2, actualState);
|
||||
|
||||
if (prop instanceof PropertyDirection && this.equal(allowedValues, EnumFacing.HORIZONTALS))
|
||||
// If the blockstate doesn't handle rotation,
|
||||
// try to
|
||||
// change rotation via NBT
|
||||
if (!getTileData(stack).isEmpty())
|
||||
{
|
||||
world.setBlockState(pos2, containedstate.withProperty(prop, containedblock instanceof BlockStairs ? facing2 : facing2.getOpposite()));
|
||||
set = true;
|
||||
}
|
||||
else if (prop instanceof PropertyDirection && this.equal(allowedValues, EnumFacing.VALUES))
|
||||
{
|
||||
facing2 = EnumFacing.getFacingFromVector((float) vec.x, (float) vec.y, (float) vec.z);
|
||||
world.setBlockState(pos2, containedstate.withProperty(prop, facing2.getOpposite()));
|
||||
set = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If the blockstate doesn't handle rotation, try to
|
||||
// change rotation via NBT
|
||||
if (!set && !getTileData(stack).hasNoTags())
|
||||
{
|
||||
NBTTagCompound tag = getTileData(stack);
|
||||
Set<String> keys = tag.getKeySet();
|
||||
keytester:
|
||||
for (String key : keys)
|
||||
{
|
||||
for (String facingKey : FACING_KEYS)
|
||||
NBTTagCompound tag = getTileData(stack);
|
||||
Set<String> keys = tag.keySet();
|
||||
keytester: for (String key : keys)
|
||||
{
|
||||
if (key.toLowerCase().equals(facingKey))
|
||||
for (String facingKey : FACING_KEYS)
|
||||
{
|
||||
String type = tag.getTagTypeName(tag.getTagId(key));
|
||||
switch (type)
|
||||
if (key.toLowerCase().equals(facingKey))
|
||||
{
|
||||
case "TAG_String":
|
||||
tag.setString(key, facing2.getOpposite().getName());
|
||||
break;
|
||||
case "TAG_Int":
|
||||
tag.setInteger(key, facing2.getOpposite().getIndex());
|
||||
break;
|
||||
case "TAG_Byte":
|
||||
tag.setByte(key, (byte) facing2.getOpposite().getIndex());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
byte type = tag.getTagId(key);
|
||||
switch (type)
|
||||
{
|
||||
case 8:
|
||||
tag.setString(key, CharMatcher.javaUpperCase().matchesAllOf(tag.getString(key)) ? facing2.getOpposite().getName().toUpperCase() : facing2.getOpposite().getName());
|
||||
break;
|
||||
case 3:
|
||||
tag.setInt(key, facing2.getOpposite().getIndex());
|
||||
break;
|
||||
case 1:
|
||||
tag.setByte(key, (byte) facing2.getOpposite().getIndex());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break keytester;
|
||||
}
|
||||
|
||||
break keytester;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!set)
|
||||
world.setBlockState(pos2, containedstate);
|
||||
TileEntity tile = world.getTileEntity(pos2);
|
||||
if (tile != null)
|
||||
{
|
||||
tile.deserializeNBT(getTileData(stack));
|
||||
tile.setPos(pos2);
|
||||
}
|
||||
clearTileData(stack);
|
||||
player.playSound(actualState.getSoundType(world, pos2, player).getPlaceSound(), 1.0f, 0.5f);
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY);
|
||||
player.getEntityData().removeTag("overrideKey");
|
||||
ItemEvents.sendPacket(player, 9, 0);
|
||||
return EnumActionResult.SUCCESS;
|
||||
|
||||
TileEntity tile = world.getTileEntity(pos2);
|
||||
if (tile != null)
|
||||
{
|
||||
tile.readFromNBT(getTileData(stack));
|
||||
tile.setPos(pos2);
|
||||
}
|
||||
clearTileData(stack);
|
||||
player.playSound(containedblock.getSoundType().getPlaceSound(), 1.0f, 0.5f);
|
||||
player.setHeldItem(hand, ItemStack.EMPTY);
|
||||
player.getEntityData().removeTag("overrideKey");
|
||||
ItemEvents.sendPacket(player, 9, 0);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
|
||||
|
|
@ -201,7 +188,7 @@ public class ItemTile extends Item
|
|||
{
|
||||
CarryOn.LOGGER.info("Block: " + ItemTile.getBlock(stack));
|
||||
CarryOn.LOGGER.info("BlockState: " + ItemTile.getBlockState(stack));
|
||||
CarryOn.LOGGER.info("Meta: " + ItemTile.getMeta(stack));
|
||||
// CarryOn.LOGGER.info("Meta: " + ItemTile.getMeta(stack));
|
||||
CarryOn.LOGGER.info("ItemStack: " + ItemTile.getItemStack(stack));
|
||||
|
||||
if (ModelOverridesHandler.hasCustomOverrideModel(ItemTile.getBlockState(stack), ItemTile.getTileData(stack)))
|
||||
|
|
@ -224,19 +211,18 @@ public class ItemTile extends Item
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected)
|
||||
public void inventoryTick(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if (hasTileData(stack))
|
||||
{
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
if (entity instanceof EntityPlayer && CarryOnConfig.settings.slownessInCreative ? false : ((EntityPlayer) entity).isCreative())
|
||||
if (entity instanceof EntityPlayer && Settings.slownessInCreative.get() ? false : ((EntityPlayer) entity).isCreative())
|
||||
return;
|
||||
|
||||
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 1, potionLevel(stack), false, false));
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
stack = ItemStack.EMPTY;
|
||||
}
|
||||
|
|
@ -244,10 +230,10 @@ public class ItemTile extends Item
|
|||
|
||||
public static boolean hasTileData(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
if (stack.hasTag())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.hasKey(TILE_DATA_KEY) && tag.hasKey("block") && tag.hasKey("meta") && tag.hasKey("stateid");
|
||||
NBTTagCompound tag = stack.getTag();
|
||||
return tag.hasKey(TILE_DATA_KEY) && tag.hasKey("block") && tag.hasKey("stateid");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -259,79 +245,78 @@ public class ItemTile extends Item
|
|||
|
||||
NBTTagCompound chest = new NBTTagCompound();
|
||||
if (tile != null)
|
||||
chest = tile.writeToNBT(chest);
|
||||
chest = tile.write(chest);
|
||||
|
||||
NBTTagCompound tag = stack.hasTagCompound() ? stack.getTagCompound() : new NBTTagCompound();
|
||||
NBTTagCompound tag = stack.hasTag() ? stack.getTag() : new NBTTagCompound();
|
||||
if (tag.hasKey(TILE_DATA_KEY))
|
||||
return false;
|
||||
|
||||
tag.setTag(TILE_DATA_KEY, chest);
|
||||
|
||||
ItemStack drop = new ItemStack(state.getBlock().getItemDropped(state, itemRand, 0), 1, state.getBlock().damageDropped(state));
|
||||
// ItemStack drop = new ItemStack(state.getBlock().getItemDropped(state, itemRand, 0), 1, state.getBlock().damageDropped(state));
|
||||
|
||||
tag.setString("block", state.getBlock().getRegistryName().toString());
|
||||
Item item = Item.getItemFromBlock(state.getBlock());
|
||||
tag.setInteger("meta", drop.getItemDamage());
|
||||
tag.setInteger("stateid", Block.getStateId(state));
|
||||
stack.setTagCompound(tag);
|
||||
// Item item = Item.getItemFromBlock(state.getBlock());
|
||||
// tag.setInt("meta", drop.getItemDamage());
|
||||
tag.setInt("stateid", Block.getStateId(state));
|
||||
stack.setTag(tag);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void clearTileData(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
if (stack.hasTag())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
NBTTagCompound tag = stack.getTag();
|
||||
tag.removeTag(TILE_DATA_KEY);
|
||||
tag.removeTag("block");
|
||||
tag.removeTag("meta");
|
||||
tag.removeTag("stateid");
|
||||
}
|
||||
}
|
||||
|
||||
public static NBTTagCompound getTileData(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
if (stack.hasTag())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getCompoundTag(TILE_DATA_KEY);
|
||||
NBTTagCompound tag = stack.getTag();
|
||||
return tag.getCompound(TILE_DATA_KEY);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Block getBlock(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
if (stack.hasTag())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
int id = tag.getInteger("stateid");
|
||||
NBTTagCompound tag = stack.getTag();
|
||||
int id = tag.getInt("stateid");
|
||||
return Block.getStateById(id).getBlock();
|
||||
}
|
||||
return Blocks.AIR;
|
||||
}
|
||||
|
||||
public static int getMeta(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
int meta = tag.getInteger("meta");
|
||||
return meta;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
// public static int getMeta(ItemStack stack)
|
||||
// {
|
||||
// if (stack.hasTag())
|
||||
// {
|
||||
// NBTTagCompound tag = stack.getTag();
|
||||
// int meta = tag.getInt("meta");
|
||||
// return meta;
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
public static ItemStack getItemStack(ItemStack stack)
|
||||
{
|
||||
return new ItemStack(getBlock(stack), 1, getMeta(stack));
|
||||
return new ItemStack(getBlock(stack), 1);
|
||||
}
|
||||
|
||||
public static IBlockState getBlockState(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
if (stack.hasTag())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
int id = tag.getInteger("stateid");
|
||||
NBTTagCompound tag = stack.getTag();
|
||||
int id = tag.getInt("stateid");
|
||||
return Block.getStateById(id);
|
||||
}
|
||||
return Blocks.AIR.getDefaultState();
|
||||
|
|
@ -343,23 +328,23 @@ public class ItemTile extends Item
|
|||
if (te != null)
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
te.writeToNBT(tag);
|
||||
te.write(tag);
|
||||
return tag.hasKey("Lock") ? !tag.getString("Lock").equals("") : false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean equal(Object[] a, Object[] b)
|
||||
{
|
||||
if (a.length != b.length)
|
||||
return false;
|
||||
|
||||
List lA = Arrays.asList(a);
|
||||
List lB = Arrays.asList(b);
|
||||
|
||||
return lA.containsAll(lB);
|
||||
}
|
||||
// private boolean equal(Object[] a, Object[] b)
|
||||
// {
|
||||
// if (a.length != b.length)
|
||||
// return false;
|
||||
//
|
||||
// List lA = Arrays.asList(a);
|
||||
// List lB = Arrays.asList(b);
|
||||
//
|
||||
// return lA.containsAll(lB);
|
||||
// }
|
||||
|
||||
private int potionLevel(ItemStack stack)
|
||||
{
|
||||
|
|
@ -369,9 +354,9 @@ public class ItemTile extends Item
|
|||
if (i > 4)
|
||||
i = 4;
|
||||
|
||||
if (!CarryOnConfig.settings.heavyTiles)
|
||||
if (!Settings.heavyTiles.get())
|
||||
i = 1;
|
||||
|
||||
return (int) (i * CarryOnConfig.settings.blockSlownessMultiplier);
|
||||
return (int) (i * Settings.blockSlownessMultiplier.get());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ public class CarryOnOverride
|
|||
{
|
||||
// BLOCKS
|
||||
private NBTTagCompound typeBlockTag;
|
||||
private String typeMeta;
|
||||
private String typeNameBlock;
|
||||
private String typeMaterial;
|
||||
private String typeHardness;
|
||||
|
|
@ -31,11 +30,10 @@ public class CarryOnOverride
|
|||
// RENDER
|
||||
private String renderNameBlock;
|
||||
private String renderNameEntity;
|
||||
private int renderMeta;
|
||||
private NBTTagCompound renderNBT;
|
||||
private String renderTranslation;
|
||||
private String renderRotation;
|
||||
private String renderScale;
|
||||
private String renderscaled;
|
||||
private String renderRotationLeftArm;
|
||||
private String renderRotationRightArm;
|
||||
private boolean renderLeftArm = true;
|
||||
|
|
@ -236,8 +234,6 @@ public class CarryOnOverride
|
|||
return false;
|
||||
if (renderLeftArm != other.renderLeftArm)
|
||||
return false;
|
||||
if (renderMeta != other.renderMeta)
|
||||
return false;
|
||||
if (renderNBT == null)
|
||||
{
|
||||
if (other.renderNBT != null)
|
||||
|
|
@ -282,12 +278,12 @@ public class CarryOnOverride
|
|||
}
|
||||
else if (!renderRotationRightArm.equals(other.renderRotationRightArm))
|
||||
return false;
|
||||
if (renderScale == null)
|
||||
if (renderscaled == null)
|
||||
{
|
||||
if (other.renderScale != null)
|
||||
if (other.renderscaled != null)
|
||||
return false;
|
||||
}
|
||||
else if (!renderScale.equals(other.renderScale))
|
||||
else if (!renderscaled.equals(other.renderscaled))
|
||||
return false;
|
||||
if (renderTranslation == null)
|
||||
{
|
||||
|
|
@ -338,13 +334,6 @@ public class CarryOnOverride
|
|||
}
|
||||
else if (!typeMaterial.equals(other.typeMaterial))
|
||||
return false;
|
||||
if (typeMeta == null)
|
||||
{
|
||||
if (other.typeMeta != null)
|
||||
return false;
|
||||
}
|
||||
else if (!typeMeta.equals(other.typeMeta))
|
||||
return false;
|
||||
if (typeNameBlock == null)
|
||||
{
|
||||
if (other.typeNameBlock != null)
|
||||
|
|
@ -403,11 +392,6 @@ public class CarryOnOverride
|
|||
return typeBlockTag;
|
||||
}
|
||||
|
||||
public String getTypeMeta()
|
||||
{
|
||||
return typeMeta;
|
||||
}
|
||||
|
||||
public String getTypeNameBlock()
|
||||
{
|
||||
return typeNameBlock;
|
||||
|
|
@ -493,11 +477,6 @@ public class CarryOnOverride
|
|||
return renderNameEntity;
|
||||
}
|
||||
|
||||
public int getRenderMeta()
|
||||
{
|
||||
return renderMeta;
|
||||
}
|
||||
|
||||
public NBTTagCompound getRenderNBT()
|
||||
{
|
||||
return renderNBT;
|
||||
|
|
@ -513,9 +492,9 @@ public class CarryOnOverride
|
|||
return renderRotation;
|
||||
}
|
||||
|
||||
public String getRenderScale()
|
||||
public String getRenderscaled()
|
||||
{
|
||||
return renderScale;
|
||||
return renderscaled;
|
||||
}
|
||||
|
||||
public void setTypeBlockTag(NBTTagCompound typeBlockTag)
|
||||
|
|
@ -523,10 +502,6 @@ public class CarryOnOverride
|
|||
this.typeBlockTag = typeBlockTag;
|
||||
}
|
||||
|
||||
public void setTypeMeta(String typeMeta)
|
||||
{
|
||||
this.typeMeta = typeMeta;
|
||||
}
|
||||
|
||||
public void setTypeNameBlock(String typeNameBlock)
|
||||
{
|
||||
|
|
@ -613,11 +588,6 @@ public class CarryOnOverride
|
|||
this.renderNameEntity = renderNameEntity;
|
||||
}
|
||||
|
||||
public void setRenderMeta(int renderMeta)
|
||||
{
|
||||
this.renderMeta = renderMeta;
|
||||
}
|
||||
|
||||
public void setRenderNBT(NBTTagCompound renderNBT)
|
||||
{
|
||||
this.renderNBT = renderNBT;
|
||||
|
|
@ -633,9 +603,9 @@ public class CarryOnOverride
|
|||
this.renderRotation = renderRotation;
|
||||
}
|
||||
|
||||
public void setRenderScale(String renderScale)
|
||||
public void setRenderscaled(String renderscaled)
|
||||
{
|
||||
this.renderScale = renderScale;
|
||||
this.renderscaled = renderscaled;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
|
@ -18,10 +17,9 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import tschipp.carryon.common.config.Configs.Settings;
|
||||
import tschipp.carryon.common.handler.ListHandler;
|
||||
import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||
|
||||
|
|
@ -30,17 +28,17 @@ public class ScriptChecker
|
|||
@Nullable
|
||||
public static CarryOnOverride inspectBlock(IBlockState state, World world, BlockPos pos, @Nullable NBTTagCompound tag)
|
||||
{
|
||||
if (!CarryOnConfig.settings.useScripts)
|
||||
if (!Settings.useScripts.get())
|
||||
return null;
|
||||
|
||||
Block block = state.getBlock();
|
||||
int meta = block.getMetaFromState(state);
|
||||
Material material = state.getMaterial();
|
||||
float hardness = state.getBlockHardness(world, pos);
|
||||
float resistance = block.getExplosionResistance(null);
|
||||
@SuppressWarnings("deprecation")
|
||||
float resistance = block.getExplosionResistance();
|
||||
NBTTagCompound nbt = tag;
|
||||
|
||||
boolean isAllowed = CarryOnConfig.settings.useWhitelistBlocks ? ListHandler.isAllowed(block) : !ListHandler.isForbidden(block);
|
||||
boolean isAllowed = Settings.useWhitelistBlocks.get() ? ListHandler.isAllowed(block) : !ListHandler.isForbidden(block);
|
||||
|
||||
if (isAllowed)
|
||||
{
|
||||
|
|
@ -48,7 +46,7 @@ public class ScriptChecker
|
|||
{
|
||||
if (override.isBlock())
|
||||
{
|
||||
if (matchesAll(override, block, meta, material, hardness, resistance, nbt))
|
||||
if (matchesAll(override, block, material, hardness, resistance, nbt))
|
||||
return override;
|
||||
}
|
||||
}
|
||||
|
|
@ -60,17 +58,17 @@ public class ScriptChecker
|
|||
@Nullable
|
||||
public static CarryOnOverride inspectEntity(Entity entity)
|
||||
{
|
||||
if (!CarryOnConfig.settings.useScripts)
|
||||
if (!Settings.useScripts.get())
|
||||
return null;
|
||||
|
||||
String name = EntityList.getKey(entity).toString();
|
||||
String name = entity.getType().getRegistryName().toString();
|
||||
float height = entity.height;
|
||||
float width = entity.width;
|
||||
float health = entity instanceof EntityLivingBase ? ((EntityLivingBase) entity).getHealth() : 0.0f;
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
entity.writeToNBT(tag);
|
||||
entity.deserializeNBT(tag);
|
||||
|
||||
boolean isAllowed = CarryOnConfig.settings.useWhitelistEntities ? ListHandler.isAllowed(entity) : !ListHandler.isForbidden(entity);
|
||||
boolean isAllowed = Settings.useWhitelistEntities.get() ? ListHandler.isAllowed(entity) : !ListHandler.isForbidden(entity);
|
||||
|
||||
if (isAllowed)
|
||||
{
|
||||
|
|
@ -98,27 +96,26 @@ public class ScriptChecker
|
|||
return (matchname && matchheight && matchwidth && matchhealth && matchnbt);
|
||||
}
|
||||
|
||||
public static boolean matchesAll(CarryOnOverride override, Block block, int meta, Material material, float hardness, float resistance, NBTTagCompound nbt)
|
||||
public static boolean matchesAll(CarryOnOverride override, Block block, Material material, float hardness, float resistance, NBTTagCompound nbt)
|
||||
{
|
||||
boolean matchnbt = ScriptParseHelper.matches(nbt, override.getTypeBlockTag());
|
||||
boolean matchblock = ScriptParseHelper.matches(block, override.getTypeNameBlock());
|
||||
boolean matchmeta = ScriptParseHelper.matches(meta, override.getTypeMeta());
|
||||
boolean matchmaterial = ScriptParseHelper.matches(material, override.getTypeMaterial());
|
||||
boolean matchhardness = ScriptParseHelper.matches(hardness, override.getTypeHardness());
|
||||
boolean matchresistance = ScriptParseHelper.matches(resistance, override.getTypeResistance());
|
||||
|
||||
return (matchnbt && matchblock && matchmeta && matchmaterial && matchhardness && matchresistance);
|
||||
return (matchnbt && matchblock && matchmaterial && matchhardness && matchresistance);
|
||||
}
|
||||
|
||||
public static boolean fulfillsConditions(CarryOnOverride override, EntityPlayer player)
|
||||
{
|
||||
AdvancementManager manager = ((WorldServer) ((EntityPlayerMP) player).world).getAdvancementManager();
|
||||
AdvancementManager manager = ((EntityPlayerMP) player).server.getAdvancementManager();
|
||||
Advancement adv = manager.getAdvancement(new ResourceLocation((override.getConditionAchievement()) == null ? "" : override.getConditionAchievement()));
|
||||
|
||||
boolean achievement = adv == null ? true : ((EntityPlayerMP) player).getAdvancements().getProgress(adv).isDone();
|
||||
boolean gamemode = ScriptParseHelper.matches(((EntityPlayerMP) player).interactionManager.getGameType().getID(), override.getConditionGamemode());
|
||||
boolean gamestage = true;
|
||||
if (Loader.isModLoaded("gamestages"))
|
||||
if (ModList.get().isLoaded("gamestages"))
|
||||
{
|
||||
if (override.getConditionGamestage() != null)
|
||||
{
|
||||
|
|
@ -127,8 +124,8 @@ public class ScriptChecker
|
|||
Class<?> gameStageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper");
|
||||
Class<?> iStageData = Class.forName("net.darkhax.gamestages.data.IStageData");
|
||||
|
||||
Method getPlayerData = ReflectionHelper.findMethod(gameStageHelper, "getPlayerData", null, EntityPlayer.class);
|
||||
Method hasStage = ReflectionHelper.findMethod(iStageData, "hasStage", null, String.class);
|
||||
Method getPlayerData = ObfuscationReflectionHelper.findMethod(gameStageHelper, "getPlayerData", EntityPlayer.class);
|
||||
Method hasStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasStage", String.class);
|
||||
|
||||
Object stageData = getPlayerData.invoke(null, player);
|
||||
String condition = override.getConditionGamestage();
|
||||
|
|
@ -141,8 +138,8 @@ public class ScriptChecker
|
|||
Class<?> playerDataHandler = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler");
|
||||
Class<?> iStageData = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler$IStageData");
|
||||
|
||||
Method getStageData = ReflectionHelper.findMethod(playerDataHandler, "getStageData", null, EntityPlayer.class);
|
||||
Method hasUnlockedStage = ReflectionHelper.findMethod(iStageData, "hasUnlockedStage", null, String.class);
|
||||
Method getStageData = ObfuscationReflectionHelper.findMethod(playerDataHandler, "getStageData", EntityPlayer.class);
|
||||
Method hasUnlockedStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasUnlockedStage", String.class);
|
||||
|
||||
Object stageData = getStageData.invoke(null, player);
|
||||
String condition = override.getConditionGamestage();
|
||||
|
|
@ -172,7 +169,7 @@ public class ScriptChecker
|
|||
|
||||
if (tag != null && tag.hasKey("overrideKey"))
|
||||
{
|
||||
int key = tag.getInteger("overrideKey");
|
||||
int key = tag.getInt("overrideKey");
|
||||
|
||||
return ScriptReader.OVERRIDES.get(key);
|
||||
}
|
||||
|
|
@ -185,7 +182,7 @@ public class ScriptChecker
|
|||
NBTTagCompound tag = player.getEntityData();
|
||||
|
||||
if (tag != null)
|
||||
tag.setInteger("overrideKey", i);
|
||||
tag.setInt("overrideKey", i);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +1,33 @@
|
|||
package tschipp.carryon.common.scripting;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonIOException;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import tschipp.carryon.common.config.Configs.Settings;
|
||||
|
||||
public class ScriptReader
|
||||
{
|
||||
private static ArrayList<File> scripts = new ArrayList<File>();
|
||||
public static HashMap<Integer, CarryOnOverride> OVERRIDES = new HashMap<Integer, CarryOnOverride>();
|
||||
|
||||
//public static HashSet<CarryOnOverride> OVERRIDES = new HashSet<CarryOnOverride>();
|
||||
|
||||
public static void preInit(FMLPreInitializationEvent event)
|
||||
// public static HashSet<CarryOnOverride> OVERRIDES = new
|
||||
// HashSet<CarryOnOverride>();
|
||||
|
||||
public static void preInit()
|
||||
{
|
||||
CarryOn.CONFIGURATION_FILE = new File(event.getModConfigurationDirectory(), "carryon-scripts/");
|
||||
scripts.clear();
|
||||
|
||||
CarryOn.CONFIGURATION_FILE = new File(FMLPaths.CONFIGDIR.get().toString(), "/carryon-scripts/");
|
||||
|
||||
if (!CarryOn.CONFIGURATION_FILE.exists())
|
||||
CarryOn.CONFIGURATION_FILE.mkdir();
|
||||
|
||||
|
|
@ -41,183 +39,180 @@ public class ScriptReader
|
|||
|
||||
}
|
||||
|
||||
public static void parseScripts() throws JsonIOException, JsonSyntaxException, FileNotFoundException, NBTException
|
||||
public static void parseScripts()
|
||||
{
|
||||
if(!CarryOnConfig.settings.useScripts)
|
||||
return;
|
||||
|
||||
for (File file : scripts)
|
||||
OVERRIDES.clear();
|
||||
|
||||
try
|
||||
{
|
||||
boolean errored = false;
|
||||
int hash = file.getAbsolutePath().hashCode();
|
||||
if (!Settings.useScripts.get())
|
||||
return;
|
||||
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonObject json = (JsonObject) parser.parse(new FileReader(file.getAbsolutePath()));
|
||||
|
||||
JsonObject object = (JsonObject) json.get("object");
|
||||
JsonObject conditions = (JsonObject) json.get("conditions");
|
||||
JsonObject render = (JsonObject) json.get("render");
|
||||
JsonObject effects = (JsonObject) json.get("effects");
|
||||
|
||||
if ((object != null && conditions != null) || (object != null && render != null) || (object != null && effects != null))
|
||||
for (File file : scripts)
|
||||
{
|
||||
JsonObject block = (JsonObject) object.get("block");
|
||||
JsonObject entity = (JsonObject) object.get("entity");
|
||||
boolean errored = false;
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonObject json = (JsonObject) parser.parse(new FileReader(file.getAbsolutePath()));
|
||||
|
||||
if ((block == null && entity == null) || (block != null && entity != null))
|
||||
errored = true;
|
||||
|
||||
if (!errored)
|
||||
JsonObject object = (JsonObject) json.get("object");
|
||||
JsonObject conditions = (JsonObject) json.get("conditions");
|
||||
JsonObject render = (JsonObject) json.get("render");
|
||||
JsonObject effects = (JsonObject) json.get("effects");
|
||||
|
||||
if ((object != null && conditions != null) || (object != null && render != null) || (object != null && effects != null))
|
||||
{
|
||||
CarryOnOverride override = new CarryOnOverride(file.getAbsolutePath());
|
||||
|
||||
if (block != null)
|
||||
JsonObject block = (JsonObject) object.get("block");
|
||||
JsonObject entity = (JsonObject) object.get("entity");
|
||||
|
||||
if ((block == null && entity == null) || (block != null && entity != null))
|
||||
errored = true;
|
||||
|
||||
if (!errored)
|
||||
{
|
||||
override.setBlock(true);
|
||||
JsonElement name = block.get("name");
|
||||
JsonElement meta = block.get("meta");
|
||||
JsonElement material = block.get("material");
|
||||
JsonElement hardness = block.get("hardness");
|
||||
JsonElement resistance = block.get("resistance");
|
||||
JsonObject nbt = (JsonObject) block.get("nbt");
|
||||
CarryOnOverride override = new CarryOnOverride(file.getAbsolutePath());
|
||||
|
||||
if (name != null)
|
||||
override.setTypeNameBlock(name.getAsString());
|
||||
if (meta != null)
|
||||
override.setTypeMeta(meta.getAsString());
|
||||
if (material != null)
|
||||
override.setTypeMaterial(material.getAsString());
|
||||
if (hardness != null)
|
||||
override.setTypeHardness(hardness.getAsString());
|
||||
if (resistance != null)
|
||||
override.setTypeResistance(resistance.getAsString());
|
||||
if (nbt != null)
|
||||
override.setTypeBlockTag(JsonToNBT.getTagFromJson(nbt.toString()));
|
||||
if (block != null)
|
||||
{
|
||||
override.setBlock(true);
|
||||
JsonElement name = block.get("name");
|
||||
JsonElement material = block.get("material");
|
||||
JsonElement hardness = block.get("hardness");
|
||||
JsonElement resistance = block.get("resistance");
|
||||
JsonObject nbt = (JsonObject) block.get("nbt");
|
||||
|
||||
if (name != null)
|
||||
override.setTypeNameBlock(name.getAsString());
|
||||
if (material != null)
|
||||
override.setTypeMaterial(material.getAsString());
|
||||
if (hardness != null)
|
||||
override.setTypeHardness(hardness.getAsString());
|
||||
if (resistance != null)
|
||||
override.setTypeResistance(resistance.getAsString());
|
||||
if (nbt != null)
|
||||
override.setTypeBlockTag(JsonToNBT.getTagFromJson(nbt.toString()));
|
||||
} else
|
||||
{
|
||||
override.setEntity(true);
|
||||
JsonElement name = entity.get("name");
|
||||
JsonElement health = entity.get("health");
|
||||
JsonElement height = entity.get("height");
|
||||
JsonElement width = entity.get("width");
|
||||
JsonObject nbt = (JsonObject) entity.get("nbt");
|
||||
|
||||
if (name != null)
|
||||
override.setTypeNameEntity(name.getAsString());
|
||||
if (health != null)
|
||||
override.setTypeHealth(health.getAsString());
|
||||
if (height != null)
|
||||
override.setTypeHeight(height.getAsString());
|
||||
if (width != null)
|
||||
override.setTypeWidth(width.getAsString());
|
||||
if (nbt != null)
|
||||
override.setTypeEntityTag(JsonToNBT.getTagFromJson(nbt.toString()));
|
||||
}
|
||||
|
||||
if (conditions != null)
|
||||
{
|
||||
JsonElement gamestage = conditions.get("gamestage");
|
||||
JsonElement achievement = conditions.get("advancement");
|
||||
JsonElement xp = conditions.get("xp");
|
||||
JsonElement gamemode = conditions.get("gamemode");
|
||||
JsonElement scoreboard = conditions.get("scoreboard");
|
||||
JsonElement position = conditions.get("position");
|
||||
JsonElement potionEffects = conditions.get("effects");
|
||||
|
||||
if (gamestage != null)
|
||||
override.setConditionGamestage(gamestage.getAsString());
|
||||
if (achievement != null)
|
||||
override.setConditionAchievement(achievement.getAsString());
|
||||
if (xp != null)
|
||||
override.setConditionXp(xp.getAsString());
|
||||
if (gamemode != null)
|
||||
override.setConditionGamemode(gamemode.getAsString());
|
||||
if (scoreboard != null)
|
||||
override.setConditionScoreboard(scoreboard.getAsString());
|
||||
if (position != null)
|
||||
override.setConditionPosition(position.getAsString());
|
||||
if (potionEffects != null)
|
||||
override.setConditionEffects(potionEffects.getAsString());
|
||||
}
|
||||
|
||||
if (render != null)
|
||||
{
|
||||
JsonElement name_block = render.get("name_block");
|
||||
JsonElement name_entity = render.get("name_entity");
|
||||
JsonObject nbt = (JsonObject) render.get("nbt");
|
||||
JsonElement translation = render.get("translation");
|
||||
JsonElement rotation = render.get("rotation");
|
||||
JsonElement scaled = render.get("scaled");
|
||||
JsonElement rotationLeftArm = render.get("rotation_left_arm");
|
||||
JsonElement rotationRightArm = render.get("rotation_right_arm");
|
||||
JsonElement renderLeftArm = render.get("render_left_arm");
|
||||
JsonElement renderRightArm = render.get("render_right_arm");
|
||||
|
||||
if (name_block != null)
|
||||
override.setRenderNameBlock(name_block.getAsString());
|
||||
if (name_entity != null)
|
||||
override.setRenderNameEntity(name_entity.getAsString());
|
||||
if (translation != null)
|
||||
override.setRenderTranslation(translation.getAsString());
|
||||
if (rotation != null)
|
||||
override.setRenderRotation(rotation.getAsString());
|
||||
if (scaled != null)
|
||||
override.setRenderscaled(scaled.getAsString());
|
||||
if (nbt != null)
|
||||
override.setRenderNBT(JsonToNBT.getTagFromJson(nbt.toString()));
|
||||
if (rotationLeftArm != null)
|
||||
override.setRenderRotationLeftArm(rotationLeftArm.getAsString());
|
||||
if (rotationRightArm != null)
|
||||
override.setRenderRotationRightArm(rotationRightArm.getAsString());
|
||||
if (renderLeftArm != null)
|
||||
override.setRenderLeftArm(renderLeftArm.getAsBoolean());
|
||||
if (renderRightArm != null)
|
||||
override.setRenderRightArm(renderRightArm.getAsBoolean());
|
||||
}
|
||||
|
||||
if (effects != null)
|
||||
{
|
||||
JsonElement commandInit = effects.get("commandPickup");
|
||||
JsonElement commandLoop = effects.get("commandLoop");
|
||||
JsonElement commandPlace = effects.get("commandPlace");
|
||||
|
||||
if (commandInit != null)
|
||||
override.setCommandInit(commandInit.getAsString());
|
||||
if (commandLoop != null)
|
||||
override.setCommandLoop(commandLoop.getAsString());
|
||||
if (commandPlace != null)
|
||||
override.setCommandPlace(commandPlace.getAsString());
|
||||
}
|
||||
|
||||
OVERRIDES.put(override.hashCode(), override);
|
||||
}
|
||||
else
|
||||
{
|
||||
override.setEntity(true);
|
||||
JsonElement name = entity.get("name");
|
||||
JsonElement health = entity.get("health");
|
||||
JsonElement height = entity.get("height");
|
||||
JsonElement width = entity.get("width");
|
||||
JsonObject nbt = (JsonObject) entity.get("nbt");
|
||||
|
||||
if (name != null)
|
||||
override.setTypeNameEntity(name.getAsString());
|
||||
if (health != null)
|
||||
override.setTypeHealth(health.getAsString());
|
||||
if (height != null)
|
||||
override.setTypeHeight(height.getAsString());
|
||||
if (width != null)
|
||||
override.setTypeWidth(width.getAsString());
|
||||
if (nbt != null)
|
||||
override.setTypeEntityTag(JsonToNBT.getTagFromJson(nbt.toString()));
|
||||
}
|
||||
|
||||
if (conditions != null)
|
||||
{
|
||||
JsonElement gamestage = conditions.get("gamestage");
|
||||
JsonElement achievement = conditions.get("advancement");
|
||||
JsonElement xp = conditions.get("xp");
|
||||
JsonElement gamemode = conditions.get("gamemode");
|
||||
JsonElement scoreboard = conditions.get("scoreboard");
|
||||
JsonElement position = conditions.get("position");
|
||||
JsonElement potionEffects = conditions.get("effects");
|
||||
|
||||
if(gamestage != null)
|
||||
override.setConditionGamestage(gamestage.getAsString());
|
||||
if(achievement != null)
|
||||
override.setConditionAchievement(achievement.getAsString());
|
||||
if(xp != null)
|
||||
override.setConditionXp(xp.getAsString());
|
||||
if(gamemode != null)
|
||||
override.setConditionGamemode(gamemode.getAsString());
|
||||
if(scoreboard != null)
|
||||
override.setConditionScoreboard(scoreboard.getAsString());
|
||||
if(position != null)
|
||||
override.setConditionPosition(position.getAsString());
|
||||
if(potionEffects != null)
|
||||
override.setConditionEffects(potionEffects.getAsString());
|
||||
}
|
||||
|
||||
if (render != null)
|
||||
{
|
||||
JsonElement name_block = render.get("name_block");
|
||||
JsonElement name_entity = render.get("name_entity");
|
||||
JsonElement meta = render.get("meta");
|
||||
JsonObject nbt = (JsonObject) render.get("nbt");
|
||||
JsonElement translation = render.get("translation");
|
||||
JsonElement rotation = render.get("rotation");
|
||||
JsonElement scale = render.get("scale");
|
||||
JsonElement rotationLeftArm = render.get("rotation_left_arm");
|
||||
JsonElement rotationRightArm = render.get("rotation_right_arm");
|
||||
JsonElement renderLeftArm = render.get("render_left_arm");
|
||||
JsonElement renderRightArm = render.get("render_right_arm");
|
||||
|
||||
if(name_block != null)
|
||||
override.setRenderNameBlock(name_block.getAsString());
|
||||
if(name_entity != null)
|
||||
override.setRenderNameEntity(name_entity.getAsString());
|
||||
if(meta != null)
|
||||
override.setRenderMeta(meta.getAsInt());
|
||||
if(translation != null)
|
||||
override.setRenderTranslation(translation.getAsString());
|
||||
if(rotation != null)
|
||||
override.setRenderRotation(rotation.getAsString());
|
||||
if(scale != null)
|
||||
override.setRenderScale(scale.getAsString());
|
||||
if (nbt != null)
|
||||
override.setRenderNBT(JsonToNBT.getTagFromJson(nbt.toString()));
|
||||
if(rotationLeftArm != null)
|
||||
override.setRenderRotationLeftArm(rotationLeftArm.getAsString());
|
||||
if(rotationRightArm != null)
|
||||
override.setRenderRotationRightArm(rotationRightArm.getAsString());
|
||||
if(renderLeftArm != null)
|
||||
override.setRenderLeftArm(renderLeftArm.getAsBoolean());
|
||||
if(renderRightArm != null)
|
||||
override.setRenderRightArm(renderRightArm.getAsBoolean());
|
||||
}
|
||||
|
||||
if(effects != null)
|
||||
{
|
||||
JsonElement commandInit = effects.get("commandPickup");
|
||||
JsonElement commandLoop = effects.get("commandLoop");
|
||||
JsonElement commandPlace = effects.get("commandPlace");
|
||||
|
||||
if(commandInit != null)
|
||||
override.setCommandInit(commandInit.getAsString());
|
||||
if(commandLoop != null)
|
||||
override.setCommandLoop(commandLoop.getAsString());
|
||||
if(commandPlace != null)
|
||||
override.setCommandPlace(commandPlace.getAsString());
|
||||
}
|
||||
|
||||
OVERRIDES.put(override.hashCode(), override);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Successfully parsed scripts!");
|
||||
} catch (Exception e)
|
||||
{
|
||||
CarryOn.LOGGER.error(e);
|
||||
}
|
||||
|
||||
System.out.println("Successfully parsed scripts!");
|
||||
}
|
||||
|
||||
|
||||
public static void reloadScripts()
|
||||
{
|
||||
scripts.clear();
|
||||
OVERRIDES.clear();
|
||||
|
||||
|
||||
for (File file : CarryOn.CONFIGURATION_FILE.listFiles())
|
||||
{
|
||||
if (file.getName().endsWith(".json"))
|
||||
scripts.add(file);
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
parseScripts();
|
||||
}
|
||||
catch (JsonIOException | JsonSyntaxException | FileNotFoundException | NBTException e)
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,104 +1,79 @@
|
|||
package tschipp.carryon.compat.obfuscate;
|
||||
|
||||
import com.mrcrayfish.obfuscate.client.event.ModelPlayerEvent;
|
||||
|
||||
import net.minecraft.client.model.ModelPlayer;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||
import tschipp.carryon.common.item.ItemEntity;
|
||||
import tschipp.carryon.common.item.ItemTile;
|
||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
|
||||
public class ObfuscateEvents
|
||||
{
|
||||
|
||||
@SubscribeEvent
|
||||
public void preModelPlayerEvent(ModelPlayerEvent.SetupAngles.Post event)
|
||||
{
|
||||
if(!CarryOnConfig.settings.renderArms)
|
||||
return;
|
||||
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
float partialticks = event.getPartialTicks();
|
||||
|
||||
ModelPlayer model = event.getModelPlayer();
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))
|
||||
{
|
||||
|
||||
float rotation = 0;
|
||||
|
||||
if (player.isRiding() && player.getRidingEntity() instanceof EntityLivingBase)
|
||||
rotation = 0;
|
||||
else
|
||||
rotation = 0;
|
||||
|
||||
|
||||
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
||||
if (overrider != null)
|
||||
{
|
||||
double[] rotLeft = null;
|
||||
double[] 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.bipedLeftArm, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
||||
renderArmPre(model.bipedLeftArmwear, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
||||
}
|
||||
else if (renderLeft)
|
||||
{
|
||||
renderArmPre(model.bipedLeftArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
renderArmPre(model.bipedLeftArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
}
|
||||
|
||||
if (renderRight && rotRight != null)
|
||||
{
|
||||
renderArmPre(model.bipedRightArm, (float) rotRight[0], (float) rotRight[2], rotation);
|
||||
renderArmPre(model.bipedRightArmwear, (float) rotRight[0], (float) rotRight[2], rotation);
|
||||
}
|
||||
else if (renderRight)
|
||||
{
|
||||
renderArmPre(model.bipedRightArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
renderArmPre(model.bipedRightArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
renderArmPre(model.bipedRightArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
renderArmPre(model.bipedRightArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
renderArmPre(model.bipedLeftArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
renderArmPre(model.bipedLeftArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void renderArmPre(ModelRenderer arm, float x, float z, float rotation)
|
||||
{
|
||||
arm.rotateAngleX = (float) -x;
|
||||
arm.rotateAngleY = (float) -Math.toRadians(rotation);
|
||||
arm.rotateAngleZ = (float) z;
|
||||
}
|
||||
|
||||
//
|
||||
// @SubscribeEvent
|
||||
// public void preModelPlayerEvent(ModelPlayerEvent.SetupAngles.Post event)
|
||||
// {
|
||||
// if(!CarryOnConfig.settings.renderArms.get())
|
||||
// return;
|
||||
//
|
||||
// EntityPlayer player = event.getEntityPlayer();
|
||||
//
|
||||
// ModelPlayer model = event.getModelPlayer();
|
||||
// ItemStack stack = player.getHeldItemMainhand();
|
||||
// if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))
|
||||
// {
|
||||
//
|
||||
// float rotation = 0;
|
||||
//
|
||||
// CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
||||
// if (overrider != null)
|
||||
// {
|
||||
// double[] rotLeft = null;
|
||||
// double[] 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.bipedLeftArm, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
||||
// renderArmPre(model.bipedLeftArmwear, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
||||
// }
|
||||
// else if (renderLeft)
|
||||
// {
|
||||
// renderArmPre(model.bipedLeftArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
// renderArmPre(model.bipedLeftArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
// }
|
||||
//
|
||||
// if (renderRight && rotRight != null)
|
||||
// {
|
||||
// renderArmPre(model.bipedRightArm, (float) rotRight[0], (float) rotRight[2], rotation);
|
||||
// renderArmPre(model.bipedRightArmwear, (float) rotRight[0], (float) rotRight[2], rotation);
|
||||
// }
|
||||
// else if (renderRight)
|
||||
// {
|
||||
// renderArmPre(model.bipedRightArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
// renderArmPre(model.bipedRightArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// renderArmPre(model.bipedRightArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
// renderArmPre(model.bipedRightArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
// renderArmPre(model.bipedLeftArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
// renderArmPre(model.bipedLeftArmwear, 0.8F + (player.isSneaking() ? 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.rotateAngleX = (float) -x;
|
||||
// arm.rotateAngleY = (float) -Math.toRadians(rotation);
|
||||
// arm.rotateAngleZ = (float) z;
|
||||
// }
|
||||
//
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,34 @@
|
|||
package tschipp.carryon.network.client;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class CarrySlotPacket implements IMessage
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
|
||||
public class CarrySlotPacket
|
||||
{
|
||||
public int slot;
|
||||
public int carryOverride = 0;
|
||||
public int entityid;
|
||||
|
||||
public CarrySlotPacket()
|
||||
|
||||
public CarrySlotPacket(ByteBuf buf)
|
||||
{
|
||||
this.slot = 9;
|
||||
this.entityid = 0;
|
||||
this.slot = buf.readInt();
|
||||
this.carryOverride = buf.readInt();
|
||||
this.entityid = buf.readInt();
|
||||
}
|
||||
|
||||
|
||||
public CarrySlotPacket(int slot, int entityid)
|
||||
{
|
||||
this.slot = slot;
|
||||
this.entityid = entityid;
|
||||
}
|
||||
|
||||
|
||||
public CarrySlotPacket(int slot, int entityid, int carryOverride)
|
||||
{
|
||||
this.slot = slot;
|
||||
|
|
@ -30,25 +36,44 @@ public class CarrySlotPacket implements IMessage
|
|||
this.entityid = entityid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf)
|
||||
{
|
||||
NBTTagCompound tag = ByteBufUtils.readTag(buf);
|
||||
|
||||
this.slot = tag.getInteger("slot");
|
||||
this.carryOverride = tag.getInteger("override");
|
||||
this.entityid = tag.getInteger("entityid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf)
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setInteger("slot", slot);
|
||||
tag.setInteger("override", carryOverride);
|
||||
tag.setInteger("entityid", entityid);
|
||||
ByteBufUtils.writeTag(buf, tag);
|
||||
buf.writeInt(slot);
|
||||
buf.writeInt(carryOverride);
|
||||
buf.writeInt(entityid);
|
||||
}
|
||||
|
||||
public void handle(Supplier<NetworkEvent.Context> ctx)
|
||||
{
|
||||
ctx.get().enqueueWork(() -> {
|
||||
|
||||
World world = CarryOn.proxy.getWorld();
|
||||
|
||||
if (world != null)
|
||||
{
|
||||
Entity e = world.getEntityByID(entityid);
|
||||
|
||||
if (e != null && e instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) e;
|
||||
|
||||
ctx.get().setPacketHandled(true);
|
||||
|
||||
if (slot >= 9)
|
||||
{
|
||||
player.getEntityData().removeTag("carrySlot");
|
||||
player.getEntityData().removeTag("overrideKey");
|
||||
} else
|
||||
{
|
||||
|
||||
player.getEntityData().setInt("carrySlot", slot);
|
||||
if (carryOverride != 0)
|
||||
ScriptChecker.setCarryOnOverride(player, carryOverride);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
package tschipp.carryon.network.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.IThreadListener;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
|
||||
public class CarrySlotPacketHandler implements IMessageHandler<CarrySlotPacket, IMessage>
|
||||
{
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(final CarrySlotPacket message, final MessageContext ctx)
|
||||
{
|
||||
IThreadListener mainThread = Minecraft.getMinecraft();
|
||||
|
||||
mainThread.addScheduledTask(new Runnable()
|
||||
{
|
||||
World world = Minecraft.getMinecraft().world;
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (world != null)
|
||||
{
|
||||
Entity e = world.getEntityByID(message.entityid);
|
||||
|
||||
if (e != null && e instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) e;
|
||||
|
||||
if (message.slot >= 9)
|
||||
{
|
||||
player.getEntityData().removeTag("carrySlot");
|
||||
player.getEntityData().removeTag("overrideKey");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
player.getEntityData().setInteger("carrySlot", message.slot);
|
||||
if (message.carryOverride != 0)
|
||||
ScriptChecker.setCarryOnOverride(player, message.carryOverride);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,26 +1,39 @@
|
|||
package tschipp.carryon.network.client;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ScriptReloadPacket implements IMessage
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.scripting.ScriptReader;
|
||||
|
||||
public class ScriptReloadPacket
|
||||
{
|
||||
|
||||
public ScriptReloadPacket()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf)
|
||||
public ScriptReloadPacket(ByteBuf buf)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void handle(Supplier<NetworkEvent.Context> ctx)
|
||||
{
|
||||
ctx.get().enqueueWork(() -> {
|
||||
|
||||
EntityPlayer player = CarryOn.proxy.getPlayer();
|
||||
|
||||
if (player != null)
|
||||
ScriptReader.reloadScripts();
|
||||
|
||||
ctx.get().setPacketHandled(true);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
package tschipp.carryon.network.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.util.IThreadListener;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import tschipp.carryon.common.scripting.ScriptReader;
|
||||
|
||||
public class ScriptReloadPacketHandler implements IMessageHandler<ScriptReloadPacket, IMessage>
|
||||
{
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(ScriptReloadPacket message, MessageContext ctx)
|
||||
{
|
||||
IThreadListener mainThread = Minecraft.getMinecraft();
|
||||
|
||||
mainThread.addScheduledTask(new Runnable()
|
||||
{
|
||||
EntityPlayerSP player = Minecraft.getMinecraft().player;
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if(player != null)
|
||||
ScriptReader.reloadScripts();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,35 +1,41 @@
|
|||
package tschipp.carryon.network.server;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class SyncKeybindPacket implements IMessage
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
|
||||
public class SyncKeybindPacket
|
||||
{
|
||||
|
||||
private int p;
|
||||
public boolean pressed;
|
||||
|
||||
public SyncKeybindPacket()
|
||||
|
||||
public SyncKeybindPacket(ByteBuf buf)
|
||||
{
|
||||
this.pressed = buf.readBoolean();
|
||||
}
|
||||
|
||||
|
||||
public SyncKeybindPacket(boolean pressed)
|
||||
{
|
||||
this.p = pressed ? 1 : 0;
|
||||
this.pressed = pressed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf)
|
||||
{
|
||||
this.p = ByteBufUtils.readVarInt(buf, 4);
|
||||
this.pressed = p == 1 ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf)
|
||||
{
|
||||
ByteBufUtils.writeVarInt(buf, p, 4);
|
||||
buf.writeBoolean(pressed);
|
||||
}
|
||||
|
||||
public void handle(Supplier<NetworkEvent.Context> ctx)
|
||||
{
|
||||
ctx.get().enqueueWork(() -> {
|
||||
|
||||
EntityPlayerMP player = ctx.get().getSender();
|
||||
|
||||
CarryOnKeybinds.setKeyPressed(player, pressed);
|
||||
|
||||
ctx.get().setPacketHandled(true);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
package tschipp.carryon.network.server;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.IThreadListener;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
|
||||
public class SyncKeybindPacketHandler implements IMessageHandler<SyncKeybindPacket, IMessage>
|
||||
{
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(final SyncKeybindPacket message, final MessageContext ctx)
|
||||
{
|
||||
IThreadListener mainThread = (WorldServer) ctx.getServerHandler().player.world;
|
||||
|
||||
mainThread.addScheduledTask(new Runnable()
|
||||
{
|
||||
EntityPlayerMP player = ctx.getServerHandler().player;
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
CarryOnKeybinds.setKeyPressed(player, message.pressed);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
37
src/main/java/tschipp/carryon/proxy/ClientProxy.java
Normal file
37
src/main/java/tschipp/carryon/proxy/ClientProxy.java
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package tschipp.carryon.proxy;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.helper.KeyboardCallbackWrapper;
|
||||
import tschipp.carryon.common.helper.ScrollCallbackWrapper;
|
||||
|
||||
public class ClientProxy implements IProxy {
|
||||
|
||||
|
||||
@Override
|
||||
public void setup(FMLCommonSetupEvent event)
|
||||
{
|
||||
RegistrationHandler.regClientEvents();
|
||||
|
||||
CarryOnKeybinds.init();
|
||||
|
||||
new ScrollCallbackWrapper().setup(Minecraft.getInstance());;
|
||||
new KeyboardCallbackWrapper().setup(Minecraft.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer()
|
||||
{
|
||||
return Minecraft.getInstance().player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
return Minecraft.getInstance().world;
|
||||
}
|
||||
}
|
||||
15
src/main/java/tschipp/carryon/proxy/IProxy.java
Normal file
15
src/main/java/tschipp/carryon/proxy/IProxy.java
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package tschipp.carryon.proxy;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
|
||||
public interface IProxy
|
||||
{
|
||||
|
||||
public void setup(final FMLCommonSetupEvent event);
|
||||
|
||||
public EntityPlayer getPlayer();
|
||||
|
||||
public World getWorld();
|
||||
}
|
||||
28
src/main/java/tschipp/carryon/proxy/ServerProxy.java
Normal file
28
src/main/java/tschipp/carryon/proxy/ServerProxy.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package tschipp.carryon.proxy;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
|
||||
public class ServerProxy implements IProxy
|
||||
{
|
||||
|
||||
@Override
|
||||
public void setup(FMLCommonSetupEvent event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
33
src/main/resources/META-INF/mods.toml
Normal file
33
src/main/resources/META-INF/mods.toml
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
modLoader="javafml"
|
||||
loaderVersion="[13,)"
|
||||
issueTrackerURL="https://github.com/Tschipp/CarryOn/issues"
|
||||
logoFile="logo.png"
|
||||
|
||||
|
||||
[[mods]]
|
||||
modId="carryon"
|
||||
version="1.12.2"
|
||||
displayName="Carry On"
|
||||
description='''Carry On is a simple mod that improves game interaction by allowing players to pick up, carry, and place single block Tile Entities using only their empty hands.'''
|
||||
authors="Tschipp, Purplicious_Cow, cy4n" #mandatory
|
||||
displayURL="https://minecraft.curseforge.com/projects/carry-on" #mandatory
|
||||
updateJSONURL="https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/" #mandatory
|
||||
|
||||
[[dependencies.carryon]] #optional
|
||||
# the modid of the dependency
|
||||
modId="forge" #mandatory
|
||||
# Does this dependency have to exist - if not, ordering below must be specified
|
||||
mandatory=true #mandatory
|
||||
# The version range of the dependency
|
||||
versionRange="[14.23.2.0,)" #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
|
||||
side="BOTH"
|
||||
|
||||
[[dependencies.carryon]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
versionRange="[1.13.2,1.14)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
carryon.category.settings=sᵷuᴉʇʇǝS
|
||||
carryon.category.blacklist=ʇsᴉꞁʞɔɐꞁᗺ
|
||||
carryon.category.modeloverrides=(pǝɔuɐʌpⱯ) sǝpᴉɹɹǝʌO ꞁǝpoW
|
||||
carryon.category.custompickupconditions=(pǝɔuɐʌpⱯ) suoᴉʇᴉpuoƆ dnʞɔᴉԀ ɯoʇsnƆ
|
||||
carryon.category.whitelist=ʇsᴉꞁǝʇᴉɥM
|
||||
|
||||
carryon.general.modeloverrides.modeloverrides=sǝpᴉɹɹǝʌO ꞁǝpoW
|
||||
carryon.general.blacklist.forbiddenentities=dn ʞɔᴉd ʇouuɐɔ ɹǝʎɐꞁԀ ǝɥʇ ʇɐɥʇ sǝᴉʇᴉʇuƎ
|
||||
carryon.general.blacklist.forbiddentiles=dn ʞɔᴉd ʇouuɐɔ ɹǝʎɐꞁԀ ǝɥʇ ʇɐɥʇ sʞɔoꞁᗺ
|
||||
carryon.category.custompickupconditions.custompickupconditionsblocks=suoᴉʇᴉpuoƆ dnʞɔᴉԀ ʞɔoꞁᗺ ɯoʇsnƆ
|
||||
carryon.category.custompickupconditions.custompickupconditionsentities=suoᴉʇᴉpuoƆ dnʞɔᴉԀ ʎʇᴉʇuƎ ɯoʇsnƆ
|
||||
|
||||
key.carry.desc=ʎɹɹɐƆ
|
||||
key.carry.category=uO ʎɹɹɐƆ
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
carryon.category.settings=Settings
|
||||
carryon.category.blacklist=Blacklist
|
||||
carryon.category.modeloverrides=Model Overrides (Advanced)
|
||||
carryon.category.custompickupconditions=Custom Pickup Conditions (Advanced)
|
||||
carryon.category.whitelist=Whitelist
|
||||
|
||||
carryon.general.modeloverrides.modeloverrides=Model Overrides
|
||||
carryon.general.blacklist.forbiddenentities=Entities that the Player cannot pick up
|
||||
carryon.general.blacklist.forbiddentiles=Blocks that the Player cannot pick up
|
||||
carryon.category.custompickupconditions.custompickupconditionsblocks=Custom Block Pickup Conditions
|
||||
carryon.category.custompickupconditions.custompickupconditionsentities=Custom Entity Pickup Conditions
|
||||
|
||||
key.carry.desc=Carry
|
||||
key.carry.category=Carry On
|
||||
16
src/main/resources/assets/carryon/lang/en_ud.json
Normal file
16
src/main/resources/assets/carryon/lang/en_ud.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"carryon.category.settings": "sᵷuᴉʇʇǝS",
|
||||
"carryon.category.blacklist": "ʇsᴉꞁʞɔɐꞁᗺ",
|
||||
"carryon.category.modeloverrides": "(pǝɔuɐʌpⱯ) sǝpᴉɹɹǝʌO ꞁǝpoW",
|
||||
"carryon.category.custompickupconditions": "(pǝɔuɐʌpⱯ) suoᴉʇᴉpuoƆ dnʞɔᴉԀ ɯoʇsnƆ",
|
||||
"carryon.category.whitelist": "ʇsᴉꞁǝʇᴉɥM",
|
||||
|
||||
"carryon.general.modeloverrides.modeloverrides": "sǝpᴉɹɹǝʌO ꞁǝpoW",
|
||||
"carryon.general.blacklist.forbiddenentities": "dn ʞɔᴉd ʇouuɐɔ ɹǝʎɐꞁԀ ǝɥʇ ʇɐɥʇ sǝᴉʇᴉʇuƎ",
|
||||
"carryon.general.blacklist.forbiddentiles": "dn ʞɔᴉd ʇouuɐɔ ɹǝʎɐꞁԀ ǝɥʇ ʇɐɥʇ sʞɔoꞁᗺ",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsblocks": "suoᴉʇᴉpuoƆ dnʞɔᴉԀ ʞɔoꞁᗺ ɯoʇsnƆ",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsentities": "suoᴉʇᴉpuoƆ dnʞɔᴉԀ ʎʇᴉʇuƎ ɯoʇsnƆ",
|
||||
|
||||
"key.carry.desc": "ʎɹɹɐƆ",
|
||||
"key.carry.category": "uO ʎɹɹɐƆ"
|
||||
}
|
||||
16
src/main/resources/assets/carryon/lang/en_us.json
Normal file
16
src/main/resources/assets/carryon/lang/en_us.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"carryon.category.settings": "Settings",
|
||||
"carryon.category.blacklist": "Blacklist",
|
||||
"carryon.category.modeloverrides": "Model Overrides (Advanced)",
|
||||
"carryon.category.custompickupconditions": "Custom Pickup Conditions (Advanced)",
|
||||
"carryon.category.whitelist": "Whitelist",
|
||||
|
||||
"carryon.general.modeloverrides.modeloverrides": "Model Overrides",
|
||||
"carryon.general.blacklist.forbiddenentities": "Entities that the Player cannot pick up",
|
||||
"carryon.general.blacklist.forbiddentiles": "Blocks that the Player cannot pick up",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsblocks": "Custom Block Pickup Conditions",
|
||||
"carryon.category.custompickupconditions.custompickupconditionsentities": "Custom Entity Pickup Conditions",
|
||||
|
||||
"key.carry.desc": "Carry",
|
||||
"key.carry.category": "Carry On"
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "carryon:items/tile"
|
||||
"layer0": "carryon:item/tile"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "carryon:item/tile"
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 198 B After Width: | Height: | Size: 198 B |
|
Before Width: | Height: | Size: 170 KiB After Width: | Height: | Size: 170 KiB |
|
|
@ -1,16 +0,0 @@
|
|||
[
|
||||
{
|
||||
"modid" : "carryon",
|
||||
"name" : "Carry On",
|
||||
"version" : "1.12", "mcversion" : "1.12.2",
|
||||
"url" : "",
|
||||
"credits" : "Tschipp, Purplicious_Cow, cy4n",
|
||||
"authorList" : ["Tschipp, Purplicious_Cow, cy4n"],
|
||||
"description": "Carry On is a simple mod that improves game interaction by allowing players to pick up, carry, and place single block Tile Entities using only their empty hands.",
|
||||
"logoFile" : "assets/carryon/logo.png",
|
||||
"updateUrl" : "https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/5115328bf7c35d5c5cea64bdb58becd2ca17fcac/update.json",
|
||||
"parent" : "",
|
||||
"dependencies": [],
|
||||
"screenshots": []
|
||||
}
|
||||
]
|
||||
7
src/main/resources/pack.mcmeta
Normal file
7
src/main/resources/pack.mcmeta
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"pack": {
|
||||
"description": "Mod Resources",
|
||||
"pack_format": 4,
|
||||
"_comment": "A pack_format of 4 requires json lang files. Note: we require v4 pack meta for all mods."
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user