Compare commits
1 Commits
1.21.11
...
1.14-fabri
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6bce45230 |
37
.gitignore
vendored
37
.gitignore
vendored
|
|
@ -1,3 +1,24 @@
|
||||||
|
# gradle
|
||||||
|
|
||||||
|
.gradle/
|
||||||
|
build/
|
||||||
|
out/
|
||||||
|
bin/
|
||||||
|
|
||||||
|
|
||||||
|
# idea
|
||||||
|
|
||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
#vscode
|
||||||
|
.vscode/
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
|
||||||
|
|
||||||
# eclipse
|
# eclipse
|
||||||
bin
|
bin
|
||||||
*.launch
|
*.launch
|
||||||
|
|
@ -7,17 +28,5 @@ bin
|
||||||
.project
|
.project
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
# idea
|
# fabric
|
||||||
out
|
run/
|
||||||
*.ipr
|
|
||||||
*.iws
|
|
||||||
*.iml
|
|
||||||
.idea
|
|
||||||
|
|
||||||
# gradle
|
|
||||||
build
|
|
||||||
.gradle
|
|
||||||
|
|
||||||
# other
|
|
||||||
eclipse
|
|
||||||
run
|
|
||||||
262
LICENSE
262
LICENSE
|
|
@ -1,165 +1,121 @@
|
||||||
GNU LESSER GENERAL PUBLIC LICENSE
|
Creative Commons Legal Code
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
CC0 1.0 Universal
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
|
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||||
|
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
||||||
|
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||||
|
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||||
|
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
||||||
|
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
||||||
|
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
||||||
|
HEREUNDER.
|
||||||
|
|
||||||
This version of the GNU Lesser General Public License incorporates
|
Statement of Purpose
|
||||||
the terms and conditions of version 3 of the GNU General Public
|
|
||||||
License, supplemented by the additional permissions listed below.
|
|
||||||
|
|
||||||
0. Additional Definitions.
|
The laws of most jurisdictions throughout the world automatically confer
|
||||||
|
exclusive Copyright and Related Rights (defined below) upon the creator
|
||||||
|
and subsequent owner(s) (each and all, an "owner") of an original work of
|
||||||
|
authorship and/or a database (each, a "Work").
|
||||||
|
|
||||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
Certain owners wish to permanently relinquish those rights to a Work for
|
||||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
the purpose of contributing to a commons of creative, cultural and
|
||||||
General Public License.
|
scientific works ("Commons") that the public can reliably and without fear
|
||||||
|
of later claims of infringement build upon, modify, incorporate in other
|
||||||
|
works, reuse and redistribute as freely as possible in any form whatsoever
|
||||||
|
and for any purposes, including without limitation commercial purposes.
|
||||||
|
These owners may contribute to the Commons to promote the ideal of a free
|
||||||
|
culture and the further production of creative, cultural and scientific
|
||||||
|
works, or to gain reputation or greater distribution for their Work in
|
||||||
|
part through the use and efforts of others.
|
||||||
|
|
||||||
"The Library" refers to a covered work governed by this License,
|
For these and/or other purposes and motivations, and without any
|
||||||
other than an Application or a Combined Work as defined below.
|
expectation of additional consideration or compensation, the person
|
||||||
|
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
||||||
|
is an owner of Copyright and Related Rights in the Work, voluntarily
|
||||||
|
elects to apply CC0 to the Work and publicly distribute the Work under its
|
||||||
|
terms, with knowledge of his or her Copyright and Related Rights in the
|
||||||
|
Work and the meaning and intended legal effect of CC0 on those rights.
|
||||||
|
|
||||||
An "Application" is any work that makes use of an interface provided
|
1. Copyright and Related Rights. A Work made available under CC0 may be
|
||||||
by the Library, but which is not otherwise based on the Library.
|
protected by copyright and related or neighboring rights ("Copyright and
|
||||||
Defining a subclass of a class defined by the Library is deemed a mode
|
Related Rights"). Copyright and Related Rights include, but are not
|
||||||
of using an interface provided by the Library.
|
limited to, the following:
|
||||||
|
|
||||||
A "Combined Work" is a work produced by combining or linking an
|
i. the right to reproduce, adapt, distribute, perform, display,
|
||||||
Application with the Library. The particular version of the Library
|
communicate, and translate a Work;
|
||||||
with which the Combined Work was made is also called the "Linked
|
ii. moral rights retained by the original author(s) and/or performer(s);
|
||||||
Version".
|
iii. publicity and privacy rights pertaining to a person's image or
|
||||||
|
likeness depicted in a Work;
|
||||||
|
iv. rights protecting against unfair competition in regards to a Work,
|
||||||
|
subject to the limitations in paragraph 4(a), below;
|
||||||
|
v. rights protecting the extraction, dissemination, use and reuse of data
|
||||||
|
in a Work;
|
||||||
|
vi. database rights (such as those arising under Directive 96/9/EC of the
|
||||||
|
European Parliament and of the Council of 11 March 1996 on the legal
|
||||||
|
protection of databases, and under any national implementation
|
||||||
|
thereof, including any amended or successor version of such
|
||||||
|
directive); and
|
||||||
|
vii. other similar, equivalent or corresponding rights throughout the
|
||||||
|
world based on applicable law or treaty, and any national
|
||||||
|
implementations thereof.
|
||||||
|
|
||||||
The "Minimal Corresponding Source" for a Combined Work means the
|
2. Waiver. To the greatest extent permitted by, but not in contravention
|
||||||
Corresponding Source for the Combined Work, excluding any source code
|
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
||||||
for portions of the Combined Work that, considered in isolation, are
|
irrevocably and unconditionally waives, abandons, and surrenders all of
|
||||||
based on the Application, and not on the Linked Version.
|
Affirmer's Copyright and Related Rights and associated claims and causes
|
||||||
|
of action, whether now known or unknown (including existing as well as
|
||||||
|
future claims and causes of action), in the Work (i) in all territories
|
||||||
|
worldwide, (ii) for the maximum duration provided by applicable law or
|
||||||
|
treaty (including future time extensions), (iii) in any current or future
|
||||||
|
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
||||||
|
including without limitation commercial, advertising or promotional
|
||||||
|
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
||||||
|
member of the public at large and to the detriment of Affirmer's heirs and
|
||||||
|
successors, fully intending that such Waiver shall not be subject to
|
||||||
|
revocation, rescission, cancellation, termination, or any other legal or
|
||||||
|
equitable action to disrupt the quiet enjoyment of the Work by the public
|
||||||
|
as contemplated by Affirmer's express Statement of Purpose.
|
||||||
|
|
||||||
The "Corresponding Application Code" for a Combined Work means the
|
3. Public License Fallback. Should any part of the Waiver for any reason
|
||||||
object code and/or source code for the Application, including any data
|
be judged legally invalid or ineffective under applicable law, then the
|
||||||
and utility programs needed for reproducing the Combined Work from the
|
Waiver shall be preserved to the maximum extent permitted taking into
|
||||||
Application, but excluding the System Libraries of the Combined Work.
|
account Affirmer's express Statement of Purpose. In addition, to the
|
||||||
|
extent the Waiver is so judged Affirmer hereby grants to each affected
|
||||||
|
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
||||||
|
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
||||||
|
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
||||||
|
maximum duration provided by applicable law or treaty (including future
|
||||||
|
time extensions), (iii) in any current or future medium and for any number
|
||||||
|
of copies, and (iv) for any purpose whatsoever, including without
|
||||||
|
limitation commercial, advertising or promotional purposes (the
|
||||||
|
"License"). The License shall be deemed effective as of the date CC0 was
|
||||||
|
applied by Affirmer to the Work. Should any part of the License for any
|
||||||
|
reason be judged legally invalid or ineffective under applicable law, such
|
||||||
|
partial invalidity or ineffectiveness shall not invalidate the remainder
|
||||||
|
of the License, and in such case Affirmer hereby affirms that he or she
|
||||||
|
will not (i) exercise any of his or her remaining Copyright and Related
|
||||||
|
Rights in the Work or (ii) assert any associated claims and causes of
|
||||||
|
action with respect to the Work, in either case contrary to Affirmer's
|
||||||
|
express Statement of Purpose.
|
||||||
|
|
||||||
1. Exception to Section 3 of the GNU GPL.
|
4. Limitations and Disclaimers.
|
||||||
|
|
||||||
You may convey a covered work under sections 3 and 4 of this License
|
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
||||||
without being bound by section 3 of the GNU GPL.
|
surrendered, licensed or otherwise affected by this document.
|
||||||
|
b. Affirmer offers the Work as-is and makes no representations or
|
||||||
2. Conveying Modified Versions.
|
warranties of any kind concerning the Work, express, implied,
|
||||||
|
statutory or otherwise, including without limitation warranties of
|
||||||
If you modify a copy of the Library, and, in your modifications, a
|
title, merchantability, fitness for a particular purpose, non
|
||||||
facility refers to a function or data to be supplied by an Application
|
infringement, or the absence of latent or other defects, accuracy, or
|
||||||
that uses the facility (other than as an argument passed when the
|
the present or absence of errors, whether or not discoverable, all to
|
||||||
facility is invoked), then you may convey a copy of the modified
|
the greatest extent permissible under applicable law.
|
||||||
version:
|
c. Affirmer disclaims responsibility for clearing rights of other persons
|
||||||
|
that may apply to the Work or any use thereof, including without
|
||||||
a) under this License, provided that you make a good faith effort to
|
limitation any person's Copyright and Related Rights in the Work.
|
||||||
ensure that, in the event an Application does not supply the
|
Further, Affirmer disclaims responsibility for obtaining any necessary
|
||||||
function or data, the facility still operates, and performs
|
consents, permissions or other rights required for any use of the
|
||||||
whatever part of its purpose remains meaningful, or
|
Work.
|
||||||
|
d. Affirmer understands and acknowledges that Creative Commons is not a
|
||||||
b) under the GNU GPL, with none of the additional permissions of
|
party to this document and has no duty or obligation with respect to
|
||||||
this License applicable to that copy.
|
this CC0 or use of the Work.
|
||||||
|
|
||||||
3. Object Code Incorporating Material from Library Header Files.
|
|
||||||
|
|
||||||
The object code form of an Application may incorporate material from
|
|
||||||
a header file that is part of the Library. You may convey such object
|
|
||||||
code under terms of your choice, provided that, if the incorporated
|
|
||||||
material is not limited to numerical parameters, data structure
|
|
||||||
layouts and accessors, or small macros, inline functions and templates
|
|
||||||
(ten or fewer lines in length), you do both of the following:
|
|
||||||
|
|
||||||
a) Give prominent notice with each copy of the object code that the
|
|
||||||
Library is used in it and that the Library and its use are
|
|
||||||
covered by this License.
|
|
||||||
|
|
||||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
||||||
document.
|
|
||||||
|
|
||||||
4. Combined Works.
|
|
||||||
|
|
||||||
You may convey a Combined Work under terms of your choice that,
|
|
||||||
taken together, effectively do not restrict modification of the
|
|
||||||
portions of the Library contained in the Combined Work and reverse
|
|
||||||
engineering for debugging such modifications, if you also do each of
|
|
||||||
the following:
|
|
||||||
|
|
||||||
a) Give prominent notice with each copy of the Combined Work that
|
|
||||||
the Library is used in it and that the Library and its use are
|
|
||||||
covered by this License.
|
|
||||||
|
|
||||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
||||||
document.
|
|
||||||
|
|
||||||
c) For a Combined Work that displays copyright notices during
|
|
||||||
execution, include the copyright notice for the Library among
|
|
||||||
these notices, as well as a reference directing the user to the
|
|
||||||
copies of the GNU GPL and this license document.
|
|
||||||
|
|
||||||
d) Do one of the following:
|
|
||||||
|
|
||||||
0) Convey the Minimal Corresponding Source under the terms of this
|
|
||||||
License, and the Corresponding Application Code in a form
|
|
||||||
suitable for, and under terms that permit, the user to
|
|
||||||
recombine or relink the Application with a modified version of
|
|
||||||
the Linked Version to produce a modified Combined Work, in the
|
|
||||||
manner specified by section 6 of the GNU GPL for conveying
|
|
||||||
Corresponding Source.
|
|
||||||
|
|
||||||
1) Use a suitable shared library mechanism for linking with the
|
|
||||||
Library. A suitable mechanism is one that (a) uses at run time
|
|
||||||
a copy of the Library already present on the user's computer
|
|
||||||
system, and (b) will operate properly with a modified version
|
|
||||||
of the Library that is interface-compatible with the Linked
|
|
||||||
Version.
|
|
||||||
|
|
||||||
e) Provide Installation Information, but only if you would otherwise
|
|
||||||
be required to provide such information under section 6 of the
|
|
||||||
GNU GPL, and only to the extent that such information is
|
|
||||||
necessary to install and execute a modified version of the
|
|
||||||
Combined Work produced by recombining or relinking the
|
|
||||||
Application with a modified version of the Linked Version. (If
|
|
||||||
you use option 4d0, the Installation Information must accompany
|
|
||||||
the Minimal Corresponding Source and Corresponding Application
|
|
||||||
Code. If you use option 4d1, you must provide the Installation
|
|
||||||
Information in the manner specified by section 6 of the GNU GPL
|
|
||||||
for conveying Corresponding Source.)
|
|
||||||
|
|
||||||
5. Combined Libraries.
|
|
||||||
|
|
||||||
You may place library facilities that are a work based on the
|
|
||||||
Library side by side in a single library together with other library
|
|
||||||
facilities that are not Applications and are not covered by this
|
|
||||||
License, and convey such a combined library under terms of your
|
|
||||||
choice, if you do both of the following:
|
|
||||||
|
|
||||||
a) Accompany the combined library with a copy of the same work based
|
|
||||||
on the Library, uncombined with any other library facilities,
|
|
||||||
conveyed under the terms of this License.
|
|
||||||
|
|
||||||
b) Give prominent notice with the combined library that part of it
|
|
||||||
is a work based on the Library, and explaining where to find the
|
|
||||||
accompanying uncombined form of the same work.
|
|
||||||
|
|
||||||
6. Revised Versions of the GNU Lesser General Public License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions
|
|
||||||
of the GNU Lesser General Public License from time to time. Such new
|
|
||||||
versions will be similar in spirit to the present version, but may
|
|
||||||
differ in detail to address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Library as you received it specifies that a certain numbered version
|
|
||||||
of the GNU Lesser General Public License "or any later version"
|
|
||||||
applies to it, you have the option of following the terms and
|
|
||||||
conditions either of that published version or of any later version
|
|
||||||
published by the Free Software Foundation. If the Library as you
|
|
||||||
received it does not specify a version number of the GNU Lesser
|
|
||||||
General Public License, you may choose any version of the GNU Lesser
|
|
||||||
General Public License ever published by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Library as you received it specifies that a proxy can decide
|
|
||||||
whether future versions of the GNU Lesser General Public License shall
|
|
||||||
apply, that proxy's public statement of acceptance of any version is
|
|
||||||
permanent authorization for you to choose that version for the
|
|
||||||
Library.
|
|
||||||
|
|
|
||||||
16
README.md
16
README.md
|
|
@ -1,2 +1,16 @@
|
||||||
|
# Fabric Example Mod
|
||||||
|
|
||||||
# Carry On [](https://minecraft.curseforge.com/projects/carry-on) [](https://minecraft.curseforge.com/projects/carry-on)
|
## Setup
|
||||||
|
|
||||||
|
1. Edit build.gradle and mod.json to suit your needs.
|
||||||
|
* The "mixins" object can be removed from mod.json if you do not need to use mixins.
|
||||||
|
* Please replace all occurences of "modid" with your own mod ID - sometimes, a different string may also suffice.
|
||||||
|
2. Run the following command:
|
||||||
|
|
||||||
|
```
|
||||||
|
./gradlew idea
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This template is available under the CC0 license. Feel free to learn from it and incorporate it in your own projects.
|
||||||
|
|
|
||||||
70
build.gradle
70
build.gradle
|
|
@ -1,70 +1,20 @@
|
||||||
buildscript {
|
plugins {
|
||||||
repositories {
|
id 'fabric-loom' version '0.1.0-SNAPSHOT'
|
||||||
jcenter()
|
|
||||||
maven { url = "http://files.minecraftforge.net/maven" }
|
|
||||||
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceCompatibility = 1.8
|
||||||
|
targetCompatibility = 1.8
|
||||||
|
|
||||||
|
archivesBaseName = "CarryOn"
|
||||||
|
version = "1.0.0"
|
||||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
|
||||||
|
|
||||||
version = "1.0"
|
|
||||||
group = "tschipp.carryon"
|
|
||||||
archivesBaseName = "carryon"
|
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = '1.8'
|
|
||||||
compileJava {
|
|
||||||
sourceCompatibility = targetCompatibility = '1.8'
|
|
||||||
}
|
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
version = "1.11.2-13.20.1.2386"
|
|
||||||
runDir = "run"
|
|
||||||
|
|
||||||
mappings = "snapshot_20161220"
|
|
||||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
|
||||||
|
|
||||||
maven { url 'http://maven.epoxide.org' }
|
|
||||||
|
|
||||||
ivy {
|
|
||||||
name "LatMod"
|
|
||||||
artifactPattern "http://mods.latmod.com/[module]/[revision]/[module]-[revision](-[classifier]).[ext]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
minecraft "com.mojang:minecraft:18w50a"
|
||||||
deobfCompile "net.darkhax.gamestages:GameStages-1.11.2:1.0.11"
|
mappings "net.fabricmc:yarn:18w50a.33"
|
||||||
|
modCompile "net.fabricmc:fabric-loader:0.2.0.70"
|
||||||
deobfCompile "LatMod:FTBUtilities:1.1x-3.6.5"
|
|
||||||
deobfCompile "LatMod:FTBLib:1.1x-3.6.5"
|
|
||||||
|
|
||||||
|
modCompile "net.fabricmc:fabric:0.1.1.53"
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
|
||||||
exclude 'mcmod.info'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
# 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
|
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
|
@ -1,6 +1,6 @@
|
||||||
#Mon Sep 14 12:28:28 PDT 2015
|
#Mon Aug 22 17:36:22 EDT 2016
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
|
||||||
|
|
|
||||||
57
gradlew
vendored
57
gradlew
vendored
|
|
@ -6,12 +6,30 @@
|
||||||
##
|
##
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Attempt to set APP_HOME
|
||||||
DEFAULT_JVM_OPTS=""
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
APP_NAME="Gradle"
|
||||||
APP_BASE_NAME=`basename "$0"`
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
|
@ -30,6 +48,7 @@ die ( ) {
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
case "`uname`" in
|
case "`uname`" in
|
||||||
CYGWIN* )
|
CYGWIN* )
|
||||||
cygwin=true
|
cygwin=true
|
||||||
|
|
@ -40,31 +59,11 @@ case "`uname`" in
|
||||||
MINGW* )
|
MINGW* )
|
||||||
msys=true
|
msys=true
|
||||||
;;
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
esac
|
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"
|
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
|
||||||
ls=`ls -ld "$PRG"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
PRG="$link"
|
|
||||||
else
|
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >&-
|
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >&-
|
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
|
|
@ -90,7 +89,7 @@ location of your Java installation."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
if [ $? -eq 0 ] ; then
|
if [ $? -eq 0 ] ; then
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
|
@ -114,6 +113,7 @@ fi
|
||||||
if $cygwin ; then
|
if $cygwin ; then
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
|
@ -161,4 +161,9 @@ function splitJvmOpts() {
|
||||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||||
|
|
||||||
|
# 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" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||||
|
|
|
||||||
14
gradlew.bat
vendored
14
gradlew.bat
vendored
|
|
@ -8,14 +8,14 @@
|
||||||
@rem Set local scope for the variables with windows NT shell
|
@rem Set local scope for the variables with windows NT shell
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
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
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
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
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
|
@ -46,10 +46,9 @@ echo location of your Java installation.
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:init
|
: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 not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
|
||||||
|
|
||||||
:win9xME_args
|
:win9xME_args
|
||||||
@rem Slurp the command line arguments.
|
@rem Slurp the command line arguments.
|
||||||
|
|
@ -60,11 +59,6 @@ set _SKIP=2
|
||||||
if "x%~1" == "x" goto execute
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
set CMD_LINE_ARGS=%*
|
set CMD_LINE_ARGS=%*
|
||||||
goto execute
|
|
||||||
|
|
||||||
:4NT_args
|
|
||||||
@rem Get arguments from the 4NT Shell from JP Software
|
|
||||||
set CMD_LINE_ARGS=%$
|
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
|
||||||
10
settings.gradle
Normal file
10
settings.gradle
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
maven {
|
||||||
|
name = 'Fabric'
|
||||||
|
url = 'http://maven.fabricmc.net/'
|
||||||
|
}
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,70 +1,24 @@
|
||||||
package tschipp.carryon;
|
package tschipp.carryon;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
import tschipp.carryon.keybinds.CarryOnKeybinds;
|
||||||
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.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;
|
|
||||||
|
|
||||||
@EventBusSubscriber
|
|
||||||
@Mod(modid = CarryOn.MODID, name = CarryOn.NAME, version = CarryOn.VERSION, guiFactory = "tschipp.carryon.client.gui.GuiFactoryCarryOn", dependencies = "required-after:forge@[13.20.1.2386,)", updateJSON = CarryOn.UPDATE_JSON, acceptedMinecraftVersions = CarryOn.ACCEPTED_VERSIONS)
|
|
||||||
public class CarryOn {
|
|
||||||
|
|
||||||
@SidedProxy(clientSide = "tschipp.carryon.client.ClientProxy", serverSide = "tschipp.carryon.common.CommonProxy")
|
public class CarryOn implements ModInitializer {
|
||||||
public static CommonProxy proxy;
|
|
||||||
|
|
||||||
// Instance
|
public static String MODID = "carryon";
|
||||||
@Instance(CarryOn.MODID)
|
|
||||||
public static CarryOn instance;
|
|
||||||
|
|
||||||
public static final String MODID = "carryon";
|
|
||||||
public static final String VERSION = "1.9.1";
|
|
||||||
public static final String NAME = "Carry On";
|
|
||||||
public static final String ACCEPTED_VERSIONS = "[1.11,1.12)";
|
|
||||||
public static final String UPDATE_JSON = "https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/";
|
|
||||||
public static final Logger LOGGER = LogManager.getFormatterLogger("CarryOn");
|
public static final Logger LOGGER = LogManager.getFormatterLogger("CarryOn");
|
||||||
public static File CONFIGURATION_FILE;
|
|
||||||
|
|
||||||
public static SimpleNetworkWrapper network;
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void preInit(FMLPreInitializationEvent event){
|
@Override
|
||||||
CarryOn.proxy.preInit(event);
|
public void onInitialize() {
|
||||||
|
RegistryHandler.regItems();
|
||||||
|
CarryOnKeybinds.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void init(FMLInitializationEvent event) {
|
|
||||||
CarryOn.proxy.init(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void postInit(FMLPostInitializationEvent event) {
|
|
||||||
CarryOn.proxy.postInit(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
}
|
||||||
public void serverLoad(FMLServerStartingEvent event)
|
|
||||||
{
|
|
||||||
event.registerServerCommand(new CommandCarryOn());
|
|
||||||
event.registerServerCommand(new CommandCarryOnReload());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
21
src/main/java/tschipp/carryon/PickupHandler.java
Normal file
21
src/main/java/tschipp/carryon/PickupHandler.java
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
package tschipp.carryon;
|
||||||
|
|
||||||
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class PickupHandler {
|
||||||
|
|
||||||
|
public static boolean canPlayerPickUpBlock(PlayerEntity player, BlockEntity te, World world, BlockPos pos)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean canPlayerPickUpEntity(PlayerEntity player, Entity entity)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
25
src/main/java/tschipp/carryon/RegistryHandler.java
Normal file
25
src/main/java/tschipp/carryon/RegistryHandler.java
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
package tschipp.carryon;
|
||||||
|
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
import tschipp.carryon.items.ItemEntity;
|
||||||
|
import tschipp.carryon.items.ItemTile;
|
||||||
|
|
||||||
|
public class RegistryHandler {
|
||||||
|
|
||||||
|
public static Item TILE_ITEM;
|
||||||
|
public static Item ENTITY_ITEM;
|
||||||
|
|
||||||
|
public static void regItems()
|
||||||
|
{
|
||||||
|
TILE_ITEM = register(new ItemTile(), "tile_item");
|
||||||
|
ENTITY_ITEM = register(new ItemEntity(), "entity_item");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Item register(Item item, String name)
|
||||||
|
{
|
||||||
|
return Registry.register(Registry.ITEM, new Identifier(CarryOn.MODID, name), item);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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,390 +0,0 @@
|
||||||
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.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.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 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()[7];
|
|
||||||
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)
|
|
||||||
@SubscribeEvent
|
|
||||||
public void renderHand(RenderHandEvent event)
|
|
||||||
{
|
|
||||||
World world = Minecraft.getMinecraft().world;
|
|
||||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
|
||||||
int perspective = Minecraft.getMinecraft().gameSettings.thirdPersonView;
|
|
||||||
float partialticks = event.getPartialTicks();
|
|
||||||
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))
|
|
||||||
{
|
|
||||||
if(Loader.isModLoaded("realrender") || Loader.isModLoaded("rfpr"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
Entity entity = ItemEntity.getEntity(stack, world);
|
|
||||||
|
|
||||||
if (entity != null)
|
|
||||||
{
|
|
||||||
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialticks;
|
|
||||||
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialticks;
|
|
||||||
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialticks;
|
|
||||||
|
|
||||||
entity.setPosition(d0, d1, d2);
|
|
||||||
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();
|
|
||||||
|
|
||||||
if (perspective == 0)
|
|
||||||
{
|
|
||||||
RenderHelper.enableStandardItemLighting();
|
|
||||||
Minecraft.getMinecraft().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());
|
|
||||||
String entityname = carryOverride.getRenderNameEntity();
|
|
||||||
if (entityname != null)
|
|
||||||
{
|
|
||||||
Entity newEntity = EntityList.createEntityByIDFromName(new ResourceLocation(entityname), world);
|
|
||||||
if (newEntity != null)
|
|
||||||
{
|
|
||||||
NBTTagCompound nbttag = carryOverride.getRenderNBT();
|
|
||||||
if (nbttag != null)
|
|
||||||
newEntity.readFromNBT(nbttag);
|
|
||||||
entity = newEntity;
|
|
||||||
entity.setPosition(d0, d1, d2);
|
|
||||||
entity.rotationYaw = 0.0f;
|
|
||||||
entity.prevRotationYaw = 0.0f;
|
|
||||||
entity.setRotationYawHead(0.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
this.renderEntityStatic(entity);
|
|
||||||
Minecraft.getMinecraft().getRenderManager().setRenderShadow(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
GlStateManager.disableAlpha();
|
|
||||||
GlStateManager.scale(1, 1, 1);
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
|
|
||||||
RenderHelper.disableStandardItemLighting();
|
|
||||||
GlStateManager.disableRescaleNormal();
|
|
||||||
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
|
||||||
GlStateManager.disableTexture2D();
|
|
||||||
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
|
||||||
|
|
||||||
if (perspective == 0)
|
|
||||||
{
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
private void renderEntityStatic(Entity entity)
|
|
||||||
{
|
|
||||||
if (entity.ticksExisted == 0)
|
|
||||||
{
|
|
||||||
entity.lastTickPosX = entity.posX;
|
|
||||||
entity.lastTickPosY = entity.posY;
|
|
||||||
entity.lastTickPosZ = entity.posZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
float f = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw);
|
|
||||||
int i = this.getBrightnessForRender(entity, Minecraft.getMinecraft().player);
|
|
||||||
|
|
||||||
if (entity.isBurning())
|
|
||||||
{
|
|
||||||
i = 15728880;
|
|
||||||
}
|
|
||||||
|
|
||||||
int j = i % 65536;
|
|
||||||
int k = i / 65536;
|
|
||||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j, k);
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
|
|
||||||
this.setLightmapDisabled(false);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Minecraft.getMinecraft().getRenderManager().doRenderEntity(entity, 0.0D, 0.0D, 0.0D, f, 0.0F, true);
|
|
||||||
this.setLightmapDisabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
private int getBrightnessForRender(Entity entity, EntityPlayer player)
|
|
||||||
{
|
|
||||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor(player.posX), 0, MathHelper.floor(player.posZ));
|
|
||||||
|
|
||||||
if (entity.world.isBlockLoaded(blockpos$mutableblockpos))
|
|
||||||
{
|
|
||||||
blockpos$mutableblockpos.setY(MathHelper.floor(player.posY + entity.getEyeHeight()));
|
|
||||||
return entity.world.getCombinedLight(blockpos$mutableblockpos, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
private void setLightmapDisabled(boolean disabled)
|
|
||||||
{
|
|
||||||
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
|
||||||
|
|
||||||
if (disabled)
|
|
||||||
{
|
|
||||||
GlStateManager.disableTexture2D();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GlStateManager.enableTexture2D();
|
|
||||||
}
|
|
||||||
|
|
||||||
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Renders the Block in Third Person
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onPlayerRenderPost(RenderPlayerEvent.Post event)
|
|
||||||
{
|
|
||||||
World world = Minecraft.getMinecraft().world;
|
|
||||||
EntityPlayer player = event.getEntityPlayer();
|
|
||||||
event.getRenderer().getMainModel();
|
|
||||||
EntityPlayerSP clientPlayer = Minecraft.getMinecraft().player;
|
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
|
||||||
float partialticks = event.getPartialRenderTick();
|
|
||||||
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))
|
|
||||||
{
|
|
||||||
Entity entity = ItemEntity.getEntity(stack, world);
|
|
||||||
float rotation = -(player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialticks);
|
|
||||||
|
|
||||||
if (entity != null)
|
|
||||||
{
|
|
||||||
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialticks;
|
|
||||||
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialticks;
|
|
||||||
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialticks;
|
|
||||||
|
|
||||||
double c0 = clientPlayer.lastTickPosX + (clientPlayer.posX - clientPlayer.lastTickPosX) * partialticks;
|
|
||||||
double c1 = clientPlayer.lastTickPosY + (clientPlayer.posY - clientPlayer.lastTickPosY) * partialticks;
|
|
||||||
double c2 = clientPlayer.lastTickPosZ + (clientPlayer.posZ - clientPlayer.lastTickPosZ) * partialticks;
|
|
||||||
|
|
||||||
double xOffset = d0 - c0;
|
|
||||||
double yOffset = d1 - c1;
|
|
||||||
double zOffset = d2 - c2;
|
|
||||||
|
|
||||||
float height = entity.height;
|
|
||||||
float width = entity.width;
|
|
||||||
float multiplier = height * width;
|
|
||||||
|
|
||||||
entity.setPosition(c0, c1, c2);
|
|
||||||
entity.rotationYaw = 0.0f;
|
|
||||||
entity.prevRotationYaw = 0.0f;
|
|
||||||
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);
|
|
||||||
|
|
||||||
if((Loader.isModLoaded("realrender") || Loader.isModLoaded("rfpr")) && Minecraft.getMinecraft().gameSettings.thirdPersonView == 0)
|
|
||||||
GlStateManager.translate(0, 0, -0.3);
|
|
||||||
|
|
||||||
if (player.isSneaking())
|
|
||||||
{
|
|
||||||
GlStateManager.translate(0, -0.3, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Minecraft.getMinecraft().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());
|
|
||||||
String entityname = carryOverride.getRenderNameEntity();
|
|
||||||
if (entityname != null)
|
|
||||||
{
|
|
||||||
Entity newEntity = EntityList.createEntityByIDFromName(new ResourceLocation(entityname), world);
|
|
||||||
if (newEntity != null)
|
|
||||||
{
|
|
||||||
NBTTagCompound nbttag = carryOverride.getRenderNBT();
|
|
||||||
if (nbttag != null)
|
|
||||||
newEntity.readFromNBT(nbttag);
|
|
||||||
entity = newEntity;
|
|
||||||
entity.setPosition(c0, c1, c2);
|
|
||||||
entity.rotationYaw = 0.0f;
|
|
||||||
entity.prevRotationYaw = 0.0f;
|
|
||||||
entity.setRotationYawHead(0.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Minecraft.getMinecraft().getRenderManager().renderEntityStatic(entity, 0.0f, false);
|
|
||||||
Minecraft.getMinecraft().getRenderManager().setRenderShadow(true);
|
|
||||||
|
|
||||||
GlStateManager.scale(1, 1, 1);
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,827 +0,0 @@
|
||||||
package tschipp.carryon.client.event;
|
|
||||||
|
|
||||||
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.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.texture.TextureMap;
|
|
||||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
|
||||||
import net.minecraft.client.settings.GameSettings;
|
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.entity.player.EnumPlayerModelParts;
|
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
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.GuiScreenEvent.InitGuiEvent;
|
|
||||||
import net.minecraftforge.client.event.MouseEvent;
|
|
||||||
import net.minecraftforge.client.event.RenderHandEvent;
|
|
||||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
|
||||||
import net.minecraftforge.fml.common.Loader;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
|
||||||
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.handler.ModelOverridesHandler;
|
|
||||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
|
||||||
import tschipp.carryon.common.helper.ScriptParseHelper;
|
|
||||||
import tschipp.carryon.common.helper.StringParser;
|
|
||||||
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.network.server.SyncKeybindPacket;
|
|
||||||
|
|
||||||
public class RenderEvents
|
|
||||||
{
|
|
||||||
private static boolean initModels;
|
|
||||||
private ModelRenderer fakeLeftArm;
|
|
||||||
private ModelRenderer fakeRightArm;
|
|
||||||
private ModelRenderer fakeLeftArmwear;
|
|
||||||
private ModelRenderer fakeRightArmwear;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Prevents the Player from scrolling
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onScroll(MouseEvent event)
|
|
||||||
{
|
|
||||||
if (event.getDwheel() > 0 || event.getDwheel() < 0 || Minecraft.getMinecraft().gameSettings.keyBindPickBlock.isPressed())
|
|
||||||
{
|
|
||||||
ItemStack stack = Minecraft.getMinecraft().player.getHeldItemMainhand();
|
|
||||||
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile)
|
|
||||||
{
|
|
||||||
if (ItemTile.hasTileData(stack))
|
|
||||||
{
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void onPlayerTick(PlayerTickEvent event) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
|
|
||||||
{
|
|
||||||
EntityPlayer player = event.player;
|
|
||||||
|
|
||||||
if (player != null && event.side == Side.CLIENT)
|
|
||||||
{
|
|
||||||
boolean keyPressed = CarryOnKeybinds.carryKey.isKeyDown();
|
|
||||||
boolean playerKeyPressed = CarryOnKeybinds.isKeyPressed(player);
|
|
||||||
|
|
||||||
if (keyPressed && !playerKeyPressed)
|
|
||||||
{
|
|
||||||
CarryOnKeybinds.setKeyPressed(player, true);
|
|
||||||
CarryOn.network.sendToServer(new SyncKeybindPacket(true));
|
|
||||||
}
|
|
||||||
else if (!keyPressed && playerKeyPressed)
|
|
||||||
{
|
|
||||||
CarryOnKeybinds.setKeyPressed(player, false);
|
|
||||||
CarryOn.network.sendToServer(new SyncKeybindPacket(false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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.itemTile && ItemTile.hasTileData(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
|
|
||||||
{
|
|
||||||
GameSettings settings = Minecraft.getMinecraft().gameSettings;
|
|
||||||
Field field = KeyBinding.class.getDeclaredFields()[7];
|
|
||||||
field.setAccessible(true);
|
|
||||||
ItemStack stack = Minecraft.getMinecraft().player.getHeldItemMainhand();
|
|
||||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
|
||||||
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(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 Block in First Person
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@SubscribeEvent
|
|
||||||
public void renderHand(RenderHandEvent event)
|
|
||||||
{
|
|
||||||
World world = Minecraft.getMinecraft().world;
|
|
||||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
|
||||||
AbstractClientPlayer aplayer = (AbstractClientPlayer) player;
|
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
|
||||||
int perspective = Minecraft.getMinecraft().gameSettings.thirdPersonView;
|
|
||||||
boolean f1 = Minecraft.getMinecraft().gameSettings.hideGUI;
|
|
||||||
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack) && perspective == 0 && !f1)
|
|
||||||
{
|
|
||||||
if (Loader.isModLoaded("realrender") || Loader.isModLoaded("rfpr"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Block block = ItemTile.getBlock(stack);
|
|
||||||
NBTTagCompound tag = ItemTile.getTileData(stack);
|
|
||||||
IBlockState state = ItemTile.getBlockState(stack);
|
|
||||||
ItemStack tileStack = ItemTile.getItemStack(stack);
|
|
||||||
|
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
GlStateManager.scale(2.5, 2.5, 2.5);
|
|
||||||
GlStateManager.translate(0, -0.6, -1);
|
|
||||||
|
|
||||||
if (CarryOnConfig.settings.facePlayer ? !isChest(block) : isChest(block))
|
|
||||||
{
|
|
||||||
GlStateManager.rotate(180, 0, 1f, 0);
|
|
||||||
GlStateManager.rotate(-8, 1f, 0, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GlStateManager.rotate(8, 1f, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : Minecraft.getMinecraft().getRenderItem().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());
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int i = this.getBrightnessForRender(Minecraft.getMinecraft().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);
|
|
||||||
this.setLightmapDisabled(false);
|
|
||||||
|
|
||||||
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
|
||||||
|
|
||||||
if (ModelOverridesHandler.hasCustomOverrideModel(state, tag))
|
|
||||||
{
|
|
||||||
Object override = ModelOverridesHandler.getOverrideObject(state, tag);
|
|
||||||
|
|
||||||
if (override instanceof ItemStack)
|
|
||||||
{
|
|
||||||
|
|
||||||
Minecraft.getMinecraft().getRenderItem().renderItem((ItemStack) override, model);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Minecraft.getMinecraft().getRenderItem().renderItem(tileStack.isEmpty() ? stack : tileStack, model);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Minecraft.getMinecraft().getRenderItem().renderItem(tileStack.isEmpty() ? stack : tileStack, model);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setLightmapDisabled(true);
|
|
||||||
|
|
||||||
if (perspective == 0)
|
|
||||||
{
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
GlStateManager.scale(1, 1, 1);
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (stack.isEmpty() ? true : stack.getItem() != RegistrationHandler.itemEntity)
|
|
||||||
{
|
|
||||||
event.setCanceled(false);
|
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
RenderManager manager = mc.getRenderManager();
|
|
||||||
RenderPlayer renderPlayer = manager.getSkinMap().get(aplayer.getSkinType());
|
|
||||||
ModelPlayer modelPlayer = renderPlayer.getMainModel();
|
|
||||||
|
|
||||||
if (modelPlayer != null)
|
|
||||||
{
|
|
||||||
if (modelPlayer.bipedLeftArm != null && modelPlayer.bipedRightArm != null)
|
|
||||||
{
|
|
||||||
modelPlayer.bipedLeftArm.isHidden = false;
|
|
||||||
modelPlayer.bipedRightArm.isHidden = false;
|
|
||||||
modelPlayer.bipedLeftArmwear.isHidden = false;
|
|
||||||
modelPlayer.bipedRightArmwear.isHidden = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
private int getBrightnessForRender(EntityPlayer player)
|
|
||||||
{
|
|
||||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor(player.posX), 0, MathHelper.floor(player.posZ));
|
|
||||||
|
|
||||||
if (player.world.isBlockLoaded(blockpos$mutableblockpos))
|
|
||||||
{
|
|
||||||
blockpos$mutableblockpos.setY(MathHelper.floor(player.posY + player.getEyeHeight()));
|
|
||||||
return player.world.getCombinedLight(blockpos$mutableblockpos, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
private void setLightmapDisabled(boolean disabled)
|
|
||||||
{
|
|
||||||
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
|
||||||
|
|
||||||
if (disabled)
|
|
||||||
{
|
|
||||||
GlStateManager.disableTexture2D();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GlStateManager.enableTexture2D();
|
|
||||||
}
|
|
||||||
|
|
||||||
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Renders the Block in Third Person
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onPlayerRenderPost(RenderPlayerEvent.Post event)
|
|
||||||
{
|
|
||||||
World world = Minecraft.getMinecraft().world;
|
|
||||||
EntityPlayer player = event.getEntityPlayer();
|
|
||||||
EntityPlayerSP clientPlayer = Minecraft.getMinecraft().player;
|
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
|
||||||
float partialticks = event.getPartialRenderTick();
|
|
||||||
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack))
|
|
||||||
{
|
|
||||||
Block block = ItemTile.getBlock(stack);
|
|
||||||
IBlockState state = ItemTile.getBlockState(stack);
|
|
||||||
NBTTagCompound tag = ItemTile.getTileData(stack);
|
|
||||||
ItemStack tileItem = ItemTile.getItemStack(stack);
|
|
||||||
|
|
||||||
float rotation = -(player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialticks);
|
|
||||||
|
|
||||||
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialticks;
|
|
||||||
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialticks;
|
|
||||||
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialticks;
|
|
||||||
|
|
||||||
double c0 = clientPlayer.lastTickPosX + (clientPlayer.posX - clientPlayer.lastTickPosX) * partialticks;
|
|
||||||
double c1 = clientPlayer.lastTickPosY + (clientPlayer.posY - clientPlayer.lastTickPosY) * partialticks;
|
|
||||||
double c2 = clientPlayer.lastTickPosZ + (clientPlayer.posZ - clientPlayer.lastTickPosZ) * partialticks;
|
|
||||||
|
|
||||||
double xOffset = d0 - c0;
|
|
||||||
double yOffset = d1 - c1;
|
|
||||||
double zOffset = d2 - c2;
|
|
||||||
|
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
GlStateManager.translate(xOffset, yOffset, zOffset);
|
|
||||||
GlStateManager.scale(0.6, 0.6, 0.6);
|
|
||||||
|
|
||||||
if (CarryOnConfig.settings.facePlayer ? !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.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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player.isSneaking())
|
|
||||||
{
|
|
||||||
GlStateManager.translate(0, -0.3, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : Minecraft.getMinecraft().getRenderItem().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());
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
|
||||||
|
|
||||||
if (ModelOverridesHandler.hasCustomOverrideModel(state, tag))
|
|
||||||
{
|
|
||||||
Object override = ModelOverridesHandler.getOverrideObject(state, tag);
|
|
||||||
|
|
||||||
if (override instanceof ItemStack)
|
|
||||||
{
|
|
||||||
Minecraft.getMinecraft().getRenderItem().renderItem((ItemStack) override, model);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Minecraft.getMinecraft().getRenderItem().renderItem(tileItem.isEmpty() ? stack : tileItem, model);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Minecraft.getMinecraft().getRenderItem().renderItem(tileItem.isEmpty() ? stack : tileItem, model);
|
|
||||||
}
|
|
||||||
|
|
||||||
GlStateManager.scale(1, 1, 1);
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Renders correct arm rotation
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onPlayerRenderPre(RenderPlayerEvent.Pre event)
|
|
||||||
{
|
|
||||||
if (!Loader.isModLoaded("mobends") && CarryOnConfig.settings.renderArms)
|
|
||||||
{
|
|
||||||
EntityPlayer player = event.getEntityPlayer();
|
|
||||||
AbstractClientPlayer aplayer = (AbstractClientPlayer) player;
|
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
|
||||||
ModelPlayer model = event.getRenderer().getMainModel();
|
|
||||||
ResourceLocation skinLoc = DefaultPlayerSkin.getDefaultSkin(player.getPersistentID());
|
|
||||||
|
|
||||||
if (!initModels)
|
|
||||||
{
|
|
||||||
this.fakeLeftArm = new ModelRenderer(model, 32, 48);
|
|
||||||
this.fakeRightArm = new ModelRenderer(model, 40, 16);
|
|
||||||
this.fakeLeftArmwear = new ModelRenderer(model, 48, 48);
|
|
||||||
this.fakeRightArmwear = new ModelRenderer(model, 40, 32);
|
|
||||||
initModels = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
player.setArrowCountInEntity(0); // TODO Temporary Fix
|
|
||||||
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))
|
|
||||||
{
|
|
||||||
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
|
||||||
if (overrider != null)
|
|
||||||
{
|
|
||||||
if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty())
|
|
||||||
{
|
|
||||||
for (int k = 0; k < model.bipedBody.childModels.size(); k++)
|
|
||||||
{
|
|
||||||
double[] rotLeft1 = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
|
|
||||||
double[] rotRight1 = ScriptParseHelper.getXYZArray(overrider.getRenderRotationRightArm());
|
|
||||||
|
|
||||||
float rotX = model.bipedBody.childModels.get(k).rotateAngleX;
|
|
||||||
float rotY = model.bipedBody.childModels.get(k).rotateAngleY;
|
|
||||||
float rotZ = model.bipedBody.childModels.get(k).rotateAngleZ;
|
|
||||||
|
|
||||||
if (rotLeft1[0] == rotX || rotLeft1[1] == rotY || rotRight1[2] == rotZ || rotRight1[0] == rotX || rotRight1[1] == rotY || rotRight1[2] == rotZ || rotX == rotLeft1[0] - 0.5f || rotX == rotRight1[0] - 0.5f)
|
|
||||||
{
|
|
||||||
model.bipedBody.childModels.remove(k);
|
|
||||||
k = k - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty())
|
|
||||||
{
|
|
||||||
for (int k = 0; k < model.bipedBody.childModels.size(); k++)
|
|
||||||
{
|
|
||||||
float chkRot = model.bipedBody.childModels.get(k).rotateAngleX;
|
|
||||||
|
|
||||||
if (chkRot == -0.9001F || chkRot == -1.2001F || chkRot == -1.4001F || chkRot == -1.7001F)
|
|
||||||
{
|
|
||||||
model.bipedBody.childModels.remove(k);
|
|
||||||
k = k - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Item item = stack.getItem();
|
|
||||||
|
|
||||||
model.bipedLeftArm.isHidden = true;
|
|
||||||
model.bipedRightArm.isHidden = true;
|
|
||||||
model.bipedLeftArmwear.isHidden = true;
|
|
||||||
model.bipedRightArmwear.isHidden = true;
|
|
||||||
this.fakeLeftArm.isHidden = false;
|
|
||||||
this.fakeLeftArmwear.isHidden = false;
|
|
||||||
this.fakeRightArm.isHidden = false;
|
|
||||||
this.fakeRightArmwear.isHidden = false;
|
|
||||||
|
|
||||||
Minecraft.getMinecraft().getTextureManager().bindTexture(skinLoc);
|
|
||||||
|
|
||||||
if (aplayer.getSkinType().equals("default"))
|
|
||||||
{
|
|
||||||
// left arm
|
|
||||||
this.fakeLeftArm.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 4, 12, 4, .08F);
|
|
||||||
this.fakeLeftArmwear.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 4, 12, 4, .08F + 0.25F);
|
|
||||||
|
|
||||||
// right arm
|
|
||||||
this.fakeRightArm.addBox(model.bipedRightArm.offsetX - 7.9F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 4, 12, 4, .08F);
|
|
||||||
this.fakeRightArmwear.addBox(model.bipedRightArm.offsetX - 7.9F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 4, 12, 4, .08F + 0.25F);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// left arm
|
|
||||||
this.fakeLeftArm.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 3, 12, 4, .08F);
|
|
||||||
this.fakeLeftArmwear.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 3, 12, 4, .08F + 0.25F);
|
|
||||||
|
|
||||||
// right arm
|
|
||||||
this.fakeRightArm.addBox(model.bipedRightArm.offsetX - 7.2F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 3, 12, 4, .08F);
|
|
||||||
this.fakeRightArmwear.addBox(model.bipedRightArm.offsetX - 7.2F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 3, 12, 4, .08F + 0.25F);
|
|
||||||
}
|
|
||||||
|
|
||||||
CarryOnOverride override = ScriptChecker.getOverride(player);
|
|
||||||
if (override != null)
|
|
||||||
{
|
|
||||||
double[] rotLeft = null;
|
|
||||||
double[] rotRight = null;
|
|
||||||
if (override.getRenderRotationLeftArm() != null)
|
|
||||||
rotLeft = ScriptParseHelper.getXYZArray(override.getRenderRotationLeftArm());
|
|
||||||
if (override.getRenderRotationRightArm() != null)
|
|
||||||
rotRight = ScriptParseHelper.getXYZArray(override.getRenderRotationRightArm());
|
|
||||||
|
|
||||||
boolean renderRight = override.isRenderRightArm();
|
|
||||||
boolean renderLeft = override.isRenderLeftArm();
|
|
||||||
|
|
||||||
if (!renderRight)
|
|
||||||
{
|
|
||||||
this.fakeRightArm.isHidden = true;
|
|
||||||
this.fakeRightArmwear.isHidden = true;
|
|
||||||
model.bipedRightArm.isHidden = false;
|
|
||||||
model.bipedRightArmwear.isHidden = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!renderLeft)
|
|
||||||
{
|
|
||||||
this.fakeLeftArm.isHidden = true;
|
|
||||||
this.fakeLeftArmwear.isHidden = true;
|
|
||||||
model.bipedLeftArm.isHidden = false;
|
|
||||||
model.bipedLeftArmwear.isHidden = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rotLeft != null)
|
|
||||||
{
|
|
||||||
if (!player.isSneaking())
|
|
||||||
{
|
|
||||||
this.fakeLeftArm.rotateAngleX = (float) rotLeft[0];
|
|
||||||
this.fakeLeftArmwear.rotateAngleX = (float) rotLeft[0];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.fakeLeftArm.rotateAngleX = (float) rotLeft[0] - 0.5f;
|
|
||||||
this.fakeLeftArmwear.rotateAngleX = (float) rotLeft[0] - 0.5f;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.fakeLeftArmwear.rotateAngleY = (float) rotLeft[1];
|
|
||||||
this.fakeLeftArmwear.rotateAngleZ = (float) rotLeft[2];
|
|
||||||
this.fakeLeftArm.rotateAngleY = (float) rotLeft[1];
|
|
||||||
this.fakeLeftArm.rotateAngleZ = (float) rotLeft[2];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (item == RegistrationHandler.itemTile)
|
|
||||||
{
|
|
||||||
if (!player.isSneaking())
|
|
||||||
{
|
|
||||||
this.fakeLeftArm.rotateAngleX = -.9001F;
|
|
||||||
this.fakeLeftArmwear.rotateAngleX = -.9001F;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.fakeLeftArm.rotateAngleX = -1.4001F;
|
|
||||||
this.fakeLeftArmwear.rotateAngleX = -1.4001F;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!player.isSneaking())
|
|
||||||
{
|
|
||||||
this.fakeLeftArm.rotateAngleX = -1.2001F;
|
|
||||||
this.fakeLeftArmwear.rotateAngleX = -1.2001F;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.fakeLeftArm.rotateAngleX = -1.7001F;
|
|
||||||
this.fakeLeftArmwear.rotateAngleX = -1.7001F;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.fakeLeftArm.rotateAngleY = 0.15f;
|
|
||||||
this.fakeLeftArmwear.rotateAngleY = 0.15f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rotRight != null)
|
|
||||||
{
|
|
||||||
if (!player.isSneaking())
|
|
||||||
{
|
|
||||||
this.fakeRightArm.rotateAngleX = (float) rotRight[0];
|
|
||||||
this.fakeRightArmwear.rotateAngleX = (float) rotRight[0];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.fakeRightArm.rotateAngleX = (float) rotRight[0] - 0.5f;
|
|
||||||
this.fakeRightArmwear.rotateAngleX = (float) rotRight[0] - 0.5f;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.fakeRightArmwear.rotateAngleY = (float) rotRight[1];
|
|
||||||
this.fakeRightArmwear.rotateAngleZ = (float) rotRight[2];
|
|
||||||
this.fakeRightArm.rotateAngleY = (float) rotRight[1];
|
|
||||||
this.fakeRightArm.rotateAngleZ = (float) rotRight[2];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (item == RegistrationHandler.itemTile)
|
|
||||||
{
|
|
||||||
if (!player.isSneaking())
|
|
||||||
{
|
|
||||||
this.fakeRightArm.rotateAngleX = -.9001F;
|
|
||||||
this.fakeRightArmwear.rotateAngleX = -.9001F;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.fakeRightArm.rotateAngleX = -1.4001F;
|
|
||||||
this.fakeRightArmwear.rotateAngleX = -1.4001F;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!player.isSneaking())
|
|
||||||
{
|
|
||||||
this.fakeRightArm.rotateAngleX = -1.2001F;
|
|
||||||
this.fakeRightArmwear.rotateAngleX = -1.2001F;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.fakeRightArm.rotateAngleX = -1.7001F;
|
|
||||||
this.fakeRightArmwear.rotateAngleX = -1.7001F;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.fakeRightArm.rotateAngleY = -0.15f;
|
|
||||||
this.fakeRightArmwear.rotateAngleY = -0.15f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (item == RegistrationHandler.itemTile)
|
|
||||||
{
|
|
||||||
if (!player.isSneaking())
|
|
||||||
{
|
|
||||||
this.fakeRightArm.rotateAngleX = -.9001F;
|
|
||||||
this.fakeLeftArm.rotateAngleX = -.9001F;
|
|
||||||
this.fakeLeftArmwear.rotateAngleX = -.9001F;
|
|
||||||
this.fakeRightArmwear.rotateAngleX = -.9001F;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.fakeRightArm.rotateAngleX = -1.4001F;
|
|
||||||
this.fakeLeftArm.rotateAngleX = -1.4001F;
|
|
||||||
this.fakeLeftArmwear.rotateAngleX = -1.4001F;
|
|
||||||
this.fakeRightArmwear.rotateAngleX = -1.4001F;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.fakeRightArm.rotateAngleY = 0f;
|
|
||||||
this.fakeLeftArm.rotateAngleY = 0f;
|
|
||||||
this.fakeLeftArmwear.rotateAngleY = 0f;
|
|
||||||
this.fakeRightArmwear.rotateAngleY = 0f;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!player.isSneaking())
|
|
||||||
{
|
|
||||||
this.fakeRightArm.rotateAngleX = -1.2001F;
|
|
||||||
this.fakeLeftArm.rotateAngleX = -1.2001F;
|
|
||||||
this.fakeLeftArmwear.rotateAngleX = -1.2001F;
|
|
||||||
this.fakeRightArmwear.rotateAngleX = -1.2001F;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.fakeRightArm.rotateAngleX = -1.7001F;
|
|
||||||
this.fakeLeftArm.rotateAngleX = -1.7001F;
|
|
||||||
this.fakeLeftArmwear.rotateAngleX = -1.7001F;
|
|
||||||
this.fakeRightArmwear.rotateAngleX = -1.7001F;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.fakeRightArm.rotateAngleY = -0.15f;
|
|
||||||
this.fakeLeftArm.rotateAngleY = 0.15f;
|
|
||||||
this.fakeLeftArmwear.rotateAngleY = 0.15f;
|
|
||||||
this.fakeRightArmwear.rotateAngleY = -0.15f;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.fakeRightArm.rotateAngleZ = 0F;
|
|
||||||
this.fakeLeftArm.rotateAngleZ = 0F;
|
|
||||||
this.fakeLeftArmwear.rotateAngleZ = 0F;
|
|
||||||
this.fakeRightArmwear.rotateAngleZ = 0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
model.bipedBody.addChild(this.fakeLeftArm);
|
|
||||||
model.bipedBody.addChild(this.fakeRightArm);
|
|
||||||
|
|
||||||
if (player.isWearing(EnumPlayerModelParts.LEFT_SLEEVE))
|
|
||||||
{
|
|
||||||
model.bipedBody.addChild(this.fakeLeftArmwear);
|
|
||||||
}
|
|
||||||
if (player.isWearing(EnumPlayerModelParts.RIGHT_SLEEVE))
|
|
||||||
{
|
|
||||||
model.bipedBody.addChild(this.fakeRightArmwear);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
model.bipedLeftArm.isHidden = false;
|
|
||||||
model.bipedRightArm.isHidden = false;
|
|
||||||
model.bipedLeftArmwear.isHidden = false;
|
|
||||||
model.bipedRightArmwear.isHidden = false;
|
|
||||||
|
|
||||||
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
|
||||||
if (overrider != null)
|
|
||||||
{
|
|
||||||
if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty())
|
|
||||||
{
|
|
||||||
for (int k = 0; k < model.bipedBody.childModels.size(); k++)
|
|
||||||
{
|
|
||||||
double[] rotLeft1 = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
|
|
||||||
double[] rotRight1 = ScriptParseHelper.getXYZArray(overrider.getRenderRotationRightArm());
|
|
||||||
|
|
||||||
float rotX = model.bipedBody.childModels.get(k).rotateAngleX;
|
|
||||||
float rotY = model.bipedBody.childModels.get(k).rotateAngleY;
|
|
||||||
float rotZ = model.bipedBody.childModels.get(k).rotateAngleZ;
|
|
||||||
|
|
||||||
if (rotLeft1[0] == rotX || rotLeft1[1] == rotY || rotRight1[2] == rotZ || rotRight1[0] == rotX || rotRight1[1] == rotY || rotRight1[2] == rotZ || rotX == rotLeft1[0] - 0.5f || rotX == rotRight1[0] - 0.5f)
|
|
||||||
{
|
|
||||||
model.bipedBody.childModels.remove(k);
|
|
||||||
k = k - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty())
|
|
||||||
{
|
|
||||||
for (int k = 0; k < model.bipedBody.childModels.size(); k++)
|
|
||||||
{
|
|
||||||
float chkRot = model.bipedBody.childModels.get(k).rotateAngleX;
|
|
||||||
|
|
||||||
if (chkRot == -0.9001F || chkRot == -1.2001F || chkRot == -1.4001F || chkRot == -1.7001F)
|
|
||||||
{
|
|
||||||
model.bipedBody.childModels.remove(k);
|
|
||||||
k = k - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stack.isEmpty() || stack.getItem() != RegistrationHandler.itemTile && stack.getItem() != RegistrationHandler.itemEntity)
|
|
||||||
{
|
|
||||||
model.bipedLeftArm.isHidden = false;
|
|
||||||
model.bipedRightArm.isHidden = false;
|
|
||||||
model.bipedLeftArmwear.isHidden = false;
|
|
||||||
model.bipedRightArmwear.isHidden = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isChest(Block block)
|
|
||||||
{
|
|
||||||
return block == Blocks.CHEST || block == Blocks.ENDER_CHEST || block == Blocks.TRAPPED_CHEST;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
private static RenderPlayer getRenderPlayer(AbstractClientPlayer player)
|
|
||||||
{
|
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
RenderManager manager = mc.getRenderManager();
|
|
||||||
return manager.getSkinMap().get(player.getSkinType());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
private static ModelPlayer getPlayerModel(AbstractClientPlayer player)
|
|
||||||
{
|
|
||||||
return getRenderPlayer(player).getMainModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void hideItems(RenderPlayerEvent.Specials.Pre event)
|
|
||||||
{
|
|
||||||
EntityPlayer player = event.getEntityPlayer();
|
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
|
||||||
|
|
||||||
if (stack != null && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
|
||||||
{
|
|
||||||
event.setRenderItem(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
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,44 +0,0 @@
|
||||||
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.fml.client.registry.ClientRegistry;
|
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
public class CarryOnKeybinds
|
|
||||||
{
|
|
||||||
|
|
||||||
public static final String KEYBIND_KEY = "carryOnKeyPressed";
|
|
||||||
public static KeyBinding carryKey;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public static void init()
|
|
||||||
{
|
|
||||||
carryKey = new KeyBinding("key.carry.desc", Keyboard.KEY_LSHIFT, "key.carry.category");
|
|
||||||
|
|
||||||
ClientRegistry.registerKeyBinding(carryKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isKeyPressed(EntityPlayer player)
|
|
||||||
{
|
|
||||||
NBTTagCompound tag = player.getEntityData();
|
|
||||||
if(tag != null && tag.hasKey(KEYBIND_KEY))
|
|
||||||
{
|
|
||||||
return tag.getBoolean(KEYBIND_KEY);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setKeyPressed(EntityPlayer player, boolean pressed)
|
|
||||||
{
|
|
||||||
NBTTagCompound tag = player.getEntityData();
|
|
||||||
tag.setBoolean(KEYBIND_KEY, pressed);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
package tschipp.carryon.client.model;
|
|
||||||
|
|
||||||
import net.minecraft.client.model.ModelPlayer;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
|
|
||||||
public class ModelPlayerCarrying extends ModelPlayer
|
|
||||||
{
|
|
||||||
|
|
||||||
public ModelPlayerCarrying(float modelSize, boolean smallArmsIn)
|
|
||||||
{
|
|
||||||
super(modelSize, smallArmsIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
|
|
||||||
{
|
|
||||||
super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -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,16 +0,0 @@
|
||||||
package tschipp.carryon.common.capabilities;
|
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
|
|
||||||
public interface IPosition {
|
|
||||||
|
|
||||||
public BlockPos getPos();
|
|
||||||
|
|
||||||
public void setPos(BlockPos pos);
|
|
||||||
|
|
||||||
public boolean isBlockActivated();
|
|
||||||
|
|
||||||
public void setBlockActivated(boolean b);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
package tschipp.carryon.common.capabilities;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTBase;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
|
||||||
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
|
||||||
|
|
||||||
public class PositionProvider implements ICapabilitySerializable {
|
|
||||||
|
|
||||||
@CapabilityInject(IPosition.class)
|
|
||||||
public static final Capability<IPosition> POSITION_CAPABILITY = null;
|
|
||||||
|
|
||||||
private IPosition instance = POSITION_CAPABILITY.getDefaultInstance();
|
|
||||||
|
|
||||||
|
|
||||||
@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,41 +0,0 @@
|
||||||
package tschipp.carryon.common.capabilities;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTBase;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability.IStorage;
|
|
||||||
|
|
||||||
public class PositionStorage implements IStorage<IPosition> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase 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());
|
|
||||||
|
|
||||||
return tag;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readNBT(Capability<IPosition> capability, IPosition instance, EnumFacing side, NBTBase nbt) {
|
|
||||||
|
|
||||||
NBTTagCompound tag = (NBTTagCompound) nbt;
|
|
||||||
|
|
||||||
int x = tag.getInteger("x");
|
|
||||||
int y = tag.getInteger("y");
|
|
||||||
int z = tag.getInteger("z");
|
|
||||||
|
|
||||||
BlockPos pos = new BlockPos(x,y,z);
|
|
||||||
|
|
||||||
instance.setPos(pos);
|
|
||||||
instance.setBlockActivated(tag.getBoolean("blockActivated"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
package tschipp.carryon.common.capabilities;
|
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
|
|
||||||
public class TEPosition implements IPosition {
|
|
||||||
|
|
||||||
private BlockPos pos = new BlockPos(0, 0, 0);
|
|
||||||
private boolean blockActivated = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockPos getPos()
|
|
||||||
{
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void setPos(BlockPos pos)
|
|
||||||
{
|
|
||||||
this.pos = pos;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public boolean isBlockActivated()
|
|
||||||
{
|
|
||||||
return blockActivated;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void setBlockActivated(boolean b)
|
|
||||||
{
|
|
||||||
this.blockActivated = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
||||||
package tschipp.carryon.common.capabilities.event;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
||||||
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.client.event.GuiScreenEvent;
|
|
||||||
import net.minecraftforge.event.entity.player.PlayerContainerEvent;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
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;
|
|
||||||
|
|
||||||
public class PositionClientEvents
|
|
||||||
{
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onGui(GuiScreenEvent.DrawScreenEvent event)
|
|
||||||
{
|
|
||||||
if (event.getGui() != null)
|
|
||||||
{
|
|
||||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
|
||||||
boolean inventory = event.getGui() instanceof GuiContainer;
|
|
||||||
|
|
||||||
if (player != null && inventory)
|
|
||||||
{
|
|
||||||
if(player.hasCapability(PositionProvider.POSITION_CAPABILITY, null))
|
|
||||||
{
|
|
||||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY, null);
|
|
||||||
if(cap.isBlockActivated())
|
|
||||||
{
|
|
||||||
World world = player.world;
|
|
||||||
BlockPos pos = cap.getPos();
|
|
||||||
if(world != null)
|
|
||||||
{
|
|
||||||
TileEntity te = world.getTileEntity(pos);
|
|
||||||
if(te == null)
|
|
||||||
{
|
|
||||||
// player.openContainer = null;
|
|
||||||
Minecraft.getMinecraft().currentScreen = null;
|
|
||||||
Minecraft.getMinecraft().setIngameFocus();
|
|
||||||
cap.setBlockActivated(false);
|
|
||||||
cap.setPos(new BlockPos(0,0,0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onGuiClose(PlayerContainerEvent.Close event)
|
|
||||||
{
|
|
||||||
EntityPlayer player = event.getEntityPlayer();
|
|
||||||
if(player.hasCapability(PositionProvider.POSITION_CAPABILITY, null))
|
|
||||||
{
|
|
||||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY, null);
|
|
||||||
cap.setBlockActivated(false);
|
|
||||||
cap.setPos(new BlockPos(0,0,0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onPlayerTick(PlayerTickEvent event)
|
|
||||||
{
|
|
||||||
if (event.side == Side.CLIENT)
|
|
||||||
{
|
|
||||||
EntityPlayer player = event.player;
|
|
||||||
if (player.hasCapability(PositionProvider.POSITION_CAPABILITY, null))
|
|
||||||
{
|
|
||||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY, null);
|
|
||||||
if (cap.isBlockActivated() && Minecraft.getMinecraft().currentScreen == null)
|
|
||||||
{
|
|
||||||
cap.setBlockActivated(false);
|
|
||||||
cap.setPos(new BlockPos(0, 0, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
package tschipp.carryon.common.capabilities.event;
|
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
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 tschipp.carryon.CarryOn;
|
|
||||||
import tschipp.carryon.common.capabilities.IPosition;
|
|
||||||
import tschipp.carryon.common.capabilities.PositionProvider;
|
|
||||||
|
|
||||||
public class PositionCommonEvents
|
|
||||||
{
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onAttachCaps(AttachCapabilitiesEvent<Entity> event)
|
|
||||||
{
|
|
||||||
if (event.getObject() instanceof EntityPlayer)
|
|
||||||
{
|
|
||||||
event.addCapability(new ResourceLocation(CarryOn.MODID, "position"), new PositionProvider());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onBlockRight(PlayerInteractEvent.RightClickBlock event)
|
|
||||||
{
|
|
||||||
BlockPos pos = event.getPos();
|
|
||||||
World world = event.getWorld();
|
|
||||||
EntityPlayer player = event.getEntityPlayer();
|
|
||||||
|
|
||||||
if (event.isCanceled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (player == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (player instanceof FakePlayer)
|
|
||||||
return;
|
|
||||||
|
|
||||||
TileEntity te = world.getTileEntity(pos);
|
|
||||||
if (te != null)
|
|
||||||
{
|
|
||||||
if (player.hasCapability(PositionProvider.POSITION_CAPABILITY, null))
|
|
||||||
{
|
|
||||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY, null);
|
|
||||||
cap.setBlockActivated(true);
|
|
||||||
cap.setPos(pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,194 +0,0 @@
|
||||||
package tschipp.carryon.common.command;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
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 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 tschipp.carryon.CarryOn;
|
|
||||||
import tschipp.carryon.common.handler.CustomPickupOverrideHandler;
|
|
||||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
|
||||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
|
||||||
import tschipp.carryon.common.item.ItemEntity;
|
|
||||||
import tschipp.carryon.common.item.ItemTile;
|
|
||||||
import tschipp.carryon.common.scripting.ScriptReader;
|
|
||||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
|
||||||
|
|
||||||
public class CommandCarryOn extends CommandBase implements ICommand
|
|
||||||
{
|
|
||||||
|
|
||||||
private final List names;
|
|
||||||
|
|
||||||
public CommandCarryOn()
|
|
||||||
{
|
|
||||||
names = new ArrayList();
|
|
||||||
names.add("carryon");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(ICommand o)
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
// Handling clear
|
|
||||||
if (args[0].toLowerCase().equals("clear"))
|
|
||||||
{
|
|
||||||
if (sender instanceof EntityPlayer)
|
|
||||||
{
|
|
||||||
EntityPlayer player = (EntityPlayer) sender;
|
|
||||||
|
|
||||||
int cleared = 0;
|
|
||||||
cleared += player.inventory.clearMatchingItems(RegistrationHandler.itemTile, 0, 64, null);
|
|
||||||
cleared += player.inventory.clearMatchingItems(RegistrationHandler.itemEntity, 0, 64, null);
|
|
||||||
|
|
||||||
CarryOn.network.sendTo(new CarrySlotPacket(9, player.getEntityId()), (EntityPlayerMP) player);
|
|
||||||
|
|
||||||
if (cleared != 1)
|
|
||||||
player.sendMessage(new TextComponentString("Cleared " + cleared + " Items!"));
|
|
||||||
else
|
|
||||||
player.sendMessage(new TextComponentString("Cleared " + cleared + " Item!"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
// Handling debug
|
|
||||||
else if (args[0].toLowerCase().equals("debug"))
|
|
||||||
{
|
|
||||||
|
|
||||||
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())));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(this.getUsage(sender));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(this.getUsage(sender));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@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,102 +0,0 @@
|
||||||
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")
|
|
||||||
public static Configs.Settings settings = new Configs.Settings();
|
|
||||||
|
|
||||||
@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!)")
|
|
||||||
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!")
|
|
||||||
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!")
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,262 +0,0 @@
|
||||||
package tschipp.carryon.common.config;
|
|
||||||
|
|
||||||
import net.minecraftforge.common.config.Config;
|
|
||||||
import net.minecraftforge.common.config.Config.Comment;
|
|
||||||
|
|
||||||
public class Configs {
|
|
||||||
|
|
||||||
public static class Settings
|
|
||||||
{
|
|
||||||
@Comment("If the front of the Tile Entities should face the player or should face outward")
|
|
||||||
public boolean facePlayer = false;
|
|
||||||
|
|
||||||
@Comment("More complex Tile Entities slow down the player more")
|
|
||||||
public boolean heavyTiles = true;
|
|
||||||
|
|
||||||
@Comment("Allow all blocks to be picked up, not just Tile Entites")
|
|
||||||
public boolean pickupAllBlocks = false;
|
|
||||||
|
|
||||||
@Comment("Whether Blocks and Entities slow the creative player down when carried")
|
|
||||||
public boolean slownessInCreative = true;
|
|
||||||
|
|
||||||
@Config.RangeDouble(min = 0)
|
|
||||||
@Comment("Maximum distance from where Blocks and Entities can be picked up")
|
|
||||||
public double maxDistance = 2.5;
|
|
||||||
|
|
||||||
@Config.RangeDouble(min = 0, max = 10)
|
|
||||||
@Comment("Max width of entities that can be picked up in survival mode")
|
|
||||||
public float maxEntityWidth = 1.5f;
|
|
||||||
|
|
||||||
@Config.RangeDouble(min = 0, max = 10)
|
|
||||||
@Comment("Max height of entities that can be picked up in survival mode")
|
|
||||||
public float maxEntityHeight = 1.5f;
|
|
||||||
|
|
||||||
@Comment("Whether hostile mobs should be able to picked up in survival mode")
|
|
||||||
public boolean pickupHostileMobs = false;
|
|
||||||
|
|
||||||
@Comment("Larger Entities slow down the player more")
|
|
||||||
public boolean heavyEntities = true;
|
|
||||||
|
|
||||||
@Comment("Slowness multiplier for blocks")
|
|
||||||
public double blockSlownessMultiplier = 1.0;
|
|
||||||
|
|
||||||
@Comment("Slowness multiplier for entities")
|
|
||||||
public double entitySlownessMultiplier = 1.0;
|
|
||||||
|
|
||||||
@Comment("Arms should render on sides when carrying")
|
|
||||||
public boolean renderArms = true;
|
|
||||||
|
|
||||||
@Comment("Allow babies to be carried even when adult mob is blacklisted (or not whitelisted)")
|
|
||||||
public boolean allowBabies = false;
|
|
||||||
|
|
||||||
@Comment("Use Whitelist instead of Blacklist for Blocks")
|
|
||||||
public boolean useWhitelistBlocks=false;
|
|
||||||
|
|
||||||
@Comment("Use Whitelist instead of Blacklist for Entities")
|
|
||||||
public boolean useWhitelistEntities=false;
|
|
||||||
|
|
||||||
@Comment("Whether the player can hit blocks and entities while carrying or not")
|
|
||||||
public boolean hitWhileCarrying=false;
|
|
||||||
|
|
||||||
@Comment("Whether the player drops the carried object when hit or not")
|
|
||||||
public boolean dropCarriedWhenHit=false;
|
|
||||||
|
|
||||||
@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;
|
|
||||||
|
|
||||||
@Comment("Allows entities to be stacked using Carry On")
|
|
||||||
public boolean stackableEntities = true;
|
|
||||||
|
|
||||||
@Config.RangeInt(min = 1)
|
|
||||||
@Comment("Maximum stack limit for entities")
|
|
||||||
public int maxEntityStackLimit = 10;
|
|
||||||
|
|
||||||
@Comment("Whether entities' size matters when stacking or not")
|
|
||||||
public boolean entitySizeMattersStacking = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class WhiteList
|
|
||||||
{
|
|
||||||
@Config.RequiresMcRestart()
|
|
||||||
@Comment("Entities that CAN be picked up")
|
|
||||||
public String[] allowedEntities=new String[]
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
@Config.RequiresMcRestart()
|
|
||||||
@Comment("Blocks that CAN be picked up")
|
|
||||||
public String[] allowedBlocks=new String[]
|
|
||||||
{
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Blacklist
|
|
||||||
{
|
|
||||||
@Config.RequiresMcRestart()
|
|
||||||
@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:*",
|
|
||||||
};
|
|
||||||
|
|
||||||
@Config.RequiresMcRestart()
|
|
||||||
@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:*"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ModelOverrides
|
|
||||||
{
|
|
||||||
@Config.RequiresMcRestart()
|
|
||||||
@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",
|
|
||||||
"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 class CustomPickupConditions
|
|
||||||
{
|
|
||||||
@Config.RequiresMcRestart()
|
|
||||||
@Comment("Custom Pickup Conditions for Blocks")
|
|
||||||
public String[] customPickupConditionsBlocks = new String[]
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
@Config.RequiresMcRestart()
|
|
||||||
@Comment("Custom Pickup Conditions for Entities")
|
|
||||||
public String[] customPickupConditionsEntities = new String[]
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,259 +0,0 @@
|
||||||
package tschipp.carryon.common.event;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.entity.passive.EntityAnimal;
|
|
||||||
import net.minecraft.entity.passive.EntityHorse;
|
|
||||||
import net.minecraft.entity.passive.EntityVillager;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
|
||||||
import net.minecraft.init.SoundEvents;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraft.util.EnumHand;
|
|
||||||
import net.minecraft.util.SoundCategory;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
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.fml.common.network.NetworkRegistry.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.handler.PickupHandler;
|
|
||||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
|
||||||
import tschipp.carryon.common.item.ItemEntity;
|
|
||||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
|
||||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
|
||||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
|
||||||
|
|
||||||
public class ItemEntityEvents
|
|
||||||
{
|
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
|
||||||
public void onBlockClick(PlayerInteractEvent.RightClickBlock event)
|
|
||||||
{
|
|
||||||
EntityPlayer player = event.getEntityPlayer();
|
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))
|
|
||||||
{
|
|
||||||
player.getEntityData().removeTag("carrySlot");
|
|
||||||
event.setUseBlock(Result.DENY);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
|
||||||
public void onItemDropped(EntityJoinWorldEvent event)
|
|
||||||
{
|
|
||||||
Entity e = event.getEntity();
|
|
||||||
World world = event.getWorld();
|
|
||||||
if (e instanceof EntityItem)
|
|
||||||
{
|
|
||||||
EntityItem eitem = (EntityItem) e;
|
|
||||||
ItemStack stack = eitem.getEntityItem();
|
|
||||||
Item item = stack.getItem();
|
|
||||||
if (item == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))
|
|
||||||
{
|
|
||||||
BlockPos pos = eitem.getPosition();
|
|
||||||
Entity entity = ItemEntity.getEntity(stack, world);
|
|
||||||
entity.setPosition(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
|
|
||||||
world.spawnEntity(entity);
|
|
||||||
|
|
||||||
ItemEntity.clearEntityData(stack);
|
|
||||||
eitem.setEntityItemStack(ItemStack.EMPTY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
|
||||||
public void onEntityRightClick(PlayerInteractEvent.EntityInteract event)
|
|
||||||
{
|
|
||||||
EntityPlayer player = event.getEntityPlayer();
|
|
||||||
|
|
||||||
if (player instanceof EntityPlayerMP)
|
|
||||||
{
|
|
||||||
ItemStack main = player.getHeldItemMainhand();
|
|
||||||
ItemStack off = player.getHeldItemOffhand();
|
|
||||||
World world = event.getWorld();
|
|
||||||
Entity entity = event.getTarget();
|
|
||||||
BlockPos pos = entity.getPosition();
|
|
||||||
|
|
||||||
if (main.isEmpty() && off.isEmpty() && CarryOnKeybinds.isKeyPressed(player))
|
|
||||||
{
|
|
||||||
ItemStack stack = new ItemStack(RegistrationHandler.itemEntity);
|
|
||||||
|
|
||||||
if (entity.hurtResistantTime == 0)
|
|
||||||
{
|
|
||||||
if (entity instanceof EntityAnimal)
|
|
||||||
((EntityAnimal) entity).clearLeashed(true, true);
|
|
||||||
|
|
||||||
if (PickupHandler.canPlayerPickUpEntity(player, entity))
|
|
||||||
{
|
|
||||||
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++)
|
|
||||||
{
|
|
||||||
handler.extractItem(i, 64, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CarryOnOverride override = ScriptChecker.inspectEntity(entity);
|
|
||||||
int overrideHash = 0;
|
|
||||||
if (override != null)
|
|
||||||
overrideHash = override.hashCode();
|
|
||||||
|
|
||||||
CarryOn.network.sendToAllAround(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId(), overrideHash), new TargetPoint(world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));
|
|
||||||
entity.setDead();
|
|
||||||
player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(main) && !CarryOnKeybinds.isKeyPressed(player) && CarryOnConfig.settings.stackableEntities)
|
|
||||||
{
|
|
||||||
Entity entityHeld = ItemEntity.getEntity(main, world);
|
|
||||||
|
|
||||||
if (entity.hurtResistantTime == 0 && entityHeld instanceof EntityLivingBase)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!world.isRemote && entityHeld.getUniqueID() != entity.getUniqueID() && !entityHeld.isDead && !entity.isDead)
|
|
||||||
{
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
Entity topEntity = getTopPassenger(lowestEntity);
|
|
||||||
|
|
||||||
double sizeEntity = topEntity.height * topEntity.width;
|
|
||||||
if ((CarryOnConfig.settings.entitySizeMattersStacking && sizeHeldEntity <= sizeEntity) || !CarryOnConfig.settings.entitySizeMattersStacking)
|
|
||||||
{
|
|
||||||
if (topEntity instanceof EntityHorse)
|
|
||||||
{
|
|
||||||
EntityHorse horse = (EntityHorse) topEntity;
|
|
||||||
horse.setHorseTamed(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (distance < 6)
|
|
||||||
{
|
|
||||||
double tempX = entity.posX;
|
|
||||||
double tempY = entity.posY;
|
|
||||||
double tempZ = entity.posZ;
|
|
||||||
entityHeld.setPosition(tempX, tempY + 2.6, tempZ);
|
|
||||||
world.spawnEntity(entityHeld);
|
|
||||||
entityHeld.startRiding(topEntity, false);
|
|
||||||
entityHeld.setPositionAndUpdate(tempX, tempY, tempZ);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
entityHeld.setPosition(entity.posX, entity.posY, entity.posZ);
|
|
||||||
world.spawnEntity(entityHeld);
|
|
||||||
entityHeld.startRiding(topEntity, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ItemEntity.clearEntityData(main);
|
|
||||||
player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY);
|
|
||||||
CarryOn.network.sendToAllAround(new CarrySlotPacket(9, player.getEntityId()), new TargetPoint(world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));
|
|
||||||
event.setCanceled(true);
|
|
||||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_HORSE_SADDLE, SoundCategory.PLAYERS, 0.5F, 1.5F);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_NOTE_BASS, SoundCategory.PLAYERS, 0.5F, 1.5F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_NOTE_BASS, SoundCategory.PLAYERS, 0.5F, 1.5F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getAllPassengers(Entity entity)
|
|
||||||
{
|
|
||||||
int passengers = 0;
|
|
||||||
while (entity.isBeingRidden())
|
|
||||||
{
|
|
||||||
List<Entity> pass = entity.getPassengers();
|
|
||||||
if (!pass.isEmpty())
|
|
||||||
{
|
|
||||||
entity = pass.get(0);
|
|
||||||
passengers++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return passengers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Entity getTopPassenger(Entity entity)
|
|
||||||
{
|
|
||||||
Entity top = entity;
|
|
||||||
while (entity.isBeingRidden())
|
|
||||||
{
|
|
||||||
List<Entity> pass = entity.getPassengers();
|
|
||||||
if (!pass.isEmpty())
|
|
||||||
{
|
|
||||||
entity = pass.get(0);
|
|
||||||
top = entity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return top;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onLivingUpdate(LivingUpdateEvent event)
|
|
||||||
{
|
|
||||||
EntityLivingBase entity = event.getEntityLiving();
|
|
||||||
World world = entity.world;
|
|
||||||
ItemStack main = entity.getHeldItemMainhand();
|
|
||||||
if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(main))
|
|
||||||
{
|
|
||||||
BlockPos pos = entity.getPosition();
|
|
||||||
BlockPos below = pos.offset(EnumFacing.DOWN);
|
|
||||||
|
|
||||||
if (world.getBlockState(pos).getMaterial() == Material.WATER || world.getBlockState(below).getMaterial() == Material.WATER)
|
|
||||||
{
|
|
||||||
Entity contained = ItemEntity.getEntity(main, world);
|
|
||||||
if (contained != null)
|
|
||||||
{
|
|
||||||
float height = contained.height;
|
|
||||||
float width = contained.width;
|
|
||||||
|
|
||||||
entity.addVelocity(0, -0.01 * height * width, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,375 +0,0 @@
|
||||||
package tschipp.carryon.common.event;
|
|
||||||
|
|
||||||
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.inventory.IInventory;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraft.util.EnumHand;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
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.GameRules;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
|
||||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
|
||||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
|
||||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
|
||||||
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed;
|
|
||||||
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.fml.common.eventhandler.Event.Result;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
|
|
||||||
import net.minecraftforge.fml.common.network.NetworkRegistry.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.handler.PickupHandler;
|
|
||||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
|
||||||
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.network.client.CarrySlotPacket;
|
|
||||||
|
|
||||||
public class ItemEvents
|
|
||||||
{
|
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
|
||||||
public void onBlockClick(PlayerInteractEvent.RightClickBlock event)
|
|
||||||
{
|
|
||||||
EntityPlayer player = event.getEntityPlayer();
|
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack))
|
|
||||||
{
|
|
||||||
player.getEntityData().removeTag("carrySlot");
|
|
||||||
event.setUseBlock(Result.DENY);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
|
||||||
public void onItemDropped(EntityJoinWorldEvent event)
|
|
||||||
{
|
|
||||||
Entity e = event.getEntity();
|
|
||||||
World world = event.getWorld();
|
|
||||||
if (e instanceof EntityItem)
|
|
||||||
{
|
|
||||||
EntityItem eitem = (EntityItem) e;
|
|
||||||
ItemStack stack = eitem.getEntityItem();
|
|
||||||
Item item = stack.getItem();
|
|
||||||
if (item == RegistrationHandler.itemTile && ItemTile.hasTileData(stack))
|
|
||||||
{
|
|
||||||
BlockPos pos = eitem.getPosition();
|
|
||||||
BlockPos finalPos = pos;
|
|
||||||
Block block = ItemTile.getBlock(stack);
|
|
||||||
if (!world.getBlockState(pos).getBlock().isReplaceable(world, pos) || !block.canPlaceBlockAt(world, pos))
|
|
||||||
{
|
|
||||||
for (EnumFacing facing : EnumFacing.VALUES)
|
|
||||||
{
|
|
||||||
BlockPos offsetPos = pos.offset(facing);
|
|
||||||
if (world.getBlockState(offsetPos).getBlock().isReplaceable(world, offsetPos) && block.canPlaceBlockAt(world, offsetPos))
|
|
||||||
{
|
|
||||||
finalPos = offsetPos;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
world.setBlockState(finalPos, ItemTile.getBlockState(stack));
|
|
||||||
TileEntity tile = world.getTileEntity(finalPos);
|
|
||||||
if (tile != null)
|
|
||||||
{
|
|
||||||
tile.readFromNBT(ItemTile.getTileData(stack));
|
|
||||||
tile.setPos(finalPos);
|
|
||||||
}
|
|
||||||
ItemTile.clearTileData(stack);
|
|
||||||
eitem.setEntityItemStack(ItemStack.EMPTY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onPlayerLogin(PlayerLoggedInEvent event)
|
|
||||||
{
|
|
||||||
if (event.player instanceof EntityPlayer)
|
|
||||||
{
|
|
||||||
EntityPlayer player = (EntityPlayer) event.player;
|
|
||||||
World world = player.getEntityWorld();
|
|
||||||
|
|
||||||
ItemStack carried = player.getHeldItemMainhand();
|
|
||||||
if (!carried.isEmpty() && carried.getItem() == RegistrationHandler.itemTile || carried.getItem() == RegistrationHandler.itemEntity)
|
|
||||||
{
|
|
||||||
if (carried.getItem() == RegistrationHandler.itemTile)
|
|
||||||
{
|
|
||||||
CarryOnOverride override = ScriptChecker.inspectBlock(((ItemTile) carried.getItem()).getBlockState(carried), world, player.getPosition(), ((ItemTile) carried.getItem()).getTileData(carried));
|
|
||||||
if (override != null)
|
|
||||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId(), override.hashCode()), (EntityPlayerMP) player);
|
|
||||||
else
|
|
||||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId()), (EntityPlayerMP) player);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CarryOnOverride override = ScriptChecker.inspectEntity(((ItemEntity) carried.getItem()).getEntity(carried, world));
|
|
||||||
if (override != null)
|
|
||||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId(), override.hashCode()), (EntityPlayerMP) player);
|
|
||||||
else
|
|
||||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId()), (EntityPlayerMP) player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onEntityStartTracking(StartTracking event)
|
|
||||||
{
|
|
||||||
Entity e = event.getTarget();
|
|
||||||
EntityPlayer tracker = event.getEntityPlayer();
|
|
||||||
|
|
||||||
if (e instanceof EntityPlayer && tracker instanceof EntityPlayerMP)
|
|
||||||
{
|
|
||||||
EntityPlayer player = (EntityPlayer) e;
|
|
||||||
World world = player.getEntityWorld();
|
|
||||||
|
|
||||||
ItemStack carried = player.getHeldItemMainhand();
|
|
||||||
if (!carried.isEmpty() && carried.getItem() == RegistrationHandler.itemTile || carried.getItem() == RegistrationHandler.itemEntity)
|
|
||||||
{
|
|
||||||
if (carried.getItem() == RegistrationHandler.itemTile)
|
|
||||||
{
|
|
||||||
CarryOnOverride override = ScriptChecker.inspectBlock(((ItemTile) carried.getItem()).getBlockState(carried), world, player.getPosition(), ((ItemTile) carried.getItem()).getTileData(carried));
|
|
||||||
if (override != null)
|
|
||||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId(), override.hashCode()), (EntityPlayerMP) tracker);
|
|
||||||
else
|
|
||||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId()), (EntityPlayerMP) tracker);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CarryOnOverride override = ScriptChecker.inspectEntity(((ItemEntity) carried.getItem()).getEntity(carried, world));
|
|
||||||
if (override != null)
|
|
||||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId(), override.hashCode()), (EntityPlayerMP) tracker);
|
|
||||||
else
|
|
||||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId()), (EntityPlayerMP) tracker);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void harvestSpeed(BreakSpeed event)
|
|
||||||
{
|
|
||||||
EntityPlayer player = event.getEntityPlayer();
|
|
||||||
if (player != null && !CarryOnConfig.settings.hitWhileCarrying)
|
|
||||||
{
|
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
|
||||||
if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
|
||||||
event.setNewSpeed(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void attackEntity(AttackEntityEvent event)
|
|
||||||
{
|
|
||||||
EntityPlayer player = event.getEntityPlayer();
|
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
|
||||||
if (!stack.isEmpty() && !CarryOnConfig.settings.hitWhileCarrying && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
|
||||||
{
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void harvestSpeed(BreakEvent event)
|
|
||||||
{
|
|
||||||
EntityPlayer player = event.getPlayer();
|
|
||||||
if (player != null && !CarryOnConfig.settings.hitWhileCarrying)
|
|
||||||
{
|
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
|
||||||
if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void playerAttack(LivingAttackEvent event)
|
|
||||||
{
|
|
||||||
EntityLivingBase eliving = event.getEntityLiving();
|
|
||||||
if (eliving instanceof EntityPlayer && CarryOnConfig.settings.dropCarriedWhenHit)
|
|
||||||
{
|
|
||||||
EntityPlayer player = (EntityPlayer) eliving;
|
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
|
||||||
if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
|
||||||
{
|
|
||||||
if (!player.world.isRemote)
|
|
||||||
{
|
|
||||||
player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY);
|
|
||||||
EntityItem item = new EntityItem(player.world, player.posX, player.posY, player.posZ, stack);
|
|
||||||
CarryOn.network.sendToAllAround(new CarrySlotPacket(9, player.getEntityId()), new TargetPoint(player.world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));
|
|
||||||
player.world.spawnEntity(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onBlockRightClick(PlayerInteractEvent.RightClickBlock event) throws InstantiationException, IllegalAccessException
|
|
||||||
{
|
|
||||||
EntityPlayer player = event.getEntityPlayer();
|
|
||||||
|
|
||||||
if (player instanceof EntityPlayerMP)
|
|
||||||
{
|
|
||||||
|
|
||||||
ItemStack main = player.getHeldItemMainhand();
|
|
||||||
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))
|
|
||||||
{
|
|
||||||
ItemStack stack = new ItemStack(RegistrationHandler.itemTile);
|
|
||||||
|
|
||||||
TileEntity te = world.getTileEntity(pos);
|
|
||||||
if (PickupHandler.canPlayerPickUpBlock(player, te, world, pos))
|
|
||||||
{
|
|
||||||
if (ItemTile.storeTileData(te, world, pos, state.getActualState(world, pos), stack))
|
|
||||||
{
|
|
||||||
IBlockState statee = world.getBlockState(pos);
|
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
|
||||||
tag = world.getTileEntity(pos) != null ? world.getTileEntity(pos).writeToNBT(tag) : new NBTTagCompound();
|
|
||||||
CarryOnOverride override = ScriptChecker.inspectBlock(state, world, pos, tag);
|
|
||||||
int overrideHash = 0;
|
|
||||||
if (override != null)
|
|
||||||
overrideHash = override.hashCode();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
CarryOn.network.sendToAllAround(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId(), overrideHash), new TargetPoint(world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));
|
|
||||||
world.removeTileEntity(pos);
|
|
||||||
world.setBlockToAir(pos);
|
|
||||||
player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
|
||||||
event.setUseBlock(Result.DENY);
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
CarryOn.network.sendToAllAround(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId(), overrideHash), new TargetPoint(world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));
|
|
||||||
emptyTileEntity(te);
|
|
||||||
world.setBlockToAir(pos);
|
|
||||||
player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
|
||||||
event.setUseBlock(Result.DENY);
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
CarryOn.network.sendToAllAround(new CarrySlotPacket(9, player.getEntityId()), new TargetPoint(world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));
|
|
||||||
world.setBlockState(pos, statee);
|
|
||||||
if (!tag.hasNoTags())
|
|
||||||
TileEntity.create(world, tag);
|
|
||||||
|
|
||||||
player.sendMessage(new TextComponentString(TextFormatting.RED + "Error detected. Cannot pick up block."));
|
|
||||||
TextComponentString s = new TextComponentString(TextFormatting.GOLD + "here");
|
|
||||||
s.getStyle().setClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/Tschipp/CarryOn/issues"));
|
|
||||||
player.sendMessage(new TextComponentString(TextFormatting.RED + "Please report this error ").appendSibling(s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void emptyTileEntity(TileEntity te)
|
|
||||||
{
|
|
||||||
if (te != null && !te.isInvalid())
|
|
||||||
{
|
|
||||||
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++)
|
|
||||||
{
|
|
||||||
itemHandler.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++)
|
|
||||||
{
|
|
||||||
itemHandler.extractItem(i, 64, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (te instanceof IInventory)
|
|
||||||
{
|
|
||||||
IInventory inv = (IInventory) te;
|
|
||||||
inv.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (te instanceof IItemHandler)
|
|
||||||
{
|
|
||||||
IItemHandler itemHandler = (IItemHandler) te;
|
|
||||||
for (int i = 0; i < itemHandler.getSlots(); i++)
|
|
||||||
{
|
|
||||||
itemHandler.extractItem(i, 64, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onRespawn(PlayerEvent.Clone event)
|
|
||||||
{
|
|
||||||
EntityPlayer original = event.getOriginal();
|
|
||||||
EntityPlayer player = event.getEntityPlayer();
|
|
||||||
boolean wasDead = event.isWasDeath();
|
|
||||||
GameRules rules = player.world.getGameRules();
|
|
||||||
boolean keepInv = rules.getBoolean("keepInventory");
|
|
||||||
boolean wasCarrying = player.inventory.hasItemStack(new ItemStack(RegistrationHandler.itemTile)) || player.inventory.hasItemStack(new ItemStack(RegistrationHandler.itemEntity));
|
|
||||||
|
|
||||||
if ((wasDead ? keepInv : true) && wasCarrying)
|
|
||||||
{
|
|
||||||
int carrySlot = original.inventory.currentItem;
|
|
||||||
|
|
||||||
ItemStack stack = player.inventory.removeStackFromSlot(carrySlot);
|
|
||||||
World world = player.world;
|
|
||||||
|
|
||||||
EntityItem item = new EntityItem(world);
|
|
||||||
item.setEntityItemStack(stack);
|
|
||||||
BlockPos pos = original.getBedLocation();
|
|
||||||
if (pos == null)
|
|
||||||
pos = player.getPosition();
|
|
||||||
item.setPosition(pos.getX(), pos.getY(), pos.getZ());
|
|
||||||
world.spawnEntity(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,125 +0,0 @@
|
||||||
package tschipp.carryon.common.handler;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
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 tschipp.carryon.common.helper.InvalidConfigException;
|
|
||||||
|
|
||||||
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>();
|
|
||||||
|
|
||||||
public static void initPickupOverrides()
|
|
||||||
{
|
|
||||||
if (Loader.isModLoaded("gamestages"))
|
|
||||||
{
|
|
||||||
|
|
||||||
String[] conditions = CarryOnConfig.customPickupConditions.customPickupConditionsBlocks;
|
|
||||||
|
|
||||||
for (int i = 0; i < conditions.length; i++)
|
|
||||||
{
|
|
||||||
String line = conditions[i];
|
|
||||||
|
|
||||||
if (!line.contains("(") || !line.contains(")"))
|
|
||||||
new InvalidConfigException("Invalid Condition at line " + i + ": " + line).printException();
|
|
||||||
|
|
||||||
String condition = line.substring(line.indexOf("("));
|
|
||||||
String blockname = line.replace(condition, "");
|
|
||||||
condition = condition.replace("(", "");
|
|
||||||
condition = condition.replace(")", "");
|
|
||||||
|
|
||||||
if (blockname.contains("*"))
|
|
||||||
{
|
|
||||||
String modid = blockname.replace("*", "");
|
|
||||||
for (int k = 0; k < Block.REGISTRY.getKeys().size(); k++)
|
|
||||||
{
|
|
||||||
if (Block.REGISTRY.getKeys().toArray()[k].toString().contains(modid))
|
|
||||||
{
|
|
||||||
PICKUP_CONDITIONS.put(Block.REGISTRY.getKeys().toArray()[k].toString() + ";any", condition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!blockname.contains(";"))
|
|
||||||
blockname = blockname + ";any";
|
|
||||||
|
|
||||||
PICKUP_CONDITIONS.put(blockname, condition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] entityConditions = CarryOnConfig.customPickupConditions.customPickupConditionsEntities;
|
|
||||||
|
|
||||||
for (int i = 0; i < entityConditions.length; i++)
|
|
||||||
{
|
|
||||||
String line = entityConditions[i];
|
|
||||||
|
|
||||||
if (!line.contains("(") || !line.contains(")"))
|
|
||||||
new InvalidConfigException("Invalid Condition at line " + i + ": " + line).printException();
|
|
||||||
|
|
||||||
String condition = line.substring(line.indexOf("("));
|
|
||||||
String entityname = line.replace(condition, "");
|
|
||||||
condition = condition.replace("(", "");
|
|
||||||
condition = condition.replace(")", "");
|
|
||||||
|
|
||||||
PICKUP_CONDITIONS_ENTITIES.put(entityname, condition);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasSpecialPickupConditions(IBlockState state)
|
|
||||||
{
|
|
||||||
if (!Loader.isModLoaded("gamestages"))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
String block = state.getBlock().getRegistryName().toString();
|
|
||||||
String meta = "" + state.getBlock().getMetaFromState(state);
|
|
||||||
|
|
||||||
boolean absolute = PICKUP_CONDITIONS.containsKey(block + ";" + meta);
|
|
||||||
boolean any = PICKUP_CONDITIONS.containsKey(block + ";any");
|
|
||||||
|
|
||||||
return absolute || any;
|
|
||||||
}
|
|
||||||
|
|
||||||
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");
|
|
||||||
|
|
||||||
if (absolute != null)
|
|
||||||
return absolute;
|
|
||||||
else
|
|
||||||
return any;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasSpecialPickupConditions(Entity entity)
|
|
||||||
{
|
|
||||||
if (!Loader.isModLoaded("gamestages"))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
String entityname = EntityList.getKey(entity).toString();
|
|
||||||
boolean condition = PICKUP_CONDITIONS_ENTITIES.containsKey(entityname);
|
|
||||||
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getPickupCondition(Entity entity)
|
|
||||||
{
|
|
||||||
String entityname = EntityList.getKey(entity).toString();
|
|
||||||
String condition = PICKUP_CONDITIONS_ENTITIES.get(entityname);
|
|
||||||
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,138 +0,0 @@
|
||||||
package tschipp.carryon.common.handler;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.EntityList;
|
|
||||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
|
||||||
import tschipp.carryon.common.config.CarryOnConfig;
|
|
||||||
|
|
||||||
public class ListHandler
|
|
||||||
{
|
|
||||||
public static List<String> FORBIDDEN_TILES;
|
|
||||||
public static List<String> FORBIDDEN_ENTITIES;
|
|
||||||
public static List<String> ALLOWED_ENTITIES;
|
|
||||||
public static List<String> ALLOWED_TILES;
|
|
||||||
|
|
||||||
public static boolean isForbidden(Block block)
|
|
||||||
{
|
|
||||||
String name = block.getRegistryName().toString();
|
|
||||||
if (FORBIDDEN_TILES.contains(name))
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
boolean contains = false;
|
|
||||||
for (String s : FORBIDDEN_TILES)
|
|
||||||
{
|
|
||||||
if (s.contains("*"))
|
|
||||||
{
|
|
||||||
if(name.contains(s.replace("*", "")))
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isAllowed(Block block)
|
|
||||||
{
|
|
||||||
String name = block.getRegistryName().toString();
|
|
||||||
if (ALLOWED_TILES.contains(name))
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
boolean contains = false;
|
|
||||||
for (String s : ALLOWED_TILES)
|
|
||||||
{
|
|
||||||
if (s.contains("*"))
|
|
||||||
{
|
|
||||||
if(name.contains(s.replace("*", "")))
|
|
||||||
contains = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return contains;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void initForbiddenTiles()
|
|
||||||
{
|
|
||||||
String[] forbidden = CarryOnConfig.blacklist.forbiddenTiles;
|
|
||||||
FORBIDDEN_TILES = new ArrayList<String>();
|
|
||||||
|
|
||||||
for (int i = 0; i < forbidden.length; i++)
|
|
||||||
{
|
|
||||||
FORBIDDEN_TILES.add(forbidden[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] forbiddenEntity = CarryOnConfig.blacklist.forbiddenEntities;
|
|
||||||
FORBIDDEN_ENTITIES = new ArrayList<String>();
|
|
||||||
|
|
||||||
for (int i = 0; i < forbiddenEntity.length; i++)
|
|
||||||
{
|
|
||||||
if (forbiddenEntity[i].contains("*"))
|
|
||||||
{
|
|
||||||
String modid = forbiddenEntity[i].replace("*", "");
|
|
||||||
for (int k = 0; k < ForgeRegistries.ENTITIES.getKeys().size(); k++)
|
|
||||||
{
|
|
||||||
if (ForgeRegistries.ENTITIES.getKeys().toArray()[k].toString().contains(modid))
|
|
||||||
{
|
|
||||||
FORBIDDEN_ENTITIES.add(ForgeRegistries.ENTITIES.getKeys().toArray()[k].toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FORBIDDEN_ENTITIES.add(forbiddenEntity[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] allowedEntities = CarryOnConfig.whitelist.allowedEntities;
|
|
||||||
ALLOWED_ENTITIES = new ArrayList<String>();
|
|
||||||
for (int i = 0; i < allowedEntities.length; i++)
|
|
||||||
{
|
|
||||||
if (allowedEntities[i].contains("*"))
|
|
||||||
{
|
|
||||||
String modid = allowedEntities[i].replace("*", "");
|
|
||||||
for (int k = 0; k < ForgeRegistries.ENTITIES.getKeys().size(); k++)
|
|
||||||
{
|
|
||||||
if (ForgeRegistries.ENTITIES.getKeys().toArray()[k].toString().contains(modid))
|
|
||||||
{
|
|
||||||
ALLOWED_ENTITIES.add(ForgeRegistries.ENTITIES.getKeys().toArray()[k].toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ALLOWED_ENTITIES.add(allowedEntities[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] allowedBlocks = CarryOnConfig.whitelist.allowedBlocks;
|
|
||||||
ALLOWED_TILES = new ArrayList<String>();
|
|
||||||
for (int i = 0; i < allowedBlocks.length; i++)
|
|
||||||
{
|
|
||||||
ALLOWED_TILES.add(allowedBlocks[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,269 +0,0 @@
|
||||||
package tschipp.carryon.common.handler;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
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.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 tschipp.carryon.common.helper.InvalidConfigException;
|
|
||||||
import tschipp.carryon.common.helper.StringParser;
|
|
||||||
|
|
||||||
public class ModelOverridesHandler
|
|
||||||
{
|
|
||||||
public static HashMap<NBTTagCompound, Object> OVERRIDE_OBJECTS = new HashMap<NBTTagCompound, Object>();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This class is really ugly, will probably be replaced by something else -
|
|
||||||
* Tschipp
|
|
||||||
*/
|
|
||||||
public static void initOverrides()
|
|
||||||
{
|
|
||||||
String[] overrides = CarryOnConfig.modelOverrides.modelOverrides;
|
|
||||||
|
|
||||||
for (int i = 0; i < overrides.length; i++)
|
|
||||||
{
|
|
||||||
boolean errored = false;
|
|
||||||
|
|
||||||
Object toOverrideObject;
|
|
||||||
Object overrideObject;
|
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
|
||||||
|
|
||||||
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 = "";
|
|
||||||
try
|
|
||||||
{
|
|
||||||
toOverride = sa[0];
|
|
||||||
override = sa[1];
|
|
||||||
}
|
|
||||||
catch (ArrayIndexOutOfBoundsException e)
|
|
||||||
{
|
|
||||||
errored = true;
|
|
||||||
new InvalidConfigException("Missing Override Model at line " + i + " : " + currentline).printException();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toOverride.contains("{"))
|
|
||||||
{
|
|
||||||
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("}"))
|
|
||||||
{
|
|
||||||
errored = true;
|
|
||||||
new InvalidConfigException("Missing { at line " + i + " : " + currentline).printException();
|
|
||||||
}
|
|
||||||
|
|
||||||
String overridetype = "item";
|
|
||||||
if (override.contains("("))
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
else
|
|
||||||
toOverrideObject = StringParser.getBlockState(toOverride);
|
|
||||||
|
|
||||||
if (toOverrideObject != 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)
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasCustomOverrideModel(IBlockState state, NBTTagCompound tag)
|
|
||||||
{
|
|
||||||
if (OVERRIDE_OBJECTS.isEmpty())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int stateid = Block.getStateId(state);
|
|
||||||
NBTTagCompound[] keys = new NBTTagCompound[OVERRIDE_OBJECTS.size()];
|
|
||||||
OVERRIDE_OBJECTS.keySet().toArray(keys);
|
|
||||||
for (NBTTagCompound key : keys)
|
|
||||||
{
|
|
||||||
int id = key.getInteger("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();
|
|
||||||
|
|
||||||
boolean flag = true;
|
|
||||||
if (kSetTile.containsAll(kSetToCheck))
|
|
||||||
{
|
|
||||||
for (String skey : kSetToCheck)
|
|
||||||
{
|
|
||||||
if (!NBTUtil.areNBTEquals(tag.getTag(skey), toCheckForCompound.getTag(skey), true))
|
|
||||||
flag = false;
|
|
||||||
}
|
|
||||||
if (flag)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public static IBakedModel getCustomOverrideModel(IBlockState state, NBTTagCompound tag, World world, EntityPlayer player)
|
|
||||||
{
|
|
||||||
int stateid = Block.getStateId(state);
|
|
||||||
NBTTagCompound[] keys = new NBTTagCompound[OVERRIDE_OBJECTS.size()];
|
|
||||||
OVERRIDE_OBJECTS.keySet().toArray(keys);
|
|
||||||
for (NBTTagCompound key : keys)
|
|
||||||
{
|
|
||||||
int id = key.getInteger("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();
|
|
||||||
|
|
||||||
boolean flag = true;
|
|
||||||
if (kSetTile.containsAll(kSetToCheck))
|
|
||||||
{
|
|
||||||
for (String skey : kSetToCheck)
|
|
||||||
{
|
|
||||||
if (!NBTUtil.areNBTEquals(tag.getTag(skey), toCheckForCompound.getTag(skey), true))
|
|
||||||
flag = false;
|
|
||||||
}
|
|
||||||
if (flag)
|
|
||||||
{
|
|
||||||
Object override = OVERRIDE_OBJECTS.get(key);
|
|
||||||
|
|
||||||
if (override == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (override instanceof IBlockState)
|
|
||||||
return Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState((IBlockState) override);
|
|
||||||
else
|
|
||||||
return Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides((ItemStack) override, world, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Object getOverrideObject(IBlockState state, NBTTagCompound tag)
|
|
||||||
{
|
|
||||||
int stateid = Block.getStateId(state);
|
|
||||||
NBTTagCompound[] keys = new NBTTagCompound[OVERRIDE_OBJECTS.size()];
|
|
||||||
OVERRIDE_OBJECTS.keySet().toArray(keys);
|
|
||||||
for (NBTTagCompound key : keys)
|
|
||||||
{
|
|
||||||
int id = key.getInteger("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();
|
|
||||||
|
|
||||||
boolean flag = true;
|
|
||||||
if (kSetTile.containsAll(kSetToCheck))
|
|
||||||
{
|
|
||||||
for (String skey : kSetToCheck)
|
|
||||||
{
|
|
||||||
if (!NBTUtil.areNBTEquals(tag.getTag(skey), toCheckForCompound.getTag(skey), true))
|
|
||||||
flag = false;
|
|
||||||
}
|
|
||||||
if (flag)
|
|
||||||
{
|
|
||||||
Object override = OVERRIDE_OBJECTS.get(key);
|
|
||||||
return override;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,222 +0,0 @@
|
||||||
package tschipp.carryon.common.handler;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import net.darkhax.gamestages.capabilities.PlayerDataHandler;
|
|
||||||
import net.darkhax.gamestages.capabilities.PlayerDataHandler.IStageData;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.EntityAgeable;
|
|
||||||
import net.minecraft.entity.EnumCreatureType;
|
|
||||||
import net.minecraft.entity.passive.EntityTameable;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
|
||||||
import net.minecraftforge.event.world.BlockEvent;
|
|
||||||
import tschipp.carryon.CarryOn;
|
|
||||||
import tschipp.carryon.common.config.CarryOnConfig;
|
|
||||||
import tschipp.carryon.common.item.ItemTile;
|
|
||||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
|
||||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
|
||||||
|
|
||||||
public class PickupHandler
|
|
||||||
{
|
|
||||||
|
|
||||||
public static boolean canPlayerPickUpBlock(EntityPlayer player, @Nullable TileEntity tile, World world, BlockPos pos)
|
|
||||||
{
|
|
||||||
IBlockState state = world.getBlockState(pos);
|
|
||||||
Block block = state.getBlock();
|
|
||||||
|
|
||||||
player.closeScreen();
|
|
||||||
|
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
|
||||||
if (tile != null)
|
|
||||||
tile.writeToNBT(tag);
|
|
||||||
|
|
||||||
CarryOnOverride override = ScriptChecker.inspectBlock(world.getBlockState(pos), world, pos, tag);
|
|
||||||
if (override != null)
|
|
||||||
{
|
|
||||||
return (ScriptChecker.fulfillsConditions(override, player)) && handleProtections((EntityPlayerMP) player, world, pos, state);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (CarryOnConfig.settings.useWhitelistBlocks)
|
|
||||||
{
|
|
||||||
if (!ListHandler.isAllowed(world.getBlockState(pos).getBlock()))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
CarryOn.LOGGER.info("Block is allowed");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (ListHandler.isForbidden(world.getBlockState(pos).getBlock()))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((block.getBlockHardness(state, 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 (!ItemTile.isLocked(pos, world))
|
|
||||||
{
|
|
||||||
|
|
||||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(state))
|
|
||||||
{
|
|
||||||
IStageData stageData = PlayerDataHandler.getStageData(player);
|
|
||||||
String condition = CustomPickupOverrideHandler.getPickupCondition(state);
|
|
||||||
if (stageData.hasUnlockedStage(condition))
|
|
||||||
return true && handleProtections((EntityPlayerMP) player, world, pos, state);
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (CarryOnConfig.settings.pickupAllBlocks ? true : tile != null)
|
|
||||||
{
|
|
||||||
|
|
||||||
return true && handleProtections((EntityPlayerMP) player, world, pos, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canPlayerPickUpEntity(EntityPlayer player, Entity toPickUp)
|
|
||||||
{
|
|
||||||
BlockPos pos = toPickUp.getPosition();
|
|
||||||
|
|
||||||
if (toPickUp instanceof EntityPlayer)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
CarryOnOverride override = ScriptChecker.inspectEntity(toPickUp);
|
|
||||||
if (override != null)
|
|
||||||
{
|
|
||||||
return (ScriptChecker.fulfillsConditions(override, player)) && handleProtections((EntityPlayerMP) player, toPickUp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
// check for allow babies to be picked up
|
|
||||||
if (toPickUp instanceof EntityAgeable && CarryOnConfig.settings.allowBabies)
|
|
||||||
{
|
|
||||||
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 (toPickUp instanceof EntityTameable)
|
|
||||||
{
|
|
||||||
EntityTameable tame = (EntityTameable) toPickUp;
|
|
||||||
if (tame.getOwnerId() != null && tame.getOwnerId() != player.getUUID(player.getGameProfile()))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
|
|
||||||
{
|
|
||||||
IStageData stageData = PlayerDataHandler.getStageData(player);
|
|
||||||
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
|
|
||||||
if (stageData.hasUnlockedStage(condition))
|
|
||||||
return true && handleProtections((EntityPlayerMP) player, toPickUp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return true && handleProtections((EntityPlayerMP) player, toPickUp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CarryOnConfig.settings.useWhitelistEntities)
|
|
||||||
{
|
|
||||||
if (!ListHandler.isAllowed(toPickUp))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (ListHandler.isForbidden(toPickUp))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()))
|
|
||||||
{
|
|
||||||
if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()))
|
|
||||||
{
|
|
||||||
if ((toPickUp.height <= CarryOnConfig.settings.maxEntityHeight && toPickUp.width <= CarryOnConfig.settings.maxEntityWidth || player.isCreative()))
|
|
||||||
{
|
|
||||||
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
|
|
||||||
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
|
|
||||||
{
|
|
||||||
if (toPickUp instanceof EntityTameable)
|
|
||||||
{
|
|
||||||
EntityTameable tame = (EntityTameable) toPickUp;
|
|
||||||
UUID owner = tame.getOwnerId();
|
|
||||||
UUID playerID = player.getUUID(player.getGameProfile());
|
|
||||||
if (owner != null && !owner.equals(playerID))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
|
|
||||||
{
|
|
||||||
IStageData stageData = PlayerDataHandler.getStageData(player);
|
|
||||||
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
|
|
||||||
if (stageData.hasUnlockedStage(condition))
|
|
||||||
return true && handleProtections((EntityPlayerMP) player, toPickUp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return true && handleProtections((EntityPlayerMP) player, toPickUp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean handleProtections(EntityPlayerMP player, World world, BlockPos pos, IBlockState state)
|
|
||||||
{
|
|
||||||
boolean breakable = true;
|
|
||||||
|
|
||||||
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, pos, state, player);
|
|
||||||
MinecraftForge.EVENT_BUS.post(event);
|
|
||||||
|
|
||||||
if(event.isCanceled())
|
|
||||||
breakable = false;
|
|
||||||
|
|
||||||
return breakable;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean handleProtections(EntityPlayerMP player, Entity entity)
|
|
||||||
{
|
|
||||||
boolean canPickup = true;
|
|
||||||
|
|
||||||
AttackEntityEvent event = new AttackEntityEvent(player, entity);
|
|
||||||
MinecraftForge.EVENT_BUS.post(event);
|
|
||||||
|
|
||||||
if(event.isCanceled())
|
|
||||||
canPickup = false;
|
|
||||||
|
|
||||||
return canPickup;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
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 tschipp.carryon.CarryOn;
|
|
||||||
import tschipp.carryon.client.event.RenderEntityEvents;
|
|
||||||
import tschipp.carryon.client.event.RenderEvents;
|
|
||||||
import tschipp.carryon.common.capabilities.IPosition;
|
|
||||||
import tschipp.carryon.common.capabilities.PositionStorage;
|
|
||||||
import tschipp.carryon.common.capabilities.TEPosition;
|
|
||||||
import tschipp.carryon.common.capabilities.event.PositionClientEvents;
|
|
||||||
import tschipp.carryon.common.capabilities.event.PositionCommonEvents;
|
|
||||||
import tschipp.carryon.common.event.ItemEntityEvents;
|
|
||||||
import tschipp.carryon.common.event.ItemEvents;
|
|
||||||
import tschipp.carryon.common.item.ItemEntity;
|
|
||||||
import tschipp.carryon.common.item.ItemTile;
|
|
||||||
|
|
||||||
public class RegistrationHandler
|
|
||||||
{
|
|
||||||
public static Item itemTile;
|
|
||||||
public static Item itemEntity;
|
|
||||||
|
|
||||||
public static void regItems()
|
|
||||||
{
|
|
||||||
itemTile = new ItemTile();
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void regClientEvents()
|
|
||||||
{
|
|
||||||
MinecraftForge.EVENT_BUS.register(new RenderEvents());
|
|
||||||
MinecraftForge.EVENT_BUS.register(new RenderEntityEvents());
|
|
||||||
MinecraftForge.EVENT_BUS.register(new PositionClientEvents());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void regOverrideList()
|
|
||||||
{
|
|
||||||
ModelOverridesHandler.initOverrides();
|
|
||||||
CustomPickupOverrideHandler.initPickupOverrides();
|
|
||||||
ListHandler.initForbiddenTiles();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void regCaps()
|
|
||||||
{
|
|
||||||
CapabilityManager.INSTANCE.register(IPosition.class, new PositionStorage(), TEPosition::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
package tschipp.carryon.common.helper;
|
|
||||||
|
|
||||||
import tschipp.carryon.CarryOn;
|
|
||||||
|
|
||||||
public class InvalidConfigException extends Exception
|
|
||||||
{
|
|
||||||
|
|
||||||
public InvalidConfigException(String cause)
|
|
||||||
{
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void printException()
|
|
||||||
{
|
|
||||||
CarryOn.LOGGER.error(this.getMessage());
|
|
||||||
for (int i = 0; i < this.getStackTrace().length; i++)
|
|
||||||
{
|
|
||||||
StackTraceElement element = this.getStackTrace()[i];
|
|
||||||
CarryOn.LOGGER.error(element.toString());
|
|
||||||
|
|
||||||
if(i >= 10)
|
|
||||||
{
|
|
||||||
CarryOn.LOGGER.error((this.getStackTrace().length - 10) + " more...");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CarryOn.LOGGER.info("");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
||||||
package tschipp.carryon.common.helper;
|
|
||||||
|
|
||||||
import java.lang.invoke.MethodHandle;
|
|
||||||
import java.lang.invoke.MethodHandles;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility methods for reflection.
|
|
||||||
*
|
|
||||||
* @author Choonster
|
|
||||||
*/
|
|
||||||
public class ReflectionUtil
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get a {@link MethodHandle} for a method.
|
|
||||||
*
|
|
||||||
* @param clazz
|
|
||||||
* The class
|
|
||||||
* @param methodNames
|
|
||||||
* The possible names of the method
|
|
||||||
* @param methodTypes
|
|
||||||
* The argument types of the method
|
|
||||||
* @param <T>
|
|
||||||
* The class
|
|
||||||
* @return The MethodHandle
|
|
||||||
*/
|
|
||||||
public static <T> MethodHandle findMethod(Class<T> clazz, String[] methodNames, Class<?>... methodTypes) {
|
|
||||||
final Method method = ReflectionHelper.findMethod(clazz, null, methodNames, methodTypes);
|
|
||||||
try {
|
|
||||||
return MethodHandles.lookup().unreflect(method);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new ReflectionHelper.UnableToFindMethodException(methodNames, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a {@link MethodHandle} for a field's getter.
|
|
||||||
*
|
|
||||||
* @param clazz
|
|
||||||
* The class
|
|
||||||
* @param fieldNames
|
|
||||||
* The possible names of the field
|
|
||||||
* @return The MethodHandle
|
|
||||||
*/
|
|
||||||
public static MethodHandle findFieldGetter(Class<?> clazz, String... fieldNames) {
|
|
||||||
final Field field = ReflectionHelper.findField(clazz, fieldNames);
|
|
||||||
|
|
||||||
try {
|
|
||||||
return MethodHandles.lookup().unreflectGetter(field);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new ReflectionHelper.UnableToAccessFieldException(fieldNames, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a {@link MethodHandle} for a field's setter.
|
|
||||||
*
|
|
||||||
* @param clazz
|
|
||||||
* The class
|
|
||||||
* @param fieldNames
|
|
||||||
* The possible names of the field
|
|
||||||
* @return The MethodHandle
|
|
||||||
*/
|
|
||||||
public static MethodHandle findFieldSetter(Class<?> clazz, String... fieldNames) {
|
|
||||||
final Field field = ReflectionHelper.findField(clazz, fieldNames);
|
|
||||||
|
|
||||||
try {
|
|
||||||
return MethodHandles.lookup().unreflectSetter(field);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new ReflectionHelper.UnableToAccessFieldException(fieldNames, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,372 +0,0 @@
|
||||||
package tschipp.carryon.common.helper;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.nbt.NBTBase;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.potion.PotionEffect;
|
|
||||||
import net.minecraft.scoreboard.Score;
|
|
||||||
import net.minecraft.scoreboard.ScoreObjective;
|
|
||||||
import net.minecraft.scoreboard.Scoreboard;
|
|
||||||
import net.minecraft.stats.Achievement;
|
|
||||||
import net.minecraft.stats.AchievementList;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
|
|
||||||
public class ScriptParseHelper
|
|
||||||
{
|
|
||||||
|
|
||||||
public static boolean matches(double number, String cond)
|
|
||||||
{
|
|
||||||
if (cond == null)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (cond.contains("<="))
|
|
||||||
{
|
|
||||||
return number <= Double.parseDouble(cond.replace("<=", ""));
|
|
||||||
}
|
|
||||||
if (cond.contains(">="))
|
|
||||||
{
|
|
||||||
return number >= Double.parseDouble(cond.replace(">=", ""));
|
|
||||||
}
|
|
||||||
if (cond.contains("<"))
|
|
||||||
{
|
|
||||||
return number < Double.parseDouble(cond.replace("<", ""));
|
|
||||||
}
|
|
||||||
if (cond.contains(">"))
|
|
||||||
{
|
|
||||||
return number > Double.parseDouble(cond.replace(">", ""));
|
|
||||||
}
|
|
||||||
if (cond.contains("="))
|
|
||||||
{
|
|
||||||
return number == Double.parseDouble(cond.replace("=", ""));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return number == Double.parseDouble(cond);
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
new InvalidConfigException(e.getMessage()).printException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean matches(Block block, String cond)
|
|
||||||
{
|
|
||||||
if (cond == null)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
Block toCheck = StringParser.getBlock(cond);
|
|
||||||
if (toCheck != null)
|
|
||||||
return block == toCheck;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean matches(NBTTagCompound toCheck, NBTTagCompound toMatch)
|
|
||||||
{
|
|
||||||
if (toCheck == null || toMatch == null)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
boolean matching = true;
|
|
||||||
for (String key : toMatch.getKeySet())
|
|
||||||
{
|
|
||||||
NBTBase tag = toMatch.getTag(key);
|
|
||||||
key = key.replace("\"", "");
|
|
||||||
NBTBase tagToCheck = toCheck.getTag(key);
|
|
||||||
if (!tag.equals(tagToCheck))
|
|
||||||
matching = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return matching;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double[] getXYZArray(String s)
|
|
||||||
{
|
|
||||||
double[] d = new double[3];
|
|
||||||
d[0] = getValueFromString(s, "x");
|
|
||||||
d[1] = getValueFromString(s, "y");
|
|
||||||
d[2] = getValueFromString(s, "z");
|
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static double[] getScale(String s)
|
|
||||||
{
|
|
||||||
double[] d = new double[3];
|
|
||||||
d[0] = getScaleValueFromString(s, "x");
|
|
||||||
d[1] = getScaleValueFromString(s, "y");
|
|
||||||
d[2] = getScaleValueFromString(s, "z");
|
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double getScaleValueFromString(String toGetFrom, String key)
|
|
||||||
{
|
|
||||||
if(toGetFrom == null)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
String[] s = toGetFrom.split(",");
|
|
||||||
for (String string : s)
|
|
||||||
{
|
|
||||||
if (string.contains(key) && string.contains("="))
|
|
||||||
{
|
|
||||||
double numb = 1;
|
|
||||||
string = string.replace(key + "=", "");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
numb = Double.parseDouble(string);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
return numb;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Achievement getAchievementFromString(String s)
|
|
||||||
{
|
|
||||||
if (s == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
for (Achievement a : AchievementList.ACHIEVEMENTS)
|
|
||||||
{
|
|
||||||
if (a.statId.equals(s))
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean matchesScore(EntityPlayer player, String cond)
|
|
||||||
{
|
|
||||||
if (cond == null)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
Scoreboard score = player.getWorldScoreboard();
|
|
||||||
String numb;
|
|
||||||
String scorename;
|
|
||||||
int iE = cond.indexOf("=");
|
|
||||||
int iG = cond.indexOf(">");
|
|
||||||
int iL = cond.indexOf("<");
|
|
||||||
|
|
||||||
if (iG == -1 ? true : iE < iG && iL == -1 ? true : iE < iL && iE != -1)
|
|
||||||
numb = cond.substring(iE);
|
|
||||||
else if (iE == -1 ? true : iG < iE && iL == -1 ? true : iG < iL && iG != -1)
|
|
||||||
numb = cond.substring(iG);
|
|
||||||
else
|
|
||||||
numb = cond.substring(iL);
|
|
||||||
|
|
||||||
scorename = cond.replace(numb, "");
|
|
||||||
Map<ScoreObjective, Score> o = score.getObjectivesForEntity(player.getGameProfile().getName());
|
|
||||||
if (o != null)
|
|
||||||
{
|
|
||||||
Score sc = o.get(score.getObjective(scorename));
|
|
||||||
if (sc != null)
|
|
||||||
{
|
|
||||||
int points = sc.getScorePoints();
|
|
||||||
|
|
||||||
return matches(points, numb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean matches(BlockPos pos, String cond)
|
|
||||||
{
|
|
||||||
if (cond == null)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
BlockPos blockpos = new BlockPos(getValueFromString(cond, "x"), getValueFromString(cond, "y"), getValueFromString(cond, "z"));
|
|
||||||
BlockPos expand = new BlockPos(getValueFromString(cond, "dx"), getValueFromString(cond, "dy"), getValueFromString(cond, "dz"));
|
|
||||||
BlockPos expanded = blockpos.add(expand);
|
|
||||||
|
|
||||||
boolean x = (pos.getX() >= blockpos.getX() && pos.getX() <= expanded.getX()) || blockpos.getX() == 0;
|
|
||||||
boolean y = (pos.getY() >= blockpos.getY() && pos.getY() <= expanded.getY()) || blockpos.getY() == 0;
|
|
||||||
boolean z = (pos.getZ() >= blockpos.getZ() && pos.getZ() <= expanded.getZ()) || blockpos.getZ() == 0;
|
|
||||||
|
|
||||||
return x && y && z;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double getValueFromString(String toGetFrom, String key)
|
|
||||||
{
|
|
||||||
if(toGetFrom == null)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
String[] s = toGetFrom.split(",");
|
|
||||||
for (String string : s)
|
|
||||||
{
|
|
||||||
if (string.contains(key) && string.contains("="))
|
|
||||||
{
|
|
||||||
double numb = 0;
|
|
||||||
string = string.replace(key + "=", "");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
numb = Double.parseDouble(string);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
return numb;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasEffects(EntityPlayer player, String cond)
|
|
||||||
{
|
|
||||||
if(cond == null)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
Collection<PotionEffect> effects = player.getActivePotionEffects();
|
|
||||||
String[] potions = cond.split(",");
|
|
||||||
|
|
||||||
List<String> names = new ArrayList<String>();
|
|
||||||
List<Integer> levels = new ArrayList<Integer>();
|
|
||||||
|
|
||||||
for(int i = 0; i < potions.length; i++)
|
|
||||||
{
|
|
||||||
String pot = potions[i];
|
|
||||||
if(pot.contains("#"))
|
|
||||||
{
|
|
||||||
String level = pot.substring(pot.indexOf("#"));
|
|
||||||
String name = pot.substring(0, pot.indexOf("#"));
|
|
||||||
level = level.replace("#", "");
|
|
||||||
int lev = 0;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
lev = Integer.parseInt(level);
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{}
|
|
||||||
|
|
||||||
levels.add(lev);
|
|
||||||
names.add(name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
levels.add(0);
|
|
||||||
names.add(pot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int matches = 0;
|
|
||||||
for(PotionEffect effect : effects)
|
|
||||||
{
|
|
||||||
int amp = effect.getAmplifier();
|
|
||||||
String name = effect.getPotion().getRegistryName().toString();
|
|
||||||
|
|
||||||
if(names.contains(name))
|
|
||||||
{
|
|
||||||
int idx = names.indexOf(name);
|
|
||||||
int lev = levels.get(idx);
|
|
||||||
|
|
||||||
if(lev == amp)
|
|
||||||
matches++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return matches == potions.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean matches(Material material, String cond)
|
|
||||||
{
|
|
||||||
if (cond == null)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
switch (cond)
|
|
||||||
{
|
|
||||||
case "air":
|
|
||||||
return material == Material.AIR;
|
|
||||||
case "anvil":
|
|
||||||
return material == Material.ANVIL;
|
|
||||||
case "barrier":
|
|
||||||
return material == Material.BARRIER;
|
|
||||||
case "cactus":
|
|
||||||
return material == Material.CACTUS;
|
|
||||||
case "cake":
|
|
||||||
return material == Material.CAKE;
|
|
||||||
case "carpet":
|
|
||||||
return material == Material.CARPET;
|
|
||||||
case "circuits":
|
|
||||||
return material == Material.CIRCUITS;
|
|
||||||
case "clay":
|
|
||||||
return material == Material.CLAY;
|
|
||||||
case "cloth":
|
|
||||||
return material == Material.CLOTH;
|
|
||||||
case "coral":
|
|
||||||
return material == Material.CORAL;
|
|
||||||
case "dragon_egg":
|
|
||||||
return material == Material.DRAGON_EGG;
|
|
||||||
case "fire":
|
|
||||||
return material == Material.FIRE;
|
|
||||||
case "glass":
|
|
||||||
return material == Material.GLASS;
|
|
||||||
case "gourd":
|
|
||||||
return material == Material.GOURD;
|
|
||||||
case "grass":
|
|
||||||
return material == Material.GRASS;
|
|
||||||
case "ground":
|
|
||||||
return material == Material.GROUND;
|
|
||||||
case "ice":
|
|
||||||
return material == Material.ICE;
|
|
||||||
case "iron":
|
|
||||||
return material == Material.IRON;
|
|
||||||
case "lava":
|
|
||||||
return material == Material.LAVA;
|
|
||||||
case "leaves":
|
|
||||||
return material == Material.LEAVES;
|
|
||||||
case "packed_ice":
|
|
||||||
return material == Material.PACKED_ICE;
|
|
||||||
case "piston":
|
|
||||||
return material == Material.PISTON;
|
|
||||||
case "plants":
|
|
||||||
return material == Material.PLANTS;
|
|
||||||
case "portal":
|
|
||||||
return material == Material.PORTAL;
|
|
||||||
case "redstone_light":
|
|
||||||
return material == Material.REDSTONE_LIGHT;
|
|
||||||
case "rock":
|
|
||||||
return material == Material.ROCK;
|
|
||||||
case "sand":
|
|
||||||
return material == Material.SAND;
|
|
||||||
case "snow":
|
|
||||||
return material == Material.SNOW;
|
|
||||||
case "sponge":
|
|
||||||
return material == Material.SPONGE;
|
|
||||||
case "structure_void":
|
|
||||||
return material == Material.STRUCTURE_VOID;
|
|
||||||
case "tnt":
|
|
||||||
return material == Material.TNT;
|
|
||||||
case "vine":
|
|
||||||
return material == Material.VINE;
|
|
||||||
case "water":
|
|
||||||
return material == Material.WATER;
|
|
||||||
case "web":
|
|
||||||
return material == Material.WEB;
|
|
||||||
case "wood":
|
|
||||||
return material == Material.WOOD;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,158 +0,0 @@
|
||||||
package tschipp.carryon.common.helper;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.Level;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
|
||||||
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
|
|
||||||
{
|
|
||||||
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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(), "");
|
|
||||||
|
|
||||||
int meta = getMeta(string);
|
|
||||||
if (meta == 0)
|
|
||||||
{
|
|
||||||
Block block = getBlock(string);
|
|
||||||
if(block != null)
|
|
||||||
return block.getDefaultState();
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return getBlock(string).getStateFromMeta(meta);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
new InvalidConfigException("Blockstate parsing Exception at: " + string + " : " + e.getMessage()).printException();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static Item getItem(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(";")), "");
|
|
||||||
|
|
||||||
return Item.getByNameOrId(string);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack getItemStack(String string)
|
|
||||||
{
|
|
||||||
if(string == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
Item item = getItem(string);
|
|
||||||
|
|
||||||
if(item == null)
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
|
|
||||||
ItemStack stack = new ItemStack(item, 1, getMeta(string));
|
|
||||||
NBTTagCompound tag = getTagCompound(string);
|
|
||||||
if (tag != null)
|
|
||||||
stack.setTagCompound(tag);
|
|
||||||
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static NBTTagCompound getTagCompound(String string)
|
|
||||||
{
|
|
||||||
NBTTagCompound tag = null;
|
|
||||||
if(string == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (string.contains("{"))
|
|
||||||
{
|
|
||||||
if (!string.contains("}"))
|
|
||||||
new InvalidConfigException("Missing } at : " + string).printException();
|
|
||||||
|
|
||||||
String nbt = string.substring(string.indexOf("{"));
|
|
||||||
string = string.replace(nbt, "");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
tag = JsonToNBT.getTagFromJson(nbt);
|
|
||||||
}
|
|
||||||
catch (NBTException e)
|
|
||||||
{
|
|
||||||
new InvalidConfigException("Error while parsing NBT: " + e.getMessage()).printException();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (string.contains("}"))
|
|
||||||
new InvalidConfigException("Missing { at : " + string).printException();
|
|
||||||
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,221 +0,0 @@
|
||||||
package tschipp.carryon.common.item;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.EntityList;
|
|
||||||
import net.minecraft.entity.EntityLiving;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.init.MobEffects;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.potion.PotionEffect;
|
|
||||||
import net.minecraft.util.EnumActionResult;
|
|
||||||
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.world.World;
|
|
||||||
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
|
|
||||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
|
||||||
import tschipp.carryon.CarryOn;
|
|
||||||
import tschipp.carryon.common.config.CarryOnConfig;
|
|
||||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
|
||||||
|
|
||||||
public class ItemEntity extends Item
|
|
||||||
{
|
|
||||||
|
|
||||||
public static final String ENTITY_DATA_KEY = "entityData";
|
|
||||||
|
|
||||||
public ItemEntity()
|
|
||||||
{
|
|
||||||
this.setUnlocalizedName("entity_item");
|
|
||||||
this.setRegistryName(CarryOn.MODID, "entity_item");
|
|
||||||
GameRegistry.register(this);
|
|
||||||
this.setMaxStackSize(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getItemStackDisplayName(ItemStack stack)
|
|
||||||
{
|
|
||||||
if (hasEntityData(stack))
|
|
||||||
{
|
|
||||||
return I18n.translateToLocal("entity."+EntityList.getTranslationName(new ResourceLocation(getEntityName(stack))) + ".name");
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasEntityData(ItemStack stack)
|
|
||||||
{
|
|
||||||
if (stack.hasTagCompound())
|
|
||||||
{
|
|
||||||
NBTTagCompound tag = stack.getTagCompound();
|
|
||||||
return tag.hasKey(ENTITY_DATA_KEY) && tag.hasKey("entity");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean storeEntityData(@Nonnull Entity entity, World world, ItemStack stack)
|
|
||||||
{
|
|
||||||
if (entity == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (stack.isEmpty())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
NBTTagCompound entityData = new NBTTagCompound();
|
|
||||||
entityData = entity.writeToNBT(entityData);
|
|
||||||
|
|
||||||
String name = EntityList.getKey(entity).toString();
|
|
||||||
|
|
||||||
NBTTagCompound tag = stack.hasTagCompound() ? stack.getTagCompound() : new NBTTagCompound();
|
|
||||||
if (tag.hasKey(ENTITY_DATA_KEY))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
tag.setTag(ENTITY_DATA_KEY, entityData);
|
|
||||||
tag.setString("entity", name);
|
|
||||||
stack.setTagCompound(tag);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
|
||||||
{
|
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
|
||||||
Block block = world.getBlockState(pos).getBlock();
|
|
||||||
|
|
||||||
if (hasEntityData(stack))
|
|
||||||
{
|
|
||||||
BlockPos finalPos = pos;
|
|
||||||
|
|
||||||
if (!block.isReplaceable(world, pos))
|
|
||||||
{
|
|
||||||
finalPos = pos.offset(facing);
|
|
||||||
}
|
|
||||||
|
|
||||||
Entity entity = getEntity(stack, world);
|
|
||||||
if (entity != null)
|
|
||||||
{
|
|
||||||
if (!world.isRemote)
|
|
||||||
{
|
|
||||||
entity.setPositionAndRotation(finalPos.getX() + 0.5, finalPos.getY(), finalPos.getZ() + 0.5, 180 + player.rotationYawHead, 0.0f);
|
|
||||||
world.spawnEntity(entity);
|
|
||||||
if (entity instanceof EntityLiving)
|
|
||||||
{
|
|
||||||
((EntityLiving) entity).playLivingSound();
|
|
||||||
}
|
|
||||||
clearEntityData(stack);
|
|
||||||
player.setHeldItem(hand, ItemStack.EMPTY);
|
|
||||||
CarryOn.network.sendToAllAround(new CarrySlotPacket(9, player.getEntityId()), new TargetPoint(world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));
|
|
||||||
}
|
|
||||||
player.getEntityData().removeTag("overrideKey");
|
|
||||||
return EnumActionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return EnumActionResult.FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected)
|
|
||||||
{
|
|
||||||
if (hasEntityData(stack))
|
|
||||||
{
|
|
||||||
if(getEntity(stack, world) == null)
|
|
||||||
stack = ItemStack.EMPTY;
|
|
||||||
|
|
||||||
if (entity instanceof EntityLivingBase)
|
|
||||||
{
|
|
||||||
if(entity instanceof EntityPlayer && CarryOnConfig.settings.slownessInCreative ? false : ((EntityPlayer)entity).isCreative())
|
|
||||||
return;
|
|
||||||
|
|
||||||
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 1, potionLevel(stack, world), false, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stack = ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void clearEntityData(ItemStack stack)
|
|
||||||
{
|
|
||||||
if (stack.hasTagCompound())
|
|
||||||
{
|
|
||||||
NBTTagCompound tag = stack.getTagCompound();
|
|
||||||
tag.removeTag(ENTITY_DATA_KEY);
|
|
||||||
tag.removeTag("entity");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NBTTagCompound getEntityData(ItemStack stack)
|
|
||||||
{
|
|
||||||
if (stack.hasTagCompound())
|
|
||||||
{
|
|
||||||
NBTTagCompound tag = stack.getTagCompound();
|
|
||||||
return tag.getCompoundTag(ENTITY_DATA_KEY);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Entity getEntity(ItemStack stack, World world)
|
|
||||||
{
|
|
||||||
if (world == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
String name = getEntityName(stack);
|
|
||||||
|
|
||||||
NBTTagCompound e = getEntityData(stack);
|
|
||||||
Entity entity = EntityList.createEntityByIDFromName(new ResourceLocation(name), world);
|
|
||||||
if (entity != null)
|
|
||||||
entity.readFromNBT(e);
|
|
||||||
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getEntityName(ItemStack stack)
|
|
||||||
{
|
|
||||||
if (stack.hasTagCompound())
|
|
||||||
{
|
|
||||||
NBTTagCompound tag = stack.getTagCompound();
|
|
||||||
return tag.getString("entity");
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getCustomName(ItemStack stack)
|
|
||||||
{
|
|
||||||
if (stack.hasTagCompound())
|
|
||||||
{
|
|
||||||
NBTTagCompound tag = stack.getTagCompound();
|
|
||||||
if (tag.hasKey("CustomName") && !tag.getString("CustomName").isEmpty()) {
|
|
||||||
return tag.toString();
|
|
||||||
} else {
|
|
||||||
return tag.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int potionLevel(ItemStack stack, World world)
|
|
||||||
{
|
|
||||||
Entity e = getEntity(stack, world);
|
|
||||||
if(e == null)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
int i = (int)(e.height * e.width);
|
|
||||||
if (i > 4)
|
|
||||||
i = 4;
|
|
||||||
|
|
||||||
if (!CarryOnConfig.settings.heavyEntities)
|
|
||||||
i = 1;
|
|
||||||
|
|
||||||
return (int) (i * CarryOnConfig.settings.entitySlownessMultiplier);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,333 +0,0 @@
|
||||||
package tschipp.carryon.common.item;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
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.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.potion.PotionEffect;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.EnumActionResult;
|
|
||||||
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.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.network.NetworkRegistry.TargetPoint;
|
|
||||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
|
||||||
import tschipp.carryon.CarryOn;
|
|
||||||
import tschipp.carryon.common.config.CarryOnConfig;
|
|
||||||
import tschipp.carryon.common.handler.CustomPickupOverrideHandler;
|
|
||||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
|
||||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
|
||||||
|
|
||||||
public class ItemTile extends Item
|
|
||||||
{
|
|
||||||
|
|
||||||
public static final String TILE_DATA_KEY = "tileData";
|
|
||||||
|
|
||||||
public ItemTile()
|
|
||||||
{
|
|
||||||
this.setUnlocalizedName("tile_item");
|
|
||||||
this.setRegistryName(CarryOn.MODID, "tile_item");
|
|
||||||
GameRegistry.register(this);
|
|
||||||
this.setMaxStackSize(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getItemStackDisplayName(ItemStack stack)
|
|
||||||
{
|
|
||||||
if (hasTileData(stack))
|
|
||||||
{
|
|
||||||
IBlockState state = getBlockState(stack);
|
|
||||||
NBTTagCompound nbt = getTileData(stack);
|
|
||||||
|
|
||||||
if (ModelOverridesHandler.hasCustomOverrideModel(state, nbt))
|
|
||||||
{
|
|
||||||
Object override = ModelOverridesHandler.getOverrideObject(state, nbt);
|
|
||||||
if (override instanceof ItemStack)
|
|
||||||
return ((ItemStack) override).getDisplayName();
|
|
||||||
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 getItemStack(stack).getDisplayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
|
||||||
{
|
|
||||||
Block block = world.getBlockState(pos).getBlock();
|
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
|
||||||
if (hasTileData(stack))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Vec3d vec = player.getLookVec();
|
|
||||||
EnumFacing facing2 = EnumFacing.getFacingFromVector((float) vec.xCoord, 0f, (float) vec.zCoord);
|
|
||||||
BlockPos pos2 = pos;
|
|
||||||
Block containedblock = getBlock(stack);
|
|
||||||
int meta = getMeta(stack);
|
|
||||||
IBlockState containedstate = getBlockState(stack);
|
|
||||||
if (!world.getBlockState(pos2).getBlock().isReplaceable(world, pos2))
|
|
||||||
{
|
|
||||||
pos2 = pos.offset(facing);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world.getBlockState(pos2).getBlock().isReplaceable(world, pos2) && containedblock != null)
|
|
||||||
{
|
|
||||||
boolean canPlace = containedblock.canPlaceBlockAt(world, pos2);
|
|
||||||
|
|
||||||
if (canPlace)
|
|
||||||
{
|
|
||||||
if (player.canPlayerEdit(pos, facing, stack) && world.mayPlace(containedblock, pos2, false, facing, (Entity) null))
|
|
||||||
{
|
|
||||||
boolean set = false;
|
|
||||||
|
|
||||||
Iterator<IProperty<?>> iterator = containedblock.getDefaultState().getPropertyKeys().iterator();
|
|
||||||
while (iterator.hasNext())
|
|
||||||
{
|
|
||||||
IProperty prop = iterator.next();
|
|
||||||
Object[] allowedValues = prop.getAllowedValues().toArray();
|
|
||||||
|
|
||||||
if (prop instanceof PropertyDirection && this.equal(allowedValues, EnumFacing.HORIZONTALS))
|
|
||||||
{
|
|
||||||
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.xCoord, (float) vec.yCoord, (float) vec.zCoord);
|
|
||||||
world.setBlockState(pos2, containedstate.withProperty(prop, facing2.getOpposite()));
|
|
||||||
set = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!set)
|
|
||||||
world.setBlockState(pos2, containedstate);
|
|
||||||
|
|
||||||
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");
|
|
||||||
CarryOn.network.sendToAllAround(new CarrySlotPacket(9, player.getEntityId()), new TargetPoint(world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));
|
|
||||||
return EnumActionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
|
|
||||||
if (world != null && world.isRemote)
|
|
||||||
{
|
|
||||||
CarryOn.LOGGER.info("Block: " + ItemTile.getBlock(stack));
|
|
||||||
CarryOn.LOGGER.info("BlockState: " + ItemTile.getBlockState(stack));
|
|
||||||
CarryOn.LOGGER.info("Meta: " + ItemTile.getMeta(stack));
|
|
||||||
CarryOn.LOGGER.info("ItemStack: " + ItemTile.getItemStack(stack));
|
|
||||||
|
|
||||||
if (ModelOverridesHandler.hasCustomOverrideModel(ItemTile.getBlockState(stack), ItemTile.getTileData(stack)))
|
|
||||||
CarryOn.LOGGER.info("Override Model: " + ModelOverridesHandler.getOverrideObject(ItemTile.getBlockState(stack), ItemTile.getTileData(stack)));
|
|
||||||
|
|
||||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemTile.getBlockState(stack)))
|
|
||||||
CarryOn.LOGGER.info("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemTile.getBlockState(stack)));
|
|
||||||
|
|
||||||
player.sendMessage(new TextComponentString(TextFormatting.RED + "Error detected. Cannot place block. Execute \"/carryon clear\" to remove the item"));
|
|
||||||
TextComponentString s = new TextComponentString(TextFormatting.GOLD + "here");
|
|
||||||
s.getStyle().setClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/Tschipp/CarryOn/issues"));
|
|
||||||
player.sendMessage(new TextComponentString(TextFormatting.RED + "Please report this error ").appendSibling(s));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return EnumActionResult.FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdate(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())
|
|
||||||
return;
|
|
||||||
|
|
||||||
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 1, potionLevel(stack), false, false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stack = ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasTileData(ItemStack stack)
|
|
||||||
{
|
|
||||||
if (stack.hasTagCompound())
|
|
||||||
{
|
|
||||||
NBTTagCompound tag = stack.getTagCompound();
|
|
||||||
return tag.hasKey(TILE_DATA_KEY) && tag.hasKey("block") && tag.hasKey("meta") && tag.hasKey("stateid");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean storeTileData(@Nullable TileEntity tile, World world, BlockPos pos, IBlockState state, ItemStack stack)
|
|
||||||
{
|
|
||||||
if (stack.isEmpty())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
NBTTagCompound chest = new NBTTagCompound();
|
|
||||||
if (tile != null)
|
|
||||||
chest = tile.writeToNBT(chest);
|
|
||||||
|
|
||||||
NBTTagCompound tag = stack.hasTagCompound() ? stack.getTagCompound() : 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));
|
|
||||||
|
|
||||||
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);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void clearTileData(ItemStack stack)
|
|
||||||
{
|
|
||||||
if (stack.hasTagCompound())
|
|
||||||
{
|
|
||||||
NBTTagCompound tag = stack.getTagCompound();
|
|
||||||
tag.removeTag(TILE_DATA_KEY);
|
|
||||||
tag.removeTag("block");
|
|
||||||
tag.removeTag("meta");
|
|
||||||
tag.removeTag("stateid");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NBTTagCompound getTileData(ItemStack stack)
|
|
||||||
{
|
|
||||||
if (stack.hasTagCompound())
|
|
||||||
{
|
|
||||||
NBTTagCompound tag = stack.getTagCompound();
|
|
||||||
return tag.getCompoundTag(TILE_DATA_KEY);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Block getBlock(ItemStack stack)
|
|
||||||
{
|
|
||||||
if (stack.hasTagCompound())
|
|
||||||
{
|
|
||||||
NBTTagCompound tag = stack.getTagCompound();
|
|
||||||
int id = tag.getInteger("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 ItemStack getItemStack(ItemStack stack)
|
|
||||||
{
|
|
||||||
return new ItemStack(getBlock(stack), 1, getMeta(stack));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IBlockState getBlockState(ItemStack stack)
|
|
||||||
{
|
|
||||||
if (stack.hasTagCompound())
|
|
||||||
{
|
|
||||||
NBTTagCompound tag = stack.getTagCompound();
|
|
||||||
int id = tag.getInteger("stateid");
|
|
||||||
return Block.getStateById(id);
|
|
||||||
}
|
|
||||||
return Blocks.AIR.getDefaultState();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isLocked(BlockPos pos, World world)
|
|
||||||
{
|
|
||||||
TileEntity te = world.getTileEntity(pos);
|
|
||||||
if (te != null)
|
|
||||||
{
|
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
|
||||||
te.writeToNBT(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 int potionLevel(ItemStack stack)
|
|
||||||
{
|
|
||||||
String nbt = getTileData(stack).toString();
|
|
||||||
int i = nbt.length() / 500;
|
|
||||||
|
|
||||||
if (i > 4)
|
|
||||||
i = 4;
|
|
||||||
|
|
||||||
if (!CarryOnConfig.settings.heavyTiles)
|
|
||||||
i = 1;
|
|
||||||
|
|
||||||
return (int) (i * CarryOnConfig.settings.blockSlownessMultiplier);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
11
src/main/java/tschipp/carryon/interfaces/ICarryOnData.java
Normal file
11
src/main/java/tschipp/carryon/interfaces/ICarryOnData.java
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
package tschipp.carryon.interfaces;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
|
||||||
|
public interface ICarryOnData {
|
||||||
|
|
||||||
|
public CompoundTag getCarryOnData();
|
||||||
|
|
||||||
|
public void setCarryOnData(CompoundTag tag);
|
||||||
|
|
||||||
|
}
|
||||||
213
src/main/java/tschipp/carryon/items/ItemEntity.java
Normal file
213
src/main/java/tschipp/carryon/items/ItemEntity.java
Normal file
|
|
@ -0,0 +1,213 @@
|
||||||
|
package tschipp.carryon.items;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
|
import net.minecraft.entity.effect.StatusEffects;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemPlacementContext;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.ItemUsageContext;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.text.StringTextComponent;
|
||||||
|
import net.minecraft.text.TextComponent;
|
||||||
|
import net.minecraft.text.TranslatableTextComponent;
|
||||||
|
import net.minecraft.util.ActionResult;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class ItemEntity extends Item {
|
||||||
|
|
||||||
|
public static final String ENTITY_DATA_KEY = "entityData";
|
||||||
|
|
||||||
|
public ItemEntity() {
|
||||||
|
super(new Item.Settings().stackSize(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextComponent getTranslatedNameTrimmed(ItemStack stack) {
|
||||||
|
if (hasEntityData(stack)) {
|
||||||
|
return new TranslatableTextComponent(getEntityType(stack).getTranslationKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
return new StringTextComponent("");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasEntityData(ItemStack stack) {
|
||||||
|
if (stack.hasTag()) {
|
||||||
|
CompoundTag tag = stack.getTag();
|
||||||
|
return tag.containsKey(ENTITY_DATA_KEY) && tag.containsKey("entity");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean storeEntityData(Entity entity, World world, ItemStack stack) {
|
||||||
|
if (entity == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (stack.isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
CompoundTag entityData = new CompoundTag();
|
||||||
|
entityData = entity.toTag(entityData);
|
||||||
|
EntityType<?> type = entity.getType();
|
||||||
|
|
||||||
|
String name = EntityType.getId(type).toString();
|
||||||
|
|
||||||
|
CompoundTag tag = stack.hasTag() ? stack.getTag() : new CompoundTag();
|
||||||
|
if (tag.containsKey(ENTITY_DATA_KEY))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
tag.put(ENTITY_DATA_KEY, entityData);
|
||||||
|
tag.putString("entity", name);
|
||||||
|
stack.setTag(tag);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionResult useOnBlock(ItemUsageContext context) {
|
||||||
|
|
||||||
|
Direction Direction = context.getFacing();
|
||||||
|
PlayerEntity player = context.getPlayer();
|
||||||
|
World world = context.getWorld();
|
||||||
|
BlockPos pos = context.getPos();
|
||||||
|
ItemStack stack = context.getItemStack();
|
||||||
|
|
||||||
|
// if(Loader.isModLoaded("betterplacement"))
|
||||||
|
// {
|
||||||
|
// if(CarryOnKeybinds.isKeyPressed(player))
|
||||||
|
// return ActionResult.FAIL;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (hasEntityData(stack)) {
|
||||||
|
BlockPos finalPos = pos;
|
||||||
|
|
||||||
|
if (!world.getBlockState(finalPos).method_11587(new ItemPlacementContext(context)))
|
||||||
|
{
|
||||||
|
finalPos = pos.offset(Direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
Entity entity = getEntity(stack, world);
|
||||||
|
if (entity != null) {
|
||||||
|
if (!world.isClient) {
|
||||||
|
entity.setPositionAndAngles(finalPos.getX() + 0.5, finalPos.getY(), finalPos.getZ() + 0.5,
|
||||||
|
180 + player.yaw, 0.0f);
|
||||||
|
world.spawnEntity(entity);
|
||||||
|
if (entity instanceof LivingEntity) {
|
||||||
|
// ((LivingEntity) entity).sound.playLivingSound();
|
||||||
|
}
|
||||||
|
clearEntityData(stack);
|
||||||
|
player.setStackInHand(Hand.MAIN, ItemStack.EMPTY);
|
||||||
|
// ItemEvents.sendPacket(player, 9, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
// player.getEntityData().remove("overrideKey");
|
||||||
|
return ActionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ActionResult.FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
|
||||||
|
if (hasEntityData(stack)) {
|
||||||
|
if (getEntity(stack, world) == null)
|
||||||
|
stack = ItemStack.EMPTY;
|
||||||
|
|
||||||
|
if (entity instanceof LivingEntity) {
|
||||||
|
if (entity instanceof PlayerEntity
|
||||||
|
&& /* CarryOnConfig.settings.slownessInCreative ? false : */ ((PlayerEntity) entity)
|
||||||
|
.isCreative())
|
||||||
|
return;
|
||||||
|
|
||||||
|
((LivingEntity) entity).addPotionEffect(
|
||||||
|
new StatusEffectInstance(StatusEffects.SLOWNESS, 1, potionLevel(stack, world), false, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
stack = ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clearEntityData(ItemStack stack) {
|
||||||
|
if (stack.hasTag()) {
|
||||||
|
CompoundTag tag = stack.getTag();
|
||||||
|
tag.remove(ENTITY_DATA_KEY);
|
||||||
|
tag.remove("entity");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CompoundTag getEntityData(ItemStack stack) {
|
||||||
|
if (stack.hasTag()) {
|
||||||
|
CompoundTag tag = stack.getTag();
|
||||||
|
return tag.getCompound(ENTITY_DATA_KEY);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Entity getEntity(ItemStack stack, World world) {
|
||||||
|
if (world == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
String name = getEntityName(stack);
|
||||||
|
|
||||||
|
CompoundTag e = getEntityData(stack);
|
||||||
|
Entity entity = EntityType.createInstance(world, new Identifier(name));
|
||||||
|
if (entity != null)
|
||||||
|
entity.fromTag(e);
|
||||||
|
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getEntityName(ItemStack stack) {
|
||||||
|
if (stack.hasTag()) {
|
||||||
|
CompoundTag tag = stack.getTag();
|
||||||
|
return tag.getString("entity");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EntityType<?> getEntityType(ItemStack stack) {
|
||||||
|
if (stack.hasTag()) {
|
||||||
|
CompoundTag tag = stack.getTag();
|
||||||
|
String name = tag.getString("entity");
|
||||||
|
EntityType<?> type = EntityType.get(name);
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getCustomName(ItemStack stack) {
|
||||||
|
if (stack.hasTag()) {
|
||||||
|
CompoundTag tag = stack.getTag();
|
||||||
|
if (tag.containsKey("CustomName") && !tag.getString("CustomName").isEmpty()) {
|
||||||
|
return tag.toString();
|
||||||
|
} else {
|
||||||
|
return tag.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int potionLevel(ItemStack stack, World world) {
|
||||||
|
Entity e = getEntity(stack, world);
|
||||||
|
if (e == null)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
int i = (int) (e.height * e.width);
|
||||||
|
if (i > 4)
|
||||||
|
i = 4;
|
||||||
|
|
||||||
|
// if (!CarryOnConfig.settings.heavyEntities)
|
||||||
|
// i = 1;
|
||||||
|
|
||||||
|
// return (int) (i * CarryOnConfig.settings.entitySlownessMultiplier);
|
||||||
|
return i * 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
351
src/main/java/tschipp/carryon/items/ItemTile.java
Normal file
351
src/main/java/tschipp/carryon/items/ItemTile.java
Normal file
|
|
@ -0,0 +1,351 @@
|
||||||
|
package tschipp.carryon.items;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
|
import net.minecraft.entity.effect.StatusEffects;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemPlacementContext;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.ItemUsageContext;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.text.StringTextComponent;
|
||||||
|
import net.minecraft.text.TextComponent;
|
||||||
|
import net.minecraft.util.ActionResult;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class ItemTile extends Item {
|
||||||
|
|
||||||
|
public static final String TILE_DATA_KEY = "tileData";
|
||||||
|
public static final String[] Direction_KEYS = new String[] { "rotation", "rot", "Direction", "face", "direction", "dir",
|
||||||
|
"front" };
|
||||||
|
|
||||||
|
public ItemTile() {
|
||||||
|
super(new Item.Settings().stackSize(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextComponent getTranslatedNameTrimmed(ItemStack stack) {
|
||||||
|
if (hasTileData(stack)) {
|
||||||
|
// BlockState state = getBlockState(stack);
|
||||||
|
// CompoundTag nbt = getTileData(stack);
|
||||||
|
|
||||||
|
// if (ModelOverridesHandler.hasCustomOverrideModel(state, nbt))
|
||||||
|
// {
|
||||||
|
// Object override = ModelOverridesHandler.getOverrideObject(state, nbt);
|
||||||
|
// if (override instanceof ItemStack)
|
||||||
|
// return ((ItemStack) override).getDisplayName();
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// BlockState ostate = (BlockState) override;
|
||||||
|
// List<ItemStack> drops = ostate.getDroppedStacks(new LootContext.Builder());
|
||||||
|
// ItemStack itemstack = new ItemStack(ostate.getBlock().getItemDropped(ostate, this.random, 0), 1, state.getBlock().damageDropped(ostate));
|
||||||
|
// return itemstack.getDisplayName();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
return getItemStack(stack).getItem().getTranslatedNameTrimmed(getItemStack(stack));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new StringTextComponent("");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionResult useOnBlock(ItemUsageContext context)
|
||||||
|
{
|
||||||
|
// if (Loader.isModLoaded("betterplacement"))
|
||||||
|
// {
|
||||||
|
// if (CarryOnKeybinds.isKeyPressed(player))
|
||||||
|
// return EnumActionResult.FAIL;
|
||||||
|
// }
|
||||||
|
|
||||||
|
Direction direction = context.getFacing();
|
||||||
|
PlayerEntity player = context.getPlayer();
|
||||||
|
World world = context.getWorld();
|
||||||
|
BlockPos pos = context.getPos();
|
||||||
|
ItemStack stack = context.getItemStack();
|
||||||
|
|
||||||
|
|
||||||
|
// Block block = world.getBlockState(pos).getBlock();
|
||||||
|
if (hasTileData(stack))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Vec3d vec = player.getRotationVecClient();
|
||||||
|
Direction direction2 = Direction.getFacing((float) vec.x, 0f, (float) vec.z);
|
||||||
|
BlockPos pos2 = pos;
|
||||||
|
Block containedblock = getBlock(stack);
|
||||||
|
BlockState containedstate = getBlockState(stack);
|
||||||
|
if (!world.getBlockState(pos).method_11587(new ItemPlacementContext(context)))
|
||||||
|
{
|
||||||
|
pos2 = pos.offset(direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (world.getBlockState(pos2).getBlock().method_9579(world.getBlockState(pos2), world, pos2) && containedblock != null)
|
||||||
|
{
|
||||||
|
boolean canPlace = containedblock.canPlaceAt(world.getBlockState(pos2), world, pos2);
|
||||||
|
|
||||||
|
if (canPlace)
|
||||||
|
{
|
||||||
|
if (player.canPlaceBlock(pos2, direction, stack) && world.canPlayerModifyAt(player, pos2))
|
||||||
|
{
|
||||||
|
// Handles Blockstate rotation
|
||||||
|
// Iterator<Property<?>> iterator = containedblock.getDefaultState().getProperties().iterator();
|
||||||
|
// while (iterator.hasNext())
|
||||||
|
// {
|
||||||
|
// Property prop = iterator.next();
|
||||||
|
// Object[] allowedValues = prop.getValues().toArray();
|
||||||
|
|
||||||
|
// if (prop instanceof DirectionProperty && this.equal(allowedValues, horizontals))
|
||||||
|
// {
|
||||||
|
// world.setBlockState(pos2, containedstate.with(prop, containedblock instanceof StairsBlock ? Direction2 : Direction2.getOpposite()));
|
||||||
|
// set = true;
|
||||||
|
// }
|
||||||
|
// else if (prop instanceof DirectionProperty && this.equal(allowedValues, Direction.values()))
|
||||||
|
// {
|
||||||
|
// Direction2 = Direction.getDirection((float) vec.x, (float) vec.y, (float) vec.z);
|
||||||
|
// world.setBlockState(pos2, containedstate.with(prop, Direction2.getOpposite()));
|
||||||
|
// set = true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
BlockState actualState = containedblock.getPlacementState(new ItemPlacementContext(context));
|
||||||
|
world.setBlockState(pos2, actualState);
|
||||||
|
|
||||||
|
// world.updateNeighborsAlways(pos2, containedblock);
|
||||||
|
// If the blockstate doesn't handle rotation, try to
|
||||||
|
// change rotation via NBT
|
||||||
|
if (!getTileData(stack).isEmpty())
|
||||||
|
{
|
||||||
|
CompoundTag tag = getTileData(stack);
|
||||||
|
Set<String> keys = tag.getKeys();
|
||||||
|
keytester:
|
||||||
|
for (String key : keys)
|
||||||
|
{
|
||||||
|
for (String DirectionKey : Direction_KEYS)
|
||||||
|
{
|
||||||
|
if (key.toLowerCase().equals(DirectionKey))
|
||||||
|
{
|
||||||
|
byte type = tag.getType(key);
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case 8:
|
||||||
|
tag.putString(key, direction2.getOpposite().getName());
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
tag.putInt(key, direction2.getOpposite().getId());
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
tag.putByte(key, (byte) direction2.getOpposite().getId());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
break keytester;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockEntity tile = world.getBlockEntity(pos2);
|
||||||
|
if (tile != null)
|
||||||
|
{
|
||||||
|
tile.fromTag(getTileData(stack));
|
||||||
|
tile.setPos(pos2);
|
||||||
|
}
|
||||||
|
clearTileData(stack);
|
||||||
|
player.playSoundAtEntity(containedstate.getSoundGroup().getPlaceSound(), 1.0f, 0.5f);
|
||||||
|
player.setStackInHand(Hand.MAIN, ItemStack.EMPTY);
|
||||||
|
// player.nbt.remove("overrideKey");
|
||||||
|
// ItemEvents.sendPacket(player, 9, 0);
|
||||||
|
return ActionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
// if (world != null && world.isRemote)
|
||||||
|
// {
|
||||||
|
// CarryOn.LOGGER.info("Block: " + ItemTile.getBlock(stack));
|
||||||
|
// CarryOn.LOGGER.info("BlockState: " + ItemTile.getBlockState(stack));
|
||||||
|
// CarryOn.LOGGER.info("Meta: " + ItemTile.getMeta(stack));
|
||||||
|
// CarryOn.LOGGER.info("ItemStack: " + ItemTile.getItemStack(stack));
|
||||||
|
|
||||||
|
// if (ModelOverridesHandler.hasCustomOverrideModel(ItemTile.getBlockState(stack), ItemTile.getTileData(stack)))
|
||||||
|
// CarryOn.LOGGER.info("Override Model: " + ModelOverridesHandler.getOverrideObject(ItemTile.getBlockState(stack), ItemTile.getTileData(stack)));
|
||||||
|
|
||||||
|
// if (CustomPickupOverrideHandler.hasSpecialPickupConditions(ItemTile.getBlockState(stack)))
|
||||||
|
// CarryOn.LOGGER.info("Custom Pickup Condition: " + CustomPickupOverrideHandler.getPickupCondition(ItemTile.getBlockState(stack)));
|
||||||
|
|
||||||
|
// player.sendMessage(new TextComponentString(TextFormatting.RED + "Error detected. Cannot place block. Execute \"/carryon clear\" to remove the item"));
|
||||||
|
// TextComponentString s = new TextComponentString(TextFormatting.GOLD + "here");
|
||||||
|
// s.getStyle().setClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/Tschipp/CarryOn/issues"));
|
||||||
|
// player.sendMessage(new TextComponentString(TextFormatting.RED + "Please report this error ").appendSibling(s));
|
||||||
|
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return ActionResult.FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected)
|
||||||
|
{
|
||||||
|
if (hasTileData(stack))
|
||||||
|
{
|
||||||
|
if (entity instanceof LivingEntity)
|
||||||
|
{
|
||||||
|
if (entity instanceof PlayerEntity && /*CarryOnConfig.settings.slownessInCreative ? false : */ ((PlayerEntity) entity).isCreative())
|
||||||
|
return;
|
||||||
|
|
||||||
|
((LivingEntity) entity).addPotionEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 1, potionLevel(stack), false, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stack = ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasTileData(ItemStack stack)
|
||||||
|
{
|
||||||
|
if (stack.hasTag())
|
||||||
|
{
|
||||||
|
CompoundTag tag = stack.getTag();
|
||||||
|
return tag.containsKey(TILE_DATA_KEY) && tag.containsKey("block") && tag.containsKey("stateid");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean storeTileData(BlockEntity tile, World world, BlockPos pos, BlockState state, ItemStack stack)
|
||||||
|
{
|
||||||
|
if (stack.isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
CompoundTag chest = new CompoundTag();
|
||||||
|
if (tile != null)
|
||||||
|
chest = tile.toTag(chest);
|
||||||
|
|
||||||
|
CompoundTag tag = stack.hasTag() ? stack.getTag() : new CompoundTag();
|
||||||
|
if (tag.containsKey(TILE_DATA_KEY))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
tag.put(TILE_DATA_KEY, chest);
|
||||||
|
|
||||||
|
// ItemStack drop = new ItemStack(state.getBlock().getItemDropped(state, ItemTile.random, 0), 1, state.getBlock().damageDropped(state));
|
||||||
|
|
||||||
|
tag.putString("block", Registry.BLOCK.getId(getBlock(stack)).toString());
|
||||||
|
// Item item = Item.getItemFromBlock(state.getBlock());
|
||||||
|
tag.putInt("stateid", Block.getRawIdFromState(state));
|
||||||
|
stack.setTag(tag);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clearTileData(ItemStack stack)
|
||||||
|
{
|
||||||
|
if (stack.hasTag())
|
||||||
|
{
|
||||||
|
CompoundTag tag = stack.getTag();
|
||||||
|
tag.remove(TILE_DATA_KEY);
|
||||||
|
tag.remove("block");
|
||||||
|
tag.remove("stateid");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CompoundTag getTileData(ItemStack stack)
|
||||||
|
{
|
||||||
|
if (stack.hasTag())
|
||||||
|
{
|
||||||
|
CompoundTag tag = stack.getTag();
|
||||||
|
return (CompoundTag)tag.getTag(TILE_DATA_KEY);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Block getBlock(ItemStack stack)
|
||||||
|
{
|
||||||
|
if (stack.hasTag())
|
||||||
|
{
|
||||||
|
CompoundTag tag = stack.getTag();
|
||||||
|
int id = tag.getInt("stateid");
|
||||||
|
return Block.getStateFromRawId(id).getBlock();
|
||||||
|
}
|
||||||
|
return Blocks.AIR;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack getItemStack(ItemStack stack)
|
||||||
|
{
|
||||||
|
return new ItemStack(getBlock(stack), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockState getBlockState(ItemStack stack)
|
||||||
|
{
|
||||||
|
if (stack.hasTag())
|
||||||
|
{
|
||||||
|
CompoundTag tag = stack.getTag();
|
||||||
|
int id = tag.getInt("stateid");
|
||||||
|
return Block.getStateFromRawId(id);
|
||||||
|
}
|
||||||
|
return Blocks.AIR.getDefaultState();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isLocked(BlockPos pos, World world)
|
||||||
|
{
|
||||||
|
BlockEntity te = world.getBlockEntity(pos);
|
||||||
|
if (te != null)
|
||||||
|
{
|
||||||
|
CompoundTag tag = new CompoundTag();
|
||||||
|
te.toTag(tag);
|
||||||
|
return tag.containsKey("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 int potionLevel(ItemStack stack)
|
||||||
|
{
|
||||||
|
String nbt = getTileData(stack).toString();
|
||||||
|
int i = nbt.length() / 500;
|
||||||
|
|
||||||
|
if (i > 4)
|
||||||
|
i = 4;
|
||||||
|
|
||||||
|
// if (!CarryOnConfig.settings.heavyTiles)
|
||||||
|
// i = 1;
|
||||||
|
|
||||||
|
// return (int) (i * CarryOnConfig.settings.blockSlownessMultiplier);
|
||||||
|
|
||||||
|
return i * 1;
|
||||||
|
// return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
45
src/main/java/tschipp/carryon/keybinds/CarryOnKeybinds.java
Normal file
45
src/main/java/tschipp/carryon/keybinds/CarryOnKeybinds.java
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
package tschipp.carryon.keybinds;
|
||||||
|
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
|
import net.minecraft.client.util.InputUtil;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import tschipp.carryon.interfaces.ICarryOnData;
|
||||||
|
|
||||||
|
|
||||||
|
public class CarryOnKeybinds
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final String KEYBIND_KEY = "carryOnKeyPressed";
|
||||||
|
public static KeyBinding carryKey;
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public static void init()
|
||||||
|
{
|
||||||
|
carryKey = new KeyBinding("key.carry.desc", InputUtil.Type.KEY_KEYBOARD, 340, "key.carry.category");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isKeyPressed(PlayerEntity player)
|
||||||
|
{
|
||||||
|
ICarryOnData data = (ICarryOnData)player;
|
||||||
|
CompoundTag tag = data.getCarryOnData();
|
||||||
|
if(tag != null && tag.containsKey(KEYBIND_KEY))
|
||||||
|
{
|
||||||
|
return tag.getBoolean(KEYBIND_KEY);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setKeyPressed(PlayerEntity player, boolean pressed)
|
||||||
|
{
|
||||||
|
ICarryOnData data = (ICarryOnData)player;
|
||||||
|
CompoundTag tag = data.getCarryOnData();
|
||||||
|
tag.putBoolean(KEYBIND_KEY, pressed);
|
||||||
|
data.setCarryOnData(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
package tschipp.carryon.mixin.client;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import net.minecraft.class_3883;
|
||||||
|
import net.minecraft.client.model.Model;
|
||||||
|
import net.minecraft.client.render.entity.ArmorBipedEntityRenderer;
|
||||||
|
import net.minecraft.client.render.entity.ArmorEntityRenderer;
|
||||||
|
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import tschipp.carryon.RegistryHandler;
|
||||||
|
import tschipp.carryon.render.ICarrying;
|
||||||
|
|
||||||
|
@Mixin(ArmorBipedEntityRenderer.class)
|
||||||
|
public abstract class ArmorRendererMixin<T extends LivingEntity, M extends Model<T>, A extends BipedEntityModel<T>> extends ArmorEntityRenderer<T, M, A> {
|
||||||
|
|
||||||
|
protected ArmorRendererMixin(class_3883<T, M> var1, A var2, A var3) {
|
||||||
|
super(var1, var2, var3);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Used to be "render"
|
||||||
|
@Inject(method = "method_17157", at = @At("HEAD"))
|
||||||
|
private void onRenderArmor(LivingEntity living, float var2, float var3, float var4, float var5, float var6, float var7, float var8, CallbackInfo info)
|
||||||
|
{
|
||||||
|
ItemStack stack = living.getMainHandStack();
|
||||||
|
ICarrying model = (ICarrying)this.modelBody;
|
||||||
|
|
||||||
|
if (!stack.isEmpty() && stack.getItem() == RegistryHandler.TILE_ITEM)
|
||||||
|
model.setCarryingBlock(true);
|
||||||
|
else
|
||||||
|
model.setCarryingBlock(false);
|
||||||
|
|
||||||
|
if (!stack.isEmpty() && stack.getItem() == RegistryHandler.ENTITY_ITEM)
|
||||||
|
model.setCarryingEntity(true);
|
||||||
|
else
|
||||||
|
model.setCarryingEntity(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void method_17157(T var1, float var2, float var3, float var4, float var5, float var6, float var7, float var8) {
|
||||||
|
super.method_17157(var1, var2, var3, var4, var5, var6, var7, var8);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
package tschipp.carryon.mixin.client;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import net.minecraft.client.model.Cuboid;
|
||||||
|
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import tschipp.carryon.render.ICarrying;
|
||||||
|
|
||||||
|
@Mixin(BipedEntityModel.class)
|
||||||
|
public class BipedModelMixin implements ICarrying {
|
||||||
|
|
||||||
|
private boolean isCarryingBlock;
|
||||||
|
private boolean isCarryingEntity;
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
public Cuboid armRight;
|
||||||
|
@Shadow
|
||||||
|
public Cuboid armLeft;
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
public boolean isSneaking;
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isCarryingBlock()
|
||||||
|
{
|
||||||
|
return isCarryingBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCarryingEntity()
|
||||||
|
{
|
||||||
|
return isCarryingEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCarryingBlock(boolean isCarrying)
|
||||||
|
{
|
||||||
|
this.isCarryingBlock = isCarrying;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCarryingEntity(boolean isCarrying)
|
||||||
|
{
|
||||||
|
this.isCarryingEntity = isCarrying;
|
||||||
|
}
|
||||||
|
|
||||||
|
//setRotationAngles
|
||||||
|
@Inject(method = "method_17087", at = @At("RETURN"))
|
||||||
|
public void onSetAngles(LivingEntity var1, float var2, float var3, float var4, float var5, float var6, float var7, CallbackInfo info)
|
||||||
|
{
|
||||||
|
if(this.isCarryingBlock())
|
||||||
|
{
|
||||||
|
armRight.pitch = -1F + (this.isSneaking ? 0f : 0.2f);
|
||||||
|
armLeft.pitch = -1F + (this.isSneaking ? 0f : 0.2f);
|
||||||
|
armRight.roll = 0f;
|
||||||
|
armLeft.roll = 0f;
|
||||||
|
armRight.yaw = 0f;
|
||||||
|
armLeft.yaw = 0f;
|
||||||
|
}
|
||||||
|
else if (this.isCarryingEntity())
|
||||||
|
{
|
||||||
|
armRight.pitch = -1.2F + (this.isSneaking ? 0f : 0.2f);
|
||||||
|
armLeft.pitch = -1.2F + (this.isSneaking ? 0f : 0.2f);
|
||||||
|
armRight.roll = -0.15f;
|
||||||
|
armLeft.roll = 0.15f;
|
||||||
|
armRight.yaw = 0f;
|
||||||
|
armLeft.yaw = 0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package tschipp.carryon.mixin.client;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.render.FirstPersonRenderer;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import tschipp.carryon.RegistryHandler;
|
||||||
|
import tschipp.carryon.render.BlockRendererLayer;
|
||||||
|
import tschipp.carryon.render.EntityRendererLayer;
|
||||||
|
|
||||||
|
@Mixin(FirstPersonRenderer.class)
|
||||||
|
public class FirstPersonMixin {
|
||||||
|
|
||||||
|
@Inject(method = "renderFirstPersonItem", at = @At("HEAD"))
|
||||||
|
public void onRenderItem(float partialTicks, CallbackInfo info)
|
||||||
|
{
|
||||||
|
PlayerEntity player = MinecraftClient.getInstance().player;
|
||||||
|
ItemStack stack = player.getMainHandStack();
|
||||||
|
|
||||||
|
if(!stack.isEmpty() && stack.getItem() == RegistryHandler.TILE_ITEM)
|
||||||
|
BlockRendererLayer.renderFirstPerson(player, stack, partialTicks);
|
||||||
|
else if(!stack.isEmpty() && stack.getItem() == RegistryHandler.ENTITY_ITEM)
|
||||||
|
EntityRendererLayer.renderFirstPerson(player, stack, partialTicks);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
package tschipp.carryon.mixin.client;
|
||||||
|
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
|
import net.minecraft.client.settings.GameOptions;
|
||||||
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
|
import net.minecraft.client.util.Keyboard;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import tschipp.carryon.CarryOn;
|
||||||
|
import tschipp.carryon.RegistryHandler;
|
||||||
|
|
||||||
|
@Mixin(Keyboard.class)
|
||||||
|
public class KeyboardMixin {
|
||||||
|
|
||||||
|
@Inject(method = "(JIIII)V", at = @At("HEAD"), cancellable = true)
|
||||||
|
public void onKeyPressed(long var1, int code1, int code2, int var5, int var6, CallbackInfo info)
|
||||||
|
{
|
||||||
|
ClientPlayerEntity player = MinecraftClient.getInstance().player;
|
||||||
|
GameOptions options = MinecraftClient.getInstance().options;
|
||||||
|
if (player != null) {
|
||||||
|
ItemStack held = player.getMainHandStack();
|
||||||
|
|
||||||
|
CarryOn.LOGGER.info(player);
|
||||||
|
CarryOn.LOGGER.info(held);
|
||||||
|
|
||||||
|
if (!held.isEmpty() && held.getItem() == RegistryHandler.TILE_ITEM || held.getItem() == RegistryHandler.ENTITY_ITEM)
|
||||||
|
{
|
||||||
|
boolean cancel = false;
|
||||||
|
if(options.keyInventory.matches(code1, code2))
|
||||||
|
cancel = true;
|
||||||
|
else if(options.keySwapHands.matches(code1, code2))
|
||||||
|
cancel = true;
|
||||||
|
else if(options.keyDrop.matches(code1, code2))
|
||||||
|
cancel = true;
|
||||||
|
else if(options.keyLoadToolbarActivator.matches(code1, code2))
|
||||||
|
cancel = true;
|
||||||
|
else if(options.keySaveToolbarActivator.matches(code1, code2))
|
||||||
|
cancel = true;
|
||||||
|
else if(options.keyPickItem.matches(code1, code2))
|
||||||
|
cancel = true;
|
||||||
|
else {
|
||||||
|
for(KeyBinding key : options.keysHotbar)
|
||||||
|
{
|
||||||
|
if(key.matches(code1, code2))
|
||||||
|
cancel = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(cancel)
|
||||||
|
info.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
46
src/main/java/tschipp/carryon/mixin/client/MouseMixin.java
Normal file
46
src/main/java/tschipp/carryon/mixin/client/MouseMixin.java
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
package tschipp.carryon.mixin.client;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
|
import net.minecraft.client.util.Mouse;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import tschipp.carryon.CarryOn;
|
||||||
|
import tschipp.carryon.RegistryHandler;
|
||||||
|
|
||||||
|
@Mixin(Mouse.class)
|
||||||
|
public class MouseMixin {
|
||||||
|
|
||||||
|
@Inject(method = "(JDD)V", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void onMouseScrolling(long var1, double var3, double var5, CallbackInfo info) {
|
||||||
|
ClientPlayerEntity player = MinecraftClient.getInstance().player;
|
||||||
|
ItemStack held = player.getMainHandStack();
|
||||||
|
|
||||||
|
CarryOn.LOGGER.info(player);
|
||||||
|
CarryOn.LOGGER.info(held);
|
||||||
|
|
||||||
|
if (!held.isEmpty() && held.getItem() == RegistryHandler.TILE_ITEM
|
||||||
|
|| held.getItem() == RegistryHandler.ENTITY_ITEM)
|
||||||
|
info.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "(JIII)V", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void onMouseButtonPress(long var1, int code, int var4, int var5, CallbackInfo info) {
|
||||||
|
ClientPlayerEntity player = MinecraftClient.getInstance().player;
|
||||||
|
if (player != null) {
|
||||||
|
ItemStack held = player.getMainHandStack();
|
||||||
|
|
||||||
|
CarryOn.LOGGER.info(player);
|
||||||
|
CarryOn.LOGGER.info(held);
|
||||||
|
|
||||||
|
if (!held.isEmpty() && held.getItem() == RegistryHandler.TILE_ITEM
|
||||||
|
|| held.getItem() == RegistryHandler.ENTITY_ITEM)
|
||||||
|
if (MinecraftClient.getInstance().options.keyPickItem.matches(code))
|
||||||
|
info.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
package tschipp.carryon.mixin.client;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
|
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||||
|
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
||||||
|
import net.minecraft.client.render.entity.PlayerEntityRenderer;
|
||||||
|
import net.minecraft.client.render.entity.model.PlayerEntityModel;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import tschipp.carryon.RegistryHandler;
|
||||||
|
import tschipp.carryon.render.BlockRendererLayer;
|
||||||
|
import tschipp.carryon.render.EntityRendererLayer;
|
||||||
|
import tschipp.carryon.render.ICarrying;
|
||||||
|
|
||||||
|
@Mixin(PlayerEntityRenderer.class)
|
||||||
|
public abstract class PlayerRendererMixin extends LivingEntityRenderer<AbstractClientPlayerEntity, PlayerEntityModel<AbstractClientPlayerEntity>>{
|
||||||
|
|
||||||
|
private PlayerRendererMixin(EntityRenderDispatcher var1, PlayerEntityModel<AbstractClientPlayerEntity> var2, float var3) {
|
||||||
|
super(var1, var2, var3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "<init>*", at = @At("RETURN"))
|
||||||
|
public void onConstructed(EntityRenderDispatcher renderDispatcher, boolean slim, CallbackInfo info)
|
||||||
|
{
|
||||||
|
this.addLayer(new BlockRendererLayer(this));
|
||||||
|
this.addLayer(new EntityRendererLayer(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "method_4218", at = @At("RETURN"))
|
||||||
|
private void onPreRender(AbstractClientPlayerEntity player, CallbackInfo info)
|
||||||
|
{
|
||||||
|
ItemStack stack = player.getMainHandStack();
|
||||||
|
ICarrying model = (ICarrying)this.method_4038();
|
||||||
|
|
||||||
|
if (!stack.isEmpty() && stack.getItem() == RegistryHandler.TILE_ITEM)
|
||||||
|
model.setCarryingBlock(true);
|
||||||
|
else
|
||||||
|
model.setCarryingBlock(false);
|
||||||
|
|
||||||
|
if (!stack.isEmpty() && stack.getItem() == RegistryHandler.ENTITY_ITEM)
|
||||||
|
model.setCarryingEntity(true);
|
||||||
|
else
|
||||||
|
model.setCarryingEntity(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
117
src/main/java/tschipp/carryon/mixin/common/BlockStateMixin.java
Normal file
117
src/main/java/tschipp/carryon/mixin/common/BlockStateMixin.java
Normal file
|
|
@ -0,0 +1,117 @@
|
||||||
|
package tschipp.carryon.mixin.common;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import tschipp.carryon.PickupHandler;
|
||||||
|
import tschipp.carryon.RegistryHandler;
|
||||||
|
import tschipp.carryon.items.ItemTile;
|
||||||
|
|
||||||
|
@Mixin(BlockState.class)
|
||||||
|
public class BlockStateMixin {
|
||||||
|
|
||||||
|
|
||||||
|
//Detects right click detection
|
||||||
|
@Inject(method = "activate", at = @At("HEAD"), cancellable = true)
|
||||||
|
public void onBlockActivated(World world, BlockPos pos, PlayerEntity player, Hand hand, Direction Direction, float hitx, float hity, float hitz, CallbackInfoReturnable<Boolean> info) {
|
||||||
|
ItemStack main = player.getMainHandStack();
|
||||||
|
ItemStack off = player.getOffHandStack();
|
||||||
|
|
||||||
|
if(main.isEmpty() && off.isEmpty() && player.isSneaking())
|
||||||
|
{
|
||||||
|
info.cancel();
|
||||||
|
info.setReturnValue(false);
|
||||||
|
|
||||||
|
BlockState state = world.getBlockState(pos);
|
||||||
|
ItemStack stack = new ItemStack(RegistryHandler.TILE_ITEM);
|
||||||
|
|
||||||
|
BlockEntity te = world.getBlockEntity(pos);
|
||||||
|
if (PickupHandler.canPlayerPickUpBlock(player, te, world, pos))
|
||||||
|
{
|
||||||
|
// player.open.closeScreen();
|
||||||
|
|
||||||
|
if (ItemTile.storeTileData(te, world, pos, state, stack))
|
||||||
|
{
|
||||||
|
|
||||||
|
// BlockState statee = world.getBlockState(pos);
|
||||||
|
CompoundTag tag = new CompoundTag();
|
||||||
|
tag = world.getBlockEntity(pos) != null ? world.getBlockEntity(pos).toTag(tag) : new CompoundTag();
|
||||||
|
// CarryOnOverride override = ScriptChecker.inspectBlock(state, world, pos, tag);
|
||||||
|
// int overrideHash = 0;
|
||||||
|
// if (override != null)
|
||||||
|
// overrideHash = override.hashCode();
|
||||||
|
|
||||||
|
// positions.put(pos, 0);
|
||||||
|
|
||||||
|
// boolean success = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// sendPacket(player, player.inventory.currentItem, overrideHash);
|
||||||
|
|
||||||
|
world.removeBlockEntity(pos);
|
||||||
|
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 3);
|
||||||
|
player.setStackInHand(Hand.MAIN, stack);
|
||||||
|
// event.setUseBlock(Result.DENY);
|
||||||
|
// event.setUseItem(Result.DENY);
|
||||||
|
// event.setCanceled(true);
|
||||||
|
// success = true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// sendPacket(player, player.inventory.currentItem, overrideHash);
|
||||||
|
// emptyBlockEntity(te);
|
||||||
|
// world.setBlockToAir(pos);
|
||||||
|
// player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
||||||
|
// event.setUseBlock(Result.DENY);
|
||||||
|
// event.setUseItem(Result.DENY);
|
||||||
|
// event.setCanceled(true);
|
||||||
|
// success = true;
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// sendPacket(player, 9, 0);
|
||||||
|
// world.setBlockState(pos, statee);
|
||||||
|
// if (!tag.hasNoTags())
|
||||||
|
// BlockEntity.create(world, tag);
|
||||||
|
|
||||||
|
// player.sendMessage(new TextComponentString(TextFormatting.RED + "Error detected. Cannot pick up block."));
|
||||||
|
// TextComponentString s = new TextComponentString(TextFormatting.GOLD + "here");
|
||||||
|
// s.getStyle().setClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/Tschipp/CarryOn/issues"));
|
||||||
|
// player.sendMessage(new TextComponentString(TextFormatting.RED + "Please report this error ").appendSibling(s));
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (success && override != null)
|
||||||
|
// {
|
||||||
|
// String command = override.getCommandInit();
|
||||||
|
// if (command != null)
|
||||||
|
// player.getServer().getCommandManager().executeCommand(player.getServer(), "/execute " + player.getGameProfile().getName() + " ~ ~ ~ " + command);
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(!main.isEmpty() && main.getItem() == RegistryHandler.TILE_ITEM || main.getItem() == RegistryHandler.ENTITY_ITEM)
|
||||||
|
{
|
||||||
|
info.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
72
src/main/java/tschipp/carryon/mixin/common/EntityMixin.java
Normal file
72
src/main/java/tschipp/carryon/mixin/common/EntityMixin.java
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
package tschipp.carryon.mixin.common;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.passive.AnimalEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import tschipp.carryon.PickupHandler;
|
||||||
|
import tschipp.carryon.RegistryHandler;
|
||||||
|
import tschipp.carryon.items.ItemEntity;
|
||||||
|
|
||||||
|
@Mixin(Entity.class)
|
||||||
|
public abstract class EntityMixin {
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
public boolean field_6037;
|
||||||
|
|
||||||
|
@Inject(method = "interact", at = @At("HEAD"), cancellable = true)
|
||||||
|
public void onInteract(PlayerEntity player, Hand hand, CallbackInfoReturnable<Boolean> info) {
|
||||||
|
|
||||||
|
ItemStack main = player.getMainHandStack();
|
||||||
|
ItemStack off = player.getOffHandStack();
|
||||||
|
World world = player.world;
|
||||||
|
Entity entity = ((Entity) (Object) this);
|
||||||
|
|
||||||
|
if (main.isEmpty() && off.isEmpty() && player.isSneaking()) {
|
||||||
|
ItemStack stack = new ItemStack(RegistryHandler.ENTITY_ITEM);
|
||||||
|
|
||||||
|
if (!this.field_6037) {
|
||||||
|
if (entity instanceof AnimalEntity)
|
||||||
|
((AnimalEntity) entity).detachLeash(true, true);
|
||||||
|
|
||||||
|
if (PickupHandler.canPlayerPickUpEntity(player, entity)) {
|
||||||
|
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++) {
|
||||||
|
// handler.extractItem(i, 64, false);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// CarryOnOverride override = ScriptChecker.inspectEntity(entity);
|
||||||
|
// int overrideHash = 0;
|
||||||
|
// if (override != null)
|
||||||
|
// overrideHash = override.hashCode();
|
||||||
|
|
||||||
|
// ItemEvents.sendPacket(player, player.inventory.currentItem, overrideHash);
|
||||||
|
|
||||||
|
// if (entity instanceof LivingEntity)
|
||||||
|
// ((LivingEntity) entity).setHealth(0);
|
||||||
|
|
||||||
|
entity.invalidate();
|
||||||
|
player.setStackInHand(Hand.MAIN, stack);
|
||||||
|
info.cancel();
|
||||||
|
info.setReturnValue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
42
src/main/java/tschipp/carryon/mixin/common/PlayerMixin.java
Normal file
42
src/main/java/tschipp/carryon/mixin/common/PlayerMixin.java
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
package tschipp.carryon.mixin.common;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.data.DataTracker;
|
||||||
|
import net.minecraft.entity.data.TrackedData;
|
||||||
|
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import tschipp.carryon.interfaces.ICarryOnData;
|
||||||
|
|
||||||
|
@Mixin(PlayerEntity.class)
|
||||||
|
public abstract class PlayerMixin extends LivingEntity implements ICarryOnData {
|
||||||
|
|
||||||
|
private PlayerMixin(World var1) {
|
||||||
|
super(EntityType.PLAYER, var1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final TrackedData<CompoundTag> CARRYON_DATA = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND);;
|
||||||
|
|
||||||
|
@Inject(method = "initDataTracker", at = @At("RETURN"))
|
||||||
|
public void onInitDataTracker(CallbackInfo info) {
|
||||||
|
this.dataTracker.startTracking(CARRYON_DATA, new CompoundTag());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag getCarryOnData() {
|
||||||
|
return (CompoundTag)this.dataTracker.get(CARRYON_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCarryOnData(CompoundTag tag) {
|
||||||
|
this.dataTracker.set(CARRYON_DATA, tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
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;
|
|
||||||
|
|
||||||
public class CarrySlotPacket implements IMessage
|
|
||||||
{
|
|
||||||
public int slot;
|
|
||||||
public int carryOverride = 0;
|
|
||||||
public int entityid;
|
|
||||||
|
|
||||||
public CarrySlotPacket()
|
|
||||||
{
|
|
||||||
this.slot = 9;
|
|
||||||
this.entityid = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CarrySlotPacket(int slot, int entityid)
|
|
||||||
{
|
|
||||||
this.slot = slot;
|
|
||||||
this.entityid = entityid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CarrySlotPacket(int slot, int entityid, int carryOverride)
|
|
||||||
{
|
|
||||||
this.slot = slot;
|
|
||||||
this.carryOverride = carryOverride;
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -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 +0,0 @@
|
||||||
package tschipp.carryon.network.client;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
|
||||||
|
|
||||||
public class ScriptReloadPacket implements IMessage
|
|
||||||
{
|
|
||||||
|
|
||||||
public ScriptReloadPacket()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes(ByteBuf buf)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void toBytes(ByteBuf buf)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -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 +0,0 @@
|
||||||
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;
|
|
||||||
|
|
||||||
public class SyncKeybindPacket implements IMessage
|
|
||||||
{
|
|
||||||
|
|
||||||
private int p;
|
|
||||||
public boolean pressed;
|
|
||||||
|
|
||||||
public SyncKeybindPacket()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public SyncKeybindPacket(boolean pressed)
|
|
||||||
{
|
|
||||||
this.p = pressed ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -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().playerEntity.world;
|
|
||||||
|
|
||||||
mainThread.addScheduledTask(new Runnable()
|
|
||||||
{
|
|
||||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
CarryOnKeybinds.setKeyPressed(player, message.pressed);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
95
src/main/java/tschipp/carryon/render/BlockRendererLayer.java
Normal file
95
src/main/java/tschipp/carryon/render/BlockRendererLayer.java
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
package tschipp.carryon.render;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.GLX;
|
||||||
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
|
||||||
|
import net.minecraft.class_3883;
|
||||||
|
import net.minecraft.class_3887;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
|
import net.minecraft.client.render.entity.model.PlayerEntityModel;
|
||||||
|
import net.minecraft.client.render.model.json.ModelTransformations.Type;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import tschipp.carryon.RegistryHandler;
|
||||||
|
import tschipp.carryon.items.ItemTile;
|
||||||
|
|
||||||
|
public class BlockRendererLayer extends class_3887<AbstractClientPlayerEntity, PlayerEntityModel<AbstractClientPlayerEntity>> {
|
||||||
|
|
||||||
|
private static MinecraftClient client = MinecraftClient.getInstance();
|
||||||
|
|
||||||
|
public BlockRendererLayer(class_3883<AbstractClientPlayerEntity, PlayerEntityModel<AbstractClientPlayerEntity>> var1) {
|
||||||
|
super(var1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void method_4199(AbstractClientPlayerEntity player, float var2, float var3, float partialTicks, float var5,
|
||||||
|
float var6, float var7, float var8) {
|
||||||
|
ItemStack stack = player.getMainHandStack();
|
||||||
|
if (!stack.isEmpty() && stack.getItem() == RegistryHandler.TILE_ITEM) {
|
||||||
|
ItemStack renderStack = ItemTile.getItemStack(stack);
|
||||||
|
// BakedModel model =
|
||||||
|
// client.getItemRenderer().getModelMap().getModel(renderStack);
|
||||||
|
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
GlStateManager.rotated(180, 1, 0, 0);
|
||||||
|
GlStateManager.rotated(180, 0, 1, 0);
|
||||||
|
GlStateManager.scaled(0.6, 0.6, 0.6);
|
||||||
|
GlStateManager.translated(0, -0.75, -0.65);
|
||||||
|
|
||||||
|
if(player.isSneaking())
|
||||||
|
{
|
||||||
|
GlStateManager.translated(0, -0.15, -0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isChest(ItemTile.getBlock(stack)))
|
||||||
|
{
|
||||||
|
GlStateManager.rotated(180, 0, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
client.getItemRenderer().renderItemWithTransformation(renderStack, Type.ORIGIN);
|
||||||
|
GlStateManager.popMatrix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean method_4200() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isChest(Block block)
|
||||||
|
{
|
||||||
|
return block == Blocks.CHEST || block == Blocks.ENDER_CHEST || block == Blocks.TRAPPED_CHEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void renderFirstPerson(LivingEntity entity, ItemStack stack, float partialTicks)
|
||||||
|
{
|
||||||
|
ItemStack renderStack = ItemTile.getItemStack(stack);
|
||||||
|
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
GlStateManager.scaled(2.5, 2.5, 2.5);
|
||||||
|
GlStateManager.translated(0, -0.6, -1);
|
||||||
|
GlStateManager.enableBlend();
|
||||||
|
|
||||||
|
if(isChest(ItemTile.getBlock(stack)))
|
||||||
|
{
|
||||||
|
GlStateManager.rotated(180, 0, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
setLightCoords();
|
||||||
|
client.getItemRenderer().renderItemWithTransformation(renderStack, Type.ORIGIN);
|
||||||
|
GlStateManager.popMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setLightCoords() {
|
||||||
|
AbstractClientPlayerEntity player = client.player;
|
||||||
|
int var2 = client.world.getLightmapIndex(new BlockPos(player.x, player.y + (double)player.getEyeHeight(), player.z), 0);
|
||||||
|
float var3 = (float)(var2 & '\uffff');
|
||||||
|
float var4 = (float)(var2 >> 16);
|
||||||
|
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, var3, var4);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
123
src/main/java/tschipp/carryon/render/EntityRendererLayer.java
Normal file
123
src/main/java/tschipp/carryon/render/EntityRendererLayer.java
Normal file
|
|
@ -0,0 +1,123 @@
|
||||||
|
package tschipp.carryon.render;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.GLX;
|
||||||
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
|
||||||
|
import net.minecraft.class_3883;
|
||||||
|
import net.minecraft.class_3887;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
|
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||||
|
import net.minecraft.client.render.entity.model.PlayerEntityModel;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import tschipp.carryon.RegistryHandler;
|
||||||
|
import tschipp.carryon.items.ItemEntity;
|
||||||
|
|
||||||
|
public class EntityRendererLayer extends class_3887<AbstractClientPlayerEntity, PlayerEntityModel<AbstractClientPlayerEntity>> {
|
||||||
|
|
||||||
|
private static MinecraftClient client = MinecraftClient.getInstance();
|
||||||
|
|
||||||
|
public EntityRendererLayer(class_3883<AbstractClientPlayerEntity, PlayerEntityModel<AbstractClientPlayerEntity>> var1) {
|
||||||
|
super(var1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void method_4199(AbstractClientPlayerEntity player, float var2, float var3, float partialTicks, float var5,
|
||||||
|
float var6, float var7, float var8) {
|
||||||
|
ItemStack stack = player.getMainHandStack();
|
||||||
|
if (!stack.isEmpty() && stack.getItem() == RegistryHandler.ENTITY_ITEM) {
|
||||||
|
Entity renderEntity = ItemEntity.getEntity(stack, player.world);
|
||||||
|
|
||||||
|
double c0 = player.prevX + (player.x - player.prevX) * partialTicks;
|
||||||
|
double c1 = player.prevY + (player.y - player.prevY) * partialTicks;
|
||||||
|
double c2 = player.prevZ + (player.z - player.prevZ) * partialTicks;
|
||||||
|
|
||||||
|
renderEntity.setPosition(c0, c1, c2);
|
||||||
|
|
||||||
|
EntityRenderDispatcher renderer = client.getEntityRenderManager();
|
||||||
|
|
||||||
|
renderEntity.yaw = 0f;
|
||||||
|
renderEntity.pitch = 0f;
|
||||||
|
float height = renderEntity.height;
|
||||||
|
float width = renderEntity.width;
|
||||||
|
float multiplier = height * width;
|
||||||
|
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
GlStateManager.scaled(1, -1, 1);
|
||||||
|
GlStateManager.scaled((10 - multiplier) * 0.08, (10 - multiplier) * 0.08, (10 - multiplier) * 0.08);
|
||||||
|
GlStateManager.rotated(180, 0, 1, 0);
|
||||||
|
GlStateManager.translated(0.0, height / 2 + -(height / 2) - 1.2, width - 0.1 < 0.7 ? width - 0.1 + (0.7 - (width - 0.1)) : width - 0.1);
|
||||||
|
GlStateManager.color3f(1f, 1f, 1f);
|
||||||
|
GlStateManager.enableAlphaTest();
|
||||||
|
|
||||||
|
if (player.isSneaking()) {
|
||||||
|
GlStateManager.translated(0, -0.1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderer.method_3948(false);
|
||||||
|
renderer.method_3954(renderEntity, 0, 0, 0, partialTicks, 0, true);
|
||||||
|
renderer.method_3948(true);
|
||||||
|
|
||||||
|
GlStateManager.scaled(1, 1, 1);
|
||||||
|
GlStateManager.popMatrix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean method_4200() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isChest(Block block) {
|
||||||
|
return block == Blocks.CHEST || block == Blocks.ENDER_CHEST || block == Blocks.TRAPPED_CHEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void renderFirstPerson(LivingEntity player, ItemStack stack, float partialTicks)
|
||||||
|
{
|
||||||
|
if (!stack.isEmpty() && stack.getItem() == RegistryHandler.ENTITY_ITEM) {
|
||||||
|
Entity renderEntity = ItemEntity.getEntity(stack, player.world);
|
||||||
|
|
||||||
|
double c0 = player.prevX + (player.x - player.prevX) * partialTicks;
|
||||||
|
double c1 = player.prevY + (player.y - player.prevY) * partialTicks;
|
||||||
|
double c2 = player.prevZ + (player.z - player.prevZ) * partialTicks;
|
||||||
|
|
||||||
|
renderEntity.setPosition(c0, c1, c2);
|
||||||
|
|
||||||
|
EntityRenderDispatcher renderer = client.getEntityRenderManager();
|
||||||
|
|
||||||
|
renderEntity.yaw = 0f;
|
||||||
|
renderEntity.pitch = 0f;
|
||||||
|
float height = renderEntity.height;
|
||||||
|
float width = renderEntity.width;
|
||||||
|
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
GlStateManager.scaled(.8, .8, .8);
|
||||||
|
GlStateManager.rotated(180, 0, 1, 0);
|
||||||
|
GlStateManager.translated(0.0, -height - .1, width + 0.1);
|
||||||
|
GlStateManager.enableAlphaTest();
|
||||||
|
|
||||||
|
setLightCoords();
|
||||||
|
renderer.method_3948(false);
|
||||||
|
renderer.method_3954(renderEntity, 0, 0, 0, partialTicks, 0, true);
|
||||||
|
renderer.method_3948(true);
|
||||||
|
|
||||||
|
GlStateManager.disableAlphaTest();
|
||||||
|
GlStateManager.scaled(1, 1, 1);
|
||||||
|
GlStateManager.popMatrix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setLightCoords() {
|
||||||
|
AbstractClientPlayerEntity player = client.player;
|
||||||
|
int var2 = client.world.getLightmapIndex(new BlockPos(player.x, player.y + (double)player.getEyeHeight(), player.z), 0);
|
||||||
|
float var3 = (float)(var2 & '\uffff');
|
||||||
|
float var4 = (float)(var2 >> 16);
|
||||||
|
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, var3, var4);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
11
src/main/java/tschipp/carryon/render/ICarrying.java
Normal file
11
src/main/java/tschipp/carryon/render/ICarrying.java
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
package tschipp.carryon.render;
|
||||||
|
|
||||||
|
public interface ICarrying {
|
||||||
|
|
||||||
|
public boolean isCarryingBlock();
|
||||||
|
public boolean isCarryingEntity();
|
||||||
|
|
||||||
|
public void setCarryingBlock(boolean isCarrying);
|
||||||
|
public void setCarryingEntity(boolean isCarrying);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -41,6 +41,11 @@ public class CarryOnOverride
|
||||||
private boolean renderLeftArm = true;
|
private boolean renderLeftArm = true;
|
||||||
private boolean renderRightArm = true;
|
private boolean renderRightArm = true;
|
||||||
|
|
||||||
|
//EFFECTS
|
||||||
|
private String commandInit;
|
||||||
|
private String commandLoop;
|
||||||
|
private String commandPlace;
|
||||||
|
|
||||||
private boolean isBlock;
|
private boolean isBlock;
|
||||||
private boolean isEntity;
|
private boolean isEntity;
|
||||||
private final String path;
|
private final String path;
|
||||||
|
|
@ -51,6 +56,28 @@ public class CarryOnOverride
|
||||||
this.path = path;
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getCommandInit()
|
||||||
|
{
|
||||||
|
return commandInit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommandInit(String commandInit)
|
||||||
|
{
|
||||||
|
this.commandInit = commandInit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCommandLoop()
|
||||||
|
{
|
||||||
|
return commandLoop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommandLoop(String commandLoop)
|
||||||
|
{
|
||||||
|
this.commandLoop = commandLoop;
|
||||||
|
}
|
||||||
|
|
||||||
public String getConditionEffects()
|
public String getConditionEffects()
|
||||||
{
|
{
|
||||||
return conditionEffects;
|
return conditionEffects;
|
||||||
|
|
@ -115,7 +142,7 @@ public class CarryOnOverride
|
||||||
{
|
{
|
||||||
return "Code: " + this.hashCode();
|
return "Code: " + this.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
|
|
@ -126,6 +153,27 @@ public class CarryOnOverride
|
||||||
if (getClass() != obj.getClass())
|
if (getClass() != obj.getClass())
|
||||||
return false;
|
return false;
|
||||||
CarryOnOverride other = (CarryOnOverride) obj;
|
CarryOnOverride other = (CarryOnOverride) obj;
|
||||||
|
if (commandInit == null)
|
||||||
|
{
|
||||||
|
if (other.commandInit != null)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (!commandInit.equals(other.commandInit))
|
||||||
|
return false;
|
||||||
|
if (commandLoop == null)
|
||||||
|
{
|
||||||
|
if (other.commandLoop != null)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (!commandLoop.equals(other.commandLoop))
|
||||||
|
return false;
|
||||||
|
if (commandPlace == null)
|
||||||
|
{
|
||||||
|
if (other.commandPlace != null)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (!commandPlace.equals(other.commandPlace))
|
||||||
|
return false;
|
||||||
if (conditionAchievement == null)
|
if (conditionAchievement == null)
|
||||||
{
|
{
|
||||||
if (other.conditionAchievement != null)
|
if (other.conditionAchievement != null)
|
||||||
|
|
@ -133,6 +181,13 @@ public class CarryOnOverride
|
||||||
}
|
}
|
||||||
else if (!conditionAchievement.equals(other.conditionAchievement))
|
else if (!conditionAchievement.equals(other.conditionAchievement))
|
||||||
return false;
|
return false;
|
||||||
|
if (conditionEffects == null)
|
||||||
|
{
|
||||||
|
if (other.conditionEffects != null)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (!conditionEffects.equals(other.conditionEffects))
|
||||||
|
return false;
|
||||||
if (conditionGamemode == null)
|
if (conditionGamemode == null)
|
||||||
{
|
{
|
||||||
if (other.conditionGamemode != null)
|
if (other.conditionGamemode != null)
|
||||||
|
|
@ -172,6 +227,15 @@ public class CarryOnOverride
|
||||||
return false;
|
return false;
|
||||||
if (isEntity != other.isEntity)
|
if (isEntity != other.isEntity)
|
||||||
return false;
|
return false;
|
||||||
|
if (path == null)
|
||||||
|
{
|
||||||
|
if (other.path != null)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (!path.equals(other.path))
|
||||||
|
return false;
|
||||||
|
if (renderLeftArm != other.renderLeftArm)
|
||||||
|
return false;
|
||||||
if (renderMeta != other.renderMeta)
|
if (renderMeta != other.renderMeta)
|
||||||
return false;
|
return false;
|
||||||
if (renderNBT == null)
|
if (renderNBT == null)
|
||||||
|
|
@ -195,6 +259,8 @@ public class CarryOnOverride
|
||||||
}
|
}
|
||||||
else if (!renderNameEntity.equals(other.renderNameEntity))
|
else if (!renderNameEntity.equals(other.renderNameEntity))
|
||||||
return false;
|
return false;
|
||||||
|
if (renderRightArm != other.renderRightArm)
|
||||||
|
return false;
|
||||||
if (renderRotation == null)
|
if (renderRotation == null)
|
||||||
{
|
{
|
||||||
if (other.renderRotation != null)
|
if (other.renderRotation != null)
|
||||||
|
|
@ -310,6 +376,8 @@ public class CarryOnOverride
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isBlock()
|
public boolean isBlock()
|
||||||
{
|
{
|
||||||
return isBlock;
|
return isBlock;
|
||||||
|
|
@ -570,4 +638,18 @@ public class CarryOnOverride
|
||||||
this.renderScale = renderScale;
|
this.renderScale = renderScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getCommandPlace()
|
||||||
|
{
|
||||||
|
return commandPlace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommandPlace(String commandPlace)
|
||||||
|
{
|
||||||
|
this.commandPlace = commandPlace;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
package tschipp.carryon.common.scripting;
|
package tschipp.carryon.common.scripting;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import net.darkhax.gamestages.capabilities.PlayerDataHandler;
|
import net.minecraft.advancements.Advancement;
|
||||||
|
import net.minecraft.advancements.AdvancementManager;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
|
@ -12,10 +15,14 @@ import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.WorldServer;
|
||||||
import net.minecraftforge.fml.common.Loader;
|
import net.minecraftforge.fml.common.Loader;
|
||||||
|
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||||
import tschipp.carryon.common.config.CarryOnConfig;
|
import tschipp.carryon.common.config.CarryOnConfig;
|
||||||
|
import tschipp.carryon.common.handler.ListHandler;
|
||||||
import tschipp.carryon.common.helper.ScriptParseHelper;
|
import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||||
|
|
||||||
public class ScriptChecker
|
public class ScriptChecker
|
||||||
|
|
@ -33,12 +40,17 @@ public class ScriptChecker
|
||||||
float resistance = block.getExplosionResistance(null);
|
float resistance = block.getExplosionResistance(null);
|
||||||
NBTTagCompound nbt = tag;
|
NBTTagCompound nbt = tag;
|
||||||
|
|
||||||
for (CarryOnOverride override : ScriptReader.OVERRIDES.values())
|
boolean isAllowed = CarryOnConfig.settings.useWhitelistBlocks ? ListHandler.isAllowed(block) : !ListHandler.isForbidden(block);
|
||||||
|
|
||||||
|
if (isAllowed)
|
||||||
{
|
{
|
||||||
if (override.isBlock())
|
for (CarryOnOverride override : ScriptReader.OVERRIDES.values())
|
||||||
{
|
{
|
||||||
if (matchesAll(override, block, meta, material, hardness, resistance, nbt))
|
if (override.isBlock())
|
||||||
return override;
|
{
|
||||||
|
if (matchesAll(override, block, meta, material, hardness, resistance, nbt))
|
||||||
|
return override;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,12 +70,17 @@ public class ScriptChecker
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
entity.writeToNBT(tag);
|
entity.writeToNBT(tag);
|
||||||
|
|
||||||
for (CarryOnOverride override : ScriptReader.OVERRIDES.values())
|
boolean isAllowed = CarryOnConfig.settings.useWhitelistEntities ? ListHandler.isAllowed(entity) : !ListHandler.isForbidden(entity);
|
||||||
|
|
||||||
|
if (isAllowed)
|
||||||
{
|
{
|
||||||
if (override.isEntity())
|
for (CarryOnOverride override : ScriptReader.OVERRIDES.values())
|
||||||
{
|
{
|
||||||
if (matchesAll(override, name, height, width, health, tag))
|
if (override.isEntity())
|
||||||
return override;
|
{
|
||||||
|
if (matchesAll(override, name, height, width, health, tag))
|
||||||
|
return override;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,14 +112,56 @@ public class ScriptChecker
|
||||||
|
|
||||||
public static boolean fulfillsConditions(CarryOnOverride override, EntityPlayer player)
|
public static boolean fulfillsConditions(CarryOnOverride override, EntityPlayer player)
|
||||||
{
|
{
|
||||||
boolean achievement = ScriptParseHelper.getAchievementFromString(override.getConditionAchievement()) == null ? true : player.hasAchievement(ScriptParseHelper.getAchievementFromString(override.getConditionAchievement()));
|
AdvancementManager manager = ((WorldServer) ((EntityPlayerMP) player).world).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 gamemode = ScriptParseHelper.matches(((EntityPlayerMP) player).interactionManager.getGameType().getID(), override.getConditionGamemode());
|
||||||
boolean gamestage = Loader.isModLoaded("gamestages") ? (override.getConditionGamestage() != null ? PlayerDataHandler.getStageData(player).hasUnlockedStage(override.getConditionGamestage()) : true) : true;
|
boolean gamestage = true;
|
||||||
|
if (Loader.isModLoaded("gamestages"))
|
||||||
|
{
|
||||||
|
if (override.getConditionGamestage() != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
Object stageData = getPlayerData.invoke(null, player);
|
||||||
|
String condition = override.getConditionGamestage();
|
||||||
|
gamestage = (boolean) hasStage.invoke(stageData, condition);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
Object stageData = getStageData.invoke(null, player);
|
||||||
|
String condition = override.getConditionGamestage();
|
||||||
|
gamestage = (boolean) hasUnlockedStage.invoke(stageData, condition);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean position = ScriptParseHelper.matches(player.getPosition(), override.getConditionPosition());
|
boolean position = ScriptParseHelper.matches(player.getPosition(), override.getConditionPosition());
|
||||||
boolean xp = ScriptParseHelper.matches(player.experienceLevel, override.getConditionXp());
|
boolean xp = ScriptParseHelper.matches(player.experienceLevel, override.getConditionXp());
|
||||||
boolean scoreboard = ScriptParseHelper.matchesScore(player, override.getConditionScoreboard());
|
boolean scoreboard = ScriptParseHelper.matchesScore(player, override.getConditionScoreboard());
|
||||||
boolean effects = ScriptParseHelper.hasEffects(player, override.getConditionEffects());
|
boolean effects = ScriptParseHelper.hasEffects(player, override.getConditionEffects());
|
||||||
|
|
||||||
return (achievement && gamemode && gamestage && position && xp && scoreboard && effects);
|
return (achievement && gamemode && gamestage && position && xp && scoreboard && effects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,13 +173,13 @@ public class ScriptChecker
|
||||||
if (tag != null && tag.hasKey("overrideKey"))
|
if (tag != null && tag.hasKey("overrideKey"))
|
||||||
{
|
{
|
||||||
int key = tag.getInteger("overrideKey");
|
int key = tag.getInteger("overrideKey");
|
||||||
|
|
||||||
return ScriptReader.OVERRIDES.get(key);
|
return ScriptReader.OVERRIDES.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setCarryOnOverride(EntityPlayer player, int i)
|
public static void setCarryOnOverride(EntityPlayer player, int i)
|
||||||
{
|
{
|
||||||
NBTTagCompound tag = player.getEntityData();
|
NBTTagCompound tag = player.getEntityData();
|
||||||
|
|
@ -128,5 +187,5 @@ public class ScriptChecker
|
||||||
if (tag != null)
|
if (tag != null)
|
||||||
tag.setInteger("overrideKey", i);
|
tag.setInteger("overrideKey", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -29,6 +29,7 @@ public class ScriptReader
|
||||||
public static void preInit(FMLPreInitializationEvent event)
|
public static void preInit(FMLPreInitializationEvent event)
|
||||||
{
|
{
|
||||||
CarryOn.CONFIGURATION_FILE = new File(event.getModConfigurationDirectory(), "carryon-scripts/");
|
CarryOn.CONFIGURATION_FILE = new File(event.getModConfigurationDirectory(), "carryon-scripts/");
|
||||||
|
|
||||||
if (!CarryOn.CONFIGURATION_FILE.exists())
|
if (!CarryOn.CONFIGURATION_FILE.exists())
|
||||||
CarryOn.CONFIGURATION_FILE.mkdir();
|
CarryOn.CONFIGURATION_FILE.mkdir();
|
||||||
|
|
||||||
|
|
@ -56,8 +57,9 @@ public class ScriptReader
|
||||||
JsonObject object = (JsonObject) json.get("object");
|
JsonObject object = (JsonObject) json.get("object");
|
||||||
JsonObject conditions = (JsonObject) json.get("conditions");
|
JsonObject conditions = (JsonObject) json.get("conditions");
|
||||||
JsonObject render = (JsonObject) json.get("render");
|
JsonObject render = (JsonObject) json.get("render");
|
||||||
|
JsonObject effects = (JsonObject) json.get("effects");
|
||||||
|
|
||||||
if ((object != null && conditions != null) || (object != null && render != null))
|
if ((object != null && conditions != null) || (object != null && render != null) || (object != null && effects != null))
|
||||||
{
|
{
|
||||||
JsonObject block = (JsonObject) object.get("block");
|
JsonObject block = (JsonObject) object.get("block");
|
||||||
JsonObject entity = (JsonObject) object.get("entity");
|
JsonObject entity = (JsonObject) object.get("entity");
|
||||||
|
|
@ -116,12 +118,12 @@ public class ScriptReader
|
||||||
if (conditions != null)
|
if (conditions != null)
|
||||||
{
|
{
|
||||||
JsonElement gamestage = conditions.get("gamestage");
|
JsonElement gamestage = conditions.get("gamestage");
|
||||||
JsonElement achievement = conditions.get("achievement");
|
JsonElement achievement = conditions.get("advancement");
|
||||||
JsonElement xp = conditions.get("xp");
|
JsonElement xp = conditions.get("xp");
|
||||||
JsonElement gamemode = conditions.get("gamemode");
|
JsonElement gamemode = conditions.get("gamemode");
|
||||||
JsonElement scoreboard = conditions.get("scoreboard");
|
JsonElement scoreboard = conditions.get("scoreboard");
|
||||||
JsonElement position = conditions.get("position");
|
JsonElement position = conditions.get("position");
|
||||||
JsonElement effects = conditions.get("effects");
|
JsonElement potionEffects = conditions.get("effects");
|
||||||
|
|
||||||
if(gamestage != null)
|
if(gamestage != null)
|
||||||
override.setConditionGamestage(gamestage.getAsString());
|
override.setConditionGamestage(gamestage.getAsString());
|
||||||
|
|
@ -135,8 +137,8 @@ public class ScriptReader
|
||||||
override.setConditionScoreboard(scoreboard.getAsString());
|
override.setConditionScoreboard(scoreboard.getAsString());
|
||||||
if(position != null)
|
if(position != null)
|
||||||
override.setConditionPosition(position.getAsString());
|
override.setConditionPosition(position.getAsString());
|
||||||
if(effects != null)
|
if(potionEffects != null)
|
||||||
override.setConditionEffects(effects.getAsString());
|
override.setConditionEffects(potionEffects.getAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (render != null)
|
if (render != null)
|
||||||
|
|
@ -177,8 +179,21 @@ public class ScriptReader
|
||||||
override.setRenderRightArm(renderRightArm.getAsBoolean());
|
override.setRenderRightArm(renderRightArm.getAsBoolean());
|
||||||
}
|
}
|
||||||
|
|
||||||
OVERRIDES.put(override.hashCode(), override);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 170 KiB |
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "carryon:item/tile"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "builtin/generated",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "carryon:items/tile"
|
|
||||||
},
|
|
||||||
"display": {
|
|
||||||
"ground": {
|
|
||||||
"rotation": [ 0, 0, 0 ],
|
|
||||||
"translation": [ 0, 2, 0],
|
|
||||||
"scale":[ 0.5, 0.5, 0.5 ]
|
|
||||||
},
|
|
||||||
"head": {
|
|
||||||
"rotation": [ 0, 180, 0 ],
|
|
||||||
"translation": [ 0, 13, 7],
|
|
||||||
"scale":[ 1, 1, 1]
|
|
||||||
},
|
|
||||||
"thirdperson_righthand": {
|
|
||||||
"rotation": [ 0, 0, 0 ],
|
|
||||||
"translation": [ 0, 0, 1 ],
|
|
||||||
"scale": [ 0.1, 0.1, 0.1 ]
|
|
||||||
},
|
|
||||||
"firstperson_righthand": {
|
|
||||||
"rotation": [ 0, -90, 25 ],
|
|
||||||
"translation": [ 1.13, 3.2, 1.13],
|
|
||||||
"scale": [ 0.68, 0.68, 0.68 ]
|
|
||||||
},
|
|
||||||
"gui": {
|
|
||||||
"rotation": [ 30, 225, 0 ],
|
|
||||||
"translation": [ 0, 0, 0],
|
|
||||||
"scale":[ 0.625, 0.625, 0.625 ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "carryon:item/tile"
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
src/main/resources/assets/carryon/pack.png
Normal file
BIN
src/main/resources/assets/carryon/pack.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 198 B After Width: | Height: | Size: 198 B |
16
src/main/resources/carryon.client.json
Normal file
16
src/main/resources/carryon.client.json
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"package": "tschipp.carryon.mixin.client",
|
||||||
|
"compatibilityLevel": "JAVA_8",
|
||||||
|
"mixins": [
|
||||||
|
"PlayerRendererMixin",
|
||||||
|
"BipedModelMixin",
|
||||||
|
"ArmorRendererMixin",
|
||||||
|
"FirstPersonMixin",
|
||||||
|
"MouseMixin",
|
||||||
|
"KeyboardMixin"
|
||||||
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
13
src/main/resources/carryon.common.json
Normal file
13
src/main/resources/carryon.common.json
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"package": "tschipp.carryon.mixin.common",
|
||||||
|
"compatibilityLevel": "JAVA_8",
|
||||||
|
"mixins": [
|
||||||
|
"BlockStateMixin",
|
||||||
|
"EntityMixin",
|
||||||
|
"PlayerMixin"
|
||||||
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
12
src/main/resources/fabric.mod.json
Normal file
12
src/main/resources/fabric.mod.json
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"id": "carryon",
|
||||||
|
"name": "Carry On",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"side": "universal",
|
||||||
|
"initializer": "tschipp.carryon.CarryOn",
|
||||||
|
"description": "Carry On for Fabric",
|
||||||
|
"mixins": {
|
||||||
|
"client": "carryon.client.json",
|
||||||
|
"common": "carryon.common.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"modid" : "carryon",
|
|
||||||
"name" : "Carry On",
|
|
||||||
"version" : "1.9.1", "mcversion" : "1.11.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": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
Loading…
Reference in New Issue
Block a user