mirror of
https://github.com/GTNewHorizons/WirelessCraftingTerminal.git
synced 2026-11-26 06:42:55 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6542d6c9f | ||
|
|
7389db2552 | ||
|
|
2543c8d142 | ||
|
|
b029da08cb | ||
|
|
1c1d1d04a7 | ||
|
|
626b96a91e | ||
|
|
506cf78f4e | ||
|
|
3aa59a3cba | ||
|
|
ee5bfc213d | ||
|
|
c265b71dc3 | ||
|
|
ba49449781 | ||
|
|
89189dbff1 | ||
|
|
eb2e654b52 | ||
|
|
db9977b715 | ||
|
|
978fc5f7c6 | ||
|
|
4c246b7093 | ||
|
|
b8ecbbb567 | ||
|
|
f0978c8e00 | ||
|
|
0c3d47b3aa | ||
|
|
3bf3b800d3 | ||
|
|
d73eccc895 |
No files matched your search
@@ -0,0 +1,19 @@
|
||||
# This is the universal Text Editor Configuration
|
||||
# for all GTNewHorizons projects
|
||||
# See: https://editorconfig.org/
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.{bat,ini}]
|
||||
end_of_line = crlf
|
||||
|
||||
[*.{dtd,json,info,mcmeta,md,sh,svg,xml,xsd,xsl,yaml,yml}]
|
||||
indent_size = 2
|
||||
@@ -1,27 +0,0 @@
|
||||
if [[ -d "run/crash-reports" ]]; then
|
||||
echo "Crash reports detected:"
|
||||
cat $directory/*
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if grep --quiet "Fatal errors were detected" server.log; then
|
||||
echo "Fatal errors detected:"
|
||||
cat server.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if grep --quiet "The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED" server.log; then
|
||||
echo "Server force stopped:"
|
||||
cat server.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if grep --quiet 'Done .+ For help, type "help" or "?"' server.log; then
|
||||
echo "Server didn't finish startup:"
|
||||
cat server.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "No crash reports detected"
|
||||
exit 0
|
||||
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# bashsupport disable=BP5006 # Global environment variables
|
||||
RUNDIR="run" \
|
||||
CRASH="crash-reports" \
|
||||
SERVERLOG="server.log"
|
||||
|
||||
# enable nullglob to get 0 results when no match rather than the pattern
|
||||
shopt -s nullglob
|
||||
|
||||
# store matches in array
|
||||
crash_reports=("$RUNDIR/$CRASH/crash"*.txt)
|
||||
|
||||
# if array not empty there are crash_reports
|
||||
if [ "${#crash_reports[@]}" -gt 0 ]; then
|
||||
# get the latest crash_report from array
|
||||
latest_crash_report="${crash_reports[-1]}"
|
||||
{
|
||||
printf 'Latest crash report detected %s:\n' "${latest_crash_report##*/}"
|
||||
cat "$latest_crash_report"
|
||||
} >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if grep --quiet --fixed-strings 'Fatal errors were detected' "$SERVERLOG"; then
|
||||
{
|
||||
printf 'Fatal errors detected:\n'
|
||||
cat server.log
|
||||
} >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if grep --quiet --fixed-strings 'The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED' \
|
||||
"$SERVERLOG"; then
|
||||
{
|
||||
printf 'Server force stopped:'
|
||||
cat server.log
|
||||
} >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep --quiet --perl-regexp --only-matching '.+Done \(.+\)\! For help, type "help" or "\?"' "$SERVERLOG"; then
|
||||
{
|
||||
printf 'Server did not finish startup:'
|
||||
cat server.log
|
||||
} >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf 'No crash reports detected'
|
||||
exit 0
|
||||
@@ -14,16 +14,16 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: '8'
|
||||
distribution: 'adopt'
|
||||
cache: gradle
|
||||
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
@@ -36,10 +36,10 @@ jobs:
|
||||
- name: Run server for 1.5 minutes
|
||||
run: |
|
||||
mkdir run
|
||||
echo "eula=true" > run/eula.txt
|
||||
timeout 90 ./gradlew runServer | tee --append server.log || true
|
||||
echo "eula=true" > run/eula.txt
|
||||
timeout 90 ./gradlew runServer 2>&1 | tee -a server.log || true
|
||||
|
||||
- name: Test no errors reported during server run
|
||||
run: |
|
||||
chmod +x .github/scripts/test-no-error-reports.sh
|
||||
.github/scripts/test-no-error-reports.sh
|
||||
chmod +x .github/scripts/test_no_error_reports
|
||||
.github/scripts/test_no_error_reports
|
||||
@@ -44,18 +44,8 @@ jobs:
|
||||
title: "${{ env.RELEASE_VERSION }}"
|
||||
files: build/libs/*.jar
|
||||
|
||||
- name: Set repository owner and name
|
||||
run: |
|
||||
echo "REPOSITORY_OWNER=${GITHUB_REPOSITORY%/*}" >> $GITHUB_ENV
|
||||
echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
|
||||
|
||||
- name: Publish package
|
||||
- name: Publish to Maven
|
||||
run: ./gradlew publish
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
ARTIFACT_GROUP_ID: com.github.${{ env.REPOSITORY_OWNER }}
|
||||
ARTIFACT_ID: "${{ env.REPOSITORY_NAME }}"
|
||||
ARTIFACT_VERSION: "${{ env.RELEASE_VERSION }}"
|
||||
REPOSITORY_NAME: "${{ env.REPOSITORY_NAME }}"
|
||||
REPOSITORY_OWNER: "${{ env.REPOSITORY_OWNER }}"
|
||||
|
||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
||||
@@ -0,0 +1,3 @@
|
||||
# Any Github changes require admin approval
|
||||
/.github/** @GTNewHorizons/admin
|
||||
|
||||
@@ -53,10 +53,10 @@ Providing as many details as possible does help us to find and resolve the issue
|
||||
|
||||
## Building
|
||||
|
||||
1. Clone this repository via
|
||||
- SSH `git clone [email protected]:p455w0rd/WirelessCraftingTerminal.git` or
|
||||
1. Clone this repository via
|
||||
- SSH `git clone [email protected]:p455w0rd/WirelessCraftingTerminal.git` or
|
||||
- HTTPS `git clone https://github.com/p455w0rd/WirelessCraftingTerminal.git`
|
||||
2. Setup workspace
|
||||
2. Setup workspace
|
||||
- Decompiled source `gradlew setupDecompWorkspace`
|
||||
- Obfuscated source `gradlew setupDevWorkspace`
|
||||
- CI server `gradlew setupCIWorkspace`
|
||||
@@ -102,7 +102,7 @@ I would love for someone to do translations for me =]
|
||||
## Credits
|
||||
|
||||
Thanks to the following people for support, code, et al
|
||||
|
||||
|
||||
* Code/tutorials/general help: Notch, brandon3055, Techjar, AlgorythmX2, thatsIch, Nividica, squeek502, M3gaFr3ak, DrummerMC, cpw, LexManos, Pahimar, diesieben07, Wuppy, Jabelar, blay09, SirSengir, mezz
|
||||
|
||||
* Contributors: condensedapple, TKH+
|
||||
@@ -0,0 +1,3 @@
|
||||
compileJava {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
+495
-125
@@ -1,50 +1,71 @@
|
||||
//version: 29197fa3cf1ea6ef5c07884a613171d01c026d1d
|
||||
//version: 1656003794
|
||||
/*
|
||||
DO NOT CHANGE THIS FILE!
|
||||
|
||||
Also, you may replace this file at any time if there is an update available.
|
||||
Please check https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/build.gradle for updates.
|
||||
*/
|
||||
Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates.
|
||||
*/
|
||||
|
||||
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.internal.logging.text.StyledTextOutput.Style
|
||||
import org.gradle.internal.logging.text.StyledTextOutputFactory
|
||||
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipInputStream
|
||||
import java.util.zip.ZipOutputStream
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "https://maven.minecraftforge.net"
|
||||
name 'forge'
|
||||
url 'https://maven.minecraftforge.net'
|
||||
}
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
name 'sonatype'
|
||||
url 'https://oss.sonatype.org/content/repositories/snapshots/'
|
||||
}
|
||||
maven {
|
||||
name = "Scala CI dependencies"
|
||||
url = "https://repo1.maven.org/maven2/"
|
||||
name 'Scala CI dependencies'
|
||||
url 'https://repo1.maven.org/maven2/'
|
||||
}
|
||||
maven {
|
||||
name = "jitpack"
|
||||
url = "https://jitpack.io"
|
||||
name 'jitpack'
|
||||
url 'https://jitpack.io'
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.4'
|
||||
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.7'
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'java-library'
|
||||
id 'idea'
|
||||
id 'eclipse'
|
||||
id 'scala'
|
||||
id("org.ajoberstar.grgit") version("3.1.1")
|
||||
id("com.github.johnrengelman.shadow") version("4.0.4")
|
||||
id("com.palantir.git-version") version("0.12.3")
|
||||
id("maven-publish")
|
||||
id 'maven-publish'
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false
|
||||
id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false
|
||||
id 'com.google.devtools.ksp' version '1.5.30-1.0.0' apply false
|
||||
id 'org.ajoberstar.grgit' version '4.1.1'
|
||||
id 'com.github.johnrengelman.shadow' version '4.0.4'
|
||||
id 'com.palantir.git-version' version '0.13.0' apply false
|
||||
id 'de.undercouch.download' version '5.0.1'
|
||||
id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false
|
||||
id "com.diffplug.spotless" version "6.7.2"
|
||||
}
|
||||
|
||||
if (project.file('.git/HEAD').isFile()) {
|
||||
apply plugin: 'com.palantir.git-version'
|
||||
}
|
||||
|
||||
def out = services.get(StyledTextOutputFactory).create('an-output')
|
||||
|
||||
apply plugin: 'forge'
|
||||
|
||||
def projectJavaVersion = JavaLanguageVersion.of(8)
|
||||
@@ -63,6 +84,37 @@ idea {
|
||||
}
|
||||
}
|
||||
|
||||
// Spotless autoformatter
|
||||
// See https://github.com/diffplug/spotless/tree/main/plugin-gradle
|
||||
// Can be locally toggled via spotless:off/spotless:on comments
|
||||
spotless {
|
||||
encoding 'UTF-8'
|
||||
|
||||
format 'misc', {
|
||||
target '*.md', '.gitignore'
|
||||
|
||||
trimTrailingWhitespace()
|
||||
indentWithSpaces(4)
|
||||
endWithNewline()
|
||||
}
|
||||
java {
|
||||
toggleOffOn()
|
||||
importOrder()
|
||||
removeUnusedImports()
|
||||
palantirJavaFormat('1.1.0') // last version supporting jvm 8
|
||||
}
|
||||
kotlin {
|
||||
toggleOffOn()
|
||||
ktfmt('0.39')
|
||||
}
|
||||
groovyGradle {
|
||||
toggleOffOn()
|
||||
importOrder()
|
||||
target '*.gradle'
|
||||
greclipse('4.19.0') // last version supporting jvm 8
|
||||
}
|
||||
}
|
||||
|
||||
if(JavaVersion.current() != JavaVersion.VERSION_1_8) {
|
||||
throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current())
|
||||
}
|
||||
@@ -88,27 +140,35 @@ checkPropertyExists("containsMixinsAndOrCoreModOnly")
|
||||
checkPropertyExists("usesShadowedDependencies")
|
||||
checkPropertyExists("developmentEnvironmentUserName")
|
||||
|
||||
boolean noPublishedSources = project.findProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false
|
||||
boolean usesMixinDebug = project.findProperty('usesMixinDebug') ?: project.usesMixins.toBoolean()
|
||||
String channel = project.findProperty('channel') ? project.channel : 'stable'
|
||||
String mappingsVersion = project.findProperty('mappingsVersion') ? project.mappingsVersion : '12'
|
||||
String remoteMappings = project.findProperty('remoteMappings') ? project.remoteMappings : 'https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/'
|
||||
|
||||
String javaSourceDir = "src/main/java/"
|
||||
String scalaSourceDir = "src/main/scala/"
|
||||
String kotlinSourceDir = "src/main/kotlin/"
|
||||
|
||||
String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/")
|
||||
String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/")
|
||||
if((getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists()) == false) {
|
||||
throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala)
|
||||
String targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/")
|
||||
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
|
||||
throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
|
||||
}
|
||||
|
||||
if(apiPackage) {
|
||||
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
|
||||
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
|
||||
if((getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists()) == false) {
|
||||
throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala)
|
||||
targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
|
||||
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
|
||||
throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
|
||||
}
|
||||
}
|
||||
|
||||
if(accessTransformersFile) {
|
||||
String targetFile = "src/main/resources/META-INF/" + accessTransformersFile
|
||||
if(getFile(targetFile).exists() == false) {
|
||||
if(!getFile(targetFile).exists()) {
|
||||
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
|
||||
}
|
||||
}
|
||||
@@ -120,15 +180,17 @@ if(usesMixins.toBoolean()) {
|
||||
|
||||
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
|
||||
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
|
||||
if((getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists()) == false) {
|
||||
throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala)
|
||||
targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
|
||||
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
|
||||
throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
|
||||
}
|
||||
|
||||
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
|
||||
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala"
|
||||
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
|
||||
if((getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists()) == false) {
|
||||
throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava)
|
||||
String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".kt"
|
||||
if(!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
|
||||
throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,8 +198,9 @@ if(coreModClass) {
|
||||
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
|
||||
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".scala"
|
||||
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
|
||||
if((getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists()) == false) {
|
||||
throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava)
|
||||
String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".kt"
|
||||
if(!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
|
||||
throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,13 +213,35 @@ configurations.all {
|
||||
}
|
||||
|
||||
// Fix Jenkins' Git: chmod a file should not be detected as a change and append a '.dirty' to the version
|
||||
'git config core.fileMode false'.execute()
|
||||
// Pulls version from git tag
|
||||
try {
|
||||
version = minecraftVersion + "-" + gitVersion()
|
||||
'git config core.fileMode false'.execute()
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException("This mod must be version controlled by Git AND the repository must provide at least one tag!");
|
||||
catch (Exception ignored) {
|
||||
out.style(Style.Failure).println("git isn't installed at all")
|
||||
}
|
||||
|
||||
// Pulls version first from the VERSION env and then git tag
|
||||
String identifiedVersion
|
||||
String versionOverride = System.getenv("VERSION") ?: null
|
||||
try {
|
||||
identifiedVersion = versionOverride == null ? gitVersion() : versionOverride
|
||||
}
|
||||
catch (Exception ignored) {
|
||||
out.style(Style.Failure).text(
|
||||
'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' +
|
||||
'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' +
|
||||
'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)'
|
||||
)
|
||||
versionOverride = 'NO-GIT-TAG-SET'
|
||||
identifiedVersion = versionOverride
|
||||
}
|
||||
version = minecraftVersion + '-' + identifiedVersion
|
||||
ext {
|
||||
modVersion = identifiedVersion
|
||||
}
|
||||
|
||||
if(identifiedVersion == versionOverride) {
|
||||
out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7')
|
||||
}
|
||||
|
||||
group = modGroup
|
||||
@@ -167,9 +252,25 @@ else {
|
||||
archivesBaseName = modId
|
||||
}
|
||||
|
||||
def arguments = []
|
||||
def jvmArguments = []
|
||||
|
||||
if (usesMixins.toBoolean()) {
|
||||
arguments += [
|
||||
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
|
||||
]
|
||||
if (usesMixinDebug.toBoolean()) {
|
||||
jvmArguments += [
|
||||
"-Dmixin.debug.countInjections=true",
|
||||
"-Dmixin.debug.verbose=true",
|
||||
"-Dmixin.debug.export=true"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
minecraft {
|
||||
version = minecraftVersion + "-" + forgeVersion + "-" + minecraftVersion
|
||||
runDir = "run"
|
||||
version = minecraftVersion + '-' + forgeVersion + '-' + minecraftVersion
|
||||
runDir = 'run'
|
||||
|
||||
if (replaceGradleTokenInFile) {
|
||||
replaceIn replaceGradleTokenInFile
|
||||
@@ -180,78 +281,99 @@ minecraft {
|
||||
replace gradleTokenModName, modName
|
||||
}
|
||||
if(gradleTokenVersion) {
|
||||
replace gradleTokenVersion, versionDetails().lastTag
|
||||
replace gradleTokenVersion, modVersion
|
||||
}
|
||||
if(gradleTokenGroupName) {
|
||||
replace gradleTokenGroupName, modGroup
|
||||
}
|
||||
}
|
||||
|
||||
clientIntellijRun {
|
||||
args(arguments)
|
||||
jvmArgs(jvmArguments)
|
||||
|
||||
if(developmentEnvironmentUserName) {
|
||||
args("--username", developmentEnvironmentUserName)
|
||||
}
|
||||
}
|
||||
|
||||
serverIntellijRun {
|
||||
args(arguments)
|
||||
jvmArgs(jvmArguments)
|
||||
}
|
||||
}
|
||||
|
||||
if(file("addon.gradle").exists()) {
|
||||
apply from: "addon.gradle"
|
||||
if(file('addon.gradle').exists()) {
|
||||
apply from: 'addon.gradle'
|
||||
}
|
||||
|
||||
apply from: 'repositories.gradle'
|
||||
|
||||
configurations {
|
||||
implementation.extendsFrom(shadowImplementation)
|
||||
implementation.extendsFrom(shadowImplementation) // TODO: remove after all uses are refactored
|
||||
implementation.extendsFrom(shadowCompile)
|
||||
implementation.extendsFrom(shadeCompile)
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "Overmind forge repo mirror"
|
||||
url = "https://gregtech.overminddl1.com/"
|
||||
name 'Overmind forge repo mirror'
|
||||
url 'https://gregtech.overminddl1.com/'
|
||||
}
|
||||
if(usesMixins.toBoolean()) {
|
||||
maven {
|
||||
name = "sponge"
|
||||
url = "https://repo.spongepowered.org/repository/maven-public"
|
||||
name 'sponge'
|
||||
url 'https://repo.spongepowered.org/repository/maven-public'
|
||||
}
|
||||
maven {
|
||||
url = "https://jitpack.io"
|
||||
url 'https://jitpack.io'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
if(usesMixins.toBoolean()) {
|
||||
annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3")
|
||||
annotationProcessor("com.google.guava:guava:24.1.1-jre")
|
||||
annotationProcessor("com.google.code.gson:gson:2.8.6")
|
||||
annotationProcessor("org.spongepowered:mixin:0.8-SNAPSHOT")
|
||||
annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3')
|
||||
annotationProcessor('com.google.guava:guava:24.1.1-jre')
|
||||
annotationProcessor('com.google.code.gson:gson:2.8.6')
|
||||
annotationProcessor('org.spongepowered:mixin:0.8-SNAPSHOT')
|
||||
// using 0.8 to workaround a issue in 0.7 which fails mixin application
|
||||
compile("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
|
||||
compile('com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH') {
|
||||
// Mixin includes a lot of dependencies that are too up-to-date
|
||||
exclude module: "launchwrapper"
|
||||
exclude module: "guava"
|
||||
exclude module: "gson"
|
||||
exclude module: "commons-io"
|
||||
exclude module: "log4j-core"
|
||||
exclude module: 'launchwrapper'
|
||||
exclude module: 'guava'
|
||||
exclude module: 'gson'
|
||||
exclude module: 'commons-io'
|
||||
exclude module: 'log4j-core'
|
||||
}
|
||||
compile("com.github.GTNewHorizons:SpongeMixins:1.3.3:dev")
|
||||
compile('com.github.GTNewHorizons:SpongeMixins:1.5.0')
|
||||
}
|
||||
}
|
||||
|
||||
apply from: 'dependencies.gradle'
|
||||
|
||||
def mixingConfigRefMap = "mixins." + modId + ".refmap.json"
|
||||
def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json'
|
||||
def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfigRefMap
|
||||
def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg"
|
||||
|
||||
task generateAssets {
|
||||
if(usesMixins.toBoolean()) {
|
||||
getFile("/src/main/resources/mixins." + modId + ".json").text = """{
|
||||
if (usesMixins.toBoolean()) {
|
||||
def mixinConfigFile = getFile("/src/main/resources/mixins." + modId + ".json");
|
||||
if (!mixinConfigFile.exists()) {
|
||||
mixinConfigFile.text = """{
|
||||
"required": true,
|
||||
"minVersion": "0.7.11",
|
||||
"package": "${modGroup}.${mixinsPackage}",
|
||||
"plugin": "${modGroup}.${mixinPlugin}",
|
||||
"refmap": "${mixingConfigRefMap}",
|
||||
"target": "@env(DEFAULT)",
|
||||
"compatibilityLevel": "JAVA_8"
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [],
|
||||
"client": [],
|
||||
"server": []
|
||||
}
|
||||
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,16 +383,28 @@ task relocateShadowJar(type: ConfigureShadowRelocation) {
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
project.configurations.shadeCompile.each { dep ->
|
||||
from(project.zipTree(dep)) {
|
||||
exclude 'META-INF', 'META-INF/**'
|
||||
}
|
||||
}
|
||||
|
||||
manifest {
|
||||
attributes(getManifestAttributes())
|
||||
}
|
||||
|
||||
minimize() // This will only allow shading for actually used classes
|
||||
configurations = [project.configurations.shadowImplementation]
|
||||
configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile]
|
||||
dependsOn(relocateShadowJar)
|
||||
}
|
||||
|
||||
jar {
|
||||
project.configurations.shadeCompile.each { dep ->
|
||||
from(project.zipTree(dep)) {
|
||||
exclude 'META-INF', 'META-INF/**'
|
||||
}
|
||||
}
|
||||
|
||||
manifest {
|
||||
attributes(getManifestAttributes())
|
||||
}
|
||||
@@ -303,15 +437,6 @@ afterEvaluate {
|
||||
}
|
||||
|
||||
runClient {
|
||||
def arguments = []
|
||||
|
||||
if(usesMixins.toBoolean()) {
|
||||
arguments += [
|
||||
"--mods=../build/libs/$modId-${version}.jar",
|
||||
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
|
||||
]
|
||||
}
|
||||
|
||||
if(developmentEnvironmentUserName) {
|
||||
arguments += [
|
||||
"--username",
|
||||
@@ -320,19 +445,12 @@ runClient {
|
||||
}
|
||||
|
||||
args(arguments)
|
||||
jvmArgs(jvmArguments)
|
||||
}
|
||||
|
||||
runServer {
|
||||
def arguments = []
|
||||
|
||||
if (usesMixins.toBoolean()) {
|
||||
arguments += [
|
||||
"--mods=../build/libs/$modId-${version}.jar",
|
||||
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
|
||||
]
|
||||
}
|
||||
|
||||
args(arguments)
|
||||
jvmArgs(jvmArguments)
|
||||
}
|
||||
|
||||
tasks.withType(JavaExec).configureEach {
|
||||
@@ -343,36 +461,35 @@ tasks.withType(JavaExec).configureEach {
|
||||
)
|
||||
}
|
||||
|
||||
processResources
|
||||
{
|
||||
// this will ensure that this task is redone when the versions change.
|
||||
inputs.property "version", project.version
|
||||
inputs.property "mcversion", project.minecraft.version
|
||||
processResources {
|
||||
// this will ensure that this task is redone when the versions change.
|
||||
inputs.property "version", project.version
|
||||
inputs.property "mcversion", project.minecraft.version
|
||||
|
||||
// replace stuff in mcmod.info, nothing else
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
// replace stuff in mcmod.info, nothing else
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
|
||||
// replace version and mcversion
|
||||
expand "minecraftVersion": project.minecraft.version,
|
||||
"modVersion": versionDetails().lastTag,
|
||||
"modId": modId,
|
||||
"modName": modName
|
||||
}
|
||||
// replace modVersion and minecraftVersion
|
||||
expand "minecraftVersion": project.minecraft.version,
|
||||
"modVersion": modVersion,
|
||||
"modId": modId,
|
||||
"modName": modName
|
||||
}
|
||||
|
||||
if(usesMixins.toBoolean()) {
|
||||
from refMap
|
||||
}
|
||||
if(usesMixins.toBoolean()) {
|
||||
from refMap
|
||||
}
|
||||
|
||||
// copy everything else, thats not the mcmod.info
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
}
|
||||
}
|
||||
// copy everything else that's not the mcmod.info
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
}
|
||||
}
|
||||
|
||||
def getManifestAttributes() {
|
||||
def manifestAttributes = [:]
|
||||
if(containsMixinsAndOrCoreModOnly.toBoolean() == false && (usesMixins.toBoolean() || coreModClass)) {
|
||||
if(!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) {
|
||||
manifestAttributes += ["FMLCorePluginContainsFMLMod": true]
|
||||
}
|
||||
|
||||
@@ -388,19 +505,25 @@ def getManifestAttributes() {
|
||||
manifestAttributes += [
|
||||
"TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
|
||||
"MixinConfigs" : "mixins." + modId + ".json",
|
||||
"ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false
|
||||
"ForceLoadAsMod" : !containsMixinsAndOrCoreModOnly.toBoolean()
|
||||
]
|
||||
}
|
||||
return manifestAttributes
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
from (sourceSets.main.allJava)
|
||||
from (sourceSets.main.allSource)
|
||||
from (file("$projectDir/LICENSE"))
|
||||
getArchiveClassifier().set('sources')
|
||||
}
|
||||
|
||||
task shadowDevJar(type: ShadowJar) {
|
||||
project.configurations.shadeCompile.each { dep ->
|
||||
from(project.zipTree(dep)) {
|
||||
exclude 'META-INF', 'META-INF/**'
|
||||
}
|
||||
}
|
||||
|
||||
from sourceSets.main.output
|
||||
getArchiveClassifier().set("dev")
|
||||
|
||||
@@ -409,7 +532,7 @@ task shadowDevJar(type: ShadowJar) {
|
||||
}
|
||||
|
||||
minimize() // This will only allow shading for actually used classes
|
||||
configurations = [project.configurations.shadowImplementation]
|
||||
configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile]
|
||||
}
|
||||
|
||||
task relocateShadowDevJar(type: ConfigureShadowRelocation) {
|
||||
@@ -424,6 +547,12 @@ task circularResolverJar(type: Jar) {
|
||||
}
|
||||
|
||||
task devJar(type: Jar) {
|
||||
project.configurations.shadeCompile.each { dep ->
|
||||
from(project.zipTree(dep)) {
|
||||
exclude 'META-INF', 'META-INF/**'
|
||||
}
|
||||
}
|
||||
|
||||
from sourceSets.main.output
|
||||
getArchiveClassifier().set("dev")
|
||||
|
||||
@@ -438,7 +567,7 @@ task devJar(type: Jar) {
|
||||
}
|
||||
|
||||
task apiJar(type: Jar) {
|
||||
from (sourceSets.main.allJava) {
|
||||
from (sourceSets.main.allSource) {
|
||||
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
|
||||
}
|
||||
|
||||
@@ -454,40 +583,71 @@ task apiJar(type: Jar) {
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
if(!noPublishedSources) {
|
||||
archives sourcesJar
|
||||
}
|
||||
archives devJar
|
||||
if(apiPackage) {
|
||||
archives apiJar
|
||||
}
|
||||
}
|
||||
|
||||
// publishing
|
||||
// The gradle metadata includes all of the additional deps that we disabled from POM generation (including forgeBin with no groupID),
|
||||
// and isn't strictly needed with the POM so just disable it.
|
||||
tasks.withType(GenerateModuleMetadata) {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
// workaround variable hiding in pom processing
|
||||
def projectConfigs = project.configurations
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
artifact source: jar
|
||||
artifact source: sourcesJar, classifier: "src"
|
||||
artifact source: devJar, classifier: "dev"
|
||||
from components.java
|
||||
if(usesShadowedDependencies.toBoolean()) {
|
||||
artifact source: shadowJar, classifier: ""
|
||||
}
|
||||
if(!noPublishedSources) {
|
||||
artifact source: sourcesJar, classifier: "sources"
|
||||
}
|
||||
artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev"
|
||||
if (apiPackage) {
|
||||
artifact source: apiJar, classifier: "api"
|
||||
}
|
||||
|
||||
groupId = System.getenv("ARTIFACT_GROUP_ID") ?: group
|
||||
groupId = System.getenv("ARTIFACT_GROUP_ID") ?: "com.github.GTNewHorizons"
|
||||
artifactId = System.getenv("ARTIFACT_ID") ?: project.name
|
||||
version = System.getenv("ARTIFACT_VERSION") ?: project.version
|
||||
// Using the identified version, not project.version as it has the prepended 1.7.10
|
||||
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
|
||||
|
||||
// remove extra garbage from minecraft and minecraftDeps configuration
|
||||
pom.withXml {
|
||||
def badArtifacts = [:].withDefault {[] as Set<String>}
|
||||
for (configuration in [projectConfigs.minecraft, projectConfigs.minecraftDeps]) {
|
||||
for (dependency in configuration.allDependencies) {
|
||||
badArtifacts[dependency.group == null ? "" : dependency.group] += dependency.name
|
||||
}
|
||||
}
|
||||
// example for specifying extra stuff to ignore
|
||||
// badArtifacts["org.example.group"] += "artifactName"
|
||||
|
||||
Node pomNode = asNode()
|
||||
pomNode.dependencies.'*'.findAll() {
|
||||
badArtifacts[it.groupId.text()].contains(it.artifactId.text())
|
||||
}.each() {
|
||||
it.parent().remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
String owner = System.getenv("REPOSITORY_OWNER") ?: "Unknown"
|
||||
String repositoryName = System.getenv("REPOSITORY_NAME") ?: "Unknown"
|
||||
String githubRepositoryUrl = "https://maven.pkg.github.com/$owner/$repositoryName"
|
||||
name = "GitHubPackages"
|
||||
url = githubRepositoryUrl
|
||||
url = "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases"
|
||||
credentials {
|
||||
username = System.getenv("GITHUB_ACTOR") ?: "NONE"
|
||||
password = System.getenv("GITHUB_TOKEN") ?: "NONE"
|
||||
username = System.getenv("MAVEN_USER") ?: "NONE"
|
||||
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -506,19 +666,19 @@ if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
|
||||
if (autoUpdateBuildScript.toBoolean()) {
|
||||
performBuildScriptUpdate(projectDir.toString())
|
||||
} else {
|
||||
println("Build script update available! Run 'gradle updateBuildScript'")
|
||||
out.style(Style.SuccessHeader).println("Build script update available! Run 'gradle updateBuildScript'")
|
||||
}
|
||||
}
|
||||
|
||||
static URL availableBuildScriptUrl() {
|
||||
new URL("https://raw.githubusercontent.com/SinTh0r4s/ExampleMod1.7.10/main/build.gradle")
|
||||
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle")
|
||||
}
|
||||
|
||||
boolean performBuildScriptUpdate(String projectDir) {
|
||||
if (isNewBuildScriptVersionAvailable(projectDir)) {
|
||||
def buildscriptFile = getFile("build.gradle")
|
||||
availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } }
|
||||
print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
|
||||
out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -549,11 +709,221 @@ configure(updateBuildScript) {
|
||||
description = 'Updates the build script to the latest version'
|
||||
}
|
||||
|
||||
// Parameter Deobfuscation
|
||||
|
||||
task deobfParams {
|
||||
doLast {
|
||||
|
||||
String mcpDir = "$project.gradle.gradleUserHomeDir/caches/minecraft/de/oceanlabs/mcp/mcp_$channel/$mappingsVersion"
|
||||
String mcpZIP = "$mcpDir/mcp_$channel-$mappingsVersion-${minecraftVersion}.zip"
|
||||
String paramsCSV = "$mcpDir/params.csv"
|
||||
|
||||
download.run {
|
||||
src "https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp_$channel/$mappingsVersion-$minecraftVersion/mcp_$channel-$mappingsVersion-${minecraftVersion}.zip"
|
||||
dest mcpZIP
|
||||
overwrite false
|
||||
}
|
||||
|
||||
if(!file(paramsCSV).exists()) {
|
||||
println("Extracting MCP archive ...")
|
||||
unzip(mcpZIP, mcpDir)
|
||||
}
|
||||
|
||||
println("Parsing params.csv ...")
|
||||
Map<String, String> params = new HashMap<>()
|
||||
Files.lines(Paths.get(paramsCSV)).forEach{line ->
|
||||
String[] cells = line.split(",")
|
||||
if(cells.length > 2 && cells[0].matches("p_i?\\d+_\\d+_")) {
|
||||
params.put(cells[0], cells[1])
|
||||
}
|
||||
}
|
||||
|
||||
out.style(Style.Success).println("Modified ${replaceParams(file("$projectDir/src/main/java"), params)} files!")
|
||||
out.style(Style.Failure).println("Don't forget to verify that the code still works as before!\n It could be broken due to duplicate variables existing now\n or parameters taking priority over other variables.")
|
||||
}
|
||||
}
|
||||
|
||||
static int replaceParams(File file, Map<String, String> params) {
|
||||
int fileCount = 0
|
||||
|
||||
if(file.isDirectory()) {
|
||||
for(File f : file.listFiles()) {
|
||||
fileCount += replaceParams(f, params)
|
||||
}
|
||||
return fileCount
|
||||
}
|
||||
println("Visiting ${file.getName()} ...")
|
||||
try {
|
||||
String content = new String(Files.readAllBytes(file.toPath()))
|
||||
int hash = content.hashCode()
|
||||
params.forEach{key, value ->
|
||||
content = content.replaceAll(key, value)
|
||||
}
|
||||
if(hash != content.hashCode()) {
|
||||
Files.write(file.toPath(), content.getBytes("UTF-8"))
|
||||
return 1
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Credit: bitsnaps (https://gist.github.com/bitsnaps/00947f2dce66f4bbdabc67d7e7b33681)
|
||||
static unzip(String zipFileName, String outputDir) {
|
||||
byte[] buffer = new byte[16384]
|
||||
ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName))
|
||||
ZipEntry zipEntry = zis.getNextEntry()
|
||||
while (zipEntry != null) {
|
||||
File newFile = new File(outputDir + File.separator, zipEntry.name)
|
||||
if (zipEntry.isDirectory()) {
|
||||
if (!newFile.isDirectory() && !newFile.mkdirs()) {
|
||||
throw new IOException("Failed to create directory $newFile")
|
||||
}
|
||||
} else {
|
||||
// fix for Windows-created archives
|
||||
File parent = newFile.parentFile
|
||||
if (!parent.isDirectory() && !parent.mkdirs()) {
|
||||
throw new IOException("Failed to create directory $parent")
|
||||
}
|
||||
// write file content
|
||||
FileOutputStream fos = new FileOutputStream(newFile)
|
||||
int len = 0
|
||||
while ((len = zis.read(buffer)) > 0) {
|
||||
fos.write(buffer, 0, len)
|
||||
}
|
||||
fos.close()
|
||||
}
|
||||
zipEntry = zis.getNextEntry()
|
||||
}
|
||||
zis.closeEntry()
|
||||
zis.close()
|
||||
}
|
||||
|
||||
configure(deobfParams) {
|
||||
group = 'forgegradle'
|
||||
description = 'Rename all obfuscated parameter names inherited from Minecraft classes'
|
||||
}
|
||||
|
||||
// Dependency Deobfuscation
|
||||
|
||||
def deobf(String sourceURL) {
|
||||
try {
|
||||
URL url = new URL(sourceURL)
|
||||
String fileName = url.getFile()
|
||||
|
||||
//get rid of directories:
|
||||
int lastSlash = fileName.lastIndexOf("/")
|
||||
if(lastSlash > 0) {
|
||||
fileName = fileName.substring(lastSlash + 1)
|
||||
}
|
||||
//get rid of extension:
|
||||
if(fileName.endsWith(".jar") || fileName.endsWith(".litemod")) {
|
||||
fileName = fileName.substring(0, fileName.lastIndexOf("."))
|
||||
}
|
||||
|
||||
String hostName = url.getHost()
|
||||
if(hostName.startsWith("www.")) {
|
||||
hostName = hostName.substring(4)
|
||||
}
|
||||
List parts = Arrays.asList(hostName.split("\\."))
|
||||
Collections.reverse(parts)
|
||||
hostName = String.join(".", parts)
|
||||
|
||||
return deobf(sourceURL, "$hostName/$fileName")
|
||||
} catch(Exception e) {
|
||||
return deobf(sourceURL, "deobf/${sourceURL.hashCode()}")
|
||||
}
|
||||
}
|
||||
|
||||
// The method above is to be preferred. Use this method if the filename is not at the end of the URL.
|
||||
def deobf(String sourceURL, String rawFileName) {
|
||||
String bon2Version = "2.5.1"
|
||||
String fileName = URLDecoder.decode(rawFileName, "UTF-8")
|
||||
String cacheDir = "$project.gradle.gradleUserHomeDir/caches"
|
||||
String bon2Dir = "$cacheDir/forge_gradle/deobf"
|
||||
String bon2File = "$bon2Dir/BON2-${bon2Version}.jar"
|
||||
String obfFile = "$cacheDir/modules-2/files-2.1/${fileName}.jar"
|
||||
String deobfFile = "$cacheDir/modules-2/files-2.1/${fileName}-deobf.jar"
|
||||
|
||||
if(file(deobfFile).exists()) {
|
||||
return files(deobfFile)
|
||||
}
|
||||
|
||||
String mappingsVer
|
||||
if(remoteMappings) {
|
||||
String id = "${forgeVersion.split("\\.")[3]}-$minecraftVersion"
|
||||
String mappingsZIP = "$cacheDir/forge_gradle/maven_downloader/de/oceanlabs/mcp/mcp_snapshot_nodoc/$id/mcp_snapshot_nodoc-${id}.zip"
|
||||
|
||||
zipMappings(mappingsZIP, remoteMappings, bon2Dir)
|
||||
|
||||
mappingsVer = "snapshot_$id"
|
||||
} else {
|
||||
mappingsVer = "${channel}_$mappingsVersion"
|
||||
}
|
||||
|
||||
download.run {
|
||||
src "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases/com/github/parker8283/BON2/$bon2Version-CUSTOM/BON2-$bon2Version-CUSTOM-all.jar"
|
||||
dest bon2File
|
||||
quiet true
|
||||
overwrite false
|
||||
}
|
||||
|
||||
download.run {
|
||||
src sourceURL
|
||||
dest obfFile
|
||||
quiet true
|
||||
overwrite false
|
||||
}
|
||||
|
||||
exec {
|
||||
commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', minecraftVersion, '--mappingsVer', mappingsVer, '--notch'
|
||||
workingDir bon2Dir
|
||||
standardOutput = new FileOutputStream("${deobfFile}.log")
|
||||
}
|
||||
|
||||
return files(deobfFile)
|
||||
}
|
||||
|
||||
def zipMappings(String zipPath, String url, String bon2Dir) {
|
||||
File zipFile = new File(zipPath)
|
||||
if(zipFile.exists()) {
|
||||
return
|
||||
}
|
||||
|
||||
String fieldsCache = "$bon2Dir/data/fields.csv"
|
||||
String methodsCache = "$bon2Dir/data/methods.csv"
|
||||
|
||||
download.run {
|
||||
src "${url}fields.csv"
|
||||
dest fieldsCache
|
||||
quiet true
|
||||
}
|
||||
download.run {
|
||||
src "${url}methods.csv"
|
||||
dest methodsCache
|
||||
quiet true
|
||||
}
|
||||
|
||||
zipFile.getParentFile().mkdirs()
|
||||
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile))
|
||||
|
||||
zos.putNextEntry(new ZipEntry("fields.csv"))
|
||||
Files.copy(Paths.get(fieldsCache), zos)
|
||||
zos.closeEntry()
|
||||
|
||||
zos.putNextEntry(new ZipEntry("methods.csv"))
|
||||
Files.copy(Paths.get(methodsCache), zos)
|
||||
zos.closeEntry()
|
||||
|
||||
zos.close()
|
||||
}
|
||||
|
||||
// Helper methods
|
||||
|
||||
def checkPropertyExists(String propertyName) {
|
||||
if (project.hasProperty(propertyName) == false) {
|
||||
throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/gradle.properties")
|
||||
if (!project.hasProperty(propertyName)) {
|
||||
throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/gradle.properties")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-11
@@ -1,15 +1,10 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
compile("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:master-SNAPSHOT:dev")
|
||||
compile("com.github.GTNewHorizons:Baubles:master-SNAPSHOT:dev")
|
||||
|
||||
compile("curse.maven:cofh-core-69162:2388751")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:NotEnoughItems:master-SNAPSHOT:dev") {
|
||||
transitive = false
|
||||
}
|
||||
compileOnly("com.github.GTNewHorizons:EnderIO:master-SNAPSHOT:dev") {
|
||||
transitive = false
|
||||
}
|
||||
compile("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-87-GTNH:dev")
|
||||
compile("com.github.GTNewHorizons:Baubles:1.0.1.14:dev")
|
||||
compile("curse.maven:cofh-core-69162:2388751")
|
||||
compile("com.github.GTNewHorizons:NotEnoughItems:2.2.12-GTNH:dev")
|
||||
compile("com.github.GTNewHorizons:CodeChickenLib:1.1.5.3:dev")
|
||||
compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.32:dev") { transitive = false }
|
||||
}
|
||||
+1
-1
@@ -19,7 +19,7 @@ forgeVersion = 10.13.4.1614
|
||||
# restart Minecraft in development. Choose this dependent on your mod:
|
||||
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
|
||||
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
|
||||
developmentEnvironmentUserName = "Developer"
|
||||
developmentEnvironmentUserName = Developer
|
||||
|
||||
# Define a source file of your project with:
|
||||
# public static final String VERSION = "GRADLETOKEN_VERSION";
|
||||
|
||||
+10
-6
@@ -1,10 +1,14 @@
|
||||
// Add any additional repositories for your dependencies here
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url "https://cursemaven.com"
|
||||
}
|
||||
maven {
|
||||
url = "https://jitpack.io"
|
||||
}
|
||||
maven {
|
||||
name = "GTNH Maven"
|
||||
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
||||
}
|
||||
maven {
|
||||
url "https://cursemaven.com"
|
||||
}
|
||||
maven {
|
||||
url = "https://jitpack.io"
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.api;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public interface IWCTInteractionHelper {
|
||||
|
||||
void openWirelessCraftingTerminalGui( @Nonnull EntityPlayer player );
|
||||
|
||||
|
||||
void openWirelessCraftingTerminalGui(@Nonnull EntityPlayer player);
|
||||
}
|
||||
@@ -1,40 +1,39 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.api;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IWCTItemDescription {
|
||||
/**
|
||||
* Gets the damage, or meta, value of the item.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getDamage();
|
||||
/**
|
||||
* Gets the damage, or meta, value of the item.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getDamage();
|
||||
|
||||
/**
|
||||
* Gets the item.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Nonnull
|
||||
Item getItem();
|
||||
/**
|
||||
* Gets the item.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Nonnull
|
||||
Item getItem();
|
||||
|
||||
/**
|
||||
* Gets a stack of size 1.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Nonnull
|
||||
ItemStack getStack();
|
||||
/**
|
||||
* Gets a stack of size 1.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Nonnull
|
||||
ItemStack getStack();
|
||||
|
||||
/**
|
||||
* Gets a stack of the specified size.
|
||||
*
|
||||
* @param amount
|
||||
* @return
|
||||
*/
|
||||
@Nonnull
|
||||
ItemStack getStacks( int amount );
|
||||
/**
|
||||
* Gets a stack of the specified size.
|
||||
*
|
||||
* @param amount
|
||||
* @return
|
||||
*/
|
||||
@Nonnull
|
||||
ItemStack getStacks(int amount);
|
||||
}
|
||||
@@ -3,36 +3,36 @@ package net.p455w0rd.wirelesscraftingterminal.api;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public abstract class IWCTItems {
|
||||
/**
|
||||
* WirelessCraftingTerminal
|
||||
*/
|
||||
@Nonnull
|
||||
public IWCTItemDescription WirelessCraftingTerminal;
|
||||
|
||||
/**
|
||||
* Infinity Booster Card
|
||||
*/
|
||||
@Nonnull
|
||||
public IWCTItemDescription InfinityBoosterCard;
|
||||
|
||||
/**
|
||||
* Used for the creat6ive tab
|
||||
* TODO: remove unneeded item and just
|
||||
* add the icon properly
|
||||
*/
|
||||
@Nonnull
|
||||
public IWCTItemDescription WCTDummyIcon;
|
||||
|
||||
/**
|
||||
* Item used solely for infinity booster
|
||||
* card slot background icon
|
||||
*/
|
||||
@Nonnull
|
||||
public IWCTItemDescription WCTBoosterBGIcon;
|
||||
|
||||
/**
|
||||
* Magnet Card
|
||||
*/
|
||||
@Nonnull
|
||||
public IWCTItemDescription MagnetCard;
|
||||
/**
|
||||
* WirelessCraftingTerminal
|
||||
*/
|
||||
@Nonnull
|
||||
public IWCTItemDescription WirelessCraftingTerminal;
|
||||
|
||||
/**
|
||||
* Infinity Booster Card
|
||||
*/
|
||||
@Nonnull
|
||||
public IWCTItemDescription InfinityBoosterCard;
|
||||
|
||||
/**
|
||||
* Used for the creat6ive tab
|
||||
* TODO: remove unneeded item and just
|
||||
* add the icon properly
|
||||
*/
|
||||
@Nonnull
|
||||
public IWCTItemDescription WCTDummyIcon;
|
||||
|
||||
/**
|
||||
* Item used solely for infinity booster
|
||||
* card slot background icon
|
||||
*/
|
||||
@Nonnull
|
||||
public IWCTItemDescription WCTBoosterBGIcon;
|
||||
|
||||
/**
|
||||
* Magnet Card
|
||||
*/
|
||||
@Nonnull
|
||||
public IWCTItemDescription MagnetCard;
|
||||
}
|
||||
+17
-17
@@ -10,26 +10,26 @@ import net.minecraft.item.ItemStack;
|
||||
* Provides the required functionality of a wireless terminal.
|
||||
* Presumably this interface would be implemented on an Item, but that is
|
||||
* not a requirement.
|
||||
*
|
||||
*
|
||||
* @author Nividica
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface IWirelessCraftingTermHandler extends IWirelessTermHandler, IAEItemPowerStorage {
|
||||
//public interface IWirelessCraftingTermHandler extends INetworkEncodable, IAEItemPowerStorage {
|
||||
/**
|
||||
* Gets the tag used to store the terminal data.
|
||||
*
|
||||
* @param terminalItemstack
|
||||
* @return
|
||||
*/
|
||||
//@Nonnull
|
||||
//NBTTagCompound getWTerminalTag( @Nonnull ItemStack terminalItemstack );
|
||||
|
||||
boolean canHandle( ItemStack is );
|
||||
// public interface IWirelessCraftingTermHandler extends INetworkEncodable, IAEItemPowerStorage {
|
||||
/**
|
||||
* Gets the tag used to store the terminal data.
|
||||
*
|
||||
* @param terminalItemstack
|
||||
* @return
|
||||
*/
|
||||
// @Nonnull
|
||||
// NBTTagCompound getWTerminalTag( @Nonnull ItemStack terminalItemstack );
|
||||
|
||||
boolean usePower( EntityPlayer player, double amount, ItemStack is );
|
||||
boolean canHandle(ItemStack is);
|
||||
|
||||
boolean hasPower( EntityPlayer player, double amount, ItemStack is );
|
||||
|
||||
IConfigManager getConfigManager( ItemStack is );
|
||||
boolean usePower(EntityPlayer player, double amount, ItemStack is);
|
||||
|
||||
boolean hasPower(EntityPlayer player, double amount, ItemStack is);
|
||||
|
||||
IConfigManager getConfigManager(ItemStack is);
|
||||
}
|
||||
+7
-7
@@ -5,12 +5,12 @@ import appeng.core.features.IAEFeature;
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IWirelessCraftingTerminalItem extends IWirelessCraftingTermHandler, IAEItemPowerStorage, IAEFeature, IEnergyContainerItem{
|
||||
public interface IWirelessCraftingTerminalItem
|
||||
extends IWirelessCraftingTermHandler, IAEItemPowerStorage, IAEFeature, IEnergyContainerItem {
|
||||
|
||||
// checks if an Infinity Booster Caqrd is installed on the WCT
|
||||
public boolean checkForBooster(final ItemStack wirelessTerminal);
|
||||
|
||||
// checks if the Wireless Crafting Terminal is enabled on your item (need for ExtraCells Universal Terminal)
|
||||
public boolean isWirelessCraftingEnabled(final ItemStack wirelessTerminal);
|
||||
|
||||
// checks if an Infinity Booster Caqrd is installed on the WCT
|
||||
public boolean checkForBooster(final ItemStack wirelessTerminal);
|
||||
|
||||
// checks if the Wireless Crafting Terminal is enabled on your item (need for ExtraCells Universal Terminal)
|
||||
public boolean isWirelessCraftingEnabled(final ItemStack wirelessTerminal);
|
||||
}
|
||||
@@ -1,46 +1,40 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.api;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class WCTApi {
|
||||
|
||||
protected static WCTApi api = null;
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Nullable
|
||||
public static WCTApi instance()
|
||||
{
|
||||
// Have we already retrieved the api?
|
||||
if( WCTApi.api == null )
|
||||
{
|
||||
try
|
||||
{
|
||||
// Attempt to locate the API implementation
|
||||
Class clazz = Class.forName( "net.p455w0rd.wirelesscraftingterminal.implementation.WCTAPIImplementation" );
|
||||
protected static WCTApi api = null;
|
||||
|
||||
// Get the instance method
|
||||
Method instanceAccessor = clazz.getMethod( "instance" );
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Nullable
|
||||
public static WCTApi instance() {
|
||||
// Have we already retrieved the api?
|
||||
if (WCTApi.api == null) {
|
||||
try {
|
||||
// Attempt to locate the API implementation
|
||||
Class clazz =
|
||||
Class.forName("net.p455w0rd.wirelesscraftingterminal.implementation.WCTAPIImplementation");
|
||||
|
||||
// Attempt to get the API instance
|
||||
WCTApi.api = (WCTApi)instanceAccessor.invoke( null );
|
||||
}
|
||||
catch( Throwable e )
|
||||
{
|
||||
// Unable to locate the API, return null
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// Get the instance method
|
||||
Method instanceAccessor = clazz.getMethod("instance");
|
||||
|
||||
return WCTApi.api;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public abstract IWCTInteractionHelper interact();
|
||||
// Attempt to get the API instance
|
||||
WCTApi.api = (WCTApi) instanceAccessor.invoke(null);
|
||||
} catch (Throwable e) {
|
||||
// Unable to locate the API, return null
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public abstract IWCTItems items();
|
||||
|
||||
return WCTApi.api;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public abstract IWCTInteractionHelper interact();
|
||||
|
||||
@Nonnull
|
||||
public abstract IWCTItems items();
|
||||
}
|
||||
+4
-4
@@ -2,9 +2,9 @@ package net.p455w0rd.wirelesscraftingterminal.api.exceptions;
|
||||
|
||||
public class MissingIngredientError extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -998858343831371697L;
|
||||
private static final long serialVersionUID = -998858343831371697L;
|
||||
|
||||
public MissingIngredientError(final String n) {
|
||||
super(n);
|
||||
}
|
||||
public MissingIngredientError(final String n) {
|
||||
super(n);
|
||||
}
|
||||
}
|
||||
+5
-7
@@ -1,12 +1,10 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.api.exceptions;
|
||||
|
||||
public class ModNotInstalled extends Exception
|
||||
{
|
||||
public class ModNotInstalled extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -9052435206368425494L;
|
||||
private static final long serialVersionUID = -9052435206368425494L;
|
||||
|
||||
public ModNotInstalled( final String t )
|
||||
{
|
||||
super( t );
|
||||
}
|
||||
public ModNotInstalled(final String t) {
|
||||
super(t);
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -2,9 +2,9 @@ package net.p455w0rd.wirelesscraftingterminal.api.exceptions;
|
||||
|
||||
public class RegistrationError extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -6602870588617670263L;
|
||||
private static final long serialVersionUID = -6602870588617670263L;
|
||||
|
||||
public RegistrationError(final String n) {
|
||||
super(n);
|
||||
}
|
||||
public RegistrationError(final String n) {
|
||||
super(n);
|
||||
}
|
||||
}
|
||||
+13
-13
@@ -6,21 +6,21 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Defines the requirements for a terminal that wishes to issue AE2 crafting jobs.
|
||||
*
|
||||
*
|
||||
* @author Nividica
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface ICraftingIssuerHost extends ITerminalHost {
|
||||
/**
|
||||
* Gets the icon for this terminal.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
ItemStack getIcon();
|
||||
/**
|
||||
* Gets the icon for this terminal.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
ItemStack getIcon();
|
||||
|
||||
/**
|
||||
* Launches the terminal's GUI.
|
||||
* Used to return to the gui after crafting is confirmed or canceled.
|
||||
*/
|
||||
void launchGUI( EntityPlayer player );
|
||||
/**
|
||||
* Launches the terminal's GUI.
|
||||
* Used to return to the gui after crafting is confirmed or canceled.
|
||||
*/
|
||||
void launchGUI(EntityPlayer player);
|
||||
}
|
||||
+2
-4
@@ -1,12 +1,10 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.api.gui;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.p455w0rd.wirelesscraftingterminal.api.grid.ICraftingIssuerHost;
|
||||
|
||||
public interface ICraftingIssuerContainer {
|
||||
|
||||
@Nonnull
|
||||
ICraftingIssuerHost getCraftingHost();
|
||||
|
||||
@Nonnull
|
||||
ICraftingIssuerHost getCraftingHost();
|
||||
}
|
||||
+9
-12
@@ -2,19 +2,16 @@ package net.p455w0rd.wirelesscraftingterminal.api.networking.security;
|
||||
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
|
||||
public class MachineSource extends BaseActionSource
|
||||
{
|
||||
public class MachineSource extends BaseActionSource {
|
||||
|
||||
public final WCTIActionHost via;
|
||||
public final WCTIActionHost via;
|
||||
|
||||
public MachineSource( final WCTIActionHost v )
|
||||
{
|
||||
this.via = v;
|
||||
}
|
||||
public MachineSource(final WCTIActionHost v) {
|
||||
this.via = v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMachine()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isMachine() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+12
-12
@@ -3,17 +3,17 @@ package net.p455w0rd.wirelesscraftingterminal.api.networking.security;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
|
||||
public interface WCTIActionHost extends IGridHost
|
||||
{
|
||||
public interface WCTIActionHost extends IGridHost {
|
||||
|
||||
/**
|
||||
* Used to for calculating security rules, you must supply a node from your
|
||||
* IGridHost for the security test, this should be the primary node for the
|
||||
* machine, unless the action is preformed by a non primary node.
|
||||
*
|
||||
* @return the the gridnode that actions from this IGridHost are preformed
|
||||
* by.
|
||||
*/
|
||||
IGridNode getActionableNode();
|
||||
IGridNode getActionableNode(boolean ignoreRange);
|
||||
/**
|
||||
* Used to for calculating security rules, you must supply a node from your
|
||||
* IGridHost for the security test, this should be the primary node for the
|
||||
* machine, unless the action is preformed by a non primary node.
|
||||
*
|
||||
* @return the the gridnode that actions from this IGridHost are preformed
|
||||
* by.
|
||||
*/
|
||||
IGridNode getActionableNode();
|
||||
|
||||
IGridNode getActionableNode(boolean ignoreRange);
|
||||
}
|
||||
+11
-11
@@ -6,17 +6,17 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class WCTPlayerSource extends PlayerSource {
|
||||
|
||||
public final EntityPlayer player;
|
||||
public final WCTIActionHost via;
|
||||
public final EntityPlayer player;
|
||||
public final WCTIActionHost via;
|
||||
|
||||
public WCTPlayerSource(final EntityPlayer p, final WCTIActionHost v) {
|
||||
super(p, (IActionHost) v);
|
||||
this.player = p;
|
||||
this.via = v;
|
||||
}
|
||||
public WCTPlayerSource(final EntityPlayer p, final WCTIActionHost v) {
|
||||
super(p, (IActionHost) v);
|
||||
this.player = p;
|
||||
this.via = v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,4 @@
|
||||
@API( apiVersion = "1.7.10-rv3-1.8.6b", owner = "ae2wct", provides = "ae2wct|API" ) package net.p455w0rd.wirelesscraftingterminal.api;
|
||||
import cpw.mods.fml.common.API;
|
||||
@API(apiVersion = "1.7.10-rv3-1.8.6b", owner = "ae2wct", provides = "ae2wct|API")
|
||||
package net.p455w0rd.wirelesscraftingterminal.api;
|
||||
|
||||
import cpw.mods.fml.common.API;
|
||||
@@ -6,65 +6,65 @@ import net.p455w0rd.wirelesscraftingterminal.api.exceptions.RegistrationError;
|
||||
|
||||
public interface IIngredient {
|
||||
|
||||
/**
|
||||
* Acquire a single input stack for the current recipe, if more then one
|
||||
* ItemStack is possible a RegistrationError exception will be thrown,
|
||||
* ignore these and let the system handle the error.
|
||||
*
|
||||
* @return a single ItemStack for the recipe handler.
|
||||
*
|
||||
* @throws RegistrationError
|
||||
* @throws MissingIngredientError
|
||||
*/
|
||||
ItemStack getItemStack() throws RegistrationError, MissingIngredientError;
|
||||
/**
|
||||
* Acquire a single input stack for the current recipe, if more then one
|
||||
* ItemStack is possible a RegistrationError exception will be thrown,
|
||||
* ignore these and let the system handle the error.
|
||||
*
|
||||
* @return a single ItemStack for the recipe handler.
|
||||
*
|
||||
* @throws RegistrationError
|
||||
* @throws MissingIngredientError
|
||||
*/
|
||||
ItemStack getItemStack() throws RegistrationError, MissingIngredientError;
|
||||
|
||||
/**
|
||||
* Acquire a list of all the input stacks for the current recipe, this is
|
||||
* for handlers that support multiple inputs per slot.
|
||||
*
|
||||
* @return an array of ItemStacks for the recipe handler.
|
||||
*
|
||||
* @throws RegistrationError
|
||||
* @throws MissingIngredientError
|
||||
*/
|
||||
ItemStack[] getItemStackSet() throws RegistrationError, MissingIngredientError;
|
||||
/**
|
||||
* Acquire a list of all the input stacks for the current recipe, this is
|
||||
* for handlers that support multiple inputs per slot.
|
||||
*
|
||||
* @return an array of ItemStacks for the recipe handler.
|
||||
*
|
||||
* @throws RegistrationError
|
||||
* @throws MissingIngredientError
|
||||
*/
|
||||
ItemStack[] getItemStackSet() throws RegistrationError, MissingIngredientError;
|
||||
|
||||
/**
|
||||
* If you wish to support air, you must test before getting the ItemStack,
|
||||
* or ItemStackSet
|
||||
*
|
||||
* @return true if this slot contains no ItemStack, this is passed as "_"
|
||||
*/
|
||||
boolean isAir();
|
||||
/**
|
||||
* If you wish to support air, you must test before getting the ItemStack,
|
||||
* or ItemStackSet
|
||||
*
|
||||
* @return true if this slot contains no ItemStack, this is passed as "_"
|
||||
*/
|
||||
boolean isAir();
|
||||
|
||||
/**
|
||||
* @return The Name Space of the item. Prefer getItemStack or
|
||||
* getItemStackSet
|
||||
*/
|
||||
String getNameSpace();
|
||||
/**
|
||||
* @return The Name Space of the item. Prefer getItemStack or
|
||||
* getItemStackSet
|
||||
*/
|
||||
String getNameSpace();
|
||||
|
||||
/**
|
||||
* @return The Name of the item. Prefer getItemStack or getItemStackSet
|
||||
*/
|
||||
String getItemName();
|
||||
/**
|
||||
* @return The Name of the item. Prefer getItemStack or getItemStackSet
|
||||
*/
|
||||
String getItemName();
|
||||
|
||||
/**
|
||||
* @return The Damage Value of the item. Prefer getItemStack or
|
||||
* getItemStackSet
|
||||
*/
|
||||
int getDamageValue();
|
||||
/**
|
||||
* @return The Damage Value of the item. Prefer getItemStack or
|
||||
* getItemStackSet
|
||||
*/
|
||||
int getDamageValue();
|
||||
|
||||
/**
|
||||
* @return The Damage Value of the item. Prefer getItemStack or
|
||||
* getItemStackSet
|
||||
*/
|
||||
int getQty();
|
||||
/**
|
||||
* @return The Damage Value of the item. Prefer getItemStack or
|
||||
* getItemStackSet
|
||||
*/
|
||||
int getQty();
|
||||
|
||||
/**
|
||||
* Bakes the lists in for faster runtime look-ups.
|
||||
*
|
||||
* @throws MissingIngredientError
|
||||
* @throws RegistrationError
|
||||
*/
|
||||
void bake() throws RegistrationError, MissingIngredientError;
|
||||
/**
|
||||
* Bakes the lists in for faster runtime look-ups.
|
||||
*
|
||||
* @throws MissingIngredientError
|
||||
* @throws RegistrationError
|
||||
*/
|
||||
void bake() throws RegistrationError, MissingIngredientError;
|
||||
}
|
||||
+2
-3
@@ -2,7 +2,6 @@ package net.p455w0rd.wirelesscraftingterminal.api.recipes.game;
|
||||
|
||||
import net.p455w0rd.wirelesscraftingterminal.api.exceptions.RegistrationError;
|
||||
|
||||
public interface IRecipeBakeable
|
||||
{
|
||||
void bake() throws RegistrationError;
|
||||
public interface IRecipeBakeable {
|
||||
void bake() throws RegistrationError;
|
||||
}
|
||||
+192
-256
@@ -3,7 +3,6 @@ package net.p455w0rd.wirelesscraftingterminal.api.recipes.game;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
@@ -13,295 +12,232 @@ import net.p455w0rd.wirelesscraftingterminal.api.exceptions.MissingIngredientErr
|
||||
import net.p455w0rd.wirelesscraftingterminal.api.exceptions.RegistrationError;
|
||||
import net.p455w0rd.wirelesscraftingterminal.api.recipes.IIngredient;
|
||||
|
||||
public class ShapedRecipe implements IRecipe, IRecipeBakeable {
|
||||
// Added in for future ease of change, but hard coded for now.
|
||||
private static final int MAX_CRAFT_GRID_WIDTH = 3;
|
||||
private static final int MAX_CRAFT_GRID_HEIGHT = 3;
|
||||
|
||||
public class ShapedRecipe implements IRecipe, IRecipeBakeable
|
||||
{
|
||||
// Added in for future ease of change, but hard coded for now.
|
||||
private static final int MAX_CRAFT_GRID_WIDTH = 3;
|
||||
private static final int MAX_CRAFT_GRID_HEIGHT = 3;
|
||||
private ItemStack output = null;
|
||||
private Object[] input = null;
|
||||
private int width = 0;
|
||||
private int height = 0;
|
||||
private boolean mirrored = true;
|
||||
private boolean disable = false;
|
||||
|
||||
private ItemStack output = null;
|
||||
private Object[] input = null;
|
||||
private int width = 0;
|
||||
private int height = 0;
|
||||
private boolean mirrored = true;
|
||||
private boolean disable = false;
|
||||
public ShapedRecipe(final ItemStack result, Object... recipe) {
|
||||
this.output = result.copy();
|
||||
|
||||
public ShapedRecipe( final ItemStack result, Object... recipe )
|
||||
{
|
||||
this.output = result.copy();
|
||||
final StringBuilder shape = new StringBuilder();
|
||||
int idx = 0;
|
||||
|
||||
final StringBuilder shape = new StringBuilder();
|
||||
int idx = 0;
|
||||
if (recipe[idx] instanceof Boolean) {
|
||||
this.mirrored = (Boolean) recipe[idx];
|
||||
if (recipe[idx + 1] instanceof Object[]) {
|
||||
recipe = (Object[]) recipe[idx + 1];
|
||||
} else {
|
||||
idx = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if( recipe[idx] instanceof Boolean )
|
||||
{
|
||||
this.mirrored = (Boolean) recipe[idx];
|
||||
if( recipe[idx + 1] instanceof Object[] )
|
||||
{
|
||||
recipe = (Object[]) recipe[idx + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
idx = 1;
|
||||
}
|
||||
}
|
||||
if (recipe[idx] instanceof String[]) {
|
||||
final String[] parts = ((String[]) recipe[idx]);
|
||||
idx++;
|
||||
|
||||
if( recipe[idx] instanceof String[] )
|
||||
{
|
||||
final String[] parts = ( (String[]) recipe[idx] );
|
||||
idx++;
|
||||
for (final String s : parts) {
|
||||
this.width = s.length();
|
||||
shape.append(s);
|
||||
}
|
||||
|
||||
for( final String s : parts )
|
||||
{
|
||||
this.width = s.length();
|
||||
shape.append( s );
|
||||
}
|
||||
this.height = parts.length;
|
||||
} else {
|
||||
while (recipe[idx] instanceof String) {
|
||||
final String s = (String) recipe[idx];
|
||||
idx++;
|
||||
shape.append(s);
|
||||
this.width = s.length();
|
||||
this.height++;
|
||||
}
|
||||
}
|
||||
|
||||
this.height = parts.length;
|
||||
}
|
||||
else
|
||||
{
|
||||
while( recipe[idx] instanceof String )
|
||||
{
|
||||
final String s = (String) recipe[idx];
|
||||
idx++;
|
||||
shape.append( s );
|
||||
this.width = s.length();
|
||||
this.height++;
|
||||
}
|
||||
}
|
||||
if (this.width * this.height != shape.length()) {
|
||||
final StringBuilder ret = new StringBuilder("Invalid shaped ore recipe: ");
|
||||
for (final Object tmp : recipe) {
|
||||
ret.append(tmp).append(", ");
|
||||
}
|
||||
ret.append(this.output);
|
||||
throw new IllegalStateException(ret.toString());
|
||||
}
|
||||
|
||||
if( this.width * this.height != shape.length() )
|
||||
{
|
||||
final StringBuilder ret = new StringBuilder( "Invalid shaped ore recipe: " );
|
||||
for( final Object tmp : recipe )
|
||||
{
|
||||
ret.append( tmp ).append( ", " );
|
||||
}
|
||||
ret.append( this.output );
|
||||
throw new IllegalStateException( ret.toString() );
|
||||
}
|
||||
final Map<Character, IIngredient> itemMap = new HashMap<Character, IIngredient>();
|
||||
|
||||
final Map<Character, IIngredient> itemMap = new HashMap<Character, IIngredient>();
|
||||
for (; idx < recipe.length; idx += 2) {
|
||||
final Character chr = (Character) recipe[idx];
|
||||
final Object in = recipe[idx + 1];
|
||||
|
||||
for( ; idx < recipe.length; idx += 2 )
|
||||
{
|
||||
final Character chr = (Character) recipe[idx];
|
||||
final Object in = recipe[idx + 1];
|
||||
if (in instanceof IIngredient) {
|
||||
itemMap.put(chr, (IIngredient) in);
|
||||
} else {
|
||||
final StringBuilder ret = new StringBuilder("Invalid shaped ore recipe: ");
|
||||
for (final Object tmp : recipe) {
|
||||
ret.append(tmp).append(", ");
|
||||
}
|
||||
ret.append(this.output);
|
||||
throw new IllegalStateException(ret.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if( in instanceof IIngredient )
|
||||
{
|
||||
itemMap.put( chr, (IIngredient) in );
|
||||
}
|
||||
else
|
||||
{
|
||||
final StringBuilder ret = new StringBuilder( "Invalid shaped ore recipe: " );
|
||||
for( final Object tmp : recipe )
|
||||
{
|
||||
ret.append( tmp ).append( ", " );
|
||||
}
|
||||
ret.append( this.output );
|
||||
throw new IllegalStateException( ret.toString() );
|
||||
}
|
||||
}
|
||||
this.input = new Object[this.width * this.height];
|
||||
int x = 0;
|
||||
for (final char chr : shape.toString().toCharArray()) {
|
||||
this.input[x] = itemMap.get(chr);
|
||||
x++;
|
||||
}
|
||||
}
|
||||
|
||||
this.input = new Object[this.width * this.height];
|
||||
int x = 0;
|
||||
for( final char chr : shape.toString().toCharArray() )
|
||||
{
|
||||
this.input[x] = itemMap.get( chr );
|
||||
x++;
|
||||
}
|
||||
}
|
||||
public boolean isEnabled() {
|
||||
return !this.disable;
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return !this.disable;
|
||||
}
|
||||
@Override
|
||||
public boolean matches(final InventoryCrafting inv, final World world) {
|
||||
if (this.disable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches( final InventoryCrafting inv, final World world )
|
||||
{
|
||||
if( this.disable )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - this.width; x++) {
|
||||
for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - this.height; ++y) {
|
||||
if (this.checkMatch(inv, x, y, false)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for( int x = 0; x <= MAX_CRAFT_GRID_WIDTH - this.width; x++ )
|
||||
{
|
||||
for( int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - this.height; ++y )
|
||||
{
|
||||
if( this.checkMatch( inv, x, y, false ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (this.mirrored && this.checkMatch(inv, x, y, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( this.mirrored && this.checkMatch( inv, x, y, true ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getCraftingResult(final InventoryCrafting var1) {
|
||||
return this.output.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult( final InventoryCrafting var1 )
|
||||
{
|
||||
return this.output.copy();
|
||||
}
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return this.input.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize()
|
||||
{
|
||||
return this.input.length;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return this.output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
return this.output;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
private boolean checkMatch(final InventoryCrafting inv, final int startX, final int startY, final boolean mirror) {
|
||||
if (this.disable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
private boolean checkMatch( final InventoryCrafting inv, final int startX, final int startY, final boolean mirror )
|
||||
{
|
||||
if( this.disable )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) {
|
||||
for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) {
|
||||
final int subX = x - startX;
|
||||
final int subY = y - startY;
|
||||
Object target = null;
|
||||
|
||||
for( int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++ )
|
||||
{
|
||||
for( int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++ )
|
||||
{
|
||||
final int subX = x - startX;
|
||||
final int subY = y - startY;
|
||||
Object target = null;
|
||||
if (subX >= 0 && subY >= 0 && subX < this.width && subY < this.height) {
|
||||
if (mirror) {
|
||||
target = this.input[this.width - subX - 1 + subY * this.width];
|
||||
} else {
|
||||
target = this.input[subX + subY * this.width];
|
||||
}
|
||||
}
|
||||
|
||||
if( subX >= 0 && subY >= 0 && subX < this.width && subY < this.height )
|
||||
{
|
||||
if( mirror )
|
||||
{
|
||||
target = this.input[this.width - subX - 1 + subY * this.width];
|
||||
}
|
||||
else
|
||||
{
|
||||
target = this.input[subX + subY * this.width];
|
||||
}
|
||||
}
|
||||
final ItemStack slot = inv.getStackInRowAndColumn(x, y);
|
||||
|
||||
final ItemStack slot = inv.getStackInRowAndColumn( x, y );
|
||||
if (target instanceof IIngredient) {
|
||||
boolean matched = false;
|
||||
|
||||
if( target instanceof IIngredient )
|
||||
{
|
||||
boolean matched = false;
|
||||
try {
|
||||
for (final ItemStack item : ((IIngredient) target).getItemStackSet()) {
|
||||
matched = matched || this.checkItemEquals(item, slot);
|
||||
}
|
||||
} catch (final RegistrationError e) {
|
||||
// :P
|
||||
} catch (final MissingIngredientError e) {
|
||||
// :P
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
for( final ItemStack item : ( (IIngredient) target ).getItemStackSet() )
|
||||
{
|
||||
matched = matched || this.checkItemEquals( item, slot );
|
||||
}
|
||||
}
|
||||
catch( final RegistrationError e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
catch( final MissingIngredientError e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
if (!matched) {
|
||||
return false;
|
||||
}
|
||||
} else if (target instanceof ArrayList) {
|
||||
boolean matched = false;
|
||||
|
||||
if( !matched )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if( target instanceof ArrayList )
|
||||
{
|
||||
boolean matched = false;
|
||||
for (final ItemStack item : (Iterable<ItemStack>) target) {
|
||||
matched = matched || this.checkItemEquals(item, slot);
|
||||
}
|
||||
|
||||
for( final ItemStack item : (Iterable<ItemStack>) target )
|
||||
{
|
||||
matched = matched || this.checkItemEquals( item, slot );
|
||||
}
|
||||
if (!matched) {
|
||||
return false;
|
||||
}
|
||||
} else if (target == null && slot != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !matched )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if( target == null && slot != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
private boolean checkItemEquals(final ItemStack target, final ItemStack input) {
|
||||
if (input == null && target != null || input != null && target == null) {
|
||||
return false;
|
||||
}
|
||||
return (target.getItem() == input.getItem()
|
||||
&& (target.getItemDamage() == OreDictionary.WILDCARD_VALUE
|
||||
|| target.getItemDamage() == input.getItemDamage()));
|
||||
}
|
||||
|
||||
private boolean checkItemEquals( final ItemStack target, final ItemStack input )
|
||||
{
|
||||
if( input == null && target != null || input != null && target == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return( target.getItem() == input.getItem() && ( target.getItemDamage() == OreDictionary.WILDCARD_VALUE || target.getItemDamage() == input.getItemDamage() ) );
|
||||
}
|
||||
public ShapedRecipe setMirrored(final boolean mirror) {
|
||||
this.mirrored = mirror;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ShapedRecipe setMirrored( final boolean mirror )
|
||||
{
|
||||
this.mirrored = mirror;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Returns the input for this recipe, any mod accessing this value should never manipulate the values in this array
|
||||
* as it will effect the recipe itself.
|
||||
*
|
||||
* @return The recipes input vales.
|
||||
*/
|
||||
public Object[] getInput() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the input for this recipe, any mod accessing this value should never manipulate the values in this array
|
||||
* as it will effect the recipe itself.
|
||||
*
|
||||
* @return The recipes input vales.
|
||||
*/
|
||||
public Object[] getInput()
|
||||
{
|
||||
return this.input;
|
||||
}
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public int getWidth()
|
||||
{
|
||||
return this.width;
|
||||
}
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public int getHeight()
|
||||
{
|
||||
return this.height;
|
||||
}
|
||||
public Object[] getIngredients() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
public Object[] getIngredients()
|
||||
{
|
||||
return this.input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bake() throws RegistrationError
|
||||
{
|
||||
try
|
||||
{
|
||||
this.disable = false;
|
||||
for( final Object o : this.input )
|
||||
{
|
||||
if( o instanceof IIngredient )
|
||||
{
|
||||
( (IIngredient) o ).bake();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( final MissingIngredientError err )
|
||||
{
|
||||
this.disable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void bake() throws RegistrationError {
|
||||
try {
|
||||
this.disable = false;
|
||||
for (final Object o : this.input) {
|
||||
if (o instanceof IIngredient) {
|
||||
((IIngredient) o).bake();
|
||||
}
|
||||
}
|
||||
} catch (final MissingIngredientError err) {
|
||||
this.disable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+172
-160
@@ -22,202 +22,214 @@ import net.p455w0rd.wirelesscraftingterminal.items.ItemWirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
public class GuiCraftAmount extends WCTBaseGui {
|
||||
private GuiNumberBox amountToCraft;
|
||||
private GuiTabButton originalGuiBtn;
|
||||
private GuiNumberBox amountToCraft;
|
||||
private GuiTabButton originalGuiBtn;
|
||||
|
||||
private GuiButton next;
|
||||
private GuiButton next;
|
||||
|
||||
private GuiButton plus1;
|
||||
private GuiButton plus10;
|
||||
private GuiButton plus100;
|
||||
private GuiButton plus1000;
|
||||
private GuiButton minus1;
|
||||
private GuiButton minus10;
|
||||
private GuiButton minus100;
|
||||
private GuiButton minus1000;
|
||||
private GuiButton plus1;
|
||||
private GuiButton plus10;
|
||||
private GuiButton plus100;
|
||||
private GuiButton plus1000;
|
||||
private GuiButton minus1;
|
||||
private GuiButton minus10;
|
||||
private GuiButton minus100;
|
||||
private GuiButton minus1000;
|
||||
|
||||
private ItemStack myIcon;
|
||||
private ItemStack myIcon;
|
||||
|
||||
private int originalGui;
|
||||
private int originalGui;
|
||||
|
||||
@Reflected
|
||||
public GuiCraftAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
super(new ContainerCraftAmount(inventoryPlayer, te));
|
||||
ItemStack is = new ItemStack(ItemEnum.WIRELESS_CRAFTING_TERMINAL.getItem());
|
||||
((ItemWirelessCraftingTerminal) is.getItem()).injectAEPower(is, 6400001);
|
||||
myIcon = is;
|
||||
}
|
||||
@Reflected
|
||||
public GuiCraftAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
super(new ContainerCraftAmount(inventoryPlayer, te));
|
||||
ItemStack is = new ItemStack(ItemEnum.WIRELESS_CRAFTING_TERMINAL.getItem());
|
||||
((ItemWirelessCraftingTerminal) is.getItem()).injectAEPower(is, 6400001);
|
||||
myIcon = is;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "unused" })
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
@SuppressWarnings({"unchecked", "unused"})
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
final int a = AEConfig.instance.craftItemsByStackAmounts(0);
|
||||
final int b = AEConfig.instance.craftItemsByStackAmounts(1);
|
||||
final int c = AEConfig.instance.craftItemsByStackAmounts(2);
|
||||
final int d = AEConfig.instance.craftItemsByStackAmounts(3);
|
||||
final int a = AEConfig.instance.craftItemsByStackAmounts(0);
|
||||
final int b = AEConfig.instance.craftItemsByStackAmounts(1);
|
||||
final int c = AEConfig.instance.craftItemsByStackAmounts(2);
|
||||
final int d = AEConfig.instance.craftItemsByStackAmounts(3);
|
||||
|
||||
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a));
|
||||
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b));
|
||||
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c));
|
||||
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d));
|
||||
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a));
|
||||
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b));
|
||||
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c));
|
||||
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d));
|
||||
|
||||
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a));
|
||||
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b));
|
||||
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c));
|
||||
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d));
|
||||
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a));
|
||||
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b));
|
||||
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c));
|
||||
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d));
|
||||
|
||||
this.buttonList.add(this.next = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal()));
|
||||
final Object target = ((ContainerCraftAmount) this.inventorySlots).getTarget();
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
this.buttonList.add(
|
||||
this.next = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal()));
|
||||
final Object target = ((ContainerCraftAmount) this.inventorySlots).getTarget();
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
if (target instanceof WirelessTerminalGuiObject) {
|
||||
this.originalGui = Reference.GUI_WCT;
|
||||
}
|
||||
if (target instanceof WirelessTerminalGuiObject) {
|
||||
this.originalGui = Reference.GUI_WCT;
|
||||
}
|
||||
|
||||
if (this.originalGui > 0 && myIcon != null) {
|
||||
this.buttonList.add(this.originalGuiBtn = new GuiTabButton(this.guiLeft + 154, this.guiTop - 4, myIcon, myIcon.getDisplayName(), itemRender));
|
||||
}
|
||||
if (this.originalGui > 0 && myIcon != null) {
|
||||
this.buttonList.add(
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + 154, this.guiTop - 4, myIcon, myIcon.getDisplayName(), itemRender));
|
||||
}
|
||||
|
||||
this.amountToCraft = new GuiNumberBox(this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Integer.class);
|
||||
this.amountToCraft.setEnableBackgroundDrawing(false);
|
||||
this.amountToCraft.setMaxStringLength(16);
|
||||
this.amountToCraft.setTextColor(0xFFFFFF);
|
||||
this.amountToCraft.setVisible(true);
|
||||
this.amountToCraft.setFocused(true);
|
||||
this.amountToCraft.setText("1");
|
||||
}
|
||||
this.amountToCraft = new GuiNumberBox(
|
||||
this.fontRendererObj,
|
||||
this.guiLeft + 62,
|
||||
this.guiTop + 57,
|
||||
59,
|
||||
this.fontRendererObj.FONT_HEIGHT,
|
||||
Integer.class);
|
||||
this.amountToCraft.setEnableBackgroundDrawing(false);
|
||||
this.amountToCraft.setMaxStringLength(16);
|
||||
this.amountToCraft.setTextColor(0xFFFFFF);
|
||||
this.amountToCraft.setVisible(true);
|
||||
this.amountToCraft.setFocused(true);
|
||||
this.amountToCraft.setText("1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.fontRendererObj.drawString(GuiText.SelectAmount.getLocal(), 8, 6, 4210752);
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.fontRendererObj.drawString(GuiText.SelectAmount.getLocal(), 8, 6, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.next.displayString = isShiftKeyDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal();
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.next.displayString = isShiftKeyDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal();
|
||||
|
||||
this.bindTexture("appliedenergistics2", "guis/craftAmt.png");
|
||||
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
|
||||
this.bindTexture("appliedenergistics2", "guis/craftAmt.png");
|
||||
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
try {
|
||||
Long.parseLong(this.amountToCraft.getText());
|
||||
this.next.enabled = this.amountToCraft.getText().length() > 0;
|
||||
}
|
||||
catch (final NumberFormatException e) {
|
||||
this.next.enabled = false;
|
||||
}
|
||||
try {
|
||||
Long.parseLong(this.amountToCraft.getText());
|
||||
this.next.enabled = this.amountToCraft.getText().length() > 0;
|
||||
} catch (final NumberFormatException e) {
|
||||
this.next.enabled = false;
|
||||
}
|
||||
|
||||
this.amountToCraft.drawTextBox();
|
||||
}
|
||||
this.amountToCraft.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(final char character, final int key) {
|
||||
if (!this.checkHotbarKeys(key)) {
|
||||
if (key == 28) {
|
||||
this.actionPerformed(this.next);
|
||||
}
|
||||
if ((key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit(character)) && this.amountToCraft.textboxKeyTyped(character, key)) {
|
||||
try {
|
||||
String out = this.amountToCraft.getText();
|
||||
@Override
|
||||
protected void keyTyped(final char character, final int key) {
|
||||
if (!this.checkHotbarKeys(key)) {
|
||||
if (key == 28) {
|
||||
this.actionPerformed(this.next);
|
||||
}
|
||||
if ((key == 211
|
||||
|| key == 205
|
||||
|| key == 203
|
||||
|| key == 14
|
||||
|| character == '-'
|
||||
|| Character.isDigit(character))
|
||||
&& this.amountToCraft.textboxKeyTyped(character, key)) {
|
||||
try {
|
||||
String out = this.amountToCraft.getText();
|
||||
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
if (fixed) {
|
||||
this.amountToCraft.setText(out);
|
||||
}
|
||||
if (fixed) {
|
||||
this.amountToCraft.setText(out);
|
||||
}
|
||||
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
final long result = Long.parseLong(out);
|
||||
if (result < 0) {
|
||||
this.amountToCraft.setText("1");
|
||||
}
|
||||
}
|
||||
catch (final NumberFormatException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.keyTyped(character, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
final long result = Long.parseLong(out);
|
||||
if (result < 0) {
|
||||
this.amountToCraft.setText("1");
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
// :P
|
||||
}
|
||||
} else {
|
||||
super.keyTyped(character, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
|
||||
try {
|
||||
try {
|
||||
|
||||
if (btn == this.originalGuiBtn) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(this.originalGui));
|
||||
}
|
||||
if (btn == this.originalGuiBtn) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(this.originalGui));
|
||||
}
|
||||
|
||||
if (btn == this.next) {
|
||||
NetworkHandler.instance.sendToServer(new PacketCraftRequest(Integer.parseInt(this.amountToCraft.getText()), isShiftKeyDown()));
|
||||
}
|
||||
}
|
||||
catch (final NumberFormatException e) {
|
||||
// nope..
|
||||
this.amountToCraft.setText("1");
|
||||
}
|
||||
if (btn == this.next) {
|
||||
NetworkHandler.instance.sendToServer(
|
||||
new PacketCraftRequest(Integer.parseInt(this.amountToCraft.getText()), isShiftKeyDown()));
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
// nope..
|
||||
this.amountToCraft.setText("1");
|
||||
}
|
||||
|
||||
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
|
||||
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
|
||||
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
|
||||
final boolean isMinus =
|
||||
btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
|
||||
|
||||
if (isPlus || isMinus) {
|
||||
this.addQty(this.getQty(btn));
|
||||
}
|
||||
}
|
||||
if (isPlus || isMinus) {
|
||||
this.addQty(this.getQty(btn));
|
||||
}
|
||||
}
|
||||
|
||||
private void addQty(final int i) {
|
||||
try {
|
||||
String out = this.amountToCraft.getText();
|
||||
private void addQty(final int i) {
|
||||
try {
|
||||
String out = this.amountToCraft.getText();
|
||||
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
if (fixed) {
|
||||
this.amountToCraft.setText(out);
|
||||
}
|
||||
if (fixed) {
|
||||
this.amountToCraft.setText(out);
|
||||
}
|
||||
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
long result = Integer.parseInt(out);
|
||||
long result = Integer.parseInt(out);
|
||||
|
||||
if (result == 1 && i > 1) {
|
||||
result = 0;
|
||||
}
|
||||
if (result == 1 && i > 1) {
|
||||
result = 0;
|
||||
}
|
||||
|
||||
result += i;
|
||||
if (result < 1) {
|
||||
result = 1;
|
||||
}
|
||||
result += i;
|
||||
if (result < 1) {
|
||||
result = 1;
|
||||
}
|
||||
|
||||
out = Long.toString(result);
|
||||
Integer.parseInt(out);
|
||||
this.amountToCraft.setText(out);
|
||||
}
|
||||
catch (final NumberFormatException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
out = Long.toString(result);
|
||||
Integer.parseInt(out);
|
||||
this.amountToCraft.setText(out);
|
||||
} catch (final NumberFormatException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground() {
|
||||
return "guis/craftAmt.png";
|
||||
}
|
||||
protected String getBackground() {
|
||||
return "guis/craftAmt.png";
|
||||
}
|
||||
}
|
||||
+397
-380
@@ -1,23 +1,18 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.client.gui;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.util.Platform;
|
||||
import com.google.common.base.Joiner;
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -29,469 +24,491 @@ import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwitchGuis;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketValueConfig;
|
||||
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiCraftConfirm extends WCTBaseGui {
|
||||
|
||||
private final ContainerCraftConfirm ccc;
|
||||
private final ContainerCraftConfirm ccc;
|
||||
|
||||
private final int rows = 5;
|
||||
private final int rows = 5;
|
||||
|
||||
private final IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
|
||||
private final IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
|
||||
private final IItemList<IAEItemStack> missing = AEApi.instance().storage().createItemList();
|
||||
private final IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
|
||||
private final IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
|
||||
private final IItemList<IAEItemStack> missing = AEApi.instance().storage().createItemList();
|
||||
|
||||
private final List<IAEItemStack> visual = new ArrayList<IAEItemStack>();
|
||||
private final List<IAEItemStack> visual = new ArrayList<IAEItemStack>();
|
||||
|
||||
private int OriginalGui = 0;
|
||||
private GuiButton cancel;
|
||||
private GuiButton start;
|
||||
private GuiButton selectCPU;
|
||||
private int tooltip = -1;
|
||||
InventoryPlayer inventoryPlayer;
|
||||
private static int jobBytes;
|
||||
private static int currCPUAvailBytes;
|
||||
private static int currCPUCoCPUs;
|
||||
private int OriginalGui = 0;
|
||||
private GuiButton cancel;
|
||||
private GuiButton start;
|
||||
private GuiButton selectCPU;
|
||||
private int tooltip = -1;
|
||||
InventoryPlayer inventoryPlayer;
|
||||
private static int jobBytes;
|
||||
private static int currCPUAvailBytes;
|
||||
private static int currCPUCoCPUs;
|
||||
|
||||
public GuiCraftConfirm(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
super(new ContainerCraftConfirm(inventoryPlayer, te));
|
||||
this.xSize = 238;
|
||||
this.ySize = 206;
|
||||
public GuiCraftConfirm(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
super(new ContainerCraftConfirm(inventoryPlayer, te));
|
||||
this.xSize = 238;
|
||||
this.ySize = 206;
|
||||
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
this.setScrollBar(scrollbar);
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
this.setScrollBar(scrollbar);
|
||||
|
||||
this.ccc = (ContainerCraftConfirm) this.inventorySlots;
|
||||
this.inventoryPlayer = inventoryPlayer;
|
||||
this.ccc = (ContainerCraftConfirm) this.inventorySlots;
|
||||
this.inventoryPlayer = inventoryPlayer;
|
||||
|
||||
if (te instanceof WirelessTerminalGuiObject) {
|
||||
this.OriginalGui = Reference.GUI_WCT;
|
||||
}
|
||||
if (te instanceof WirelessTerminalGuiObject) {
|
||||
this.OriginalGui = Reference.GUI_WCT;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
boolean isAutoStart() {
|
||||
return ((ContainerCraftConfirm) this.inventorySlots).isAutoStart();
|
||||
}
|
||||
|
||||
boolean isAutoStart() {
|
||||
return ((ContainerCraftConfirm) this.inventorySlots).isAutoStart();
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.start =
|
||||
new GuiButton(0, this.guiLeft + 162, this.guiTop + this.ySize - 25, 50, 20, GuiText.Start.getLocal());
|
||||
this.start.enabled = false;
|
||||
this.buttonList.add(this.start);
|
||||
|
||||
this.start = new GuiButton(0, this.guiLeft + 162, this.guiTop + this.ySize - 25, 50, 20, GuiText.Start.getLocal());
|
||||
this.start.enabled = false;
|
||||
this.buttonList.add(this.start);
|
||||
this.selectCPU = new GuiButton(
|
||||
0,
|
||||
this.guiLeft + (219 - 180) / 2,
|
||||
this.guiTop + this.ySize - 68,
|
||||
180,
|
||||
20,
|
||||
GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic);
|
||||
this.selectCPU.enabled = false;
|
||||
this.buttonList.add(this.selectCPU);
|
||||
|
||||
this.selectCPU = new GuiButton(0, this.guiLeft + (219 - 180) / 2, this.guiTop + this.ySize - 68, 180, 20, GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic);
|
||||
this.selectCPU.enabled = false;
|
||||
this.buttonList.add(this.selectCPU);
|
||||
if (this.OriginalGui > 0) {
|
||||
this.cancel = new GuiButton(
|
||||
0, this.guiLeft + 6, this.guiTop + this.ySize - 25, 50, 20, GuiText.Cancel.getLocal());
|
||||
}
|
||||
|
||||
if (this.OriginalGui > 0) {
|
||||
this.cancel = new GuiButton(0, this.guiLeft + 6, this.guiTop + this.ySize - 25, 50, 20, GuiText.Cancel.getLocal());
|
||||
}
|
||||
this.buttonList.add(this.cancel);
|
||||
}
|
||||
|
||||
this.buttonList.add(this.cancel);
|
||||
}
|
||||
@Override
|
||||
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
|
||||
this.updateCPUButtonText();
|
||||
|
||||
@Override
|
||||
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
|
||||
this.updateCPUButtonText();
|
||||
this.start.enabled = !(this.ccc.hasNoCPU() || this.isSimulation());
|
||||
this.selectCPU.enabled = !this.isSimulation();
|
||||
|
||||
this.start.enabled = !(this.ccc.hasNoCPU() || this.isSimulation());
|
||||
this.selectCPU.enabled = !this.isSimulation();
|
||||
final int gx = (this.width - this.xSize) / 2;
|
||||
final int gy = (this.height - this.ySize) / 2;
|
||||
|
||||
final int gx = (this.width - this.xSize) / 2;
|
||||
final int gy = (this.height - this.ySize) / 2;
|
||||
this.tooltip = -1;
|
||||
|
||||
this.tooltip = -1;
|
||||
final int offY = 23;
|
||||
int y = 0;
|
||||
int x = 0;
|
||||
for (int z = 0; z <= 4 * 5; z++) {
|
||||
final int minX = gx + 9 + x * 67;
|
||||
final int minY = gy + 22 + y * offY;
|
||||
|
||||
final int offY = 23;
|
||||
int y = 0;
|
||||
int x = 0;
|
||||
for (int z = 0; z <= 4 * 5; z++) {
|
||||
final int minX = gx + 9 + x * 67;
|
||||
final int minY = gy + 22 + y * offY;
|
||||
if (minX < mouseX && minX + 67 > mouseX) {
|
||||
if (minY < mouseY && minY + offY - 2 > mouseY) {
|
||||
this.tooltip = z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (minX < mouseX && minX + 67 > mouseX) {
|
||||
if (minY < mouseY && minY + offY - 2 > mouseY) {
|
||||
this.tooltip = z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
x++;
|
||||
|
||||
x++;
|
||||
if (x > 2) {
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (x > 2) {
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
super.drawScreen(mouseX, mouseY, btn);
|
||||
}
|
||||
|
||||
super.drawScreen(mouseX, mouseY, btn);
|
||||
}
|
||||
private void updateCPUButtonText() {
|
||||
String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal();
|
||||
if (this.ccc.getSelectedCpu() >= 0) // && status.selectedCpu < status.cpus.size() )
|
||||
{
|
||||
if (this.ccc.getName().length() > 0) {
|
||||
final String name = this.ccc
|
||||
.getName()
|
||||
.substring(0, Math.min(20, this.ccc.getName().length()));
|
||||
btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name;
|
||||
} else {
|
||||
btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + this.ccc.getSelectedCpu();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCPUButtonText() {
|
||||
String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal();
|
||||
if (this.ccc.getSelectedCpu() >= 0)// && status.selectedCpu < status.cpus.size() )
|
||||
{
|
||||
if (this.ccc.getName().length() > 0) {
|
||||
final String name = this.ccc.getName().substring(0, Math.min(20, this.ccc.getName().length()));
|
||||
btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name;
|
||||
}
|
||||
else {
|
||||
btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + this.ccc.getSelectedCpu();
|
||||
}
|
||||
}
|
||||
if (this.ccc.hasNoCPU()) {
|
||||
btnTextText = GuiText.NoCraftingCPUs.getLocal();
|
||||
}
|
||||
|
||||
if (this.ccc.hasNoCPU()) {
|
||||
btnTextText = GuiText.NoCraftingCPUs.getLocal();
|
||||
}
|
||||
this.selectCPU.displayString = btnTextText;
|
||||
}
|
||||
|
||||
this.selectCPU.displayString = btnTextText;
|
||||
}
|
||||
private boolean isSimulation() {
|
||||
return ((ContainerCraftConfirm) this.inventorySlots).isSimulation();
|
||||
}
|
||||
|
||||
private boolean isSimulation() {
|
||||
return ((ContainerCraftConfirm) this.inventorySlots).isSimulation();
|
||||
}
|
||||
|
||||
public int getJobBytes() {
|
||||
return GuiCraftConfirm.jobBytes;
|
||||
}
|
||||
public int getJobBytes() {
|
||||
return GuiCraftConfirm.jobBytes;
|
||||
}
|
||||
|
||||
public static void setJobBytes( int numBytes ) {
|
||||
jobBytes = numBytes;
|
||||
}
|
||||
|
||||
public int getCurrentCPUAvailBytes() {
|
||||
return GuiCraftConfirm.currCPUAvailBytes;
|
||||
}
|
||||
public static void setJobBytes(int numBytes) {
|
||||
jobBytes = numBytes;
|
||||
}
|
||||
|
||||
public static void setCurrentCPUAvailBytes( int numBytes ) {
|
||||
currCPUAvailBytes = numBytes;
|
||||
}
|
||||
|
||||
public int getCurrentCPUCoCPUs() {
|
||||
return GuiCraftConfirm.currCPUCoCPUs;
|
||||
}
|
||||
public int getCurrentCPUAvailBytes() {
|
||||
return GuiCraftConfirm.currCPUAvailBytes;
|
||||
}
|
||||
|
||||
public static void setCurrentCPUCoCPUs( int coCPUs ) {
|
||||
currCPUCoCPUs = coCPUs;
|
||||
}
|
||||
public static void setCurrentCPUAvailBytes(int numBytes) {
|
||||
currCPUAvailBytes = numBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
int bytesUsed = this.getJobBytes();
|
||||
int availBytes = this.getCurrentCPUAvailBytes();
|
||||
int availCoCPUs = this.getCurrentCPUCoCPUs();
|
||||
String byteUsed = NumberFormat.getInstance().format(bytesUsed);
|
||||
public int getCurrentCPUCoCPUs() {
|
||||
return GuiCraftConfirm.currCPUCoCPUs;
|
||||
}
|
||||
|
||||
final String Add = bytesUsed > 0 ? (byteUsed + ' ' + GuiText.BytesUsed.getLocal()) : GuiText.CalculatingWait.getLocal();
|
||||
this.fontRendererObj.drawString(GuiText.CraftingPlan.getLocal() + " -- " + Add, 8, 7, 4210752);
|
||||
public static void setCurrentCPUCoCPUs(int coCPUs) {
|
||||
currCPUCoCPUs = coCPUs;
|
||||
}
|
||||
|
||||
String dsp = null;
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
int bytesUsed = this.getJobBytes();
|
||||
int availBytes = this.getCurrentCPUAvailBytes();
|
||||
int availCoCPUs = this.getCurrentCPUCoCPUs();
|
||||
String byteUsed = NumberFormat.getInstance().format(bytesUsed);
|
||||
|
||||
if (this.isSimulation()) {
|
||||
dsp = GuiText.Simulation.getLocal();
|
||||
}
|
||||
else {
|
||||
dsp = availBytes > 0 ? (GuiText.Bytes.getLocal() + ": " + availBytes + " : " + GuiText.CoProcessors.getLocal() + ": " + availCoCPUs) : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
|
||||
}
|
||||
final String Add =
|
||||
bytesUsed > 0 ? (byteUsed + ' ' + GuiText.BytesUsed.getLocal()) : GuiText.CalculatingWait.getLocal();
|
||||
this.fontRendererObj.drawString(GuiText.CraftingPlan.getLocal() + " -- " + Add, 8, 7, 4210752);
|
||||
|
||||
final int offset = (219 - this.fontRendererObj.getStringWidth(dsp)) / 2;
|
||||
this.fontRendererObj.drawString(dsp, offset, 165, 4210752);
|
||||
String dsp = null;
|
||||
|
||||
final int sectionLength = 67;
|
||||
if (this.isSimulation()) {
|
||||
dsp = GuiText.Simulation.getLocal();
|
||||
} else {
|
||||
dsp = availBytes > 0
|
||||
? (GuiText.Bytes.getLocal() + ": " + availBytes + " : " + GuiText.CoProcessors.getLocal() + ": "
|
||||
+ availCoCPUs)
|
||||
: GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
|
||||
}
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
final int xo = 9;
|
||||
final int yo = 22;
|
||||
final int viewStart = this.getScrollBar().getCurrentScroll() * 3;
|
||||
final int viewEnd = viewStart + 3 * this.rows;
|
||||
final int offset = (219 - this.fontRendererObj.getStringWidth(dsp)) / 2;
|
||||
this.fontRendererObj.drawString(dsp, offset, 165, 4210752);
|
||||
|
||||
String dspToolTip = "";
|
||||
final List<String> lineList = new LinkedList<String>();
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
final int sectionLength = 67;
|
||||
|
||||
final int offY = 23;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
final int xo = 9;
|
||||
final int yo = 22;
|
||||
final int viewStart = this.getScrollBar().getCurrentScroll() * 3;
|
||||
final int viewEnd = viewStart + 3 * this.rows;
|
||||
|
||||
for (int z = viewStart; z < Math.min(viewEnd, this.visual.size()); z++) {
|
||||
final IAEItemStack refStack = this.visual.get(z);// repo.getReferenceItem( z );
|
||||
if (refStack != null) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled(0.5, 0.5, 0.5);
|
||||
String dspToolTip = "";
|
||||
final List<String> lineList = new LinkedList<String>();
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
|
||||
final IAEItemStack stored = this.storage.findPrecise(refStack);
|
||||
final IAEItemStack pendingStack = this.pending.findPrecise(refStack);
|
||||
final IAEItemStack missingStack = this.missing.findPrecise(refStack);
|
||||
final int offY = 23;
|
||||
|
||||
int lines = 0;
|
||||
for (int z = viewStart; z < Math.min(viewEnd, this.visual.size()); z++) {
|
||||
final IAEItemStack refStack = this.visual.get(z); // repo.getReferenceItem( z );
|
||||
if (refStack != null) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled(0.5, 0.5, 0.5);
|
||||
|
||||
if (stored != null && stored.getStackSize() > 0) {
|
||||
lines++;
|
||||
}
|
||||
if (pendingStack != null && pendingStack.getStackSize() > 0) {
|
||||
lines++;
|
||||
}
|
||||
if (pendingStack != null && pendingStack.getStackSize() > 0) {
|
||||
lines++;
|
||||
}
|
||||
final IAEItemStack stored = this.storage.findPrecise(refStack);
|
||||
final IAEItemStack pendingStack = this.pending.findPrecise(refStack);
|
||||
final IAEItemStack missingStack = this.missing.findPrecise(refStack);
|
||||
|
||||
final int negY = ((lines - 1) * 5) / 2;
|
||||
int downY = 0;
|
||||
int lines = 0;
|
||||
|
||||
if (stored != null && stored.getStackSize() > 0) {
|
||||
String str = Long.toString(stored.getStackSize());
|
||||
if (stored.getStackSize() >= 10000) {
|
||||
str = Long.toString(stored.getStackSize() / 1000) + 'k';
|
||||
}
|
||||
if (stored.getStackSize() >= 10000000) {
|
||||
str = Long.toString(stored.getStackSize() / 1000000) + 'm';
|
||||
}
|
||||
if (stored != null && stored.getStackSize() > 0) {
|
||||
lines++;
|
||||
}
|
||||
if (pendingStack != null && pendingStack.getStackSize() > 0) {
|
||||
lines++;
|
||||
}
|
||||
if (pendingStack != null && pendingStack.getStackSize() > 0) {
|
||||
lines++;
|
||||
}
|
||||
|
||||
str = GuiText.FromStorage.getLocal() + ": " + str;
|
||||
final int w = 4 + this.fontRendererObj.getStringWidth(str);
|
||||
this.fontRendererObj.drawString(str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo + 6 - negY + downY) * 2, 4210752);
|
||||
final int negY = ((lines - 1) * 5) / 2;
|
||||
int downY = 0;
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
lineList.add(GuiText.FromStorage.getLocal() + ": " + Long.toString(stored.getStackSize()));
|
||||
}
|
||||
if (stored != null && stored.getStackSize() > 0) {
|
||||
String str = Long.toString(stored.getStackSize());
|
||||
if (stored.getStackSize() >= 10000) {
|
||||
str = Long.toString(stored.getStackSize() / 1000) + 'k';
|
||||
}
|
||||
if (stored.getStackSize() >= 10000000) {
|
||||
str = Long.toString(stored.getStackSize() / 1000000) + 'm';
|
||||
}
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
str = GuiText.FromStorage.getLocal() + ": " + str;
|
||||
final int w = 4 + this.fontRendererObj.getStringWidth(str);
|
||||
this.fontRendererObj.drawString(
|
||||
str,
|
||||
(int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2),
|
||||
(y * offY + yo + 6 - negY + downY) * 2,
|
||||
4210752);
|
||||
|
||||
boolean red = false;
|
||||
if (missingStack != null && missingStack.getStackSize() > 0) {
|
||||
String str = Long.toString(missingStack.getStackSize());
|
||||
if (missingStack.getStackSize() >= 10000) {
|
||||
str = Long.toString(missingStack.getStackSize() / 1000) + 'k';
|
||||
}
|
||||
if (missingStack.getStackSize() >= 10000000) {
|
||||
str = Long.toString(missingStack.getStackSize() / 1000000) + 'm';
|
||||
}
|
||||
if (this.tooltip == z - viewStart) {
|
||||
lineList.add(GuiText.FromStorage.getLocal() + ": " + Long.toString(stored.getStackSize()));
|
||||
}
|
||||
|
||||
str = GuiText.Missing.getLocal() + ": " + str;
|
||||
final int w = 4 + this.fontRendererObj.getStringWidth(str);
|
||||
this.fontRendererObj.drawString(str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo + 6 - negY + downY) * 2, 4210752);
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
lineList.add(GuiText.Missing.getLocal() + ": " + Long.toString(missingStack.getStackSize()));
|
||||
}
|
||||
boolean red = false;
|
||||
if (missingStack != null && missingStack.getStackSize() > 0) {
|
||||
String str = Long.toString(missingStack.getStackSize());
|
||||
if (missingStack.getStackSize() >= 10000) {
|
||||
str = Long.toString(missingStack.getStackSize() / 1000) + 'k';
|
||||
}
|
||||
if (missingStack.getStackSize() >= 10000000) {
|
||||
str = Long.toString(missingStack.getStackSize() / 1000000) + 'm';
|
||||
}
|
||||
|
||||
red = true;
|
||||
downY += 5;
|
||||
}
|
||||
str = GuiText.Missing.getLocal() + ": " + str;
|
||||
final int w = 4 + this.fontRendererObj.getStringWidth(str);
|
||||
this.fontRendererObj.drawString(
|
||||
str,
|
||||
(int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2),
|
||||
(y * offY + yo + 6 - negY + downY) * 2,
|
||||
4210752);
|
||||
|
||||
if (pendingStack != null && pendingStack.getStackSize() > 0) {
|
||||
String str = Long.toString(pendingStack.getStackSize());
|
||||
if (pendingStack.getStackSize() >= 10000) {
|
||||
str = Long.toString(pendingStack.getStackSize() / 1000) + 'k';
|
||||
}
|
||||
if (pendingStack.getStackSize() >= 10000000) {
|
||||
str = Long.toString(pendingStack.getStackSize() / 1000000) + 'm';
|
||||
}
|
||||
if (this.tooltip == z - viewStart) {
|
||||
lineList.add(GuiText.Missing.getLocal() + ": " + Long.toString(missingStack.getStackSize()));
|
||||
}
|
||||
|
||||
str = GuiText.ToCraft.getLocal() + ": " + str;
|
||||
final int w = 4 + this.fontRendererObj.getStringWidth(str);
|
||||
this.fontRendererObj.drawString(str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo + 6 - negY + downY) * 2, 4210752);
|
||||
red = true;
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
lineList.add(GuiText.ToCraft.getLocal() + ": " + Long.toString(pendingStack.getStackSize()));
|
||||
}
|
||||
}
|
||||
if (pendingStack != null && pendingStack.getStackSize() > 0) {
|
||||
String str = Long.toString(pendingStack.getStackSize());
|
||||
if (pendingStack.getStackSize() >= 10000) {
|
||||
str = Long.toString(pendingStack.getStackSize() / 1000) + 'k';
|
||||
}
|
||||
if (pendingStack.getStackSize() >= 10000000) {
|
||||
str = Long.toString(pendingStack.getStackSize() / 1000000) + 'm';
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
final int posX = x * (1 + sectionLength) + xo + sectionLength - 19;
|
||||
final int posY = y * offY + yo;
|
||||
str = GuiText.ToCraft.getLocal() + ": " + str;
|
||||
final int w = 4 + this.fontRendererObj.getStringWidth(str);
|
||||
this.fontRendererObj.drawString(
|
||||
str,
|
||||
(int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2),
|
||||
(y * offY + yo + 6 - negY + downY) * 2,
|
||||
4210752);
|
||||
|
||||
final ItemStack is = refStack.copy().getItemStack();
|
||||
if (this.tooltip == z - viewStart) {
|
||||
lineList.add(GuiText.ToCraft.getLocal() + ": " + Long.toString(pendingStack.getStackSize()));
|
||||
}
|
||||
}
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
dspToolTip = Platform.getItemDisplayName(is);
|
||||
GL11.glPopMatrix();
|
||||
final int posX = x * (1 + sectionLength) + xo + sectionLength - 19;
|
||||
final int posY = y * offY + yo;
|
||||
|
||||
if (lineList.size() > 0) {
|
||||
final ItemStack is = refStack.copy().getItemStack();
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
dspToolTip = Platform.getItemDisplayName(is);
|
||||
|
||||
if (lineList.size() > 0) {
|
||||
addItemTooltip(is, lineList);
|
||||
dspToolTip = dspToolTip + '\n' + Joiner.on("\n").join(lineList);
|
||||
}
|
||||
dspToolTip = dspToolTip + '\n' + Joiner.on("\n").join(lineList);
|
||||
}
|
||||
|
||||
toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8;
|
||||
toolPosY = y * offY + yo;
|
||||
}
|
||||
toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8;
|
||||
toolPosY = y * offY + yo;
|
||||
}
|
||||
|
||||
this.drawItem(posX, posY, is);
|
||||
this.drawItem(posX, posY, is);
|
||||
|
||||
if (red) {
|
||||
final int startX = x * (1 + sectionLength) + xo;
|
||||
final int startY = posY - 4;
|
||||
drawRect(startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000);
|
||||
}
|
||||
if (red) {
|
||||
final int startX = x * (1 + sectionLength) + xo;
|
||||
final int startY = posY - 4;
|
||||
drawRect(startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000);
|
||||
}
|
||||
|
||||
x++;
|
||||
x++;
|
||||
|
||||
if (x > 2) {
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (x > 2) {
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.tooltip >= 0 && dspToolTip.length() > 0) {
|
||||
this.drawTooltip(toolPosX, toolPosY + 10, 0, dspToolTip);
|
||||
}
|
||||
}
|
||||
if (this.tooltip >= 0 && dspToolTip.length() > 0) {
|
||||
this.drawTooltip(toolPosX, toolPosY + 10, 0, dspToolTip);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.setScrollBar();
|
||||
this.bindTexture("appliedenergistics2", "guis/craftingreport.png");
|
||||
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.setScrollBar();
|
||||
this.bindTexture("appliedenergistics2", "guis/craftingreport.png");
|
||||
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
|
||||
private void setScrollBar() {
|
||||
final int size = this.visual.size();
|
||||
private void setScrollBar() {
|
||||
final int size = this.visual.size();
|
||||
|
||||
this.getScrollBar().setTop(19).setLeft(218).setHeight(114);
|
||||
this.getScrollBar().setRange(0, (size + 2) / 3 - this.rows, 1);
|
||||
}
|
||||
this.getScrollBar().setTop(19).setLeft(218).setHeight(114);
|
||||
this.getScrollBar().setRange(0, (size + 2) / 3 - this.rows, 1);
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEItemStack> list, final byte ref) {
|
||||
switch (ref) {
|
||||
case 0:
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.storage, l);
|
||||
}
|
||||
break;
|
||||
public void postUpdate(final List<IAEItemStack> list, final byte ref) {
|
||||
switch (ref) {
|
||||
case 0:
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.storage, l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.pending, l);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.pending, l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.missing, l);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.missing, l);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (final IAEItemStack l : list) {
|
||||
final long amt = this.getTotal(l);
|
||||
for (final IAEItemStack l : list) {
|
||||
final long amt = this.getTotal(l);
|
||||
|
||||
if (amt <= 0) {
|
||||
this.deleteVisualStack(l);
|
||||
}
|
||||
else {
|
||||
final IAEItemStack is = this.findVisualStack(l);
|
||||
is.setStackSize(amt);
|
||||
}
|
||||
}
|
||||
if (amt <= 0) {
|
||||
this.deleteVisualStack(l);
|
||||
} else {
|
||||
final IAEItemStack is = this.findVisualStack(l);
|
||||
is.setStackSize(amt);
|
||||
}
|
||||
}
|
||||
|
||||
this.setScrollBar();
|
||||
}
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void handleInput(final IItemList<IAEItemStack> s, final IAEItemStack l) {
|
||||
IAEItemStack a = s.findPrecise(l);
|
||||
private void handleInput(final IItemList<IAEItemStack> s, final IAEItemStack l) {
|
||||
IAEItemStack a = s.findPrecise(l);
|
||||
|
||||
if (l.getStackSize() <= 0) {
|
||||
if (a != null) {
|
||||
a.reset();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (a == null) {
|
||||
s.add(l.copy());
|
||||
a = s.findPrecise(l);
|
||||
}
|
||||
if (l.getStackSize() <= 0) {
|
||||
if (a != null) {
|
||||
a.reset();
|
||||
}
|
||||
} else {
|
||||
if (a == null) {
|
||||
s.add(l.copy());
|
||||
a = s.findPrecise(l);
|
||||
}
|
||||
|
||||
if (a != null) {
|
||||
a.setStackSize(l.getStackSize());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (a != null) {
|
||||
a.setStackSize(l.getStackSize());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long getTotal(final IAEItemStack is) {
|
||||
final IAEItemStack a = this.storage.findPrecise(is);
|
||||
final IAEItemStack c = this.pending.findPrecise(is);
|
||||
final IAEItemStack m = this.missing.findPrecise(is);
|
||||
private long getTotal(final IAEItemStack is) {
|
||||
final IAEItemStack a = this.storage.findPrecise(is);
|
||||
final IAEItemStack c = this.pending.findPrecise(is);
|
||||
final IAEItemStack m = this.missing.findPrecise(is);
|
||||
|
||||
long total = 0;
|
||||
long total = 0;
|
||||
|
||||
if (a != null) {
|
||||
total += a.getStackSize();
|
||||
}
|
||||
if (a != null) {
|
||||
total += a.getStackSize();
|
||||
}
|
||||
|
||||
if (c != null) {
|
||||
total += c.getStackSize();
|
||||
}
|
||||
if (c != null) {
|
||||
total += c.getStackSize();
|
||||
}
|
||||
|
||||
if (m != null) {
|
||||
total += m.getStackSize();
|
||||
}
|
||||
if (m != null) {
|
||||
total += m.getStackSize();
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
private void deleteVisualStack(final IAEItemStack l) {
|
||||
final Iterator<IAEItemStack> i = this.visual.iterator();
|
||||
while (i.hasNext()) {
|
||||
final IAEItemStack o = i.next();
|
||||
if (o.equals(l)) {
|
||||
i.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void deleteVisualStack(final IAEItemStack l) {
|
||||
final Iterator<IAEItemStack> i = this.visual.iterator();
|
||||
while (i.hasNext()) {
|
||||
final IAEItemStack o = i.next();
|
||||
if (o.equals(l)) {
|
||||
i.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IAEItemStack findVisualStack(final IAEItemStack l) {
|
||||
for (final IAEItemStack o : this.visual) {
|
||||
if (o.equals(l)) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
private IAEItemStack findVisualStack(final IAEItemStack l) {
|
||||
for (final IAEItemStack o : this.visual) {
|
||||
if (o.equals(l)) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
final IAEItemStack stack = l.copy();
|
||||
this.visual.add(stack);
|
||||
return stack;
|
||||
}
|
||||
final IAEItemStack stack = l.copy();
|
||||
this.visual.add(stack);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(final char character, final int key) {
|
||||
if (!this.checkHotbarKeys(key)) {
|
||||
if (key == 28) {
|
||||
this.actionPerformed(this.start);
|
||||
}
|
||||
super.keyTyped(character, key);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void keyTyped(final char character, final int key) {
|
||||
if (!this.checkHotbarKeys(key)) {
|
||||
if (key == 28) {
|
||||
this.actionPerformed(this.start);
|
||||
}
|
||||
super.keyTyped(character, key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
|
||||
final boolean backwards = Mouse.isButtonDown(1);
|
||||
final boolean backwards = Mouse.isButtonDown(1);
|
||||
|
||||
if (btn == this.selectCPU) {
|
||||
try {
|
||||
NetworkHandler.instance.sendToServer(new PacketValueConfig("Terminal.Cpu", backwards ? "Prev" : "Next"));
|
||||
}
|
||||
catch (final IOException e) {
|
||||
WCTLog.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
if (btn == this.selectCPU) {
|
||||
try {
|
||||
NetworkHandler.instance.sendToServer(
|
||||
new PacketValueConfig("Terminal.Cpu", backwards ? "Prev" : "Next"));
|
||||
} catch (final IOException e) {
|
||||
WCTLog.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (btn == this.cancel) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(this.OriginalGui));
|
||||
}
|
||||
if (btn == this.cancel) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(this.OriginalGui));
|
||||
}
|
||||
|
||||
if (btn == this.start) {
|
||||
try {
|
||||
NetworkHandler.instance.sendToServer(new PacketValueConfig("Terminal.Start", "Start"));
|
||||
}
|
||||
catch (final Throwable e) {
|
||||
WCTLog.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (btn == this.start) {
|
||||
try {
|
||||
NetworkHandler.instance.sendToServer(new PacketValueConfig("Terminal.Start", "Start"));
|
||||
} catch (final Throwable e) {
|
||||
WCTLog.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,476 +0,0 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.client.gui;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.lang3.time.DurationFormatUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.ReadableNumberConverter;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.widgets.GuiScrollbar;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftingCPU;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketValueConfig;
|
||||
|
||||
|
||||
public class GuiCraftingCPU extends WCTBaseGui implements ISortSource
|
||||
{
|
||||
private static final int GUI_HEIGHT = 184;
|
||||
private static final int GUI_WIDTH = 238;
|
||||
|
||||
private static final int DISPLAYED_ROWS = 6;
|
||||
|
||||
private static final int TEXT_COLOR = 0x404040;
|
||||
private static final int BACKGROUND_ALPHA = 0x5A000000;
|
||||
|
||||
private static final int SECTION_LENGTH = 67;
|
||||
|
||||
private static final int SCROLLBAR_TOP = 19;
|
||||
private static final int SCROLLBAR_LEFT = 218;
|
||||
private static final int SCROLLBAR_HEIGHT = 137;
|
||||
|
||||
private static final int CANCEL_LEFT_OFFSET = 163;
|
||||
private static final int CANCEL_TOP_OFFSET = 25;
|
||||
private static final int CANCEL_HEIGHT = 20;
|
||||
private static final int CANCEL_WIDTH = 50;
|
||||
|
||||
private static final int TITLE_TOP_OFFSET = 7;
|
||||
private static final int TITLE_LEFT_OFFSET = 8;
|
||||
|
||||
private static final int ITEMSTACK_LEFT_OFFSET = 9;
|
||||
private static final int ITEMSTACK_TOP_OFFSET = 22;
|
||||
|
||||
private final ContainerCraftingCPU craftingCpu;
|
||||
|
||||
private IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
|
||||
private IItemList<IAEItemStack> active = AEApi.instance().storage().createItemList();
|
||||
private IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
|
||||
|
||||
private List<IAEItemStack> visual = new ArrayList<IAEItemStack>();
|
||||
private GuiButton cancel;
|
||||
private int tooltip = -1;
|
||||
|
||||
public GuiCraftingCPU( final InventoryPlayer inventoryPlayer, final Object te )
|
||||
{
|
||||
this( new ContainerCraftingCPU( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
protected GuiCraftingCPU( final ContainerCraftingCPU container )
|
||||
{
|
||||
super( container );
|
||||
this.craftingCpu = container;
|
||||
this.ySize = GUI_HEIGHT;
|
||||
this.xSize = GUI_WIDTH;
|
||||
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
this.setScrollBar( scrollbar );
|
||||
}
|
||||
|
||||
public void clearItems()
|
||||
{
|
||||
this.storage = AEApi.instance().storage().createItemList();
|
||||
this.active = AEApi.instance().storage().createItemList();
|
||||
this.pending = AEApi.instance().storage().createItemList();
|
||||
this.visual = new ArrayList<IAEItemStack>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn )
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
if( this.cancel == btn )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "TileCrafting.Cancel", "Cancel" ) );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
WCTLog.debug( e.getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
this.setScrollBar();
|
||||
this.cancel = new GuiButton( 0, this.guiLeft + CANCEL_LEFT_OFFSET, this.guiTop + this.ySize - CANCEL_TOP_OFFSET, CANCEL_WIDTH, CANCEL_HEIGHT, GuiText.Cancel.getLocal() );
|
||||
this.buttonList.add( this.cancel );
|
||||
}
|
||||
|
||||
private void setScrollBar()
|
||||
{
|
||||
final int size = this.visual.size();
|
||||
|
||||
this.getScrollBar().setTop( SCROLLBAR_TOP ).setLeft( SCROLLBAR_LEFT ).setHeight( SCROLLBAR_HEIGHT );
|
||||
this.getScrollBar().setRange( 0, ( size + 2 ) / 3 - DISPLAYED_ROWS, 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen( final int mouseX, final int mouseY, final float btn )
|
||||
{
|
||||
this.cancel.enabled = !this.visual.isEmpty();
|
||||
|
||||
final int gx = ( this.width - this.xSize ) / 2;
|
||||
final int gy = ( this.height - this.ySize ) / 2;
|
||||
|
||||
this.tooltip = -1;
|
||||
|
||||
final int offY = 23;
|
||||
int y = 0;
|
||||
int x = 0;
|
||||
for( int z = 0; z <= 4 * 5; z++ )
|
||||
{
|
||||
final int minX = gx + 9 + x * 67;
|
||||
final int minY = gy + 22 + y * offY;
|
||||
|
||||
if( minX < mouseX && minX + 67 > mouseX )
|
||||
{
|
||||
if( minY < mouseY && minY + offY - 2 > mouseY )
|
||||
{
|
||||
this.tooltip = z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if( x > 2 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
super.drawScreen( mouseX, mouseY, btn );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
String title = this.getGuiDisplayName( GuiText.CraftingStatus.getLocal() );
|
||||
|
||||
if( this.craftingCpu.getEstimatedTime() > 0 && !this.visual.isEmpty() )
|
||||
{
|
||||
final long etaInMilliseconds = TimeUnit.MILLISECONDS.convert( this.craftingCpu.getEstimatedTime(), TimeUnit.NANOSECONDS );
|
||||
final String etaTimeText = DurationFormatUtils.formatDuration( etaInMilliseconds, GuiText.ETAFormat.getLocal() );
|
||||
title += " - " + etaTimeText;
|
||||
}
|
||||
|
||||
this.fontRendererObj.drawString( title, TITLE_LEFT_OFFSET, TITLE_TOP_OFFSET, TEXT_COLOR );
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
final int viewStart = this.getScrollBar().getCurrentScroll() * 3;
|
||||
final int viewEnd = viewStart + 3 * 6;
|
||||
|
||||
String dspToolTip = "";
|
||||
final List<String> lineList = new LinkedList<String>();
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
|
||||
final int offY = 23;
|
||||
|
||||
final ReadableNumberConverter converter = ReadableNumberConverter.INSTANCE;
|
||||
for( int z = viewStart; z < Math.min( viewEnd, this.visual.size() ); z++ )
|
||||
{
|
||||
final IAEItemStack refStack = this.visual.get( z );// repo.getReferenceItem( z );
|
||||
if( refStack != null )
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled( 0.5, 0.5, 0.5 );
|
||||
|
||||
final IAEItemStack stored = this.storage.findPrecise( refStack );
|
||||
final IAEItemStack activeStack = this.active.findPrecise( refStack );
|
||||
final IAEItemStack pendingStack = this.pending.findPrecise( refStack );
|
||||
|
||||
int lines = 0;
|
||||
|
||||
if( stored != null && stored.getStackSize() > 0 )
|
||||
{
|
||||
lines++;
|
||||
}
|
||||
boolean active = false;
|
||||
if( activeStack != null && activeStack.getStackSize() > 0 )
|
||||
{
|
||||
lines++;
|
||||
active = true;
|
||||
}
|
||||
boolean scheduled = false;
|
||||
if( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
{
|
||||
lines++;
|
||||
scheduled = true;
|
||||
}
|
||||
|
||||
if( AEConfig.instance.useColoredCraftingStatus && ( active || scheduled ) )
|
||||
{
|
||||
final int bgColor = ( active ? AEColor.Green.blackVariant : AEColor.Yellow.blackVariant ) | BACKGROUND_ALPHA;
|
||||
final int startX = ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET ) * 2;
|
||||
final int startY = ( ( y * offY + ITEMSTACK_TOP_OFFSET ) - 3 ) * 2;
|
||||
drawRect( startX, startY, startX + ( SECTION_LENGTH * 2 ), startY + ( offY * 2 ) - 2, bgColor );
|
||||
}
|
||||
|
||||
final int negY = ( ( lines - 1 ) * 5 ) / 2;
|
||||
int downY = 0;
|
||||
|
||||
if( stored != null && stored.getStackSize() > 0 )
|
||||
{
|
||||
final String str = GuiText.Stored.getLocal() + ": " + converter.toWideReadableForm( stored.getStackSize() );
|
||||
final int w = 4 + this.fontRendererObj.getStringWidth( str );
|
||||
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY ) * 2, TEXT_COLOR );
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
lineList.add( GuiText.Stored.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
|
||||
}
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if( activeStack != null && activeStack.getStackSize() > 0 )
|
||||
{
|
||||
final String str = GuiText.Crafting.getLocal() + ": " + converter.toWideReadableForm( activeStack.getStackSize() );
|
||||
final int w = 4 + this.fontRendererObj.getStringWidth( str );
|
||||
|
||||
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY ) * 2, TEXT_COLOR );
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
lineList.add( GuiText.Crafting.getLocal() + ": " + Long.toString( activeStack.getStackSize() ) );
|
||||
}
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
{
|
||||
final String str = GuiText.Scheduled.getLocal() + ": " + converter.toWideReadableForm( pendingStack.getStackSize() );
|
||||
final int w = 4 + this.fontRendererObj.getStringWidth( str );
|
||||
|
||||
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY ) * 2, TEXT_COLOR );
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
lineList.add( GuiText.Scheduled.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) );
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
final int posX = x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19;
|
||||
final int posY = y * offY + ITEMSTACK_TOP_OFFSET;
|
||||
|
||||
final ItemStack is = refStack.copy().getItemStack();
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
dspToolTip = Platform.getItemDisplayName( is );
|
||||
|
||||
if( lineList.size() > 0 )
|
||||
{
|
||||
addItemTooltip(is, lineList);
|
||||
dspToolTip = dspToolTip + '\n' + Joiner.on( "\n" ).join( lineList );
|
||||
}
|
||||
|
||||
toolPosX = x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 8;
|
||||
toolPosY = y * offY + ITEMSTACK_TOP_OFFSET;
|
||||
}
|
||||
|
||||
this.drawItem( posX, posY, is );
|
||||
|
||||
x++;
|
||||
|
||||
if( x > 2 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( this.tooltip >= 0 && dspToolTip.length() > 0 )
|
||||
{
|
||||
this.drawTooltip( toolPosX, toolPosY + 10, 0, dspToolTip );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.bindTexture( "appliedenergistics2", "guis/craftingcpu.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
|
||||
}
|
||||
|
||||
public void postUpdate( final List<IAEItemStack> list, final byte ref )
|
||||
{
|
||||
switch( ref )
|
||||
{
|
||||
case 0:
|
||||
for( final IAEItemStack l : list )
|
||||
{
|
||||
this.handleInput( this.storage, l );
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for( final IAEItemStack l : list )
|
||||
{
|
||||
this.handleInput( this.active, l );
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for( final IAEItemStack l : list )
|
||||
{
|
||||
this.handleInput( this.pending, l );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for( final IAEItemStack l : list )
|
||||
{
|
||||
final long amt = this.getTotal( l );
|
||||
|
||||
if( amt <= 0 )
|
||||
{
|
||||
this.deleteVisualStack( l );
|
||||
}
|
||||
else
|
||||
{
|
||||
final IAEItemStack is = this.findVisualStack( l );
|
||||
is.setStackSize( amt );
|
||||
}
|
||||
}
|
||||
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void handleInput( final IItemList<IAEItemStack> s, final IAEItemStack l )
|
||||
{
|
||||
IAEItemStack a = s.findPrecise( l );
|
||||
|
||||
if( l.getStackSize() <= 0 )
|
||||
{
|
||||
if( a != null )
|
||||
{
|
||||
a.reset();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( a == null )
|
||||
{
|
||||
s.add( l.copy() );
|
||||
a = s.findPrecise( l );
|
||||
}
|
||||
|
||||
if( a != null )
|
||||
{
|
||||
a.setStackSize( l.getStackSize() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long getTotal( final IAEItemStack is )
|
||||
{
|
||||
final IAEItemStack a = this.storage.findPrecise( is );
|
||||
final IAEItemStack b = this.active.findPrecise( is );
|
||||
final IAEItemStack c = this.pending.findPrecise( is );
|
||||
|
||||
long total = 0;
|
||||
|
||||
if( a != null )
|
||||
{
|
||||
total += a.getStackSize();
|
||||
}
|
||||
|
||||
if( b != null )
|
||||
{
|
||||
total += b.getStackSize();
|
||||
}
|
||||
|
||||
if( c != null )
|
||||
{
|
||||
total += c.getStackSize();
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
private void deleteVisualStack( final IAEItemStack l )
|
||||
{
|
||||
final Iterator<IAEItemStack> i = this.visual.iterator();
|
||||
|
||||
while( i.hasNext() )
|
||||
{
|
||||
final IAEItemStack o = i.next();
|
||||
if( o.equals( l ) )
|
||||
{
|
||||
i.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IAEItemStack findVisualStack( final IAEItemStack l )
|
||||
{
|
||||
for( final IAEItemStack o : this.visual )
|
||||
{
|
||||
if( o.equals( l ) )
|
||||
{
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
final IAEItemStack stack = l.copy();
|
||||
this.visual.add( stack );
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Enum getSortBy()
|
||||
{
|
||||
return SortOrder.NAME;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Enum getSortDir()
|
||||
{
|
||||
return SortDir.ASCENDING;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Enum getSortDisplay()
|
||||
{
|
||||
return ViewItems.ALL;
|
||||
}
|
||||
}
|
||||
+45
-114
@@ -1,141 +1,72 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.client.gui;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.container.implementations.ContainerCraftingStatus;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.widgets.GuiTabButton;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftingStatus;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwitchGuis;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketValueConfig;
|
||||
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemWirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
public class GuiCraftingStatus extends appeng.client.gui.implementations.GuiCraftingStatus {
|
||||
private GuiTabButton originalGuiBtn;
|
||||
private int originalGui;
|
||||
private ItemStack myIcon = null;
|
||||
|
||||
public class GuiCraftingStatus extends GuiCraftingCPU
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
public GuiCraftingStatus(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
super(inventoryPlayer, te);
|
||||
|
||||
private final ContainerCraftingStatus status;
|
||||
private GuiButton selectCPU;
|
||||
ContainerCraftingStatus status = (ContainerCraftingStatus) this.inventorySlots;
|
||||
final Object target = status.getTarget();
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
private GuiTabButton originalGuiBtn;
|
||||
private int originalGui;
|
||||
private ItemStack myIcon = null;
|
||||
if (target instanceof WirelessTerminalGuiObject) {
|
||||
for (final ItemStack wirelessTerminalStack :
|
||||
definitions.items().wirelessTerminal().maybeStack(1).asSet()) {
|
||||
this.myIcon = wirelessTerminalStack;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public GuiCraftingStatus( final InventoryPlayer inventoryPlayer, final ITerminalHost te )
|
||||
{
|
||||
super( new ContainerCraftingStatus( inventoryPlayer, te ) );
|
||||
ItemStack is = new ItemStack(ItemEnum.WIRELESS_CRAFTING_TERMINAL.getItem());
|
||||
((ItemWirelessCraftingTerminal) is.getItem()).injectAEPower(is, 6400001);
|
||||
myIcon = is;
|
||||
|
||||
this.status = (ContainerCraftingStatus) this.inventorySlots;
|
||||
final Object target = this.status.getTarget();
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
this.originalGui = Reference.GUI_WCT;
|
||||
}
|
||||
}
|
||||
|
||||
if( target instanceof WirelessTerminalGuiObject )
|
||||
{
|
||||
for( final ItemStack wirelessTerminalStack : definitions.items().wirelessTerminal().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
this.myIcon = wirelessTerminalStack;
|
||||
}
|
||||
|
||||
ItemStack is = new ItemStack(ItemEnum.WIRELESS_CRAFTING_TERMINAL.getItem());
|
||||
((ItemWirelessCraftingTerminal) is.getItem()).injectAEPower(is, 6400001);
|
||||
myIcon = is;
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
|
||||
this.originalGui = Reference.GUI_WCT;
|
||||
}
|
||||
}
|
||||
if (btn == this.originalGuiBtn) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(this.originalGui));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn )
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
final boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if( btn == this.selectCPU )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
WCTLog.debug( e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
if( btn == this.originalGuiBtn )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( this.originalGui ) );
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
this.selectCPU = new GuiButton( 0, this.guiLeft + 8, this.guiTop + this.ySize - 25, 150, 20, GuiText.CraftingCPU.getLocal() + ": " + GuiText.NoCraftingCPUs );
|
||||
// selectCPU.enabled = false;
|
||||
this.buttonList.add( this.selectCPU );
|
||||
|
||||
if( this.myIcon != null )
|
||||
{
|
||||
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 213, this.guiTop - 4, this.myIcon, this.myIcon.getDisplayName(), itemRender ) );
|
||||
this.originalGuiBtn.setHideEdge( 13 );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen( final int mouseX, final int mouseY, final float btn )
|
||||
{
|
||||
this.updateCPUButtonText();
|
||||
super.drawScreen( mouseX, mouseY, btn );
|
||||
}
|
||||
|
||||
private void updateCPUButtonText()
|
||||
{
|
||||
String btnTextText = GuiText.NoCraftingJobs.getLocal();
|
||||
|
||||
if( this.status.selectedCpu >= 0 )// && status.selectedCpu < status.cpus.size() )
|
||||
{
|
||||
if( this.status.myName.length() > 0 )
|
||||
{
|
||||
final String name = this.status.myName.substring( 0, Math.min( 20, this.status.myName.length() ) );
|
||||
btnTextText = GuiText.CPUs.getLocal() + ": " + name;
|
||||
}
|
||||
else
|
||||
{
|
||||
btnTextText = GuiText.CPUs.getLocal() + ": #" + this.status.selectedCpu;
|
||||
}
|
||||
}
|
||||
|
||||
if( this.status.noCPU )
|
||||
{
|
||||
btnTextText = GuiText.NoCraftingJobs.getLocal();
|
||||
}
|
||||
|
||||
this.selectCPU.displayString = btnTextText;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getGuiDisplayName( final String in )
|
||||
{
|
||||
return in; // the cup name is on the button
|
||||
}
|
||||
if (this.myIcon != null) {
|
||||
this.buttonList.add(
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + 213,
|
||||
this.guiTop - 4,
|
||||
this.myIcon,
|
||||
this.myIcon.getDisplayName(),
|
||||
itemRender));
|
||||
this.originalGuiBtn.setHideEdge(13);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,29 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.client.gui;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import cpw.mods.fml.client.IModGuiFactory;
|
||||
import java.util.Set;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class GuiFactory implements IModGuiFactory {
|
||||
|
||||
@Override
|
||||
public void initialize(Minecraft minecraftInstance) {
|
||||
// XD
|
||||
}
|
||||
@Override
|
||||
public void initialize(Minecraft minecraftInstance) {
|
||||
// XD
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiScreen> mainConfigGuiClass() {
|
||||
return WCTGuiConfig.class;
|
||||
}
|
||||
@Override
|
||||
public Class<? extends GuiScreen> mainConfigGuiClass() {
|
||||
return WCTGuiConfig.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.client.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -14,140 +12,135 @@ import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerMagnet;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketMagnetFilter;
|
||||
import net.p455w0rd.wirelesscraftingterminal.handlers.LocaleHandler;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiMagnet extends GuiContainer {
|
||||
|
||||
private WCTGuiButton modeBtn;
|
||||
public boolean mode = true;
|
||||
public boolean ignoreNBT = false;
|
||||
public boolean ignoreMeta = false;
|
||||
public boolean useOreDict = false;
|
||||
private ItemStack magnetItem;
|
||||
private WCTGuiCheckBox ignoreNBTBox;
|
||||
private WCTGuiCheckBox ignoreMetaBox;
|
||||
private WCTGuiCheckBox useOreDictBox;
|
||||
private WCTGuiButton modeBtn;
|
||||
public boolean mode = true;
|
||||
public boolean ignoreNBT = false;
|
||||
public boolean ignoreMeta = false;
|
||||
public boolean useOreDict = false;
|
||||
private ItemStack magnetItem;
|
||||
private WCTGuiCheckBox ignoreNBTBox;
|
||||
private WCTGuiCheckBox ignoreMetaBox;
|
||||
private WCTGuiCheckBox useOreDictBox;
|
||||
|
||||
public GuiMagnet(ContainerMagnet c) {
|
||||
super(c);
|
||||
this.xSize = 176;
|
||||
this.width = this.xSize;
|
||||
this.ySize = 208;
|
||||
this.height = this.ySize;
|
||||
this.magnetItem = c.magnetItem;
|
||||
this.loadSettings();
|
||||
}
|
||||
public GuiMagnet(ContainerMagnet c) {
|
||||
super(c);
|
||||
this.xSize = 176;
|
||||
this.width = this.xSize;
|
||||
this.ySize = 208;
|
||||
this.height = this.ySize;
|
||||
this.magnetItem = c.magnetItem;
|
||||
this.loadSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
bindTexture("magnetfilter.png");
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 208);
|
||||
}
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
bindTexture("magnetfilter.png");
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 208);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
this.mc.fontRenderer.drawString(LocaleHandler.MagnetFilterTitle.getLocal(), 7, 5, 4210752);
|
||||
this.mc.fontRenderer.drawString(I18n.format("container.inventory"), 7, 114, 4210752);
|
||||
}
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
this.mc.fontRenderer.drawString(LocaleHandler.MagnetFilterTitle.getLocal(), 7, 5, 4210752);
|
||||
this.mc.fontRenderer.drawString(I18n.format("container.inventory"), 7, 114, 4210752);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.buttonList.clear();
|
||||
this.buttonList.add(this.modeBtn = new WCTGuiButton(0, this.guiLeft + 104, this.guiTop + 4, 64, 14, getLabel(this.mode)));
|
||||
this.buttonList.add(this.ignoreNBTBox = new WCTGuiCheckBox(1, this.guiLeft + 61, this.guiTop + 20, "Ignore NBT Data", this.ignoreNBT, 107));
|
||||
this.buttonList.add(this.ignoreMetaBox = new WCTGuiCheckBox(2, this.guiLeft + 61, this.guiTop + 32, "Ignore Meta Data", this.ignoreMeta, 107));
|
||||
this.buttonList.add(this.useOreDictBox = new WCTGuiCheckBox(3, this.guiLeft + 61, this.guiTop + 44, "Use Ore Dictionary", this.useOreDict, 107));
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.buttonList.clear();
|
||||
this.buttonList.add(
|
||||
this.modeBtn = new WCTGuiButton(0, this.guiLeft + 104, this.guiTop + 4, 64, 14, getLabel(this.mode)));
|
||||
this.buttonList.add(
|
||||
this.ignoreNBTBox = new WCTGuiCheckBox(
|
||||
1, this.guiLeft + 61, this.guiTop + 20, "Ignore NBT Data", this.ignoreNBT, 107));
|
||||
this.buttonList.add(
|
||||
this.ignoreMetaBox = new WCTGuiCheckBox(
|
||||
2, this.guiLeft + 61, this.guiTop + 32, "Ignore Meta Data", this.ignoreMeta, 107));
|
||||
this.buttonList.add(
|
||||
this.useOreDictBox = new WCTGuiCheckBox(
|
||||
3, this.guiLeft + 61, this.guiTop + 44, "Use Ore Dictionary", this.useOreDict, 107));
|
||||
}
|
||||
|
||||
String getLabel(boolean filterMode) {
|
||||
return filterMode ? "Whitelisting" : "Blacklisting";
|
||||
}
|
||||
String getLabel(boolean filterMode) {
|
||||
return filterMode ? "Whitelisting" : "Blacklisting";
|
||||
}
|
||||
|
||||
private void loadSettings() {
|
||||
if (magnetItem == null) {
|
||||
return;
|
||||
}
|
||||
if (!magnetItem.hasTagCompound()) {
|
||||
NetworkHandler.instance.sendToServer(new PacketMagnetFilter(0, false));
|
||||
}
|
||||
this.mode = getMode(1);
|
||||
this.ignoreNBT = getMode(2);
|
||||
this.ignoreMeta = getMode(3);
|
||||
this.useOreDict = getMode(4);
|
||||
}
|
||||
private void loadSettings() {
|
||||
if (magnetItem == null) {
|
||||
return;
|
||||
}
|
||||
if (!magnetItem.hasTagCompound()) {
|
||||
NetworkHandler.instance.sendToServer(new PacketMagnetFilter(0, false));
|
||||
}
|
||||
this.mode = getMode(1);
|
||||
this.ignoreNBT = getMode(2);
|
||||
this.ignoreMeta = getMode(3);
|
||||
this.useOreDict = getMode(4);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
if (btn == this.modeBtn) {
|
||||
btn.displayString = getLabel(!this.mode);
|
||||
this.mode = !this.mode;
|
||||
updateMode(1, this.mode);
|
||||
}
|
||||
else if (btn == this.ignoreNBTBox) {
|
||||
this.ignoreNBT = !this.ignoreNBT;
|
||||
updateMode(2, this.ignoreNBT);
|
||||
}
|
||||
else if (btn == this.ignoreMetaBox) {
|
||||
this.ignoreMeta = !this.ignoreMeta;
|
||||
updateMode(3, this.ignoreMeta);
|
||||
}
|
||||
else if (btn == this.useOreDictBox) {
|
||||
this.useOreDict = !this.useOreDict;
|
||||
updateMode(4, this.useOreDict);
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
if (btn == this.modeBtn) {
|
||||
btn.displayString = getLabel(!this.mode);
|
||||
this.mode = !this.mode;
|
||||
updateMode(1, this.mode);
|
||||
} else if (btn == this.ignoreNBTBox) {
|
||||
this.ignoreNBT = !this.ignoreNBT;
|
||||
updateMode(2, this.ignoreNBT);
|
||||
} else if (btn == this.ignoreMetaBox) {
|
||||
this.ignoreMeta = !this.ignoreMeta;
|
||||
updateMode(3, this.ignoreMeta);
|
||||
} else if (btn == this.useOreDictBox) {
|
||||
this.useOreDict = !this.useOreDict;
|
||||
updateMode(4, this.useOreDict);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMode(int type, boolean mode) {
|
||||
NetworkHandler.instance.sendToServer(new PacketMagnetFilter(type, mode));
|
||||
}
|
||||
private void updateMode(int type, boolean mode) {
|
||||
NetworkHandler.instance.sendToServer(new PacketMagnetFilter(type, mode));
|
||||
}
|
||||
|
||||
private boolean getMode(int type) {
|
||||
NBTTagCompound nbtTC = magnetItem.getTagCompound();
|
||||
if (type == 1) {
|
||||
if (nbtTC.hasKey("Whitelisting")) {
|
||||
return nbtTC.getBoolean("Whitelisting");
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (type == 2) {
|
||||
if (nbtTC.hasKey("IgnoreNBT")) {
|
||||
return nbtTC.getBoolean("IgnoreNBT");
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (type == 3) {
|
||||
if (nbtTC.hasKey("IgnoreMeta")) {
|
||||
return nbtTC.getBoolean("IgnoreMeta");
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (type == 4) {
|
||||
if (nbtTC.hasKey("UseOreDict")) {
|
||||
return nbtTC.getBoolean("UseOreDict");
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void bindTexture(final String file) {
|
||||
final ResourceLocation loc = new ResourceLocation("ae2wct", "textures/gui/" + file);
|
||||
this.mc.getTextureManager().bindTexture(loc);
|
||||
}
|
||||
private boolean getMode(int type) {
|
||||
NBTTagCompound nbtTC = magnetItem.getTagCompound();
|
||||
if (type == 1) {
|
||||
if (nbtTC.hasKey("Whitelisting")) {
|
||||
return nbtTC.getBoolean("Whitelisting");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else if (type == 2) {
|
||||
if (nbtTC.hasKey("IgnoreNBT")) {
|
||||
return nbtTC.getBoolean("IgnoreNBT");
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if (type == 3) {
|
||||
if (nbtTC.hasKey("IgnoreMeta")) {
|
||||
return nbtTC.getBoolean("IgnoreMeta");
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if (type == 4) {
|
||||
if (nbtTC.hasKey("UseOreDict")) {
|
||||
return nbtTC.getBoolean("UseOreDict");
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void bindTexture(final String file) {
|
||||
final ResourceLocation loc = new ResourceLocation("ae2wct", "textures/gui/" + file);
|
||||
this.mc.getTextureManager().bindTexture(loc);
|
||||
}
|
||||
}
|
||||
+1431
-1275
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -9,15 +9,14 @@ import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
public class WCTGuiConfig extends GuiConfig {
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public WCTGuiConfig(GuiScreen guiScreen)
|
||||
{
|
||||
super(guiScreen,
|
||||
new ConfigElement(ConfigHandler.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(),
|
||||
Reference.MODID,
|
||||
false,
|
||||
false,
|
||||
GuiConfig.getAbridgedConfigPath(ConfigHandler.config.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public WCTGuiConfig(GuiScreen guiScreen) {
|
||||
super(
|
||||
guiScreen,
|
||||
new ConfigElement(ConfigHandler.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(),
|
||||
Reference.MODID,
|
||||
false,
|
||||
false,
|
||||
GuiConfig.getAbridgedConfigPath(ConfigHandler.config.toString()));
|
||||
}
|
||||
}
|
||||
+91
-116
@@ -1,144 +1,119 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.client.gui.widgets;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.client.gui.widgets.IScrollSource;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiWirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.WCTBaseGui;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiScrollbar implements IScrollSource
|
||||
{
|
||||
public class GuiScrollbar implements IScrollSource {
|
||||
|
||||
private int displayX = 0;
|
||||
private int displayY = 0;
|
||||
private int width = 12;
|
||||
private int height = 16;
|
||||
private int pageSize = 1;
|
||||
private int displayX = 0;
|
||||
private int displayY = 0;
|
||||
private int width = 12;
|
||||
private int height = 16;
|
||||
private int pageSize = 1;
|
||||
|
||||
private int maxScroll = 0;
|
||||
private int minScroll = 0;
|
||||
private int currentScroll = 0;
|
||||
private int maxScroll = 0;
|
||||
private int minScroll = 0;
|
||||
private int currentScroll = 0;
|
||||
|
||||
public void draw( final GuiContainer g )
|
||||
{
|
||||
if (g instanceof GuiWirelessCraftingTerminal) {
|
||||
((GuiWirelessCraftingTerminal) g).bindTexture( "minecraft", "gui/container/creative_inventory/tabs.png" );
|
||||
public void draw(final GuiContainer g) {
|
||||
if (g instanceof GuiWirelessCraftingTerminal) {
|
||||
((GuiWirelessCraftingTerminal) g).bindTexture("minecraft", "gui/container/creative_inventory/tabs.png");
|
||||
|
||||
}
|
||||
else if (g instanceof WCTBaseGui) {
|
||||
((WCTBaseGui) g).bindTexture("minecraft", "gui/container/creative_inventory/tabs.png");
|
||||
}
|
||||
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
if( this.getRange() == 0 )
|
||||
{
|
||||
g.drawTexturedModalRect( this.displayX, this.displayY, 232 + this.width, 0, this.width, 15 );
|
||||
}
|
||||
else
|
||||
{
|
||||
final int offset = ( this.currentScroll - this.minScroll ) * ( this.height - 15 ) / this.getRange();
|
||||
g.drawTexturedModalRect( this.displayX, offset + this.displayY, 232, 0, this.width, 15 );
|
||||
}
|
||||
}
|
||||
} else if (g instanceof WCTBaseGui) {
|
||||
((WCTBaseGui) g).bindTexture("minecraft", "gui/container/creative_inventory/tabs.png");
|
||||
}
|
||||
|
||||
private int getRange()
|
||||
{
|
||||
return this.maxScroll - this.minScroll;
|
||||
}
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
if (this.getRange() == 0) {
|
||||
g.drawTexturedModalRect(this.displayX, this.displayY, 232 + this.width, 0, this.width, 15);
|
||||
} else {
|
||||
final int offset = (this.currentScroll - this.minScroll) * (this.height - 15) / this.getRange();
|
||||
g.drawTexturedModalRect(this.displayX, offset + this.displayY, 232, 0, this.width, 15);
|
||||
}
|
||||
}
|
||||
|
||||
public int getLeft()
|
||||
{
|
||||
return this.displayX;
|
||||
}
|
||||
private int getRange() {
|
||||
return this.maxScroll - this.minScroll;
|
||||
}
|
||||
|
||||
public GuiScrollbar setLeft( final int v )
|
||||
{
|
||||
this.displayX = v;
|
||||
return this;
|
||||
}
|
||||
public int getLeft() {
|
||||
return this.displayX;
|
||||
}
|
||||
|
||||
public int getTop()
|
||||
{
|
||||
return this.displayY;
|
||||
}
|
||||
public GuiScrollbar setLeft(final int v) {
|
||||
this.displayX = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuiScrollbar setTop( final int v )
|
||||
{
|
||||
this.displayY = v;
|
||||
return this;
|
||||
}
|
||||
public int getTop() {
|
||||
return this.displayY;
|
||||
}
|
||||
|
||||
public int getWidth()
|
||||
{
|
||||
return this.width;
|
||||
}
|
||||
public GuiScrollbar setTop(final int v) {
|
||||
this.displayY = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuiScrollbar setWidth( final int v )
|
||||
{
|
||||
this.width = v;
|
||||
return this;
|
||||
}
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public int getHeight()
|
||||
{
|
||||
return this.height;
|
||||
}
|
||||
public GuiScrollbar setWidth(final int v) {
|
||||
this.width = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuiScrollbar setHeight( final int v )
|
||||
{
|
||||
this.height = v;
|
||||
return this;
|
||||
}
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public void setRange( final int min, final int max, final int pageSize )
|
||||
{
|
||||
this.minScroll = min;
|
||||
this.maxScroll = max;
|
||||
this.pageSize = pageSize;
|
||||
public GuiScrollbar setHeight(final int v) {
|
||||
this.height = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
if( this.minScroll > this.maxScroll )
|
||||
{
|
||||
this.maxScroll = this.minScroll;
|
||||
}
|
||||
public void setRange(final int min, final int max, final int pageSize) {
|
||||
this.minScroll = min;
|
||||
this.maxScroll = max;
|
||||
this.pageSize = pageSize;
|
||||
|
||||
this.applyRange();
|
||||
}
|
||||
if (this.minScroll > this.maxScroll) {
|
||||
this.maxScroll = this.minScroll;
|
||||
}
|
||||
|
||||
private void applyRange()
|
||||
{
|
||||
this.currentScroll = Math.max( Math.min( this.currentScroll, this.maxScroll ), this.minScroll );
|
||||
}
|
||||
this.applyRange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentScroll()
|
||||
{
|
||||
return this.currentScroll;
|
||||
}
|
||||
private void applyRange() {
|
||||
this.currentScroll = Math.max(Math.min(this.currentScroll, this.maxScroll), this.minScroll);
|
||||
}
|
||||
|
||||
public void click( final GuiContainer aeBaseGui, final int x, final int y )
|
||||
{
|
||||
if( this.getRange() == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public int getCurrentScroll() {
|
||||
return this.currentScroll;
|
||||
}
|
||||
|
||||
if( x > this.displayX && x <= this.displayX + this.width )
|
||||
{
|
||||
if( y > this.displayY && y <= this.displayY + this.height )
|
||||
{
|
||||
this.currentScroll = ( y - this.displayY );
|
||||
this.currentScroll = this.minScroll + ( ( this.currentScroll * 2 * this.getRange() / this.height ) );
|
||||
this.currentScroll = ( this.currentScroll + 1 ) >> 1;
|
||||
this.applyRange();
|
||||
}
|
||||
}
|
||||
}
|
||||
public void click(final GuiContainer aeBaseGui, final int x, final int y) {
|
||||
if (this.getRange() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
public void wheel( int delta )
|
||||
{
|
||||
delta = Math.max( Math.min( -delta, 1 ), -1 );
|
||||
this.currentScroll += delta * this.pageSize;
|
||||
this.applyRange();
|
||||
}
|
||||
}
|
||||
if (x > this.displayX && x <= this.displayX + this.width) {
|
||||
if (y > this.displayY && y <= this.displayY + this.height) {
|
||||
this.currentScroll = (y - this.displayY);
|
||||
this.currentScroll = this.minScroll + ((this.currentScroll * 2 * this.getRange() / this.height));
|
||||
this.currentScroll = (this.currentScroll + 1) >> 1;
|
||||
this.applyRange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void wheel(int delta) {
|
||||
delta = Math.max(Math.min(-delta, 1), -1);
|
||||
this.currentScroll += delta * this.pageSize;
|
||||
this.applyRange();
|
||||
}
|
||||
}
|
||||
+109
-115
@@ -1,8 +1,5 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.client.gui.widgets;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import appeng.client.gui.widgets.ITooltip;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -11,137 +8,134 @@ import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
public class GuiTabButton extends GuiButton implements ITooltip {
|
||||
private final RenderItem itemRenderer;
|
||||
private final String message;
|
||||
private int hideEdge = 0;
|
||||
private int myIcon = -1;
|
||||
private ItemStack myItem;
|
||||
|
||||
public class GuiTabButton extends GuiButton implements ITooltip
|
||||
{
|
||||
private final RenderItem itemRenderer;
|
||||
private final String message;
|
||||
private int hideEdge = 0;
|
||||
private int myIcon = -1;
|
||||
private ItemStack myItem;
|
||||
public GuiTabButton(final int x, final int y, final int ico, final String message, final RenderItem ir) {
|
||||
super(0, 0, 16, "");
|
||||
|
||||
public GuiTabButton( final int x, final int y, final int ico, final String message, final RenderItem ir )
|
||||
{
|
||||
super( 0, 0, 16, "" );
|
||||
this.xPosition = x;
|
||||
this.yPosition = y;
|
||||
this.width = 22;
|
||||
this.height = 22;
|
||||
this.myIcon = ico;
|
||||
this.message = message;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
|
||||
this.xPosition = x;
|
||||
this.yPosition = y;
|
||||
this.width = 22;
|
||||
this.height = 22;
|
||||
this.myIcon = ico;
|
||||
this.message = message;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
/**
|
||||
* Using itemstack as an icon
|
||||
*
|
||||
* @param x x pos of button
|
||||
* @param y y pos of button
|
||||
* @param ico used icon
|
||||
* @param message mouse over message
|
||||
* @param ir renderer
|
||||
*/
|
||||
public GuiTabButton(final int x, final int y, final ItemStack ico, final String message, final RenderItem ir) {
|
||||
super(0, 0, 16, "");
|
||||
this.xPosition = x;
|
||||
this.yPosition = y;
|
||||
this.width = 22;
|
||||
this.height = 22;
|
||||
this.myItem = ico;
|
||||
this.message = message;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Using itemstack as an icon
|
||||
*
|
||||
* @param x x pos of button
|
||||
* @param y y pos of button
|
||||
* @param ico used icon
|
||||
* @param message mouse over message
|
||||
* @param ir renderer
|
||||
*/
|
||||
public GuiTabButton( final int x, final int y, final ItemStack ico, final String message, final RenderItem ir )
|
||||
{
|
||||
super( 0, 0, 16, "" );
|
||||
this.xPosition = x;
|
||||
this.yPosition = y;
|
||||
this.width = 22;
|
||||
this.height = 22;
|
||||
this.myItem = ico;
|
||||
this.message = message;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
@Override
|
||||
public void drawButton(final Minecraft minecraft, final int x, final int y) {
|
||||
if (this.visible) {
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
minecraft.renderEngine.bindTexture(ExtraBlockTextures.GuiTexture("guis/states.png"));
|
||||
this.field_146123_n = x >= this.xPosition
|
||||
&& y >= this.yPosition
|
||||
&& x < this.xPosition + this.width
|
||||
&& y < this.yPosition + this.height;
|
||||
|
||||
@Override
|
||||
public void drawButton( final Minecraft minecraft, final int x, final int y )
|
||||
{
|
||||
if( this.visible )
|
||||
{
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
|
||||
this.field_146123_n = x >= this.xPosition && y >= this.yPosition && x < this.xPosition + this.width && y < this.yPosition + this.height;
|
||||
int uv_x = (this.hideEdge > 0 ? 11 : 13);
|
||||
|
||||
int uv_x = ( this.hideEdge > 0 ? 11 : 13 );
|
||||
final int offsetX = this.hideEdge > 0 ? 1 : 0;
|
||||
|
||||
final int offsetX = this.hideEdge > 0 ? 1 : 0;
|
||||
// this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, 0, 25, 22 );
|
||||
|
||||
//this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, 0, 25, 22 );
|
||||
|
||||
if( this.myIcon >= 0 )
|
||||
{
|
||||
final int uv_y = (int) Math.floor( this.myIcon / 16 );
|
||||
uv_x = this.myIcon - uv_y * 16;
|
||||
if (this.myIcon >= 0) {
|
||||
final int uv_y = (int) Math.floor(this.myIcon / 16);
|
||||
uv_x = this.myIcon - uv_y * 16;
|
||||
|
||||
this.drawTexturedModalRect( offsetX + this.xPosition + 3, this.yPosition + 6, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
}
|
||||
|
||||
this.mouseDragged( minecraft, x, y );
|
||||
this.drawTexturedModalRect(
|
||||
offsetX + this.xPosition + 3, this.yPosition + 6, uv_x * 16, uv_y * 16, 16, 16);
|
||||
}
|
||||
|
||||
if( this.myItem != null )
|
||||
{
|
||||
this.zLevel = 100.0F;
|
||||
this.itemRenderer.zLevel = 100.0F;
|
||||
this.mouseDragged(minecraft, x, y);
|
||||
|
||||
GL11.glEnable( GL11.GL_LIGHTING );
|
||||
GL11.glEnable( GL12.GL_RESCALE_NORMAL );
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
final FontRenderer fontrenderer = minecraft.fontRenderer;
|
||||
//this.itemRenderer.renderItemAndEffectIntoGUI( fontrenderer, minecraft.renderEngine, this.myItem, offsetX + this.xPosition + 3, this.yPosition + 6 );
|
||||
this.itemRenderer.renderItemIntoGUI( fontrenderer, minecraft.renderEngine, this.myItem, offsetX + this.xPosition + 3, this.yPosition + 6, false );
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
if (this.myItem != null) {
|
||||
this.zLevel = 100.0F;
|
||||
this.itemRenderer.zLevel = 100.0F;
|
||||
|
||||
this.itemRenderer.zLevel = 0.0F;
|
||||
this.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
final FontRenderer fontrenderer = minecraft.fontRenderer;
|
||||
// this.itemRenderer.renderItemAndEffectIntoGUI( fontrenderer, minecraft.renderEngine, this.myItem,
|
||||
// offsetX + this.xPosition + 3, this.yPosition + 6 );
|
||||
this.itemRenderer.renderItemIntoGUI(
|
||||
fontrenderer,
|
||||
minecraft.renderEngine,
|
||||
this.myItem,
|
||||
offsetX + this.xPosition + 3,
|
||||
this.yPosition + 6,
|
||||
false);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
return this.message;
|
||||
}
|
||||
this.itemRenderer.zLevel = 0.0F;
|
||||
this.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return this.xPosition;
|
||||
}
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return this.yPosition;
|
||||
}
|
||||
@Override
|
||||
public int xPos() {
|
||||
return this.xPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return 22;
|
||||
}
|
||||
@Override
|
||||
public int yPos() {
|
||||
return this.yPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return 22;
|
||||
}
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 22;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return this.visible;
|
||||
}
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 22;
|
||||
}
|
||||
|
||||
public int getHideEdge()
|
||||
{
|
||||
return this.hideEdge;
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return this.visible;
|
||||
}
|
||||
|
||||
public void setHideEdge( final int hideEdge )
|
||||
{
|
||||
this.hideEdge = hideEdge;
|
||||
}
|
||||
public int getHideEdge() {
|
||||
return this.hideEdge;
|
||||
}
|
||||
|
||||
public void setHideEdge(final int hideEdge) {
|
||||
this.hideEdge = hideEdge;
|
||||
}
|
||||
}
|
||||
+52
-52
@@ -1,70 +1,70 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.client.gui.widgets;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.client.gui.widgets.ITooltip;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.p455w0rd.wirelesscraftingterminal.handlers.LocaleHandler;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiTrashButton extends GuiButton implements ITooltip {
|
||||
|
||||
public GuiTrashButton(int x, int y) {
|
||||
super(x, y, 8, "");
|
||||
this.xPosition = x;
|
||||
this.yPosition = y;
|
||||
this.width = 8;
|
||||
this.height = 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton( final Minecraft mc, final int par2, final int par3 )
|
||||
{
|
||||
if( this.visible )
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef( this.xPosition, this.yPosition, 0.0F );
|
||||
GL11.glScalef( 0.5f, 0.5f, 0.5f );
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
mc.renderEngine.bindTexture( new ResourceLocation( "appliedenergistics2", "textures/guis/states.png" ) );
|
||||
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
|
||||
this.drawTexturedModalRect( 0, 0, 256 - 16, 256 - 16, 16, 16 );
|
||||
this.drawTexturedModalRect( 0, 0, 6 * 16, 0, 16, 16 );
|
||||
this.mouseDragged(mc, par2, par3 );
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return EnumChatFormatting.WHITE + "" + LocaleHandler.EmptyTrash.getLocal() + "\n" + EnumChatFormatting.GRAY + "" + LocaleHandler.EmptyTrashDesc.getLocal();
|
||||
}
|
||||
public GuiTrashButton(int x, int y) {
|
||||
super(x, y, 8, "");
|
||||
this.xPosition = x;
|
||||
this.yPosition = y;
|
||||
this.width = 8;
|
||||
this.height = 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos() {
|
||||
return this.xPosition;
|
||||
}
|
||||
@Override
|
||||
public void drawButton(final Minecraft mc, final int par2, final int par3) {
|
||||
if (this.visible) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(this.xPosition, this.yPosition, 0.0F);
|
||||
GL11.glScalef(0.5f, 0.5f, 0.5f);
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
mc.renderEngine.bindTexture(new ResourceLocation("appliedenergistics2", "textures/guis/states.png"));
|
||||
this.field_146123_n = par2 >= this.xPosition
|
||||
&& par3 >= this.yPosition
|
||||
&& par2 < this.xPosition + this.width
|
||||
&& par3 < this.yPosition + this.height;
|
||||
this.drawTexturedModalRect(0, 0, 256 - 16, 256 - 16, 16, 16);
|
||||
this.drawTexturedModalRect(0, 0, 6 * 16, 0, 16, 16);
|
||||
this.mouseDragged(mc, par2, par3);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos() {
|
||||
return this.yPosition;
|
||||
}
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return EnumChatFormatting.WHITE + "" + LocaleHandler.EmptyTrash.getLocal() + "\n" + EnumChatFormatting.GRAY + ""
|
||||
+ LocaleHandler.EmptyTrashDesc.getLocal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
@Override
|
||||
public int xPos() {
|
||||
return this.xPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
@Override
|
||||
public int yPos() {
|
||||
return this.yPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return this.visible;
|
||||
}
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return this.visible;
|
||||
}
|
||||
}
|
||||
+65
-47
@@ -3,7 +3,6 @@ package net.p455w0rd.wirelesscraftingterminal.client.gui.widgets;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
|
||||
|
||||
/**
|
||||
* A modified version of the Minecraft text field.
|
||||
* You can initialize it over the full element span.
|
||||
@@ -12,58 +11,77 @@ import net.minecraft.client.gui.GuiTextField;
|
||||
*
|
||||
* The rendering does pay attention to the size of the '_' caret.
|
||||
*/
|
||||
public class MEGuiTextField extends GuiTextField
|
||||
{
|
||||
private static final int PADDING = 2;
|
||||
public class MEGuiTextField extends GuiTextField {
|
||||
private static final int PADDING = 2;
|
||||
|
||||
private final int _xPos;
|
||||
private final int _yPos;
|
||||
private final int _width;
|
||||
private final int _height;
|
||||
private final int _xPos;
|
||||
private final int _yPos;
|
||||
private final int _width;
|
||||
private final int _height;
|
||||
|
||||
/**
|
||||
* Uses the values to instantiate a padded version of a text field.
|
||||
* Pays attention to the '_' caret.
|
||||
*
|
||||
* @param fontRenderer renderer for the strings
|
||||
* @param xPos absolute left position
|
||||
* @param yPos absolute top position
|
||||
* @param width absolute width
|
||||
* @param height absolute height
|
||||
*/
|
||||
public MEGuiTextField( final FontRenderer fontRenderer, final int xPos, final int yPos, final int width, final int height )
|
||||
{
|
||||
super( fontRenderer, xPos, yPos, width, height - 2 * PADDING );
|
||||
/**
|
||||
* Uses the values to instantiate a padded version of a text field.
|
||||
* Pays attention to the '_' caret.
|
||||
*
|
||||
* @param fontRenderer renderer for the strings
|
||||
* @param xPos absolute left position
|
||||
* @param yPos absolute top position
|
||||
* @param width absolute width
|
||||
* @param height absolute height
|
||||
*/
|
||||
public MEGuiTextField(
|
||||
final FontRenderer fontRenderer, final int xPos, final int yPos, final int width, final int height) {
|
||||
super(fontRenderer, xPos, yPos, width, height - 2 * PADDING);
|
||||
|
||||
this._xPos = xPos;
|
||||
this._yPos = yPos;
|
||||
this._width = width;
|
||||
this._height = height;
|
||||
}
|
||||
this._xPos = xPos;
|
||||
this._yPos = yPos;
|
||||
this._width = width;
|
||||
this._height = height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked( final int xPos, final int yPos, final int button )
|
||||
{
|
||||
super.mouseClicked( xPos, yPos, button );
|
||||
@Override
|
||||
public void mouseClicked(final int xPos, final int yPos, final int button) {
|
||||
super.mouseClicked(xPos, yPos, button);
|
||||
|
||||
final boolean requiresFocus = this.isMouseIn( xPos, yPos );
|
||||
final boolean requiresFocus = this.isMouseIn(xPos, yPos);
|
||||
|
||||
this.setFocused( requiresFocus );
|
||||
}
|
||||
this.setFocused(requiresFocus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the mouse is within the element
|
||||
*
|
||||
* @param xCoord current x coord of the mouse
|
||||
* @param yCoord current y coord of the mouse
|
||||
*
|
||||
* @return true if mouse position is within the text field area
|
||||
*/
|
||||
public boolean isMouseIn( final int xCoord, final int yCoord )
|
||||
{
|
||||
final boolean withinXRange = xCoord >= this._xPos && xCoord <= this._xPos + this._width;
|
||||
final boolean withinYRange = this._yPos <= yCoord && yCoord < this._yPos + this._height;
|
||||
/**
|
||||
* Checks if the mouse is within the element
|
||||
*
|
||||
* @param xCoord current x coord of the mouse
|
||||
* @param yCoord current y coord of the mouse
|
||||
*
|
||||
* @return true if mouse position is within the text field area
|
||||
*/
|
||||
public boolean isMouseIn(final int xCoord, final int yCoord) {
|
||||
final boolean withinXRange = xCoord >= this._xPos && xCoord <= this._xPos + this._width;
|
||||
final boolean withinYRange = this._yPos <= yCoord && yCoord < this._yPos + this._height;
|
||||
|
||||
return withinXRange && withinYRange;
|
||||
}
|
||||
return withinXRange && withinYRange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTextBox() {
|
||||
if (this.getVisible()) {
|
||||
if (this.isFocused()) {
|
||||
drawRect(
|
||||
this.xPosition - 1,
|
||||
this.yPosition,
|
||||
this.xPosition + this.width - 1,
|
||||
this.yPosition + this.height + 2,
|
||||
0xFF606060);
|
||||
} else {
|
||||
drawRect(
|
||||
this.xPosition - 1,
|
||||
this.yPosition,
|
||||
this.xPosition + this.width - 1,
|
||||
this.yPosition + this.height + 2,
|
||||
0xFFA8A8A8);
|
||||
}
|
||||
super.drawTextBox();
|
||||
}
|
||||
}
|
||||
}
|
||||
+42
-30
@@ -1,25 +1,24 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.client.gui.widgets;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class WCTGuiButton extends GuiButton {
|
||||
|
||||
protected static final ResourceLocation buttonTextures = new ResourceLocation("minecraft", "textures/gui/widgets.png");
|
||||
|
||||
public WCTGuiButton(int p_i1020_1_, int p_i1020_2_, int p_i1020_3_, String p_i1020_4_)
|
||||
{
|
||||
|
||||
protected static final ResourceLocation buttonTextures =
|
||||
new ResourceLocation("minecraft", "textures/gui/widgets.png");
|
||||
|
||||
public WCTGuiButton(int p_i1020_1_, int p_i1020_2_, int p_i1020_3_, String p_i1020_4_) {
|
||||
this(p_i1020_1_, p_i1020_2_, p_i1020_3_, 200, 20, p_i1020_4_);
|
||||
}
|
||||
|
||||
public WCTGuiButton(int p_i1021_1_, int p_i1021_2_, int p_i1021_3_, int p_i1021_4_, int p_i1021_5_, String p_i1021_6_)
|
||||
{
|
||||
super(p_i1021_1_, p_i1021_2_, p_i1021_3_, p_i1021_4_, p_i1021_5_, p_i1021_6_);
|
||||
public WCTGuiButton(
|
||||
int p_i1021_1_, int p_i1021_2_, int p_i1021_3_, int p_i1021_4_, int p_i1021_5_, String p_i1021_6_) {
|
||||
super(p_i1021_1_, p_i1021_2_, p_i1021_3_, p_i1021_4_, p_i1021_5_, p_i1021_6_);
|
||||
this.width = 200;
|
||||
this.height = 20;
|
||||
this.enabled = true;
|
||||
@@ -31,43 +30,56 @@ public class WCTGuiButton extends GuiButton {
|
||||
this.height = p_i1021_5_;
|
||||
this.displayString = p_i1021_6_;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_)
|
||||
{
|
||||
if (this.visible)
|
||||
{
|
||||
public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_) {
|
||||
if (this.visible) {
|
||||
FontRenderer fontrenderer = p_146112_1_.fontRenderer;
|
||||
p_146112_1_.getTextureManager().bindTexture(buttonTextures);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.field_146123_n = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height;
|
||||
this.field_146123_n = p_146112_2_ >= this.xPosition
|
||||
&& p_146112_3_ >= this.yPosition
|
||||
&& p_146112_2_ < this.xPosition + this.width
|
||||
&& p_146112_3_ < this.yPosition + this.height;
|
||||
int k = this.getHoverState(this.field_146123_n);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height);
|
||||
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height - 2);
|
||||
this.drawTexturedModalRect(this.xPosition + 2, this.yPosition + (this.height - 2), 200 - (this.width - 2), 64 + k * 20, this.width - 2, 2);
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition + (this.height - 1), 200 - this.width, 65 + k * 20, this.width, 1);
|
||||
this.drawTexturedModalRect(
|
||||
this.xPosition + this.width / 2,
|
||||
this.yPosition,
|
||||
200 - this.width / 2,
|
||||
46 + k * 20,
|
||||
this.width / 2,
|
||||
this.height - 2);
|
||||
this.drawTexturedModalRect(
|
||||
this.xPosition + 2,
|
||||
this.yPosition + (this.height - 2),
|
||||
200 - (this.width - 2),
|
||||
64 + k * 20,
|
||||
this.width - 2,
|
||||
2);
|
||||
this.drawTexturedModalRect(
|
||||
this.xPosition, this.yPosition + (this.height - 1), 200 - this.width, 65 + k * 20, this.width, 1);
|
||||
this.mouseDragged(p_146112_1_, p_146112_2_, p_146112_3_);
|
||||
int l = 14737632;
|
||||
|
||||
if (packedFGColour != 0)
|
||||
{
|
||||
if (packedFGColour != 0) {
|
||||
l = packedFGColour;
|
||||
}
|
||||
else if (!this.enabled)
|
||||
{
|
||||
} else if (!this.enabled) {
|
||||
l = 10526880;
|
||||
}
|
||||
else if (this.field_146123_n)
|
||||
{
|
||||
} else if (this.field_146123_n) {
|
||||
l = 16777120;
|
||||
}
|
||||
|
||||
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l);
|
||||
this.drawCenteredString(
|
||||
fontrenderer,
|
||||
this.displayString,
|
||||
this.xPosition + this.width / 2,
|
||||
this.yPosition + (this.height - 8) / 2,
|
||||
l);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+59
-41
@@ -6,68 +6,86 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
|
||||
public class WCTGuiCheckBox extends GuiCheckBox {
|
||||
|
||||
private boolean isChecked;
|
||||
private int boxWidth;
|
||||
|
||||
public WCTGuiCheckBox(int id, int xPos, int yPos, String displayString, boolean isChecked, int width) {
|
||||
super(id, xPos, yPos, displayString, isChecked);
|
||||
this.isChecked = isChecked;
|
||||
private boolean isChecked;
|
||||
private int boxWidth;
|
||||
|
||||
public WCTGuiCheckBox(int id, int xPos, int yPos, String displayString, boolean isChecked, int width) {
|
||||
super(id, xPos, yPos, displayString, isChecked);
|
||||
this.isChecked = isChecked;
|
||||
this.boxWidth = 11;
|
||||
this.height = 11;
|
||||
//this.width = this.boxWidth + 2 + Minecraft.getMinecraft().fontRenderer.getStringWidth(displayString);
|
||||
// this.width = this.boxWidth + 2 + Minecraft.getMinecraft().fontRenderer.getStringWidth(displayString);
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY)
|
||||
{
|
||||
if (this.visible)
|
||||
{
|
||||
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.boxWidth && mouseY < this.yPosition + this.height;
|
||||
GuiUtils.drawContinuousTexturedBox(buttonTextures, this.xPosition + (this.width - this.boxWidth), this.yPosition, 0, 46, this.boxWidth, this.height, 200, 20, 2, 3, 2, 2, this.zLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
|
||||
if (this.visible) {
|
||||
this.field_146123_n = mouseX >= this.xPosition
|
||||
&& mouseY >= this.yPosition
|
||||
&& mouseX < this.xPosition + this.boxWidth
|
||||
&& mouseY < this.yPosition + this.height;
|
||||
GuiUtils.drawContinuousTexturedBox(
|
||||
buttonTextures,
|
||||
this.xPosition + (this.width - this.boxWidth),
|
||||
this.yPosition,
|
||||
0,
|
||||
46,
|
||||
this.boxWidth,
|
||||
this.height,
|
||||
200,
|
||||
20,
|
||||
2,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
this.zLevel);
|
||||
this.mouseDragged(mc, mouseX, mouseY);
|
||||
int color = 14737632;
|
||||
|
||||
if (!this.enabled)
|
||||
{
|
||||
|
||||
if (!this.enabled) {
|
||||
color = 10526880;
|
||||
}
|
||||
else {
|
||||
color = 4210752;
|
||||
} else {
|
||||
color = 4210752;
|
||||
}
|
||||
if (this.isChecked)
|
||||
this.drawCenteredString(mc.fontRenderer, "✔", this.xPosition + (this.width - this.boxWidth) + this.boxWidth / 2 + 1, this.yPosition + 1, 0x00FF00);
|
||||
|
||||
this.drawCenteredString(
|
||||
mc.fontRenderer,
|
||||
"✔",
|
||||
this.xPosition + (this.width - this.boxWidth) + this.boxWidth / 2 + 1,
|
||||
this.yPosition + 1,
|
||||
0x00FF00);
|
||||
|
||||
this.drawStringNoShadow(mc.fontRenderer, displayString, xPosition, yPosition + 2, color);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawStringNoShadow(FontRenderer p_73731_1_, String p_73731_2_, int p_73731_3_, int p_73731_4_, int p_73731_5_)
|
||||
{
|
||||
|
||||
public void drawStringNoShadow(
|
||||
FontRenderer p_73731_1_, String p_73731_2_, int p_73731_3_, int p_73731_4_, int p_73731_5_) {
|
||||
p_73731_1_.drawString(p_73731_2_, p_73731_3_, p_73731_4_, p_73731_5_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft p_146116_1_, int p_146116_2_, int p_146116_3_)
|
||||
{
|
||||
if (this.enabled && this.visible && p_146116_2_ >= this.xPosition && p_146116_3_ >= this.yPosition && p_146116_2_ < this.xPosition + this.width && p_146116_3_ < this.yPosition + this.height)
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft p_146116_1_, int p_146116_2_, int p_146116_3_) {
|
||||
if (this.enabled
|
||||
&& this.visible
|
||||
&& p_146116_2_ >= this.xPosition
|
||||
&& p_146116_3_ >= this.yPosition
|
||||
&& p_146116_2_ < this.xPosition + this.width
|
||||
&& p_146116_3_ < this.yPosition + this.height) {
|
||||
this.isChecked = !this.isChecked;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isChecked()
|
||||
{
|
||||
|
||||
public boolean isChecked() {
|
||||
return this.isChecked;
|
||||
}
|
||||
|
||||
public void setIsChecked(boolean isChecked)
|
||||
{
|
||||
|
||||
public void setIsChecked(boolean isChecked) {
|
||||
this.isChecked = isChecked;
|
||||
}
|
||||
|
||||
}
|
||||
+30
-39
@@ -1,52 +1,43 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.client.me;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ItemSorters;
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class ClientDCInternalInv implements Comparable<ClientDCInternalInv> {
|
||||
|
||||
public class ClientDCInternalInv implements Comparable<ClientDCInternalInv>
|
||||
{
|
||||
private final String unlocalizedName;
|
||||
private final AppEngInternalInventory inventory;
|
||||
|
||||
private final String unlocalizedName;
|
||||
private final AppEngInternalInventory inventory;
|
||||
private final long id;
|
||||
private final long sortBy;
|
||||
|
||||
private final long id;
|
||||
private final long sortBy;
|
||||
public ClientDCInternalInv(final int size, final long id, final long sortBy, final String unlocalizedName) {
|
||||
this.inventory = new AppEngInternalInventory(null, size);
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
this.id = id;
|
||||
this.sortBy = sortBy;
|
||||
}
|
||||
|
||||
public ClientDCInternalInv( final int size, final long id, final long sortBy, final String unlocalizedName )
|
||||
{
|
||||
this.inventory = new AppEngInternalInventory( null, size );
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
this.id = id;
|
||||
this.sortBy = sortBy;
|
||||
}
|
||||
public String getName() {
|
||||
final String s = StatCollector.translateToLocal(this.unlocalizedName + ".name");
|
||||
if (s.equals(this.unlocalizedName + ".name")) {
|
||||
return StatCollector.translateToLocal(this.unlocalizedName);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
final String s = StatCollector.translateToLocal( this.unlocalizedName + ".name" );
|
||||
if( s.equals( this.unlocalizedName + ".name" ) )
|
||||
{
|
||||
return StatCollector.translateToLocal( this.unlocalizedName );
|
||||
}
|
||||
return s;
|
||||
}
|
||||
@Override
|
||||
public int compareTo(@Nonnull final ClientDCInternalInv o) {
|
||||
return ItemSorters.compareLong(this.sortBy, o.sortBy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo( @Nonnull final ClientDCInternalInv o )
|
||||
{
|
||||
return ItemSorters.compareLong( this.sortBy, o.sortBy );
|
||||
}
|
||||
public AppEngInternalInventory getInventory() {
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
public AppEngInternalInventory getInventory()
|
||||
{
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
public long getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
@@ -3,45 +3,37 @@ package net.p455w0rd.wirelesscraftingterminal.client.me;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class InternalSlotME {
|
||||
|
||||
public class InternalSlotME
|
||||
{
|
||||
private final int offset;
|
||||
private final int xPos;
|
||||
private final int yPos;
|
||||
private final ItemRepo repo;
|
||||
|
||||
private final int offset;
|
||||
private final int xPos;
|
||||
private final int yPos;
|
||||
private final ItemRepo repo;
|
||||
public InternalSlotME(final ItemRepo def, final int offset, final int displayX, final int displayY) {
|
||||
this.repo = def;
|
||||
this.offset = offset;
|
||||
this.xPos = displayX;
|
||||
this.yPos = displayY;
|
||||
}
|
||||
|
||||
public InternalSlotME( final ItemRepo def, final int offset, final int displayX, final int displayY )
|
||||
{
|
||||
this.repo = def;
|
||||
this.offset = offset;
|
||||
this.xPos = displayX;
|
||||
this.yPos = displayY;
|
||||
}
|
||||
ItemStack getStack() {
|
||||
return this.repo.getItem(this.offset);
|
||||
}
|
||||
|
||||
ItemStack getStack()
|
||||
{
|
||||
return this.repo.getItem( this.offset );
|
||||
}
|
||||
IAEItemStack getAEStack() {
|
||||
return this.repo.getReferenceItem(this.offset);
|
||||
}
|
||||
|
||||
IAEItemStack getAEStack()
|
||||
{
|
||||
return this.repo.getReferenceItem( this.offset );
|
||||
}
|
||||
boolean hasPower() {
|
||||
return this.repo.hasPower();
|
||||
}
|
||||
|
||||
boolean hasPower()
|
||||
{
|
||||
return this.repo.hasPower();
|
||||
}
|
||||
int getxPosition() {
|
||||
return this.xPos;
|
||||
}
|
||||
|
||||
int getxPosition()
|
||||
{
|
||||
return this.xPos;
|
||||
}
|
||||
|
||||
int getyPosition()
|
||||
{
|
||||
return this.yPos;
|
||||
}
|
||||
int getyPosition() {
|
||||
return this.yPos;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,5 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.client.me;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.Settings;
|
||||
@@ -24,270 +16,225 @@ import appeng.util.ItemSorters;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.prioitylist.IPartitionList;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemRepo {
|
||||
|
||||
public class ItemRepo
|
||||
{
|
||||
private final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
|
||||
private final ArrayList<IAEItemStack> view = new ArrayList<IAEItemStack>();
|
||||
private final ArrayList<ItemStack> dsp = new ArrayList<ItemStack>();
|
||||
private final IScrollSource src;
|
||||
private final ISortSource sortSrc;
|
||||
|
||||
private final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
|
||||
private final ArrayList<IAEItemStack> view = new ArrayList<IAEItemStack>();
|
||||
private final ArrayList<ItemStack> dsp = new ArrayList<ItemStack>();
|
||||
private final IScrollSource src;
|
||||
private final ISortSource sortSrc;
|
||||
private int rowSize = 9;
|
||||
|
||||
private int rowSize = 9;
|
||||
private String searchString = "";
|
||||
private IPartitionList<IAEItemStack> myPartitionList;
|
||||
private String innerSearch = "";
|
||||
private String NEIWord = null;
|
||||
private boolean hasPower;
|
||||
|
||||
private String searchString = "";
|
||||
private IPartitionList<IAEItemStack> myPartitionList;
|
||||
private String innerSearch = "";
|
||||
private String NEIWord = null;
|
||||
private boolean hasPower;
|
||||
public ItemRepo(final IScrollSource src, final ISortSource sortSrc) {
|
||||
this.src = src;
|
||||
this.sortSrc = sortSrc;
|
||||
}
|
||||
|
||||
public ItemRepo( final IScrollSource src, final ISortSource sortSrc )
|
||||
{
|
||||
this.src = src;
|
||||
this.sortSrc = sortSrc;
|
||||
}
|
||||
public IAEItemStack getReferenceItem(int idx) {
|
||||
idx += this.src.getCurrentScroll() * this.rowSize;
|
||||
|
||||
public IAEItemStack getReferenceItem( int idx )
|
||||
{
|
||||
idx += this.src.getCurrentScroll() * this.rowSize;
|
||||
if (idx >= this.view.size()) {
|
||||
return null;
|
||||
}
|
||||
return this.view.get(idx);
|
||||
}
|
||||
|
||||
if( idx >= this.view.size() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return this.view.get( idx );
|
||||
}
|
||||
public ItemStack getItem(int idx) {
|
||||
idx += this.src.getCurrentScroll() * this.rowSize;
|
||||
|
||||
public ItemStack getItem( int idx )
|
||||
{
|
||||
idx += this.src.getCurrentScroll() * this.rowSize;
|
||||
if (idx >= this.dsp.size()) {
|
||||
return null;
|
||||
}
|
||||
return this.dsp.get(idx);
|
||||
}
|
||||
|
||||
if( idx >= this.dsp.size() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return this.dsp.get( idx );
|
||||
}
|
||||
void setSearch(final String search) {
|
||||
this.searchString = search == null ? "" : search;
|
||||
}
|
||||
|
||||
void setSearch( final String search )
|
||||
{
|
||||
this.searchString = search == null ? "" : search;
|
||||
}
|
||||
public void postUpdate(final IAEItemStack is) {
|
||||
final IAEItemStack st = this.list.findPrecise(is);
|
||||
|
||||
public void postUpdate( final IAEItemStack is )
|
||||
{
|
||||
final IAEItemStack st = this.list.findPrecise( is );
|
||||
if (st != null) {
|
||||
st.reset();
|
||||
st.add(is);
|
||||
} else {
|
||||
this.list.add(is);
|
||||
}
|
||||
}
|
||||
|
||||
if( st != null )
|
||||
{
|
||||
st.reset();
|
||||
st.add( is );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.list.add( is );
|
||||
}
|
||||
}
|
||||
public void setViewCell(final ItemStack[] list) {
|
||||
this.myPartitionList = ItemViewCell.createFilter(list);
|
||||
this.updateView();
|
||||
}
|
||||
|
||||
public void setViewCell( final ItemStack[] list )
|
||||
{
|
||||
this.myPartitionList = ItemViewCell.createFilter( list );
|
||||
this.updateView();
|
||||
}
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void updateView() {
|
||||
this.view.clear();
|
||||
this.dsp.clear();
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void updateView()
|
||||
{
|
||||
this.view.clear();
|
||||
this.dsp.clear();
|
||||
this.view.ensureCapacity(this.list.size());
|
||||
this.dsp.ensureCapacity(this.list.size());
|
||||
|
||||
this.view.ensureCapacity( this.list.size() );
|
||||
this.dsp.ensureCapacity( this.list.size() );
|
||||
final Enum viewMode = this.sortSrc.getSortDisplay();
|
||||
final Enum searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
|
||||
if (searchMode == SearchBoxMode.NEI_AUTOSEARCH || searchMode == SearchBoxMode.NEI_MANUAL_SEARCH) {
|
||||
this.updateNEI(this.searchString);
|
||||
}
|
||||
|
||||
final Enum viewMode = this.sortSrc.getSortDisplay();
|
||||
final Enum searchMode = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
|
||||
if( searchMode == SearchBoxMode.NEI_AUTOSEARCH || searchMode == SearchBoxMode.NEI_MANUAL_SEARCH )
|
||||
{
|
||||
this.updateNEI( this.searchString );
|
||||
}
|
||||
this.innerSearch = this.searchString;
|
||||
final boolean terminalSearchToolTips =
|
||||
AEConfig.instance.settings.getSetting(Settings.SEARCH_TOOLTIPS) != YesNo.NO;
|
||||
// boolean terminalSearchMods = Configuration.INSTANCE.settings.getSetting( Settings.SEARCH_MODS ) != YesNo.NO;
|
||||
|
||||
this.innerSearch = this.searchString;
|
||||
final boolean terminalSearchToolTips = AEConfig.instance.settings.getSetting( Settings.SEARCH_TOOLTIPS ) != YesNo.NO;
|
||||
// boolean terminalSearchMods = Configuration.INSTANCE.settings.getSetting( Settings.SEARCH_MODS ) != YesNo.NO;
|
||||
boolean searchMod = false;
|
||||
if (this.innerSearch.startsWith("@")) {
|
||||
searchMod = true;
|
||||
this.innerSearch = this.innerSearch.substring(1);
|
||||
}
|
||||
|
||||
boolean searchMod = false;
|
||||
if( this.innerSearch.startsWith( "@" ) )
|
||||
{
|
||||
searchMod = true;
|
||||
this.innerSearch = this.innerSearch.substring( 1 );
|
||||
}
|
||||
Pattern m = null;
|
||||
try {
|
||||
m = Pattern.compile(this.innerSearch.toLowerCase(), Pattern.CASE_INSENSITIVE);
|
||||
} catch (final Throwable ignore) {
|
||||
try {
|
||||
m = Pattern.compile(Pattern.quote(this.innerSearch.toLowerCase()), Pattern.CASE_INSENSITIVE);
|
||||
} catch (final Throwable __) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Pattern m = null;
|
||||
try
|
||||
{
|
||||
m = Pattern.compile( this.innerSearch.toLowerCase(), Pattern.CASE_INSENSITIVE );
|
||||
}
|
||||
catch( final Throwable ignore )
|
||||
{
|
||||
try
|
||||
{
|
||||
m = Pattern.compile( Pattern.quote( this.innerSearch.toLowerCase() ), Pattern.CASE_INSENSITIVE );
|
||||
}
|
||||
catch( final Throwable __ )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
boolean notDone = false;
|
||||
for (IAEItemStack is : this.list) {
|
||||
if (this.myPartitionList != null) {
|
||||
if (!this.myPartitionList.isListed(is)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
boolean notDone = false;
|
||||
for( IAEItemStack is : this.list )
|
||||
{
|
||||
if( this.myPartitionList != null )
|
||||
{
|
||||
if( !this.myPartitionList.isListed( is ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if( viewMode == ViewItems.CRAFTABLE && !is.isCraftable() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (viewMode == ViewItems.CRAFTABLE) {
|
||||
is = is.copy();
|
||||
is.setStackSize(0);
|
||||
}
|
||||
|
||||
if( viewMode == ViewItems.CRAFTABLE )
|
||||
{
|
||||
is = is.copy();
|
||||
is.setStackSize( 0 );
|
||||
}
|
||||
if (viewMode == ViewItems.STORED && is.getStackSize() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if( viewMode == ViewItems.STORED && is.getStackSize() == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final String dspName = searchMod ? Platform.getModId(is) : Platform.getItemDisplayName(is);
|
||||
notDone = true;
|
||||
|
||||
final String dspName = searchMod ? Platform.getModId( is ) : Platform.getItemDisplayName( is );
|
||||
notDone = true;
|
||||
if (m.matcher(dspName.toLowerCase()).find()) {
|
||||
this.view.add(is);
|
||||
notDone = false;
|
||||
}
|
||||
|
||||
if( m.matcher( dspName.toLowerCase() ).find() )
|
||||
{
|
||||
this.view.add( is );
|
||||
notDone = false;
|
||||
}
|
||||
if (terminalSearchToolTips && notDone) {
|
||||
for (final Object lp : Platform.getTooltip(is)) {
|
||||
if (lp instanceof String && m.matcher((CharSequence) lp).find()) {
|
||||
this.view.add(is);
|
||||
notDone = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( terminalSearchToolTips && notDone )
|
||||
{
|
||||
for( final Object lp : Platform.getTooltip( is ) )
|
||||
{
|
||||
if( lp instanceof String && m.matcher( (CharSequence) lp ).find() )
|
||||
{
|
||||
this.view.add( is );
|
||||
notDone = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* if ( terminalSearchMods && notDone ) { if ( m.matcher( Platform.getMod( is.getItemStack() ) ).find() ) {
|
||||
* view.add( is ); notDone = false; } }
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* if ( terminalSearchMods && notDone ) { if ( m.matcher( Platform.getMod( is.getItemStack() ) ).find() ) {
|
||||
* view.add( is ); notDone = false; } }
|
||||
*/
|
||||
}
|
||||
final Enum SortBy = this.sortSrc.getSortBy();
|
||||
final Enum SortDir = this.sortSrc.getSortDir();
|
||||
|
||||
final Enum SortBy = this.sortSrc.getSortBy();
|
||||
final Enum SortDir = this.sortSrc.getSortDir();
|
||||
ItemSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||
ItemSorters.init();
|
||||
|
||||
ItemSorters.setDirection( (appeng.api.config.SortDir) SortDir );
|
||||
ItemSorters.init();
|
||||
if (SortBy == SortOrder.MOD) {
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_MOD);
|
||||
} else if (SortBy == SortOrder.AMOUNT) {
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_SIZE);
|
||||
} else if (SortBy == SortOrder.INVTWEAKS) {
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
|
||||
} else {
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||
}
|
||||
|
||||
if( SortBy == SortOrder.MOD )
|
||||
{
|
||||
Collections.sort( this.view, ItemSorters.CONFIG_BASED_SORT_BY_MOD );
|
||||
}
|
||||
else if( SortBy == SortOrder.AMOUNT )
|
||||
{
|
||||
Collections.sort( this.view, ItemSorters.CONFIG_BASED_SORT_BY_SIZE );
|
||||
}
|
||||
else if( SortBy == SortOrder.INVTWEAKS )
|
||||
{
|
||||
Collections.sort( this.view, ItemSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS );
|
||||
}
|
||||
else
|
||||
{
|
||||
Collections.sort( this.view, ItemSorters.CONFIG_BASED_SORT_BY_NAME );
|
||||
}
|
||||
for (final IAEItemStack is : this.view) {
|
||||
this.dsp.add(is.getItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
for( final IAEItemStack is : this.view )
|
||||
{
|
||||
this.dsp.add( is.getItemStack() );
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void updateNEI(final String filter) {
|
||||
try {
|
||||
if (this.NEIWord == null || !this.NEIWord.equals(filter)) {
|
||||
final Class c =
|
||||
ReflectionHelper.getClass(this.getClass().getClassLoader(), "codechicken.nei.LayoutManager");
|
||||
final Field fldSearchField = c.getField("searchField");
|
||||
final Object searchField = fldSearchField.get(c);
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void updateNEI( final String filter )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( this.NEIWord == null || !this.NEIWord.equals( filter ) )
|
||||
{
|
||||
final Class c = ReflectionHelper.getClass( this.getClass().getClassLoader(), "codechicken.nei.LayoutManager" );
|
||||
final Field fldSearchField = c.getField( "searchField" );
|
||||
final Object searchField = fldSearchField.get( c );
|
||||
final Method a = searchField.getClass().getMethod("setText", String.class);
|
||||
final Method b = searchField.getClass().getMethod("onTextChange", String.class);
|
||||
|
||||
final Method a = searchField.getClass().getMethod( "setText", String.class );
|
||||
final Method b = searchField.getClass().getMethod( "onTextChange", String.class );
|
||||
this.NEIWord = filter;
|
||||
a.invoke(searchField, filter);
|
||||
b.invoke(searchField, "");
|
||||
}
|
||||
} catch (final Throwable ignore) {
|
||||
|
||||
this.NEIWord = filter;
|
||||
a.invoke( searchField, filter );
|
||||
b.invoke( searchField, "" );
|
||||
}
|
||||
}
|
||||
catch( final Throwable ignore )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public int size() {
|
||||
return this.view.size();
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
return this.view.size();
|
||||
}
|
||||
public void clear() {
|
||||
this.list.resetStatus();
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
this.list.resetStatus();
|
||||
}
|
||||
public boolean hasPower() {
|
||||
return this.hasPower;
|
||||
}
|
||||
|
||||
public boolean hasPower()
|
||||
{
|
||||
return this.hasPower;
|
||||
}
|
||||
public void setPower(final boolean hasPower) {
|
||||
this.hasPower = hasPower;
|
||||
}
|
||||
|
||||
public void setPower( final boolean hasPower )
|
||||
{
|
||||
this.hasPower = hasPower;
|
||||
}
|
||||
public int getRowSize() {
|
||||
return this.rowSize;
|
||||
}
|
||||
|
||||
public int getRowSize()
|
||||
{
|
||||
return this.rowSize;
|
||||
}
|
||||
public void setRowSize(final int rowSize) {
|
||||
this.rowSize = rowSize;
|
||||
}
|
||||
|
||||
public void setRowSize( final int rowSize )
|
||||
{
|
||||
this.rowSize = rowSize;
|
||||
}
|
||||
public String getSearchString() {
|
||||
return this.searchString;
|
||||
}
|
||||
|
||||
public String getSearchString()
|
||||
{
|
||||
return this.searchString;
|
||||
}
|
||||
|
||||
public void setSearchString( @Nonnull final String searchString )
|
||||
{
|
||||
this.searchString = searchString;
|
||||
}
|
||||
public void setSearchString(@Nonnull final String searchString) {
|
||||
this.searchString = searchString;
|
||||
}
|
||||
}
|
||||
+51
-70
@@ -7,86 +7,67 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.slot.AppEngSlot;
|
||||
|
||||
public class SlotDisconnected extends AppEngSlot {
|
||||
|
||||
public class SlotDisconnected extends AppEngSlot
|
||||
{
|
||||
private final ClientDCInternalInv mySlot;
|
||||
|
||||
private final ClientDCInternalInv mySlot;
|
||||
public SlotDisconnected(final ClientDCInternalInv me, final int which, final int x, final int y) {
|
||||
super(me.getInventory(), which, x, y);
|
||||
this.mySlot = me;
|
||||
}
|
||||
|
||||
public SlotDisconnected( final ClientDCInternalInv me, final int which, final int x, final int y )
|
||||
{
|
||||
super( me.getInventory(), which, x, y );
|
||||
this.mySlot = me;
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void putStack(final ItemStack par1ItemStack) {}
|
||||
|
||||
@Override
|
||||
public void putStack( final ItemStack par1ItemStack )
|
||||
{
|
||||
@Override
|
||||
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public ItemStack getDisplayStack() {
|
||||
if (Platform.isClient()) {
|
||||
final ItemStack is = super.getStack();
|
||||
if (is != null && is.getItem() instanceof ItemEncodedPattern) {
|
||||
final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
|
||||
final ItemStack out = iep.getOutput(is);
|
||||
if (out != null) {
|
||||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final EntityPlayer par1EntityPlayer )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void onPickupFromSlot(final EntityPlayer par1EntityPlayer, final ItemStack par2ItemStack) {}
|
||||
|
||||
@Override
|
||||
public ItemStack getDisplayStack()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
final ItemStack is = super.getStack();
|
||||
if( is != null && is.getItem() instanceof ItemEncodedPattern )
|
||||
{
|
||||
final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
|
||||
final ItemStack out = iep.getOutput( is );
|
||||
if( out != null )
|
||||
{
|
||||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
@Override
|
||||
public boolean getHasStack() {
|
||||
return this.getStack() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot( final EntityPlayer par1EntityPlayer, final ItemStack par2ItemStack )
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasStack()
|
||||
{
|
||||
return this.getStack() != null;
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int par1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public boolean isSlotInInventory(final IInventory par1iInventory, final int par2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int par1 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotInInventory( final IInventory par1iInventory, final int par2 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public ClientDCInternalInv getSlot()
|
||||
{
|
||||
return this.mySlot;
|
||||
}
|
||||
public ClientDCInternalInv getSlot() {
|
||||
return this.mySlot;
|
||||
}
|
||||
}
|
||||
@@ -6,86 +6,66 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotME extends Slot {
|
||||
|
||||
public class SlotME extends Slot
|
||||
{
|
||||
private final InternalSlotME mySlot;
|
||||
|
||||
private final InternalSlotME mySlot;
|
||||
public SlotME(final InternalSlotME me) {
|
||||
super(null, 0, me.getxPosition(), me.getyPosition());
|
||||
this.mySlot = me;
|
||||
}
|
||||
|
||||
public SlotME( final InternalSlotME me )
|
||||
{
|
||||
super( null, 0, me.getxPosition(), me.getyPosition() );
|
||||
this.mySlot = me;
|
||||
}
|
||||
public IAEItemStack getAEStack() {
|
||||
if (this.mySlot.hasPower()) {
|
||||
return this.mySlot.getAEStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IAEItemStack getAEStack()
|
||||
{
|
||||
if( this.mySlot.hasPower() )
|
||||
{
|
||||
return this.mySlot.getAEStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public void onPickupFromSlot(final EntityPlayer par1EntityPlayer, final ItemStack par2ItemStack) {}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot( final EntityPlayer par1EntityPlayer, final ItemStack par2ItemStack )
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
if (this.mySlot.hasPower()) {
|
||||
return this.mySlot.getStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack()
|
||||
{
|
||||
if( this.mySlot.hasPower() )
|
||||
{
|
||||
return this.mySlot.getStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public boolean getHasStack() {
|
||||
if (this.mySlot.hasPower()) {
|
||||
return this.getStack() != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasStack()
|
||||
{
|
||||
if( this.mySlot.hasPower() )
|
||||
{
|
||||
return this.getStack() != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void putStack(final ItemStack par1ItemStack) {}
|
||||
|
||||
@Override
|
||||
public void putStack( final ItemStack par1ItemStack )
|
||||
{
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int par1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public boolean isSlotInInventory(final IInventory par1iInventory, final int par2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int par1 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotInInventory( final IInventory par1iInventory, final int par2 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final EntityPlayer par1EntityPlayer )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+105
-104
@@ -1,21 +1,18 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.client.me;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.util.ISlimReadableNumberConverter;
|
||||
import appeng.util.IWideReadableNumberConverter;
|
||||
import appeng.util.ReadableNumberConverter;
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* @author AlgorithmX2
|
||||
@@ -23,124 +20,128 @@ import net.minecraft.item.ItemStack;
|
||||
* @version rv2
|
||||
* @since rv0
|
||||
*/
|
||||
public class WCTRenderItem extends RenderItem
|
||||
{
|
||||
private static final ISlimReadableNumberConverter SLIM_CONVERTER = ReadableNumberConverter.INSTANCE;
|
||||
private static final IWideReadableNumberConverter WIDE_CONVERTER = ReadableNumberConverter.INSTANCE;
|
||||
boolean useLg = AEConfig.instance.useTerminalUseLargeFont();
|
||||
private IAEItemStack aeStack = null;
|
||||
public class WCTRenderItem extends RenderItem {
|
||||
private static final ISlimReadableNumberConverter SLIM_CONVERTER = ReadableNumberConverter.INSTANCE;
|
||||
private static final IWideReadableNumberConverter WIDE_CONVERTER = ReadableNumberConverter.INSTANCE;
|
||||
boolean useLg = AEConfig.instance.useTerminalUseLargeFont();
|
||||
private IAEItemStack aeStack = null;
|
||||
|
||||
@Override
|
||||
public void renderItemOverlayIntoGUI( final FontRenderer fontRenderer, final TextureManager textureManager, final ItemStack is, final int par4, final int par5, final String par6Str )
|
||||
{
|
||||
if( is != null )
|
||||
{
|
||||
final float scaleFactor = useLg ? 0.85f : 0.5f;
|
||||
final float inverseScaleFactor = 1.0f / scaleFactor;
|
||||
final int offset = useLg ? 0 : -1;
|
||||
@Override
|
||||
public void renderItemOverlayIntoGUI(
|
||||
final FontRenderer fontRenderer,
|
||||
final TextureManager textureManager,
|
||||
final ItemStack is,
|
||||
final int par4,
|
||||
final int par5,
|
||||
final String par6Str) {
|
||||
if (is != null) {
|
||||
final float scaleFactor = useLg ? 0.85f : 0.5f;
|
||||
final float inverseScaleFactor = 1.0f / scaleFactor;
|
||||
final int offset = useLg ? 0 : -1;
|
||||
|
||||
final boolean unicodeFlag = fontRenderer.getUnicodeFlag();
|
||||
fontRenderer.setUnicodeFlag( false );
|
||||
final boolean unicodeFlag = fontRenderer.getUnicodeFlag();
|
||||
fontRenderer.setUnicodeFlag(false);
|
||||
|
||||
if( is.getItem().showDurabilityBar( is ) )
|
||||
{
|
||||
final double health = is.getItem().getDurabilityForDisplay( is );
|
||||
final int j1 = (int) Math.round( 13.0D - health * 13.0D );
|
||||
final int k = (int) Math.round( 255.0D - health * 255.0D );
|
||||
if (is.getItem().showDurabilityBar(is)) {
|
||||
final double health = is.getItem().getDurabilityForDisplay(is);
|
||||
final int j1 = (int) Math.round(13.0D - health * 13.0D);
|
||||
final int k = (int) Math.round(255.0D - health * 255.0D);
|
||||
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
GL11.glDisable( GL11.GL_DEPTH_TEST );
|
||||
GL11.glDisable( GL11.GL_TEXTURE_2D );
|
||||
GL11.glDisable( GL11.GL_ALPHA_TEST );
|
||||
GL11.glDisable( GL11.GL_BLEND );
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
final int l = 255 - k << 16 | k << 8;
|
||||
final int i1 = ( 255 - k ) / 4 << 16 | 16128;
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
final int l = 255 - k << 16 | k << 8;
|
||||
final int i1 = (255 - k) / 4 << 16 | 16128;
|
||||
|
||||
this.renderQuad( tessellator, par4 + 2, par5 + 13, 13, 2, 0 );
|
||||
this.renderQuad( tessellator, par4 + 2, par5 + 13, 12, 1, i1 );
|
||||
this.renderQuad( tessellator, par4 + 2, par5 + 13, j1, 1, l );
|
||||
this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0);
|
||||
this.renderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, i1);
|
||||
this.renderQuad(tessellator, par4 + 2, par5 + 13, j1, 1, l);
|
||||
|
||||
GL11.glEnable( GL11.GL_ALPHA_TEST );
|
||||
GL11.glEnable( GL11.GL_TEXTURE_2D );
|
||||
GL11.glEnable( GL11.GL_LIGHTING );
|
||||
GL11.glEnable( GL11.GL_DEPTH_TEST );
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
}
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
if( is.stackSize == 0 )
|
||||
{
|
||||
final String craftLabelText = useLg ? GuiText.LargeFontCraft.getLocal() : GuiText.SmallFontCraft.getLocal();
|
||||
if (is.stackSize == 0) {
|
||||
final String craftLabelText =
|
||||
useLg ? GuiText.LargeFontCraft.getLocal() : GuiText.SmallFontCraft.getLocal();
|
||||
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
GL11.glDisable( GL11.GL_DEPTH_TEST );
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled( scaleFactor, scaleFactor, scaleFactor );
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled(scaleFactor, scaleFactor, scaleFactor);
|
||||
|
||||
final int X = (int) ( ( (float) par4 + offset + 16.0f - fontRenderer.getStringWidth( craftLabelText ) * scaleFactor ) * inverseScaleFactor );
|
||||
final int Y = (int) ( ( (float) par5 + offset + 16.0f - 7.0f * scaleFactor ) * inverseScaleFactor );
|
||||
fontRenderer.drawStringWithShadow( craftLabelText, X, Y, 16777215 );
|
||||
final int X = (int)
|
||||
(((float) par4 + offset + 16.0f - fontRenderer.getStringWidth(craftLabelText) * scaleFactor)
|
||||
* inverseScaleFactor);
|
||||
final int Y = (int) (((float) par5 + offset + 16.0f - 7.0f * scaleFactor) * inverseScaleFactor);
|
||||
fontRenderer.drawStringWithShadow(craftLabelText, X, Y, 16777215);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glEnable( GL11.GL_LIGHTING );
|
||||
GL11.glEnable( GL11.GL_DEPTH_TEST );
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
final long amount = this.aeStack != null ? this.aeStack.getStackSize() : is.stackSize;
|
||||
final long amount = this.aeStack != null ? this.aeStack.getStackSize() : is.stackSize;
|
||||
|
||||
if( amount != 0 )
|
||||
{
|
||||
final String stackSize = this.getToBeRenderedStackSize( amount );
|
||||
if (amount != 0) {
|
||||
final String stackSize = this.getToBeRenderedStackSize(amount);
|
||||
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
GL11.glDisable( GL11.GL_DEPTH_TEST );
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled( scaleFactor, scaleFactor, scaleFactor );
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled(scaleFactor, scaleFactor, scaleFactor);
|
||||
|
||||
final int X = (int) ( ( (float) par4 + offset + 16.0f - fontRenderer.getStringWidth( stackSize ) * scaleFactor ) * inverseScaleFactor );
|
||||
final int Y = (int) ( ( (float) par5 + offset + 16.0f - 7.0f * scaleFactor ) * inverseScaleFactor );
|
||||
fontRenderer.drawStringWithShadow( stackSize, X, Y, 16777215 );
|
||||
final int X =
|
||||
(int) (((float) par4 + offset + 16.0f - fontRenderer.getStringWidth(stackSize) * scaleFactor)
|
||||
* inverseScaleFactor);
|
||||
final int Y = (int) (((float) par5 + offset + 16.0f - 7.0f * scaleFactor) * inverseScaleFactor);
|
||||
fontRenderer.drawStringWithShadow(stackSize, X, Y, 16777215);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glEnable( GL11.GL_LIGHTING );
|
||||
GL11.glEnable( GL11.GL_DEPTH_TEST );
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
fontRenderer.setUnicodeFlag( unicodeFlag );
|
||||
}
|
||||
}
|
||||
fontRenderer.setUnicodeFlag(unicodeFlag);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderQuad( final Tessellator par1Tessellator, final int par2, final int par3, final int par4, final int par5, final int par6 )
|
||||
{
|
||||
par1Tessellator.startDrawingQuads();
|
||||
par1Tessellator.setColorOpaque_I( par6 );
|
||||
par1Tessellator.addVertex( par2, par3, 0.0D );
|
||||
par1Tessellator.addVertex( par2, par3 + par5, 0.0D );
|
||||
par1Tessellator.addVertex( par2 + par4, par3 + par5, 0.0D );
|
||||
par1Tessellator.addVertex( par2 + par4, par3, 0.0D );
|
||||
par1Tessellator.draw();
|
||||
}
|
||||
private void renderQuad(
|
||||
final Tessellator par1Tessellator,
|
||||
final int par2,
|
||||
final int par3,
|
||||
final int par4,
|
||||
final int par5,
|
||||
final int par6) {
|
||||
par1Tessellator.startDrawingQuads();
|
||||
par1Tessellator.setColorOpaque_I(par6);
|
||||
par1Tessellator.addVertex(par2, par3, 0.0D);
|
||||
par1Tessellator.addVertex(par2, par3 + par5, 0.0D);
|
||||
par1Tessellator.addVertex(par2 + par4, par3 + par5, 0.0D);
|
||||
par1Tessellator.addVertex(par2 + par4, par3, 0.0D);
|
||||
par1Tessellator.draw();
|
||||
}
|
||||
|
||||
private String getToBeRenderedStackSize( final long originalSize )
|
||||
{
|
||||
if( AEConfig.instance.useTerminalUseLargeFont() )
|
||||
{
|
||||
return SLIM_CONVERTER.toSlimReadableForm( originalSize );
|
||||
}
|
||||
else
|
||||
{
|
||||
return WIDE_CONVERTER.toWideReadableForm( originalSize );
|
||||
}
|
||||
}
|
||||
private String getToBeRenderedStackSize(final long originalSize) {
|
||||
if (AEConfig.instance.useTerminalUseLargeFont()) {
|
||||
return SLIM_CONVERTER.toSlimReadableForm(originalSize);
|
||||
} else {
|
||||
return WIDE_CONVERTER.toWideReadableForm(originalSize);
|
||||
}
|
||||
}
|
||||
|
||||
public IAEItemStack getAeStack()
|
||||
{
|
||||
return this.aeStack;
|
||||
}
|
||||
public IAEItemStack getAeStack() {
|
||||
return this.aeStack;
|
||||
}
|
||||
|
||||
public void setAeStack( @Nonnull final IAEItemStack aeStack )
|
||||
{
|
||||
this.aeStack = aeStack;
|
||||
}
|
||||
public void setAeStack(@Nonnull final IAEItemStack aeStack) {
|
||||
this.aeStack = aeStack;
|
||||
}
|
||||
}
|
||||
+35
-37
@@ -1,50 +1,48 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.client.textures;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
/**
|
||||
* Icon from a state texture.
|
||||
*
|
||||
*
|
||||
* @author Nividica
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface IStateIconTexture
|
||||
{
|
||||
/**
|
||||
* Height of the icon.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getHeight();
|
||||
public interface IStateIconTexture {
|
||||
/**
|
||||
* Height of the icon.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getHeight();
|
||||
|
||||
/**
|
||||
* Texture the icon is in.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Nonnull
|
||||
ResourceLocation getTexture();
|
||||
/**
|
||||
* Texture the icon is in.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Nonnull
|
||||
ResourceLocation getTexture();
|
||||
|
||||
/**
|
||||
* U coordinate of the icon.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getU();
|
||||
/**
|
||||
* U coordinate of the icon.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getU();
|
||||
|
||||
/**
|
||||
* V coordinate of the icon.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getV();
|
||||
/**
|
||||
* V coordinate of the icon.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getV();
|
||||
|
||||
/**
|
||||
* Width of the icon.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getWidth();
|
||||
}
|
||||
/**
|
||||
* Width of the icon.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getWidth();
|
||||
}
|
||||
+115
-95
@@ -4,127 +4,147 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
/**
|
||||
* Icons stored in the AE2's "states" texture.
|
||||
*
|
||||
*
|
||||
* @author Nividica
|
||||
*
|
||||
*
|
||||
*/
|
||||
public enum WCTStateIconsEnum implements IStateIconTexture {
|
||||
|
||||
// Redstone modes
|
||||
REDSTONE_LOW(0, 0), REDSTONE_HIGH(16, 0), REDSTONE_PULSE(32, 0), REDSTONE_IGNORE(48, 0),
|
||||
// Redstone modes
|
||||
REDSTONE_LOW(0, 0),
|
||||
REDSTONE_HIGH(16, 0),
|
||||
REDSTONE_PULSE(32, 0),
|
||||
REDSTONE_IGNORE(48, 0),
|
||||
|
||||
// Slot backgrounds
|
||||
VIEW_CELL_BACKGROUND(224, 64), UPGRADE_CARD_BACKGROUND(240, 208), ME_CELL_BACKGROUND(240,
|
||||
0), PATTERN_CELL_BACKGROUND(240, 128),
|
||||
// Slot backgrounds
|
||||
VIEW_CELL_BACKGROUND(224, 64),
|
||||
UPGRADE_CARD_BACKGROUND(240, 208),
|
||||
ME_CELL_BACKGROUND(240, 0),
|
||||
PATTERN_CELL_BACKGROUND(240, 128),
|
||||
|
||||
// Buttons
|
||||
REGULAR_BUTTON(240, 240), TAB_BUTTON(208, 0, 22, 22),
|
||||
// Buttons
|
||||
REGULAR_BUTTON(240, 240),
|
||||
TAB_BUTTON(208, 0, 22, 22),
|
||||
|
||||
// Sorting modes
|
||||
SORT_MODE_ALPHABETIC(0, 64), SORT_MODE_AMOUNT(16, 64), SORT_MODE_MOD(80, 64), SORT_MODE_INVTWEAK(64, 64),
|
||||
// Sorting modes
|
||||
SORT_MODE_ALPHABETIC(0, 64),
|
||||
SORT_MODE_AMOUNT(16, 64),
|
||||
SORT_MODE_MOD(80, 64),
|
||||
SORT_MODE_INVTWEAK(64, 64),
|
||||
|
||||
// Sorting directions
|
||||
SORT_DIR_ASC(0, 48), SORT_DIR_DEC(16, 48),
|
||||
// Sorting directions
|
||||
SORT_DIR_ASC(0, 48),
|
||||
SORT_DIR_DEC(16, 48),
|
||||
|
||||
// View types
|
||||
VIEW_TYPE_STORED(0, 16), VIEW_TYPE_ALL(32, 16), VIEW_TYPE_CRAFT(48, 16),
|
||||
// View types
|
||||
VIEW_TYPE_STORED(0, 16),
|
||||
VIEW_TYPE_ALL(32, 16),
|
||||
VIEW_TYPE_CRAFT(48, 16),
|
||||
|
||||
// Terminal styles
|
||||
TERM_STYLE_TALL(0, 208), TERM_STYLE_SMALL(16, 208),
|
||||
// Terminal styles
|
||||
TERM_STYLE_TALL(0, 208),
|
||||
TERM_STYLE_SMALL(16, 208),
|
||||
|
||||
// Search modes
|
||||
SEARCH_MODE_AUTO(48, 32), SEARCH_MODE_MANUAL(64, 32), SEARCH_MODE_NEI_AUTO(80, 32), SEARCH_MODE_NEI_MANUAL(96, 32),
|
||||
// Search modes
|
||||
SEARCH_MODE_AUTO(48, 32),
|
||||
SEARCH_MODE_MANUAL(64, 32),
|
||||
SEARCH_MODE_NEI_AUTO(80, 32),
|
||||
SEARCH_MODE_NEI_MANUAL(96, 32),
|
||||
|
||||
// Misc
|
||||
WRENCH(32, 64), DISABLED(0, 128), ENABLED(16, 128), SAVE(0, 176), DELETE(0, 192), CLEAR_GRID(96, 0), ARROW_DOWN(128, 0);
|
||||
// Misc
|
||||
WRENCH(32, 64),
|
||||
DISABLED(0, 128),
|
||||
ENABLED(16, 128),
|
||||
SAVE(0, 176),
|
||||
DELETE(0, 192),
|
||||
CLEAR_GRID(96, 0),
|
||||
ARROW_DOWN(128, 0);
|
||||
|
||||
/**
|
||||
* Location of the AE states texture
|
||||
*/
|
||||
public static final ResourceLocation AE_STATES_TEXTURE = new ResourceLocation("appliedenergistics2",
|
||||
"textures/guis/states.png");
|
||||
/**
|
||||
* Location of the AE states texture
|
||||
*/
|
||||
public static final ResourceLocation AE_STATES_TEXTURE =
|
||||
new ResourceLocation("appliedenergistics2", "textures/guis/states.png");
|
||||
|
||||
/**
|
||||
* Width and height of standard icons.
|
||||
*/
|
||||
public static final int STANDARD_ICON_SIZE = 16;
|
||||
/**
|
||||
* Width and height of standard icons.
|
||||
*/
|
||||
public static final int STANDARD_ICON_SIZE = 16;
|
||||
|
||||
/**
|
||||
* X position in the texture this icon is located at.
|
||||
*/
|
||||
private int minU;
|
||||
/**
|
||||
* X position in the texture this icon is located at.
|
||||
*/
|
||||
private int minU;
|
||||
|
||||
/**
|
||||
* Y position in the texture this icon is located at.
|
||||
*/
|
||||
private int minV;
|
||||
/**
|
||||
* Y position in the texture this icon is located at.
|
||||
*/
|
||||
private int minV;
|
||||
|
||||
/**
|
||||
* Width of the icon
|
||||
*/
|
||||
private int width;
|
||||
/**
|
||||
* Width of the icon
|
||||
*/
|
||||
private int width;
|
||||
|
||||
/**
|
||||
* Height of the icon
|
||||
*/
|
||||
private int height;
|
||||
/**
|
||||
* Height of the icon
|
||||
*/
|
||||
private int height;
|
||||
|
||||
/**
|
||||
* Standard icon constructor
|
||||
*
|
||||
* @param u
|
||||
* @param v
|
||||
*/
|
||||
private WCTStateIconsEnum(final int u, final int v) {
|
||||
this(u, v, STANDARD_ICON_SIZE, STANDARD_ICON_SIZE);
|
||||
}
|
||||
/**
|
||||
* Standard icon constructor
|
||||
*
|
||||
* @param u
|
||||
* @param v
|
||||
*/
|
||||
private WCTStateIconsEnum(final int u, final int v) {
|
||||
this(u, v, STANDARD_ICON_SIZE, STANDARD_ICON_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Icon constructor
|
||||
*
|
||||
* @param u
|
||||
* @param v
|
||||
* @param width
|
||||
* @param height
|
||||
*/
|
||||
private WCTStateIconsEnum(final int u, final int v, final int width, final int height) {
|
||||
// Set the u
|
||||
this.minU = u;
|
||||
/**
|
||||
* Icon constructor
|
||||
*
|
||||
* @param u
|
||||
* @param v
|
||||
* @param width
|
||||
* @param height
|
||||
*/
|
||||
private WCTStateIconsEnum(final int u, final int v, final int width, final int height) {
|
||||
// Set the u
|
||||
this.minU = u;
|
||||
|
||||
// Set the v
|
||||
this.minV = v;
|
||||
// Set the v
|
||||
this.minV = v;
|
||||
|
||||
// Set width
|
||||
this.width = width;
|
||||
// Set width
|
||||
this.width = width;
|
||||
|
||||
// Set height
|
||||
this.height = height;
|
||||
// Set height
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
@Override
|
||||
public ResourceLocation getTexture() {
|
||||
return WCTStateIconsEnum.AE_STATES_TEXTURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture() {
|
||||
return WCTStateIconsEnum.AE_STATES_TEXTURE;
|
||||
}
|
||||
@Override
|
||||
public int getU() {
|
||||
return this.minU;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getU() {
|
||||
return this.minU;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getV() {
|
||||
return this.minV;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
@Override
|
||||
public int getV() {
|
||||
return this.minV;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package net.p455w0rd.wirelesscraftingterminal.common;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.container.implementations.ContainerCraftingStatus;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
@@ -13,7 +14,6 @@ import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiMagnet;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiWirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftAmount;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftConfirm;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftingStatus;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerMagnet;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerWirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
|
||||
@@ -22,74 +22,83 @@ import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
public class WCTGuiHandler implements IGuiHandler {
|
||||
|
||||
public void registerRenderers() {
|
||||
}
|
||||
public void registerRenderers() {}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int guiId, EntityPlayer player, World world, int x, int y, int z) {
|
||||
final IWirelessCraftingTermHandler wh = (IWirelessCraftingTermHandler) AEApi.instance().registries().wireless().getWirelessTerminalHandler(RandomUtils.getWirelessTerm(player.inventory));
|
||||
if (wh != null) {
|
||||
final WirelessTerminalGuiObject obj = new WirelessTerminalGuiObject(wh, RandomUtils.getWirelessTerm(player.inventory), player, world, x, y, z);
|
||||
if (obj != null) {
|
||||
final IPortableCell terminal = obj;
|
||||
@Override
|
||||
public Object getServerGuiElement(int guiId, EntityPlayer player, World world, int x, int y, int z) {
|
||||
final IWirelessCraftingTermHandler wh = (IWirelessCraftingTermHandler) AEApi.instance()
|
||||
.registries()
|
||||
.wireless()
|
||||
.getWirelessTerminalHandler(RandomUtils.getWirelessTerm(player.inventory));
|
||||
if (wh != null) {
|
||||
final WirelessTerminalGuiObject obj = new WirelessTerminalGuiObject(
|
||||
wh, RandomUtils.getWirelessTerm(player.inventory), player, world, x, y, z);
|
||||
if (obj != null) {
|
||||
final IPortableCell terminal = obj;
|
||||
|
||||
if (guiId == Reference.GUI_WCT) {
|
||||
return new ContainerWirelessCraftingTerminal(player, player.inventory);
|
||||
}
|
||||
if (guiId == Reference.GUI_WCT) {
|
||||
return new ContainerWirelessCraftingTerminal(player, player.inventory);
|
||||
}
|
||||
|
||||
if (guiId == Reference.GUI_CRAFTING_STATUS) {
|
||||
return new ContainerCraftingStatus(player.inventory, terminal);
|
||||
}
|
||||
if (guiId == Reference.GUI_CRAFTING_STATUS) {
|
||||
return new ContainerCraftingStatus(player.inventory, terminal);
|
||||
}
|
||||
|
||||
if (guiId == Reference.GUI_CRAFT_AMOUNT) {
|
||||
return new ContainerCraftAmount(player.inventory, terminal);
|
||||
}
|
||||
if (guiId == Reference.GUI_CRAFT_AMOUNT) {
|
||||
return new ContainerCraftAmount(player.inventory, terminal);
|
||||
}
|
||||
|
||||
if (guiId == Reference.GUI_CRAFT_CONFIRM) {
|
||||
return new ContainerCraftConfirm(player.inventory, terminal);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (guiId == Reference.GUI_MAGNET) {
|
||||
return new ContainerMagnet(player, player.inventory);
|
||||
}
|
||||
if (guiId == Reference.GUI_CRAFT_CONFIRM) {
|
||||
return new ContainerCraftConfirm(player.inventory, terminal);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (guiId == Reference.GUI_MAGNET) {
|
||||
return new ContainerMagnet(player, player.inventory);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int guiId, EntityPlayer player, World world, int x, int y, int z) {
|
||||
final IWirelessCraftingTermHandler wh = (IWirelessCraftingTermHandler) AEApi.instance().registries().wireless().getWirelessTerminalHandler(RandomUtils.getWirelessTerm(player.inventory));
|
||||
if (wh != null) {
|
||||
final WirelessTerminalGuiObject obj = new WirelessTerminalGuiObject(wh, RandomUtils.getWirelessTerm(player.inventory), player, world, x, y, z);
|
||||
if (obj != null) {
|
||||
final IPortableCell terminal = obj;
|
||||
@Override
|
||||
public Object getClientGuiElement(int guiId, EntityPlayer player, World world, int x, int y, int z) {
|
||||
final IWirelessCraftingTermHandler wh = (IWirelessCraftingTermHandler) AEApi.instance()
|
||||
.registries()
|
||||
.wireless()
|
||||
.getWirelessTerminalHandler(RandomUtils.getWirelessTerm(player.inventory));
|
||||
if (wh != null) {
|
||||
final WirelessTerminalGuiObject obj = new WirelessTerminalGuiObject(
|
||||
wh, RandomUtils.getWirelessTerm(player.inventory), player, world, x, y, z);
|
||||
if (obj != null) {
|
||||
final IPortableCell terminal = obj;
|
||||
|
||||
if (guiId == Reference.GUI_WCT) {
|
||||
return new GuiWirelessCraftingTerminal(new ContainerWirelessCraftingTerminal(player, player.inventory));
|
||||
}
|
||||
if (guiId == Reference.GUI_WCT) {
|
||||
return new GuiWirelessCraftingTerminal(
|
||||
new ContainerWirelessCraftingTerminal(player, player.inventory));
|
||||
}
|
||||
|
||||
if (guiId == Reference.GUI_CRAFTING_STATUS) {
|
||||
return new GuiCraftingStatus(player.inventory, terminal);
|
||||
}
|
||||
if (guiId == Reference.GUI_CRAFTING_STATUS) {
|
||||
return new GuiCraftingStatus(player.inventory, terminal);
|
||||
}
|
||||
|
||||
if (guiId == Reference.GUI_CRAFT_AMOUNT) {
|
||||
return new GuiCraftAmount(player.inventory, terminal);
|
||||
}
|
||||
if (guiId == Reference.GUI_CRAFT_AMOUNT) {
|
||||
return new GuiCraftAmount(player.inventory, terminal);
|
||||
}
|
||||
|
||||
if (guiId == Reference.GUI_CRAFT_CONFIRM) {
|
||||
return new GuiCraftConfirm(player.inventory, terminal);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (guiId == Reference.GUI_MAGNET) {
|
||||
return new GuiMagnet(new ContainerMagnet(player, player.inventory));
|
||||
}
|
||||
if (guiId == Reference.GUI_CRAFT_CONFIRM) {
|
||||
return new GuiCraftConfirm(player.inventory, terminal);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (guiId == Reference.GUI_MAGNET) {
|
||||
return new GuiMagnet(new ContainerMagnet(player, player.inventory));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void launchGui(final int ID, final EntityPlayer player, final World world, final int x, final int y, final int z) {
|
||||
player.openGui(WirelessCraftingTerminal.INSTANCE, ID, world, x, y, z);
|
||||
}
|
||||
public static void launchGui(
|
||||
final int ID, final EntityPlayer player, final World world, final int x, final int y, final int z) {
|
||||
player.openGui(WirelessCraftingTerminal.INSTANCE, ID, world, x, y, z);
|
||||
}
|
||||
}
|
||||
+53
-46
@@ -1,7 +1,5 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.common;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
@@ -14,6 +12,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import java.io.File;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
|
||||
@@ -26,56 +25,64 @@ import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
|
||||
import net.p455w0rd.wirelesscraftingterminal.proxy.CommonProxy;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
@Mod(modid = Reference.MODID, acceptedMinecraftVersions = "[1.7.10]", name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY, dependencies = "" + "required-after:Forge@[" + net.minecraftforge.common.ForgeVersion.majorVersion + '.' // majorVersion
|
||||
+ net.minecraftforge.common.ForgeVersion.minorVersion + '.' // minorVersion
|
||||
+ net.minecraftforge.common.ForgeVersion.revisionVersion + '.' // revisionVersion
|
||||
+ net.minecraftforge.common.ForgeVersion.buildVersion + ",);" + "required-after:appliedenergistics2@[rv3-beta-1,);after:NotEnoughItems;")
|
||||
|
||||
@Mod(
|
||||
modid = Reference.MODID,
|
||||
acceptedMinecraftVersions = "[1.7.10]",
|
||||
name = Reference.NAME,
|
||||
version = Reference.VERSION,
|
||||
guiFactory = Reference.GUI_FACTORY,
|
||||
dependencies = "" + "required-after:Forge@[" + net.minecraftforge.common.ForgeVersion.majorVersion
|
||||
+ '.' // majorVersion
|
||||
+ net.minecraftforge.common.ForgeVersion.minorVersion + '.' // minorVersion
|
||||
+ net.minecraftforge.common.ForgeVersion.revisionVersion + '.' // revisionVersion
|
||||
+ net.minecraftforge.common.ForgeVersion.buildVersion + ",);"
|
||||
+ "required-after:appliedenergistics2@[rv3-beta-1,);after:NotEnoughItems;")
|
||||
public class WirelessCraftingTerminal {
|
||||
|
||||
private static LoaderState WCTState = LoaderState.NOINIT;
|
||||
public static CreativeTabs creativeTab;
|
||||
private static LoaderState WCTState = LoaderState.NOINIT;
|
||||
public static CreativeTabs creativeTab;
|
||||
|
||||
@Instance(Reference.MODID)
|
||||
public static WirelessCraftingTerminal INSTANCE;
|
||||
@Instance(Reference.MODID)
|
||||
public static WirelessCraftingTerminal INSTANCE;
|
||||
|
||||
@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
|
||||
public static CommonProxy proxy;
|
||||
@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
|
||||
public static CommonProxy proxy;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
long stopwatch = WCTLog.beginSection("PreInit");
|
||||
WirelessCraftingTerminal.WCTState = LoaderState.PREINITIALIZATION;
|
||||
WirelessCraftingTerminal.INSTANCE = this;
|
||||
creativeTab = new CreativeTabWCT(CreativeTabs.getNextID(), Reference.MODID).setNoScrollbar();
|
||||
WirelessCraftingTerminal.proxy.registerItems();
|
||||
ConfigHandler.init(new File(event.getModConfigurationDirectory(), Reference.CONFIG_FILE));
|
||||
FMLCommonHandler.instance().bus().register(proxy);
|
||||
AEApi.instance().registries().wireless().registerWirelessHandler((IWirelessTermHandler) ItemEnum.WIRELESS_CRAFTING_TERMINAL.getItem());
|
||||
WCTLog.endSection("PreInit", stopwatch);
|
||||
}
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
long stopwatch = WCTLog.beginSection("PreInit");
|
||||
WirelessCraftingTerminal.WCTState = LoaderState.PREINITIALIZATION;
|
||||
WirelessCraftingTerminal.INSTANCE = this;
|
||||
creativeTab = new CreativeTabWCT(CreativeTabs.getNextID(), Reference.MODID).setNoScrollbar();
|
||||
WirelessCraftingTerminal.proxy.registerItems();
|
||||
ConfigHandler.init(new File(event.getModConfigurationDirectory(), Reference.CONFIG_FILE));
|
||||
FMLCommonHandler.instance().bus().register(proxy);
|
||||
AEApi.instance().registries().wireless().registerWirelessHandler((IWirelessTermHandler)
|
||||
ItemEnum.WIRELESS_CRAFTING_TERMINAL.getItem());
|
||||
WCTLog.endSection("PreInit", stopwatch);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
long stopwatch = WCTLog.beginSection("Init");
|
||||
IntegrationRegistry.INSTANCE.init();
|
||||
WirelessCraftingTerminal.WCTState = LoaderState.INITIALIZATION;
|
||||
RecipeHandler.loadRecipes(!Reference.WCT_MINETWEAKER_OVERRIDE);
|
||||
AchievementHandler.init();
|
||||
WCTLog.endSection("Init", stopwatch);
|
||||
}
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
long stopwatch = WCTLog.beginSection("Init");
|
||||
IntegrationRegistry.INSTANCE.init();
|
||||
WirelessCraftingTerminal.WCTState = LoaderState.INITIALIZATION;
|
||||
RecipeHandler.loadRecipes(!Reference.WCT_MINETWEAKER_OVERRIDE);
|
||||
AchievementHandler.init();
|
||||
WCTLog.endSection("Init", stopwatch);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit(final FMLPostInitializationEvent event) {
|
||||
long stopwatch = WCTLog.beginSection("PostInit");
|
||||
IntegrationRegistry.INSTANCE.postInit();
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(WirelessCraftingTerminal.INSTANCE, new WCTGuiHandler());
|
||||
NetworkHandler.instance = new NetworkHandler("WCT");
|
||||
WirelessCraftingTerminal.proxy.removeItemsFromNEI();
|
||||
WCTLog.endSection("PostInit", stopwatch);
|
||||
}
|
||||
@EventHandler
|
||||
public void postInit(final FMLPostInitializationEvent event) {
|
||||
long stopwatch = WCTLog.beginSection("PostInit");
|
||||
IntegrationRegistry.INSTANCE.postInit();
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(WirelessCraftingTerminal.INSTANCE, new WCTGuiHandler());
|
||||
NetworkHandler.instance = new NetworkHandler("WCT");
|
||||
WirelessCraftingTerminal.proxy.removeItemsFromNEI();
|
||||
WCTLog.endSection("PostInit", stopwatch);
|
||||
}
|
||||
|
||||
public static LoaderState getLoaderState() {
|
||||
return WirelessCraftingTerminal.WCTState;
|
||||
}
|
||||
public static LoaderState getLoaderState() {
|
||||
return WirelessCraftingTerminal.WCTState;
|
||||
}
|
||||
}
|
||||
+32
-43
@@ -1,13 +1,12 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.common.container;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.world.World;
|
||||
@@ -15,55 +14,45 @@ import net.p455w0rd.wirelesscraftingterminal.api.networking.security.WCTIActionH
|
||||
import net.p455w0rd.wirelesscraftingterminal.api.networking.security.WCTPlayerSource;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotInaccessible;
|
||||
|
||||
public class ContainerCraftAmount extends WCTBaseContainer {
|
||||
|
||||
public class ContainerCraftAmount extends WCTBaseContainer
|
||||
{
|
||||
private final Slot craftingItem;
|
||||
private IAEItemStack itemToCreate;
|
||||
|
||||
private final Slot craftingItem;
|
||||
private IAEItemStack itemToCreate;
|
||||
public ContainerCraftAmount(final InventoryPlayer ip, final ITerminalHost te) {
|
||||
super(ip, te);
|
||||
|
||||
public ContainerCraftAmount( final InventoryPlayer ip, final ITerminalHost te )
|
||||
{
|
||||
super( ip, te );
|
||||
this.craftingItem = new SlotInaccessible(new AppEngInternalInventory(null, 1), 0, 34, 53);
|
||||
this.addSlotToContainer(this.getCraftingItem());
|
||||
}
|
||||
|
||||
this.craftingItem = new SlotInaccessible( new AppEngInternalInventory( null, 1 ), 0, 34, 53 );
|
||||
this.addSlotToContainer( this.getCraftingItem() );
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
this.verifyPermissions(SecurityPermissions.CRAFT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
this.verifyPermissions( SecurityPermissions.CRAFT, false );
|
||||
}
|
||||
public IGrid getGrid() {
|
||||
return this.obj2.getTargetGrid();
|
||||
}
|
||||
|
||||
public IGrid getGrid()
|
||||
{
|
||||
return this.obj2.getTargetGrid();
|
||||
}
|
||||
public World getWorld() {
|
||||
return this.getPlayerInv().player.worldObj;
|
||||
}
|
||||
|
||||
public World getWorld()
|
||||
{
|
||||
return this.getPlayerInv().player.worldObj;
|
||||
}
|
||||
public BaseActionSource getActionSrc() {
|
||||
return new WCTPlayerSource(this.getPlayerInv().player, (WCTIActionHost) this.getTarget());
|
||||
}
|
||||
|
||||
public BaseActionSource getActionSrc()
|
||||
{
|
||||
return new WCTPlayerSource( this.getPlayerInv().player, (WCTIActionHost) this.getTarget() );
|
||||
}
|
||||
public Slot getCraftingItem() {
|
||||
return this.craftingItem;
|
||||
}
|
||||
|
||||
public Slot getCraftingItem()
|
||||
{
|
||||
return this.craftingItem;
|
||||
}
|
||||
public IAEItemStack getItemToCraft() {
|
||||
return this.itemToCreate;
|
||||
}
|
||||
|
||||
public IAEItemStack getItemToCraft()
|
||||
{
|
||||
return this.itemToCreate;
|
||||
}
|
||||
|
||||
public void setItemToCraft( @Nonnull final IAEItemStack itemToCreate )
|
||||
{
|
||||
this.itemToCreate = itemToCreate;
|
||||
}
|
||||
public void setItemToCraft(@Nonnull final IAEItemStack itemToCreate) {
|
||||
this.itemToCreate = itemToCreate;
|
||||
}
|
||||
}
|
||||
+317
-373
@@ -1,14 +1,5 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.common.container;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
@@ -24,6 +15,12 @@ import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.util.Platform;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.Future;
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
@@ -43,431 +40,378 @@ import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketUpdateCPUIn
|
||||
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
public class ContainerCraftConfirm extends WCTBaseContainer {
|
||||
|
||||
public class ContainerCraftConfirm extends WCTBaseContainer
|
||||
{
|
||||
public final ArrayList<CraftingCPURecord> cpus = new ArrayList<CraftingCPURecord>();
|
||||
private Future<ICraftingJob> job;
|
||||
private ICraftingJob result;
|
||||
|
||||
public final ArrayList<CraftingCPURecord> cpus = new ArrayList<CraftingCPURecord>();
|
||||
private Future<ICraftingJob> job;
|
||||
private ICraftingJob result;
|
||||
@GuiSync( 0 )
|
||||
public long bytesUsed;
|
||||
@GuiSync( 1 )
|
||||
public long cpuBytesAvail;
|
||||
@GuiSync( 2 )
|
||||
public int cpuCoProcessors;
|
||||
@GuiSync( 3 )
|
||||
public boolean autoStart = false;
|
||||
@GuiSync( 4 )
|
||||
public boolean simulation = true;
|
||||
@GuiSync( 5 )
|
||||
public int selectedCpu = -1;
|
||||
@GuiSync( 6 )
|
||||
public boolean noCPU = true;
|
||||
@GuiSync( 7 )
|
||||
public String myName = "";
|
||||
InventoryPlayer inventoryPlayer;
|
||||
@GuiSync(0)
|
||||
public long bytesUsed;
|
||||
|
||||
public ContainerCraftConfirm( final InventoryPlayer ip, final ITerminalHost te )
|
||||
{
|
||||
super( ip, te );
|
||||
inventoryPlayer = ip;
|
||||
}
|
||||
@GuiSync(1)
|
||||
public long cpuBytesAvail;
|
||||
|
||||
public void cycleCpu( final boolean next )
|
||||
{
|
||||
if( next )
|
||||
{
|
||||
this.setSelectedCpu( this.getSelectedCpu() + 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setSelectedCpu( this.getSelectedCpu() - 1 );
|
||||
}
|
||||
@GuiSync(2)
|
||||
public int cpuCoProcessors;
|
||||
|
||||
if( this.getSelectedCpu() < -1 )
|
||||
{
|
||||
this.setSelectedCpu( this.cpus.size() - 1 );
|
||||
}
|
||||
else if( this.getSelectedCpu() >= this.cpus.size() )
|
||||
{
|
||||
this.setSelectedCpu( -1 );
|
||||
}
|
||||
@GuiSync(3)
|
||||
public boolean autoStart = false;
|
||||
|
||||
if( this.getSelectedCpu() == -1 )
|
||||
{
|
||||
this.setCpuAvailableBytes( 0 );
|
||||
this.setCpuCoProcessors( 0 );
|
||||
this.setName( "" );
|
||||
try {
|
||||
NetworkHandler.instance.sendTo(new PacketUpdateCPUInfo(0, 0), (EntityPlayerMP) this.getPlayerInv().player);
|
||||
}
|
||||
catch (IOException e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.setName( this.cpus.get( this.getSelectedCpu() ).getName() );
|
||||
this.setCpuAvailableBytes( this.cpus.get( this.getSelectedCpu() ).getSize() );
|
||||
this.setCpuCoProcessors( this.cpus.get( this.getSelectedCpu() ).getProcessors() );
|
||||
|
||||
try {
|
||||
NetworkHandler.instance.sendTo(new PacketUpdateCPUInfo((int)this.getCpuAvailableBytes(), (int)this.getCpuCoProcessors()), (EntityPlayerMP) this.getPlayerInv().player);
|
||||
}
|
||||
catch (IOException e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
@GuiSync(4)
|
||||
public boolean simulation = true;
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@GuiSync(5)
|
||||
public int selectedCpu = -1;
|
||||
|
||||
final ICraftingGrid cc = this.getGrid().getCache( ICraftingGrid.class );
|
||||
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
|
||||
@GuiSync(6)
|
||||
public boolean noCPU = true;
|
||||
|
||||
int matches = 0;
|
||||
boolean changed = false;
|
||||
for( final ICraftingCPU c : cpuSet )
|
||||
{
|
||||
boolean found = false;
|
||||
for( final CraftingCPURecord ccr : this.cpus )
|
||||
{
|
||||
if( ccr.getCpu() == c )
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
@GuiSync(7)
|
||||
public String myName = "";
|
||||
|
||||
final boolean matched = this.cpuMatches( c );
|
||||
InventoryPlayer inventoryPlayer;
|
||||
|
||||
if( matched )
|
||||
{
|
||||
matches++;
|
||||
}
|
||||
public ContainerCraftConfirm(final InventoryPlayer ip, final ITerminalHost te) {
|
||||
super(ip, te);
|
||||
inventoryPlayer = ip;
|
||||
}
|
||||
|
||||
if( found == !matched )
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
public void cycleCpu(final boolean next) {
|
||||
if (next) {
|
||||
this.setSelectedCpu(this.getSelectedCpu() + 1);
|
||||
} else {
|
||||
this.setSelectedCpu(this.getSelectedCpu() - 1);
|
||||
}
|
||||
|
||||
if( changed || this.cpus.size() != matches )
|
||||
{
|
||||
this.cpus.clear();
|
||||
for( final ICraftingCPU c : cpuSet )
|
||||
{
|
||||
if( this.cpuMatches( c ) )
|
||||
{
|
||||
this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
|
||||
}
|
||||
}
|
||||
if (this.getSelectedCpu() < -1) {
|
||||
this.setSelectedCpu(this.cpus.size() - 1);
|
||||
} else if (this.getSelectedCpu() >= this.cpus.size()) {
|
||||
this.setSelectedCpu(-1);
|
||||
}
|
||||
|
||||
this.sendCPUs();
|
||||
}
|
||||
if (this.getSelectedCpu() == -1) {
|
||||
this.setCpuAvailableBytes(0);
|
||||
this.setCpuCoProcessors(0);
|
||||
this.setName("");
|
||||
try {
|
||||
NetworkHandler.instance.sendTo(
|
||||
new PacketUpdateCPUInfo(0, 0), (EntityPlayerMP) this.getPlayerInv().player);
|
||||
} catch (IOException e) {
|
||||
//
|
||||
}
|
||||
} else {
|
||||
this.setName(this.cpus.get(this.getSelectedCpu()).getName());
|
||||
this.setCpuAvailableBytes(this.cpus.get(this.getSelectedCpu()).getSize());
|
||||
this.setCpuCoProcessors(this.cpus.get(this.getSelectedCpu()).getProcessors());
|
||||
|
||||
this.setNoCPU( this.cpus.isEmpty() );
|
||||
try {
|
||||
NetworkHandler.instance.sendTo(
|
||||
new PacketUpdateCPUInfo((int) this.getCpuAvailableBytes(), (int) this.getCpuCoProcessors()),
|
||||
(EntityPlayerMP) this.getPlayerInv().player);
|
||||
} catch (IOException e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
if (Platform.isClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( this.getJob() != null && this.getJob().isDone() )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.result = this.getJob().get();
|
||||
final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class);
|
||||
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
|
||||
|
||||
if( !this.result.isSimulation() )
|
||||
{
|
||||
this.setSimulation( false );
|
||||
if( this.isAutoStart() )
|
||||
{
|
||||
this.startJob();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setSimulation( true );
|
||||
}
|
||||
int matches = 0;
|
||||
boolean changed = false;
|
||||
for (final ICraftingCPU c : cpuSet) {
|
||||
boolean found = false;
|
||||
for (final CraftingCPURecord ccr : this.cpus) {
|
||||
if (ccr.getCpu() == c) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final PacketMEInventoryUpdate a = new PacketMEInventoryUpdate( (byte) 0 );
|
||||
final PacketMEInventoryUpdate b = new PacketMEInventoryUpdate( (byte) 1 );
|
||||
final PacketMEInventoryUpdate c = this.result.isSimulation() ? new PacketMEInventoryUpdate( (byte) 2 ) : null;
|
||||
final boolean matched = this.cpuMatches(c);
|
||||
|
||||
final IItemList<IAEItemStack> plan = AEApi.instance().storage().createItemList();
|
||||
this.result.populatePlan( plan );
|
||||
|
||||
try {
|
||||
NetworkHandler.instance.sendTo(new PacketSetJobBytes((int)this.result.getByteTotal()), (EntityPlayerMP) this.getPlayerInv().player);
|
||||
}
|
||||
catch (IOException e) {
|
||||
//
|
||||
}
|
||||
if (matched) {
|
||||
matches++;
|
||||
}
|
||||
|
||||
this.setUsedBytes( this.result.getByteTotal() );
|
||||
if (found == !matched) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
for( final IAEItemStack out : plan )
|
||||
{
|
||||
if (changed || this.cpus.size() != matches) {
|
||||
this.cpus.clear();
|
||||
for (final ICraftingCPU c : cpuSet) {
|
||||
if (this.cpuMatches(c)) {
|
||||
this.cpus.add(new CraftingCPURecord(c.getAvailableStorage(), c.getCoProcessors(), c));
|
||||
}
|
||||
}
|
||||
|
||||
IAEItemStack o = out.copy();
|
||||
o.reset();
|
||||
o.setStackSize( out.getStackSize() );
|
||||
this.sendCPUs();
|
||||
}
|
||||
|
||||
final IAEItemStack p = out.copy();
|
||||
p.reset();
|
||||
p.setStackSize( out.getCountRequestable() );
|
||||
this.setNoCPU(this.cpus.isEmpty());
|
||||
|
||||
final IStorageGrid sg = this.getGrid().getCache( IStorageGrid.class );
|
||||
final IMEInventory<IAEItemStack> items = sg.getItemInventory();
|
||||
super.detectAndSendChanges();
|
||||
|
||||
IAEItemStack m = null;
|
||||
if( c != null && this.result.isSimulation() )
|
||||
{
|
||||
m = o.copy();
|
||||
o = items.extractItems( o, Actionable.SIMULATE, this.getActionSource() );
|
||||
if (this.getJob() != null && this.getJob().isDone()) {
|
||||
try {
|
||||
this.result = this.getJob().get();
|
||||
|
||||
if( o == null )
|
||||
{
|
||||
o = m.copy();
|
||||
o.setStackSize( 0 );
|
||||
}
|
||||
if (!this.result.isSimulation()) {
|
||||
this.setSimulation(false);
|
||||
if (this.isAutoStart()) {
|
||||
this.startJob();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
this.setSimulation(true);
|
||||
}
|
||||
|
||||
m.setStackSize( m.getStackSize() - o.getStackSize() );
|
||||
}
|
||||
try {
|
||||
final PacketMEInventoryUpdate a = new PacketMEInventoryUpdate((byte) 0);
|
||||
final PacketMEInventoryUpdate b = new PacketMEInventoryUpdate((byte) 1);
|
||||
final PacketMEInventoryUpdate c =
|
||||
this.result.isSimulation() ? new PacketMEInventoryUpdate((byte) 2) : null;
|
||||
|
||||
if( o.getStackSize() > 0 )
|
||||
{
|
||||
a.appendItem( o );
|
||||
}
|
||||
final IItemList<IAEItemStack> plan =
|
||||
AEApi.instance().storage().createItemList();
|
||||
this.result.populatePlan(plan);
|
||||
|
||||
if( p.getStackSize() > 0 )
|
||||
{
|
||||
b.appendItem( p );
|
||||
}
|
||||
try {
|
||||
NetworkHandler.instance.sendTo(
|
||||
new PacketSetJobBytes((int) this.result.getByteTotal()),
|
||||
(EntityPlayerMP) this.getPlayerInv().player);
|
||||
} catch (IOException e) {
|
||||
//
|
||||
}
|
||||
|
||||
if( c != null && m != null && m.getStackSize() > 0 )
|
||||
{
|
||||
c.appendItem( m );
|
||||
}
|
||||
}
|
||||
this.setUsedBytes(this.result.getByteTotal());
|
||||
|
||||
for( final Object g : this.crafters )
|
||||
{
|
||||
if( g instanceof EntityPlayer )
|
||||
{
|
||||
NetworkHandler.instance.sendTo( a, (EntityPlayerMP) g );
|
||||
NetworkHandler.instance.sendTo( b, (EntityPlayerMP) g );
|
||||
if( c != null )
|
||||
{
|
||||
NetworkHandler.instance.sendTo( c, (EntityPlayerMP) g );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
catch( final Throwable e )
|
||||
{
|
||||
this.getPlayerInv().player.addChatMessage( new ChatComponentText( "Error: " + e.toString() ) );
|
||||
WCTLog.debug( e.getMessage() );
|
||||
this.setValidContainer( false );
|
||||
this.result = null;
|
||||
}
|
||||
for (final IAEItemStack out : plan) {
|
||||
|
||||
this.setJob( null );
|
||||
}
|
||||
this.verifyPermissions( SecurityPermissions.CRAFT, false );
|
||||
}
|
||||
IAEItemStack o = out.copy();
|
||||
o.reset();
|
||||
o.setStackSize(out.getStackSize());
|
||||
|
||||
private IGrid getGrid()
|
||||
{
|
||||
return this.obj2.getTargetGrid();
|
||||
}
|
||||
final IAEItemStack p = out.copy();
|
||||
p.reset();
|
||||
p.setStackSize(out.getCountRequestable());
|
||||
|
||||
private boolean cpuMatches( final ICraftingCPU c )
|
||||
{
|
||||
return c.getAvailableStorage() >= this.getUsedBytes() && !c.isBusy();
|
||||
}
|
||||
final IStorageGrid sg = this.getGrid().getCache(IStorageGrid.class);
|
||||
final IMEInventory<IAEItemStack> items = sg.getItemInventory();
|
||||
|
||||
private void sendCPUs()
|
||||
{
|
||||
Collections.sort( this.cpus );
|
||||
IAEItemStack m = null;
|
||||
if (c != null && this.result.isSimulation()) {
|
||||
m = o.copy();
|
||||
o = items.extractItems(o, Actionable.SIMULATE, this.getActionSource());
|
||||
|
||||
if( this.getSelectedCpu() >= this.cpus.size() )
|
||||
{
|
||||
this.setSelectedCpu( -1 );
|
||||
this.setCpuAvailableBytes( 0 );
|
||||
this.setCpuCoProcessors( 0 );
|
||||
this.setName( "" );
|
||||
}
|
||||
else if( this.getSelectedCpu() != -1 )
|
||||
{
|
||||
this.setName( this.cpus.get( this.getSelectedCpu() ).getName() );
|
||||
this.setCpuAvailableBytes( this.cpus.get( this.getSelectedCpu() ).getSize() );
|
||||
this.setCpuCoProcessors( this.cpus.get( this.getSelectedCpu() ).getProcessors() );
|
||||
}
|
||||
}
|
||||
if (o == null) {
|
||||
o = m.copy();
|
||||
o.setStackSize(0);
|
||||
}
|
||||
|
||||
public void startJob()
|
||||
{
|
||||
int originalGui=0;
|
||||
m.setStackSize(m.getStackSize() - o.getStackSize());
|
||||
}
|
||||
|
||||
final WCTIActionHost ah = this.getActionHost();
|
||||
if( ah instanceof WirelessTerminalGuiObject )
|
||||
{
|
||||
originalGui = Reference.GUI_WCT;
|
||||
}
|
||||
if (o.getStackSize() > 0) {
|
||||
a.appendItem(o);
|
||||
}
|
||||
|
||||
if( this.result != null && !this.isSimulation() )
|
||||
{
|
||||
final ICraftingGrid cc = this.getGrid().getCache( ICraftingGrid.class );
|
||||
final ICraftingLink g = cc.submitJob( this.result, null, this.getSelectedCpu() == -1 ? null : this.cpus.get( this.getSelectedCpu() ).getCpu(), true, this.getActionSrc() );
|
||||
this.setAutoStart( false );
|
||||
if( g != null && originalGui > 0)// && this.getOpenContext() != null )
|
||||
{
|
||||
NetworkHandler.instance.sendTo( new PacketSwitchGuis( originalGui ), (EntityPlayerMP) this.getInventoryPlayer().player );
|
||||
if (p.getStackSize() > 0) {
|
||||
b.appendItem(p);
|
||||
}
|
||||
|
||||
//final TileEntity te = this.getOpenContext().getTile();
|
||||
//Platform.openGUI( this.getInventoryPlayer().player, te, this.getOpenContext().getSide(), originalGui );
|
||||
EntityPlayerMP player = (EntityPlayerMP) this.getInventoryPlayer().player;
|
||||
World world = player.worldObj;
|
||||
int x = (int)player.posX;
|
||||
int y = (int)player.posY;
|
||||
int z = (int)player.posZ;
|
||||
WCTGuiHandler.launchGui(originalGui, player, world, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (c != null && m != null && m.getStackSize() > 0) {
|
||||
c.appendItem(m);
|
||||
}
|
||||
}
|
||||
|
||||
private BaseActionSource getActionSrc()
|
||||
{
|
||||
return new WCTPlayerSource( this.getPlayerInv().player, (WCTIActionHost) this.getTarget() );
|
||||
}
|
||||
for (final Object g : this.crafters) {
|
||||
if (g instanceof EntityPlayer) {
|
||||
NetworkHandler.instance.sendTo(a, (EntityPlayerMP) g);
|
||||
NetworkHandler.instance.sendTo(b, (EntityPlayerMP) g);
|
||||
if (c != null) {
|
||||
NetworkHandler.instance.sendTo(c, (EntityPlayerMP) g);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
// :P
|
||||
}
|
||||
} catch (final Throwable e) {
|
||||
this.getPlayerInv().player.addChatMessage(new ChatComponentText("Error: " + e.toString()));
|
||||
WCTLog.debug(e.getMessage());
|
||||
this.setValidContainer(false);
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCraftingFromCrafters( final ICrafting c )
|
||||
{
|
||||
super.removeCraftingFromCrafters( c );
|
||||
if( this.getJob() != null )
|
||||
{
|
||||
this.getJob().cancel( true );
|
||||
this.setJob( null );
|
||||
}
|
||||
}
|
||||
this.setJob(null);
|
||||
}
|
||||
this.verifyPermissions(SecurityPermissions.CRAFT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed( final EntityPlayer par1EntityPlayer )
|
||||
{
|
||||
super.onContainerClosed( par1EntityPlayer );
|
||||
if( this.getJob() != null )
|
||||
{
|
||||
this.getJob().cancel( true );
|
||||
this.setJob( null );
|
||||
}
|
||||
}
|
||||
private IGrid getGrid() {
|
||||
return this.obj2.getTargetGrid();
|
||||
}
|
||||
|
||||
public World getWorld()
|
||||
{
|
||||
return this.getPlayerInv().player.worldObj;
|
||||
}
|
||||
private boolean cpuMatches(final ICraftingCPU c) {
|
||||
return c.getAvailableStorage() >= this.getUsedBytes() && !c.isBusy();
|
||||
}
|
||||
|
||||
public boolean isAutoStart()
|
||||
{
|
||||
return this.autoStart;
|
||||
}
|
||||
private void sendCPUs() {
|
||||
Collections.sort(this.cpus);
|
||||
|
||||
public void setAutoStart( final boolean autoStart )
|
||||
{
|
||||
this.autoStart = autoStart;
|
||||
}
|
||||
if (this.getSelectedCpu() >= this.cpus.size()) {
|
||||
this.setSelectedCpu(-1);
|
||||
this.setCpuAvailableBytes(0);
|
||||
this.setCpuCoProcessors(0);
|
||||
this.setName("");
|
||||
} else if (this.getSelectedCpu() != -1) {
|
||||
this.setName(this.cpus.get(this.getSelectedCpu()).getName());
|
||||
this.setCpuAvailableBytes(this.cpus.get(this.getSelectedCpu()).getSize());
|
||||
this.setCpuCoProcessors(this.cpus.get(this.getSelectedCpu()).getProcessors());
|
||||
}
|
||||
}
|
||||
|
||||
public long getUsedBytes()
|
||||
{
|
||||
return this.bytesUsed;
|
||||
}
|
||||
public void startJob() {
|
||||
int originalGui = 0;
|
||||
|
||||
private void setUsedBytes( final long bytesUsed )
|
||||
{
|
||||
this.bytesUsed = bytesUsed;
|
||||
}
|
||||
final WCTIActionHost ah = this.getActionHost();
|
||||
if (ah instanceof WirelessTerminalGuiObject) {
|
||||
originalGui = Reference.GUI_WCT;
|
||||
}
|
||||
|
||||
public long getCpuAvailableBytes()
|
||||
{
|
||||
return this.cpuBytesAvail;
|
||||
}
|
||||
if (this.result != null && !this.isSimulation()) {
|
||||
final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class);
|
||||
final ICraftingLink g = cc.submitJob(
|
||||
this.result,
|
||||
null,
|
||||
this.getSelectedCpu() == -1
|
||||
? null
|
||||
: this.cpus.get(this.getSelectedCpu()).getCpu(),
|
||||
true,
|
||||
this.getActionSrc());
|
||||
this.setAutoStart(false);
|
||||
if (g != null && originalGui > 0) // && this.getOpenContext() != null )
|
||||
{
|
||||
NetworkHandler.instance.sendTo(
|
||||
new PacketSwitchGuis(originalGui), (EntityPlayerMP) this.getInventoryPlayer().player);
|
||||
|
||||
private void setCpuAvailableBytes( final long cpuBytesAvail )
|
||||
{
|
||||
this.cpuBytesAvail = cpuBytesAvail;
|
||||
}
|
||||
// final TileEntity te = this.getOpenContext().getTile();
|
||||
// Platform.openGUI( this.getInventoryPlayer().player, te, this.getOpenContext().getSide(), originalGui
|
||||
// );
|
||||
EntityPlayerMP player = (EntityPlayerMP) this.getInventoryPlayer().player;
|
||||
World world = player.worldObj;
|
||||
int x = (int) player.posX;
|
||||
int y = (int) player.posY;
|
||||
int z = (int) player.posZ;
|
||||
WCTGuiHandler.launchGui(originalGui, player, world, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getCpuCoProcessors()
|
||||
{
|
||||
return this.cpuCoProcessors;
|
||||
}
|
||||
private BaseActionSource getActionSrc() {
|
||||
return new WCTPlayerSource(this.getPlayerInv().player, (WCTIActionHost) this.getTarget());
|
||||
}
|
||||
|
||||
private void setCpuCoProcessors( final int cpuCoProcessors )
|
||||
{
|
||||
this.cpuCoProcessors = cpuCoProcessors;
|
||||
}
|
||||
@Override
|
||||
public void removeCraftingFromCrafters(final ICrafting c) {
|
||||
super.removeCraftingFromCrafters(c);
|
||||
if (this.getJob() != null) {
|
||||
this.getJob().cancel(true);
|
||||
this.setJob(null);
|
||||
}
|
||||
}
|
||||
|
||||
public int getSelectedCpu()
|
||||
{
|
||||
return this.selectedCpu;
|
||||
}
|
||||
@Override
|
||||
public void onContainerClosed(final EntityPlayer par1EntityPlayer) {
|
||||
super.onContainerClosed(par1EntityPlayer);
|
||||
if (this.getJob() != null) {
|
||||
this.getJob().cancel(true);
|
||||
this.setJob(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void setSelectedCpu( final int selectedCpu )
|
||||
{
|
||||
this.selectedCpu = selectedCpu;
|
||||
}
|
||||
public World getWorld() {
|
||||
return this.getPlayerInv().player.worldObj;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.myName;
|
||||
}
|
||||
public boolean isAutoStart() {
|
||||
return this.autoStart;
|
||||
}
|
||||
|
||||
private void setName( @Nonnull final String myName )
|
||||
{
|
||||
this.myName = myName;
|
||||
}
|
||||
public void setAutoStart(final boolean autoStart) {
|
||||
this.autoStart = autoStart;
|
||||
}
|
||||
|
||||
public boolean hasNoCPU()
|
||||
{
|
||||
return this.noCPU;
|
||||
}
|
||||
public long getUsedBytes() {
|
||||
return this.bytesUsed;
|
||||
}
|
||||
|
||||
private void setNoCPU( final boolean noCPU )
|
||||
{
|
||||
this.noCPU = noCPU;
|
||||
}
|
||||
private void setUsedBytes(final long bytesUsed) {
|
||||
this.bytesUsed = bytesUsed;
|
||||
}
|
||||
|
||||
public boolean isSimulation()
|
||||
{
|
||||
return this.simulation;
|
||||
}
|
||||
public long getCpuAvailableBytes() {
|
||||
return this.cpuBytesAvail;
|
||||
}
|
||||
|
||||
private void setSimulation( final boolean simulation )
|
||||
{
|
||||
this.simulation = simulation;
|
||||
}
|
||||
private void setCpuAvailableBytes(final long cpuBytesAvail) {
|
||||
this.cpuBytesAvail = cpuBytesAvail;
|
||||
}
|
||||
|
||||
public Future<ICraftingJob> getJob()
|
||||
{
|
||||
return this.job;
|
||||
}
|
||||
public int getCpuCoProcessors() {
|
||||
return this.cpuCoProcessors;
|
||||
}
|
||||
|
||||
public void setJob( final Future<ICraftingJob> job )
|
||||
{
|
||||
this.job = job;
|
||||
}
|
||||
private void setCpuCoProcessors(final int cpuCoProcessors) {
|
||||
this.cpuCoProcessors = cpuCoProcessors;
|
||||
}
|
||||
|
||||
public int getSelectedCpu() {
|
||||
return this.selectedCpu;
|
||||
}
|
||||
|
||||
private void setSelectedCpu(final int selectedCpu) {
|
||||
this.selectedCpu = selectedCpu;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.myName;
|
||||
}
|
||||
|
||||
private void setName(@Nonnull final String myName) {
|
||||
this.myName = myName;
|
||||
}
|
||||
|
||||
public boolean hasNoCPU() {
|
||||
return this.noCPU;
|
||||
}
|
||||
|
||||
private void setNoCPU(final boolean noCPU) {
|
||||
this.noCPU = noCPU;
|
||||
}
|
||||
|
||||
public boolean isSimulation() {
|
||||
return this.simulation;
|
||||
}
|
||||
|
||||
private void setSimulation(final boolean simulation) {
|
||||
this.simulation = simulation;
|
||||
}
|
||||
|
||||
public Future<ICraftingJob> getJob() {
|
||||
return this.job;
|
||||
}
|
||||
|
||||
public void setJob(final Future<ICraftingJob> job) {
|
||||
this.job = job;
|
||||
}
|
||||
}
|
||||
-277
@@ -1,277 +0,0 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.common.container;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.crafting.CraftingItemList;
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.helpers.ICustomNameObject;
|
||||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.p455w0rd.wirelesscraftingterminal.api.IWirelessCraftingTermHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.guisync.GuiSync;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketValueConfig;
|
||||
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
|
||||
|
||||
|
||||
public class ContainerCraftingCPU extends WCTBaseContainer implements IMEMonitorHandlerReceiver<IAEItemStack>, ICustomNameObject
|
||||
{
|
||||
|
||||
private final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
|
||||
private CraftingCPUCluster monitor = null;
|
||||
private String cpuName = null;
|
||||
private final WirelessTerminalGuiObject obj;
|
||||
|
||||
@GuiSync( 0 )
|
||||
public long eta = -1;
|
||||
|
||||
public ContainerCraftingCPU( final InventoryPlayer ip, final Object te )
|
||||
{
|
||||
super( ip, te );
|
||||
this.obj = getGuiObject(RandomUtils.getWirelessTerm(ip), ip.player, ip.player.worldObj, (int) ip.player.posX, (int) ip.player.posY, (int) ip.player.posZ);
|
||||
if (this.obj == null) {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
/*
|
||||
final IGridHost host = (IGridHost) ( te instanceof IGridHost ? te : null );
|
||||
|
||||
if( host != null )
|
||||
{
|
||||
this.findNode( host, ForgeDirection.UNKNOWN );
|
||||
for( final ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
|
||||
{
|
||||
this.findNode( host, d );
|
||||
}
|
||||
}
|
||||
|
||||
if( te instanceof TileCraftingTile )
|
||||
{
|
||||
this.setCPU( (ICraftingCPU) ( (IAEMultiBlock) te ).getCluster() );
|
||||
}
|
||||
|
||||
if( this.getNetwork() == null && Platform.isServer() )
|
||||
{
|
||||
this.setValidContainer( false );
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
protected WirelessTerminalGuiObject getGuiObject(final ItemStack it, final EntityPlayer player, final World w, final int x, final int y, final int z) {
|
||||
if (it != null) {
|
||||
final IWirelessCraftingTermHandler wh = (IWirelessCraftingTermHandler) AEApi.instance().registries().wireless().getWirelessTerminalHandler(it);
|
||||
if (wh != null) {
|
||||
return new WirelessTerminalGuiObject(wh, it, player, w, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void setCPU( final ICraftingCPU c )
|
||||
{
|
||||
if( c == this.getMonitor() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( this.getMonitor() != null )
|
||||
{
|
||||
this.getMonitor().removeListener( this );
|
||||
}
|
||||
|
||||
for( final Object g : this.crafters )
|
||||
{
|
||||
if( g instanceof EntityPlayer )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendTo( new PacketValueConfig( "CraftingStatus", "Clear" ), (EntityPlayerMP) g );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
WCTLog.debug( e.getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( c instanceof CraftingCPUCluster )
|
||||
{
|
||||
this.cpuName = c.getName();
|
||||
this.setMonitor( (CraftingCPUCluster) c );
|
||||
this.list.resetStatus();
|
||||
this.getMonitor().getListOfItem( this.list, CraftingItemList.ALL );
|
||||
this.getMonitor().addListener( this, null );
|
||||
this.setEstimatedTime( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setMonitor( null );
|
||||
this.cpuName = "";
|
||||
this.setEstimatedTime( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelCrafting()
|
||||
{
|
||||
if( this.getMonitor() != null )
|
||||
{
|
||||
this.getMonitor().cancel();
|
||||
}
|
||||
this.setEstimatedTime( -1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCraftingFromCrafters( final ICrafting c )
|
||||
{
|
||||
super.removeCraftingFromCrafters( c );
|
||||
|
||||
if( this.crafters.isEmpty() && this.getMonitor() != null )
|
||||
{
|
||||
this.getMonitor().removeListener( this );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed( final EntityPlayer player )
|
||||
{
|
||||
super.onContainerClosed( player );
|
||||
if( this.getMonitor() != null )
|
||||
{
|
||||
this.getMonitor().removeListener( this );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if( Platform.isServer() && this.getMonitor() != null && !this.list.isEmpty() )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( this.getEstimatedTime() >= 0 )
|
||||
{
|
||||
final long elapsedTime = this.getMonitor().getElapsedTime();
|
||||
final double remainingItems = this.getMonitor().getRemainingItemCount();
|
||||
final double startItems = this.getMonitor().getStartItemCount();
|
||||
final long eta = (long) ( elapsedTime / Math.max( 1d, ( startItems - remainingItems ) ) * remainingItems );
|
||||
this.setEstimatedTime( eta );
|
||||
}
|
||||
|
||||
final PacketMEInventoryUpdate a = new PacketMEInventoryUpdate( (byte) 0 );
|
||||
final PacketMEInventoryUpdate b = new PacketMEInventoryUpdate( (byte) 1 );
|
||||
final PacketMEInventoryUpdate c = new PacketMEInventoryUpdate( (byte) 2 );
|
||||
|
||||
for( final IAEItemStack out : this.list )
|
||||
{
|
||||
a.appendItem( this.getMonitor().getItemStack( out, CraftingItemList.STORAGE ) );
|
||||
b.appendItem( this.getMonitor().getItemStack( out, CraftingItemList.ACTIVE ) );
|
||||
c.appendItem( this.getMonitor().getItemStack( out, CraftingItemList.PENDING ) );
|
||||
}
|
||||
|
||||
this.list.resetStatus();
|
||||
|
||||
for( final Object g : this.crafters )
|
||||
{
|
||||
if( g instanceof EntityPlayer )
|
||||
{
|
||||
if( !a.isEmpty() )
|
||||
{
|
||||
NetworkHandler.instance.sendTo( a, (EntityPlayerMP) g );
|
||||
}
|
||||
|
||||
if( !b.isEmpty() )
|
||||
{
|
||||
NetworkHandler.instance.sendTo( b, (EntityPlayerMP) g );
|
||||
}
|
||||
|
||||
if( !c.isEmpty() )
|
||||
{
|
||||
NetworkHandler.instance.sendTo( c, (EntityPlayerMP) g );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid( final Object verificationToken )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final BaseActionSource actionSource )
|
||||
{
|
||||
for( IAEItemStack is : change )
|
||||
{
|
||||
is = is.copy();
|
||||
is.setStackSize( 1 );
|
||||
this.list.add( is );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListUpdate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomName()
|
||||
{
|
||||
return this.cpuName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return this.cpuName != null && this.cpuName.length() > 0;
|
||||
}
|
||||
|
||||
public long getEstimatedTime()
|
||||
{
|
||||
return this.eta;
|
||||
}
|
||||
|
||||
private void setEstimatedTime( final long eta )
|
||||
{
|
||||
this.eta = eta;
|
||||
}
|
||||
|
||||
CraftingCPUCluster getMonitor()
|
||||
{
|
||||
return this.monitor;
|
||||
}
|
||||
|
||||
private void setMonitor( final CraftingCPUCluster monitor )
|
||||
{
|
||||
this.monitor = monitor;
|
||||
}
|
||||
|
||||
IGrid getNetwork()
|
||||
{
|
||||
return this.obj.getTargetGrid();
|
||||
}
|
||||
}
|
||||
-156
@@ -1,156 +0,0 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.common.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.guisync.GuiSync;
|
||||
|
||||
|
||||
public class ContainerCraftingStatus extends ContainerCraftingCPU
|
||||
{
|
||||
|
||||
private final List<CraftingCPURecord> cpus = new ArrayList<CraftingCPURecord>();
|
||||
@GuiSync( 5 )
|
||||
public int selectedCpu = -1;
|
||||
@GuiSync( 6 )
|
||||
public boolean noCPU = true;
|
||||
@GuiSync( 7 )
|
||||
public String myName = "";
|
||||
|
||||
public ContainerCraftingStatus( final InventoryPlayer ip, final ITerminalHost te )
|
||||
{
|
||||
super( ip, te );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
final ICraftingGrid cc = this.getNetwork().getCache( ICraftingGrid.class );
|
||||
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
|
||||
|
||||
int matches = 0;
|
||||
boolean changed = false;
|
||||
for( final ICraftingCPU c : cpuSet )
|
||||
{
|
||||
boolean found = false;
|
||||
for( final CraftingCPURecord ccr : this.cpus )
|
||||
{
|
||||
if( ccr.getCpu() == c )
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
final boolean matched = this.cpuMatches( c );
|
||||
|
||||
if( matched )
|
||||
{
|
||||
matches++;
|
||||
}
|
||||
|
||||
if( found == !matched )
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( changed || this.cpus.size() != matches )
|
||||
{
|
||||
this.cpus.clear();
|
||||
for( final ICraftingCPU c : cpuSet )
|
||||
{
|
||||
if( this.cpuMatches( c ) )
|
||||
{
|
||||
this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
|
||||
}
|
||||
}
|
||||
|
||||
this.sendCPUs();
|
||||
}
|
||||
|
||||
this.noCPU = this.cpus.isEmpty();
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
private boolean cpuMatches( final ICraftingCPU c )
|
||||
{
|
||||
return c.isBusy();
|
||||
}
|
||||
|
||||
private void sendCPUs()
|
||||
{
|
||||
Collections.sort( this.cpus );
|
||||
|
||||
if( this.selectedCpu >= this.cpus.size() )
|
||||
{
|
||||
this.selectedCpu = -1;
|
||||
this.myName = "";
|
||||
}
|
||||
else if( this.selectedCpu != -1 )
|
||||
{
|
||||
this.myName = this.cpus.get( this.selectedCpu ).getName();
|
||||
}
|
||||
|
||||
if( this.selectedCpu == -1 && this.cpus.size() > 0 )
|
||||
{
|
||||
this.selectedCpu = 0;
|
||||
}
|
||||
|
||||
if( this.selectedCpu != -1 )
|
||||
{
|
||||
if( this.cpus.get( this.selectedCpu ).getCpu() != this.getMonitor() )
|
||||
{
|
||||
this.setCPU( this.cpus.get( this.selectedCpu ).getCpu() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setCPU( null );
|
||||
}
|
||||
}
|
||||
|
||||
public void cycleCpu( final boolean next )
|
||||
{
|
||||
if( next )
|
||||
{
|
||||
this.selectedCpu++;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.selectedCpu--;
|
||||
}
|
||||
|
||||
if( this.selectedCpu < -1 )
|
||||
{
|
||||
this.selectedCpu = this.cpus.size() - 1;
|
||||
}
|
||||
else if( this.selectedCpu >= this.cpus.size() )
|
||||
{
|
||||
this.selectedCpu = -1;
|
||||
}
|
||||
|
||||
if( this.selectedCpu == -1 && this.cpus.size() > 0 )
|
||||
{
|
||||
this.selectedCpu = 0;
|
||||
}
|
||||
|
||||
if( this.selectedCpu == -1 )
|
||||
{
|
||||
this.myName = "";
|
||||
this.setCPU( null );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.myName = this.cpus.get( this.selectedCpu ).getName();
|
||||
this.setCPU( this.cpus.get( this.selectedCpu ).getCpu() );
|
||||
}
|
||||
}
|
||||
}
|
||||
+479
-479
@@ -3,7 +3,6 @@ package net.p455w0rd.wirelesscraftingterminal.common.container;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
@@ -17,482 +16,483 @@ import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
|
||||
|
||||
public class ContainerMagnet extends Container {
|
||||
|
||||
public final InventoryPlayer inventoryPlayer;
|
||||
public ItemStack magnetItem;
|
||||
public WCTInventoryMagnetFilter magnetInventory;
|
||||
private int distributeState = 0;
|
||||
private int pressedKeyInRange = -1;
|
||||
@SuppressWarnings("rawtypes")
|
||||
private final Set distributeSlotSet = new HashSet();
|
||||
private final int PLAYER_INV_START = 0, PLAYER_INV_END = 26, HOTBAR_START = 27, HOTBAR_END = 35, FILTERS_START = 36,
|
||||
FILTERS_END = 62;
|
||||
|
||||
public ContainerMagnet(EntityPlayer player, InventoryPlayer inventoryPlayer) {
|
||||
this.inventoryPlayer = inventoryPlayer;
|
||||
this.magnetItem = RandomUtils.getMagnet(inventoryPlayer);
|
||||
this.magnetInventory = new WCTInventoryMagnetFilter(magnetItem);
|
||||
this.magnetInventory.setContainer(this);
|
||||
// Add player inventory slots
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(this.inventoryPlayer, j + i * 9 + 9, j * 18 + 8, 126 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
// Add hotbar slots
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new Slot(this.inventoryPlayer, i, i * 18 + 8, 184));
|
||||
}
|
||||
|
||||
// Add filter slots
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 9; j++) {
|
||||
this.addSlotToContainer(new SlotMagnetFilter(this.magnetInventory, j + i * 9, j * 18 + 8, 58 + i * 18));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInHotbar(int slotNum) {
|
||||
return (slotNum >= HOTBAR_START) && (slotNum <= HOTBAR_END);
|
||||
}
|
||||
|
||||
private boolean isInPlayerInventory(int slotNum) {
|
||||
return (slotNum >= PLAYER_INV_START) && (slotNum <= PLAYER_INV_END);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private boolean isInFilters(int slotNum) {
|
||||
return (slotNum >= FILTERS_START) && (slotNum <= FILTERS_END);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer p) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean alreadyFiltered(ItemStack item) {
|
||||
for (int i = 0; i < magnetInventory.getSizeInventory(); i++) {
|
||||
if (isIdenticalItem(item, magnetInventory.getStackInSlot(i))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public ItemStack slotClick(int slotNum, int mouseButton, int modifier, EntityPlayer player) {
|
||||
if (slotNum >= this.inventorySlots.size()) {
|
||||
return null;
|
||||
}
|
||||
InventoryPlayer inventoryplayer = player.inventory;
|
||||
ItemStack itemstack3;
|
||||
ItemStack stack = null;
|
||||
int sizeOrID;
|
||||
if (slotNum == -999) {
|
||||
|
||||
if (inventoryplayer.getItemStack() != null && slotNum == -999) {
|
||||
if (mouseButton == 0) {
|
||||
player.dropPlayerItemWithRandomChoice(inventoryplayer.getItemStack(), true);
|
||||
inventoryplayer.setItemStack((ItemStack) null);
|
||||
}
|
||||
|
||||
if (mouseButton == 1) {
|
||||
player.dropPlayerItemWithRandomChoice(inventoryplayer.getItemStack().splitStack(1), true);
|
||||
|
||||
if (inventoryplayer.getItemStack().stackSize == 0) {
|
||||
inventoryplayer.setItemStack((ItemStack) null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Click+drag stack
|
||||
else if (modifier == 5) {
|
||||
//if (isInFilters(slotNum)) {
|
||||
// return null;
|
||||
//}
|
||||
int currentDistributeState = this.distributeState;
|
||||
this.distributeState = checkForPressedButton(mouseButton);
|
||||
|
||||
if ((currentDistributeState != 1 || this.distributeState != 2) && currentDistributeState != this.distributeState) {
|
||||
this.resetDistributionVariables();
|
||||
}
|
||||
else if (inventoryplayer.getItemStack() == null) {
|
||||
this.resetDistributionVariables();
|
||||
}
|
||||
else if (this.distributeState == 0) {
|
||||
this.pressedKeyInRange = checkForPressedButton2(mouseButton);
|
||||
|
||||
if (checkValue(this.pressedKeyInRange)) {
|
||||
this.distributeState = 1;
|
||||
this.distributeSlotSet.clear();
|
||||
}
|
||||
else {
|
||||
this.resetDistributionVariables();
|
||||
}
|
||||
}
|
||||
else if (this.distributeState == 1) {
|
||||
Slot slot = (Slot) this.inventorySlots.get(slotNum);
|
||||
|
||||
if (slot != null && stackFitsInSlot(slot, inventoryplayer.getItemStack(), true) && slot.isItemValid(inventoryplayer.getItemStack()) && inventoryplayer.getItemStack().stackSize > this.distributeSlotSet.size() && this.canDragIntoSlot(slot)) {
|
||||
this.distributeSlotSet.add(slot);
|
||||
}
|
||||
}
|
||||
else if (this.distributeState == 2) {
|
||||
if (!this.distributeSlotSet.isEmpty()) {
|
||||
itemstack3 = inventoryplayer.getItemStack().copy();
|
||||
sizeOrID = inventoryplayer.getItemStack().stackSize;
|
||||
Iterator iterator = this.distributeSlotSet.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Slot slot1 = (Slot) iterator.next();
|
||||
|
||||
if (slot1 != null && stackFitsInSlot(slot1, inventoryplayer.getItemStack(), true) && slot1.isItemValid(inventoryplayer.getItemStack()) && inventoryplayer.getItemStack().stackSize >= this.distributeSlotSet.size() && this.canDragIntoSlot(slot1)) {
|
||||
ItemStack itemstack1 = itemstack3.copy();
|
||||
int j1 = slot1.getHasStack() ? slot1.getStack().stackSize : 0;
|
||||
setSlotStack(this.distributeSlotSet, this.pressedKeyInRange, itemstack1, j1);
|
||||
|
||||
if (itemstack1.stackSize > itemstack1.getMaxStackSize()) {
|
||||
itemstack1.stackSize = itemstack1.getMaxStackSize();
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize > slot1.getSlotStackLimit()) {
|
||||
itemstack1.stackSize = slot1.getSlotStackLimit();
|
||||
}
|
||||
|
||||
sizeOrID -= itemstack1.stackSize - j1;
|
||||
slot1.putStack(itemstack1);
|
||||
}
|
||||
}
|
||||
|
||||
itemstack3.stackSize = sizeOrID;
|
||||
|
||||
if (itemstack3.stackSize <= 0) {
|
||||
itemstack3 = null;
|
||||
}
|
||||
|
||||
inventoryplayer.setItemStack(itemstack3);
|
||||
}
|
||||
|
||||
this.resetDistributionVariables();
|
||||
}
|
||||
else {
|
||||
this.resetDistributionVariables();
|
||||
}
|
||||
}
|
||||
|
||||
else if (this.distributeState != 0) {
|
||||
this.resetDistributionVariables();
|
||||
}
|
||||
|
||||
else if (getSlot(slotNum) != null && getSlot(slotNum) instanceof SlotMagnetFilter) {
|
||||
|
||||
SlotMagnetFilter slot = (SlotMagnetFilter) getSlot(slotNum);
|
||||
|
||||
ItemStack stackSlot = slot.getStack();
|
||||
if (alreadyFiltered(player.inventory.getItemStack()) && player.inventory.getItemStack() != null) {
|
||||
return null;
|
||||
}
|
||||
if (stackSlot != null) {
|
||||
stack = stackSlot.copy();
|
||||
}
|
||||
|
||||
if (mouseButton == 2) {
|
||||
fillPhantomSlot(slot, null, mouseButton);
|
||||
}
|
||||
else if (mouseButton == 0 || mouseButton == 1) {
|
||||
InventoryPlayer playerInv = player.inventory;
|
||||
|
||||
ItemStack stackHeld = playerInv.getItemStack();
|
||||
|
||||
if (stackSlot == null) {
|
||||
if (stackHeld != null && slot.isItemValid(stackHeld)) {
|
||||
fillPhantomSlot(slot, stackHeld, mouseButton);
|
||||
}
|
||||
}
|
||||
else if (stackHeld == null) {
|
||||
adjustPhantomSlot(slot, mouseButton, modifier);
|
||||
}
|
||||
else if (slot.isItemValid(stackHeld)) {
|
||||
if (isIdenticalItem(stackSlot, stackHeld)) {
|
||||
adjustPhantomSlot(slot, mouseButton, modifier);
|
||||
}
|
||||
else {
|
||||
fillPhantomSlot(slot, stackHeld, mouseButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
else {
|
||||
return super.slotClick(slotNum, mouseButton, modifier, player);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public boolean alwaysTrue(Slot slot) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static void setSlotStack(Set slotSet, int stackSizeSelector, ItemStack stackToResize, int currentSlotStackSize) {
|
||||
switch (stackSizeSelector) {
|
||||
case 0:
|
||||
stackToResize.stackSize = MathHelper.floor_float((float) stackToResize.stackSize / (float) slotSet.size());
|
||||
break;
|
||||
case 1:
|
||||
stackToResize.stackSize = 1;
|
||||
}
|
||||
|
||||
stackToResize.stackSize += currentSlotStackSize;
|
||||
}
|
||||
|
||||
public static boolean stackFitsInSlot(Slot slot, ItemStack itemStack, boolean sizeMatters) {
|
||||
boolean flag1 = slot == null || !slot.getHasStack();
|
||||
|
||||
if (slot != null && slot.getHasStack() && itemStack != null && itemStack.isItemEqual(slot.getStack()) && ItemStack.areItemStackTagsEqual(slot.getStack(), itemStack)) {
|
||||
int i = sizeMatters ? 0 : itemStack.stackSize;
|
||||
flag1 |= slot.getStack().stackSize + i <= itemStack.getMaxStackSize();
|
||||
}
|
||||
|
||||
return flag1;
|
||||
}
|
||||
|
||||
public static int checkForPressedButton(int btn) {
|
||||
return btn & 3;
|
||||
}
|
||||
|
||||
public static int checkForPressedButton2(int mouseButtonPressed) {
|
||||
return mouseButtonPressed >> 2 & 3;
|
||||
}
|
||||
|
||||
public static boolean checkValue(int value) {
|
||||
return value == 0 || value == 1;
|
||||
}
|
||||
|
||||
protected void resetDistributionVariables() {
|
||||
this.distributeState = 0;
|
||||
this.distributeSlotSet.clear();
|
||||
}
|
||||
|
||||
private void arrangeSlots() {
|
||||
int invSize = magnetInventory.getSizeInventory();
|
||||
if (invSize <= 0) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < invSize; i++) {
|
||||
if (magnetInventory.getStackInSlot(i) == null) {
|
||||
for (int j = 0; j < invSize; j++) {
|
||||
if (j <= i) {
|
||||
continue;
|
||||
}
|
||||
if (magnetInventory.getStackInSlot(j) != null) {
|
||||
magnetInventory.setInventorySlotContents(i, magnetInventory.getStackInSlot(j));
|
||||
magnetInventory.decrStackSize(j, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fillPhantomSlot(SlotMagnetFilter slot, ItemStack stackHeld, int mouseButton) {
|
||||
if (!slot.canAdjustPhantom()) {
|
||||
return;
|
||||
}
|
||||
if (stackHeld == null) {
|
||||
slot.putStack(null);
|
||||
return;
|
||||
}
|
||||
|
||||
int stackSize = mouseButton == 0 ? stackHeld.stackSize : 1;
|
||||
if (stackSize > slot.getSlotStackLimit()) {
|
||||
stackSize = slot.getSlotStackLimit();
|
||||
}
|
||||
ItemStack phantomStack = stackHeld.copy();
|
||||
RandomUtils.removeTimerTags(phantomStack);
|
||||
phantomStack.stackSize = stackSize;
|
||||
|
||||
slot.putStack(phantomStack);
|
||||
arrangeSlots();
|
||||
}
|
||||
|
||||
private void adjustPhantomSlot(SlotMagnetFilter slot, int mouseButton, int modifier) {
|
||||
if (!slot.canAdjustPhantom()) {
|
||||
return;
|
||||
}
|
||||
ItemStack stackSlot = slot.getStack();
|
||||
int stackSize;
|
||||
if (modifier == 1) {
|
||||
stackSize = mouseButton == 0 ? (stackSlot.stackSize + 1) / 2 : stackSlot.stackSize * 2;
|
||||
}
|
||||
else {
|
||||
stackSize = mouseButton == 0 ? stackSlot.stackSize - 1 : stackSlot.stackSize + 1;
|
||||
}
|
||||
|
||||
if (stackSize > slot.getSlotStackLimit()) {
|
||||
stackSize = slot.getSlotStackLimit();
|
||||
}
|
||||
|
||||
stackSlot.stackSize = stackSize;
|
||||
|
||||
if (stackSlot.stackSize <= 0) {
|
||||
stackSlot = null;
|
||||
}
|
||||
|
||||
slot.putStack(stackSlot);
|
||||
arrangeSlots();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(final EntityPlayer p, final int slotIndex) {
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
if (slot == null || slot.getStack() == null) {
|
||||
return null;
|
||||
}
|
||||
ItemStack stack = slot.getStack();
|
||||
if (isInHotbar(slotIndex)) {
|
||||
if (!mergePhantomStack(stack)) {
|
||||
if (!mergeItemStack(stack, PLAYER_INV_START, PLAYER_INV_END + 1, false)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (isInPlayerInventory(slotIndex)) {
|
||||
if (!mergePhantomStack(stack)) {
|
||||
if (!mergeItemStack(stack, HOTBAR_START, HOTBAR_END + 1, false)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
if (stack.stackSize == 0) {
|
||||
slot.putStack((ItemStack) null);
|
||||
}
|
||||
else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
slot.onPickupFromSlot(p, stack);
|
||||
return stack;
|
||||
}
|
||||
|
||||
protected boolean mergePhantomStack(ItemStack stack) {
|
||||
if (!alreadyFiltered(stack)) {
|
||||
for (int i = FILTERS_START; i <= FILTERS_END; i++) {
|
||||
if (this.getSlot(i).getStack() != null) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
fillPhantomSlot((SlotMagnetFilter) this.getSlot(i), stack, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isIdenticalItem(ItemStack lhs, ItemStack rhs) {
|
||||
if (lhs == rhs) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (lhs == null || rhs == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lhs.getItem() != rhs.getItem()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lhs.getItemDamage() != OreDictionary.WILDCARD_VALUE) {
|
||||
if (lhs.getItemDamage() != rhs.getItemDamage()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return ItemStack.areItemStackTagsEqual(lhs, rhs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean mergeItemStack(ItemStack stack, int start, int end, boolean backwards) {
|
||||
boolean flag1 = false;
|
||||
int k = (backwards ? end - 1 : start);
|
||||
Slot slot;
|
||||
ItemStack itemstack1;
|
||||
|
||||
if (stack.isStackable()) {
|
||||
while (stack.stackSize > 0 && (!backwards && k < end || backwards && k >= start)) {
|
||||
slot = (Slot) inventorySlots.get(k);
|
||||
itemstack1 = slot.getStack();
|
||||
|
||||
if (!slot.isItemValid(stack)) {
|
||||
k += (backwards ? -1 : 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itemstack1 != null && itemstack1.getItem() == stack.getItem() && (!stack.getHasSubtypes() || stack.getItemDamage() == itemstack1.getItemDamage()) && ItemStack.areItemStackTagsEqual(stack, itemstack1)) {
|
||||
int l = itemstack1.stackSize + stack.stackSize;
|
||||
|
||||
if (l <= stack.getMaxStackSize() && l <= slot.getSlotStackLimit()) {
|
||||
stack.stackSize = 0;
|
||||
itemstack1.stackSize = l;
|
||||
magnetInventory.markDirty();
|
||||
flag1 = true;
|
||||
}
|
||||
else if (itemstack1.stackSize < stack.getMaxStackSize() && l < slot.getSlotStackLimit()) {
|
||||
stack.stackSize -= stack.getMaxStackSize() - itemstack1.stackSize;
|
||||
itemstack1.stackSize = stack.getMaxStackSize();
|
||||
magnetInventory.markDirty();
|
||||
flag1 = true;
|
||||
}
|
||||
}
|
||||
|
||||
k += (backwards ? -1 : 1);
|
||||
}
|
||||
}
|
||||
if (stack.stackSize > 0) {
|
||||
k = (backwards ? end - 1 : start);
|
||||
while (!backwards && k < end || backwards && k >= start) {
|
||||
slot = (Slot) inventorySlots.get(k);
|
||||
itemstack1 = slot.getStack();
|
||||
|
||||
if (!slot.isItemValid(stack)) {
|
||||
k += (backwards ? -1 : 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itemstack1 == null) {
|
||||
int l = stack.stackSize;
|
||||
if (l <= slot.getSlotStackLimit()) {
|
||||
slot.putStack(stack.copy());
|
||||
stack.stackSize = 0;
|
||||
magnetInventory.markDirty();
|
||||
flag1 = true;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
putStackInSlot(k, new ItemStack(stack.getItem(), slot.getSlotStackLimit(), stack.getItemDamage()));
|
||||
stack.stackSize -= slot.getSlotStackLimit();
|
||||
magnetInventory.markDirty();
|
||||
flag1 = true;
|
||||
}
|
||||
}
|
||||
|
||||
k += (backwards ? -1 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
return flag1;
|
||||
}
|
||||
|
||||
public final InventoryPlayer inventoryPlayer;
|
||||
public ItemStack magnetItem;
|
||||
public WCTInventoryMagnetFilter magnetInventory;
|
||||
private int distributeState = 0;
|
||||
private int pressedKeyInRange = -1;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private final Set distributeSlotSet = new HashSet();
|
||||
|
||||
private final int PLAYER_INV_START = 0,
|
||||
PLAYER_INV_END = 26,
|
||||
HOTBAR_START = 27,
|
||||
HOTBAR_END = 35,
|
||||
FILTERS_START = 36,
|
||||
FILTERS_END = 62;
|
||||
|
||||
public ContainerMagnet(EntityPlayer player, InventoryPlayer inventoryPlayer) {
|
||||
this.inventoryPlayer = inventoryPlayer;
|
||||
this.magnetItem = RandomUtils.getMagnet(inventoryPlayer);
|
||||
this.magnetInventory = new WCTInventoryMagnetFilter(magnetItem);
|
||||
this.magnetInventory.setContainer(this);
|
||||
// Add player inventory slots
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(this.inventoryPlayer, j + i * 9 + 9, j * 18 + 8, 126 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
// Add hotbar slots
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new Slot(this.inventoryPlayer, i, i * 18 + 8, 184));
|
||||
}
|
||||
|
||||
// Add filter slots
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 9; j++) {
|
||||
this.addSlotToContainer(new SlotMagnetFilter(this.magnetInventory, j + i * 9, j * 18 + 8, 58 + i * 18));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInHotbar(int slotNum) {
|
||||
return (slotNum >= HOTBAR_START) && (slotNum <= HOTBAR_END);
|
||||
}
|
||||
|
||||
private boolean isInPlayerInventory(int slotNum) {
|
||||
return (slotNum >= PLAYER_INV_START) && (slotNum <= PLAYER_INV_END);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private boolean isInFilters(int slotNum) {
|
||||
return (slotNum >= FILTERS_START) && (slotNum <= FILTERS_END);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer p) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean alreadyFiltered(ItemStack item) {
|
||||
for (int i = 0; i < magnetInventory.getSizeInventory(); i++) {
|
||||
if (isIdenticalItem(item, magnetInventory.getStackInSlot(i))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@Override
|
||||
public ItemStack slotClick(int slotNum, int mouseButton, int modifier, EntityPlayer player) {
|
||||
if (slotNum >= this.inventorySlots.size()) {
|
||||
return null;
|
||||
}
|
||||
InventoryPlayer inventoryplayer = player.inventory;
|
||||
ItemStack itemstack3;
|
||||
ItemStack stack = null;
|
||||
int sizeOrID;
|
||||
if (slotNum == -999) {
|
||||
|
||||
if (inventoryplayer.getItemStack() != null && slotNum == -999) {
|
||||
if (mouseButton == 0) {
|
||||
player.dropPlayerItemWithRandomChoice(inventoryplayer.getItemStack(), true);
|
||||
inventoryplayer.setItemStack((ItemStack) null);
|
||||
}
|
||||
|
||||
if (mouseButton == 1) {
|
||||
player.dropPlayerItemWithRandomChoice(
|
||||
inventoryplayer.getItemStack().splitStack(1), true);
|
||||
|
||||
if (inventoryplayer.getItemStack().stackSize == 0) {
|
||||
inventoryplayer.setItemStack((ItemStack) null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Click+drag stack
|
||||
else if (modifier == 5) {
|
||||
// if (isInFilters(slotNum)) {
|
||||
// return null;
|
||||
// }
|
||||
int currentDistributeState = this.distributeState;
|
||||
this.distributeState = checkForPressedButton(mouseButton);
|
||||
|
||||
if ((currentDistributeState != 1 || this.distributeState != 2)
|
||||
&& currentDistributeState != this.distributeState) {
|
||||
this.resetDistributionVariables();
|
||||
} else if (inventoryplayer.getItemStack() == null) {
|
||||
this.resetDistributionVariables();
|
||||
} else if (this.distributeState == 0) {
|
||||
this.pressedKeyInRange = checkForPressedButton2(mouseButton);
|
||||
|
||||
if (checkValue(this.pressedKeyInRange)) {
|
||||
this.distributeState = 1;
|
||||
this.distributeSlotSet.clear();
|
||||
} else {
|
||||
this.resetDistributionVariables();
|
||||
}
|
||||
} else if (this.distributeState == 1) {
|
||||
Slot slot = (Slot) this.inventorySlots.get(slotNum);
|
||||
|
||||
if (slot != null
|
||||
&& stackFitsInSlot(slot, inventoryplayer.getItemStack(), true)
|
||||
&& slot.isItemValid(inventoryplayer.getItemStack())
|
||||
&& inventoryplayer.getItemStack().stackSize > this.distributeSlotSet.size()
|
||||
&& this.canDragIntoSlot(slot)) {
|
||||
this.distributeSlotSet.add(slot);
|
||||
}
|
||||
} else if (this.distributeState == 2) {
|
||||
if (!this.distributeSlotSet.isEmpty()) {
|
||||
itemstack3 = inventoryplayer.getItemStack().copy();
|
||||
sizeOrID = inventoryplayer.getItemStack().stackSize;
|
||||
Iterator iterator = this.distributeSlotSet.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Slot slot1 = (Slot) iterator.next();
|
||||
|
||||
if (slot1 != null
|
||||
&& stackFitsInSlot(slot1, inventoryplayer.getItemStack(), true)
|
||||
&& slot1.isItemValid(inventoryplayer.getItemStack())
|
||||
&& inventoryplayer.getItemStack().stackSize >= this.distributeSlotSet.size()
|
||||
&& this.canDragIntoSlot(slot1)) {
|
||||
ItemStack itemstack1 = itemstack3.copy();
|
||||
int j1 = slot1.getHasStack() ? slot1.getStack().stackSize : 0;
|
||||
setSlotStack(this.distributeSlotSet, this.pressedKeyInRange, itemstack1, j1);
|
||||
|
||||
if (itemstack1.stackSize > itemstack1.getMaxStackSize()) {
|
||||
itemstack1.stackSize = itemstack1.getMaxStackSize();
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize > slot1.getSlotStackLimit()) {
|
||||
itemstack1.stackSize = slot1.getSlotStackLimit();
|
||||
}
|
||||
|
||||
sizeOrID -= itemstack1.stackSize - j1;
|
||||
slot1.putStack(itemstack1);
|
||||
}
|
||||
}
|
||||
|
||||
itemstack3.stackSize = sizeOrID;
|
||||
|
||||
if (itemstack3.stackSize <= 0) {
|
||||
itemstack3 = null;
|
||||
}
|
||||
|
||||
inventoryplayer.setItemStack(itemstack3);
|
||||
}
|
||||
|
||||
this.resetDistributionVariables();
|
||||
} else {
|
||||
this.resetDistributionVariables();
|
||||
}
|
||||
} else if (this.distributeState != 0) {
|
||||
this.resetDistributionVariables();
|
||||
} else if (getSlot(slotNum) != null && getSlot(slotNum) instanceof SlotMagnetFilter) {
|
||||
|
||||
SlotMagnetFilter slot = (SlotMagnetFilter) getSlot(slotNum);
|
||||
|
||||
ItemStack stackSlot = slot.getStack();
|
||||
if (alreadyFiltered(player.inventory.getItemStack()) && player.inventory.getItemStack() != null) {
|
||||
return null;
|
||||
}
|
||||
if (stackSlot != null) {
|
||||
stack = stackSlot.copy();
|
||||
}
|
||||
|
||||
if (mouseButton == 2) {
|
||||
fillPhantomSlot(slot, null, mouseButton);
|
||||
} else if (mouseButton == 0 || mouseButton == 1) {
|
||||
InventoryPlayer playerInv = player.inventory;
|
||||
|
||||
ItemStack stackHeld = playerInv.getItemStack();
|
||||
|
||||
if (stackSlot == null) {
|
||||
if (stackHeld != null && slot.isItemValid(stackHeld)) {
|
||||
fillPhantomSlot(slot, stackHeld, mouseButton);
|
||||
}
|
||||
} else if (stackHeld == null) {
|
||||
adjustPhantomSlot(slot, mouseButton, modifier);
|
||||
} else if (slot.isItemValid(stackHeld)) {
|
||||
if (isIdenticalItem(stackSlot, stackHeld)) {
|
||||
adjustPhantomSlot(slot, mouseButton, modifier);
|
||||
} else {
|
||||
fillPhantomSlot(slot, stackHeld, mouseButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
} else {
|
||||
return super.slotClick(slotNum, mouseButton, modifier, player);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public boolean alwaysTrue(Slot slot) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static void setSlotStack(
|
||||
Set slotSet, int stackSizeSelector, ItemStack stackToResize, int currentSlotStackSize) {
|
||||
switch (stackSizeSelector) {
|
||||
case 0:
|
||||
stackToResize.stackSize =
|
||||
MathHelper.floor_float((float) stackToResize.stackSize / (float) slotSet.size());
|
||||
break;
|
||||
case 1:
|
||||
stackToResize.stackSize = 1;
|
||||
}
|
||||
|
||||
stackToResize.stackSize += currentSlotStackSize;
|
||||
}
|
||||
|
||||
public static boolean stackFitsInSlot(Slot slot, ItemStack itemStack, boolean sizeMatters) {
|
||||
boolean flag1 = slot == null || !slot.getHasStack();
|
||||
|
||||
if (slot != null
|
||||
&& slot.getHasStack()
|
||||
&& itemStack != null
|
||||
&& itemStack.isItemEqual(slot.getStack())
|
||||
&& ItemStack.areItemStackTagsEqual(slot.getStack(), itemStack)) {
|
||||
int i = sizeMatters ? 0 : itemStack.stackSize;
|
||||
flag1 |= slot.getStack().stackSize + i <= itemStack.getMaxStackSize();
|
||||
}
|
||||
|
||||
return flag1;
|
||||
}
|
||||
|
||||
public static int checkForPressedButton(int btn) {
|
||||
return btn & 3;
|
||||
}
|
||||
|
||||
public static int checkForPressedButton2(int mouseButtonPressed) {
|
||||
return mouseButtonPressed >> 2 & 3;
|
||||
}
|
||||
|
||||
public static boolean checkValue(int value) {
|
||||
return value == 0 || value == 1;
|
||||
}
|
||||
|
||||
protected void resetDistributionVariables() {
|
||||
this.distributeState = 0;
|
||||
this.distributeSlotSet.clear();
|
||||
}
|
||||
|
||||
private void arrangeSlots() {
|
||||
int invSize = magnetInventory.getSizeInventory();
|
||||
if (invSize <= 0) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < invSize; i++) {
|
||||
if (magnetInventory.getStackInSlot(i) == null) {
|
||||
for (int j = 0; j < invSize; j++) {
|
||||
if (j <= i) {
|
||||
continue;
|
||||
}
|
||||
if (magnetInventory.getStackInSlot(j) != null) {
|
||||
magnetInventory.setInventorySlotContents(i, magnetInventory.getStackInSlot(j));
|
||||
magnetInventory.decrStackSize(j, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fillPhantomSlot(SlotMagnetFilter slot, ItemStack stackHeld, int mouseButton) {
|
||||
if (!slot.canAdjustPhantom()) {
|
||||
return;
|
||||
}
|
||||
if (stackHeld == null) {
|
||||
slot.putStack(null);
|
||||
return;
|
||||
}
|
||||
|
||||
int stackSize = mouseButton == 0 ? stackHeld.stackSize : 1;
|
||||
if (stackSize > slot.getSlotStackLimit()) {
|
||||
stackSize = slot.getSlotStackLimit();
|
||||
}
|
||||
ItemStack phantomStack = stackHeld.copy();
|
||||
RandomUtils.removeTimerTags(phantomStack);
|
||||
phantomStack.stackSize = stackSize;
|
||||
|
||||
slot.putStack(phantomStack);
|
||||
arrangeSlots();
|
||||
}
|
||||
|
||||
private void adjustPhantomSlot(SlotMagnetFilter slot, int mouseButton, int modifier) {
|
||||
if (!slot.canAdjustPhantom()) {
|
||||
return;
|
||||
}
|
||||
ItemStack stackSlot = slot.getStack();
|
||||
int stackSize;
|
||||
if (modifier == 1) {
|
||||
stackSize = mouseButton == 0 ? (stackSlot.stackSize + 1) / 2 : stackSlot.stackSize * 2;
|
||||
} else {
|
||||
stackSize = mouseButton == 0 ? stackSlot.stackSize - 1 : stackSlot.stackSize + 1;
|
||||
}
|
||||
|
||||
if (stackSize > slot.getSlotStackLimit()) {
|
||||
stackSize = slot.getSlotStackLimit();
|
||||
}
|
||||
|
||||
stackSlot.stackSize = stackSize;
|
||||
|
||||
if (stackSlot.stackSize <= 0) {
|
||||
stackSlot = null;
|
||||
}
|
||||
|
||||
slot.putStack(stackSlot);
|
||||
arrangeSlots();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(final EntityPlayer p, final int slotIndex) {
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
if (slot == null || slot.getStack() == null) {
|
||||
return null;
|
||||
}
|
||||
ItemStack stack = slot.getStack();
|
||||
if (isInHotbar(slotIndex)) {
|
||||
if (!mergePhantomStack(stack)) {
|
||||
if (!mergeItemStack(stack, PLAYER_INV_START, PLAYER_INV_END + 1, false)) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else if (isInPlayerInventory(slotIndex)) {
|
||||
if (!mergePhantomStack(stack)) {
|
||||
if (!mergeItemStack(stack, HOTBAR_START, HOTBAR_END + 1, false)) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
if (stack.stackSize == 0) {
|
||||
slot.putStack((ItemStack) null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
slot.onPickupFromSlot(p, stack);
|
||||
return stack;
|
||||
}
|
||||
|
||||
protected boolean mergePhantomStack(ItemStack stack) {
|
||||
if (!alreadyFiltered(stack)) {
|
||||
for (int i = FILTERS_START; i <= FILTERS_END; i++) {
|
||||
if (this.getSlot(i).getStack() != null) {
|
||||
continue;
|
||||
} else {
|
||||
fillPhantomSlot((SlotMagnetFilter) this.getSlot(i), stack, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isIdenticalItem(ItemStack lhs, ItemStack rhs) {
|
||||
if (lhs == rhs) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (lhs == null || rhs == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lhs.getItem() != rhs.getItem()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lhs.getItemDamage() != OreDictionary.WILDCARD_VALUE) {
|
||||
if (lhs.getItemDamage() != rhs.getItemDamage()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return ItemStack.areItemStackTagsEqual(lhs, rhs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean mergeItemStack(ItemStack stack, int start, int end, boolean backwards) {
|
||||
boolean flag1 = false;
|
||||
int k = (backwards ? end - 1 : start);
|
||||
Slot slot;
|
||||
ItemStack itemstack1;
|
||||
|
||||
if (stack.isStackable()) {
|
||||
while (stack.stackSize > 0 && (!backwards && k < end || backwards && k >= start)) {
|
||||
slot = (Slot) inventorySlots.get(k);
|
||||
itemstack1 = slot.getStack();
|
||||
|
||||
if (!slot.isItemValid(stack)) {
|
||||
k += (backwards ? -1 : 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itemstack1 != null
|
||||
&& itemstack1.getItem() == stack.getItem()
|
||||
&& (!stack.getHasSubtypes() || stack.getItemDamage() == itemstack1.getItemDamage())
|
||||
&& ItemStack.areItemStackTagsEqual(stack, itemstack1)) {
|
||||
int l = itemstack1.stackSize + stack.stackSize;
|
||||
|
||||
if (l <= stack.getMaxStackSize() && l <= slot.getSlotStackLimit()) {
|
||||
stack.stackSize = 0;
|
||||
itemstack1.stackSize = l;
|
||||
magnetInventory.markDirty();
|
||||
flag1 = true;
|
||||
} else if (itemstack1.stackSize < stack.getMaxStackSize() && l < slot.getSlotStackLimit()) {
|
||||
stack.stackSize -= stack.getMaxStackSize() - itemstack1.stackSize;
|
||||
itemstack1.stackSize = stack.getMaxStackSize();
|
||||
magnetInventory.markDirty();
|
||||
flag1 = true;
|
||||
}
|
||||
}
|
||||
|
||||
k += (backwards ? -1 : 1);
|
||||
}
|
||||
}
|
||||
if (stack.stackSize > 0) {
|
||||
k = (backwards ? end - 1 : start);
|
||||
while (!backwards && k < end || backwards && k >= start) {
|
||||
slot = (Slot) inventorySlots.get(k);
|
||||
itemstack1 = slot.getStack();
|
||||
|
||||
if (!slot.isItemValid(stack)) {
|
||||
k += (backwards ? -1 : 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itemstack1 == null) {
|
||||
int l = stack.stackSize;
|
||||
if (l <= slot.getSlotStackLimit()) {
|
||||
slot.putStack(stack.copy());
|
||||
stack.stackSize = 0;
|
||||
magnetInventory.markDirty();
|
||||
flag1 = true;
|
||||
break;
|
||||
} else {
|
||||
putStackInSlot(
|
||||
k, new ItemStack(stack.getItem(), slot.getSlotStackLimit(), stack.getItemDamage()));
|
||||
stack.stackSize -= slot.getSlotStackLimit();
|
||||
magnetInventory.markDirty();
|
||||
flag1 = true;
|
||||
}
|
||||
}
|
||||
|
||||
k += (backwards ? -1 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
return flag1;
|
||||
}
|
||||
}
|
||||
+47
-62
@@ -5,79 +5,64 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class ContainerOpenContext {
|
||||
|
||||
public class ContainerOpenContext
|
||||
{
|
||||
private final boolean isItem;
|
||||
private World w;
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private ForgeDirection side;
|
||||
|
||||
private final boolean isItem;
|
||||
private World w;
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private ForgeDirection side;
|
||||
public ContainerOpenContext(final Object myItem) {
|
||||
final boolean isWorld = myItem instanceof IPart || myItem instanceof TileEntity;
|
||||
this.isItem = !isWorld;
|
||||
}
|
||||
|
||||
public ContainerOpenContext( final Object myItem )
|
||||
{
|
||||
final boolean isWorld = myItem instanceof IPart || myItem instanceof TileEntity;
|
||||
this.isItem = !isWorld;
|
||||
}
|
||||
public TileEntity getTile() {
|
||||
if (this.isItem) {
|
||||
return null;
|
||||
}
|
||||
return this.getWorld().getTileEntity(this.getX(), this.getY(), this.getZ());
|
||||
}
|
||||
|
||||
public TileEntity getTile()
|
||||
{
|
||||
if( this.isItem )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return this.getWorld().getTileEntity( this.getX(), this.getY(), this.getZ() );
|
||||
}
|
||||
public ForgeDirection getSide() {
|
||||
return this.side;
|
||||
}
|
||||
|
||||
public ForgeDirection getSide()
|
||||
{
|
||||
return this.side;
|
||||
}
|
||||
public void setSide(final ForgeDirection side) {
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
public void setSide( final ForgeDirection side )
|
||||
{
|
||||
this.side = side;
|
||||
}
|
||||
private int getZ() {
|
||||
return this.z;
|
||||
}
|
||||
|
||||
private int getZ()
|
||||
{
|
||||
return this.z;
|
||||
}
|
||||
public void setZ(final int z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public void setZ( final int z )
|
||||
{
|
||||
this.z = z;
|
||||
}
|
||||
private int getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
private int getY()
|
||||
{
|
||||
return this.y;
|
||||
}
|
||||
public void setY(final int y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void setY( final int y )
|
||||
{
|
||||
this.y = y;
|
||||
}
|
||||
private int getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
private int getX()
|
||||
{
|
||||
return this.x;
|
||||
}
|
||||
public void setX(final int x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public void setX( final int x )
|
||||
{
|
||||
this.x = x;
|
||||
}
|
||||
private World getWorld() {
|
||||
return this.w;
|
||||
}
|
||||
|
||||
private World getWorld()
|
||||
{
|
||||
return this.w;
|
||||
}
|
||||
|
||||
public void setWorld( final World w )
|
||||
{
|
||||
this.w = w;
|
||||
}
|
||||
public void setWorld(final World w) {
|
||||
this.w = w;
|
||||
}
|
||||
}
|
||||
+1709
-1687
File diff suppressed because it is too large.
Load diff
+33
-43
@@ -1,55 +1,45 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.common.container;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.util.ItemSorters;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CraftingCPURecord implements Comparable<CraftingCPURecord> {
|
||||
|
||||
public class CraftingCPURecord implements Comparable<CraftingCPURecord>
|
||||
{
|
||||
private final String myName;
|
||||
private final ICraftingCPU cpu;
|
||||
private final long size;
|
||||
private final int processors;
|
||||
|
||||
private final String myName;
|
||||
private final ICraftingCPU cpu;
|
||||
private final long size;
|
||||
private final int processors;
|
||||
public CraftingCPURecord(final long size, final int coProcessors, final ICraftingCPU server) {
|
||||
this.size = size;
|
||||
this.processors = coProcessors;
|
||||
this.cpu = server;
|
||||
this.myName = server.getName();
|
||||
}
|
||||
|
||||
public CraftingCPURecord( final long size, final int coProcessors, final ICraftingCPU server )
|
||||
{
|
||||
this.size = size;
|
||||
this.processors = coProcessors;
|
||||
this.cpu = server;
|
||||
this.myName = server.getName();
|
||||
}
|
||||
@Override
|
||||
public int compareTo(@Nonnull final CraftingCPURecord o) {
|
||||
final int a = ItemSorters.compareLong(o.getProcessors(), this.getProcessors());
|
||||
if (a != 0) {
|
||||
return a;
|
||||
}
|
||||
return ItemSorters.compareLong(o.getSize(), this.getSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo( @Nonnull final CraftingCPURecord o )
|
||||
{
|
||||
final int a = ItemSorters.compareLong( o.getProcessors(), this.getProcessors() );
|
||||
if( a != 0 )
|
||||
{
|
||||
return a;
|
||||
}
|
||||
return ItemSorters.compareLong( o.getSize(), this.getSize() );
|
||||
}
|
||||
public ICraftingCPU getCpu() {
|
||||
return this.cpu;
|
||||
}
|
||||
|
||||
public ICraftingCPU getCpu()
|
||||
{
|
||||
return this.cpu;
|
||||
}
|
||||
String getName() {
|
||||
return this.myName;
|
||||
}
|
||||
|
||||
String getName()
|
||||
{
|
||||
return this.myName;
|
||||
}
|
||||
int getProcessors() {
|
||||
return this.processors;
|
||||
}
|
||||
|
||||
int getProcessors()
|
||||
{
|
||||
return this.processors;
|
||||
}
|
||||
|
||||
long getSize()
|
||||
{
|
||||
return this.size;
|
||||
}
|
||||
}
|
||||
long getSize() {
|
||||
return this.size;
|
||||
}
|
||||
}
|
||||
+1032
-1037
File diff suppressed because it is too large.
Load diff
+4
-6
@@ -5,15 +5,13 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* Annotates that this field should be synchronized between the server and client.
|
||||
* Requires the field to be public.
|
||||
*/
|
||||
@Retention( RetentionPolicy.RUNTIME )
|
||||
@Target( ElementType.FIELD )
|
||||
public @interface GuiSync
|
||||
{
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface GuiSync {
|
||||
|
||||
int value();
|
||||
int value();
|
||||
}
|
||||
+116
-179
@@ -3,7 +3,6 @@ package net.p455w0rd.wirelesscraftingterminal.common.container.guisync;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
@@ -13,191 +12,129 @@ import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketValueConfig;
|
||||
|
||||
public class SyncData
|
||||
{
|
||||
private final Container source;
|
||||
private final Field field;
|
||||
private final int channel;
|
||||
private Object clientVersion;
|
||||
public class SyncData {
|
||||
private final Container source;
|
||||
private final Field field;
|
||||
private final int channel;
|
||||
private Object clientVersion;
|
||||
|
||||
public SyncData( final Container container, final Field field, final GuiSync annotation )
|
||||
{
|
||||
if (container instanceof ContainerWirelessCraftingTerminal) {
|
||||
this.source = (ContainerWirelessCraftingTerminal) container;
|
||||
}
|
||||
else if (container instanceof WCTBaseContainer) {
|
||||
this.source = (WCTBaseContainer) container;
|
||||
}
|
||||
else {
|
||||
this.source = container;
|
||||
}
|
||||
this.clientVersion = null;
|
||||
this.field = field;
|
||||
this.channel = annotation.value();
|
||||
}
|
||||
public SyncData(final Container container, final Field field, final GuiSync annotation) {
|
||||
if (container instanceof ContainerWirelessCraftingTerminal) {
|
||||
this.source = (ContainerWirelessCraftingTerminal) container;
|
||||
} else if (container instanceof WCTBaseContainer) {
|
||||
this.source = (WCTBaseContainer) container;
|
||||
} else {
|
||||
this.source = container;
|
||||
}
|
||||
this.clientVersion = null;
|
||||
this.field = field;
|
||||
this.channel = annotation.value();
|
||||
}
|
||||
|
||||
public int getChannel()
|
||||
{
|
||||
return this.channel;
|
||||
}
|
||||
public int getChannel() {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
public void tick( final ICrafting c )
|
||||
{
|
||||
try
|
||||
{
|
||||
final Object val = this.field.get( this.source );
|
||||
if( val != null && this.clientVersion == null )
|
||||
{
|
||||
this.send( c, val );
|
||||
}
|
||||
else if( !val.equals( this.clientVersion ) )
|
||||
{
|
||||
this.send( c, val );
|
||||
}
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
WCTLog.debug( e.getMessage() );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
WCTLog.debug( e.getMessage() );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
WCTLog.debug( e.getMessage() );
|
||||
}
|
||||
}
|
||||
public void tick(final ICrafting c) {
|
||||
try {
|
||||
final Object val = this.field.get(this.source);
|
||||
if (val != null && this.clientVersion == null) {
|
||||
this.send(c, val);
|
||||
} else if (!val.equals(this.clientVersion)) {
|
||||
this.send(c, val);
|
||||
}
|
||||
} catch (final IllegalArgumentException e) {
|
||||
WCTLog.debug(e.getMessage());
|
||||
} catch (final IllegalAccessException e) {
|
||||
WCTLog.debug(e.getMessage());
|
||||
} catch (final IOException e) {
|
||||
WCTLog.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void send( final ICrafting o, final Object val ) throws IOException
|
||||
{
|
||||
if( val instanceof String )
|
||||
{
|
||||
if( o instanceof EntityPlayerMP )
|
||||
{
|
||||
NetworkHandler.instance.sendTo( new PacketValueConfig( "SyncDat." + this.channel, (String) val ), (EntityPlayerMP) o );
|
||||
}
|
||||
}
|
||||
else if( this.field.getType().isEnum() )
|
||||
{
|
||||
o.sendProgressBarUpdate( this.source, this.channel, ( (Enum) val ).ordinal() );
|
||||
}
|
||||
else if( val instanceof Long || val.getClass() == long.class )
|
||||
{
|
||||
//NetworkHandler.instance.sendTo( new PacketProgressBar( this.channel, (Long) val ), (EntityPlayerMP) o );
|
||||
}
|
||||
else if( val instanceof Boolean || val.getClass() == boolean.class )
|
||||
{
|
||||
o.sendProgressBarUpdate( this.source, this.channel, ( (Boolean) val ) ? 1 : 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
o.sendProgressBarUpdate( this.source, this.channel, (Integer) val );
|
||||
}
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void send(final ICrafting o, final Object val) throws IOException {
|
||||
if (val instanceof String) {
|
||||
if (o instanceof EntityPlayerMP) {
|
||||
NetworkHandler.instance.sendTo(
|
||||
new PacketValueConfig("SyncDat." + this.channel, (String) val), (EntityPlayerMP) o);
|
||||
}
|
||||
} else if (this.field.getType().isEnum()) {
|
||||
o.sendProgressBarUpdate(this.source, this.channel, ((Enum) val).ordinal());
|
||||
} else if (val instanceof Long || val.getClass() == long.class) {
|
||||
// NetworkHandler.instance.sendTo( new PacketProgressBar( this.channel, (Long) val ), (EntityPlayerMP) o );
|
||||
} else if (val instanceof Boolean || val.getClass() == boolean.class) {
|
||||
o.sendProgressBarUpdate(this.source, this.channel, ((Boolean) val) ? 1 : 0);
|
||||
} else {
|
||||
o.sendProgressBarUpdate(this.source, this.channel, (Integer) val);
|
||||
}
|
||||
|
||||
this.clientVersion = val;
|
||||
}
|
||||
this.clientVersion = val;
|
||||
}
|
||||
|
||||
public void update( final Object val )
|
||||
{
|
||||
try
|
||||
{
|
||||
final Object oldValue = this.field.get( this.source );
|
||||
if( val instanceof String )
|
||||
{
|
||||
this.updateString( oldValue, (String) val );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.updateValue( oldValue, (Long) val );
|
||||
}
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
WCTLog.debug( e.getMessage() );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
WCTLog.debug( e.getMessage() );
|
||||
}
|
||||
}
|
||||
public void update(final Object val) {
|
||||
try {
|
||||
final Object oldValue = this.field.get(this.source);
|
||||
if (val instanceof String) {
|
||||
this.updateString(oldValue, (String) val);
|
||||
} else {
|
||||
this.updateValue(oldValue, (Long) val);
|
||||
}
|
||||
} catch (final IllegalArgumentException e) {
|
||||
WCTLog.debug(e.getMessage());
|
||||
} catch (final IllegalAccessException e) {
|
||||
WCTLog.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateString( final Object oldValue, final String val )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.field.set( this.source, val );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
WCTLog.debug( e.getMessage() );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
WCTLog.debug( e.getMessage() );
|
||||
}
|
||||
}
|
||||
private void updateString(final Object oldValue, final String val) {
|
||||
try {
|
||||
this.field.set(this.source, val);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
WCTLog.debug(e.getMessage());
|
||||
} catch (final IllegalAccessException e) {
|
||||
WCTLog.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private void updateValue( final Object oldValue, final long val )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( this.field.getType().isEnum() )
|
||||
{
|
||||
final EnumSet<? extends Enum> valList = EnumSet.allOf( (Class<? extends Enum>) this.field.getType() );
|
||||
for( final Enum e : valList )
|
||||
{
|
||||
if( e.ordinal() == val )
|
||||
{
|
||||
this.field.set( this.source, e );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( this.field.getType().equals( int.class ) )
|
||||
{
|
||||
this.field.set( this.source, (int) val );
|
||||
}
|
||||
else if( this.field.getType().equals( long.class ) )
|
||||
{
|
||||
this.field.set( this.source, val );
|
||||
}
|
||||
else if( this.field.getType().equals( boolean.class ) )
|
||||
{
|
||||
this.field.set( this.source, val == 1 );
|
||||
}
|
||||
else if( this.field.getType().equals( Integer.class ) )
|
||||
{
|
||||
this.field.set( this.source, (int) val );
|
||||
}
|
||||
else if( this.field.getType().equals( Long.class ) )
|
||||
{
|
||||
this.field.set( this.source, val );
|
||||
}
|
||||
else if( this.field.getType().equals( Boolean.class ) )
|
||||
{
|
||||
this.field.set( this.source, val == 1 );
|
||||
}
|
||||
}
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private void updateValue(final Object oldValue, final long val) {
|
||||
try {
|
||||
if (this.field.getType().isEnum()) {
|
||||
final EnumSet<? extends Enum> valList = EnumSet.allOf((Class<? extends Enum>) this.field.getType());
|
||||
for (final Enum e : valList) {
|
||||
if (e.ordinal() == val) {
|
||||
this.field.set(this.source, e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.field.getType().equals(int.class)) {
|
||||
this.field.set(this.source, (int) val);
|
||||
} else if (this.field.getType().equals(long.class)) {
|
||||
this.field.set(this.source, val);
|
||||
} else if (this.field.getType().equals(boolean.class)) {
|
||||
this.field.set(this.source, val == 1);
|
||||
} else if (this.field.getType().equals(Integer.class)) {
|
||||
this.field.set(this.source, (int) val);
|
||||
} else if (this.field.getType().equals(Long.class)) {
|
||||
this.field.set(this.source, val);
|
||||
} else if (this.field.getType().equals(Boolean.class)) {
|
||||
this.field.set(this.source, val == 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.source instanceof ContainerWirelessCraftingTerminal) {
|
||||
((ContainerWirelessCraftingTerminal) this.source).onUpdate( this.field.getName(), oldValue, this.field.get( this.source ) );
|
||||
}
|
||||
if (this.source instanceof WCTBaseContainer) {
|
||||
((WCTBaseContainer) this.source).onUpdate( this.field.getName(), oldValue, this.field.get( this.source ) );
|
||||
}
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
WCTLog.debug( e.getMessage() );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
WCTLog.debug( e.getMessage() );
|
||||
}
|
||||
}
|
||||
if (this.source instanceof ContainerWirelessCraftingTerminal) {
|
||||
((ContainerWirelessCraftingTerminal) this.source)
|
||||
.onUpdate(this.field.getName(), oldValue, this.field.get(this.source));
|
||||
}
|
||||
if (this.source instanceof WCTBaseContainer) {
|
||||
((WCTBaseContainer) this.source).onUpdate(this.field.getName(), oldValue, this.field.get(this.source));
|
||||
}
|
||||
} catch (final IllegalArgumentException e) {
|
||||
WCTLog.debug(e.getMessage());
|
||||
} catch (final IllegalAccessException e) {
|
||||
WCTLog.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
+119
-136
@@ -15,164 +15,147 @@ import net.minecraft.stats.AchievementList;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
||||
|
||||
public class AppEngCraftingSlot extends AppEngSlot {
|
||||
|
||||
public class AppEngCraftingSlot extends AppEngSlot
|
||||
{
|
||||
/**
|
||||
* The craft matrix inventory linked to this result slot.
|
||||
*/
|
||||
private final IInventory craftMatrix;
|
||||
|
||||
/**
|
||||
* The craft matrix inventory linked to this result slot.
|
||||
*/
|
||||
private final IInventory craftMatrix;
|
||||
/**
|
||||
* The player that is using the GUI where this slot resides.
|
||||
*/
|
||||
private final EntityPlayer thePlayer;
|
||||
|
||||
/**
|
||||
* The player that is using the GUI where this slot resides.
|
||||
*/
|
||||
private final EntityPlayer thePlayer;
|
||||
/**
|
||||
* The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset.
|
||||
*/
|
||||
private int amountCrafted;
|
||||
|
||||
/**
|
||||
* The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset.
|
||||
*/
|
||||
private int amountCrafted;
|
||||
public AppEngCraftingSlot(
|
||||
final EntityPlayer par1EntityPlayer,
|
||||
final IInventory par2IInventory,
|
||||
final IInventory par3IInventory,
|
||||
final int par4,
|
||||
final int par5,
|
||||
final int par6) {
|
||||
super(par3IInventory, par4, par5, par6);
|
||||
this.thePlayer = par1EntityPlayer;
|
||||
this.craftMatrix = par2IInventory;
|
||||
}
|
||||
|
||||
public AppEngCraftingSlot( final EntityPlayer par1EntityPlayer, final IInventory par2IInventory, final IInventory par3IInventory, final int par4, final int par5, final int par6 )
|
||||
{
|
||||
super( par3IInventory, par4, par5, par6 );
|
||||
this.thePlayer = par1EntityPlayer;
|
||||
this.craftMatrix = par2IInventory;
|
||||
}
|
||||
/**
|
||||
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an
|
||||
* internal count then calls onCrafting(item).
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting(final ItemStack par1ItemStack, final int par2) {
|
||||
this.amountCrafted += par2;
|
||||
this.onCrafting(par1ItemStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an
|
||||
* internal count then calls onCrafting(item).
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting( final ItemStack par1ItemStack, final int par2 )
|
||||
{
|
||||
this.amountCrafted += par2;
|
||||
this.onCrafting( par1ItemStack );
|
||||
}
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting(final ItemStack par1ItemStack) {
|
||||
par1ItemStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted);
|
||||
this.amountCrafted = 0;
|
||||
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting( final ItemStack par1ItemStack )
|
||||
{
|
||||
par1ItemStack.onCrafting( this.thePlayer.worldObj, this.thePlayer, this.amountCrafted );
|
||||
this.amountCrafted = 0;
|
||||
if (par1ItemStack.getItem() == Item.getItemFromBlock(Blocks.crafting_table)) {
|
||||
this.thePlayer.addStat(AchievementList.buildWorkBench, 1);
|
||||
}
|
||||
|
||||
if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.crafting_table ) )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.buildWorkBench, 1 );
|
||||
}
|
||||
if (par1ItemStack.getItem() instanceof ItemPickaxe) {
|
||||
this.thePlayer.addStat(AchievementList.buildPickaxe, 1);
|
||||
}
|
||||
|
||||
if( par1ItemStack.getItem() instanceof ItemPickaxe )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.buildPickaxe, 1 );
|
||||
}
|
||||
if (par1ItemStack.getItem() == Item.getItemFromBlock(Blocks.furnace)) {
|
||||
this.thePlayer.addStat(AchievementList.buildFurnace, 1);
|
||||
}
|
||||
|
||||
if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.furnace ) )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.buildFurnace, 1 );
|
||||
}
|
||||
if (par1ItemStack.getItem() instanceof ItemHoe) {
|
||||
this.thePlayer.addStat(AchievementList.buildHoe, 1);
|
||||
}
|
||||
|
||||
if( par1ItemStack.getItem() instanceof ItemHoe )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.buildHoe, 1 );
|
||||
}
|
||||
if (par1ItemStack.getItem() == Items.bread) {
|
||||
this.thePlayer.addStat(AchievementList.makeBread, 1);
|
||||
}
|
||||
|
||||
if( par1ItemStack.getItem() == Items.bread )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.makeBread, 1 );
|
||||
}
|
||||
if (par1ItemStack.getItem() == Items.cake) {
|
||||
this.thePlayer.addStat(AchievementList.bakeCake, 1);
|
||||
}
|
||||
|
||||
if( par1ItemStack.getItem() == Items.cake )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.bakeCake, 1 );
|
||||
}
|
||||
if (par1ItemStack.getItem() instanceof ItemPickaxe
|
||||
&& ((ItemTool) par1ItemStack.getItem()).func_150913_i() != Item.ToolMaterial.WOOD) {
|
||||
this.thePlayer.addStat(AchievementList.buildBetterPickaxe, 1);
|
||||
}
|
||||
|
||||
if( par1ItemStack.getItem() instanceof ItemPickaxe && ( (ItemTool) par1ItemStack.getItem() ).func_150913_i() != Item.ToolMaterial.WOOD )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.buildBetterPickaxe, 1 );
|
||||
}
|
||||
if (par1ItemStack.getItem() instanceof ItemSword) {
|
||||
this.thePlayer.addStat(AchievementList.buildSword, 1);
|
||||
}
|
||||
|
||||
if( par1ItemStack.getItem() instanceof ItemSword )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.buildSword, 1 );
|
||||
}
|
||||
if (par1ItemStack.getItem() == Item.getItemFromBlock(Blocks.enchanting_table)) {
|
||||
this.thePlayer.addStat(AchievementList.enchantments, 1);
|
||||
}
|
||||
|
||||
if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.enchanting_table ) )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.enchantments, 1 );
|
||||
}
|
||||
if (par1ItemStack.getItem() == Item.getItemFromBlock(Blocks.bookshelf)) {
|
||||
this.thePlayer.addStat(AchievementList.bookcase, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.bookshelf ) )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.bookcase, 1 );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onPickupFromSlot(final EntityPlayer par1EntityPlayer, final ItemStack par2ItemStack) {
|
||||
FMLCommonHandler.instance().firePlayerCraftingEvent(par1EntityPlayer, par2ItemStack, this.craftMatrix);
|
||||
this.onCrafting(par2ItemStack);
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot( final EntityPlayer par1EntityPlayer, final ItemStack par2ItemStack )
|
||||
{
|
||||
FMLCommonHandler.instance().firePlayerCraftingEvent( par1EntityPlayer, par2ItemStack, this.craftMatrix );
|
||||
this.onCrafting( par2ItemStack );
|
||||
for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i) {
|
||||
final ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i);
|
||||
|
||||
for( int i = 0; i < this.craftMatrix.getSizeInventory(); ++i )
|
||||
{
|
||||
final ItemStack itemstack1 = this.craftMatrix.getStackInSlot( i );
|
||||
if (itemstack1 != null) {
|
||||
this.craftMatrix.decrStackSize(i, 1);
|
||||
|
||||
if( itemstack1 != null )
|
||||
{
|
||||
this.craftMatrix.decrStackSize( i, 1 );
|
||||
if (itemstack1.getItem().hasContainerItem(itemstack1)) {
|
||||
final ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1);
|
||||
|
||||
if( itemstack1.getItem().hasContainerItem( itemstack1 ) )
|
||||
{
|
||||
final ItemStack itemstack2 = itemstack1.getItem().getContainerItem( itemstack1 );
|
||||
if (itemstack2 != null
|
||||
&& itemstack2.isItemStackDamageable()
|
||||
&& itemstack2.getItemDamage() > itemstack2.getMaxDamage()) {
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this.thePlayer, itemstack2));
|
||||
continue;
|
||||
}
|
||||
|
||||
if( itemstack2 != null && itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage() )
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( this.thePlayer, itemstack2 ) );
|
||||
continue;
|
||||
}
|
||||
if (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1)
|
||||
|| !this.thePlayer.inventory.addItemStackToInventory(itemstack2)) {
|
||||
if (this.craftMatrix.getStackInSlot(i) == null) {
|
||||
this.craftMatrix.setInventorySlotContents(i, itemstack2);
|
||||
} else {
|
||||
this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !itemstack1.getItem().doesContainerItemLeaveCraftingGrid( itemstack1 ) || !this.thePlayer.inventory.addItemStackToInventory( itemstack2 ) )
|
||||
{
|
||||
if( this.craftMatrix.getStackInSlot( i ) == null )
|
||||
{
|
||||
this.craftMatrix.setInventorySlotContents( i, itemstack2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.thePlayer.dropPlayerItemWithRandomChoice( itemstack2, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
|
||||
* stack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int par1) {
|
||||
if (this.getHasStack()) {
|
||||
this.amountCrafted += Math.min(par1, this.getStack().stackSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
|
||||
* stack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int par1 )
|
||||
{
|
||||
if( this.getHasStack() )
|
||||
{
|
||||
this.amountCrafted += Math.min( par1, this.getStack().stackSize );
|
||||
}
|
||||
|
||||
return super.decrStackSize( par1 );
|
||||
}
|
||||
}
|
||||
return super.decrStackSize(par1);
|
||||
}
|
||||
}
|
||||
+161
-162
@@ -11,201 +11,200 @@ import net.p455w0rd.wirelesscraftingterminal.common.container.WCTBaseContainer;
|
||||
|
||||
public class AppEngSlot extends Slot {
|
||||
|
||||
private final int defX;
|
||||
private final int defY;
|
||||
private boolean isDraggable = true;
|
||||
private boolean isPlayerSide = false;
|
||||
private Container myContainer = null;
|
||||
private int IIcon = -1;
|
||||
private hasCalculatedValidness isValid;
|
||||
private boolean isDisplay = false;
|
||||
private final int defX;
|
||||
private final int defY;
|
||||
private boolean isDraggable = true;
|
||||
private boolean isPlayerSide = false;
|
||||
private Container myContainer = null;
|
||||
private int IIcon = -1;
|
||||
private hasCalculatedValidness isValid;
|
||||
private boolean isDisplay = false;
|
||||
|
||||
public AppEngSlot(final IInventory inv, final int idx, final int x, final int y) {
|
||||
super(inv, idx, x, y);
|
||||
this.defX = x;
|
||||
this.defY = y;
|
||||
this.setIsValid(hasCalculatedValidness.NotAvailable);
|
||||
}
|
||||
public AppEngSlot(final IInventory inv, final int idx, final int x, final int y) {
|
||||
super(inv, idx, x, y);
|
||||
this.defX = x;
|
||||
this.defY = y;
|
||||
this.setIsValid(hasCalculatedValidness.NotAvailable);
|
||||
}
|
||||
|
||||
public Slot setNotDraggable() {
|
||||
this.setDraggable(false);
|
||||
return this;
|
||||
}
|
||||
public Slot setNotDraggable() {
|
||||
this.setDraggable(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Slot setPlayerSide() {
|
||||
this.isPlayerSide = true;
|
||||
return this;
|
||||
}
|
||||
public Slot setPlayerSide() {
|
||||
this.isPlayerSide = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTooltip() {
|
||||
return null;
|
||||
}
|
||||
public String getTooltip() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void clearStack() {
|
||||
super.putStack(null);
|
||||
}
|
||||
public void clearStack() {
|
||||
super.putStack(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
if (this.isEnabled()) {
|
||||
return super.isItemValid(par1ItemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
if (this.isEnabled()) {
|
||||
return super.isItemValid(par1ItemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
if (!this.isEnabled()) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
if (!this.isEnabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this.inventory.getSizeInventory() <= this.getSlotIndex()) {
|
||||
return null;
|
||||
}
|
||||
if (this.inventory.getSizeInventory() <= this.getSlotIndex()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this.isDisplay()) {
|
||||
this.setDisplay(false);
|
||||
return this.getDisplayStack();
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
if (this.isDisplay()) {
|
||||
this.setDisplay(false);
|
||||
return this.getDisplayStack();
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(final ItemStack par1ItemStack) {
|
||||
if (this.isEnabled()) {
|
||||
super.putStack(par1ItemStack);
|
||||
@Override
|
||||
public void putStack(final ItemStack par1ItemStack) {
|
||||
if (this.isEnabled()) {
|
||||
super.putStack(par1ItemStack);
|
||||
|
||||
if (this.getContainer() != null) {
|
||||
if (this.getContainer() instanceof ContainerWirelessCraftingTerminal) {
|
||||
((ContainerWirelessCraftingTerminal) this.getContainer()).onSlotChange(this);
|
||||
}
|
||||
if (this.getContainer() instanceof WCTBaseContainer) {
|
||||
((WCTBaseContainer) this.getContainer()).onSlotChange(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.getContainer() != null) {
|
||||
if (this.getContainer() instanceof ContainerWirelessCraftingTerminal) {
|
||||
((ContainerWirelessCraftingTerminal) this.getContainer()).onSlotChange(this);
|
||||
}
|
||||
if (this.getContainer() instanceof WCTBaseContainer) {
|
||||
((WCTBaseContainer) this.getContainer()).onSlotChange(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged() {
|
||||
if (this.inventory instanceof AppEngInternalInventory) {
|
||||
((AppEngInternalInventory) this.inventory).markDirty(this.getSlotIndex());
|
||||
}
|
||||
else {
|
||||
super.onSlotChanged();
|
||||
}
|
||||
@Override
|
||||
public void onSlotChanged() {
|
||||
if (this.inventory instanceof AppEngInternalInventory) {
|
||||
((AppEngInternalInventory) this.inventory).markDirty(this.getSlotIndex());
|
||||
} else {
|
||||
super.onSlotChanged();
|
||||
}
|
||||
|
||||
this.setIsValid(hasCalculatedValidness.NotAvailable);
|
||||
}
|
||||
this.setIsValid(hasCalculatedValidness.NotAvailable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
|
||||
if (this.isEnabled()) {
|
||||
return super.canTakeStack(par1EntityPlayer);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
|
||||
if (this.isEnabled()) {
|
||||
return super.canTakeStack(par1EntityPlayer);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_111238_b() {
|
||||
return this.isEnabled();
|
||||
}
|
||||
@Override
|
||||
public boolean func_111238_b() {
|
||||
return this.isEnabled();
|
||||
}
|
||||
|
||||
public ItemStack getDisplayStack() {
|
||||
return super.getStack();
|
||||
}
|
||||
public ItemStack getDisplayStack() {
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public float getOpacityOfIcon() {
|
||||
return 0.4f;
|
||||
}
|
||||
public float getOpacityOfIcon() {
|
||||
return 0.4f;
|
||||
}
|
||||
|
||||
public boolean renderIconWithItem() {
|
||||
return false;
|
||||
}
|
||||
public boolean renderIconWithItem() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getIcon() {
|
||||
return this.getIIcon();
|
||||
}
|
||||
public int getIcon() {
|
||||
return this.getIIcon();
|
||||
}
|
||||
|
||||
public boolean isPlayerSide() {
|
||||
return this.isPlayerSide;
|
||||
}
|
||||
public boolean isPlayerSide() {
|
||||
return this.isPlayerSide;
|
||||
}
|
||||
|
||||
public boolean shouldDisplay() {
|
||||
return this.isEnabled();
|
||||
}
|
||||
public boolean shouldDisplay() {
|
||||
return this.isEnabled();
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return this.defX;
|
||||
}
|
||||
public int getX() {
|
||||
return this.defX;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return this.defY;
|
||||
}
|
||||
public int getY() {
|
||||
return this.defY;
|
||||
}
|
||||
|
||||
private int getIIcon() {
|
||||
return this.IIcon;
|
||||
}
|
||||
private int getIIcon() {
|
||||
return this.IIcon;
|
||||
}
|
||||
|
||||
public void setIIcon(final int iIcon) {
|
||||
this.IIcon = iIcon;
|
||||
}
|
||||
public void setIIcon(final int iIcon) {
|
||||
this.IIcon = iIcon;
|
||||
}
|
||||
|
||||
private boolean isDisplay() {
|
||||
return this.isDisplay;
|
||||
}
|
||||
private boolean isDisplay() {
|
||||
return this.isDisplay;
|
||||
}
|
||||
|
||||
public void setDisplay(final boolean isDisplay) {
|
||||
this.isDisplay = isDisplay;
|
||||
}
|
||||
public void setDisplay(final boolean isDisplay) {
|
||||
this.isDisplay = isDisplay;
|
||||
}
|
||||
|
||||
public boolean isDraggable() {
|
||||
return this.isDraggable;
|
||||
}
|
||||
public boolean isDraggable() {
|
||||
return this.isDraggable;
|
||||
}
|
||||
|
||||
private void setDraggable(final boolean isDraggable) {
|
||||
this.isDraggable = isDraggable;
|
||||
}
|
||||
private void setDraggable(final boolean isDraggable) {
|
||||
this.isDraggable = isDraggable;
|
||||
}
|
||||
|
||||
void setPlayerSide(final boolean isPlayerSide) {
|
||||
this.isPlayerSide = isPlayerSide;
|
||||
}
|
||||
void setPlayerSide(final boolean isPlayerSide) {
|
||||
this.isPlayerSide = isPlayerSide;
|
||||
}
|
||||
|
||||
public hasCalculatedValidness getIsValid() {
|
||||
return this.isValid;
|
||||
}
|
||||
public hasCalculatedValidness getIsValid() {
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
public void setIsValid(final hasCalculatedValidness isValid) {
|
||||
this.isValid = isValid;
|
||||
}
|
||||
public void setIsValid(final hasCalculatedValidness isValid) {
|
||||
this.isValid = isValid;
|
||||
}
|
||||
|
||||
Container getContainer() {
|
||||
if (this.myContainer instanceof ContainerWirelessCraftingTerminal) {
|
||||
return (ContainerWirelessCraftingTerminal) this.myContainer;
|
||||
}
|
||||
if (this.myContainer instanceof WCTBaseContainer) {
|
||||
return (WCTBaseContainer) this.myContainer;
|
||||
}
|
||||
return this.myContainer;
|
||||
}
|
||||
Container getContainer() {
|
||||
if (this.myContainer instanceof ContainerWirelessCraftingTerminal) {
|
||||
return (ContainerWirelessCraftingTerminal) this.myContainer;
|
||||
}
|
||||
if (this.myContainer instanceof WCTBaseContainer) {
|
||||
return (WCTBaseContainer) this.myContainer;
|
||||
}
|
||||
return this.myContainer;
|
||||
}
|
||||
|
||||
public void setContainer(final Container myContainer) {
|
||||
if (this.myContainer instanceof ContainerWirelessCraftingTerminal) {
|
||||
this.myContainer = (ContainerWirelessCraftingTerminal) myContainer;
|
||||
}
|
||||
else if (this.myContainer instanceof WCTBaseContainer) {
|
||||
this.myContainer = (WCTBaseContainer) myContainer;
|
||||
}
|
||||
else {
|
||||
this.myContainer = myContainer;
|
||||
}
|
||||
}
|
||||
public void setContainer(final Container myContainer) {
|
||||
if (this.myContainer instanceof ContainerWirelessCraftingTerminal) {
|
||||
this.myContainer = (ContainerWirelessCraftingTerminal) myContainer;
|
||||
} else if (this.myContainer instanceof WCTBaseContainer) {
|
||||
this.myContainer = (WCTBaseContainer) myContainer;
|
||||
} else {
|
||||
this.myContainer = myContainer;
|
||||
}
|
||||
}
|
||||
|
||||
public enum hasCalculatedValidness {
|
||||
NotAvailable, Valid, Invalid
|
||||
}
|
||||
}
|
||||
public enum hasCalculatedValidness {
|
||||
NotAvailable,
|
||||
Valid,
|
||||
Invalid
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.common.container.slot;
|
||||
|
||||
public interface IOptionalSlotHost
|
||||
{
|
||||
public interface IOptionalSlotHost {
|
||||
|
||||
boolean isSlotEnabled( int idx );
|
||||
boolean isSlotEnabled(int idx);
|
||||
}
|
||||
+40
-62
@@ -4,78 +4,56 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class NullSlot extends AppEngSlot {
|
||||
|
||||
public class NullSlot extends AppEngSlot
|
||||
{
|
||||
public NullSlot() {
|
||||
super(null, 0, 0, 0);
|
||||
}
|
||||
|
||||
public NullSlot()
|
||||
{
|
||||
super( null, 0, 0, 0 );
|
||||
}
|
||||
@Override
|
||||
public void onSlotChange(final ItemStack par1ItemStack, final ItemStack par2ItemStack) {}
|
||||
|
||||
@Override
|
||||
public void onSlotChange( final ItemStack par1ItemStack, final ItemStack par2ItemStack )
|
||||
{
|
||||
@Override
|
||||
public void onPickupFromSlot(final EntityPlayer par1EntityPlayer, final ItemStack par2ItemStack) {}
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot( final EntityPlayer par1EntityPlayer, final ItemStack par2ItemStack )
|
||||
{
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void putStack(final ItemStack par1ItemStack) {}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void onSlotChanged() {}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( final ItemStack par1ItemStack )
|
||||
{
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int par1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean isSlotInInventory(final IInventory par1IInventory, final int par2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged()
|
||||
{
|
||||
@Override
|
||||
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int par1 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotInInventory( final IInventory par1IInventory, final int par2 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final EntityPlayer par1EntityPlayer )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotIndex()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getSlotIndex() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
+52
-57
@@ -3,72 +3,67 @@ package net.p455w0rd.wirelesscraftingterminal.common.container.slot;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class OptionalSlotFake extends SlotFake {
|
||||
|
||||
public class OptionalSlotFake extends SlotFake
|
||||
{
|
||||
private final int srcX;
|
||||
private final int srcY;
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
private boolean renderDisabled = true;
|
||||
|
||||
private final int srcX;
|
||||
private final int srcY;
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
private boolean renderDisabled = true;
|
||||
public OptionalSlotFake(
|
||||
final IInventory inv,
|
||||
final IOptionalSlotHost containerBus,
|
||||
final int idx,
|
||||
final int x,
|
||||
final int y,
|
||||
final int offX,
|
||||
final int offY,
|
||||
final int groupNum) {
|
||||
super(inv, idx, x + offX * 18, y + offY * 18);
|
||||
this.srcX = x;
|
||||
this.srcY = y;
|
||||
this.groupNum = groupNum;
|
||||
this.host = containerBus;
|
||||
}
|
||||
|
||||
public OptionalSlotFake( final IInventory inv, final IOptionalSlotHost containerBus, final int idx, final int x, final int y, final int offX, final int offY, final int groupNum )
|
||||
{
|
||||
super( inv, idx, x + offX * 18, y + offY * 18 );
|
||||
this.srcX = x;
|
||||
this.srcY = y;
|
||||
this.groupNum = groupNum;
|
||||
this.host = containerBus;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
if (!this.isEnabled()) {
|
||||
if (this.getDisplayStack() != null) {
|
||||
this.clearStack();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack()
|
||||
{
|
||||
if( !this.isEnabled() )
|
||||
{
|
||||
if( this.getDisplayStack() != null )
|
||||
{
|
||||
this.clearStack();
|
||||
}
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
return super.getStack();
|
||||
}
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (this.host == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
if( this.host == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return this.host.isSlotEnabled(this.groupNum);
|
||||
}
|
||||
|
||||
return this.host.isSlotEnabled( this.groupNum );
|
||||
}
|
||||
public boolean renderDisabled() {
|
||||
return this.isRenderDisabled();
|
||||
}
|
||||
|
||||
public boolean renderDisabled()
|
||||
{
|
||||
return this.isRenderDisabled();
|
||||
}
|
||||
private boolean isRenderDisabled() {
|
||||
return this.renderDisabled;
|
||||
}
|
||||
|
||||
private boolean isRenderDisabled()
|
||||
{
|
||||
return this.renderDisabled;
|
||||
}
|
||||
public void setRenderDisabled(final boolean renderDisabled) {
|
||||
this.renderDisabled = renderDisabled;
|
||||
}
|
||||
|
||||
public void setRenderDisabled( final boolean renderDisabled )
|
||||
{
|
||||
this.renderDisabled = renderDisabled;
|
||||
}
|
||||
public int getSourceX() {
|
||||
return this.srcX;
|
||||
}
|
||||
|
||||
public int getSourceX()
|
||||
{
|
||||
return this.srcX;
|
||||
}
|
||||
|
||||
public int getSourceY()
|
||||
{
|
||||
return this.srcY;
|
||||
}
|
||||
public int getSourceY() {
|
||||
return this.srcY;
|
||||
}
|
||||
}
|
||||
+45
-47
@@ -11,55 +11,53 @@ import net.minecraft.util.IIcon;
|
||||
|
||||
public class SlotArmor extends AppEngSlot {
|
||||
|
||||
/*
|
||||
* The armor type that can be placed on that slot, it uses the same values
|
||||
* of armorType field on ItemArmor. Probably could've done just as well
|
||||
* with vanilla armor slot class. if so, this will be removed in the future.
|
||||
*/
|
||||
final int armorType;
|
||||
/*
|
||||
* The armor type that can be placed on that slot, it uses the same values
|
||||
* of armorType field on ItemArmor. Probably could've done just as well
|
||||
* with vanilla armor slot class. if so, this will be removed in the future.
|
||||
*/
|
||||
final int armorType;
|
||||
|
||||
final EntityPlayer player;
|
||||
final EntityPlayer player;
|
||||
|
||||
/**
|
||||
* Custom armor slot
|
||||
*
|
||||
* @param player
|
||||
* @param inventory
|
||||
* @param slot
|
||||
* @param x
|
||||
* @param y
|
||||
* @param armorType
|
||||
*/
|
||||
public SlotArmor(EntityPlayer player, IInventory inventory, int slot, int x, int y, int armorType) {
|
||||
super(inventory, slot, x, y);
|
||||
this.player = player;
|
||||
this.armorType = armorType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
/**
|
||||
* Custom armor slot
|
||||
*
|
||||
* @param player
|
||||
* @param inventory
|
||||
* @param slot
|
||||
* @param x
|
||||
* @param y
|
||||
* @param armorType
|
||||
*/
|
||||
public SlotArmor(EntityPlayer player, IInventory inventory, int slot, int x, int y, int armorType) {
|
||||
super(inventory, slot, x, y);
|
||||
this.player = player;
|
||||
this.armorType = armorType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the item being put into the slot is a valid armor type
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
Item item = (stack == null ? null : stack.getItem());
|
||||
return item != null && item.isValidArmor(stack, armorType, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the icon of the slot when no armor item is present
|
||||
*/
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getBackgroundIconIndex()
|
||||
{
|
||||
return ItemArmor.func_94602_b( this.armorType );
|
||||
}
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the item being put into the slot is a valid armor type
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
Item item = (stack == null ? null : stack.getItem());
|
||||
return item != null && item.isValidArmor(stack, armorType, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the icon of the slot when no armor item is present
|
||||
*/
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getBackgroundIconIndex() {
|
||||
return ItemArmor.func_94602_b(this.armorType);
|
||||
}
|
||||
}
|
||||
+37
-42
@@ -9,47 +9,42 @@ import net.minecraft.util.IIcon;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemBoosterBGIcon;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemInfinityBooster;
|
||||
|
||||
public class SlotBooster extends AppEngSlot
|
||||
{
|
||||
|
||||
/**
|
||||
* Custom slot for infinity booster card
|
||||
*
|
||||
* @param inv
|
||||
* @param index
|
||||
* @param xPos
|
||||
* @param yPos
|
||||
*/
|
||||
public SlotBooster(IInventory inv, int index, int xPos, int yPos)
|
||||
{
|
||||
super(inv, index, xPos, yPos);
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
|
||||
this.backgroundIcon = ItemBoosterBGIcon.getIcon();
|
||||
}
|
||||
}
|
||||
public class SlotBooster extends AppEngSlot {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getBackgroundIconIndex() {
|
||||
return this.backgroundIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures only the infinity booster card can be placed in the custom slot
|
||||
*
|
||||
* @param is
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack is)
|
||||
{
|
||||
if (is != null) {
|
||||
if (is.getItem() instanceof ItemInfinityBooster)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Everything returns false except an instance of our Item
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom slot for infinity booster card
|
||||
*
|
||||
* @param inv
|
||||
* @param index
|
||||
* @param xPos
|
||||
* @param yPos
|
||||
*/
|
||||
public SlotBooster(IInventory inv, int index, int xPos, int yPos) {
|
||||
super(inv, index, xPos, yPos);
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
|
||||
this.backgroundIcon = ItemBoosterBGIcon.getIcon();
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getBackgroundIconIndex() {
|
||||
return this.backgroundIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures only the infinity booster card can be placed in the custom slot
|
||||
*
|
||||
* @param is
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack is) {
|
||||
if (is != null) {
|
||||
if (is.getItem() instanceof ItemInfinityBooster) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Everything returns false except an instance of our Item
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+27
-33
@@ -4,43 +4,37 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotCraftingMatrix extends AppEngSlot {
|
||||
|
||||
public class SlotCraftingMatrix extends AppEngSlot
|
||||
{
|
||||
private final Container c;
|
||||
|
||||
private final Container c;
|
||||
public SlotCraftingMatrix(
|
||||
final Container c, final IInventory par1iInventory, final int par2, final int par3, final int par4) {
|
||||
super(par1iInventory, par2, par3, par4);
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
public SlotCraftingMatrix( final Container c, final IInventory par1iInventory, final int par2, final int par3, final int par4 )
|
||||
{
|
||||
super( par1iInventory, par2, par3, par4 );
|
||||
this.c = c;
|
||||
}
|
||||
@Override
|
||||
public void clearStack() {
|
||||
super.clearStack();
|
||||
this.c.onCraftMatrixChanged(this.inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearStack()
|
||||
{
|
||||
super.clearStack();
|
||||
this.c.onCraftMatrixChanged( this.inventory );
|
||||
}
|
||||
@Override
|
||||
public void putStack(final ItemStack par1ItemStack) {
|
||||
super.putStack(par1ItemStack);
|
||||
this.c.onCraftMatrixChanged(this.inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( final ItemStack par1ItemStack )
|
||||
{
|
||||
super.putStack( par1ItemStack );
|
||||
this.c.onCraftMatrixChanged( this.inventory );
|
||||
}
|
||||
@Override
|
||||
public boolean isPlayerSide() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerSide()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int par1 )
|
||||
{
|
||||
final ItemStack is = super.decrStackSize( par1 );
|
||||
this.c.onCraftMatrixChanged( this.inventory );
|
||||
return is;
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int par1) {
|
||||
final ItemStack is = super.decrStackSize(par1);
|
||||
this.c.onCraftMatrixChanged(this.inventory);
|
||||
return is;
|
||||
}
|
||||
}
|
||||
+187
-170
@@ -1,8 +1,5 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.common.container.slot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
@@ -17,6 +14,8 @@ import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorPlayerHand;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
@@ -26,201 +25,219 @@ import net.minecraft.item.crafting.IRecipe;
|
||||
|
||||
public class SlotCraftingTerm extends AppEngCraftingSlot {
|
||||
|
||||
private final IInventory craftInv;
|
||||
private final IInventory pattern;
|
||||
private final IInventory craftInv;
|
||||
private final IInventory pattern;
|
||||
|
||||
private final BaseActionSource mySrc;
|
||||
private final IEnergySource energySrc;
|
||||
private final IStorageMonitorable storage;
|
||||
private final BaseActionSource mySrc;
|
||||
private final IEnergySource energySrc;
|
||||
private final IStorageMonitorable storage;
|
||||
|
||||
public SlotCraftingTerm(final EntityPlayer player, final BaseActionSource mySrc, final IEnergySource energySrc,
|
||||
final IStorageMonitorable storage, final IInventory cMatrix, final IInventory secondMatrix,
|
||||
final IInventory output, final int x, final int y, final IContainerCraftingPacket ccp) {
|
||||
super(player, cMatrix, output, 0, x, y);
|
||||
this.energySrc = energySrc;
|
||||
this.storage = storage;
|
||||
this.mySrc = mySrc;
|
||||
this.pattern = cMatrix;
|
||||
this.craftInv = secondMatrix;
|
||||
}
|
||||
public SlotCraftingTerm(
|
||||
final EntityPlayer player,
|
||||
final BaseActionSource mySrc,
|
||||
final IEnergySource energySrc,
|
||||
final IStorageMonitorable storage,
|
||||
final IInventory cMatrix,
|
||||
final IInventory secondMatrix,
|
||||
final IInventory output,
|
||||
final int x,
|
||||
final int y,
|
||||
final IContainerCraftingPacket ccp) {
|
||||
super(player, cMatrix, output, 0, x, y);
|
||||
this.energySrc = energySrc;
|
||||
this.storage = storage;
|
||||
this.mySrc = mySrc;
|
||||
this.pattern = cMatrix;
|
||||
this.craftInv = secondMatrix;
|
||||
}
|
||||
|
||||
public IInventory getCraftingMatrix() {
|
||||
return this.craftInv;
|
||||
}
|
||||
public IInventory getCraftingMatrix() {
|
||||
return this.craftInv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(final EntityPlayer p, final ItemStack is) {
|
||||
}
|
||||
@Override
|
||||
public void onPickupFromSlot(final EntityPlayer p, final ItemStack is) {}
|
||||
|
||||
public void doClick(final InventoryAction action, final EntityPlayer who) {
|
||||
if (this.getStack() == null) {
|
||||
return;
|
||||
}
|
||||
if (Platform.isClient()) {
|
||||
return;
|
||||
}
|
||||
public void doClick(final InventoryAction action, final EntityPlayer who) {
|
||||
if (this.getStack() == null) {
|
||||
return;
|
||||
}
|
||||
if (Platform.isClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final IMEMonitor<IAEItemStack> inv = this.storage.getItemInventory();
|
||||
final int howManyPerCraft = this.getStack().stackSize;
|
||||
int maxTimesToCraft = 0;
|
||||
final IMEMonitor<IAEItemStack> inv = this.storage.getItemInventory();
|
||||
final int howManyPerCraft = this.getStack().stackSize;
|
||||
int maxTimesToCraft = 0;
|
||||
|
||||
InventoryAdaptor ia = null;
|
||||
if (action == InventoryAction.CRAFT_SHIFT) // craft into player
|
||||
// inventory...
|
||||
{
|
||||
ia = InventoryAdaptor.getAdaptor(who, null);
|
||||
maxTimesToCraft = (int) Math.floor((double) this.getStack().getMaxStackSize() / (double) howManyPerCraft);
|
||||
} else if (action == InventoryAction.CRAFT_STACK) // craft into hand,
|
||||
// full stack
|
||||
{
|
||||
ia = new AdaptorPlayerHand(who);
|
||||
maxTimesToCraft = (int) Math.floor((double) this.getStack().getMaxStackSize() / (double) howManyPerCraft);
|
||||
} else
|
||||
// pick up what was crafted...
|
||||
{
|
||||
ia = new AdaptorPlayerHand(who);
|
||||
maxTimesToCraft = 1;
|
||||
}
|
||||
InventoryAdaptor ia = null;
|
||||
if (action == InventoryAction.CRAFT_SHIFT) // craft into player
|
||||
// inventory...
|
||||
{
|
||||
ia = InventoryAdaptor.getAdaptor(who, null);
|
||||
maxTimesToCraft = (int) Math.floor((double) this.getStack().getMaxStackSize() / (double) howManyPerCraft);
|
||||
} else if (action == InventoryAction.CRAFT_STACK) // craft into hand,
|
||||
// full stack
|
||||
{
|
||||
ia = new AdaptorPlayerHand(who);
|
||||
maxTimesToCraft = (int) Math.floor((double) this.getStack().getMaxStackSize() / (double) howManyPerCraft);
|
||||
} else
|
||||
// pick up what was crafted...
|
||||
{
|
||||
ia = new AdaptorPlayerHand(who);
|
||||
maxTimesToCraft = 1;
|
||||
}
|
||||
|
||||
maxTimesToCraft = this.capCraftingAttempts(maxTimesToCraft);
|
||||
maxTimesToCraft = this.capCraftingAttempts(maxTimesToCraft);
|
||||
|
||||
if (ia == null) {
|
||||
return;
|
||||
}
|
||||
if (ia == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ItemStack rs = Platform.cloneItemStack(this.getStack());
|
||||
if (rs == null) {
|
||||
return;
|
||||
}
|
||||
final ItemStack rs = Platform.cloneItemStack(this.getStack());
|
||||
if (rs == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int x = 0; x < maxTimesToCraft; x++) {
|
||||
if (ia.simulateAdd(rs) == null) {
|
||||
final IItemList<IAEItemStack> all = inv.getStorageList();
|
||||
final ItemStack extra = ia.addItems(this.craftItem(who, rs, inv, all));
|
||||
if (extra != null) {
|
||||
final List<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
drops.add(extra);
|
||||
Platform.spawnDrops(who.worldObj, (int) who.posX, (int) who.posY, (int) who.posZ, drops);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int x = 0; x < maxTimesToCraft; x++) {
|
||||
if (ia.simulateAdd(rs) == null) {
|
||||
final IItemList<IAEItemStack> all = inv.getStorageList();
|
||||
final ItemStack extra = ia.addItems(this.craftItem(who, rs, inv, all));
|
||||
if (extra != null) {
|
||||
final List<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
drops.add(extra);
|
||||
Platform.spawnDrops(who.worldObj, (int) who.posX, (int) who.posY, (int) who.posZ, drops);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int capCraftingAttempts(final int maxTimesToCraft) {
|
||||
return maxTimesToCraft;
|
||||
}
|
||||
private int capCraftingAttempts(final int maxTimesToCraft) {
|
||||
return maxTimesToCraft;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private ItemStack craftItem(final EntityPlayer p, final ItemStack request, final IMEMonitor<IAEItemStack> inv,
|
||||
final IItemList all) {
|
||||
// update crafting matrix...
|
||||
ItemStack is = this.getStack();
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
private ItemStack craftItem(
|
||||
final EntityPlayer p, final ItemStack request, final IMEMonitor<IAEItemStack> inv, final IItemList all) {
|
||||
// update crafting matrix...
|
||||
ItemStack is = this.getStack();
|
||||
|
||||
if (is != null && Platform.isSameItem(request, is)) {
|
||||
final ItemStack[] set = new ItemStack[this.getPattern().getSizeInventory()];
|
||||
if (is != null && Platform.isSameItem(request, is)) {
|
||||
final ItemStack[] set = new ItemStack[this.getPattern().getSizeInventory()];
|
||||
|
||||
// add one of each item to the items on the board...
|
||||
if (Platform.isServer()) {
|
||||
final InventoryCrafting ic = new InventoryCrafting(new ContainerNull(), 3, 3);
|
||||
for (int x = 0; x < 9; x++) {
|
||||
ic.setInventorySlotContents(x, this.getPattern().getStackInSlot(x));
|
||||
}
|
||||
// add one of each item to the items on the board...
|
||||
if (Platform.isServer()) {
|
||||
final InventoryCrafting ic = new InventoryCrafting(new ContainerNull(), 3, 3);
|
||||
for (int x = 0; x < 9; x++) {
|
||||
ic.setInventorySlotContents(x, this.getPattern().getStackInSlot(x));
|
||||
}
|
||||
|
||||
final IRecipe r = Platform.findMatchingRecipe(ic, p.worldObj);
|
||||
final IRecipe r = Platform.findMatchingRecipe(ic, p.worldObj);
|
||||
|
||||
if (r == null) {
|
||||
final Item target = request.getItem();
|
||||
if (target.isDamageable() && target.isRepairable()) {
|
||||
boolean isBad = false;
|
||||
for (int x = 0; x < ic.getSizeInventory(); x++) {
|
||||
final ItemStack pis = ic.getStackInSlot(x);
|
||||
if (pis == null) {
|
||||
continue;
|
||||
}
|
||||
if (pis.getItem() != target) {
|
||||
isBad = true;
|
||||
}
|
||||
}
|
||||
if (!isBad) {
|
||||
super.onPickupFromSlot(p, is);
|
||||
// actually necessary to cleanup this case...
|
||||
p.openContainer.onCraftMatrixChanged(this.craftInv);
|
||||
return request;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (r == null) {
|
||||
final Item target = request.getItem();
|
||||
if (target.isDamageable() && target.isRepairable()) {
|
||||
boolean isBad = false;
|
||||
for (int x = 0; x < ic.getSizeInventory(); x++) {
|
||||
final ItemStack pis = ic.getStackInSlot(x);
|
||||
if (pis == null) {
|
||||
continue;
|
||||
}
|
||||
if (pis.getItem() != target) {
|
||||
isBad = true;
|
||||
}
|
||||
}
|
||||
if (!isBad) {
|
||||
super.onPickupFromSlot(p, is);
|
||||
// actually necessary to cleanup this case...
|
||||
p.openContainer.onCraftMatrixChanged(this.craftInv);
|
||||
return request;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
is = r.getCraftingResult(ic);
|
||||
is = r.getCraftingResult(ic);
|
||||
|
||||
if (inv != null) {
|
||||
for (int x = 0; x < this.getPattern().getSizeInventory(); x++) {
|
||||
if (this.getPattern().getStackInSlot(x) != null) {
|
||||
set[x] = Platform.extractItemsByRecipe(this.energySrc, this.mySrc, inv, p.worldObj, r, is,
|
||||
ic, this.getPattern().getStackInSlot(x), x, all, Actionable.MODULATE, null);
|
||||
ic.setInventorySlotContents(x, set[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (inv != null) {
|
||||
for (int x = 0; x < this.getPattern().getSizeInventory(); x++) {
|
||||
if (this.getPattern().getStackInSlot(x) != null) {
|
||||
set[x] = Platform.extractItemsByRecipe(
|
||||
this.energySrc,
|
||||
this.mySrc,
|
||||
inv,
|
||||
p.worldObj,
|
||||
r,
|
||||
is,
|
||||
ic,
|
||||
this.getPattern().getStackInSlot(x),
|
||||
x,
|
||||
all,
|
||||
Actionable.MODULATE,
|
||||
null);
|
||||
ic.setInventorySlotContents(x, set[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.preCraft(p, inv, set, is)) {
|
||||
this.makeItem(p, is);
|
||||
if (this.preCraft(p, inv, set, is)) {
|
||||
this.makeItem(p, is);
|
||||
|
||||
this.postCraft(p, inv, set, is);
|
||||
}
|
||||
this.postCraft(p, inv, set, is);
|
||||
}
|
||||
|
||||
// shouldn't be necessary...
|
||||
p.openContainer.onCraftMatrixChanged(this.craftInv);
|
||||
// shouldn't be necessary...
|
||||
p.openContainer.onCraftMatrixChanged(this.craftInv);
|
||||
|
||||
return is;
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean preCraft(final EntityPlayer p, final IMEMonitor<IAEItemStack> inv, final ItemStack[] set,
|
||||
final ItemStack result) {
|
||||
return true;
|
||||
}
|
||||
private boolean preCraft(
|
||||
final EntityPlayer p, final IMEMonitor<IAEItemStack> inv, final ItemStack[] set, final ItemStack result) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void makeItem(final EntityPlayer p, final ItemStack is) {
|
||||
super.onPickupFromSlot(p, is);
|
||||
}
|
||||
private void makeItem(final EntityPlayer p, final ItemStack is) {
|
||||
super.onPickupFromSlot(p, is);
|
||||
}
|
||||
|
||||
private void postCraft(final EntityPlayer p, final IMEMonitor<IAEItemStack> inv, final ItemStack[] set,
|
||||
final ItemStack result) {
|
||||
final List<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
private void postCraft(
|
||||
final EntityPlayer p, final IMEMonitor<IAEItemStack> inv, final ItemStack[] set, final ItemStack result) {
|
||||
final List<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
|
||||
// add one of each item to the items on the board...
|
||||
if (Platform.isServer()) {
|
||||
// set new items onto the crafting table...
|
||||
for (int x = 0; x < this.craftInv.getSizeInventory(); x++) {
|
||||
if (this.craftInv.getStackInSlot(x) == null) {
|
||||
this.craftInv.setInventorySlotContents(x, set[x]);
|
||||
} else if (set[x] != null) {
|
||||
// eek! put it back!
|
||||
final IAEItemStack fail = inv.injectItems(AEItemStack.create(set[x]), Actionable.MODULATE,
|
||||
this.mySrc);
|
||||
if (fail != null) {
|
||||
drops.add(fail.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// add one of each item to the items on the board...
|
||||
if (Platform.isServer()) {
|
||||
// set new items onto the crafting table...
|
||||
for (int x = 0; x < this.craftInv.getSizeInventory(); x++) {
|
||||
if (this.craftInv.getStackInSlot(x) == null) {
|
||||
this.craftInv.setInventorySlotContents(x, set[x]);
|
||||
} else if (set[x] != null) {
|
||||
// eek! put it back!
|
||||
final IAEItemStack fail =
|
||||
inv.injectItems(AEItemStack.create(set[x]), Actionable.MODULATE, this.mySrc);
|
||||
if (fail != null) {
|
||||
drops.add(fail.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (drops.size() > 0) {
|
||||
Platform.spawnDrops(p.worldObj, (int) p.posX, (int) p.posY, (int) p.posZ, drops);
|
||||
}
|
||||
}
|
||||
if (drops.size() > 0) {
|
||||
Platform.spawnDrops(p.worldObj, (int) p.posX, (int) p.posY, (int) p.posZ, drops);
|
||||
}
|
||||
}
|
||||
|
||||
IInventory getPattern() {
|
||||
return this.pattern;
|
||||
}
|
||||
}
|
||||
IInventory getPattern() {
|
||||
return this.pattern;
|
||||
}
|
||||
}
|
||||
+12
-17
@@ -4,24 +4,19 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotDisabled extends AppEngSlot {
|
||||
|
||||
public class SlotDisabled extends AppEngSlot
|
||||
{
|
||||
public SlotDisabled(final IInventory par1iInventory, final int slotIndex, final int x, final int y) {
|
||||
super(par1iInventory, slotIndex, x, y);
|
||||
}
|
||||
|
||||
public SlotDisabled( final IInventory par1iInventory, final int slotIndex, final int x, final int y )
|
||||
{
|
||||
super( par1iInventory, slotIndex, x, y );
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final EntityPlayer par1EntityPlayer )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+25
-35
@@ -4,46 +4,36 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotFake extends AppEngSlot {
|
||||
|
||||
public class SlotFake extends AppEngSlot
|
||||
{
|
||||
public SlotFake(final IInventory inv, final int idx, final int x, final int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
|
||||
public SlotFake( final IInventory inv, final int idx, final int x, final int y )
|
||||
{
|
||||
super( inv, idx, x, y );
|
||||
}
|
||||
@Override
|
||||
public void onPickupFromSlot(final EntityPlayer par1EntityPlayer, final ItemStack par2ItemStack) {}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot( final EntityPlayer par1EntityPlayer, final ItemStack par2ItemStack )
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int par1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int par1 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void putStack(ItemStack is) {
|
||||
if (is != null) {
|
||||
is = is.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( ItemStack is )
|
||||
{
|
||||
if( is != null )
|
||||
{
|
||||
is = is.copy();
|
||||
}
|
||||
super.putStack(is);
|
||||
}
|
||||
|
||||
super.putStack( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final EntityPlayer par1EntityPlayer )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+4
-7
@@ -2,12 +2,9 @@ package net.p455w0rd.wirelesscraftingterminal.common.container.slot;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
public class SlotFakeCraftingMatrix extends SlotFake {
|
||||
|
||||
public class SlotFakeCraftingMatrix extends SlotFake
|
||||
{
|
||||
|
||||
public SlotFakeCraftingMatrix( final IInventory inv, final int idx, final int x, final int y )
|
||||
{
|
||||
super( inv, idx, x, y );
|
||||
}
|
||||
public SlotFakeCraftingMatrix(final IInventory inv, final int idx, final int x, final int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
}
|
||||
+28
-37
@@ -4,47 +4,38 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotInaccessible extends AppEngSlot {
|
||||
|
||||
public class SlotInaccessible extends AppEngSlot
|
||||
{
|
||||
private ItemStack dspStack = null;
|
||||
|
||||
private ItemStack dspStack = null;
|
||||
public SlotInaccessible(final IInventory i, final int slotIdx, final int x, final int y) {
|
||||
super(i, slotIdx, x, y);
|
||||
}
|
||||
|
||||
public SlotInaccessible( final IInventory i, final int slotIdx, final int x, final int y )
|
||||
{
|
||||
super( i, slotIdx, x, y );
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack i )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void onSlotChanged() {
|
||||
super.onSlotChanged();
|
||||
this.dspStack = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged()
|
||||
{
|
||||
super.onSlotChanged();
|
||||
this.dspStack = null;
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final EntityPlayer par1EntityPlayer )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDisplayStack()
|
||||
{
|
||||
if( this.dspStack == null )
|
||||
{
|
||||
final ItemStack dsp = super.getDisplayStack();
|
||||
if( dsp != null )
|
||||
{
|
||||
this.dspStack = dsp.copy();
|
||||
}
|
||||
}
|
||||
return this.dspStack;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getDisplayStack() {
|
||||
if (this.dspStack == null) {
|
||||
final ItemStack dsp = super.getDisplayStack();
|
||||
if (dsp != null) {
|
||||
this.dspStack = dsp.copy();
|
||||
}
|
||||
}
|
||||
return this.dspStack;
|
||||
}
|
||||
}
|
||||
+7
-8
@@ -5,14 +5,13 @@ import net.minecraft.item.ItemStack;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemMagnet;
|
||||
|
||||
public class SlotMagnet extends AppEngSlot {
|
||||
|
||||
public SlotMagnet(IInventory inv, int xPos, int yPos) {
|
||||
super(inv, 0, xPos, yPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack is) {
|
||||
return ((is != null) && (is.getItem() instanceof ItemMagnet));
|
||||
}
|
||||
public SlotMagnet(IInventory inv, int xPos, int yPos) {
|
||||
super(inv, 0, xPos, yPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack is) {
|
||||
return ((is != null) && (is.getItem() instanceof ItemMagnet));
|
||||
}
|
||||
}
|
||||
+54
-54
@@ -7,69 +7,69 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotMagnetFilter extends Slot {
|
||||
|
||||
private boolean isPhantom;
|
||||
private boolean canAdjustPhantom = true;
|
||||
private boolean canShift = true;
|
||||
private int stackLimit;
|
||||
private boolean isPhantom;
|
||||
private boolean canAdjustPhantom = true;
|
||||
private boolean canShift = true;
|
||||
private int stackLimit;
|
||||
|
||||
public SlotMagnetFilter(IInventory inventory, int slotIndex, int xPos, int yPos) {
|
||||
super(inventory, slotIndex, xPos, yPos);
|
||||
if (inventory == null) {
|
||||
throw new IllegalArgumentException("Inventory must not be null");
|
||||
}
|
||||
this.stackLimit = -1;
|
||||
}
|
||||
public SlotMagnetFilter(IInventory inventory, int slotIndex, int xPos, int yPos) {
|
||||
super(inventory, slotIndex, xPos, yPos);
|
||||
if (inventory == null) {
|
||||
throw new IllegalArgumentException("Inventory must not be null");
|
||||
}
|
||||
this.stackLimit = -1;
|
||||
}
|
||||
|
||||
public SlotMagnetFilter setPhantom() {
|
||||
isPhantom = true;
|
||||
return this;
|
||||
}
|
||||
public SlotMagnetFilter setPhantom() {
|
||||
isPhantom = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SlotMagnetFilter blockShift() {
|
||||
canShift = false;
|
||||
return this;
|
||||
}
|
||||
public SlotMagnetFilter blockShift() {
|
||||
canShift = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack itemStack) {
|
||||
if (!isPhantom() || canAdjustPhantom()) {
|
||||
super.putStack(itemStack);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void putStack(ItemStack itemStack) {
|
||||
if (!isPhantom() || canAdjustPhantom()) {
|
||||
super.putStack(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
public SlotMagnetFilter setCanAdjustPhantom(boolean canAdjust) {
|
||||
this.canAdjustPhantom = canAdjust;
|
||||
return this;
|
||||
}
|
||||
public SlotMagnetFilter setCanAdjustPhantom(boolean canAdjust) {
|
||||
this.canAdjustPhantom = canAdjust;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SlotMagnetFilter setStackLimit(int limit) {
|
||||
this.stackLimit = limit;
|
||||
return this;
|
||||
}
|
||||
public SlotMagnetFilter setStackLimit(int limit) {
|
||||
this.stackLimit = limit;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isPhantom() {
|
||||
return this.isPhantom;
|
||||
}
|
||||
public boolean isPhantom() {
|
||||
return this.isPhantom;
|
||||
}
|
||||
|
||||
public boolean canAdjustPhantom() {
|
||||
return canAdjustPhantom;
|
||||
}
|
||||
public boolean canAdjustPhantom() {
|
||||
return canAdjustPhantom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer stack) {
|
||||
return !isPhantom();
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer stack) {
|
||||
return !isPhantom();
|
||||
}
|
||||
|
||||
public boolean canShift() {
|
||||
return canShift;
|
||||
}
|
||||
public boolean canShift() {
|
||||
return canShift;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
if (stackLimit < 0) {
|
||||
return super.getSlotStackLimit();
|
||||
} else {
|
||||
return stackLimit;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
if (stackLimit < 0) {
|
||||
return super.getSlotStackLimit();
|
||||
} else {
|
||||
return stackLimit;
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
-13
@@ -3,19 +3,15 @@ package net.p455w0rd.wirelesscraftingterminal.common.container.slot;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotOutput extends AppEngSlot {
|
||||
|
||||
public class SlotOutput extends AppEngSlot
|
||||
{
|
||||
public SlotOutput(final IInventory a, final int b, final int c, final int d, final int i) {
|
||||
super(a, b, c, d);
|
||||
this.setIIcon(i);
|
||||
}
|
||||
|
||||
public SlotOutput( final IInventory a, final int b, final int c, final int d, final int i )
|
||||
{
|
||||
super( a, b, c, d );
|
||||
this.setIIcon( i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack i )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack i) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+5
-7
@@ -2,12 +2,10 @@ package net.p455w0rd.wirelesscraftingterminal.common.container.slot;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
public class SlotPlayerHotBar extends AppEngSlot
|
||||
{
|
||||
public class SlotPlayerHotBar extends AppEngSlot {
|
||||
|
||||
public SlotPlayerHotBar( final IInventory par1iInventory, final int par2, final int par3, final int par4 )
|
||||
{
|
||||
super( par1iInventory, par2, par3, par4 );
|
||||
this.setPlayerSide( true );
|
||||
}
|
||||
public SlotPlayerHotBar(final IInventory par1iInventory, final int par2, final int par3, final int par4) {
|
||||
super(par1iInventory, par2, par3, par4);
|
||||
this.setPlayerSide(true);
|
||||
}
|
||||
}
|
||||
+6
-9
@@ -2,16 +2,13 @@ package net.p455w0rd.wirelesscraftingterminal.common.container.slot;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
// there is nothing special about this slot, its simply used to represent the players inventory, vs a container slot.
|
||||
|
||||
//there is nothing special about this slot, its simply used to represent the players inventory, vs a container slot.
|
||||
public class SlotPlayerInv extends AppEngSlot {
|
||||
|
||||
public class SlotPlayerInv extends AppEngSlot
|
||||
{
|
||||
public SlotPlayerInv(final IInventory par1iInventory, final int par2, final int par3, final int par4) {
|
||||
super(par1iInventory, par2, par3, par4);
|
||||
|
||||
public SlotPlayerInv( final IInventory par1iInventory, final int par2, final int par3, final int par4 )
|
||||
{
|
||||
super( par1iInventory, par2, par3, par4 );
|
||||
|
||||
this.setPlayerSide( true );
|
||||
}
|
||||
this.setPlayerSide(true);
|
||||
}
|
||||
}
|
||||
+91
-89
@@ -9,103 +9,105 @@ import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
|
||||
|
||||
public class SlotTrash extends AppEngSlot {
|
||||
|
||||
private final EntityPlayer entityPlayer;
|
||||
private ItemStack itemStack;
|
||||
private boolean shouldDeleteMouseStack;
|
||||
private String name = "TrashSlot";
|
||||
private final EntityPlayer entityPlayer;
|
||||
private ItemStack itemStack;
|
||||
private boolean shouldDeleteMouseStack;
|
||||
private String name = "TrashSlot";
|
||||
|
||||
public SlotTrash(IInventory inv, int x, int y, EntityPlayer player) {
|
||||
super(null, 0, x, y);
|
||||
entityPlayer = player;
|
||||
readNBT();
|
||||
}
|
||||
public SlotTrash(IInventory inv, int x, int y, EntityPlayer player) {
|
||||
super(null, 0, x, y);
|
||||
entityPlayer = player;
|
||||
readNBT();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
return itemStack;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasStack() {
|
||||
return itemStack != null;
|
||||
}
|
||||
@Override
|
||||
public boolean getHasStack() {
|
||||
return itemStack != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack itemStack) {
|
||||
shouldDeleteMouseStack = (this.itemStack != null);
|
||||
this.itemStack = itemStack;
|
||||
writeNBT();
|
||||
}
|
||||
@Override
|
||||
public void putStack(ItemStack itemStack) {
|
||||
shouldDeleteMouseStack = (this.itemStack != null);
|
||||
this.itemStack = itemStack;
|
||||
writeNBT();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged() {
|
||||
if (itemStack != null && shouldDeleteMouseStack) {
|
||||
entityPlayer.inventory.setItemStack(null);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onSlotChanged() {
|
||||
if (itemStack != null && shouldDeleteMouseStack) {
|
||||
entityPlayer.inventory.setItemStack(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int amount) {
|
||||
if (itemStack != null) {
|
||||
ItemStack returnStack;
|
||||
if (itemStack.stackSize <= amount) {
|
||||
returnStack = itemStack;
|
||||
itemStack = null;
|
||||
shouldDeleteMouseStack = true;
|
||||
writeNBT();
|
||||
return returnStack;
|
||||
} else {
|
||||
returnStack = itemStack.splitStack(amount);
|
||||
shouldDeleteMouseStack = false;
|
||||
if (itemStack.stackSize == 0) {
|
||||
itemStack = null;
|
||||
shouldDeleteMouseStack = true;
|
||||
}
|
||||
writeNBT();
|
||||
return returnStack;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(int amount) {
|
||||
if (itemStack != null) {
|
||||
ItemStack returnStack;
|
||||
if (itemStack.stackSize <= amount) {
|
||||
returnStack = itemStack;
|
||||
itemStack = null;
|
||||
shouldDeleteMouseStack = true;
|
||||
writeNBT();
|
||||
return returnStack;
|
||||
} else {
|
||||
returnStack = itemStack.splitStack(amount);
|
||||
shouldDeleteMouseStack = false;
|
||||
if (itemStack.stackSize == 0) {
|
||||
itemStack = null;
|
||||
shouldDeleteMouseStack = true;
|
||||
}
|
||||
writeNBT();
|
||||
return returnStack;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void readNBT() {
|
||||
NBTTagCompound nbtTagCompound = RandomUtils.getWirelessTerm(entityPlayer.inventory).getTagCompound();
|
||||
NBTTagList tagList = nbtTagCompound.getTagList(this.name, 10);
|
||||
NBTTagCompound tagCompound = tagList.getCompoundTagAt(0);
|
||||
if (tagCompound != null) {
|
||||
itemStack = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
public void readNBT() {
|
||||
NBTTagCompound nbtTagCompound =
|
||||
RandomUtils.getWirelessTerm(entityPlayer.inventory).getTagCompound();
|
||||
NBTTagList tagList = nbtTagCompound.getTagList(this.name, 10);
|
||||
NBTTagCompound tagCompound = tagList.getCompoundTagAt(0);
|
||||
if (tagCompound != null) {
|
||||
itemStack = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeNBT() {
|
||||
NBTTagCompound nbtTagCompound = RandomUtils.getWirelessTerm(entityPlayer.inventory).getTagCompound();
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
if (itemStack != null) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
itemStack.writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
nbtTagCompound.setTag(this.name, tagList);
|
||||
}
|
||||
|
||||
public void clearStack() {
|
||||
if (itemStack != null) {
|
||||
itemStack = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void writeNBT() {
|
||||
NBTTagCompound nbtTagCompound =
|
||||
RandomUtils.getWirelessTerm(entityPlayer.inventory).getTagCompound();
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
if (itemStack != null) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
itemStack.writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
nbtTagCompound.setTag(this.name, tagList);
|
||||
}
|
||||
|
||||
public void clearStack() {
|
||||
if (itemStack != null) {
|
||||
itemStack = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-11
@@ -4,18 +4,17 @@ import appeng.api.AEApi;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class SlotViewCell extends AppEngSlot {
|
||||
|
||||
public SlotViewCell(IInventory inv, int index, int xPos, int yPos) {
|
||||
super(inv, index, xPos, yPos);
|
||||
}
|
||||
public SlotViewCell(IInventory inv, int index, int xPos, int yPos) {
|
||||
super(inv, index, xPos, yPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack is) {
|
||||
if( is == null || is.getItem() == null) {
|
||||
return false;
|
||||
}
|
||||
return AEApi.instance().definitions().items().viewCell().isSameAs( is );
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack is) {
|
||||
if (is == null || is.getItem() == null) {
|
||||
return false;
|
||||
}
|
||||
return AEApi.instance().definitions().items().viewCell().isSameAs(is);
|
||||
}
|
||||
}
|
||||
+104
-108
@@ -9,129 +9,125 @@ import net.p455w0rd.wirelesscraftingterminal.items.ItemInfinityBooster;
|
||||
|
||||
public class WCTInventoryBooster implements IInventory {
|
||||
|
||||
private String name = "BoosterSlot";
|
||||
private final ItemStack invItem;
|
||||
private ItemStack[] inventory;
|
||||
private String name = "BoosterSlot";
|
||||
private final ItemStack invItem;
|
||||
private ItemStack[] inventory;
|
||||
|
||||
public WCTInventoryBooster(ItemStack stack) {
|
||||
super();
|
||||
inventory = new ItemStack[1];
|
||||
invItem = stack;
|
||||
if (stack != null) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
readFromNBT(stack.getTagCompound());
|
||||
}
|
||||
}
|
||||
public WCTInventoryBooster(ItemStack stack) {
|
||||
super();
|
||||
inventory = new ItemStack[1];
|
||||
invItem = stack;
|
||||
if (stack != null) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
readFromNBT(stack.getTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory[slot];
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory[slot];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return name;
|
||||
}
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return name.length() > 0;
|
||||
}
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return name.length() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
ItemStack stack = getStackInSlot(slot);
|
||||
if (stack != null) {
|
||||
if (stack.stackSize > amount) {
|
||||
stack = stack.splitStack(amount);
|
||||
markDirty();
|
||||
}
|
||||
else {
|
||||
setInventorySlotContents(slot, null);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
ItemStack stack = getStackInSlot(slot);
|
||||
if (stack != null) {
|
||||
if (stack.stackSize > amount) {
|
||||
stack = stack.splitStack(amount);
|
||||
markDirty();
|
||||
} else {
|
||||
setInventorySlotContents(slot, null);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (inventory[slot] != null) {
|
||||
ItemStack itemStack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return itemStack;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (inventory[slot] != null) {
|
||||
ItemStack itemStack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return itemStack;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory[slot] = stack;
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory[slot] = stack;
|
||||
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
writeNBT(invItem.getTagCompound());
|
||||
}
|
||||
@Override
|
||||
public void markDirty() {
|
||||
writeNBT(invItem.getTagCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
|
||||
return (itemstack.getItem() instanceof ItemInfinityBooster);
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
|
||||
return (itemstack.getItem() instanceof ItemInfinityBooster);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = nbtTagCompound.getTagList(this.name, 10);
|
||||
inventory = new ItemStack[this.getSizeInventory()];
|
||||
for (int i = 0; i < tagList.tagCount(); ++i) {
|
||||
NBTTagCompound tagCompound = (NBTTagCompound) tagList.getCompoundTagAt(i);
|
||||
int slot = tagCompound.getInteger("Slot");
|
||||
if (slot >= 0 && slot < inventory.length) {
|
||||
inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = nbtTagCompound.getTagList(this.name, 10);
|
||||
inventory = new ItemStack[this.getSizeInventory()];
|
||||
for (int i = 0; i < tagList.tagCount(); ++i) {
|
||||
NBTTagCompound tagCompound = (NBTTagCompound) tagList.getCompoundTagAt(i);
|
||||
int slot = tagCompound.getInteger("Slot");
|
||||
if (slot >= 0 && slot < inventory.length) {
|
||||
inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
|
||||
if (inventory[currentIndex] != null) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setInteger("Slot", currentIndex);
|
||||
inventory[currentIndex].writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
nbtTagCompound.setTag(this.name, tagList);
|
||||
}
|
||||
public void writeNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
|
||||
if (inventory[currentIndex] != null) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setInteger("Slot", currentIndex);
|
||||
inventory[currentIndex].writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
nbtTagCompound.setTag(this.name, tagList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
@Override
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
@Override
|
||||
public void closeInventory() {}
|
||||
}
|
||||
+46
-50
@@ -6,67 +6,63 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public class WCTInventoryCraftResult implements IInventory {
|
||||
|
||||
private ItemStack[] stackResult = new ItemStack[1];
|
||||
private ItemStack[] stackResult = new ItemStack[1];
|
||||
|
||||
public int getSizeInventory() {
|
||||
return 1;
|
||||
}
|
||||
public int getSizeInventory() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return this.stackResult[0];
|
||||
}
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return this.stackResult[0];
|
||||
}
|
||||
|
||||
public String getInventoryName() {
|
||||
return "CraftResult";
|
||||
}
|
||||
public String getInventoryName() {
|
||||
return "CraftResult";
|
||||
}
|
||||
|
||||
public boolean hasCustomInventoryName() {
|
||||
return true;
|
||||
}
|
||||
public boolean hasCustomInventoryName() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
if (this.stackResult[0] != null) {
|
||||
ItemStack itemstack = this.stackResult[0];
|
||||
this.stackResult[0] = null;
|
||||
return itemstack;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
if (this.stackResult[0] != null) {
|
||||
ItemStack itemstack = this.stackResult[0];
|
||||
this.stackResult[0] = null;
|
||||
return itemstack;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (this.stackResult[0] != null) {
|
||||
ItemStack itemstack = this.stackResult[0];
|
||||
this.stackResult[0] = null;
|
||||
return itemstack;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (this.stackResult[0] != null) {
|
||||
ItemStack itemstack = this.stackResult[0];
|
||||
this.stackResult[0] = null;
|
||||
return itemstack;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setInventorySlotContents(int slot, ItemStack is) {
|
||||
this.stackResult[0] = is;
|
||||
}
|
||||
public void setInventorySlotContents(int slot, ItemStack is) {
|
||||
this.stackResult[0] = is;
|
||||
}
|
||||
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
public void markDirty() {
|
||||
}
|
||||
public void markDirty() {}
|
||||
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void openInventory() {
|
||||
}
|
||||
public void openInventory() {}
|
||||
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
|
||||
return true;
|
||||
}
|
||||
public void closeInventory() {}
|
||||
|
||||
public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+161
-162
@@ -15,194 +15,193 @@ import net.p455w0rd.wirelesscraftingterminal.api.IWirelessCraftingTerminalItem;
|
||||
|
||||
public class WCTInventoryCrafting extends AppEngInternalInventory {
|
||||
|
||||
private ItemStack[] stackList;
|
||||
private int inventoryWidth;
|
||||
private Container eventHandler;
|
||||
private final ItemStack invItem;
|
||||
private IAEAppEngInventory te;
|
||||
private final int size;
|
||||
private boolean enableClientEvents = false;
|
||||
private ItemStack[] stackList;
|
||||
private int inventoryWidth;
|
||||
private Container eventHandler;
|
||||
private final ItemStack invItem;
|
||||
private IAEAppEngInventory te;
|
||||
private final int size;
|
||||
private boolean enableClientEvents = false;
|
||||
|
||||
public WCTInventoryCrafting(Container container, int rows, int cols, ItemStack is) {
|
||||
super((IAEAppEngInventory) container, rows * cols);
|
||||
size = rows * cols;
|
||||
this.stackList = new ItemStack[size];
|
||||
this.eventHandler = container;
|
||||
this.inventoryWidth = rows;
|
||||
this.invItem = is;
|
||||
this.setTileEntity((IAEAppEngInventory) container);
|
||||
}
|
||||
public WCTInventoryCrafting(Container container, int rows, int cols, ItemStack is) {
|
||||
super((IAEAppEngInventory) container, rows * cols);
|
||||
size = rows * cols;
|
||||
this.stackList = new ItemStack[size];
|
||||
this.eventHandler = container;
|
||||
this.inventoryWidth = rows;
|
||||
this.invItem = is;
|
||||
this.setTileEntity((IAEAppEngInventory) container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return this.stackList.length;
|
||||
}
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return this.stackList.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return slot >= this.getSizeInventory() ? null : this.stackList[slot];
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return slot >= this.getSizeInventory() ? null : this.stackList[slot];
|
||||
}
|
||||
|
||||
public ItemStack getStackInRowAndColumn(int row, int col) {
|
||||
if (row >= 0 && row < this.inventoryWidth) {
|
||||
int k = row + col * this.inventoryWidth;
|
||||
return this.getStackInSlot(k);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public ItemStack getStackInRowAndColumn(int row, int col) {
|
||||
if (row >= 0 && row < this.inventoryWidth) {
|
||||
int k = row + col * this.inventoryWidth;
|
||||
return this.getStackInSlot(k);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getInventoryName() {
|
||||
return "crafting";
|
||||
}
|
||||
public String getInventoryName() {
|
||||
return "crafting";
|
||||
}
|
||||
|
||||
public boolean hasCustomInventoryName() {
|
||||
return true;
|
||||
}
|
||||
public boolean hasCustomInventoryName() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (this.stackList[slot] != null) {
|
||||
ItemStack itemstack = this.stackList[slot];
|
||||
this.stackList[slot] = null;
|
||||
return itemstack;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (this.stackList[slot] != null) {
|
||||
ItemStack itemstack = this.stackList[slot];
|
||||
this.stackList[slot] = null;
|
||||
return itemstack;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int slot, final int qty) {
|
||||
if (this.stackList[slot] != null) {
|
||||
final ItemStack split = this.getStackInSlot(slot);
|
||||
ItemStack ns = null;
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int slot, final int qty) {
|
||||
if (this.stackList[slot] != null) {
|
||||
final ItemStack split = this.getStackInSlot(slot);
|
||||
ItemStack ns = null;
|
||||
|
||||
if (qty >= split.stackSize) {
|
||||
ns = this.stackList[slot];
|
||||
this.stackList[slot] = null;
|
||||
} else {
|
||||
ns = split.splitStack(qty);
|
||||
}
|
||||
if (qty >= split.stackSize) {
|
||||
ns = this.stackList[slot];
|
||||
this.stackList[slot] = null;
|
||||
} else {
|
||||
ns = split.splitStack(qty);
|
||||
}
|
||||
|
||||
if (this.getTileEntity() != null && this.eventsEnabled()) {
|
||||
this.getTileEntity().onChangeInventory(this, slot, InvOperation.decreaseStackSize, ns, null);
|
||||
}
|
||||
if (this.getTileEntity() != null && this.eventsEnabled()) {
|
||||
this.getTileEntity().onChangeInventory(this, slot, InvOperation.decreaseStackSize, ns, null);
|
||||
}
|
||||
|
||||
this.markDirty();
|
||||
return ns;
|
||||
}
|
||||
this.markDirty();
|
||||
return ns;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean eventsEnabled() {
|
||||
return Platform.isServer() || this.isEnableClientEvents();
|
||||
}
|
||||
@Override
|
||||
protected boolean eventsEnabled() {
|
||||
return Platform.isServer() || this.isEnableClientEvents();
|
||||
}
|
||||
|
||||
private boolean isEnableClientEvents() {
|
||||
return this.enableClientEvents;
|
||||
}
|
||||
private boolean isEnableClientEvents() {
|
||||
return this.enableClientEvents;
|
||||
}
|
||||
|
||||
public void setEnableClientEvents(final boolean enableClientEvents) {
|
||||
this.enableClientEvents = enableClientEvents;
|
||||
}
|
||||
public void setEnableClientEvents(final boolean enableClientEvents) {
|
||||
this.enableClientEvents = enableClientEvents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
for (int x = 0; x < this.size; x++) {
|
||||
if (this.getStackInSlot(x) != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
for (int x = 0; x < this.size; x++) {
|
||||
if (this.getStackInSlot(x) != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public IMEInventory getMEInventory() {
|
||||
return new MEIInventoryWrapper(this, null);
|
||||
}
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public IMEInventory getMEInventory() {
|
||||
return new MEIInventoryWrapper(this, null);
|
||||
}
|
||||
|
||||
private IAEAppEngInventory getTileEntity() {
|
||||
return this.te;
|
||||
}
|
||||
private IAEAppEngInventory getTileEntity() {
|
||||
return this.te;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTileEntity(final IAEAppEngInventory te) {
|
||||
this.te = te;
|
||||
}
|
||||
@Override
|
||||
public void setTileEntity(final IAEAppEngInventory te) {
|
||||
this.te = te;
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public ItemStack decrStackSize(int slot, int amount) { if
|
||||
* (this.stackList[slot] != null) { ItemStack itemstack; if
|
||||
* (this.stackList[slot].stackSize <= amount) { itemstack =
|
||||
* this.stackList[slot]; this.stackList[slot] = null;
|
||||
* this.eventHandler.onCraftMatrixChanged(this); return itemstack; } else {
|
||||
* itemstack = this.stackList[slot].splitStack(amount);
|
||||
*
|
||||
* if (this.stackList[slot].stackSize == 0) { this.stackList[slot] = null; }
|
||||
*
|
||||
* this.eventHandler.onCraftMatrixChanged(this); return itemstack; } } else
|
||||
* { return getStackInSlot(slot); } }
|
||||
*/
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
this.stackList[slot] = stack;
|
||||
this.eventHandler.onCraftMatrixChanged(this);
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
/*
|
||||
* @Override public ItemStack decrStackSize(int slot, int amount) { if
|
||||
* (this.stackList[slot] != null) { ItemStack itemstack; if
|
||||
* (this.stackList[slot].stackSize <= amount) { itemstack =
|
||||
* this.stackList[slot]; this.stackList[slot] = null;
|
||||
* this.eventHandler.onCraftMatrixChanged(this); return itemstack; } else {
|
||||
* itemstack = this.stackList[slot].splitStack(amount);
|
||||
*
|
||||
* if (this.stackList[slot].stackSize == 0) { this.stackList[slot] = null; }
|
||||
*
|
||||
* this.eventHandler.onCraftMatrixChanged(this); return itemstack; } } else
|
||||
* { return getStackInSlot(slot); } }
|
||||
*/
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
this.stackList[slot] = stack;
|
||||
this.eventHandler.onCraftMatrixChanged(this);
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty(final int slotIndex) {
|
||||
if (this.getTileEntity() != null && this.eventsEnabled()) {
|
||||
this.getTileEntity().onChangeInventory(this, slotIndex, InvOperation.markDirty, null, null);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void markDirty(final int slotIndex) {
|
||||
if (this.getTileEntity() != null && this.eventsEnabled()) {
|
||||
this.getTileEntity().onChangeInventory(this, slotIndex, InvOperation.markDirty, null, null);
|
||||
}
|
||||
if (getStackInSlot(slotIndex) != null && getStackInSlot(slotIndex).stackSize == 0) stackList[slotIndex] = null;
|
||||
writeNBT(invItem.getTagCompound());
|
||||
}
|
||||
|
||||
public void markDirty() {
|
||||
if (this.getTileEntity() != null && this.eventsEnabled()) {
|
||||
this.getTileEntity().onChangeInventory(this, -1, InvOperation.markDirty, null, null);
|
||||
}
|
||||
for (int i = 0; i < getSizeInventory(); ++i) {
|
||||
if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) {
|
||||
stackList[i] = null;
|
||||
}
|
||||
}
|
||||
writeNBT(invItem.getTagCompound());
|
||||
}
|
||||
public void markDirty() {
|
||||
if (this.getTileEntity() != null && this.eventsEnabled()) {
|
||||
this.getTileEntity().onChangeInventory(this, -1, InvOperation.markDirty, null, null);
|
||||
}
|
||||
for (int i = 0; i < getSizeInventory(); ++i) {
|
||||
if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) {
|
||||
stackList[i] = null;
|
||||
}
|
||||
}
|
||||
writeNBT(invItem.getTagCompound());
|
||||
}
|
||||
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void openInventory() {
|
||||
}
|
||||
public void openInventory() {}
|
||||
|
||||
public void closeInventory() {
|
||||
}
|
||||
public void closeInventory() {}
|
||||
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
return !(stack.getItem() instanceof IWirelessCraftingTerminalItem);
|
||||
}
|
||||
|
||||
public void writeNBT(NBTTagCompound nbtTagCompound) {
|
||||
// Write the ItemStacks in the inventory to NBT
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (int currentIndex = 0; currentIndex < stackList.length; ++currentIndex) {
|
||||
if (stackList[currentIndex] != null) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte) currentIndex);
|
||||
stackList[currentIndex].writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
nbtTagCompound.setTag("CraftingMatrix", tagList);
|
||||
}
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
return !(stack.getItem() instanceof IWirelessCraftingTerminalItem);
|
||||
}
|
||||
|
||||
public void writeNBT(NBTTagCompound nbtTagCompound) {
|
||||
// Write the ItemStacks in the inventory to NBT
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (int currentIndex = 0; currentIndex < stackList.length; ++currentIndex) {
|
||||
if (stackList[currentIndex] != null) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte) currentIndex);
|
||||
stackList[currentIndex].writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
nbtTagCompound.setTag("CraftingMatrix", tagList);
|
||||
}
|
||||
}
|
||||
+104
-108
@@ -9,129 +9,125 @@ import net.p455w0rd.wirelesscraftingterminal.items.ItemMagnet;
|
||||
|
||||
public class WCTInventoryMagnet implements IInventory {
|
||||
|
||||
private String name = "MagnetSlot";
|
||||
private final ItemStack invItem;
|
||||
private ItemStack[] inventory;
|
||||
private String name = "MagnetSlot";
|
||||
private final ItemStack invItem;
|
||||
private ItemStack[] inventory;
|
||||
|
||||
public WCTInventoryMagnet(ItemStack stack) {
|
||||
super();
|
||||
inventory = new ItemStack[1];
|
||||
invItem = stack;
|
||||
if (stack != null) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
readFromNBT(stack.getTagCompound());
|
||||
}
|
||||
}
|
||||
public WCTInventoryMagnet(ItemStack stack) {
|
||||
super();
|
||||
inventory = new ItemStack[1];
|
||||
invItem = stack;
|
||||
if (stack != null) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
readFromNBT(stack.getTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory[slot];
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory[slot];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return name;
|
||||
}
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return name.length() > 0;
|
||||
}
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return name.length() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
ItemStack stack = getStackInSlot(slot);
|
||||
if (stack != null) {
|
||||
if (stack.stackSize > amount) {
|
||||
stack = stack.splitStack(amount);
|
||||
markDirty();
|
||||
}
|
||||
else {
|
||||
setInventorySlotContents(slot, null);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
ItemStack stack = getStackInSlot(slot);
|
||||
if (stack != null) {
|
||||
if (stack.stackSize > amount) {
|
||||
stack = stack.splitStack(amount);
|
||||
markDirty();
|
||||
} else {
|
||||
setInventorySlotContents(slot, null);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (inventory[slot] != null) {
|
||||
ItemStack itemStack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return itemStack;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (inventory[slot] != null) {
|
||||
ItemStack itemStack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return itemStack;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory[slot] = stack;
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory[slot] = stack;
|
||||
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
writeNBT(invItem.getTagCompound());
|
||||
}
|
||||
@Override
|
||||
public void markDirty() {
|
||||
writeNBT(invItem.getTagCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
|
||||
return (itemstack.getItem() instanceof ItemMagnet);
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
|
||||
return (itemstack.getItem() instanceof ItemMagnet);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = nbtTagCompound.getTagList(this.name, 10);
|
||||
inventory = new ItemStack[this.getSizeInventory()];
|
||||
for (int i = 0; i < tagList.tagCount(); ++i) {
|
||||
NBTTagCompound tagCompound = (NBTTagCompound) tagList.getCompoundTagAt(i);
|
||||
int slot = tagCompound.getInteger("Slot");
|
||||
if (slot >= 0 && slot < inventory.length) {
|
||||
inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = nbtTagCompound.getTagList(this.name, 10);
|
||||
inventory = new ItemStack[this.getSizeInventory()];
|
||||
for (int i = 0; i < tagList.tagCount(); ++i) {
|
||||
NBTTagCompound tagCompound = (NBTTagCompound) tagList.getCompoundTagAt(i);
|
||||
int slot = tagCompound.getInteger("Slot");
|
||||
if (slot >= 0 && slot < inventory.length) {
|
||||
inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
|
||||
if (inventory[currentIndex] != null) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setInteger("Slot", currentIndex);
|
||||
inventory[currentIndex].writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
nbtTagCompound.setTag(this.name, tagList);
|
||||
}
|
||||
public void writeNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
|
||||
if (inventory[currentIndex] != null) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setInteger("Slot", currentIndex);
|
||||
inventory[currentIndex].writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
nbtTagCompound.setTag(this.name, tagList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
@Override
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
@Override
|
||||
public void closeInventory() {}
|
||||
}
|
||||
+109
-109
@@ -9,129 +9,129 @@ import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerMagnet;
|
||||
|
||||
public class WCTInventoryMagnetFilter implements IInventory {
|
||||
|
||||
private String name = "MagnetFilter";
|
||||
private final ItemStack invItem;
|
||||
private ItemStack[] inventory;
|
||||
private ContainerMagnet container;
|
||||
private String name = "MagnetFilter";
|
||||
private final ItemStack invItem;
|
||||
private ItemStack[] inventory;
|
||||
private ContainerMagnet container;
|
||||
|
||||
public WCTInventoryMagnetFilter(ItemStack stack) {
|
||||
super();
|
||||
inventory = new ItemStack[27];
|
||||
invItem = stack;
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
readFromNBT(stack.getTagCompound());
|
||||
}
|
||||
|
||||
public void setContainer(ContainerMagnet container) { this.container = container; }
|
||||
public WCTInventoryMagnetFilter(ItemStack stack) {
|
||||
super();
|
||||
inventory = new ItemStack[27];
|
||||
invItem = stack;
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
readFromNBT(stack.getTagCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 27;
|
||||
}
|
||||
public void setContainer(ContainerMagnet container) {
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory[slot];
|
||||
}
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 27;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return name;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory[slot];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return name.length() > 0;
|
||||
}
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return name.length() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
ItemStack stack = getStackInSlot(slot);
|
||||
if (stack != null) {
|
||||
if (stack.stackSize > amount) {
|
||||
stack = stack.splitStack(amount);
|
||||
markDirty();
|
||||
} else {
|
||||
setInventorySlotContents(slot, null);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (inventory[slot] != null) {
|
||||
ItemStack itemStack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return itemStack;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
ItemStack stack = getStackInSlot(slot);
|
||||
if (stack != null) {
|
||||
if (stack.stackSize > amount) {
|
||||
stack = stack.splitStack(amount);
|
||||
markDirty();
|
||||
} else {
|
||||
setInventorySlotContents(slot, null);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory[slot] = stack;
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (inventory[slot] != null) {
|
||||
ItemStack itemStack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return itemStack;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory[slot] = stack;
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
writeNBT(invItem.getTagCompound());
|
||||
container.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = nbtTagCompound.getTagList(this.name, 10);
|
||||
inventory = new ItemStack[this.getSizeInventory()];
|
||||
for (int i = 0; i < tagList.tagCount(); ++i) {
|
||||
NBTTagCompound tagCompound = (NBTTagCompound) tagList.getCompoundTagAt(i);
|
||||
int slot = tagCompound.getInteger("Slot");
|
||||
if (slot >= 0 && slot < inventory.length) {
|
||||
inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void markDirty() {
|
||||
writeNBT(invItem.getTagCompound());
|
||||
container.detectAndSendChanges();
|
||||
}
|
||||
|
||||
public void writeNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
|
||||
if (inventory[currentIndex] != null) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setInteger("Slot", currentIndex);
|
||||
inventory[currentIndex].writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
nbtTagCompound.setTag(this.name, tagList);
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = nbtTagCompound.getTagList(this.name, 10);
|
||||
inventory = new ItemStack[this.getSizeInventory()];
|
||||
for (int i = 0; i < tagList.tagCount(); ++i) {
|
||||
NBTTagCompound tagCompound = (NBTTagCompound) tagList.getCompoundTagAt(i);
|
||||
int slot = tagCompound.getInteger("Slot");
|
||||
if (slot >= 0 && slot < inventory.length) {
|
||||
inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
public void writeNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
|
||||
if (inventory[currentIndex] != null) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setInteger("Slot", currentIndex);
|
||||
inventory[currentIndex].writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
nbtTagCompound.setTag(this.name, tagList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {}
|
||||
}
|
||||
+104
-108
@@ -8,129 +8,125 @@ import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public class WCTInventoryTrash implements IInventory {
|
||||
|
||||
private String name = "TrashSlot";
|
||||
private final ItemStack invItem;
|
||||
private ItemStack[] inventory;
|
||||
private String name = "TrashSlot";
|
||||
private final ItemStack invItem;
|
||||
private ItemStack[] inventory;
|
||||
|
||||
public WCTInventoryTrash(ItemStack stack) {
|
||||
super();
|
||||
inventory = new ItemStack[1];
|
||||
invItem = stack;
|
||||
if (stack != null) {
|
||||
if (!invItem.hasTagCompound()) {
|
||||
invItem.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
readFromNBT(invItem.getTagCompound());
|
||||
}
|
||||
}
|
||||
public WCTInventoryTrash(ItemStack stack) {
|
||||
super();
|
||||
inventory = new ItemStack[1];
|
||||
invItem = stack;
|
||||
if (stack != null) {
|
||||
if (!invItem.hasTagCompound()) {
|
||||
invItem.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
readFromNBT(invItem.getTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory[slot];
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory[slot];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return name;
|
||||
}
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return name.length() > 0;
|
||||
}
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return name.length() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
ItemStack stack = getStackInSlot(slot);
|
||||
if (stack != null) {
|
||||
if (stack.stackSize > amount) {
|
||||
stack = stack.splitStack(amount);
|
||||
markDirty();
|
||||
}
|
||||
else {
|
||||
setInventorySlotContents(slot, null);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
ItemStack stack = getStackInSlot(slot);
|
||||
if (stack != null) {
|
||||
if (stack.stackSize > amount) {
|
||||
stack = stack.splitStack(amount);
|
||||
markDirty();
|
||||
} else {
|
||||
setInventorySlotContents(slot, null);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (inventory[slot] != null) {
|
||||
ItemStack itemStack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return itemStack;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (inventory[slot] != null) {
|
||||
ItemStack itemStack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return itemStack;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory[slot] = stack;
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory[slot] = stack;
|
||||
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
writeNBT(invItem.getTagCompound());
|
||||
}
|
||||
@Override
|
||||
public void markDirty() {
|
||||
writeNBT(invItem.getTagCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = nbtTagCompound.getTagList(this.name, 10);
|
||||
inventory = new ItemStack[this.getSizeInventory()];
|
||||
for (int i = 0; i < tagList.tagCount(); ++i) {
|
||||
NBTTagCompound tagCompound = (NBTTagCompound) tagList.getCompoundTagAt(i);
|
||||
int slot = tagCompound.getInteger("Slot");
|
||||
if (slot >= 0 && slot < inventory.length) {
|
||||
inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = nbtTagCompound.getTagList(this.name, 10);
|
||||
inventory = new ItemStack[this.getSizeInventory()];
|
||||
for (int i = 0; i < tagList.tagCount(); ++i) {
|
||||
NBTTagCompound tagCompound = (NBTTagCompound) tagList.getCompoundTagAt(i);
|
||||
int slot = tagCompound.getInteger("Slot");
|
||||
if (slot >= 0 && slot < inventory.length) {
|
||||
inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
|
||||
if (inventory[currentIndex] != null) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setInteger("Slot", currentIndex);
|
||||
inventory[currentIndex].writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
nbtTagCompound.setTag(this.name, tagList);
|
||||
}
|
||||
public void writeNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
|
||||
if (inventory[currentIndex] != null) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setInteger("Slot", currentIndex);
|
||||
inventory[currentIndex].writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
nbtTagCompound.setTag(this.name, tagList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
@Override
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
@Override
|
||||
public void closeInventory() {}
|
||||
}
|
||||
+104
-108
@@ -9,129 +9,125 @@ import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public class WCTInventoryViewCell implements IInventory {
|
||||
|
||||
private final String name = "ViewCells";
|
||||
private final ItemStack invItem;
|
||||
private ItemStack[] inventory;
|
||||
private final String name = "ViewCells";
|
||||
private final ItemStack invItem;
|
||||
private ItemStack[] inventory;
|
||||
|
||||
public WCTInventoryViewCell(ItemStack stack) {
|
||||
super();
|
||||
inventory = new ItemStack[5];
|
||||
invItem = stack;
|
||||
if (stack != null) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
readFromNBT(stack.getTagCompound());
|
||||
}
|
||||
}
|
||||
public WCTInventoryViewCell(ItemStack stack) {
|
||||
super();
|
||||
inventory = new ItemStack[5];
|
||||
invItem = stack;
|
||||
if (stack != null) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
readFromNBT(stack.getTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 5;
|
||||
}
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory[slot];
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory[slot];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return name;
|
||||
}
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return name.length() > 0;
|
||||
}
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return name.length() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
ItemStack stack = getStackInSlot(slot);
|
||||
if (stack != null) {
|
||||
if (stack.stackSize > amount) {
|
||||
stack = stack.splitStack(amount);
|
||||
markDirty();
|
||||
}
|
||||
else {
|
||||
setInventorySlotContents(slot, null);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
ItemStack stack = getStackInSlot(slot);
|
||||
if (stack != null) {
|
||||
if (stack.stackSize > amount) {
|
||||
stack = stack.splitStack(amount);
|
||||
markDirty();
|
||||
} else {
|
||||
setInventorySlotContents(slot, null);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (inventory[slot] != null) {
|
||||
ItemStack itemStack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return itemStack;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (inventory[slot] != null) {
|
||||
ItemStack itemStack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return itemStack;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory[slot] = stack;
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory[slot] = stack;
|
||||
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
writeNBT(invItem.getTagCompound());
|
||||
}
|
||||
@Override
|
||||
public void markDirty() {
|
||||
writeNBT(invItem.getTagCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
|
||||
return (AEApi.instance().definitions().items().viewCell().isSameAs( itemstack ));
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
|
||||
return (AEApi.instance().definitions().items().viewCell().isSameAs(itemstack));
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = nbtTagCompound.getTagList(this.name, 10);
|
||||
inventory = new ItemStack[this.getSizeInventory()];
|
||||
for (int i = 0; i < tagList.tagCount(); ++i) {
|
||||
NBTTagCompound tagCompound = (NBTTagCompound) tagList.getCompoundTagAt(i);
|
||||
int slot = tagCompound.getInteger("Slot");
|
||||
if (slot >= 0 && slot < inventory.length) {
|
||||
inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = nbtTagCompound.getTagList(this.name, 10);
|
||||
inventory = new ItemStack[this.getSizeInventory()];
|
||||
for (int i = 0; i < tagList.tagCount(); ++i) {
|
||||
NBTTagCompound tagCompound = (NBTTagCompound) tagList.getCompoundTagAt(i);
|
||||
int slot = tagCompound.getInteger("Slot");
|
||||
if (slot >= 0 && slot < inventory.length) {
|
||||
inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
|
||||
if (inventory[currentIndex] != null) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setInteger("Slot", currentIndex);
|
||||
inventory[currentIndex].writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
nbtTagCompound.setTag(this.name, tagList);
|
||||
}
|
||||
public void writeNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
|
||||
if (inventory[currentIndex] != null) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setInteger("Slot", currentIndex);
|
||||
inventory[currentIndex].writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
nbtTagCompound.setTag(this.name, tagList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
@Override
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
@Override
|
||||
public void closeInventory() {}
|
||||
}
|
||||
+12
-12
@@ -5,18 +5,18 @@ import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
|
||||
public class EnumCache {
|
||||
/**
|
||||
* SortDir
|
||||
*/
|
||||
public static final SortDir[] AE_SORT_DIRECTIONS = SortDir.values();
|
||||
/**
|
||||
* SortDir
|
||||
*/
|
||||
public static final SortDir[] AE_SORT_DIRECTIONS = SortDir.values();
|
||||
|
||||
/**
|
||||
* SortOrder
|
||||
*/
|
||||
public static final SortOrder[] AE_SORT_ORDERS = SortOrder.values();
|
||||
/**
|
||||
* SortOrder
|
||||
*/
|
||||
public static final SortOrder[] AE_SORT_ORDERS = SortOrder.values();
|
||||
|
||||
/**
|
||||
* ViewItems
|
||||
*/
|
||||
public static final ViewItems[] AE_VIEW_ITEMS = ViewItems.values();
|
||||
/**
|
||||
* ViewItems
|
||||
*/
|
||||
public static final ViewItems[] AE_VIEW_ITEMS = ViewItems.values();
|
||||
}
|
||||
+176
-173
@@ -14,55 +14,55 @@ import net.p455w0rd.wirelesscraftingterminal.items.ItemMagnet;
|
||||
|
||||
public class RandomUtils {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static String color(String color) {
|
||||
switch (color) {
|
||||
case "white":
|
||||
return EnumChatFormatting.WHITE.toString();
|
||||
case "black":
|
||||
return EnumChatFormatting.BLACK.toString();
|
||||
case "green":
|
||||
return EnumChatFormatting.GREEN.toString();
|
||||
case "red":
|
||||
return EnumChatFormatting.RED.toString();
|
||||
case "yellow":
|
||||
return EnumChatFormatting.YELLOW.toString();
|
||||
case "aqua":
|
||||
return EnumChatFormatting.AQUA.toString();
|
||||
case "blue":
|
||||
return EnumChatFormatting.BLUE.toString();
|
||||
case "italics":
|
||||
return EnumChatFormatting.ITALIC.toString();
|
||||
case "bold":
|
||||
return EnumChatFormatting.BOLD.toString();
|
||||
default:
|
||||
case "gray":
|
||||
return EnumChatFormatting.GRAY.toString();
|
||||
}
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static String color(String color) {
|
||||
switch (color) {
|
||||
case "white":
|
||||
return EnumChatFormatting.WHITE.toString();
|
||||
case "black":
|
||||
return EnumChatFormatting.BLACK.toString();
|
||||
case "green":
|
||||
return EnumChatFormatting.GREEN.toString();
|
||||
case "red":
|
||||
return EnumChatFormatting.RED.toString();
|
||||
case "yellow":
|
||||
return EnumChatFormatting.YELLOW.toString();
|
||||
case "aqua":
|
||||
return EnumChatFormatting.AQUA.toString();
|
||||
case "blue":
|
||||
return EnumChatFormatting.BLUE.toString();
|
||||
case "italics":
|
||||
return EnumChatFormatting.ITALIC.toString();
|
||||
case "bold":
|
||||
return EnumChatFormatting.BOLD.toString();
|
||||
default:
|
||||
case "gray":
|
||||
return EnumChatFormatting.GRAY.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getWirelessTerm(InventoryPlayer playerInv) {
|
||||
if (playerInv.player.getHeldItem() != null && playerInv.player.getHeldItem().getItem() instanceof IWirelessCraftingTerminalItem) {
|
||||
return playerInv.player.getHeldItem();
|
||||
}
|
||||
ItemStack wirelessTerm = null;
|
||||
int invSize = playerInv.getSizeInventory();
|
||||
if (invSize <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < invSize; ++i) {
|
||||
ItemStack item = playerInv.getStackInSlot(i);
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
if (item.getItem() instanceof IWirelessCraftingTerminalItem) {
|
||||
wirelessTerm = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public static ItemStack getWirelessTerm(InventoryPlayer playerInv) {
|
||||
if (playerInv.player.getHeldItem() != null
|
||||
&& playerInv.player.getHeldItem().getItem() instanceof IWirelessCraftingTerminalItem) {
|
||||
return playerInv.player.getHeldItem();
|
||||
}
|
||||
ItemStack wirelessTerm = null;
|
||||
int invSize = playerInv.getSizeInventory();
|
||||
if (invSize <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < invSize; ++i) {
|
||||
ItemStack item = playerInv.getStackInSlot(i);
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
if (item.getItem() instanceof IWirelessCraftingTerminalItem) {
|
||||
wirelessTerm = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
IInventory handler = BaublesApi.getBaubles(playerInv.player);
|
||||
if (handler != null)
|
||||
{
|
||||
if (handler != null) {
|
||||
invSize = handler.getSizeInventory();
|
||||
for (int i = 0; i < invSize; ++i) {
|
||||
ItemStack item = handler.getStackInSlot(i);
|
||||
@@ -75,132 +75,135 @@ public class RandomUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
return wirelessTerm;
|
||||
}
|
||||
return wirelessTerm;
|
||||
}
|
||||
|
||||
public static ItemStack getMagnet(InventoryPlayer playerInv) {
|
||||
// Is player holding a Magnet Card?
|
||||
if (playerInv.player.getHeldItem() != null && playerInv.player.getHeldItem().getItem() instanceof ItemMagnet) {
|
||||
return playerInv.player.getHeldItem();
|
||||
}
|
||||
// if not true, try to return first magnet card from first
|
||||
// wireless term that has a MagnetCard installed
|
||||
ItemStack wirelessTerm = getWirelessTerm(playerInv);
|
||||
if (wirelessTerm != null && wirelessTerm.getItem() instanceof IWirelessCraftingTerminalItem) {
|
||||
NBTTagCompound nbtTC = wirelessTerm.getTagCompound();
|
||||
if (nbtTC.hasKey("MagnetSlot")) {
|
||||
NBTTagList magnetSlot = nbtTC.getTagList("MagnetSlot", 10);
|
||||
ItemStack magnetItem = ItemStack.loadItemStackFromNBT(magnetSlot.getCompoundTagAt(0));
|
||||
if (magnetItem != null && magnetItem.getItem() instanceof ItemMagnet) {
|
||||
return magnetItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
// No wireless crafting terminal with Magnet Card installed,
|
||||
// is there a Magnet Card in the player's inventory?
|
||||
int invSize = playerInv.getSizeInventory();
|
||||
ItemStack magnetItem = null;
|
||||
if (invSize <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < invSize; ++i) {
|
||||
ItemStack item = playerInv.getStackInSlot(i);
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
if (item.getItem() instanceof ItemMagnet) {
|
||||
magnetItem = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return magnetItem;
|
||||
}
|
||||
|
||||
public static boolean isMagnetInitialized(ItemStack magnetItem) {
|
||||
if (magnetItem != null && magnetItem.getItem() instanceof ItemMagnet) {
|
||||
if (magnetItem.hasTagCompound()) {
|
||||
if (magnetItem.getTagCompound().hasKey("Initialized")) {
|
||||
return magnetItem.getTagCompound().getBoolean("Initialized");
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isMagnetInstalled(InventoryPlayer ip) {
|
||||
NBTTagCompound magnetNBTForm = RandomUtils.getWirelessTerm(ip).getTagCompound().getTagList("MagnetSlot", 10).getCompoundTagAt(0);
|
||||
if (magnetNBTForm != null) {
|
||||
ItemStack magnetItem = ItemStack.loadItemStackFromNBT(magnetNBTForm);
|
||||
if (magnetItem != null && magnetItem.getItem() instanceof ItemMagnet) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean readBoolean(ItemStack is, String key) {
|
||||
if (is == null) {
|
||||
return false;
|
||||
}
|
||||
NBTTagCompound tag = getTag(is);
|
||||
return (tag.hasKey(key) ? tag.getBoolean(key) : false);
|
||||
}
|
||||
|
||||
public static int readInt(ItemStack is, String key) {
|
||||
if (is == null) {
|
||||
return 0;
|
||||
}
|
||||
NBTTagCompound tag = getTag(is);
|
||||
return (tag.hasKey(key) ? tag.getInteger(key) : -1);
|
||||
}
|
||||
|
||||
public static void writeInt(ItemStack is, String key, int value) {
|
||||
if (is == null) {
|
||||
return;
|
||||
}
|
||||
NBTTagCompound tag = getTag(is);
|
||||
tag.setInteger(key, value);
|
||||
}
|
||||
|
||||
public static void writeBoolean(ItemStack is, String key, boolean value) {
|
||||
if (is == null) {
|
||||
return;
|
||||
}
|
||||
NBTTagCompound tag = getTag(is);
|
||||
tag.setBoolean(key, value);
|
||||
}
|
||||
|
||||
public static void delKey(ItemStack is, String key) {
|
||||
if (is == null) {
|
||||
return;
|
||||
}
|
||||
NBTTagCompound tag = getTag(is);
|
||||
tag.removeTag(key);
|
||||
}
|
||||
|
||||
public static NBTTagCompound getTag(ItemStack is) {
|
||||
if (!is.hasTagCompound()) {
|
||||
is.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
return is.getTagCompound();
|
||||
}
|
||||
|
||||
public static ItemStack readStack(NBTTagCompound nbtTC, String key) {
|
||||
return (nbtTC.hasKey(key) ? ItemStack.loadItemStackFromNBT(nbtTC) : null);
|
||||
}
|
||||
|
||||
public static void removeTimerTags(ItemStack is) {
|
||||
if (is == null || is.getTagCompound() == null) {
|
||||
return;
|
||||
}
|
||||
if (is.getTagCompound().hasKey("WCTReset")) {
|
||||
is.setTagCompound(null);
|
||||
}
|
||||
if (is.getTagCompound() != null) {
|
||||
if (is.getTagCompound().hasKey("WCTPickupTimer")) {
|
||||
is.getTagCompound().removeTag("WCTPickupTimer");
|
||||
}
|
||||
}
|
||||
}
|
||||
public static ItemStack getMagnet(InventoryPlayer playerInv) {
|
||||
// Is player holding a Magnet Card?
|
||||
if (playerInv.player.getHeldItem() != null
|
||||
&& playerInv.player.getHeldItem().getItem() instanceof ItemMagnet) {
|
||||
return playerInv.player.getHeldItem();
|
||||
}
|
||||
// if not true, try to return first magnet card from first
|
||||
// wireless term that has a MagnetCard installed
|
||||
ItemStack wirelessTerm = getWirelessTerm(playerInv);
|
||||
if (wirelessTerm != null && wirelessTerm.getItem() instanceof IWirelessCraftingTerminalItem) {
|
||||
NBTTagCompound nbtTC = wirelessTerm.getTagCompound();
|
||||
if (nbtTC.hasKey("MagnetSlot")) {
|
||||
NBTTagList magnetSlot = nbtTC.getTagList("MagnetSlot", 10);
|
||||
ItemStack magnetItem = ItemStack.loadItemStackFromNBT(magnetSlot.getCompoundTagAt(0));
|
||||
if (magnetItem != null && magnetItem.getItem() instanceof ItemMagnet) {
|
||||
return magnetItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
// No wireless crafting terminal with Magnet Card installed,
|
||||
// is there a Magnet Card in the player's inventory?
|
||||
int invSize = playerInv.getSizeInventory();
|
||||
ItemStack magnetItem = null;
|
||||
if (invSize <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < invSize; ++i) {
|
||||
ItemStack item = playerInv.getStackInSlot(i);
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
if (item.getItem() instanceof ItemMagnet) {
|
||||
magnetItem = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return magnetItem;
|
||||
}
|
||||
|
||||
public static boolean isMagnetInitialized(ItemStack magnetItem) {
|
||||
if (magnetItem != null && magnetItem.getItem() instanceof ItemMagnet) {
|
||||
if (magnetItem.hasTagCompound()) {
|
||||
if (magnetItem.getTagCompound().hasKey("Initialized")) {
|
||||
return magnetItem.getTagCompound().getBoolean("Initialized");
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isMagnetInstalled(InventoryPlayer ip) {
|
||||
NBTTagCompound magnetNBTForm = RandomUtils.getWirelessTerm(ip)
|
||||
.getTagCompound()
|
||||
.getTagList("MagnetSlot", 10)
|
||||
.getCompoundTagAt(0);
|
||||
if (magnetNBTForm != null) {
|
||||
ItemStack magnetItem = ItemStack.loadItemStackFromNBT(magnetNBTForm);
|
||||
if (magnetItem != null && magnetItem.getItem() instanceof ItemMagnet) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean readBoolean(ItemStack is, String key) {
|
||||
if (is == null) {
|
||||
return false;
|
||||
}
|
||||
NBTTagCompound tag = getTag(is);
|
||||
return (tag.hasKey(key) ? tag.getBoolean(key) : false);
|
||||
}
|
||||
|
||||
public static int readInt(ItemStack is, String key) {
|
||||
if (is == null) {
|
||||
return 0;
|
||||
}
|
||||
NBTTagCompound tag = getTag(is);
|
||||
return (tag.hasKey(key) ? tag.getInteger(key) : -1);
|
||||
}
|
||||
|
||||
public static void writeInt(ItemStack is, String key, int value) {
|
||||
if (is == null) {
|
||||
return;
|
||||
}
|
||||
NBTTagCompound tag = getTag(is);
|
||||
tag.setInteger(key, value);
|
||||
}
|
||||
|
||||
public static void writeBoolean(ItemStack is, String key, boolean value) {
|
||||
if (is == null) {
|
||||
return;
|
||||
}
|
||||
NBTTagCompound tag = getTag(is);
|
||||
tag.setBoolean(key, value);
|
||||
}
|
||||
|
||||
public static void delKey(ItemStack is, String key) {
|
||||
if (is == null) {
|
||||
return;
|
||||
}
|
||||
NBTTagCompound tag = getTag(is);
|
||||
tag.removeTag(key);
|
||||
}
|
||||
|
||||
public static NBTTagCompound getTag(ItemStack is) {
|
||||
if (!is.hasTagCompound()) {
|
||||
is.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
return is.getTagCompound();
|
||||
}
|
||||
|
||||
public static ItemStack readStack(NBTTagCompound nbtTC, String key) {
|
||||
return (nbtTC.hasKey(key) ? ItemStack.loadItemStackFromNBT(nbtTC) : null);
|
||||
}
|
||||
|
||||
public static void removeTimerTags(ItemStack is) {
|
||||
if (is == null || is.getTagCompound() == null) {
|
||||
return;
|
||||
}
|
||||
if (is.getTagCompound().hasKey("WCTReset")) {
|
||||
is.setTagCompound(null);
|
||||
}
|
||||
if (is.getTagCompound() != null) {
|
||||
if (is.getTagCompound().hasKey("WCTPickupTimer")) {
|
||||
is.getTagCompound().removeTag("WCTPickupTimer");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+49
-49
@@ -1,61 +1,61 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.common.utils;
|
||||
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
public class ReflectionUtils {
|
||||
/**
|
||||
* Get a {@link MethodHandle} for a method.
|
||||
*
|
||||
* @param clazz The class
|
||||
* @param methodNames The possible names of the method
|
||||
* @param methodTypes The argument types of the method
|
||||
* @param <T> The class
|
||||
* @return The MethodHandle
|
||||
*/
|
||||
public static <T> MethodHandle findMethod(Class<T> clazz, String[] methodNames, Class<?>... methodTypes) {
|
||||
final Method method = ReflectionHelper.findMethod(clazz, null, methodNames, methodTypes);
|
||||
try {
|
||||
return MethodHandles.lookup().unreflect(method);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new ReflectionHelper.UnableToFindMethodException(methodNames, e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get a {@link MethodHandle} for a method.
|
||||
*
|
||||
* @param clazz The class
|
||||
* @param methodNames The possible names of the method
|
||||
* @param methodTypes The argument types of the method
|
||||
* @param <T> The class
|
||||
* @return The MethodHandle
|
||||
*/
|
||||
public static <T> MethodHandle findMethod(Class<T> clazz, String[] methodNames, Class<?>... methodTypes) {
|
||||
final Method method = ReflectionHelper.findMethod(clazz, null, methodNames, methodTypes);
|
||||
try {
|
||||
return MethodHandles.lookup().unreflect(method);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new ReflectionHelper.UnableToFindMethodException(methodNames, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@link MethodHandle} for a field's getter.
|
||||
*
|
||||
* @param clazz The class
|
||||
* @param fieldNames The possible names of the field
|
||||
* @return The MethodHandle
|
||||
*/
|
||||
public static MethodHandle findFieldGetter(Class<?> clazz, String... fieldNames) {
|
||||
final Field field = ReflectionHelper.findField(clazz, fieldNames);
|
||||
/**
|
||||
* Get a {@link MethodHandle} for a field's getter.
|
||||
*
|
||||
* @param clazz The class
|
||||
* @param fieldNames The possible names of the field
|
||||
* @return The MethodHandle
|
||||
*/
|
||||
public static MethodHandle findFieldGetter(Class<?> clazz, String... fieldNames) {
|
||||
final Field field = ReflectionHelper.findField(clazz, fieldNames);
|
||||
|
||||
try {
|
||||
return MethodHandles.lookup().unreflectGetter(field);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new ReflectionHelper.UnableToAccessFieldException(fieldNames, e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
return MethodHandles.lookup().unreflectGetter(field);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new ReflectionHelper.UnableToAccessFieldException(fieldNames, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@link MethodHandle} for a field's setter.
|
||||
*
|
||||
* @param clazz The class
|
||||
* @param fieldNames The possible names of the field
|
||||
* @return The MethodHandle
|
||||
*/
|
||||
public static MethodHandle findFieldSetter(Class<?> clazz, String... fieldNames) {
|
||||
final Field field = ReflectionHelper.findField(clazz, fieldNames);
|
||||
/**
|
||||
* Get a {@link MethodHandle} for a field's setter.
|
||||
*
|
||||
* @param clazz The class
|
||||
* @param fieldNames The possible names of the field
|
||||
* @return The MethodHandle
|
||||
*/
|
||||
public static MethodHandle findFieldSetter(Class<?> clazz, String... fieldNames) {
|
||||
final Field field = ReflectionHelper.findField(clazz, fieldNames);
|
||||
|
||||
try {
|
||||
return MethodHandles.lookup().unreflectSetter(field);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new ReflectionHelper.UnableToAccessFieldException(fieldNames, e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
return MethodHandles.lookup().unreflectSetter(field);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new ReflectionHelper.UnableToAccessFieldException(fieldNames, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,70 +1,70 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.common.utils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class WCTLog {
|
||||
public static final Logger log = LogManager.getLogger("Wireless Crafting Terminal");
|
||||
public static final Logger log = LogManager.getLogger("Wireless Crafting Terminal");
|
||||
|
||||
/**
|
||||
* Displays the section header.
|
||||
*/
|
||||
public static long beginSection(final String section) {
|
||||
log.info(String.format("-=-=-=-=-=-=-=[START] %s=-=-=-=-=-=-=-", section));
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
/**
|
||||
* Displays the section header.
|
||||
*/
|
||||
public static long beginSection(final String section) {
|
||||
log.info(String.format("-=-=-=-=-=-=-=[START] %s=-=-=-=-=-=-=-", section));
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a debug statement.
|
||||
*
|
||||
* @param format
|
||||
* @param data
|
||||
*/
|
||||
public static void debug(final String format, final Object... data) {
|
||||
log.debug(String.format(format, data));
|
||||
}
|
||||
/**
|
||||
* Logs a debug statement.
|
||||
*
|
||||
* @param format
|
||||
* @param data
|
||||
*/
|
||||
public static void debug(final String format, final Object... data) {
|
||||
log.debug(String.format(format, data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the section footer.
|
||||
*/
|
||||
public static void endSection(final String section, final long sectionStartTime) {
|
||||
log.info(String.format("-=-=-=-=-=-=-=[FINISH] %s in %dms=-=-=-=-=-=-=-", section, (System.currentTimeMillis() - sectionStartTime)));
|
||||
}
|
||||
/**
|
||||
* Displays the section footer.
|
||||
*/
|
||||
public static void endSection(final String section, final long sectionStartTime) {
|
||||
log.info(String.format(
|
||||
"-=-=-=-=-=-=-=[FINISH] %s in %dms=-=-=-=-=-=-=-",
|
||||
section, (System.currentTimeMillis() - sectionStartTime)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs basic info.
|
||||
*
|
||||
* @param format
|
||||
* @param data
|
||||
*/
|
||||
public static void info(final String format, final Object... data) {
|
||||
log.info(String.format(format, data));
|
||||
}
|
||||
/**
|
||||
* Logs basic info.
|
||||
*
|
||||
* @param format
|
||||
* @param data
|
||||
*/
|
||||
public static void info(final String format, final Object... data) {
|
||||
log.info(String.format(format, data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an error.
|
||||
*
|
||||
* @param format
|
||||
* @param data
|
||||
*/
|
||||
public static void severe(final String format, final Object... data) {
|
||||
log.error(String.format(format, data));
|
||||
}
|
||||
/**
|
||||
* Logs an error.
|
||||
*
|
||||
* @param format
|
||||
* @param data
|
||||
*/
|
||||
public static void severe(final String format, final Object... data) {
|
||||
log.error(String.format(format, data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a warning.
|
||||
*
|
||||
* @param format
|
||||
* @param data
|
||||
*/
|
||||
public static void warning(final String format, final Object... data) {
|
||||
log.warn(String.format(format, data));
|
||||
}
|
||||
|
||||
public static void integration( @Nonnull final Throwable exception )
|
||||
{
|
||||
log.debug( exception );
|
||||
}
|
||||
/**
|
||||
* Logs a warning.
|
||||
*
|
||||
* @param format
|
||||
* @param data
|
||||
*/
|
||||
public static void warning(final String format, final Object... data) {
|
||||
log.warn(String.format(format, data));
|
||||
}
|
||||
|
||||
public static void integration(@Nonnull final Throwable exception) {
|
||||
log.debug(exception);
|
||||
}
|
||||
}
|
||||
@@ -8,32 +8,35 @@ import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
|
||||
|
||||
public abstract class WCTPacket {
|
||||
|
||||
private ByteBuf p;
|
||||
private ByteBuf p;
|
||||
|
||||
public void serverPacketData(final INetworkInfo manager, final WCTPacket packet, final EntityPlayer player) {
|
||||
throw new UnsupportedOperationException("This packet ( " + this.getPacketID() + " does not implement a server side handler.");
|
||||
}
|
||||
public void serverPacketData(final INetworkInfo manager, final WCTPacket packet, final EntityPlayer player) {
|
||||
throw new UnsupportedOperationException(
|
||||
"This packet ( " + this.getPacketID() + " does not implement a server side handler.");
|
||||
}
|
||||
|
||||
public final int getPacketID() {
|
||||
return WCTPacketHandlerBase.PacketTypes.getID(this.getClass()).ordinal();
|
||||
}
|
||||
public final int getPacketID() {
|
||||
return WCTPacketHandlerBase.PacketTypes.getID(this.getClass()).ordinal();
|
||||
}
|
||||
|
||||
public void clientPacketData(final INetworkInfo network, final WCTPacket packet, final EntityPlayer player) {
|
||||
throw new UnsupportedOperationException("This packet ( " + this.getPacketID() + " does not implement a client side handler.");
|
||||
}
|
||||
public void clientPacketData(final INetworkInfo network, final WCTPacket packet, final EntityPlayer player) {
|
||||
throw new UnsupportedOperationException(
|
||||
"This packet ( " + this.getPacketID() + " does not implement a client side handler.");
|
||||
}
|
||||
|
||||
protected void configureWrite(final ByteBuf data) {
|
||||
data.capacity(data.readableBytes());
|
||||
this.p = data;
|
||||
}
|
||||
protected void configureWrite(final ByteBuf data) {
|
||||
data.capacity(data.readableBytes());
|
||||
this.p = data;
|
||||
}
|
||||
|
||||
public FMLProxyPacket getProxy() {
|
||||
if (this.p.array().length > 2 * 1024 * 1024) {
|
||||
throw new IllegalArgumentException("Sorry WCT made a " + this.p.array().length + " byte packet by accident!");
|
||||
}
|
||||
public FMLProxyPacket getProxy() {
|
||||
if (this.p.array().length > 2 * 1024 * 1024) {
|
||||
throw new IllegalArgumentException(
|
||||
"Sorry WCT made a " + this.p.array().length + " byte packet by accident!");
|
||||
}
|
||||
|
||||
final FMLProxyPacket pp = new FMLProxyPacket(this.p, NetworkHandler.instance.getChannel());
|
||||
final FMLProxyPacket pp = new FMLProxyPacket(this.p, NetworkHandler.instance.getChannel());
|
||||
|
||||
return pp;
|
||||
}
|
||||
}
|
||||
return pp;
|
||||
}
|
||||
}
|
||||
+56
-56
@@ -1,12 +1,11 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.core.sync;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.handler.codec.DecoderException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.handler.codec.DecoderException;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketConfigSync;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketCraftRequest;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketEmptyTrash;
|
||||
@@ -24,74 +23,75 @@ import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketUpdateCPUIn
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketValueConfig;
|
||||
|
||||
public class WCTPacketHandlerBase {
|
||||
private static final Map<Class<? extends WCTPacket>, PacketTypes> REVERSE_LOOKUP = new HashMap<Class<? extends WCTPacket>, WCTPacketHandlerBase.PacketTypes>();
|
||||
private static final Map<Class<? extends WCTPacket>, PacketTypes> REVERSE_LOOKUP =
|
||||
new HashMap<Class<? extends WCTPacket>, WCTPacketHandlerBase.PacketTypes>();
|
||||
|
||||
public enum PacketTypes {
|
||||
PACKET_INVENTORY_ACTION(PacketInventoryAction.class),
|
||||
public enum PacketTypes {
|
||||
PACKET_INVENTORY_ACTION(PacketInventoryAction.class),
|
||||
|
||||
PACKET_ME_INVENTORY_UPDATE(PacketMEInventoryUpdate.class),
|
||||
PACKET_ME_INVENTORY_UPDATE(PacketMEInventoryUpdate.class),
|
||||
|
||||
PACKET_VALUE_CONFIG(PacketValueConfig.class),
|
||||
PACKET_VALUE_CONFIG(PacketValueConfig.class),
|
||||
|
||||
PACKET_SWITCH_GUIS(PacketSwitchGuis.class),
|
||||
PACKET_SWITCH_GUIS(PacketSwitchGuis.class),
|
||||
|
||||
PACKET_SWAP_SLOTS(PacketSwapSlots.class),
|
||||
PACKET_SWAP_SLOTS(PacketSwapSlots.class),
|
||||
|
||||
PACKET_RECIPE_NEI(PacketNEIRecipe.class),
|
||||
PACKET_RECIPE_NEI(PacketNEIRecipe.class),
|
||||
|
||||
PACKET_PARTIAL_ITEM(PacketPartialItem.class),
|
||||
PACKET_PARTIAL_ITEM(PacketPartialItem.class),
|
||||
|
||||
PACKET_CRAFTING_REQUEST(PacketCraftRequest.class),
|
||||
PACKET_CRAFTING_REQUEST(PacketCraftRequest.class),
|
||||
|
||||
PACKET_MAGNETFILTER_MODE(PacketMagnetFilter.class),
|
||||
PACKET_MAGNETFILTER_MODE(PacketMagnetFilter.class),
|
||||
|
||||
PACKET_OPENWIRELESSTERM(PacketOpenGui.class),
|
||||
|
||||
PACKET_SWITCHMAGNETMODE(PacketSetMagnet.class),
|
||||
|
||||
PACKET_EMPTY_TRASH(PacketEmptyTrash.class),
|
||||
|
||||
PACKET_SYNC_CONFIGS(PacketConfigSync.class),
|
||||
|
||||
PACKET_SET_JOB(PacketSetJobBytes.class),
|
||||
|
||||
PACKET_UPDATECPUINFO(PacketUpdateCPUInfo.class);
|
||||
PACKET_OPENWIRELESSTERM(PacketOpenGui.class),
|
||||
|
||||
private final Class<? extends WCTPacket> packetClass;
|
||||
private final Constructor<? extends WCTPacket> packetConstructor;
|
||||
PACKET_SWITCHMAGNETMODE(PacketSetMagnet.class),
|
||||
|
||||
PacketTypes(final Class<? extends WCTPacket> c) {
|
||||
this.packetClass = c;
|
||||
PACKET_EMPTY_TRASH(PacketEmptyTrash.class),
|
||||
|
||||
Constructor<? extends WCTPacket> x = null;
|
||||
try {
|
||||
x = this.packetClass.getConstructor(ByteBuf.class);
|
||||
}
|
||||
catch (final NoSuchMethodException ignored) {
|
||||
}
|
||||
catch (final SecurityException ignored) {
|
||||
}
|
||||
catch (final DecoderException ignored) {
|
||||
}
|
||||
PACKET_SYNC_CONFIGS(PacketConfigSync.class),
|
||||
|
||||
this.packetConstructor = x;
|
||||
REVERSE_LOOKUP.put(this.packetClass, this);
|
||||
PACKET_SET_JOB(PacketSetJobBytes.class),
|
||||
|
||||
if (this.packetConstructor == null) {
|
||||
throw new IllegalStateException("Invalid Packet Class " + c + ", must be constructable on DataInputStream");
|
||||
}
|
||||
}
|
||||
PACKET_UPDATECPUINFO(PacketUpdateCPUInfo.class);
|
||||
|
||||
public static PacketTypes getPacket(final int id) {
|
||||
return (values())[id];
|
||||
}
|
||||
private final Class<? extends WCTPacket> packetClass;
|
||||
private final Constructor<? extends WCTPacket> packetConstructor;
|
||||
|
||||
static PacketTypes getID(final Class<? extends WCTPacket> c) {
|
||||
return REVERSE_LOOKUP.get(c);
|
||||
}
|
||||
PacketTypes(final Class<? extends WCTPacket> c) {
|
||||
this.packetClass = c;
|
||||
|
||||
public WCTPacket parsePacket(final ByteBuf in) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||
return this.packetConstructor.newInstance(in);
|
||||
}
|
||||
}
|
||||
}
|
||||
Constructor<? extends WCTPacket> x = null;
|
||||
try {
|
||||
x = this.packetClass.getConstructor(ByteBuf.class);
|
||||
} catch (final NoSuchMethodException ignored) {
|
||||
} catch (final SecurityException ignored) {
|
||||
} catch (final DecoderException ignored) {
|
||||
}
|
||||
|
||||
this.packetConstructor = x;
|
||||
REVERSE_LOOKUP.put(this.packetClass, this);
|
||||
|
||||
if (this.packetConstructor == null) {
|
||||
throw new IllegalStateException(
|
||||
"Invalid Packet Class " + c + ", must be constructable on DataInputStream");
|
||||
}
|
||||
}
|
||||
|
||||
public static PacketTypes getPacket(final int id) {
|
||||
return (values())[id];
|
||||
}
|
||||
|
||||
static PacketTypes getID(final Class<? extends WCTPacket> c) {
|
||||
return REVERSE_LOOKUP.get(c);
|
||||
}
|
||||
|
||||
public WCTPacket parsePacket(final ByteBuf in)
|
||||
throws InstantiationException, IllegalAccessException, IllegalArgumentException,
|
||||
InvocationTargetException {
|
||||
return this.packetConstructor.newInstance(in);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 159 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user