4 |
5 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) bdew, 2014 - 2020
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
9 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | configurations.all {
3 | resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
4 | }
5 | repositories {
6 | mavenCentral()
7 | mavenLocal()
8 | maven {
9 | name = "forge"
10 | url = "http://files.minecraftforge.net/maven"
11 | }
12 | maven {
13 | name = "sonatype"
14 | url = "https://oss.sonatype.org/content/repositories/snapshots/"
15 | }
16 | maven {
17 | name = "gradle plugins"
18 | url = "https://plugins.gradle.org/m2/"
19 | }
20 | }
21 | dependencies {
22 | classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
23 | classpath "gradle.plugin.com.matthewprenger:CurseGradle:1.0.9"
24 | }
25 | }
26 |
27 | apply plugin: 'scala'
28 | apply plugin: 'net.minecraftforge.gradle.forge'
29 | apply plugin: 'com.matthewprenger.cursegradle'
30 |
31 | file "build.properties" withReader {
32 | def prop = new Properties()
33 | prop.load(it)
34 | ext.config = new ConfigSlurper().parse prop
35 | }
36 |
37 | if (project.hasProperty('forgeOverride')) {
38 | config.forge.version = forgeOverride
39 | }
40 |
41 | if (project.hasProperty('buildnum')) {
42 | ext.simpleVersion = "${config.ae2stuff.version}.${project.buildnum}"
43 | } else {
44 | ext.simpleVersion = "${config.ae2stuff.version}-DEV"
45 | }
46 |
47 | version = simpleVersion + '-mc' + config.minecraft.version
48 |
49 | group = "net.bdew"
50 | archivesBaseName = "ae2stuff"
51 |
52 | minecraft {
53 | version = "${config.minecraft.version}-${config.forge.version}"
54 | mappings = "${config.minecraft.mappings}"
55 | useDepAts = true
56 | makeObfSourceJar = false
57 | replace("BDLIB_VER", config.bdlib.version)
58 | replace("AE2STUFF_VER", simpleVersion.toString())
59 | }
60 |
61 | repositories {
62 | mavenCentral()
63 | maven {
64 | name = "bdew"
65 | url = "https://jenkins.bdew.net/maven"
66 | }
67 | maven {
68 | name "JEI"
69 | url "http://dvs1.progwml6.com/files/maven"
70 | }
71 | maven {
72 | name "HWYLA"
73 | url "http://tehnut.info/maven"
74 | }
75 | ivy {
76 | name "AE2"
77 | artifactPattern "http://addons-origin.cursecdn.com/files/${config.ae2.cf}/[module]-[revision](-[classifier])(.[ext])"
78 | }
79 | }
80 |
81 | dependencies {
82 | compile "net.bdew:bdlib:${config.bdlib.version}-mc${config.minecraft.version}:dev"
83 |
84 | deobfCompile "mezz.jei:jei_${config.minecraft.version}:${config.jei.version}"
85 | deobfCompile "mcp.mobius.waila:Hwyla:${config.hwyla.version}"
86 |
87 | deobfCompile ":appliedenergistics2:${config.ae2.version}@jar"
88 |
89 | }
90 |
91 | import org.apache.tools.ant.filters.ReplaceTokens
92 |
93 | sourceSets {
94 | main {
95 | scala {
96 | srcDir 'src'
97 | }
98 | resources {
99 | srcDir 'resources'
100 | }
101 | }
102 | }
103 |
104 | processResources {
105 | inputs.property "tokens", minecraft.replacements
106 | from(sourceSets.main.resources.srcDirs) {
107 | include 'mcmod.info'
108 | filter(ReplaceTokens, tokens: minecraft.replacements)
109 | }
110 |
111 | from(sourceSets.main.resources.srcDirs) {
112 | exclude 'mcmod.info'
113 | }
114 | }
115 |
116 | task sourceJarReal(type: Jar) {
117 | classifier "sources"
118 | }
119 |
120 | task deobfJar(type: Jar) {
121 | from sourceSets.main.output
122 | exclude "**/*.psd"
123 | classifier "dev"
124 | duplicatesStrategy "exclude"
125 | }
126 |
127 |
128 | jar {
129 | exclude "**/*.psd"
130 | }
131 |
132 | afterEvaluate { project ->
133 | // Fudge the inputs of api/source jars so we get the version after replacements
134 | tasks.getByPath(":sourceJarReal").from(tasks.getByPath(":sourceMainScala").outputs.files)
135 | }
136 |
137 | artifacts {
138 | archives sourceJarReal
139 | archives deobfJar
140 | }
141 |
142 | apply plugin: 'maven-publish'
143 |
144 | publishing {
145 | publications {
146 | maven(MavenPublication) {
147 | artifact deobfJar
148 | artifact sourceJarReal
149 | }
150 | }
151 | repositories {
152 | maven {
153 | url "file://var/www/maven"
154 | }
155 | }
156 | }
157 |
158 | curseforge {
159 | apiKey = project.hasProperty("curseForgeApiKey") ? project.curseForgeApiKey : ""
160 | project {
161 | id = config.curseforge.id
162 |
163 | releaseType = "alpha"
164 | changelog = project.hasProperty("changelog") ? project.changelog : "No changelog available"
165 |
166 | addGameVersion config.minecraft.version
167 | addGameVersion "1.12"
168 | addGameVersion "1.12.2"
169 |
170 |
171 | mainArtifact(jar) {
172 | displayName = "AE2Stuff ${simpleVersion} (MC ${config.minecraft.version})"
173 | }
174 |
175 | addArtifact(deobfJar) {
176 | displayName = "AE2Stuff ${simpleVersion} Deobfuscated (MC ${config.minecraft.version})"
177 | }
178 |
179 | addArtifact(sourceJarReal) {
180 | displayName = "AE2Stuff ${simpleVersion} Source (MC ${config.minecraft.version})"
181 | }
182 |
183 | relations {
184 | requiredLibrary 'bdlib'
185 | requiredLibrary 'applied-energistics-2'
186 | optionalLibrary 'waila'
187 | optionalLibrary 'just-enough-items-jei'
188 | }
189 | }
190 | }
--------------------------------------------------------------------------------
/build.properties:
--------------------------------------------------------------------------------
1 | ae2stuff.version=0.7.0
2 | curseforge.id=225194
3 | bdlib.version=1.14.3.9
4 | minecraft.version=1.12.2
5 | minecraft.mappings=snapshot_20171003
6 | forge.version=14.23.0.2512
7 | ae2.version=rv5-beta-1
8 | ae2.cf=2490/639
9 | jei.version=4.8.0.105
10 | hwyla.version=1.8.20-B35_1.12
11 |
--------------------------------------------------------------------------------
/custom-configs/no_meteorites_v1.0.cfg:
--------------------------------------------------------------------------------
1 | // This config file adds recipes for skystone and inscriber presses
2 | // It's intended for skyblock maps or maps with meteorites disabled
3 | // To use it - copy this file to your /config/AE2Stuff folder
4 |
5 | // Recipes
6 | // =======
7 | // 3 Sand + Fluix Dust => 4 Sky Dust (shapeless)
8 | // Sky Dust smelts into Sky Stone
9 | // Cutting Knife + Iron Block in various shapes => Different Presses
10 |
11 | recipes {
12 | F = M:fluixDust
13 | S = OD:sand
14 | shapeless: FSSS => M:skyDust * 4
15 |
16 | // Sky Dust smelts to Sky Stone
17 |
18 | smelt: M:skyDust => B:appliedenergistics2:"tile.BlockSkyStone" + 0 xp
19 | }
20 |
21 | recipes {
22 | K = I:appliedenergistics2:"item.ToolCertusQuartzCuttingKnife"
23 | N = I:appliedenergistics2:"item.ToolNetherQuartzCuttingKnife"
24 | I = B:iron_block
25 |
26 | K_
27 | _I => M:logicProcessorPress
28 |
29 | KI
30 | __ => M:calcProcessorPress
31 |
32 | K_
33 | I_ => M:engProcessorPress
34 |
35 | I_
36 | _K => M:siliconPress
37 |
38 | N_
39 | _I => M:logicProcessorPress
40 |
41 | NI
42 | __ => M:calcProcessorPress
43 |
44 | N_
45 | I_ => M:engProcessorPress
46 |
47 | I_
48 | _N => M:siliconPress
49 | }
50 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx2g
2 | org.gradle.daemon=false
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jul 02 15:54:47 CDT 2014
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/blockstates/encoder.json:
--------------------------------------------------------------------------------
1 | {
2 | "forge_marker": 1,
3 | "defaults": {
4 | "textures": {
5 | "top": "ae2stuff:blocks/encoder/top_off",
6 | "bottom": "ae2stuff:blocks/encoder/side",
7 | "side": "ae2stuff:blocks/encoder/side"
8 | },
9 | "model": "minecraft:cube_bottom_top"
10 | },
11 | "variants": {
12 | "active": {
13 | "true": {
14 | "textures": {
15 | "top": "ae2stuff:blocks/encoder/top_on"
16 | }
17 | },
18 | "false": {}
19 | },
20 | "facing": {
21 | "down": {"x": 90},
22 | "up": {"x": 270},
23 | "north": {},
24 | "south": {"y": 180},
25 | "west": {"y": 270},
26 | "east": {"y": 90}
27 | },
28 | "inventory": {
29 | "transform": "forge:default-block"
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/blockstates/grower.json:
--------------------------------------------------------------------------------
1 | {
2 | "forge_marker": 1,
3 | "defaults": {
4 | "textures": {
5 | "all": "ae2stuff:blocks/grower/main_off"
6 | },
7 | "model": "minecraft:cube_all"
8 | },
9 | "variants": {
10 | "active": {
11 | "true": {
12 | "textures": {
13 | "all": "ae2stuff:blocks/grower/main_on"
14 | }
15 | },
16 | "false": {}
17 | },
18 | "inventory": {
19 | "transform": "forge:default-block"
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/blockstates/inscriber.json:
--------------------------------------------------------------------------------
1 | {
2 | "forge_marker": 1,
3 | "defaults": {
4 | "textures": {
5 | "top": "ae2stuff:blocks/inscriber/top",
6 | "bottom": "ae2stuff:blocks/inscriber/top",
7 | "side": "ae2stuff:blocks/inscriber/side_off"
8 | },
9 | "model": "minecraft:cube_bottom_top"
10 | },
11 | "variants": {
12 | "active": {
13 | "true": {
14 | "textures": {
15 | "side": "ae2stuff:blocks/inscriber/side_on"
16 | }
17 | },
18 | "false": {}
19 | },
20 | "inventory": {
21 | "transform": "forge:default-block"
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/blockstates/wireless.json:
--------------------------------------------------------------------------------
1 | {
2 | "forge_marker": 1,
3 | "defaults": {
4 | "textures": {
5 | "top": "ae2stuff:blocks/wireless/top_off",
6 | "bottom": "ae2stuff:blocks/wireless/top_off",
7 | "side": "ae2stuff:blocks/wireless/side_off"
8 | },
9 | "model": "minecraft:cube_bottom_top"
10 | },
11 | "variants": {
12 | "active": {
13 | "true": {
14 | "textures": {
15 | "top": "ae2stuff:blocks/wireless/top_on",
16 | "bottom": "ae2stuff:blocks/wireless/top_on",
17 | "side": "ae2stuff:blocks/wireless/side_on"
18 | }
19 | },
20 | "false": {}
21 | },
22 | "inventory": {
23 | "transform": "forge:default-block"
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/config/files.lst:
--------------------------------------------------------------------------------
1 | tuning.cfg
2 | recipes.cfg
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/config/recipes.cfg:
--------------------------------------------------------------------------------
1 | // Special stackrefs for AE2
2 | // =========================
3 | // P:{name} - resolves to a named multipart
4 | // C:{name}/{color} - resolves to a colored multipart
5 | // M:{name} - resolves to a named material
6 | //
7 | // See http://ae2.ae-mod.info/javadoc/appeng/api/definitions/Parts.html and
8 | /// http://ae2.ae-mod.info/javadoc/appeng/api/definitions/Materials.html for names
9 |
10 |
11 | recipes {
12 | H = B:hopper
13 | T = B:chest
14 |
15 | C = C:cableGlass/TRANSPARENT
16 | G = B:appliedenergistics2:quartz_growth_accelerator
17 |
18 | GHG
19 | GTG => B:ae2stuff:grower
20 | GCG
21 | }
22 |
23 | recipes {
24 | C = B:crafting_table
25 | L = OD:itemIlluminatedPanel
26 | P = M:calcProcessor
27 |
28 | shapeless: CLP => B:ae2stuff:encoder
29 | }
30 |
31 | recipes {
32 | H = B:hopper
33 | S = B:appliedenergistics2:inscriber
34 | I = OD:ingotIron
35 | P = M:engProcessor
36 |
37 | IHI
38 | PSP => B:ae2stuff:inscriber
39 | IHI
40 | }
41 |
42 | recipes {
43 | P = M:engProcessor
44 | W = M:wirelessReceiver
45 | F = M:purifiedFluixCrystal
46 | T = I:appliedenergistics2:network_tool
47 | I = OD:ingotIron
48 | A = OD:itemIlluminatedPanel
49 |
50 | shapeless: PWT => I:ae2stuff:wireless_kit
51 |
52 | FPF
53 | IWI => B:ae2stuff:wireless
54 | FPF
55 |
56 | W_W
57 | PAP => I:ae2stuff:visualiser
58 | FFF
59 | }
60 |
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/config/tuning.cfg:
--------------------------------------------------------------------------------
1 | cfg Machines {
2 | cfg Encoder {
3 | Enabled = Y
4 | IdlePower = 1 // Idle power draw (AE/t)
5 | }
6 |
7 | cfg Grower {
8 | Enabled = Y
9 | IdlePower = 0 // Idle power draw (AE/t)
10 | CycleTicks = 1 // Length of cycle, increase to slow down (in ticks)
11 | CyclePower = 100 // Power used per growth cycle (AE)
12 | PowerCapacity = 10000 // Internal power store (AE)
13 | }
14 |
15 | cfg Inscriber {
16 | Enabled = Y
17 | IdlePower = 0 // Idle power draw (AE/t)
18 | CyclePower = 1000 // Power used per cycle (AE)
19 | PowerCapacity = 5000 // Internal power store (AE)
20 | CycleTicks = 100 // Ticks per cycle
21 | }
22 |
23 | cfg Wireless {
24 | Enabled = Y
25 |
26 | // Power use = PowerBase + PowerDistanceMultiplier * Distance^2 (AE/t)
27 | PowerBase = 10
28 | PowerDistanceMultiplier = 1
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/lang/de_DE.lang:
--------------------------------------------------------------------------------
1 | tile.ae2stuff.encoder.name=Schablonenkodierer
2 | tile.ae2stuff.grower.name=Kristallwachstumskammer
3 | tile.ae2stuff.inscriber.name=Erweiterte Gravurmaschine
4 |
5 | ae2stuff.error.not_connected=Netzwerk nicht verbunden
6 |
7 | ae2stuff.waila.sleep.true=Ruhezustand
8 | ae2stuff.waila.sleep.false=Aktiv
9 | ae2stuff.waila.power=%s / %s AE
10 |
11 | ae2stuff.gui.lock.on=Geschützt - Kann mit Automatisierung nicht entfernt werden
12 | ae2stuff.gui.lock.off=Nicht geschützt - Kann mit Automatisierung entfernt werden
13 | ae2stuff.gui.lock.note=Wenn der mittlere Slot leer ist und keine Arbeit im Gange ist
14 |
15 | ae2stuff.gui.recipes=Rezepte
16 |
17 | itemGroup.bdew.ae2stuff=AE2 Stuff
18 |
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/lang/en_US.lang:
--------------------------------------------------------------------------------
1 | tile.ae2stuff.encoder.name=Pattern Encoder
2 | tile.ae2stuff.grower.name=Crystal Growth Chamber
3 | tile.ae2stuff.inscriber.name=Advanced Inscriber
4 | tile.ae2stuff.wireless.name=Wireless Connector
5 |
6 | item.ae2stuff.wireless_kit.name=Wireless Setup Kit
7 | item.ae2stuff.visualiser.name=Network Visualisation Tool
8 |
9 | ae2stuff.error.not_connected=Network not connected
10 |
11 | ae2stuff.waila.sleep.true=Sleeping
12 | ae2stuff.waila.sleep.false=Working
13 | ae2stuff.waila.power=%s / %s AE
14 |
15 | ae2stuff.waila.wireless.connected=Connected to %s,%s,%s
16 | ae2stuff.waila.wireless.notconnected=Not Connected
17 | ae2stuff.waila.wireless.channels=Channels: %s
18 | ae2stuff.waila.wireless.power=Power Used: %s AE/t
19 |
20 | ae2stuff.gui.lock.on=Locked - Can't be removed with automation
21 | ae2stuff.gui.lock.off=Unlocked - Can be removed with automation
22 | ae2stuff.gui.lock.note=If no process is ongoing and middle slot is empty
23 |
24 | ae2stuff.gui.recipes=Recipes
25 |
26 | ae2stuff.wireless.tool.empty=Click Wireless Connector to bind
27 | ae2stuff.wireless.tool.bound1=Bound to %s,%s,%s
28 | ae2stuff.wireless.tool.bound2=Click other Wireless Connector to connect
29 | ae2stuff.wireless.tool.connected=Connected to %s,%s,%s
30 | ae2stuff.wireless.tool.failed=Connection failed
31 | ae2stuff.wireless.tool.dimension=Both connectors must be in the same dimension
32 | ae2stuff.wireless.tool.noexist=Bound connector does not exist
33 | ae2stuff.wireless.tool.security.network=Security violation - networks can't connect
34 | ae2stuff.wireless.tool.security.player=Security violation - you are not allowed to modify this network
35 |
36 | ae2stuff.visualiser.bound=Visualising network at %s,%s,%s
37 | ae2stuff.visualiser.mode=Mode:
38 | ae2stuff.visualiser.set=Mode changed to %s
39 | ae2stuff.visualiser.mode.full=Show Everything
40 | ae2stuff.visualiser.mode.nodes=Show Nodes
41 | ae2stuff.visualiser.mode.channels=Show Channels
42 | ae2stuff.visualiser.mode.nonum=Show Channels and Nodes
43 | ae2stuff.visualiser.mode.p2p=Show P2P Links
44 |
45 | itemGroup.bdew.ae2stuff=AE2 Stuff
46 |
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/lang/fr_FR.lang:
--------------------------------------------------------------------------------
1 | tile.ae2stuff.encoder.name=Encodeur de modèle
2 | tile.ae2stuff.grower.name=Chambre de croissance du crystal
3 | tile.ae2stuff.inscriber.name=Inscriveur avancé
4 | tile.ae2stuff.wireless.name=Connecteur sans-fil
5 |
6 | item.ae2stuff.wireless_kit.name=kit de configuration sans-fil
7 | item.ae2stuff.visualiser.name=Outils de visualisation du réseau
8 |
9 | ae2stuff.error.not_connected=Réseau non connecté
10 |
11 | ae2stuff.waila.sleep.true=En sommeil
12 | ae2stuff.waila.sleep.false=Au travail
13 | ae2stuff.waila.power=%s / %s AE
14 |
15 | ae2stuff.waila.wireless.connected=Connecté à %s,%s,%s
16 | ae2stuff.waila.wireless.notconnected=Non connecté
17 | ae2stuff.waila.wireless.channels=Canaux : %s
18 | ae2stuff.waila.wireless.power=Puissance utilisée : %s AE/t
19 |
20 | ae2stuff.gui.lock.on=Verrouillé - Ne peut pas être enlevé par un automatisme
21 | ae2stuff.gui.lock.off=Déverrouillé - Peut être enlevé par un automatisme
22 | ae2stuff.gui.lock.note=Si aucun processe n'est en route et que l'emplacement du milieu est vide
23 |
24 | ae2stuff.gui.recipes=Recettes
25 |
26 | ae2stuff.wireless.tool.empty=Cliquez le connecteur sans-fil pour lier
27 | ae2stuff.wireless.tool.bound1=Lié à %s,%s,%s
28 | ae2stuff.wireless.tool.bound2=Cliquez d'autre connecteur sans-fil pour connecter
29 | ae2stuff.wireless.tool.connected=Connecté à %s,%s,%s
30 | ae2stuff.wireless.tool.failed=Echec de connection
31 | ae2stuff.wireless.tool.dimension=Les deux connecteur doivent être dans la même dimension
32 | ae2stuff.wireless.tool.noexist=le connecteur lié n'existe pas
33 | ae2stuff.wireless.tool.security.network=Violation de sécurité - les réseaux ne peuvent pas se connecter
34 | ae2stuff.wireless.tool.security.player=Violation de sécurité - vous n'êtes pas autorisé à modifier ce réseau
35 |
36 | ae2stuff.visualiser.bound=Visualisation du réseau à %s,%s,%s
37 | ae2stuff.visualiser.mode=Mode :
38 | ae2stuff.visualiser.set=Mode changé en %s
39 | ae2stuff.visualiser.mode.full=Tout afficher
40 | ae2stuff.visualiser.mode.nodes=Afficher les noeuds
41 | ae2stuff.visualiser.mode.channels=Afficher les canaux
42 | ae2stuff.visualiser.mode.nonum=Afficher les cannaux et le noeud
43 | ae2stuff.visualiser.mode.p2p=Afficher les lien P2P
44 |
45 | itemGroup.bdew.ae2stuff=AE2 Stuff
46 |
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/lang/hu_HU.lang:
--------------------------------------------------------------------------------
1 | tile.ae2stuff.encoder.name=Minta Kódoló
2 | tile.ae2stuff.grower.name=Kristály Növelő Kamra
3 | tile.ae2stuff.inscriber.name=Fejlett Karcoló
4 | tile.ae2stuff.wireless.name=Vezetéknélküli Csatlakozó
5 |
6 | item.ae2stuff.wireless_kit.name=Wireless Setup Kit
7 | item.ae2stuff.visualiser.name=Network Visualisation Tool
8 |
9 | ae2stuff.error.not_connected=Hálózat nincs csatlakoztatva
10 |
11 | ae2stuff.waila.sleep.true=Alszik
12 | ae2stuff.waila.sleep.false=Dolgozik
13 | ae2stuff.waila.power=%s / %s AE
14 |
15 | ae2stuff.waila.wireless.connected=%s,%s,%s-hoz csatlakoztatva
16 | ae2stuff.waila.wireless.notconnected=Nincs csatlakoztatva
17 | ae2stuff.waila.wireless.channels=Csatornák: %s
18 | ae2stuff.waila.wireless.power=Energia használva: %s AE/t
19 |
20 | ae2stuff.gui.lock.on=Lezárva - Automatikusan nem lehet eltávolítani
21 | ae2stuff.gui.lock.off=Feloldva - Automatikusan el lehet távolítani
22 | ae2stuff.gui.lock.note=Ha egy folyamat se megy és a középső retesz üres
23 |
24 | ae2stuff.gui.recipes=Receptek
25 |
26 | ae2stuff.wireless.tool.empty=Kattints a vezetéknélküli Csatlakozóra hogy összekösd
27 | ae2stuff.wireless.tool.bound1=%s,%s,%s-hez/-hőz kötve
28 | ae2stuff.wireless.tool.bound2=Kattints a másik Vezetéknélküli Csatlakozóra hogy csatlakoztasd
29 | ae2stuff.wireless.tool.connected=%s,%s,%s-hez/-höz csatlakozik
30 | ae2stuff.wireless.tool.failed=Kapcsolat sikertelen
31 | ae2stuff.wireless.tool.dimension=Mind két csatlakozónak ugyan abban a dimenzióban kell lennie
32 | ae2stuff.wireless.tool.noexist=A csatlakoztatott Csatlakozó nem létezik
33 | ae2stuff.wireless.tool.security.network=Biztonsági áthágás - hálózatok nem kapcsolódhatnak
34 | ae2stuff.wireless.tool.security.player=Biztonsági áthágás - nem módosíthatod a hálózatot
35 |
36 | ae2stuff.visualiser.bound=Következő hálózat vizualizálása: %s,%s,%s
37 | ae2stuff.visualiser.mode=Mód:
38 | ae2stuff.visualiser.set=Mód átállítva a következőre %s
39 | ae2stuff.visualiser.mode.full=minden megjelenítése
40 | ae2stuff.visualiser.mode.nodes=Csomópontok megjelenítése
41 | ae2stuff.visualiser.mode.channels=Csatornák megjelenítése
42 | ae2stuff.visualiser.mode.nonum=Csatornák és csomópontok megjelenítése
43 | ae2stuff.visualiser.mode.p2p=P2P kapcsolatok megjelenítése
44 |
45 | itemGroup.bdew.ae2stuff=AE2 Stuff
46 |
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/lang/it_IT.lang:
--------------------------------------------------------------------------------
1 |
2 | tile.ae2stuff.encoder.name=Codificatore di Modelli
3 | tile.ae2stuff.grower.name=Camera per la crescita dei Cristalli
4 |
5 | ae2stuff.error.not_connected=Non connesso alla rete
6 |
7 | itemGroup.bdew.ae2stuff=AE2 Stuff
8 |
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/lang/ja_JP.lang:
--------------------------------------------------------------------------------
1 | #ja_JP
2 | tile.ae2stuff.encoder.name=パターンエンコーダ
3 | tile.ae2stuff.grower.name=クリスタル成長機
4 | tile.ae2stuff.inscriber.name=発展型刻印機
5 | tile.ae2stuff.wireless.name=無線コネクタ
6 |
7 | item.ae2stuff.wireless_kit.name=無線設定キット
8 | item.ae2stuff.visualiser.name=ネットワーク可視化ツール
9 |
10 | ae2stuff.error.not_connected=ネットワークに接続されていません
11 |
12 | ae2stuff.waila.sleep.true=オフライン
13 | ae2stuff.waila.sleep.false=オンライン
14 | ae2stuff.waila.power=%s / %s AE
15 |
16 | ae2stuff.waila.wireless.connected=%s,%s,%s と接続中
17 | ae2stuff.waila.wireless.notconnected=未接続
18 | ae2stuff.waila.wireless.channels=チャンネル数: %s
19 | ae2stuff.waila.wireless.power=消費パワー: %s AE/t
20 |
21 | ae2stuff.gui.lock.on=ロック - 中身を維持します
22 | ae2stuff.gui.lock.off=アンロック - 中身を維持しません
23 | ae2stuff.gui.lock.note=素材が無くなるまでクラフトします
24 |
25 | ae2stuff.gui.recipes=レシピ
26 |
27 | ae2stuff.wireless.tool.empty=無線コネクタと接続するのに使います
28 | ae2stuff.wireless.tool.bound1=接続 %s,%s,%s
29 | ae2stuff.wireless.tool.bound2=接続する為に、他の無線コネクタをクリックします
30 | ae2stuff.wireless.tool.connected=%s,%s,%s と接続しました
31 | ae2stuff.wireless.tool.failed=接続に失敗しました
32 | ae2stuff.wireless.tool.dimension=コネクタ同士は同じディメンションである必要があります
33 | ae2stuff.wireless.tool.noexist=接続先のコネクタが存在しません
34 | ae2stuff.wireless.tool.security.network=セキュリティ違反 - ネットワークに接続できません
35 | ae2stuff.wireless.tool.security.player=セキュリティ違反 - あなたはこのネットワークを変更することはできません
36 |
37 | ae2stuff.visualiser.bound=%s,%s,%s のネットワークを視覚化
38 | ae2stuff.visualiser.mode=モード:
39 | ae2stuff.visualiser.set=モード切替 %s
40 | ae2stuff.visualiser.mode.full=全て表示
41 | ae2stuff.visualiser.mode.nodes=ノードを表示
42 | ae2stuff.visualiser.mode.channels=チャンネル図を表示
43 | ae2stuff.visualiser.mode.nonum=チャンネル図とノードを表示
44 | ae2stuff.visualiser.mode.p2p=P2Pを表示
45 |
46 | itemGroup.bdew.ae2stuff=AE2 Stuff
47 |
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/lang/ko_KR.lang:
--------------------------------------------------------------------------------
1 | tile.ae2stuff.encoder.name=패턴 인코더
2 | tile.ae2stuff.grower.name=수정 성장 촉진기
3 |
4 | ae2stuff.error.not_connected=네트워크에 연결되어있지 않습니다.
5 |
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/lang/pt_BR.lang:
--------------------------------------------------------------------------------
1 | tile.ae2stuff.encoder.name=Codificador de Padrões
2 | tile.ae2stuff.grower.name=Câmara de Crescimento de Cristais
3 | tile.ae2stuff.inscriber.name=Inscritor Avançado
4 |
5 | ae2stuff.error.not_connected=Rede não conectada
6 |
7 | ae2stuff.waila.sleep.true=Dormindo
8 | ae2stuff.waila.sleep.false=Trabalhando
9 | ae2stuff.waila.power=%s / %s AE
10 |
11 | ae2stuff.gui.lock.on=Trancado - Não pode ser removido com automação
12 | ae2stuff.gui.lock.off=Destrancado - Pode ser removido com automação
13 | ae2stuff.gui.lock.note=Se não há nenhum processo ocorrendo e o slot do meio estiver vazio
14 |
15 | ae2stuff.gui.recipes=Receitas
16 |
17 | itemGroup.bdew.ae2stuff=AE2 Stuff
18 |
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/lang/ru_RU.lang:
--------------------------------------------------------------------------------
1 | tile.ae2stuff.encoder.name=Кодировщик шаблонов
2 | tile.ae2stuff.grower.name=Камера выращивания кристаллов
3 | tile.ae2stuff.inscriber.name=Продвинутый высекатель
4 | tile.ae2stuff.wireless.name=Беспроводной соединитель
5 |
6 | item.ae2stuff.wireless_kit.name=Беспроводной комплект настройки
7 | item.ae2stuff.visualiser.name=Инструмент визуализации сети
8 |
9 | ae2stuff.error.not_connected=Нет соединения с сетью
10 |
11 | ae2stuff.waila.sleep.true=Не работает
12 | ae2stuff.waila.sleep.false=Работает
13 | ae2stuff.waila.power=%s / %s AE
14 |
15 | ae2stuff.waila.wireless.connected=Подключен к %s,%s,%s
16 | ae2stuff.waila.wireless.notconnected=Не подключен
17 | ae2stuff.waila.wireless.channels=Каналы: %s
18 | ae2stuff.waila.wireless.power=Энергопотребление: %s AE/t
19 |
20 | ae2stuff.gui.lock.on=Locked - Предметы не могут быть удалены автоматически
21 | ae2stuff.gui.lock.off=Unlocked - Предметы могут быть удалены автоматически
22 | ae2stuff.gui.lock.note=Если ни один из процессов не активен, и средний слот пуст
23 |
24 | ae2stuff.gui.recipes=Рецепты
25 |
26 | ae2stuff.wireless.tool.empty=Нажмите на беспроводной соединитель для связывания
27 | ae2stuff.wireless.tool.bound1=Связан с %s,%s,%s
28 | ae2stuff.wireless.tool.bound2=Нажмите на другой беспроводной соединитель для подключения
29 | ae2stuff.wireless.tool.connected=Подключен к %s,%s,%s
30 | ae2stuff.wireless.tool.failed=Не удалось подключиться
31 | ae2stuff.wireless.tool.dimension=Оба соединителя должны быть в одном измерении
32 | ae2stuff.wireless.tool.noexist=Связанного соединителя больше не существует
33 | ae2stuff.wireless.tool.security.network=Ошибка безопасности - сети не могут быть подключены
34 | ae2stuff.wireless.tool.security.player=Ошибка безопасности - вы не можете изменить эту сеть
35 |
36 | ae2stuff.visualiser.bound=Визуализация сети на %s,%s,%s
37 | ae2stuff.visualiser.mode=Режим:
38 | ae2stuff.visualiser.set=Режим изменён на "%s"
39 | ae2stuff.visualiser.mode.full=Показывать всё
40 | ae2stuff.visualiser.mode.nodes=Показывать узлы
41 | ae2stuff.visualiser.mode.channels=Показывать каналы
42 | ae2stuff.visualiser.mode.nonum=Показывать каналы и узлы
43 | ae2stuff.visualiser.mode.p2p=Показывать P2P-соединения
44 |
45 | itemGroup.bdew.ae2stuff=AE2 Stuff
46 |
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/lang/zh_CN.lang:
--------------------------------------------------------------------------------
1 | tile.ae2stuff.encoder.name=样板编码台
2 | tile.ae2stuff.grower.name=晶体催生仓
3 | tile.ae2stuff.inscriber.name=高级压印器
4 | tile.ae2stuff.wireless.name=无线接入器
5 |
6 | item.ae2stuff.wireless_kit.name=无线设置工具
7 |
8 | ae2stuff.error.not_connected=未连接网络
9 |
10 | ae2stuff.waila.sleep.true=休眠中
11 | ae2stuff.waila.sleep.false=工作中
12 | ae2stuff.waila.power=%s / %s AE
13 |
14 | ae2stuff.waila.wireless.connected=连接至%s,%s,%s
15 | ae2stuff.waila.wireless.notconnected=非连接
16 | ae2stuff.waila.wireless.channels=频道: %s
17 | ae2stuff.waila.wireless.power=能量使用: %s AE/t
18 |
19 | ae2stuff.gui.lock.on=锁定-不能自动移除
20 | ae2stuff.gui.lock.off=解锁-能够自动移除
21 | ae2stuff.gui.lock.note=如果中间的槽非空或者正在进行中将不能处理
22 |
23 | ae2stuff.gui.recipes=Recipes
24 |
25 | ae2stuff.wireless.tool.empty=Click Wireless Connector to bind
26 | ae2stuff.wireless.tool.bound1=Bound to %s,%s,%s
27 | ae2stuff.wireless.tool.bound2=Click other Wireless Connector to connect
28 | ae2stuff.wireless.tool.connected=Connected to %s,%s,%s
29 | ae2stuff.wireless.tool.failed=Connection failed
30 | ae2stuff.wireless.tool.dimension=Both connectors must be in the same dimension
31 | ae2stuff.wireless.tool.noexist=Bound connector does not exist
32 | ae2stuff.wireless.tool.security.network=Security violation - networks can't connect
33 | ae2stuff.wireless.tool.security.player=Security violation - you are not allowed to modify this network
34 |
35 | itemGroup.bdew.ae2stuff=AE2 Stuff
36 |
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/models/item/visualiser.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/generated",
3 | "textures": {
4 | "layer0": "ae2stuff:items/visualiser"
5 | },
6 | "display": {
7 | "thirdperson_righthand": {
8 | "rotation": [0, 0, 0],
9 | "translation": [-5.0, 2.0, 0.5],
10 | "scale": [0.85, 0.85, 0.85]
11 | },
12 | "thirdperson_lefthand": {
13 | "rotation": [0, 0, 0],
14 | "translation": [-5.0, 2.0, 0.5],
15 | "scale": [0.85, 0.85, 0.85]
16 | },
17 | "firstperson_righthand": {
18 | "rotation": [0, -90, 25],
19 | "translation": [1.13, 3.2, 1.13],
20 | "scale": [0.68, 0.68, 0.68]
21 | },
22 | "firstperson_lefthand": {
23 | "rotation": [0, 90, -25],
24 | "translation": [1.13, 3.2, 1.13],
25 | "scale": [0.68, 0.68, 0.68]
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/models/item/wireless_kit.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/generated",
3 | "textures": {
4 | "layer0": "ae2stuff:items/wirelesskit"
5 | },
6 | "display": {
7 | "thirdperson_righthand": {
8 | "rotation": [90, -90, 55],
9 | "translation": [0, 4.0, 0.5],
10 | "scale": [0.85, 0.85, 0.85]
11 | },
12 | "thirdperson_lefthand": {
13 | "rotation": [90, 90, -55],
14 | "translation": [0, 4.0, 0.5],
15 | "scale": [0.85, 0.85, 0.85]
16 | },
17 | "firstperson_righthand": {
18 | "rotation": [0, -90, 25],
19 | "translation": [1.13, 3.2, 1.13],
20 | "scale": [0.68, 0.68, 0.68]
21 | },
22 | "firstperson_lefthand": {
23 | "rotation": [0, 90, -25],
24 | "translation": [1.13, 3.2, 1.13],
25 | "scale": [0.68, 0.68, 0.68]
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/blocks/encoder/side.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/blocks/encoder/side.png
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/blocks/encoder/top_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/blocks/encoder/top_off.png
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/blocks/encoder/top_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/blocks/encoder/top_on.png
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/blocks/grower/main.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/blocks/grower/main.psd
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/blocks/grower/main_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/blocks/grower/main_off.png
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/blocks/grower/main_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/blocks/grower/main_on.png
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/blocks/grower/main_on.png.mcmeta:
--------------------------------------------------------------------------------
1 | {
2 | "animation": {
3 | "frametime": 2,
4 | "frames": [
5 | 0,
6 | 1,
7 | 2,
8 | 3,
9 | 4,
10 | 4,
11 | 4,
12 | 4,
13 | 3,
14 | 2,
15 | 1,
16 | 0
17 | ]
18 | }
19 | }
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/blocks/inscriber/side.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/blocks/inscriber/side.psd
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/blocks/inscriber/side_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/blocks/inscriber/side_off.png
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/blocks/inscriber/side_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/blocks/inscriber/side_on.png
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/blocks/inscriber/side_on.png.mcmeta:
--------------------------------------------------------------------------------
1 | {
2 | "animation": {
3 | "frametime": 2,
4 | "frames": [
5 | 0,
6 | 0,
7 | 1,
8 | 2,
9 | 3,
10 | 4,
11 | 5,
12 | 6,
13 | 6,
14 | 6,
15 | 5,
16 | 4,
17 | 3,
18 | 2,
19 | 1,
20 | 0,
21 | 0
22 | ]
23 | }
24 | }
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/blocks/inscriber/top.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/blocks/inscriber/top.png
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/blocks/wireless/side_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/blocks/wireless/side_off.png
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/blocks/wireless/side_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/blocks/wireless/side_on.png
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/blocks/wireless/top_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/blocks/wireless/top_off.png
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/blocks/wireless/top_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/blocks/wireless/top_on.png
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/gui/encoder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/gui/encoder.png
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/gui/encoder.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/gui/encoder.psd
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/gui/grower.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/gui/grower.png
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/gui/grower.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/gui/grower.psd
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/icons/lock/lock.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/icons/lock/lock.psd
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/icons/lock/off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/icons/lock/off.png
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/icons/lock/on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/icons/lock/on.png
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/items/visualiser.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/items/visualiser.png
--------------------------------------------------------------------------------
/resources/assets/ae2stuff/textures/items/wirelesskit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bdew-minecraft/ae2stuff/5ed912ea686d98d1a0e5c25a9f02f142cd6f8163/resources/assets/ae2stuff/textures/items/wirelesskit.png
--------------------------------------------------------------------------------
/resources/mcmod.info:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "modid": "ae2stuff",
4 | "name": "AE2 Stuff",
5 | "description": "",
6 | "version": "@AE2STUFF_VER@",
7 | "url": "bdew.net",
8 | "updateUrl": "",
9 | "authorList": [
10 | "bdew"
11 | ],
12 | "credits": "",
13 | "logoFile": "",
14 | "screenshots": [
15 | ],
16 | "parent":"",
17 | "dependencies": [
18 | ]
19 | }
20 | ]
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'ae2stuff'
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/AE2Defs.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff
28 |
29 | import appeng.api.AEApi
30 |
31 | object AE2Defs {
32 | lazy val definitions = AEApi.instance().definitions()
33 | lazy val materials = definitions.materials()
34 | lazy val blocks = definitions.blocks()
35 | lazy val items = definitions.items()
36 | lazy val parts = definitions.parts()
37 |
38 | private def call(o: Object, m: String) = o.getClass.getMethod(m).invoke(o)
39 |
40 | def part(name: String) = call(parts, name)
41 |
42 | def material(name: String) = call(materials, name)
43 | }
44 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/AE2Stuff.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff
28 |
29 | import java.io.File
30 |
31 | import net.bdew.ae2stuff.compat.WrenchRegistry
32 | import net.bdew.ae2stuff.items.visualiser.{VisualiserOverlayRender, VisualiserPlayerTracker}
33 | import net.bdew.ae2stuff.machines.wireless.WirelessOverlayRender
34 | import net.bdew.ae2stuff.misc.{Icons, MouseEventHandler, OverlayRenderHandler}
35 | import net.bdew.ae2stuff.network.NetHandler
36 | import net.bdew.lib.Event
37 | import net.bdew.lib.gui.GuiHandler
38 | import net.minecraftforge.fml.common.Mod
39 | import net.minecraftforge.fml.common.Mod.EventHandler
40 | import net.minecraftforge.fml.common.event._
41 | import net.minecraftforge.fml.common.network.NetworkRegistry
42 | import net.minecraftforge.fml.relauncher.Side
43 | import org.apache.logging.log4j.Logger
44 |
45 | @Mod(modid = AE2Stuff.modId, version = "AE2STUFF_VER", name = "AE2 Stuff", dependencies = "required-after:appliedenergistics2;required-after:bdlib@[BDLIB_VER,)", acceptedMinecraftVersions = "[1.12,1.12.2]", modLanguage = "scala")
46 | object AE2Stuff {
47 | var log: Logger = null
48 | var instance = this
49 |
50 | final val modId = "ae2stuff"
51 | final val channel = "bdew.ae2stuff"
52 |
53 | var configDir: File = null
54 |
55 | val guiHandler = new GuiHandler
56 |
57 | def logDebug(msg: String, args: Any*) = log.debug(msg.format(args: _*))
58 | def logInfo(msg: String, args: Any*) = log.info(msg.format(args: _*))
59 | def logWarn(msg: String, args: Any*) = log.warn(msg.format(args: _*))
60 | def logError(msg: String, args: Any*) = log.error(msg.format(args: _*))
61 | def logWarnException(msg: String, t: Throwable, args: Any*) = log.warn(msg.format(args: _*), t)
62 | def logErrorException(msg: String, t: Throwable, args: Any*) = log.error(msg.format(args: _*), t)
63 |
64 | @EventHandler
65 | def preInit(event: FMLPreInitializationEvent) {
66 | log = event.getModLog
67 | configDir = new File(event.getModConfigurationDirectory, "AE2Stuff")
68 | TuningLoader.loadConfigFiles()
69 | Machines.load()
70 | Items.load()
71 | if (event.getSide == Side.CLIENT) {
72 | Icons.init()
73 | }
74 | }
75 |
76 | @EventHandler
77 | def init(event: FMLInitializationEvent) {
78 | NetworkRegistry.INSTANCE.registerGuiHandler(this, guiHandler)
79 | NetHandler.init()
80 | if (event.getSide == Side.CLIENT) {
81 | OverlayRenderHandler.register(WirelessOverlayRender)
82 | OverlayRenderHandler.register(VisualiserOverlayRender)
83 | MouseEventHandler.init()
84 | }
85 | VisualiserPlayerTracker.init()
86 | WrenchRegistry.init()
87 | FMLInterModComms.sendMessage("waila", "register", "net.bdew.ae2stuff.waila.WailaHandler.loadCallback")
88 | TuningLoader.loadDelayed()
89 | }
90 |
91 | val onPostInit = Event[FMLPostInitializationEvent]
92 |
93 | @EventHandler
94 | def postInit(event: FMLPostInitializationEvent) {
95 | onPostInit.trigger(event)
96 | }
97 |
98 | @EventHandler
99 | def onServerStarting(event: FMLServerStartingEvent): Unit = {
100 | VisualiserPlayerTracker.clear()
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/AE2Textures.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff
28 |
29 | import net.bdew.lib.gui.Texture
30 | import net.minecraft.util.ResourceLocation
31 |
32 | object AE2Textures {
33 | val inscriberTexture = new ResourceLocation("appliedenergistics2", "textures/guis/inscriber.png")
34 | val inscriberBackground = Texture(inscriberTexture, 0, 0, 176, 176)
35 | val inscriberProgress = Texture(inscriberTexture, 135, 177, 6, 18)
36 | val upgradesBackground3 = Texture(inscriberTexture, 179, 0, 32, 68)
37 | val toolBoxBackground = Texture(inscriberTexture, 178, 86, 68, 68)
38 |
39 | val upgradesBackground5 = Texture("appliedenergistics2", "textures/guis/mac.png", 179, 0, 32, 104)
40 | }
41 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/CreativeTabs.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff
28 |
29 | import net.bdew.ae2stuff.machines.encoder.BlockEncoder
30 | import net.bdew.lib.CreativeTabContainer
31 | import net.minecraft.item.ItemStack
32 |
33 | object CreativeTabs extends CreativeTabContainer {
34 | val main = new Tab("bdew.ae2stuff", new ItemStack(BlockEncoder))
35 | }
36 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/Items.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff
28 |
29 | import net.bdew.ae2stuff.items.ItemWirelessKit
30 | import net.bdew.ae2stuff.items.visualiser.ItemVisualiser
31 | import net.bdew.ae2stuff.machines.wireless.MachineWireless
32 | import net.bdew.lib.config.ItemManager
33 |
34 | object Items extends ItemManager(CreativeTabs.main) {
35 | if (MachineWireless.enabled)
36 | regItem(ItemWirelessKit)
37 |
38 | regItem(ItemVisualiser)
39 | }
40 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/Machines.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff
28 |
29 | import net.bdew.ae2stuff.machines.encoder.MachineEncoder
30 | import net.bdew.ae2stuff.machines.grower.MachineGrower
31 | import net.bdew.ae2stuff.machines.inscriber.MachineInscriber
32 | import net.bdew.ae2stuff.machines.wireless.MachineWireless
33 | import net.bdew.lib.config.{BlockManager, MachineManager}
34 |
35 | object Blocks extends BlockManager(CreativeTabs.main)
36 |
37 | object Machines extends MachineManager(Tuning.getSection("Machines"), AE2Stuff.guiHandler, Blocks) {
38 | registerMachine(MachineEncoder)
39 | registerMachine(MachineGrower)
40 | registerMachine(MachineInscriber)
41 | registerMachine(MachineWireless)
42 | }
43 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/Tuning.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff
28 |
29 | import java.io.{File, FileWriter}
30 | import java.util.Optional
31 |
32 | import appeng.api.definitions.IItemDefinition
33 | import appeng.api.util.{AEColor, AEColoredItemDefinition}
34 | import net.bdew.lib.recipes.gencfg.{ConfigSection, GenericConfigLoader, GenericConfigParser}
35 | import net.bdew.lib.recipes.{RecipeLoader, RecipeParser, RecipesHelper, StackRef}
36 | import net.minecraft.item.ItemStack
37 |
38 | object Tuning extends ConfigSection
39 |
40 | object TuningLoader {
41 |
42 | case class StackMaterial(name: String) extends StackRef
43 |
44 | case class StackPart(name: String) extends StackRef
45 |
46 | case class StackPartColored(name: String, color: String) extends StackRef
47 |
48 | class Parser extends RecipeParser with GenericConfigParser {
49 | def specMaterial = "M" ~> ":" ~> ident ^^ StackMaterial
50 | def specPart = "P" ~> ":" ~> ident ^^ StackPart
51 | def specPartColored = "C" ~> ":" ~> ident ~ "/" ~ ident ^^ { case name ~ sl ~ color => StackPartColored(name, color) }
52 | override def spec = specMaterial | specPart | specPartColored | super.spec
53 | }
54 |
55 | val loader = new RecipeLoader with GenericConfigLoader {
56 | val cfgStore = Tuning
57 | override def newParser() = new Parser
58 |
59 | val materials = AE2Defs.materials
60 | val parts = AE2Defs.parts
61 |
62 | def getOptionalStack(s: Optional[ItemStack], name: String): ItemStack = {
63 | if (s.isPresent)
64 | s.get()
65 | else
66 | error("Unable to resolve %s", name)
67 | }
68 |
69 | override def getConcreteStack(s: StackRef, cnt: Int) = s match {
70 | case StackMaterial(name) =>
71 | getOptionalStack(AE2Defs.material(name).asInstanceOf[IItemDefinition].maybeStack(cnt), s.toString)
72 | case StackPart(name) =>
73 | getOptionalStack(AE2Defs.part(name).asInstanceOf[IItemDefinition].maybeStack(cnt), s.toString)
74 | case StackPartColored(name, colorName) =>
75 | val color = AEColor.valueOf(colorName)
76 | AE2Defs.part(name).asInstanceOf[AEColoredItemDefinition].stack(color, cnt)
77 | case _ => super.getConcreteStack(s, cnt)
78 | }
79 | }
80 |
81 | def loadDelayed() = loader.processRecipeStatements()
82 |
83 | def loadConfigFiles() {
84 | if (!AE2Stuff.configDir.exists()) {
85 | AE2Stuff.configDir.mkdir()
86 | val nl = System.getProperty("line.separator")
87 | val f = new FileWriter(new File(AE2Stuff.configDir, "readme.txt"))
88 | f.write("Any .cfg files in this directory will be loaded after the internal configuration, in alphabetic order" + nl)
89 | f.write("Files in 'overrides' directory with matching names cab be used to override internal configuration" + nl)
90 | f.close()
91 | }
92 |
93 | RecipesHelper.loadConfigs(
94 | modName = "AE2 Stuff",
95 | listResource = "/assets/ae2stuff/config/files.lst",
96 | configDir = AE2Stuff.configDir,
97 | resBaseName = "/assets/ae2stuff/config/",
98 | loader = loader)
99 | }
100 | }
101 |
102 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/compat/AEWrenchHandler.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.compat
28 |
29 | import appeng.api.implementations.items.IAEWrench
30 | import net.bdew.lib.Misc
31 | import net.minecraft.entity.player.EntityPlayer
32 | import net.minecraft.item.ItemStack
33 | import net.minecraft.util.math.BlockPos
34 |
35 | object AEWrenchHandler extends WrenchHandler {
36 | override def canWrench(player: EntityPlayer, stack: ItemStack, pos: BlockPos): Boolean =
37 | Misc.asInstanceOpt(stack.getItem, classOf[IAEWrench]) exists (_.canWrench(stack, player, pos))
38 |
39 | override def doWrench(player: EntityPlayer, stack: ItemStack, pos: BlockPos): Unit = {}
40 | }
41 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/compat/WrenchRegistry.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.compat
28 |
29 | import net.minecraft.entity.player.EntityPlayer
30 | import net.minecraft.item.ItemStack
31 | import net.minecraft.util.math.BlockPos
32 |
33 | trait WrenchHandler {
34 | def canWrench(player: EntityPlayer, stack: ItemStack, pos: BlockPos): Boolean
35 | def doWrench(player: EntityPlayer, stack: ItemStack, pos: BlockPos): Unit
36 | }
37 |
38 | object WrenchRegistry {
39 | var registry = List.empty[WrenchHandler]
40 |
41 | def init(): Unit = {
42 | registry :+= AEWrenchHandler
43 | }
44 |
45 | def findWrench(player: EntityPlayer, stack: ItemStack, pos: BlockPos) =
46 | registry.find(_.canWrench(player, stack, pos))
47 | }
48 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/grid/GridTile.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.grid
28 |
29 | import java.util
30 |
31 | import appeng.api.AEApi
32 | import appeng.api.networking._
33 | import appeng.api.networking.events.MENetworkEvent
34 | import appeng.api.util.{AECableType, AEColor, AEPartLocation, DimensionalCoord}
35 | import appeng.me.GridAccessException
36 | import net.bdew.lib.items.ItemUtils
37 | import net.bdew.lib.tile.inventory.BreakableInventoryTile
38 | import net.bdew.lib.tile.{TileExtended, TileTicking}
39 | import net.minecraft.entity.player.EntityPlayer
40 | import net.minecraft.item.ItemStack
41 | import net.minecraft.util.EnumFacing
42 | import net.minecraftforge.fml.common.FMLCommonHandler
43 |
44 | trait GridTile extends TileExtended with TileTicking with IGridHost with IGridBlock {
45 | var node: IGridNode = null
46 | var initialized = false
47 |
48 | var placingPlayer: EntityPlayer = null
49 |
50 | serverTick.listen(() => {
51 | if (!initialized) {
52 | if (placingPlayer != null)
53 | getNode.setPlayerID(Security.getPlayerId(placingPlayer))
54 | getNode.updateState()
55 | initialized = true
56 | }
57 | })
58 |
59 | persistSave.listen((tag) => {
60 | if (node != null)
61 | node.saveToNBT("ae_node", tag)
62 | })
63 |
64 | persistLoad.listen((tag) => {
65 | if (FMLCommonHandler.instance().getEffectiveSide.isServer) {
66 | unRegisterNode()
67 | node = AEApi.instance().grid().createGridNode(this)
68 | if (tag.hasKey("ae_node"))
69 | node.loadFromNBT("ae_node", tag)
70 | }
71 | initialized = false
72 | })
73 |
74 | def unRegisterNode(): Unit = {
75 | if (node != null) {
76 | node.destroy()
77 | node = null
78 | initialized = false
79 | }
80 | }
81 |
82 | override def invalidate(): Unit = {
83 | unRegisterNode()
84 | super.invalidate()
85 | }
86 |
87 | override def onChunkUnload(): Unit = {
88 | unRegisterNode()
89 | super.onChunkUnload()
90 | }
91 |
92 | def getNode = {
93 | if (getWorld == null || getWorld.isRemote) null
94 | else {
95 | if (node == null)
96 | node = AEApi.instance().grid().createGridNode(this)
97 | node
98 | }
99 | }
100 |
101 | def safePostEvent(ev: MENetworkEvent) = {
102 | try {
103 | getNode.getGrid.postEvent(ev)
104 | true
105 | } catch {
106 | case _: GridAccessException => false
107 | }
108 | }
109 |
110 | // IGridHost
111 | override def getGridNode(aePartLocation: AEPartLocation): IGridNode = getNode
112 | override def getCableConnectionType(aePartLocation: AEPartLocation): AECableType = AECableType.COVERED
113 | override def securityBreak() = {
114 | ItemUtils.throwItemAt(getWorld, getPos, new ItemStack(getBlockType))
115 | if (this.isInstanceOf[BreakableInventoryTile])
116 | this.asInstanceOf[BreakableInventoryTile].dropItems()
117 | getWorld.setBlockToAir(getPos)
118 | }
119 |
120 | // IGridBlock
121 | override def getIdlePowerUsage = 0
122 | override def getFlags = util.EnumSet.noneOf(classOf[GridFlags])
123 | override def getGridColor = AEColor.TRANSPARENT
124 | override def getConnectableSides = util.EnumSet.allOf(classOf[EnumFacing])
125 | override def getMachine = this
126 | override def isWorldAccessible = true
127 | override def getLocation = new DimensionalCoord(this)
128 |
129 | // Needs to be implemented by subclass
130 | override def getMachineRepresentation: ItemStack
131 |
132 | // Default notifications do nothing
133 | override def onGridNotification(p1: GridNotification) {}
134 | override def setNetworkStatus(p1: IGrid, p2: Int) {}
135 | override def gridChanged() {}
136 | }
137 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/grid/PoweredTile.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.grid
28 |
29 | import appeng.api.config.{AccessRestriction, Actionable, PowerMultiplier}
30 | import appeng.api.networking.energy.{IAEPowerStorage, IEnergyGrid}
31 | import appeng.api.networking.events.MENetworkPowerStorage
32 | import net.bdew.lib.Misc
33 | import net.bdew.lib.data.DataSlotDouble
34 | import net.bdew.lib.data.base.{TileDataSlots, UpdateKind}
35 |
36 | trait PoweredTile extends TileDataSlots with GridTile with SleepableTile with IAEPowerStorage {
37 | def powerCapacity: Double
38 |
39 | val powerStored = DataSlotDouble("power", this).setUpdate(UpdateKind.SAVE)
40 |
41 | private var postedReq = false
42 |
43 | def requestPowerIfNeeded(): Unit = {
44 | if (node != null && node.isActive) {
45 | if (!postedReq && powerStored / powerCapacity < 0.9D) {
46 | postedReq = true
47 | safePostEvent(new MENetworkPowerStorage(this, MENetworkPowerStorage.PowerEventType.REQUEST_POWER))
48 | } else if (powerStored / powerCapacity < 0.5D) {
49 | val net = node.getGrid.getCache[IEnergyGrid](classOf[IEnergyGrid])
50 | if (net.getStoredPower / net.getMaxStoredPower > 0.2) {
51 | val drawn = net.extractAEPower(Misc.min(powerCapacity - powerStored, net.getMaxStoredPower * 0.1), Actionable.MODULATE, PowerMultiplier.CONFIG)
52 | if (drawn > 0) {
53 | powerStored += drawn
54 | wakeup()
55 | }
56 | }
57 | }
58 | }
59 | }
60 |
61 | override def getAECurrentPower: Double = powerStored
62 | override def getAEMaxPower: Double = powerCapacity
63 |
64 | override def injectAEPower(v: Double, actionable: Actionable): Double = {
65 | val canStore = Misc.clamp(v, 0D, powerCapacity - powerStored)
66 | if (actionable == Actionable.MODULATE && canStore > 0) {
67 | powerStored += canStore
68 | postedReq = false
69 | wakeup()
70 | }
71 | v - canStore
72 | }
73 |
74 | override def extractAEPower(v: Double, actionable: Actionable, powerMultiplier: PowerMultiplier): Double = 0
75 |
76 | override def getPowerFlow = AccessRestriction.WRITE
77 | override def isAEPublicPowerStorage = true
78 | }
79 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/grid/Security.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.grid
28 |
29 | import appeng.api.AEApi
30 | import appeng.api.config.SecurityPermissions
31 | import appeng.api.networking.security.ISecurityGrid
32 | import appeng.api.networking.{IGrid, IGridNode}
33 | import com.mojang.authlib.GameProfile
34 | import net.minecraft.entity.player.EntityPlayer
35 |
36 | object Security {
37 | def getPlayerId(p: GameProfile): Int = AEApi.instance().registries().players().getID(p)
38 | def getPlayerId(e: EntityPlayer): Int = AEApi.instance().registries().players().getID(e)
39 | def getPlayerFromId(id: Int): Option[EntityPlayer] = Option(AEApi.instance().registries().players().findPlayer(id))
40 |
41 | def playerHasPermission(grid: IGrid, playerID: Int, permission: SecurityPermissions): Boolean = {
42 | if (grid == null) return true
43 | val gs = grid.getCache[ISecurityGrid](classOf[ISecurityGrid])
44 | if (gs == null || !gs.isAvailable) return true
45 | gs.hasPermission(playerID, permission)
46 | }
47 |
48 | def isNodeOnSecureNetwork(n: IGridNode): Boolean = {
49 | if (n.getGrid == null) return false
50 | val gs = n.getGrid.getCache[ISecurityGrid](classOf[ISecurityGrid])
51 | if (gs == null) return false
52 | gs.isAvailable
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/grid/SleepableTile.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.grid
28 |
29 | import net.bdew.ae2stuff.AE2Stuff
30 | import net.bdew.lib.Event
31 | import net.bdew.lib.tile.{TileExtended, TileTicking}
32 |
33 | import scala.util.Random
34 |
35 | trait SleepableTile extends TileExtended with TileTicking {
36 | private final val TRACE = false
37 | private var sleeping = false
38 | private val forceWakeupOn = Random.nextInt(100)
39 |
40 | serverTick.listen(() => {
41 | // This should prevent tiles from getting stuck sleeping forever
42 | if (getWorld.getTotalWorldTime % 100 == forceWakeupOn)
43 | wakeup()
44 | })
45 |
46 | val onSleep = Event()
47 | val onWake = Event()
48 |
49 | def isAwake = !sleeping
50 |
51 | def isSleeping = sleeping
52 |
53 | def sleep(): Unit = {
54 | if (TRACE && !sleeping) AE2Stuff.logInfo("SLEEP %s (%s)", getClass.getSimpleName, getPos)
55 | if (!sleeping) onSleep.trigger()
56 | sleeping = true
57 | }
58 |
59 | def wakeup(): Unit = {
60 | if (TRACE && sleeping) AE2Stuff.logInfo("WAKEUP %s (%s)", getClass.getSimpleName, getPos)
61 | if (sleeping) onWake.trigger()
62 | sleeping = false
63 | }
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/grid/VariableIdlePower.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.grid
28 |
29 | import appeng.api.networking.events.MENetworkPowerIdleChange
30 | import net.bdew.lib.tile.TileExtended
31 |
32 | trait VariableIdlePower extends TileExtended with GridTile {
33 | private var currentPowerUsage = 0D
34 |
35 | persistSave.listen(tag => tag.setDouble("_poweruse", currentPowerUsage))
36 | persistLoad.listen(tag => setIdlePowerUse(tag.getDouble("_poweruse")))
37 |
38 | override def getIdlePowerUsage = currentPowerUsage
39 |
40 | def setIdlePowerUse(v: Double) {
41 | if (v != currentPowerUsage) {
42 | currentPowerUsage = v
43 | if (node != null && node.getGrid != null)
44 | node.getGrid.postEvent(new MENetworkPowerIdleChange(node))
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/items/visualiser/VisualiserPlayerTracker.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.items.visualiser
28 |
29 | import net.bdew.ae2stuff.misc.PosAndDimension
30 | import net.minecraft.entity.player.EntityPlayer
31 | import net.minecraftforge.common.MinecraftForge
32 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
33 | import net.minecraftforge.fml.common.gameevent.PlayerEvent.{PlayerChangedDimensionEvent, PlayerLoggedOutEvent, PlayerRespawnEvent}
34 |
35 | import scala.collection.mutable
36 |
37 | object VisualiserPlayerTracker {
38 |
39 | case class Entry(loc: PosAndDimension, last: Long)
40 |
41 | var map = mutable.Map.empty[EntityPlayer, Entry]
42 |
43 | def init() {
44 | MinecraftForge.EVENT_BUS.register(this)
45 | }
46 |
47 | def clear() = map.clear()
48 |
49 | def needToUpdate(player: EntityPlayer, loc: PosAndDimension): Boolean = {
50 | if (map.isDefinedAt(player)) {
51 | val last = map(player)
52 | val now = player.world.getTotalWorldTime
53 | if (last.loc != loc || last.last < now - 100) {
54 | map += player -> Entry(loc, player.world.getTotalWorldTime)
55 | true
56 | } else false
57 | } else {
58 | map += player -> Entry(loc, player.world.getTotalWorldTime)
59 | true
60 | }
61 | }
62 |
63 | def reset(player: EntityPlayer) = map -= player
64 |
65 | @SubscribeEvent
66 | def handlePlayerLogout(ev: PlayerLoggedOutEvent) = reset(ev.player)
67 |
68 | @SubscribeEvent
69 | def handlePlayerChangedDimension(ev: PlayerChangedDimensionEvent) = reset(ev.player)
70 |
71 | @SubscribeEvent
72 | def handlePlayerRespawn(ev: PlayerRespawnEvent) = reset(ev.player)
73 | }
74 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/items/visualiser/data.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.items.visualiser
28 |
29 | import java.io._
30 |
31 | import net.bdew.ae2stuff.AE2Stuff
32 |
33 | object VNodeFlags extends Enumeration {
34 | val DENSE, MISSING = Value
35 | }
36 |
37 | object VLinkFlags extends Enumeration {
38 | val DENSE, COMPRESSED = Value
39 | }
40 |
41 | case class VNode(x: Int, y: Int, z: Int, flags: VNodeFlags.ValueSet)
42 |
43 | case class VLink(node1: VNode, node2: VNode, channels: Byte, flags: VLinkFlags.ValueSet)
44 |
45 | class VisualisationData(var nodes: Seq[VNode], var links: Seq[VLink]) extends Externalizable {
46 | def this() = this(Seq.empty, Seq.empty)
47 |
48 | override def readExternal(in: ObjectInput): Unit = {
49 | val ver = in.readInt()
50 | if (ver != VisualisationData.VERSION) {
51 | AE2Stuff.logWarn("Visualisation data version mismatch, expected %d, got %d - make sure client/server versions are not mismatched")
52 | } else {
53 | val nodeCount = in.readInt()
54 | val linkCount = in.readInt()
55 | nodes = Vector.empty ++ (for (i <- 0 until nodeCount) yield {
56 | val x = in.readInt()
57 | val y = in.readInt()
58 | val z = in.readInt()
59 | val f = in.readByte()
60 | VNode(x, y, z, VNodeFlags.ValueSet.fromBitMask(Array(f.toLong)))
61 | })
62 |
63 | links = for (i <- 0 until linkCount) yield {
64 | val n1 = in.readInt()
65 | val n2 = in.readInt()
66 | val c = in.readByte()
67 | val f = in.readByte()
68 | VLink(nodes(n1), nodes(n2), c, VLinkFlags.ValueSet.fromBitMask(Array(f.toLong)))
69 | }
70 | }
71 | }
72 |
73 | override def writeExternal(out: ObjectOutput): Unit = {
74 | out.writeInt(VisualisationData.VERSION)
75 | out.writeInt(nodes.size)
76 | out.writeInt(links.size)
77 | for (n <- nodes) {
78 | out.writeInt(n.x)
79 | out.writeInt(n.y)
80 | out.writeInt(n.z)
81 | out.writeByte(n.flags.toBitMask(0).toByte)
82 | }
83 |
84 | val nodeMap = nodes.zipWithIndex.toMap
85 |
86 | for (l <- links) {
87 | out.writeInt(nodeMap(l.node1))
88 | out.writeInt(nodeMap(l.node2))
89 | out.writeByte(l.channels)
90 | out.writeByte(l.flags.toBitMask(0).toByte)
91 | }
92 | }
93 | }
94 |
95 | object VisualisationData {
96 | final val VERSION = 1
97 | }
98 |
99 | object VisualisationModes extends Enumeration {
100 | val FULL, NODES, CHANNELS, NONUM, P2P = Value
101 | val modes = List(FULL, NODES, CHANNELS, NONUM, P2P)
102 | }
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/jei/AE2StuffJeiPlugin.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.jei
28 |
29 | import mezz.jei.api.recipe.VanillaRecipeCategoryUid
30 | import mezz.jei.api.{IModPlugin, IModRegistry, JEIPlugin}
31 |
32 | @JEIPlugin
33 | class AE2StuffJeiPlugin extends IModPlugin {
34 | override def register(registry: IModRegistry): Unit = {
35 | registry.getRecipeTransferRegistry.addRecipeTransferHandler(EncoderTransferHandler, VanillaRecipeCategoryUid.CRAFTING)
36 | }
37 | }
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/jei/EncoderTransferHandler.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.jei
28 |
29 | import mezz.jei.api.gui.IRecipeLayout
30 | import mezz.jei.api.recipe.transfer.{IRecipeTransferError, IRecipeTransferHandler}
31 | import net.bdew.ae2stuff.machines.encoder.ContainerEncoder
32 | import net.bdew.ae2stuff.network.{MsgSetRecipe, NetHandler}
33 | import net.bdew.lib.PimpVanilla._
34 | import net.bdew.lib.nbt.NBT
35 | import net.minecraft.entity.player.EntityPlayer
36 | import net.minecraft.nbt.NBTTagCompound
37 |
38 | import scala.collection.JavaConversions._
39 |
40 | object EncoderTransferHandler extends IRecipeTransferHandler[ContainerEncoder] {
41 | override def getContainerClass = classOf[ContainerEncoder]
42 |
43 | override def transferRecipe(container: ContainerEncoder, recipeLayout: IRecipeLayout, player: EntityPlayer, maxTransfer: Boolean, doTransfer: Boolean): IRecipeTransferError = {
44 | if (!doTransfer) return null
45 |
46 | val data = new NBTTagCompound
47 |
48 | for ((ingredients, slot) <- recipeLayout.getItemStacks.getGuiIngredients.values().filter(_.isInput).zipWithIndex) {
49 | val items = for (stack <- ingredients.getAllIngredients) yield {
50 | val copy = stack.copy()
51 | copy.setCount(1)
52 | NBT.from(copy.writeToNBT)
53 | }
54 | data.setList(slot.toString, items)
55 | }
56 |
57 | NetHandler.sendToServer(MsgSetRecipe(data))
58 |
59 | return null
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/encoder/BlockEncoder.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.encoder
28 |
29 | import net.bdew.ae2stuff.AE2Stuff
30 | import net.bdew.ae2stuff.misc.{BlockActiveTexture, BlockWrenchable, MachineMaterial}
31 | import net.bdew.lib.block.{BaseBlock, BlockKeepData, HasTE}
32 | import net.bdew.lib.rotate.{BlockFacingMeta, Properties}
33 | import net.minecraft.block.state.IBlockState
34 | import net.minecraft.entity.EntityLivingBase
35 | import net.minecraft.entity.player.EntityPlayer
36 | import net.minecraft.item.ItemStack
37 | import net.minecraft.util._
38 | import net.minecraft.util.math.BlockPos
39 | import net.minecraft.world.World
40 |
41 | object BlockEncoder extends BaseBlock("encoder", MachineMaterial) with HasTE[TileEncoder] with BlockWrenchable with BlockFacingMeta with BlockKeepData with BlockActiveTexture {
42 | override val TEClass = classOf[TileEncoder]
43 |
44 | setHardness(1)
45 |
46 | override def getStateFromMeta(meta: Int) =
47 | getDefaultState
48 | .withProperty(Properties.FACING, EnumFacing.getFront(meta & 7))
49 | .withProperty(BlockActiveTexture.Active, Boolean.box((meta & 8) > 0))
50 |
51 | override def getMetaFromState(state: IBlockState) = {
52 | state.getValue(Properties.FACING).ordinal() | (if (state.getValue(BlockActiveTexture.Active)) 8 else 0)
53 | }
54 |
55 | override def onBlockActivatedReal(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, hand: EnumHand, heldItem: ItemStack, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean = {
56 | if (getTE(world, pos).getNode.isActive) {
57 | player.openGui(AE2Stuff, MachineEncoder.guiId, world, pos.getX, pos.getY, pos.getZ)
58 | } else {
59 | import net.bdew.lib.helpers.ChatHelper._
60 | player.sendStatusMessage(L("ae2stuff.error.not_connected").setColor(Color.RED), true)
61 | }
62 | true
63 | }
64 |
65 | override def onBlockPlacedBy(world: World, pos: BlockPos, state: IBlockState, placer: EntityLivingBase, stack: ItemStack): Unit = {
66 | super.onBlockPlacedBy(world, pos, state, placer, stack)
67 | if (placer.isInstanceOf[EntityPlayer])
68 | getTE(world, pos).placingPlayer = placer.asInstanceOf[EntityPlayer]
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/encoder/ContainerEncoder.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.encoder
28 |
29 | import net.bdew.ae2stuff.AE2Defs
30 | import net.bdew.lib.gui.{BaseContainer, SlotValidating}
31 | import net.minecraft.entity.player.EntityPlayer
32 | import net.minecraft.inventory.{ClickType, InventoryCrafting}
33 | import net.minecraft.item.ItemStack
34 | import net.minecraft.item.crafting.CraftingManager
35 |
36 | class ContainerEncoder(val te: TileEncoder, player: EntityPlayer) extends BaseContainer(te) {
37 |
38 | for (x <- 0 until 3; y <- 0 until 3) {
39 | addSlotToContainer(new SlotFakeCrafting(te, te.slots.recipe(x + y * 3), 10 + x * 18, 17 + y * 18, updateRecipe))
40 | }
41 |
42 | addSlotToContainer(new SlotFakeCraftingResult(te, te.slots.result, 104, 35))
43 | val patternSlot = addSlotToContainer(new SlotValidating(te, te.slots.patterns, 143, 17))
44 | addSlotToContainer(new SlotFakeEncodedPattern(te, te.slots.encoded, 143, 53))
45 |
46 | bindPlayerInventory(player.inventory, 8, 84, 142)
47 |
48 | def updateRecipe() {
49 | val c = new InventoryCrafting(this, 3, 3)
50 | for (i <- 0 until 9)
51 | c.setInventorySlotContents(i, te.getStackInSlot(te.slots.recipe(i)))
52 | val r = CraftingManager.findMatchingResult(c, te.getWorld)
53 | te.setInventorySlotContents(te.slots.result, r)
54 | }
55 |
56 | override def slotClick(slotNum: Int, button: Int, clickType: ClickType, player: EntityPlayer): ItemStack = {
57 | import scala.collection.JavaConversions._
58 | if (inventorySlots.isDefinedAt(slotNum)) {
59 | val slot = getSlot(slotNum)
60 | if (slot == patternSlot && button == 0 && clickType == ClickType.PICKUP) {
61 | val playerStack = player.inventory.getItemStack
62 | val slotStack = slot.getStack
63 | if (AE2Defs.items.encodedPattern().isSameAs(playerStack)) {
64 | if (slotStack.isEmpty) {
65 | slot.putStack(AE2Defs.materials.blankPattern().maybeStack(playerStack.getCount).get())
66 | player.inventory.setItemStack(ItemStack.EMPTY)
67 | detectAndSendChanges()
68 | return ItemStack.EMPTY
69 | } else if (slotStack.getCount + playerStack.getCount <= slotStack.getMaxStackSize) {
70 | slotStack.grow(playerStack.getCount)
71 | slot.onSlotChanged()
72 | player.inventory.setItemStack(ItemStack.EMPTY)
73 | detectAndSendChanges()
74 | return ItemStack.EMPTY
75 | }
76 | }
77 | }
78 | }
79 |
80 | // This is a hacky workaround!
81 | // When a player changes the contents of a slot, isChangingQuantityOnly is set to true,
82 | // preventing updates to OTHER slots from being detected and sent back
83 | // Here i ensure changes are sent back before returning so NetHandlerPlayServer.processClickWindow doesn't
84 | // get the opportunity to mess things up
85 | val r = super.slotClick(slotNum, button, clickType, player)
86 | detectAndSendChanges()
87 | r
88 | }
89 |
90 | override def transferStackInSlot(player: EntityPlayer, slot: Int): ItemStack = {
91 | val fromSlot = getSlot(slot)
92 | val clickedStack = fromSlot.getStack
93 | if (fromSlot.inventory == player.inventory && AE2Defs.items.encodedPattern().isSameAs(clickedStack)) {
94 | val patternStack = patternSlot.getStack
95 | if (patternStack.isEmpty) {
96 | patternSlot.putStack(AE2Defs.materials.blankPattern().maybeStack(clickedStack.getCount).get())
97 | fromSlot.putStack(ItemStack.EMPTY)
98 | return ItemStack.EMPTY
99 | } else if (patternStack.getCount + clickedStack.getCount <= patternStack.getMaxStackSize) {
100 | patternStack.grow(clickedStack.getCount)
101 | patternSlot.onSlotChanged()
102 | fromSlot.putStack(ItemStack.EMPTY)
103 | return ItemStack.EMPTY
104 | }
105 | }
106 | super.transferStackInSlot(player, slot)
107 | }
108 |
109 | override def detectAndSendChanges() {
110 | super.detectAndSendChanges()
111 | if (!te.getWorld.isRemote) {
112 | if (!te.getNode.isActive) {
113 | player.closeScreen()
114 | }
115 | }
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/encoder/GuiEncoder.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.encoder
28 |
29 | import net.bdew.ae2stuff.AE2Stuff
30 | import net.bdew.lib.Misc
31 | import net.bdew.lib.gui.widgets.WidgetLabel
32 | import net.bdew.lib.gui.{BaseScreen, Color, Texture}
33 |
34 | class GuiEncoder(cont: ContainerEncoder) extends BaseScreen(cont, 176, 166) {
35 | override val background = Texture(AE2Stuff.modId, "textures/gui/encoder.png", rect)
36 | override def initGui() {
37 | super.initGui()
38 | widgets.add(new WidgetLabel(BlockEncoder.getLocalizedName, 8, 6, Color.darkGray))
39 | widgets.add(new WidgetLabel(Misc.toLocal("container.inventory"), 8, this.ySize - 96 + 3, Color.darkGray))
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/encoder/MachineEncoder.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.encoder
28 |
29 | import net.bdew.ae2stuff.network.{MsgSetRecipe, NetHandler}
30 | import net.bdew.lib.Misc
31 | import net.bdew.lib.PimpVanilla._
32 | import net.bdew.lib.gui.GuiProvider
33 | import net.bdew.lib.machine.Machine
34 | import net.minecraft.entity.player.EntityPlayer
35 | import net.minecraft.item.ItemStack
36 | import net.minecraftforge.fml.relauncher.{Side, SideOnly}
37 |
38 | object MachineEncoder extends Machine("Encoder", BlockEncoder) with GuiProvider {
39 | override def guiId = 1
40 | override type TEClass = TileEncoder
41 |
42 | lazy val idlePowerDraw = tuning.getDouble("IdlePower")
43 |
44 | @SideOnly(Side.CLIENT)
45 | override def getGui(te: TEClass, player: EntityPlayer) = new GuiEncoder(new ContainerEncoder(te, player))
46 | override def getContainer(te: TEClass, player: EntityPlayer) = new ContainerEncoder(te, player)
47 |
48 | NetHandler.regServerHandler {
49 | case (MsgSetRecipe(data), player) =>
50 | Misc.asInstanceOpt(player.openContainer, classOf[ContainerEncoder]).foreach { cont =>
51 | for ((slotNum, recIdx) <- cont.te.slots.recipe.zipWithIndex) {
52 | val items = data.tag.getList[ItemStack](slotNum.toString)
53 | if (items.nonEmpty)
54 | cont.te.setInventorySlotContents(recIdx, cont.te.findMatchingRecipeStack(items))
55 | else
56 | cont.te.setInventorySlotContents(recIdx, ItemStack.EMPTY)
57 | }
58 | cont.updateRecipe()
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/encoder/TileEncoder.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.encoder
28 |
29 | import appeng.api.AEApi
30 | import appeng.api.networking.events.{MENetworkEventSubscribe, MENetworkPowerStatusChange}
31 | import appeng.api.networking.storage.IStorageGrid
32 | import appeng.api.storage.channels.IItemStorageChannel
33 | import appeng.api.storage.data.IAEItemStack
34 | import net.bdew.ae2stuff.AE2Defs
35 | import net.bdew.ae2stuff.grid.GridTile
36 | import net.bdew.lib.PimpVanilla._
37 | import net.bdew.lib.block.TileKeepData
38 | import net.bdew.lib.nbt.NBT
39 | import net.bdew.lib.tile.TileExtended
40 | import net.bdew.lib.tile.inventory.{PersistentInventoryTile, SidedInventory}
41 | import net.minecraft.block.state.IBlockState
42 | import net.minecraft.item.ItemStack
43 | import net.minecraft.nbt.NBTTagCompound
44 | import net.minecraft.util.math.BlockPos
45 | import net.minecraft.util.{EnumFacing, NonNullList}
46 | import net.minecraft.world.World
47 | import net.minecraftforge.oredict.OreDictionary
48 |
49 | class TileEncoder extends TileExtended with GridTile with PersistentInventoryTile with SidedInventory with TileKeepData {
50 | override def getSizeInventory = 12
51 |
52 | object slots {
53 | val recipe = (0 until 9).toArray
54 | val result = 9
55 | val patterns = 10
56 | val encoded = 11
57 | }
58 |
59 | lazy val blankPattern = AE2Defs.materials.blankPattern()
60 | lazy val encodedPattern = AE2Defs.items.encodedPattern().maybeItem().get()
61 |
62 | def getRecipe = slots.recipe map getStackInSlot
63 |
64 | def getResult = getStackInSlot(slots.result)
65 |
66 | override def markDirty() {
67 | if (!world.isRemote)
68 | inv(slots.encoded) = encodePattern() // direct to prevent an infinite recursion
69 | super.markDirty()
70 | }
71 |
72 | def encodePattern(): ItemStack = {
73 | if (getResult.isEmpty || getRecipe.forall(_.isEmpty) || getStackInSlot(slots.patterns).isEmpty)
74 | return ItemStack.EMPTY
75 |
76 | val newStack = new ItemStack(encodedPattern)
77 |
78 | newStack.setTagCompound(
79 | NBT(
80 | "in" -> getRecipe.map(x =>
81 | if (x.isEmpty)
82 | new NBTTagCompound
83 | else
84 | NBT.from(x.writeToNBT)
85 | ).toList,
86 | "out" -> List(getResult),
87 | "crafting" -> true,
88 | "substitute" -> true
89 | )
90 | )
91 |
92 | newStack
93 | }
94 |
95 | def findMatchingRecipeStack(stacks: Iterable[ItemStack]): ItemStack = {
96 | import scala.collection.JavaConversions._
97 |
98 | // This is a hack to fix various borked NEI handlers, e.g. IC2
99 | var allStacks = stacks
100 | for (x <- stacks if x.getItemDamage == OreDictionary.WILDCARD_VALUE && x.getMaxDamage < x.getItemDamage) {
101 | val toAdd = NonNullList.create[ItemStack]
102 | x.getItem.getSubItems(null, toAdd)
103 | allStacks = toAdd.toList ++ allStacks
104 | }
105 |
106 | val channel = AEApi.instance().storage().getStorageChannel[IAEItemStack, IItemStorageChannel](classOf[IItemStorageChannel])
107 | val storage = node.getGrid.getCache[IStorageGrid](classOf[IStorageGrid]).getInventory(channel).getStorageList
108 |
109 | for {
110 | stack <- allStacks
111 | found <- Option(storage.findPrecise(channel.createStack(stack)))
112 | } {
113 | val stack = found.createItemStack()
114 | stack.setCount(1)
115 | return stack
116 | }
117 |
118 | // Get the first variant if we can't find any matches
119 | allStacks.head
120 | }
121 |
122 | override def afterTileBreakSave(t: NBTTagCompound): NBTTagCompound = {
123 | t.removeTag("ae_node")
124 | t
125 | }
126 |
127 | // Inventory stuff
128 |
129 | allowSided = true
130 | override def canExtractItem(slot: Int, stack: ItemStack, side: EnumFacing) = false
131 | override def getSlotsForFace(side: EnumFacing): Array[Int] = Array(slots.patterns)
132 | override def isItemValidForSlot(slot: Int, stack: ItemStack) =
133 | slot == slots.patterns && blankPattern.isSameAs(stack)
134 |
135 | override def getMachineRepresentation = new ItemStack(BlockEncoder)
136 | override def getIdlePowerUsage = MachineEncoder.idlePowerDraw
137 |
138 | @MENetworkEventSubscribe
139 | def networkPowerStatusChange(ev: MENetworkPowerStatusChange): Unit = {
140 | BlockEncoder.setActive(world, pos, node.isActive)
141 | }
142 |
143 | override def shouldRefresh(world: World, pos: BlockPos, oldState: IBlockState, newSate: IBlockState): Boolean = newSate.getBlock != BlockEncoder
144 | }
145 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/encoder/slots.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.encoder
28 |
29 | import net.bdew.lib.gui.SlotClickable
30 | import net.bdew.lib.items.ItemUtils
31 | import net.minecraft.entity.player.EntityPlayer
32 | import net.minecraft.inventory.{ClickType, IInventory, Slot}
33 | import net.minecraft.item.ItemStack
34 |
35 | class SlotFakeCrafting(inv: IInventory, slot: Int, x: Int, y: Int, onChanged: () => Unit) extends Slot(inv, slot, x, y) with SlotClickable {
36 | override def canTakeStack(p: EntityPlayer) = false
37 |
38 | override def onClick(clickType: ClickType, button: Int, player: EntityPlayer): ItemStack = {
39 | val newStack = if (!player.inventory.getItemStack.isEmpty) {
40 | val stackCopy = player.inventory.getItemStack.copy()
41 | stackCopy.setCount(1)
42 | stackCopy
43 | } else {
44 | ItemStack.EMPTY
45 | }
46 |
47 | if (!ItemStack.areItemStacksEqual(newStack, inventory.getStackInSlot(slot))) {
48 | inventory.setInventorySlotContents(slot, newStack)
49 | onChanged()
50 | }
51 |
52 | player.inventory.getItemStack
53 | }
54 | }
55 |
56 | class SlotFakeCraftingResult(inv: IInventory, slot: Int, x: Int, y: Int) extends Slot(inv, slot, x, y) {
57 | override def canTakeStack(p: EntityPlayer) = false
58 | override def isItemValid(s: ItemStack) = false
59 | }
60 |
61 | class SlotFakeEncodedPattern(inv: TileEncoder, slot: Int, x: Int, y: Int) extends Slot(inv, slot, x, y) with SlotClickable {
62 |
63 | override def onClick(clickType: ClickType, button: Int, player: EntityPlayer): ItemStack = {
64 | val encoded = inv.getStackInSlot(slot)
65 | if (!encoded.isEmpty) {
66 | if (clickType == ClickType.PICKUP) {
67 | if (player.inventory.getItemStack.isEmpty) {
68 | player.inventory.setItemStack(encoded.copy())
69 | inv.decrStackSize(inv.slots.patterns, 1)
70 | }
71 | } else if (clickType == ClickType.QUICK_MOVE) {
72 | if (ItemUtils.addStackToSlots(encoded.copy(), player.inventory, 0 until player.inventory.getSizeInventory, true).isEmpty)
73 | inv.decrStackSize(inv.slots.patterns, 1)
74 | }
75 | }
76 | player.inventory.getItemStack
77 | }
78 | }
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/grower/BlockGrower.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.grower
28 |
29 | import net.bdew.ae2stuff.AE2Stuff
30 | import net.bdew.ae2stuff.misc.{BlockActiveTexture, BlockWrenchable, MachineMaterial}
31 | import net.bdew.lib.block.{BaseBlock, BlockKeepData, HasTE}
32 | import net.minecraft.block.state.IBlockState
33 | import net.minecraft.entity.EntityLivingBase
34 | import net.minecraft.entity.player.EntityPlayer
35 | import net.minecraft.item.ItemStack
36 | import net.minecraft.util.math.BlockPos
37 | import net.minecraft.util.{EnumFacing, EnumHand}
38 | import net.minecraft.world.World
39 |
40 | object BlockGrower extends BaseBlock("grower", MachineMaterial) with HasTE[TileGrower] with BlockKeepData with BlockWrenchable with BlockActiveTexture {
41 | override val TEClass = classOf[TileGrower]
42 |
43 | setHardness(1)
44 |
45 | override def onBlockActivatedReal(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, hand: EnumHand, heldItem: ItemStack, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean = {
46 | player.openGui(AE2Stuff, MachineGrower.guiId, world, pos.getX, pos.getY, pos.getZ)
47 | true
48 | }
49 |
50 | override def onBlockPlacedBy(world: World, pos: BlockPos, state: IBlockState, placer: EntityLivingBase, stack: ItemStack): Unit = {
51 | super.onBlockPlacedBy(world, pos, state, placer, stack)
52 | if (placer.isInstanceOf[EntityPlayer])
53 | getTE(world, pos).placingPlayer = placer.asInstanceOf[EntityPlayer]
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/grower/ContainerGrower.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.grower
28 |
29 | import net.bdew.ae2stuff.misc.ContainerUpgradeable
30 | import net.bdew.lib.data.base.ContainerDataSlots
31 | import net.bdew.lib.gui.{BaseContainer, SlotValidating}
32 | import net.minecraft.entity.player.EntityPlayer
33 |
34 | class ContainerGrower(te: TileGrower, player: EntityPlayer) extends BaseContainer(te) with ContainerDataSlots with ContainerUpgradeable {
35 | override lazy val dataSource = te
36 |
37 | for (y <- 0 until 3; x <- 0 until 9)
38 | this.addSlotToContainer(new SlotValidating(te, x + y * 9, 8 + x * 18, 17 + y * 18))
39 |
40 | for (i <- 0 until te.upgrades.getSizeInventory())
41 | addSlotToContainer(new SlotValidating(te.upgrades, i, 187, 8 + i * 18))
42 |
43 | bindPlayerInventory(player.inventory, 8, 84, 142)
44 |
45 | initUpgradeable(te, te.upgrades, player, 186, 94, addSlotToContainer)
46 | }
47 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/grower/GuiGrower.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.grower
28 |
29 | import net.bdew.ae2stuff.{AE2Stuff, AE2Textures}
30 | import net.bdew.lib.Misc
31 | import net.bdew.lib.gui._
32 | import net.bdew.lib.gui.widgets.WidgetLabel
33 |
34 | class GuiGrower(cont: ContainerGrower) extends BaseScreen(cont, if (cont.hasToolbox) 246 else 211, 166) {
35 | override val background = Texture(AE2Stuff.modId, "textures/gui/grower.png", rect)
36 | val upgradesRect = new Rect(179, 0, 32, 68)
37 | val toolBoxRect = new Rect(178, 86, 68, 68)
38 | override def initGui() {
39 | super.initGui()
40 | widgets.add(new WidgetLabel(BlockGrower.getLocalizedName, 8, 6, Color.darkGray))
41 | widgets.add(new WidgetLabel(Misc.toLocal("container.inventory"), 8, this.ySize - 96 + 3, Color.darkGray))
42 | }
43 |
44 | override protected def drawGuiContainerBackgroundLayer(f: Float, x: Int, y: Int): Unit = {
45 | super.drawGuiContainerBackgroundLayer(f, x, y)
46 | widgets.drawTexture(upgradesRect + rect.origin, AE2Textures.upgradesBackground3)
47 | if (cont.hasToolbox)
48 | widgets.drawTexture(toolBoxRect + rect.origin, AE2Textures.toolBoxBackground)
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/grower/MachineGrower.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.grower
28 |
29 | import appeng.api.config.Upgrades
30 | import net.bdew.ae2stuff.AE2Stuff
31 | import net.bdew.lib.gui.GuiProvider
32 | import net.bdew.lib.machine.{Machine, PoweredMachine}
33 | import net.minecraft.entity.player.EntityPlayer
34 | import net.minecraft.item.ItemStack
35 | import net.minecraftforge.fml.relauncher.{Side, SideOnly}
36 |
37 | object MachineGrower extends Machine("Grower", BlockGrower) with GuiProvider with PoweredMachine {
38 | override def guiId = 2
39 | override type TEClass = TileGrower
40 |
41 | lazy val idlePowerDraw = tuning.getDouble("IdlePower")
42 | lazy val cyclePower = tuning.getDouble("CyclePower")
43 | lazy val cycleTicks = tuning.getInt("CycleTicks")
44 | lazy val powerCapacity = tuning.getDouble("PowerCapacity")
45 |
46 | AE2Stuff.onPostInit.listen { ev =>
47 | // Can't do this too early, causes error
48 | Upgrades.SPEED.registerItem(new ItemStack(BlockGrower), 3)
49 | }
50 |
51 | @SideOnly(Side.CLIENT)
52 | override def getGui(te: TEClass, player: EntityPlayer) = new GuiGrower(new ContainerGrower(te, player))
53 | override def getContainer(te: TEClass, player: EntityPlayer) = new ContainerGrower(te, player)
54 | }
55 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/grower/TileGrower.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.grower
28 |
29 | import appeng.api.config.Upgrades
30 | import appeng.api.implementations.items.IGrowableCrystal
31 | import appeng.api.networking.GridNotification
32 | import net.bdew.ae2stuff.AE2Defs
33 | import net.bdew.ae2stuff.grid.{GridTile, PoweredTile}
34 | import net.bdew.ae2stuff.misc.UpgradeInventory
35 | import net.bdew.lib.block.TileKeepData
36 | import net.bdew.lib.data.base.TileDataSlots
37 | import net.bdew.lib.items.ItemUtils
38 | import net.bdew.lib.tile.inventory.{PersistentInventoryTile, SidedInventory}
39 | import net.minecraft.block.state.IBlockState
40 | import net.minecraft.init.Items
41 | import net.minecraft.item.ItemStack
42 | import net.minecraft.nbt.NBTTagCompound
43 | import net.minecraft.util.EnumFacing
44 | import net.minecraft.util.math.BlockPos
45 | import net.minecraft.world.World
46 |
47 | class TileGrower extends TileDataSlots with GridTile with SidedInventory with PersistentInventoryTile with PoweredTile with TileKeepData {
48 | override def getSizeInventory = 3 * 9
49 | override def getMachineRepresentation = new ItemStack(BlockGrower)
50 | override def powerCapacity = MachineGrower.powerCapacity
51 |
52 | val upgrades = new UpgradeInventory("upgrades", this, 3, Set(Upgrades.SPEED))
53 |
54 | val redstoneDust = Items.REDSTONE
55 | val netherQuartz = Items.QUARTZ
56 | val crystal = AE2Defs.items.crystalSeed.maybeItem().get().asInstanceOf[IGrowableCrystal]
57 | val chargedCertusQuartz = AE2Defs.materials.certusQuartzCrystalCharged()
58 | val fluixCrystal = AE2Defs.materials.fluixCrystal
59 |
60 | serverTick.listen(() => {
61 | if (world.getTotalWorldTime % MachineGrower.cycleTicks == 0 && isAwake) {
62 | var hadWork = false
63 | val needPower = MachineGrower.cyclePower * (1 + upgrades.cards(Upgrades.SPEED))
64 | if (powerStored >= needPower) {
65 | val invZipped = inv.zipWithIndex.filterNot(_._1.isEmpty)
66 | for ((stack, slot) <- invZipped if stack.getItem.isInstanceOf[IGrowableCrystal]) {
67 | var ns = stack
68 | for (i <- 0 to upgrades.cards(Upgrades.SPEED) if stack.getItem.isInstanceOf[IGrowableCrystal])
69 | ns = stack.getItem.asInstanceOf[IGrowableCrystal].triggerGrowth(stack)
70 | setInventorySlotContents(slot, ns)
71 | hadWork = true
72 | }
73 | for {
74 | (cert, certPos) <- invZipped.find(x => chargedCertusQuartz.isSameAs(x._1))
75 | redstonePos <- ItemUtils.findItemInInventory(this, redstoneDust)
76 | netherPos <- ItemUtils.findItemInInventory(this, netherQuartz)
77 | (_, empty) <- inv.zipWithIndex.find(x => x._1.isEmpty || (fluixCrystal.isSameAs(x._1) && x._1.getCount <= x._1.getMaxStackSize - 2))
78 | } {
79 | decrStackSize(certPos, 1)
80 | decrStackSize(netherPos, 1)
81 | decrStackSize(redstonePos, 1)
82 | ItemUtils.addStackToSlots(fluixCrystal.maybeStack(2).get(), this, 0 until getSizeInventory, false)
83 | hadWork = true
84 | }
85 | }
86 | if (hadWork) {
87 | powerStored -= needPower
88 | } else {
89 | sleep()
90 | }
91 | requestPowerIfNeeded()
92 | }
93 | })
94 |
95 | override def afterTileBreakSave(t: NBTTagCompound): NBTTagCompound = {
96 | t.removeTag("ae_node")
97 | t
98 | }
99 |
100 | override def onGridNotification(p1: GridNotification): Unit = {
101 | wakeup()
102 | }
103 |
104 | override def markDirty(): Unit = {
105 | wakeup()
106 | super.markDirty()
107 | }
108 |
109 | allowSided = true
110 |
111 | override def getIdlePowerUsage = MachineGrower.idlePowerDraw
112 |
113 | override def isItemValidForSlot(slot: Int, stack: ItemStack) =
114 | !stack.isEmpty && (
115 | stack.getItem.isInstanceOf[IGrowableCrystal]
116 | || stack.getItem == netherQuartz
117 | || stack.getItem == redstoneDust
118 | || chargedCertusQuartz.isSameAs(stack)
119 | )
120 |
121 | override def canExtractItem(slot: Int, stack: ItemStack, side: EnumFacing) = !isItemValidForSlot(slot, stack)
122 |
123 | override def shouldRefresh(world: World, pos: BlockPos, oldState: IBlockState, newSate: IBlockState): Boolean = newSate.getBlock != BlockGrower
124 |
125 | onWake.listen(() => BlockGrower.setActive(world, pos, true))
126 | onSleep.listen(() => BlockGrower.setActive(world, pos, false))
127 | }
128 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/inscriber/BlockInscriber.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.inscriber
28 |
29 | import net.bdew.ae2stuff.AE2Stuff
30 | import net.bdew.ae2stuff.misc.{BlockActiveTexture, BlockWrenchable, MachineMaterial}
31 | import net.bdew.lib.block.{BaseBlock, BlockKeepData, HasTE}
32 | import net.minecraft.block.state.IBlockState
33 | import net.minecraft.entity.EntityLivingBase
34 | import net.minecraft.entity.player.EntityPlayer
35 | import net.minecraft.item.ItemStack
36 | import net.minecraft.util.math.BlockPos
37 | import net.minecraft.util.{EnumFacing, EnumHand}
38 | import net.minecraft.world.World
39 |
40 | object BlockInscriber extends BaseBlock("inscriber", MachineMaterial) with HasTE[TileInscriber] with BlockKeepData with BlockWrenchable with BlockActiveTexture {
41 | override val TEClass = classOf[TileInscriber]
42 |
43 | setHardness(1)
44 |
45 | override def onBlockActivatedReal(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, hand: EnumHand, heldItem: ItemStack, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean = {
46 | player.openGui(AE2Stuff, MachineInscriber.guiId, world, pos.getX, pos.getY, pos.getZ)
47 | true
48 | }
49 |
50 | override def onBlockPlacedBy(world: World, pos: BlockPos, state: IBlockState, placer: EntityLivingBase, stack: ItemStack): Unit = {
51 | super.onBlockPlacedBy(world, pos, state, placer, stack)
52 | if (placer.isInstanceOf[EntityPlayer])
53 | getTE(world, pos).placingPlayer = placer.asInstanceOf[EntityPlayer]
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/inscriber/ContainerInscriber.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.inscriber
28 |
29 | import net.bdew.ae2stuff.misc.ContainerUpgradeable
30 | import net.bdew.lib.data.base.ContainerDataSlots
31 | import net.bdew.lib.gui.{BaseContainer, SlotValidating}
32 | import net.minecraft.entity.player.EntityPlayer
33 |
34 | class ContainerInscriber(val te: TileInscriber, player: EntityPlayer) extends BaseContainer(te) with ContainerDataSlots with ContainerUpgradeable {
35 | override lazy val dataSource = te
36 |
37 | addSlotToContainer(new SlotValidating(te, te.slots.top, 45, 16))
38 | addSlotToContainer(new SlotValidating(te, te.slots.middle, 63, 39))
39 | addSlotToContainer(new SlotValidating(te, te.slots.bottom, 45, 62))
40 | addSlotToContainer(new SlotValidating(te, te.slots.output, 113, 40))
41 |
42 | for (i <- 0 until te.upgrades.getSizeInventory())
43 | addSlotToContainer(new SlotValidating(te.upgrades, i, 187, 8 + i * 18))
44 |
45 | bindPlayerInventory(player.inventory, 8, 94, 152)
46 |
47 | initUpgradeable(te, te.upgrades, player, 186, 113, addSlotToContainer)
48 | }
49 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/inscriber/GuiInscriber.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.inscriber
28 |
29 | import net.bdew.ae2stuff.AE2Textures
30 | import net.bdew.ae2stuff.misc.WidgetSlotLock
31 | import net.bdew.lib.Misc
32 | import net.bdew.lib.gui._
33 | import net.bdew.lib.gui.widgets.{WidgetFillDataSlot, WidgetLabel}
34 |
35 | import scala.collection.mutable
36 |
37 | class GuiInscriber(cont: ContainerInscriber) extends BaseScreen(cont, if (cont.hasToolbox) 246 else 211, 176) {
38 | override def rect = new Rect(guiLeft, guiTop, 176, 176)
39 | override val background = AE2Textures.inscriberBackground
40 |
41 | val upgradesRect = new Rect(179, 0, 32, 104)
42 | val toolBoxRect = new Rect(178, 105, 68, 68)
43 |
44 | override def initGui() {
45 | super.initGui()
46 | widgets.add(new WidgetLabel(BlockInscriber.getLocalizedName, 8, 6, Color.darkGray))
47 | widgets.add(new WidgetLabel(Misc.toLocal("container.inventory"), 8, this.ySize - 96 + 3, Color.darkGray))
48 | widgets.add(new WidgetFillDataSlot(new Rect(135, 39, 6, 18), AE2Textures.inscriberProgress, Direction.UP, cont.te.progress, 1F) {
49 | override def handleTooltip(p: Point, tip: mutable.MutableList[String]) = tip += "%.0f".format(cont.te.progress * 100) + "%"
50 | })
51 | widgets.add(WidgetSlotLock(Rect(45 - 11, 16 + 4, 8, 8), cont.te.topLocked, "top"))
52 | widgets.add(WidgetSlotLock(Rect(45 - 11, 62 + 4, 8, 8), cont.te.bottomLocked, "bottom"))
53 | }
54 |
55 | override protected def drawGuiContainerBackgroundLayer(f: Float, x: Int, y: Int): Unit = {
56 | super.drawGuiContainerBackgroundLayer(f, x, y)
57 | widgets.drawTexture(upgradesRect + rect.origin, AE2Textures.upgradesBackground5)
58 | if (cont.hasToolbox)
59 | widgets.drawTexture(toolBoxRect + rect.origin, AE2Textures.toolBoxBackground)
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/inscriber/MachineInscriber.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.inscriber
28 |
29 | import appeng.api.config.Upgrades
30 | import net.bdew.ae2stuff.AE2Stuff
31 | import net.bdew.ae2stuff.network.{MsgSetLock, NetHandler}
32 | import net.bdew.lib.Misc
33 | import net.bdew.lib.gui.GuiProvider
34 | import net.bdew.lib.machine.Machine
35 | import net.minecraft.entity.player.EntityPlayer
36 | import net.minecraft.item.ItemStack
37 | import net.minecraftforge.fml.relauncher.{Side, SideOnly}
38 |
39 | object MachineInscriber extends Machine("Inscriber", BlockInscriber) with GuiProvider {
40 | override def guiId = 3
41 | override type TEClass = TileInscriber
42 |
43 | lazy val idlePowerDraw = tuning.getDouble("IdlePower")
44 | lazy val cyclePower = tuning.getDouble("CyclePower")
45 | lazy val powerCapacity = tuning.getDouble("PowerCapacity")
46 | lazy val cycleTicks = tuning.getInt("CycleTicks")
47 |
48 | AE2Stuff.onPostInit.listen { ev =>
49 | // Can't do this too early, causes error
50 | Upgrades.SPEED.registerItem(new ItemStack(BlockInscriber), 5)
51 | }
52 |
53 | NetHandler.regServerHandler {
54 | case (MsgSetLock(slot, lock), player) =>
55 | Misc.asInstanceOpt(player.openContainer, classOf[ContainerInscriber]).foreach { cont =>
56 | slot match {
57 | case "top" => cont.te.topLocked := lock
58 | case "bottom" => cont.te.bottomLocked := lock
59 | case _ => sys.error("Invalid slot")
60 | }
61 | }
62 | }
63 |
64 | @SideOnly(Side.CLIENT)
65 | override def getGui(te: TEClass, player: EntityPlayer) = new GuiInscriber(new ContainerInscriber(te, player))
66 | override def getContainer(te: TEClass, player: EntityPlayer) = new ContainerInscriber(te, player)
67 | }
68 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/wireless/BlockWireless.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.wireless
28 |
29 | import net.bdew.ae2stuff.misc.{BlockActiveTexture, BlockWrenchable, MachineMaterial}
30 | import net.bdew.lib.block.{BaseBlock, HasTE}
31 | import net.minecraft.block.state.IBlockState
32 | import net.minecraft.entity.EntityLivingBase
33 | import net.minecraft.entity.player.EntityPlayer
34 | import net.minecraft.item.ItemStack
35 | import net.minecraft.util.math.BlockPos
36 | import net.minecraft.util.{EnumFacing, EnumHand}
37 | import net.minecraft.world.World
38 |
39 | object BlockWireless extends BaseBlock("wireless", MachineMaterial) with HasTE[TileWireless] with BlockWrenchable with BlockActiveTexture {
40 | override val TEClass = classOf[TileWireless]
41 |
42 | setHardness(1)
43 |
44 | override def onBlockActivatedReal(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, hand: EnumHand, heldItem: ItemStack, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean = false
45 |
46 | override def breakBlock(world: World, pos: BlockPos, state: IBlockState): Unit = {
47 | getTE(world, pos).doUnlink()
48 | super.breakBlock(world, pos, state)
49 | }
50 |
51 | override def onBlockPlacedBy(world: World, pos: BlockPos, state: IBlockState, placer: EntityLivingBase, stack: ItemStack): Unit = {
52 | super.onBlockPlacedBy(world, pos, state, placer, stack)
53 | if (placer.isInstanceOf[EntityPlayer])
54 | getTE(world, pos).placingPlayer = placer.asInstanceOf[EntityPlayer]
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/wireless/MachineWireless.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.wireless
28 |
29 | import net.bdew.lib.machine.Machine
30 |
31 | object MachineWireless extends Machine("Wireless", BlockWireless) {
32 | lazy val powerBase = tuning.getDouble("PowerBase")
33 | lazy val powerDistanceMultiplier = tuning.getDouble("PowerDistanceMultiplier")
34 | }
35 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/wireless/TileWireless.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.wireless
28 |
29 | import java.util
30 |
31 | import appeng.api.AEApi
32 | import appeng.api.networking.{GridFlags, IGridConnection}
33 | import net.bdew.ae2stuff.AE2Stuff
34 | import net.bdew.ae2stuff.grid.{GridTile, VariableIdlePower}
35 | import net.bdew.lib.PimpVanilla._
36 | import net.bdew.lib.data.base.{TileDataSlots, UpdateKind}
37 | import net.bdew.lib.multiblock.data.DataSlotPos
38 | import net.minecraft.block.state.IBlockState
39 | import net.minecraft.item.ItemStack
40 | import net.minecraft.util.math.BlockPos
41 | import net.minecraft.world.World
42 |
43 | class TileWireless extends TileDataSlots with GridTile with VariableIdlePower {
44 | val cfg = MachineWireless
45 |
46 | val link = DataSlotPos("link", this).setUpdate(UpdateKind.SAVE, UpdateKind.WORLD)
47 |
48 | var connection: IGridConnection = null
49 |
50 | def isLinked = link.isDefined
51 | def getLink = link flatMap world.getTileSafe[TileWireless]
52 |
53 | override def getFlags = util.EnumSet.of(GridFlags.DENSE_CAPACITY)
54 |
55 | serverTick.listen(() => {
56 | if (connection == null && link.isDefined) {
57 | setupConnection()
58 | }
59 | })
60 |
61 | def doLink(other: TileWireless): Boolean = {
62 | if (other.link.isEmpty) {
63 | other.link.set(pos)
64 | link.set(other.getPos)
65 | setupConnection()
66 | } else false
67 | }
68 |
69 | def doUnlink(): Unit = {
70 | breakConnection()
71 | getLink foreach { that =>
72 | this.link := None
73 | that.link := None
74 | }
75 | }
76 |
77 | def setupConnection(): Boolean = {
78 | getLink foreach { that =>
79 | try {
80 | connection = AEApi.instance().grid().createGridConnection(this.getNode, that.getNode)
81 | that.connection = connection
82 | val power = cfg.powerBase + cfg.powerDistanceMultiplier * this.pos.distanceSq(that.pos)
83 | this.setIdlePowerUse(power)
84 | that.setIdlePowerUse(power)
85 | BlockWireless.setActive(world, pos, true)
86 | BlockWireless.setActive(world, that.getPos, true)
87 | return true
88 | } catch {
89 | case t: Exception =>
90 | AE2Stuff.logWarnException("Failed setting up wireless link %s <-> %s", t, pos, that.getPos)
91 | doUnlink()
92 | }
93 | }
94 | false
95 | }
96 |
97 | def breakConnection(): Unit = {
98 | if (connection != null)
99 | connection.destroy()
100 | connection = null
101 | setIdlePowerUse(0D)
102 | getLink foreach { other =>
103 | other.connection = null
104 | other.setIdlePowerUse(0D)
105 | BlockWireless.setActive(world, other.getPos, false)
106 | }
107 | BlockWireless.setActive(world, pos, false)
108 | }
109 |
110 | override def getMachineRepresentation: ItemStack = new ItemStack(BlockWireless)
111 |
112 | override def shouldRefresh(world: World, pos: BlockPos, oldState: IBlockState, newSate: IBlockState): Boolean = newSate.getBlock != BlockWireless
113 | }
114 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/machines/wireless/WirelessOverlayRender.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.machines.wireless
28 |
29 | import net.bdew.ae2stuff.misc.WorldOverlayRenderer
30 | import net.bdew.lib.Client
31 | import net.bdew.lib.PimpVanilla._
32 | import net.minecraft.util.math.RayTraceResult
33 | import org.lwjgl.opengl.GL11
34 |
35 | object WirelessOverlayRender extends WorldOverlayRenderer {
36 | override def doRender(partialTicks: Float): Unit = {
37 | val mop = Client.minecraft.objectMouseOver
38 | if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
39 | val pos = mop.getBlockPos
40 | for {
41 | tile <- Client.world.getTileSafe[TileWireless](pos)
42 | other <- tile.link.value
43 | } {
44 | GL11.glPushAttrib(GL11.GL_ENABLE_BIT)
45 |
46 | GL11.glDisable(GL11.GL_LIGHTING)
47 | GL11.glDisable(GL11.GL_TEXTURE_2D)
48 | GL11.glDisable(GL11.GL_DEPTH_TEST)
49 | GL11.glEnable(GL11.GL_LINE_SMOOTH)
50 | GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST)
51 | GL11.glLineWidth(4.0F)
52 |
53 | GL11.glBegin(GL11.GL_LINES)
54 | GL11.glColor3f(0, 0, 1)
55 | GL11.glVertex3d(pos.getX + 0.5D, pos.getY + 0.5D, pos.getZ + 0.5D)
56 | GL11.glVertex3d(other.getX + 0.5D, other.getY + 0.5D, other.getZ + 0.5D)
57 | GL11.glEnd()
58 |
59 | GL11.glPopAttrib()
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/misc/BlockActiveTexture.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.misc
28 |
29 | import net.bdew.lib.block.BaseBlock
30 | import net.minecraft.block.properties.{IProperty, PropertyBool}
31 | import net.minecraft.block.state.IBlockState
32 | import net.minecraft.util.math.BlockPos
33 | import net.minecraft.world.{IBlockAccess, World}
34 |
35 | object BlockActiveTexture {
36 | val Active = PropertyBool.create("active")
37 | }
38 |
39 | trait BlockActiveTexture extends BaseBlock {
40 | override def getProperties: List[IProperty[_]] = super.getProperties :+ BlockActiveTexture.Active
41 |
42 | def isActive(world: IBlockAccess, pos: BlockPos) = world.getBlockState(pos).getValue(BlockActiveTexture.Active)
43 |
44 | def setActive(world: World, pos: BlockPos, v: Boolean) = {
45 | val state = world.getBlockState(pos)
46 | if (state.getBlock == this && state.getValue(BlockActiveTexture.Active) != v)
47 | world.setBlockState(pos, state.withProperty(BlockActiveTexture.Active, Boolean.box(v)), 3)
48 | }
49 |
50 | override def getMetaFromState(state: IBlockState): Int =
51 | if (state.getValue(BlockActiveTexture.Active)) 1 else 0
52 |
53 | //noinspection ScalaDeprecation
54 | override def getStateFromMeta(meta: Int): IBlockState =
55 | if ((meta & 1) == 1)
56 | super.getStateFromMeta(meta).withProperty(BlockActiveTexture.Active, Boolean.box(true))
57 | else
58 | super.getStateFromMeta(meta).withProperty(BlockActiveTexture.Active, Boolean.box(false))
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/misc/BlockWrenchable.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.misc
28 |
29 | import net.bdew.ae2stuff.compat.WrenchRegistry
30 | import net.minecraft.block.Block
31 | import net.minecraft.block.state.IBlockState
32 | import net.minecraft.entity.player.EntityPlayer
33 | import net.minecraft.item.ItemStack
34 | import net.minecraft.util.math.BlockPos
35 | import net.minecraft.util.{EnumFacing, EnumHand}
36 | import net.minecraft.world.World
37 |
38 | trait BlockWrenchable extends Block {
39 | def onBlockActivatedReal(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, hand: EnumHand, heldItem: ItemStack, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean
40 |
41 | override def onBlockActivated(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, hand: EnumHand, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean = {
42 | if (super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ)) return true
43 | if (player.isSneaking) {
44 | for {
45 | stack <- Option(player.inventory.getCurrentItem)
46 | wrench <- WrenchRegistry.findWrench(player, stack, pos)
47 | } {
48 | wrench.doWrench(player, stack, pos)
49 | if (!world.isRemote) world.destroyBlock(pos, true)
50 | return true
51 | }
52 | false
53 | } else {
54 | if (!world.isRemote)
55 | onBlockActivatedReal(world, pos, state, player, hand, player.getHeldItem(hand), side, hitX, hitY, hitZ)
56 | else
57 | true
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/misc/ContainerUpgradeable.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.misc
28 |
29 | import appeng.api.implementations.guiobjects.INetworkTool
30 | import appeng.api.implementations.items.IUpgradeModule
31 | import net.bdew.lib.gui.{BaseContainer, SlotValidating}
32 | import net.bdew.lib.items.ItemUtils
33 | import net.minecraft.entity.player.EntityPlayer
34 | import net.minecraft.inventory.{ClickType, IInventory, Slot}
35 | import net.minecraft.item.ItemStack
36 | import net.minecraft.tileentity.TileEntity
37 |
38 | trait ContainerUpgradeable extends BaseContainer {
39 | var netToolSlot: Option[Int] = None
40 | var netToolObj: Option[INetworkTool] = None
41 | var upgradeInventory: IInventory = null
42 |
43 | def initUpgradeable(te: TileEntity, upgradeInventory: IInventory, player: EntityPlayer, baseX: Int, baseY: Int, astc: (Slot) => Unit): Unit = {
44 | this.upgradeInventory = upgradeInventory
45 | netToolSlot = UpgradeableHelper.findNetworktoolStack(player)
46 | netToolObj = netToolSlot map (x => UpgradeableHelper.getNetworkToolObj(player.inventory.getStackInSlot(x), te))
47 |
48 | netToolObj foreach { nt =>
49 | for (i <- 0 until 3; j <- 0 until 3) {
50 | astc(new SlotValidating(new InventoryHandlerAdapter(nt.getInventory), i + j * 3, baseX + i * 18, baseY + j * 18))
51 | }
52 | }
53 | }
54 |
55 | def hasToolbox = netToolObj.isDefined
56 |
57 | override def transferStackInSlot(player: EntityPlayer, slot: Int): ItemStack = {
58 | val stack = getSlot(slot).getStack
59 | if (netToolObj.contains(getSlot(slot).inventory)) {
60 | // Moving from the net tool - move into upgrades inv
61 | getSlot(slot).putStack(ItemUtils.addStackToSlots(stack, upgradeInventory, 0 until upgradeInventory.getSizeInventory, true))
62 | } else if (!stack.isEmpty && stack.getItem.isInstanceOf[IUpgradeModule] && stack.getItem.asInstanceOf[IUpgradeModule].getType(stack) != null) {
63 | // Is an upgrade
64 | if (getSlot(slot).inventory != upgradeInventory) {
65 | // If it's not in upgrade inventory try to move it there
66 | getSlot(slot).putStack(ItemUtils.addStackToSlots(stack, upgradeInventory, 0 until upgradeInventory.getSizeInventory, true))
67 | } else if (netToolObj.isDefined) {
68 | // Otherwise if we have a network tool, move it there
69 | getSlot(slot).putStack(ItemUtils.addStackToHandler(stack, netToolObj.get.getInventory))
70 | } else {
71 | // Otherwise let the default handler move it to player inventory
72 | super.transferStackInSlot(player, slot)
73 | }
74 | } else {
75 | // Otherwise let the default handler work
76 | super.transferStackInSlot(player, slot)
77 | }
78 | ItemStack.EMPTY
79 | }
80 |
81 | override def slotClick(slotNum: Int, button: Int, clickType: ClickType, player: EntityPlayer): ItemStack = {
82 | if (slotNum > 0 && slotNum < inventorySlots.size() && netToolSlot.isDefined) {
83 | val slot = getSlot(slotNum)
84 | if (slot.isHere(player.inventory, netToolSlot.get))
85 | return ItemStack.EMPTY
86 | }
87 | if (clickType == ClickType.SWAP && netToolSlot.contains(button))
88 | ItemStack.EMPTY
89 | else
90 | super.slotClick(slotNum, button, clickType, player)
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/misc/Icons.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.misc
28 |
29 | import net.bdew.lib.render.IconPreloader
30 |
31 | object Icons extends IconPreloader {
32 | val lockOn = TextureLoc("ae2stuff:icons/lock/on")
33 | val lockOff = TextureLoc("ae2stuff:icons/lock/off")
34 | }
35 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/misc/InventoryHandlerAdapter.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.misc
28 |
29 | import net.minecraft.entity.player.EntityPlayer
30 | import net.minecraft.inventory.IInventory
31 | import net.minecraft.item.ItemStack
32 | import net.minecraft.util.text.TextComponentString
33 | import net.minecraftforge.items.{IItemHandler, IItemHandlerModifiable}
34 |
35 | class InventoryHandlerAdapter(handler: IItemHandler) extends IInventory {
36 | private def allSlots = 0 until handler.getSlots
37 | private def allStacks = allSlots map handler.getStackInSlot
38 |
39 | override def getSizeInventory: Int = handler.getSlots
40 |
41 | override def isEmpty: Boolean = allStacks.forall(_.isEmpty)
42 | override def clear(): Unit = allSlots.foreach(removeStackFromSlot)
43 |
44 | override def getInventoryStackLimit: Int = allSlots.map(handler.getSlotLimit).max
45 |
46 | override def isItemValidForSlot(index: Int, stack: ItemStack): Boolean =
47 | handler.insertItem(index, stack, true).getCount < stack.getCount
48 |
49 | override def getStackInSlot(index: Int): ItemStack = handler.getStackInSlot(index)
50 | override def decrStackSize(index: Int, count: Int): ItemStack = handler.extractItem(index, count, false)
51 | override def removeStackFromSlot(index: Int): ItemStack = handler.extractItem(index, handler.getStackInSlot(index).getCount, false)
52 |
53 | override def setInventorySlotContents(index: Int, stack: ItemStack): Unit = {
54 | handler match {
55 | case x: IItemHandlerModifiable => x.setStackInSlot(index, stack)
56 | case _ =>
57 | removeStackFromSlot(index)
58 | handler.insertItem(index, stack, false)
59 | }
60 | }
61 |
62 | override val getName = ""
63 | override val hasCustomName = false
64 | override val getDisplayName = new TextComponentString("")
65 |
66 | override def getFieldCount = 0
67 | override def getField(id: Int) = throw new UnsupportedOperationException
68 | override def setField(id: Int, value: Int) = throw new UnsupportedOperationException
69 |
70 | override def markDirty() = {}
71 | override def isUsableByPlayer(player: EntityPlayer) = true
72 | override def openInventory(player: EntityPlayer) = {}
73 | override def closeInventory(player: EntityPlayer) = {}
74 | }
75 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/misc/ItemLocationStore.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.misc
28 |
29 | import net.bdew.lib.PimpVanilla._
30 | import net.minecraft.item.{Item, ItemStack}
31 | import net.minecraft.nbt.NBTTagCompound
32 | import net.minecraft.util.math.BlockPos
33 |
34 | trait ItemLocationStore extends Item {
35 | def getLocation(stack: ItemStack) =
36 | if (stack.hasTagCompound)
37 | stack.getTagCompound.get[PosAndDimension]("loc")
38 | else
39 | None
40 |
41 | def setLocation(stack: ItemStack, loc: BlockPos, dimension: Int) = {
42 | if (!stack.hasTagCompound) stack.setTagCompound(new NBTTagCompound)
43 | stack.getTagCompound.set("loc", PosAndDimension(loc, dimension))
44 | }
45 |
46 | def clearLocation(stack: ItemStack) = {
47 | if (stack.hasTagCompound) {
48 | stack.getTagCompound.removeTag("loc")
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/misc/MachineMaterial.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.misc
28 |
29 | import net.minecraft.block.material.{MapColor, Material}
30 |
31 | object MachineMaterial extends Material(MapColor.IRON)
32 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/misc/MouseEventHandler.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.misc
28 |
29 | import net.bdew.ae2stuff.items.visualiser.{ItemVisualiser, VisualisationModes, VisualiserOverlayRender}
30 | import net.bdew.ae2stuff.network.{MsgVisualisationMode, NetHandler}
31 | import net.bdew.lib.{Client, Misc}
32 | import net.minecraftforge.client.event.MouseEvent
33 | import net.minecraftforge.common.MinecraftForge
34 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
35 |
36 | object MouseEventHandler {
37 | def init() {
38 | MinecraftForge.EVENT_BUS.register(this)
39 | }
40 |
41 | @SubscribeEvent
42 | def handleMouseEvent(ev: MouseEvent) {
43 | if (ev.getDwheel == 0) return
44 | if (Client.minecraft.currentScreen != null) return
45 | val player = Client.player
46 | if (player == null || !player.isSneaking) return
47 | val stack = player.inventory.getCurrentItem
48 | if (stack.isEmpty) return
49 | if (stack.getItem == ItemVisualiser) {
50 | val newMode =
51 | if (ev.getDwheel.signum > 0)
52 | Misc.nextInSeq(VisualisationModes.modes, ItemVisualiser.getMode(stack))
53 | else
54 | Misc.prevInSeq(VisualisationModes.modes, ItemVisualiser.getMode(stack))
55 | ItemVisualiser.setMode(stack, newMode)
56 | VisualiserOverlayRender.needListRefresh = true
57 | NetHandler.sendToServer(MsgVisualisationMode(newMode))
58 | ev.setCanceled(true)
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/misc/OverlayRenderHandler.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.misc
28 |
29 | import net.bdew.ae2stuff.AE2Stuff
30 | import net.bdew.lib.Client
31 | import net.minecraft.client.renderer.Tessellator
32 | import net.minecraft.client.renderer.vertex.DefaultVertexFormats
33 | import net.minecraftforge.client.event.RenderWorldLastEvent
34 | import net.minecraftforge.common.MinecraftForge
35 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
36 | import org.lwjgl.opengl.GL11
37 |
38 | trait WorldOverlayRenderer {
39 | def doRender(partialTicks: Float): Unit
40 | }
41 |
42 | object OverlayRenderHandler {
43 | var renderers = List.empty[WorldOverlayRenderer]
44 | MinecraftForge.EVENT_BUS.register(this)
45 |
46 | def register(r: WorldOverlayRenderer) = renderers +:= r
47 |
48 | @SubscribeEvent
49 | def onRenderWorldLastEvent(ev: RenderWorldLastEvent): Unit = {
50 | val p = Client.player
51 | val dx = p.lastTickPosX + (p.posX - p.lastTickPosX) * ev.getPartialTicks
52 | val dy = p.lastTickPosY + (p.posY - p.lastTickPosY) * ev.getPartialTicks
53 | val dz = p.lastTickPosZ + (p.posZ - p.lastTickPosZ) * ev.getPartialTicks
54 |
55 | GL11.glPushMatrix()
56 | GL11.glTranslated(-dx, -dy, -dz)
57 |
58 | for (renderer <- renderers) {
59 | try {
60 | renderer.doRender(ev.getPartialTicks)
61 | } catch {
62 | case t: Throwable =>
63 | AE2Stuff.logErrorException("Error in overlay renderer %s", t, renderer)
64 | }
65 | }
66 |
67 | GL11.glPopMatrix()
68 | }
69 |
70 | def renderFloatingText(text: String, x: Double, y: Double, z: Double, color: Int): Unit = {
71 | val renderManager = Client.minecraft.getRenderManager
72 | val fontRenderer = Client.fontRenderer
73 | val tessellator = Tessellator.getInstance()
74 |
75 | val scale = 0.027F
76 | GL11.glColor4f(1f, 1f, 1f, 0.5f)
77 | GL11.glPushMatrix()
78 | GL11.glTranslated(x, y, z)
79 | GL11.glNormal3f(0.0F, 1.0F, 0.0F)
80 | GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F)
81 | GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F)
82 | GL11.glScalef(-scale, -scale, scale)
83 | GL11.glDisable(GL11.GL_LIGHTING)
84 | GL11.glDepthMask(false)
85 | GL11.glDisable(GL11.GL_DEPTH_TEST)
86 | GL11.glEnable(GL11.GL_BLEND)
87 | GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA)
88 | GL11.glDisable(GL11.GL_TEXTURE_2D)
89 |
90 | val yOffset = -4
91 | val stringMiddle = fontRenderer.getStringWidth(text) / 2
92 |
93 | val buffer = tessellator.getBuffer
94 | buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR)
95 |
96 | buffer.pos(-stringMiddle - 1, -1 + yOffset, 0.0D).color(0, 0, 0, 0.5f).endVertex()
97 | buffer.pos(-stringMiddle - 1, 8 + yOffset, 0.0D).color(0, 0, 0, 0.5f).endVertex()
98 | buffer.pos(stringMiddle + 1, 8 + yOffset, 0.0D).color(0, 0, 0, 0.5f).endVertex()
99 | buffer.pos(stringMiddle + 1, -1 + yOffset, 0.0D).color(0, 0, 0, 0.5f).endVertex()
100 |
101 | tessellator.draw()
102 |
103 | GL11.glEnable(GL11.GL_TEXTURE_2D)
104 | GL11.glColor4f(1f, 1f, 1f, 0.5f)
105 | fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, color)
106 | GL11.glEnable(GL11.GL_DEPTH_TEST)
107 | GL11.glDepthMask(true)
108 | fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, color)
109 | GL11.glEnable(GL11.GL_LIGHTING)
110 | GL11.glDisable(GL11.GL_BLEND)
111 | GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F)
112 | GL11.glPopMatrix()
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/misc/PosAndDimension.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.misc
28 |
29 | import net.bdew.lib.nbt.Type.TInt
30 | import net.bdew.lib.nbt.{ConvertedType, NBT}
31 | import net.minecraft.nbt.NBTTagCompound
32 | import net.minecraft.util.math.BlockPos
33 |
34 | case class PosAndDimension(pos: BlockPos, dim: Int)
35 |
36 | object PosAndDimension {
37 |
38 | implicit object TPosAndDimension extends ConvertedType[PosAndDimension, NBTTagCompound] {
39 | override def encode(v: PosAndDimension) =
40 | NBT(
41 | "x" -> v.pos.getX,
42 | "y" -> v.pos.getY,
43 | "z" -> v.pos.getZ,
44 | "dim" -> v.dim
45 | )
46 |
47 | override def decode(t: NBTTagCompound) =
48 | if (t.hasKey("x", TInt.id) && t.hasKey("y", TInt.id) && t.hasKey("z", TInt.id) && t.hasKey("dim", TInt.id))
49 | Some(PosAndDimension(new BlockPos(t.getInteger("x"), t.getInteger("y"), t.getInteger("z")), t.getInteger("dim")))
50 | else
51 | None
52 | }
53 |
54 | }
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/misc/UpgradeInventory.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.misc
28 |
29 | import appeng.api.config.Upgrades
30 | import appeng.api.implementations.items.IUpgradeModule
31 | import net.bdew.lib.data.DataSlotInventory
32 | import net.bdew.lib.data.base.{TileDataSlots, UpdateKind}
33 | import net.bdew.lib.items.ItemUtils
34 | import net.minecraft.item.ItemStack
35 | import net.minecraft.nbt.NBTTagCompound
36 |
37 | class UpgradeInventory(name: String, parent: TileDataSlots, size: Int, kinds: Set[Upgrades]) extends DataSlotInventory(name, parent, size) {
38 | override def getInventoryStackLimit() = 1
39 | override def isItemValidForSlot(slot: Int, stack: ItemStack): Boolean =
40 | if (!stack.isEmpty && stack.getItem.isInstanceOf[IUpgradeModule])
41 | kinds.contains(stack.getItem.asInstanceOf[IUpgradeModule].getType(stack))
42 | else false
43 |
44 | var cards = Map.empty[Upgrades, Int].withDefaultValue(0)
45 |
46 | def updateUpgradeCounts() =
47 | cards = inv filter { x =>
48 | !x.isEmpty && x.getItem.isInstanceOf[IUpgradeModule]
49 | } map { x =>
50 | x.getItem.asInstanceOf[IUpgradeModule].getType(x)
51 | } groupBy identity mapValues (_.length) withDefaultValue 0
52 |
53 | override def load(t: NBTTagCompound, kind: UpdateKind.Value): Unit = {
54 | super.load(t, kind)
55 | updateUpgradeCounts()
56 | }
57 |
58 | override def markDirty(): Unit = {
59 | updateUpgradeCounts()
60 | super.markDirty()
61 | }
62 |
63 | def dropInventory(): Unit = {
64 | if (parent.getWorldObject != null && !parent.getWorld.isRemote) {
65 | for (stack <- inv if !stack.isEmpty) {
66 | ItemUtils.throwItemAt(parent.getWorld, parent.getPos, stack)
67 | }
68 | clear()
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/misc/UpgradeableHelper.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.misc
28 |
29 | import appeng.api.implementations.guiobjects.{IGuiItem, INetworkTool}
30 | import net.bdew.ae2stuff.AE2Defs
31 | import net.minecraft.entity.player.EntityPlayer
32 | import net.minecraft.item.ItemStack
33 | import net.minecraft.tileentity.TileEntity
34 |
35 | object UpgradeableHelper {
36 | lazy val networkTool = AE2Defs.items.networkTool()
37 |
38 | def isNetworkTool(is: ItemStack) = networkTool.isSameAs(is)
39 |
40 | def getNetworkToolObj(is: ItemStack, te: TileEntity) =
41 | networkTool.maybeItem().get().asInstanceOf[IGuiItem].getGuiObject(is, te.getWorld, te.getPos).asInstanceOf[INetworkTool]
42 |
43 | def findNetworktoolStack(player: EntityPlayer) = (for {
44 | i <- 0 until player.inventory.getSizeInventory
45 | stack <- Option(player.inventory.getStackInSlot(i))
46 | if UpgradeableHelper.networkTool.isSameAs(stack)
47 | } yield i).headOption
48 | }
49 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/misc/WidgetSlotLock.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.misc
28 |
29 | import net.bdew.ae2stuff.network.{MsgSetLock, NetHandler}
30 | import net.bdew.lib.Misc
31 | import net.bdew.lib.data.DataSlotBoolean
32 | import net.bdew.lib.gui.widgets.Widget
33 | import net.bdew.lib.gui.{Point, Rect}
34 |
35 | import scala.collection.mutable
36 |
37 | case class WidgetSlotLock(rect: Rect, state: DataSlotBoolean, slot: String) extends Widget {
38 | override def draw(mouse: Point, partial: Float): Unit = {
39 | if (state)
40 | parent.drawTexture(rect, Icons.lockOn)
41 | else
42 | parent.drawTexture(rect, Icons.lockOff)
43 | }
44 |
45 | override def handleTooltip(p: Point, tip: mutable.MutableList[String]): Unit = {
46 | if (state) {
47 | tip += Misc.toLocal("ae2stuff.gui.lock.on")
48 | } else {
49 | tip += Misc.toLocal("ae2stuff.gui.lock.off")
50 | tip += Misc.toLocal("ae2stuff.gui.lock.note")
51 | }
52 |
53 | }
54 |
55 | override def mouseClicked(p: Point, button: Int): Unit = {
56 | NetHandler.sendToServer(MsgSetLock(slot, !state))
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/network/NetHandler.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.network
28 |
29 | import net.bdew.ae2stuff.AE2Stuff
30 | import net.bdew.lib.network.NetChannel
31 |
32 | object NetHandler extends NetChannel(AE2Stuff.channel) {
33 | }
34 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/network/packets.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.network
28 |
29 | import net.bdew.ae2stuff.items.visualiser.{VisualisationData, VisualisationModes}
30 | import net.bdew.lib.network.NBTTagCompoundSerialize
31 |
32 | case class MsgSetRecipe(recipe: NBTTagCompoundSerialize) extends NetHandler.Message
33 |
34 | case class MsgSetLock(slot: String, lock: Boolean) extends NetHandler.Message
35 |
36 | case class MsgVisualisationData(data: VisualisationData) extends NetHandler.Message
37 |
38 | case class MsgVisualisationMode(mode: VisualisationModes.Value) extends NetHandler.Message
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/waila/BaseDataProvider.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.waila
28 |
29 | import java.util
30 |
31 | import mcp.mobius.waila.api.{IWailaConfigHandler, IWailaDataAccessor, IWailaDataProvider}
32 | import net.bdew.ae2stuff.AE2Stuff
33 | import net.minecraft.entity.player.EntityPlayerMP
34 | import net.minecraft.item.ItemStack
35 | import net.minecraft.nbt.NBTTagCompound
36 | import net.minecraft.tileentity.TileEntity
37 | import net.minecraft.util.math.BlockPos
38 | import net.minecraft.util.text.TextFormatting
39 | import net.minecraft.world.World
40 |
41 | class BaseDataProvider[T](cls: Class[T]) extends IWailaDataProvider {
42 | def getTailStrings(target: T, stack: ItemStack, acc: IWailaDataAccessor, cfg: IWailaConfigHandler): Iterable[String] = None
43 | def getHeadStrings(target: T, stack: ItemStack, acc: IWailaDataAccessor, cfg: IWailaConfigHandler): Iterable[String] = None
44 | def getBodyStrings(target: T, stack: ItemStack, acc: IWailaDataAccessor, cfg: IWailaConfigHandler): Iterable[String] = None
45 | def getNBTTag(player: EntityPlayerMP, te: T, tag: NBTTagCompound, world: World, pos: BlockPos): NBTTagCompound = tag
46 |
47 | final override def getNBTData(player: EntityPlayerMP, te: TileEntity, tag: NBTTagCompound, world: World, pos: BlockPos): NBTTagCompound =
48 | try {
49 | if (cls.isInstance(te))
50 | getNBTTag(player, te.asInstanceOf[T], tag, world, pos)
51 | else
52 | tag
53 | } catch {
54 | case e: Throwable =>
55 | AE2Stuff.logWarnException("Error in waila handler", e)
56 | tag
57 | }
58 |
59 | import scala.collection.JavaConversions._
60 |
61 | final override def getWailaTail(itemStack: ItemStack, tip: util.List[String], accessor: IWailaDataAccessor, config: IWailaConfigHandler) = {
62 | try {
63 | if (cls.isInstance(accessor.getTileEntity))
64 | tip.addAll(getTailStrings(accessor.getTileEntity.asInstanceOf[T], itemStack, accessor, config))
65 | else if (cls.isInstance(accessor.getBlock))
66 | tip.addAll(getTailStrings(accessor.getBlock.asInstanceOf[T], itemStack, accessor, config))
67 | } catch {
68 | case e: Throwable =>
69 | AE2Stuff.logWarn("Error in waila handler: %s", e.toString)
70 | e.printStackTrace()
71 | tip.add("[%s%s%s]".format(TextFormatting.RED, e.toString, TextFormatting.RESET))
72 | }
73 | tip
74 | }
75 |
76 | final override def getWailaHead(itemStack: ItemStack, tip: util.List[String], accessor: IWailaDataAccessor, config: IWailaConfigHandler) = {
77 | try {
78 | if (cls.isInstance(accessor.getTileEntity))
79 | tip.addAll(getHeadStrings(accessor.getTileEntity.asInstanceOf[T], itemStack, accessor, config))
80 | else if (cls.isInstance(accessor.getBlock))
81 | tip.addAll(getHeadStrings(accessor.getBlock.asInstanceOf[T], itemStack, accessor, config))
82 | } catch {
83 | case e: Throwable =>
84 | AE2Stuff.logWarn("Error in waila handler: %s", e.toString)
85 | e.printStackTrace()
86 | tip.add("[%s%s%s]".format(TextFormatting.RED, e.toString, TextFormatting.RESET))
87 | }
88 | tip
89 | }
90 |
91 | final override def getWailaBody(itemStack: ItemStack, tip: util.List[String], accessor: IWailaDataAccessor, config: IWailaConfigHandler) = {
92 | try {
93 | if (cls.isInstance(accessor.getTileEntity))
94 | tip.addAll(getBodyStrings(accessor.getTileEntity.asInstanceOf[T], itemStack, accessor, config))
95 | else if (cls.isInstance(accessor.getBlock))
96 | tip.addAll(getBodyStrings(accessor.getBlock.asInstanceOf[T], itemStack, accessor, config))
97 | } catch {
98 | case e: Throwable =>
99 | AE2Stuff.logWarn("Error in waila handler: %s", e.toString)
100 | e.printStackTrace()
101 | tip.add("[%s%s%s]".format(TextFormatting.RED, e.toString, TextFormatting.RESET))
102 | }
103 | tip
104 | }
105 |
106 | override def getWailaStack(accessor: IWailaDataAccessor, config: IWailaConfigHandler): ItemStack = ItemStack.EMPTY
107 | }
108 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/waila/WailaHandler.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.waila
28 |
29 | import mcp.mobius.waila.api.IWailaRegistrar
30 | import net.bdew.ae2stuff.AE2Stuff
31 | import net.bdew.ae2stuff.grid.PoweredTile
32 | import net.bdew.ae2stuff.machines.wireless.TileWireless
33 |
34 | object WailaHandler {
35 | def loadCallback(reg: IWailaRegistrar) {
36 | AE2Stuff.logDebug("WAILA callback received, loading...")
37 | reg.registerBodyProvider(WailaPoweredDataProvider, classOf[PoweredTile])
38 | reg.registerNBTProvider(WailaPoweredDataProvider, classOf[PoweredTile])
39 | reg.registerBodyProvider(WailaWirelessDataProvider, classOf[TileWireless])
40 | reg.registerNBTProvider(WailaWirelessDataProvider, classOf[TileWireless])
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/waila/WailaPoweredDataProvider.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.waila
28 |
29 | import mcp.mobius.waila.api.{IWailaConfigHandler, IWailaDataAccessor}
30 | import net.bdew.ae2stuff.grid.PoweredTile
31 | import net.bdew.lib.{DecFormat, Misc}
32 | import net.minecraft.entity.player.EntityPlayerMP
33 | import net.minecraft.item.ItemStack
34 | import net.minecraft.nbt.NBTTagCompound
35 | import net.minecraft.util.math.BlockPos
36 | import net.minecraft.util.text.TextFormatting
37 | import net.minecraft.world.World
38 |
39 | object WailaPoweredDataProvider extends BaseDataProvider(classOf[PoweredTile]) {
40 | override def getNBTTag(player: EntityPlayerMP, te: PoweredTile, tag: NBTTagCompound, world: World, pos: BlockPos): NBTTagCompound = {
41 | tag.setDouble("waila_power_stored", te.powerStored)
42 | tag.setDouble("waila_power_capacity", te.powerCapacity)
43 | tag.setBoolean("waila_power_sleep", te.isSleeping)
44 | tag
45 | }
46 |
47 | override def getBodyStrings(target: PoweredTile, stack: ItemStack, acc: IWailaDataAccessor, cfg: IWailaConfigHandler): Iterable[String] = {
48 | val nbt = acc.getNBTData
49 | if (nbt.hasKey("waila_power_stored")) {
50 | List(
51 | Misc.toLocalF("ae2stuff.waila.power", DecFormat.short(nbt.getDouble("waila_power_stored")), DecFormat.short(nbt.getDouble("waila_power_capacity"))),
52 | if (nbt.getBoolean("waila_power_sleep"))
53 | TextFormatting.RED + Misc.toLocal("ae2stuff.waila.sleep.true") + TextFormatting.RESET
54 | else
55 | TextFormatting.GREEN + Misc.toLocal("ae2stuff.waila.sleep.false") + TextFormatting.RESET
56 | )
57 | } else List.empty
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/net/bdew/ae2stuff/waila/WailaWirelessDataProvider.scala:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) bdew, 2014 - 2020
3 | * https://github.com/bdew/ae2stuff
4 | *
5 | * This mod is distributed under the terms of the MIT License.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in all
15 | * copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | *
25 | */
26 |
27 | package net.bdew.ae2stuff.waila
28 |
29 | import mcp.mobius.waila.api.{IWailaConfigHandler, IWailaDataAccessor}
30 | import net.bdew.ae2stuff.machines.wireless.TileWireless
31 | import net.bdew.lib.PimpVanilla._
32 | import net.bdew.lib.nbt.NBT
33 | import net.bdew.lib.{DecFormat, Misc}
34 | import net.minecraft.entity.player.EntityPlayerMP
35 | import net.minecraft.item.ItemStack
36 | import net.minecraft.nbt.NBTTagCompound
37 | import net.minecraft.util.math.BlockPos
38 | import net.minecraft.world.World
39 |
40 | object WailaWirelessDataProvider extends BaseDataProvider(classOf[TileWireless]) {
41 | override def getNBTTag(player: EntityPlayerMP, te: TileWireless, tag: NBTTagCompound, world: World, pos: BlockPos): NBTTagCompound = {
42 | tag.setTag("wireless_waila",
43 | te.link map (link => NBT(
44 | "connected" -> true,
45 | "target" -> link,
46 | "channels" -> (if (te.connection != null) te.connection.getUsedChannels else 0),
47 | "power" -> te.getIdlePowerUsage
48 | )) getOrElse NBT("connected" -> false)
49 | )
50 | tag
51 | }
52 |
53 | override def getBodyStrings(target: TileWireless, stack: ItemStack, acc: IWailaDataAccessor, cfg: IWailaConfigHandler): Iterable[String] = {
54 | if (acc.getNBTData.hasKey("wireless_waila")) {
55 | val data = acc.getNBTData.getCompoundTag("wireless_waila")
56 | if (data.getBoolean("connected")) {
57 | data.get[BlockPos]("target") map { pos =>
58 | List(
59 | Misc.toLocalF("ae2stuff.waila.wireless.connected", pos.getX, pos.getY, pos.getZ),
60 | Misc.toLocalF("ae2stuff.waila.wireless.channels", data.getInteger("channels")),
61 | Misc.toLocalF("ae2stuff.waila.wireless.power", DecFormat.short(data.getDouble("power")))
62 | )
63 | } getOrElse List(Misc.toLocal("ae2stuff.waila.wireless.notconnected"))
64 | } else {
65 | List(Misc.toLocal("ae2stuff.waila.wireless.notconnected"))
66 | }
67 | } else List.empty
68 | }
69 | }
70 |
--------------------------------------------------------------------------------