Compare commits

...
26 Commits
Author SHA1 Message Date
Martin Robertz 95daa9b035 update deps 2023-12-20 20:21:36 +01:00
Under f249fd2973 Add Config to allow servers to re-enable support for client-side 'hacks' like Staff Of Traveling Keybind mod. (#142)
* Update Config.java

Adding config to allow not validating travel staff packets.

* Update TravelController.java

Disable validation if server config deems it so.

* spotlessApply fix

* Wrong ordering and spotlessApply
2023-12-20 20:06:38 +01:00
9f3f8243f9 Limited Item Filter (#143)
* Limited Item Filter

* simplify inverted limit

Co-authored-by: Alexander Anishin <[email protected]>

* Update src/main/java/crazypants/enderio/conduit/item/filter/ItemFilterLimited.java

Co-authored-by: Alexander Anishin <[email protected]>

* Update src/main/java/crazypants/enderio/conduit/item/filter/ItemFilterLimited.java

Co-authored-by: Alexander Anishin <[email protected]>

* Update ItemFilterLimited.java

---------

Co-authored-by: Alexander Anishin <[email protected]>
Co-authored-by: Martin Robertz <[email protected]>
2023-12-20 19:50:55 +01:00
Martin Robertz 23a5484ee8 update deps 2023-12-13 15:38:04 +01:00
Bears Dot Zone 4b5837cac2 Fix an edge case pertaining to freshly crafted tanks (#141)
* Update dependencies

* Replace faulty dummy object logic with object creation

* Remove logic that is exiting a function erroneously
2023-12-13 15:32:56 +01:00
Spacebuilder2020andMartin Robertz 1251427388 Fix NBT Match where tag is empty but exists (#138)
* Fix NBT Match where tag is empty but exists

* Apply Splotless

* update deps

* update gradle + bs

---------

Co-authored-by: Martin Robertz <[email protected]>
2023-12-13 09:40:48 +01:00
ghostflyby 3e7d69f460 Open conduit connection GUI with more wrenches (#139) 2023-11-25 16:02:12 +08:00
Martin Robertz 88725a144d update deps 2023-11-16 13:59:12 +01:00
Pelotrio 123f22f20e Add unload event handling to ClientNetworkManager (#137)
Added a new method `onWorldUnload` to `ClientNetworkManager` to destroy and clear any network instances when the world event `Unload` is triggered. The addition of this event handler was necessary to prevent the possibility of any network instances persisting on the client side beyond the World lifetime, thus potentially causing memory leaks.
2023-11-16 15:42:32 +03:00
Martin Robertz 0b0f7a4f1a update deps 2023-11-11 12:13:03 +01:00
Martin Robertz b00c5996f7 update bs+deps 2023-11-11 12:12:45 +01:00
Pelotrio 83f52d15c7 Removed the redundant static IWailaDataAccessor _accessor to not leak the world object 2023-11-10 18:34:39 -08:00
Pelotrio 287c4498d2 Use null for the Item to render to not leak the world 2023-11-10 18:34:39 -08:00
Martin Robertz 2470e81f0e update bs+de+wci 2023-10-15 17:43:47 +02:00
Alexdoru 1af6fcae0b set fluid conduit default to output only 2023-10-15 13:34:45 +02:00
Alexdoru f44111da96 revert changes to conduit default connection modes 2023-10-15 13:34:45 +02:00
Dream-MasterXXL 4ae9ff2d77 update bs+deps 2023-10-05 00:42:17 +02:00
Martin Robertz 71f79536a7 update deps 2023-09-28 20:54:35 +02:00
Alexdoru 0920bf28d6 Change default connection mode of fluid conduits (#134)
* update bs

* change default connection mode of fluid conduits

* fix imports
2023-09-28 20:45:53 +02:00
Martin Robertz 8e4107d11e update bs+deps 2023-09-22 19:09:29 +02:00
Glease 349bcc0926 allow small overshoot of power use for traveling (#133) 2023-09-22 20:04:04 +03:00
Glease 070660efe4 fix travel upgrade items using wrong way to determine power stored (#131)
Signed-off-by: Glease <[email protected]>
2023-07-24 01:45:41 +08:00
Martin RobertzandRaven Szewczyk 0dd56b62ab update bs+sa+deps (#130)
* update bs+sa+deps

* Switch immibis microblocks to modrinth maven

* Remove modrinth from repositories as it's now in the buildscript

---------

Co-authored-by: Raven Szewczyk <[email protected]>
2023-07-23 11:36:28 +02:00
Glease 54d61f5251 valiate tp packets (#128)
* validate tp packets

Signed-off-by: Glease <[email protected]>

* spotless

Signed-off-by: Glease <[email protected]>

---------

Signed-off-by: Glease <[email protected]>
2023-07-23 08:04:14 +02:00
初夏同学 ebcbef851a Fix a bug in NBT usage (#127) 2023-07-05 17:57:26 +02:00
miozune 1717d38632 Validate TE of packet (#126)
* Validate TE of packet

* Remove outdated script
2023-07-03 11:33:32 +09:00
122 changed files with 1661 additions and 543 deletions

No files matched your search

-33
View File
@@ -1,33 +0,0 @@
#!/usr/bin/env bash
RUNDIR="run"
CRASH="crash-reports"
SERVERLOG="server.log"
if [[ -d $RUNDIR/$CRASH ]]; then
echo "Crash reports detected:"
cat $RUNDIR/$CRASH/crash*.txt
exit 1
fi
if grep --quiet "Fatal errors were detected" $SERVERLOG; 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" $SERVERLOG; then
echo "Server force stopped:"
cat server.log
exit 1
fi
if ! grep --quiet -Po '.+Done \(.+\)\! For help, type "help" or "\?"' $SERVERLOG; then
echo "Server didn't finish startup:"
cat server.log
exit 1
fi
echo "No crash reports detected"
exit 0
+201 -101
View File
@@ -1,4 +1,4 @@
//version: 1684218858
//version: 1702141377
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
@@ -28,27 +28,12 @@ import java.util.concurrent.TimeUnit
buildscript {
repositories {
mavenCentral()
maven {
name 'forge'
url 'https://maven.minecraftforge.net'
}
maven {
// GTNH RetroFuturaGradle and ASM Fork
name "GTNH Maven"
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
allowInsecureProtocol = true
}
maven {
name 'sonatype'
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven {
name 'Scala CI dependencies'
url 'https://repo1.maven.org/maven2/'
}
mavenLocal()
}
}
@@ -69,7 +54,7 @@ plugins {
id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version
id 'com.modrinth.minotaur' version '2.+' apply false
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.14'
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.26'
}
print("You might want to check out './gradlew :faq' if your build fails.\n")
@@ -89,6 +74,23 @@ def out = services.get(StyledTextOutputFactory).create('an-output')
def projectJavaVersion = JavaLanguageVersion.of(8)
boolean disableSpotless = project.hasProperty("disableSpotless") ? project.disableSpotless.toBoolean() : false
boolean disableCheckstyle = project.hasProperty("disableCheckstyle") ? project.disableCheckstyle.toBoolean() : false
final String CHECKSTYLE_CONFIG = """
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<!-- Use CHECKSTYLE:OFF and CHECKSTYLE:ON comments to suppress checkstyle lints in a block -->
<module name="SuppressionCommentFilter"/>
<module name="AvoidStarImport">
<!-- Allow static wildcard imports for cases like Opcodes and LWJGL classes, these don't get created accidentally by the IDE -->
<property name="allowStaticMemberImports" value="true"/>
</module>
</module>
</module>
"""
checkPropertyExists("modName")
checkPropertyExists("modId")
@@ -115,6 +117,8 @@ propertyDefaultIfUnset("usesMixinDebug", project.usesMixins)
propertyDefaultIfUnset("forceEnableMixins", false)
propertyDefaultIfUnset("channel", "stable")
propertyDefaultIfUnset("mappingsVersion", "12")
propertyDefaultIfUnset("usesMavenPublishing", true)
propertyDefaultIfUnset("mavenPublishUrl", "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases")
propertyDefaultIfUnset("modrinthProjectId", "")
propertyDefaultIfUnset("modrinthRelations", "")
propertyDefaultIfUnset("curseForgeProjectId", "")
@@ -138,6 +142,17 @@ if (!disableSpotless) {
apply from: Blowdryer.file('spotless.gradle')
}
if (!disableCheckstyle) {
apply plugin: 'checkstyle'
tasks.named("checkstylePatchedMc") { enabled = false }
tasks.named("checkstyleMcLauncher") { enabled = false }
tasks.named("checkstyleIdeVirtualMain") { enabled = false }
tasks.named("checkstyleInjectedTags") { enabled = false }
checkstyle {
config = resources.text.fromString(CHECKSTYLE_CONFIG)
}
}
String javaSourceDir = "src/main/java/"
String scalaSourceDir = "src/main/scala/"
String kotlinSourceDir = "src/main/kotlin/"
@@ -272,7 +287,7 @@ if (apiPackage) {
}
if (accessTransformersFile) {
for (atFile in accessTransformersFile.split(",")) {
for (atFile in accessTransformersFile.split(" ")) {
String targetFile = "src/main/resources/META-INF/" + atFile.trim()
if (!getFile(targetFile).exists()) {
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
@@ -357,7 +372,27 @@ catch (Exception ignored) {
String identifiedVersion
String versionOverride = System.getenv("VERSION") ?: null
try {
identifiedVersion = versionOverride == null ? gitVersion() : versionOverride
// Produce a version based on the tag, or for branches something like 0.2.2-configurable-maven-and-extras.38+43090270b6-dirty
if (versionOverride == null) {
def gitDetails = versionDetails()
def isDirty = gitVersion().endsWith(".dirty") // No public API for this, isCleanTag has a different meaning
String branchName = gitDetails.branchName ?: (System.getenv('GIT_BRANCH') ?: 'git')
if (branchName.startsWith('origin/')) {
branchName = branchName.minus('origin/')
}
branchName = branchName.replaceAll("[^a-zA-Z0-9-]+", "-") // sanitize branch names for semver
identifiedVersion = gitDetails.lastTag ?: '${gitDetails.gitHash}'
if (gitDetails.commitDistance > 0) {
identifiedVersion += "-${branchName}.${gitDetails.commitDistance}+${gitDetails.gitHash}"
if (isDirty) {
identifiedVersion += "-dirty"
}
} else if (isDirty) {
identifiedVersion += "-${branchName}+${gitDetails.gitHash}-dirty"
}
} else {
identifiedVersion = versionOverride
}
}
catch (Exception ignored) {
out.style(Style.Failure).text(
@@ -379,9 +414,13 @@ if (identifiedVersion == versionOverride) {
group = "com.github.GTNewHorizons"
if (project.hasProperty("customArchiveBaseName") && customArchiveBaseName) {
archivesBaseName = customArchiveBaseName
base {
archivesName = customArchiveBaseName
}
} else {
archivesBaseName = modId
base {
archivesName = modId
}
}
@@ -465,10 +504,19 @@ sourceSets {
}
}
if (file('addon.gradle').exists()) {
if (file('addon.gradle.kts').exists()) {
apply from: 'addon.gradle.kts'
} else if (file('addon.gradle').exists()) {
apply from: 'addon.gradle'
}
// File for local tweaks not commited to Git
if (file('addon.local.gradle.kts').exists()) {
apply from: 'addon.local.gradle.kts'
} else if (file('addon.local.gradle').exists()) {
apply from: 'addon.local.gradle'
}
// Allow unsafe repos but warn
repositories.configureEach { repo ->
if (repo instanceof org.gradle.api.artifacts.repositories.UrlArtifactRepository) {
@@ -479,7 +527,14 @@ repositories.configureEach { repo ->
}
}
apply from: 'repositories.gradle'
if (file('repositories.gradle.kts').exists()) {
apply from: 'repositories.gradle.kts'
} else if (file('repositories.gradle').exists()) {
apply from: 'repositories.gradle'
} else {
logger.error("Neither repositories.gradle.kts nor repositories.gradle was found, make sure you extracted the full ExampleMod template.")
throw new RuntimeException("Missing repositories.gradle[.kts]")
}
configurations {
runtimeClasspath.extendsFrom(runtimeOnlyNonPublishable)
@@ -520,9 +575,6 @@ repositories {
maven {
name 'Overmind forge repo mirror'
url 'https://gregtech.overminddl1.com/'
mavenContent {
excludeGroup("net.minecraftforge") // missing the `universal` artefact
}
}
maven {
name = "GTNH Maven"
@@ -537,24 +589,34 @@ repositories {
}
}
if (includeWellKnownRepositories.toBoolean()) {
maven {
name "CurseMaven"
url "https://cursemaven.com"
content {
exclusiveContent {
forRepository {
maven {
name "CurseMaven"
url "https://cursemaven.com"
}
}
filter {
includeGroup "curse.maven"
}
}
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
filter {
includeGroup "maven.modrinth"
}
}
maven {
name = "ic2"
url = "https://maven.ic2.player.to/"
metadataSources {
mavenPom()
artifact()
url = getURL("https://maven2.ic2.player.to/", "https://maven.ic2.player.to/")
content {
includeGroup "net.industrial-craft"
}
}
maven {
name = "ic2-mirror"
url = "https://maven2.ic2.player.to/"
metadataSources {
mavenPom()
artifact()
@@ -569,11 +631,13 @@ repositories {
def mixinProviderGroup = "io.github.legacymoddingmc"
def mixinProviderModule = "unimixins"
def mixinProviderVersion = "0.1.7.1"
def mixinProviderVersion = "0.1.13"
def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule}:${mixinProviderVersion}"
def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev"
ext.mixinProviderSpec = mixinProviderSpec
def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json'
dependencies {
if (usesMixins.toBoolean()) {
annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3')
@@ -585,7 +649,7 @@ dependencies {
}
}
if (usesMixins.toBoolean()) {
implementation(mixinProviderSpec)
implementation(modUtils.enableMixins(mixinProviderSpec, mixingConfigRefMap))
} else if (forceEnableMixins.toBoolean()) {
runtimeOnlyNonPublishable(mixinProviderSpec)
}
@@ -608,15 +672,37 @@ configurations.all {
substitute module('com.github.GTNewHorizons:SpongePoweredMixin') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
substitute module('com.github.GTNewHorizons:SpongeMixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
substitute module('io.github.legacymoddingmc:unimixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Our previous unimixins upload was missing the dev classifier")
substitute module('org.scala-lang:scala-library:2.11.1') using module('org.scala-lang:scala-library:2.11.5') because('To allow mixing with Java 8 targets')
}
}
apply from: 'dependencies.gradle'
dependencies {
constraints {
def minGtnhLibVersion = "0.0.13"
implementation("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") {
because("fixes duplicate mod errors in java 17 configurations using old gtnhlib")
}
runtimeOnly("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") {
because("fixes duplicate mod errors in java 17 configurations using old gtnhlib")
}
devOnlyNonPublishable("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") {
because("fixes duplicate mod errors in java 17 configurations using old gtnhlib")
}
runtimeOnlyNonPublishable("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") {
because("fixes duplicate mod errors in java 17 configurations using old gtnhlib")
}
}
}
def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json'
def mixinTmpDir = buildDir.path + File.separator + 'tmp' + File.separator + 'mixins'
def refMap = "${mixinTmpDir}" + File.separator + mixingConfigRefMap
def mixinSrg = "${mixinTmpDir}" + File.separator + "mixins.srg"
if (file('dependencies.gradle.kts').exists()) {
apply from: 'dependencies.gradle.kts'
} else if (file('dependencies.gradle').exists()) {
apply from: 'dependencies.gradle'
} else {
logger.error("Neither dependencies.gradle.kts nor dependencies.gradle was found, make sure you extracted the full ExampleMod template.")
throw new RuntimeException("Missing dependencies.gradle[.kts]")
}
tasks.register('generateAssets') {
group = "GTNH Buildscript"
@@ -648,46 +734,17 @@ tasks.register('generateAssets') {
}
if (usesMixins.toBoolean()) {
tasks.named("reobfJar", ReobfuscatedJar).configure {
extraSrgFiles.from(mixinSrg)
}
tasks.named("processResources").configure {
dependsOn("generateAssets")
}
tasks.named("compileJava", JavaCompile).configure {
doFirst {
new File(mixinTmpDir).mkdirs()
}
options.compilerArgs += [
"-AreobfSrgFile=${tasks.reobfJar.srg.get().asFile}",
"-AoutSrgFile=${mixinSrg}",
"-AoutRefMapFile=${refMap}",
// Elan: from what I understand they are just some linter configs so you get some warning on how to properly code
"-XDenableSunApiLintControl",
"-XDignore.symbol.file"
]
}
pluginManager.withPlugin('org.jetbrains.kotlin.kapt') {
kapt {
correctErrorTypes = true
javacOptions {
option("-AreobfSrgFile=${tasks.reobfJar.srg.get().asFile}")
option("-AoutSrgFile=$mixinSrg")
option("-AoutRefMapFile=$refMap")
}
}
tasks.configureEach { task ->
if (task.name == "kaptKotlin") {
task.doFirst {
new File(mixinTmpDir).mkdirs()
}
}
}
}
}
tasks.named("processResources", ProcessResources).configure {
@@ -705,7 +762,6 @@ tasks.named("processResources", ProcessResources).configure {
}
if (usesMixins.toBoolean()) {
from refMap
dependsOn("compileJava", "compileScala")
}
}
@@ -724,23 +780,14 @@ ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies"
}
dependencies {
def lwjgl3ifyVersion = '1.3.5'
def asmVersion = '9.4'
def lwjgl3ifyVersion = '1.5.7'
if (modId != 'lwjgl3ify') {
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
}
if (modId != 'hodgepodge') {
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.13')
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.35')
}
java17PatchDependencies('net.minecraft:launchwrapper:1.15') {transitive = false}
java17PatchDependencies("org.ow2.asm:asm:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-commons:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-tree:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-analysis:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-util:${asmVersion}")
java17PatchDependencies('org.ow2.asm:asm-deprecated:7.1')
java17PatchDependencies("org.apache.commons:commons-lang3:3.12.0")
java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false}
}
@@ -979,6 +1026,9 @@ idea {
}
}
runConfigurations {
"0. Build and Test"(Gradle) {
taskNames = ["build"]
}
"1. Run Client"(Gradle) {
taskNames = ["runClient"]
}
@@ -1098,6 +1148,14 @@ tasks.named("processIdeaSettings").configure {
dependsOn("injectTags")
}
tasks.named("ideVirtualMainClasses").configure {
// Make IntelliJ "Build project" build the mod jars
dependsOn("jar", "reobfJar")
if (!disableSpotless) {
dependsOn("spotlessCheck")
}
}
// workaround variable hiding in pom processing
def projectConfigs = project.configurations
@@ -1116,14 +1174,15 @@ publishing {
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
}
}
repositories {
maven {
url = "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases"
allowInsecureProtocol = true
credentials {
username = System.getenv("MAVEN_USER") ?: "NONE"
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
if (usesMavenPublishing.toBoolean() && System.getenv("MAVEN_USER") != null) {
maven {
url = mavenPublishUrl
allowInsecureProtocol = mavenPublishUrl.startsWith("http://") // Mostly for the GTNH maven
credentials {
username = System.getenv("MAVEN_USER") ?: "NONE"
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
}
}
}
}
@@ -1238,7 +1297,7 @@ def addCurseForgeRelation(String type, String name) {
// Updating
def buildscriptGradleVersion = "8.1.1"
def buildscriptGradleVersion = "8.5"
tasks.named('wrapper', Wrapper).configure {
gradleVersion = buildscriptGradleVersion
@@ -1276,12 +1335,14 @@ tasks.register('faq') {
description = 'Prints frequently asked questions about building a project'
doLast {
print("If your build fails to fetch dependencies, they might have been deleted and replaced by newer " +
"versions.\nCheck if the versions you try to fetch are still on the distributing sites.\n" +
"The links can be found in repositories.gradle and build.gradle:repositories, " +
"not build.gradle:buildscript.repositories - this one is for gradle plugin metadata.\n\n" +
print("If your build fails to fetch dependencies, run './gradlew updateDependencies'. " +
"Or you can manually check if the versions are still on the distributing sites - " +
"the links can be found in repositories.gradle and build.gradle:repositories, " +
"but not build.gradle:buildscript.repositories - those ones are for gradle plugin metadata.\n\n" +
"If your build fails to recognize the syntax of new Java versions, enable Jabel in your " +
"gradle.properties. See how it's done in GTNH ExampleMod/gradle.properties.")
"gradle.properties. See how it's done in GTNH ExampleMod/gradle.properties. " +
"However, keep in mind that Jabel enables only syntax features, but not APIs that were introduced in " +
"Java 9 or later.")
}
}
@@ -1342,8 +1403,14 @@ boolean isNewBuildScriptVersionAvailable() {
String currentBuildScript = getFile("build.gradle").getText()
String currentBuildScriptHash = getVersionHash(currentBuildScript)
String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText()
String availableBuildScriptHash = getVersionHash(availableBuildScript)
String availableBuildScriptHash
try {
String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText()
availableBuildScriptHash = getVersionHash(availableBuildScript)
} catch (IOException e) {
logger.warn("Could not check for buildscript update availability: {}", e.message)
return false
}
boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash
return !isUpToDate
@@ -1508,3 +1575,36 @@ def getSecondaryArtifacts() {
if (apiPackage) secondaryArtifacts += [apiJar]
return secondaryArtifacts
}
def getURL(String main, String fallback) {
return pingURL(main, 10000) ? main : fallback
}
// credit: https://stackoverflow.com/a/3584332
def pingURL(String url, int timeout) {
url = url.replaceFirst("^https", "http") // Otherwise an exception may be thrown on invalid SSL certificates.
try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection()
connection.setConnectTimeout(timeout)
connection.setReadTimeout(timeout)
connection.setRequestMethod("HEAD")
int responseCode = connection.getResponseCode()
return 200 <= responseCode && responseCode <= 399
} catch (IOException ignored) {
return false
}
}
// For easier scripting of things that require variables defined earlier in the buildscript
if (file('addon.late.gradle.kts').exists()) {
apply from: 'addon.late.gradle.kts'
} else if (file('addon.late.gradle').exists()) {
apply from: 'addon.late.gradle'
}
// File for local tweaks not commited to Git
if (file('addon.late.local.gradle.kts').exists()) {
apply from: 'addon.late.local.gradle.kts'
} else if (file('addon.late.local.gradle').exists()) {
apply from: 'addon.late.local.gradle'
}
+15 -15
View File
@@ -1,26 +1,26 @@
// Add your dependencies here
dependencies {
api('com.github.GTNewHorizons:EnderCore:0.2.14:dev')
implementation('com.github.GTNewHorizons:ForestryMC:4.6.7:dev')
implementation('com.github.GTNewHorizons:NotEnoughItems:2.3.53-GTNH:dev')
api('com.github.GTNewHorizons:EnderCore:0.3.0:dev')
implementation('com.github.GTNewHorizons:ForestryMC:4.7.0:dev')
implementation('com.github.GTNewHorizons:NotEnoughItems:2.4.13-GTNH:dev')
implementation("com.github.GTNewHorizons:GTNHLib:0.0.13:dev")
api('com.github.GTNewHorizons:BuildCraft:7.1.33:dev')
api('com.github.GTNewHorizons:BuildCraft:7.1.38:dev')
api('curse.maven:cofh-lib-220333:2388748') // https://www.curseforge.com/minecraft/mc-mods/cofh-lib/files/2388748
shadowImplementation('cglib:cglib-nodep:3.3.0')
compileOnly('com.github.GTNewHorizons:waila:1.6.0:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-215-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Baubles:1.0.1.16:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.43.46:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:Railcraft:9.14.1:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:StorageDrawers:1.2.0-GTNH:api') {transitive = false}
implementation('com.github.GTNewHorizons:Chisel:2.11.0-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:OpenComputers:1.9.5-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:waila:1.6.5:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-304-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Baubles:1.0.3:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.03:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:Railcraft:9.15.3:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:StorageDrawers:1.12.2-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Chisel:2.12.3-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:OpenComputers:1.10.0-GTNH:api') {transitive = false}
compileOnly('curse.maven:minefactory-reloaded-66672:2366150') // https://www.curseforge.com/minecraft/mc-mods/minefactory-reloaded/files/2366150
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('curse.maven:ee3-65509:2305023') // https://www.curseforge.com/minecraft/mc-mods/ee3/files/2305023
compileOnly(deobf('https://media.forgecdn.net/files/2269/339/ComputerCraft1.75.jar')) // https://www.curseforge.com/minecraft/mc-mods/computercraft/files/2269339
compileOnly(deobf('https://media.forgecdn.net/files/2426/270/Mekanism-1.7.10-9.1.0.281.jar')) // https://aidancbrady.com/mekanism/download/
compileOnly(deobf('https://immibis.com/mcmoddl/files/immibis-microblocks-59.1.2.jar'))
compileOnly(rfg.deobf('curse.maven:computercraft-67504:2269339')) // https://www.curseforge.com/minecraft/mc-mods/computercraft/files/2269339
compileOnly(rfg.deobf('curse.maven:mekanism-268560:2475797')) // https://www.curseforge.com/minecraft/mc-mods/mekanism/files/2475797
compileOnly(rfg.deobf('maven.modrinth:immibis-microblocks:59.1.2')) // https://modrinth.com/mod/immibis-microblocks/version/59.1.2
}
Binary file not shown.
+2 -1
View File
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+10 -6
View File
@@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -133,10 +130,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
@@ -144,7 +144,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -152,7 +152,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -197,6 +197,10 @@ if "$cygwin" || "$msys" ; then
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
@@ -62,6 +62,7 @@ import crazypants.enderio.conduit.item.ItemItemConduit;
import crazypants.enderio.conduit.item.filter.ItemBasicItemFilter;
import crazypants.enderio.conduit.item.filter.ItemBigItemFilter;
import crazypants.enderio.conduit.item.filter.ItemExistingItemFilter;
import crazypants.enderio.conduit.item.filter.ItemLimitedItemFilter;
import crazypants.enderio.conduit.item.filter.ItemModItemFilter;
import crazypants.enderio.conduit.item.filter.ItemPowerItemFilter;
import crazypants.enderio.conduit.liquid.ItemLiquidConduit;
@@ -264,6 +265,7 @@ public class EnderIO {
public static ItemBasicItemFilter itemBasicFilterUpgrade;
public static ItemBigItemFilter itemBigFilterUpgrade;
public static ItemExistingItemFilter itemExistingItemFilter;
public static ItemLimitedItemFilter itemLimitedItemFilter;
public static ItemModItemFilter itemModItemFilter;
public static ItemPowerItemFilter itemPowerItemFilter;
public static ItemExtractSpeedUpgrade itemExtractSpeedUpgrade;
@@ -469,6 +471,7 @@ public class EnderIO {
itemBasicFilterUpgrade = ItemBasicItemFilter.create();
itemBigFilterUpgrade = ItemBigItemFilter.create();
itemExistingItemFilter = ItemExistingItemFilter.create();
itemLimitedItemFilter = ItemLimitedItemFilter.create();
itemModItemFilter = ItemModItemFilter.create();
itemPowerItemFilter = ItemPowerItemFilter.create();
itemExtractSpeedUpgrade = ItemExtractSpeedUpgrade.create();
@@ -788,7 +791,7 @@ public class EnderIO {
@EventHandler
public void loadComplete(FMLLoadCompleteEvent event) {
processImc(FMLInterModComms.fetchRuntimeMessages(this)); // Some mods send IMCs during PostInit, so we catch
// them here.
// them here.
}
private static String getXPJuiceName() {
@@ -2,10 +2,13 @@ package crazypants.enderio;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
public final class Log {
public static final Logger LOGGER = LogManager.getLogger(EnderIO.MODID);
public static final Marker securityMarker = MarkerManager.getMarker("SuspiciousPackets");
public static void warn(String msg) {
LOGGER.warn(msg);
@@ -18,6 +18,7 @@ public enum ModObject {
itemBasicFilterUpgrade,
itemBigFilterUpgrade,
itemExistingItemFilter,
itemLimitedItemFilter,
itemModItemFilter,
itemPowerItemFilter,
itemExtractSpeedUpgrade,
@@ -4,10 +4,20 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import cofh.api.energy.IEnergyContainerItem;
import crazypants.enderio.config.Config;
public interface IItemOfTravel extends IEnergyContainerItem {
boolean isActive(EntityPlayer ep, ItemStack equipped);
void extractInternal(ItemStack equipped, int power);
/**
* @param equipped player who is currently holding this item. caller will ensure the item held has your Item as item
* type
* @return -1 if method not supported, or max(can extract, power), e.g. 0 if item is empty.
*/
default int canExtractInternal(ItemStack equipped, int power) {
return Config.strictTPItemChecking ? 0 : -1;
}
}
@@ -94,11 +94,10 @@ public interface ITelePad extends ITravelAccessable {
/**
* Util method to set all coords using a {@link BlockCoord} object.
*
* @param coords The coords to set this telepad to.
* @see #setX(int)
* @see #setY(int)
* @see #setZ(int)
*
* @param coords The coords to set this telepad to.
*/
void setCoords(BlockCoord coords);
@@ -14,9 +14,8 @@ import cpw.mods.fml.common.eventhandler.Cancelable;
* <li>Staff of travelling</li>
* <li>Telepad</li>
* </ul>
*
* <p>
* As well as any externally added teleports, assuming they fire this event manually.
*
*/
@Cancelable
public class TeleportEntityEvent extends EntityEvent {
@@ -88,7 +88,7 @@ public abstract class AbstractConduit implements IConduit {
* If this is true, it will trigger a reconnection on the next Tick.
* <p>
* Use the method needUpdateConnections() instead of setting this to true.
*
*
* @see needUpdateConnections()
*/
private boolean needUpdateConnections = false;
@@ -47,7 +47,13 @@ import crazypants.enderio.api.tool.ITool;
import crazypants.enderio.conduit.facade.ItemConduitFacade.FacadeType;
import crazypants.enderio.conduit.geom.CollidableComponent;
import crazypants.enderio.conduit.geom.ConduitConnectorType;
import crazypants.enderio.conduit.gui.*;
import crazypants.enderio.conduit.gui.ExternalConnectionContainer;
import crazypants.enderio.conduit.gui.GuiExternalConnection;
import crazypants.enderio.conduit.gui.GuiExternalConnectionSelector;
import crazypants.enderio.conduit.gui.PacketFluidChannel;
import crazypants.enderio.conduit.gui.PacketFluidFilter;
import crazypants.enderio.conduit.gui.PacketOpenConduitUI;
import crazypants.enderio.conduit.gui.PacketSlotVisibility;
import crazypants.enderio.conduit.gui.item.PacketExistingItemFilterSnapshot;
import crazypants.enderio.conduit.gui.item.PacketModItemFilter;
import crazypants.enderio.conduit.liquid.PacketFluidLevel;
@@ -635,8 +641,8 @@ public class BlockConduitBundle extends BlockEio
@Override
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
ItemStack equipped = player.getCurrentEquippedItem();
if (!player.isSneaking() || equipped == null || equipped.getItem() != EnderIO.itemYetaWench) {
ITool tool = ToolUtil.getEquippedTool(player);
if (!player.isSneaking() || tool == null || !tool.canUse(player.getCurrentEquippedItem(), player, x, y, z)) {
return;
}
ConduitUtil.openConduitGui(world, x, y, z, player);
@@ -1,6 +1,15 @@
package crazypants.enderio.conduit;
import static crazypants.enderio.gui.IconEIO.*;
import static crazypants.enderio.gui.IconEIO.CROSS;
import static crazypants.enderio.gui.IconEIO.TICK;
import static crazypants.enderio.gui.IconEIO.WRENCH_OVERLAY_FLUID;
import static crazypants.enderio.gui.IconEIO.WRENCH_OVERLAY_FLUID_OFF;
import static crazypants.enderio.gui.IconEIO.WRENCH_OVERLAY_ITEM;
import static crazypants.enderio.gui.IconEIO.WRENCH_OVERLAY_ITEM_OFF;
import static crazypants.enderio.gui.IconEIO.WRENCH_OVERLAY_POWER;
import static crazypants.enderio.gui.IconEIO.WRENCH_OVERLAY_POWER_OFF;
import static crazypants.enderio.gui.IconEIO.WRENCH_OVERLAY_REDSTONE;
import static crazypants.enderio.gui.IconEIO.WRENCH_OVERLAY_REDSTONE_OFF;
import java.util.List;
@@ -55,11 +64,10 @@ public class ConduitDisplayMode {
* Use this constructor if you have custom display logic, it will use {@code IConduit.class} as the conduitType, and
* the passed name as the override name.
*
* @see #ConduitDisplayMode(Class, IWidgetIcon, IWidgetIcon)
*
* @param name The override name.
* @param widgetSelected The widget to render when this type is selected.
* @param widgetUnselected The widget to render when this type is unselected.
* @see #ConduitDisplayMode(Class, IWidgetIcon, IWidgetIcon)
*/
public ConduitDisplayMode(String name, IWidgetIcon widgetSelected, IWidgetIcon widgetUnselected) {
this(IConduit.class, widgetSelected, widgetUnselected);
@@ -1,9 +1,20 @@
package crazypants.enderio.conduit;
import static crazypants.enderio.ModObject.blockPainter;
import static crazypants.enderio.material.Alloy.*;
import static crazypants.enderio.material.Material.*;
import static crazypants.enderio.material.endergy.AlloyEndergy.*;
import static crazypants.enderio.material.Alloy.CONDUCTIVE_IRON;
import static crazypants.enderio.material.Alloy.ELECTRICAL_STEEL;
import static crazypants.enderio.material.Alloy.END_STEEL;
import static crazypants.enderio.material.Alloy.ENERGETIC_ALLOY;
import static crazypants.enderio.material.Alloy.PHASED_GOLD;
import static crazypants.enderio.material.Alloy.REDSTONE_ALLOY;
import static crazypants.enderio.material.Material.CONDUIT_BINDER;
import static crazypants.enderio.material.Material.PHASED_IRON_NUGGET;
import static crazypants.enderio.material.endergy.AlloyEndergy.CRUDE_STEEL;
import static crazypants.enderio.material.endergy.AlloyEndergy.CRYSTALLINE_ALLOY;
import static crazypants.enderio.material.endergy.AlloyEndergy.CRYSTALLINE_PINK_SLIME;
import static crazypants.enderio.material.endergy.AlloyEndergy.ENERGETIC_SILVER;
import static crazypants.enderio.material.endergy.AlloyEndergy.MELODIC_ALLOY;
import static crazypants.enderio.material.endergy.AlloyEndergy.STELLAR_ALLOY;
import static crazypants.util.RecipeUtil.addShaped;
import net.minecraft.init.Blocks;
@@ -590,6 +601,9 @@ public class ConduitRecipes {
'f',
advFilter);
ItemStack limitedFilter = new ItemStack(EnderIO.itemLimitedItemFilter, 1, 0);
addShaped(limitedFilter, " ", "cfc", " ", 'c', new ItemStack(Items.comparator, 1, 0), 'f', advFilter);
ItemStack powerFilt = new ItemStack(EnderIO.itemPowerItemFilter);
addShaped(powerFilt, " p ", "pcp", " p ", 'p', Items.paper, 'c', EnderIO.itemConduitProbe);
@@ -92,7 +92,7 @@ public class ConduitUtil {
}
}
if (con.getNetwork() != null) { // this should have been destroyed when destroying the neighbours network but
// lets just make
// lets just make
// sure
con.getNetwork().destroyNetwork();
}
@@ -50,7 +50,6 @@ import crazypants.enderio.conduit.power.IPowerConduit;
import crazypants.enderio.conduit.redstone.IRedstoneConduit;
import crazypants.enderio.conduit.redstone.InsulatedRedstoneConduit;
import crazypants.enderio.config.Config;
import li.cil.oc.api.network.*;
import li.cil.oc.api.network.Message;
import li.cil.oc.api.network.Node;
import mekanism.api.gas.Gas;
@@ -1,6 +1,7 @@
package crazypants.enderio.conduit.gui;
import java.awt.*;
import java.awt.Color;
import java.awt.Rectangle;
import java.util.ArrayList;
import javax.annotation.Nonnull;
@@ -10,6 +10,7 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@@ -24,12 +25,14 @@ import crazypants.enderio.conduit.gui.item.InventoryUpgrades;
import crazypants.enderio.conduit.item.IItemConduit;
import crazypants.enderio.conduit.item.SpeedUpgrade;
import crazypants.enderio.conduit.item.filter.IItemFilter;
import crazypants.enderio.machine.gui.IContainerWithTileEntity;
import crazypants.enderio.network.PacketHandler;
public class ExternalConnectionContainer extends ContainerEnder<InventoryUpgrades> {
public class ExternalConnectionContainer extends ContainerEnder<InventoryUpgrades> implements IContainerWithTileEntity {
private final IItemConduit itemConduit;
private final ForgeDirection direction;
private final TileEntity te;
private int speedUpgradeSlotLimit = 15;
@@ -52,6 +55,7 @@ public class ExternalConnectionContainer extends ContainerEnder<InventoryUpgrade
super(playerInv, new InventoryUpgrades(bundle.getConduit(IItemConduit.class), dir));
this.direction = dir;
this.itemConduit = bundle.getConduit(IItemConduit.class);
this.te = (TileEntity) bundle;
slotLocations.addAll(playerSlotLocations.values());
int x;
@@ -280,6 +284,11 @@ public class ExternalConnectionContainer extends ContainerEnder<InventoryUpgrade
return copystack;
}
@Override
public TileEntity getTileEntity() {
return te;
}
private class FilterSlot extends Slot {
public FilterSlot(IInventory par1iInventory, int par2, int par3, int par4) {
@@ -49,6 +49,7 @@ public class PacketFluidChannel extends AbstractConduitPacket<ILiquidConduit>
@Override
public IMessage onMessage(PacketFluidChannel message, MessageContext ctx) {
if (isInvalidPacketForGui(message, ctx)) return null;
ILiquidConduit conduit = message.getTileCasted(ctx);
if (!(conduit instanceof AbstractEnderLiquidConduit)) {
return null;
@@ -53,6 +53,7 @@ public class PacketFluidFilter extends AbstractConduitPacket<ILiquidConduit>
@Override
public IMessage onMessage(PacketFluidFilter message, MessageContext ctx) {
if (isInvalidPacketForGui(message, ctx)) return null;
ILiquidConduit conduit = message.getTileCasted(ctx);
if (!(conduit instanceof AbstractEnderLiquidConduit)) {
return null;
@@ -1,6 +1,6 @@
package crazypants.enderio.conduit.gui.item;
import java.awt.*;
import java.awt.Color;
import javax.annotation.Nonnull;
@@ -0,0 +1,202 @@
package crazypants.enderio.conduit.gui.item;
import net.minecraft.client.gui.GuiButton;
import org.lwjgl.opengl.GL11;
import com.enderio.core.client.gui.button.CycleButton;
import com.enderio.core.client.gui.button.IconButton;
import com.enderio.core.client.gui.button.ToggleButton;
import crazypants.enderio.EnderIO;
import crazypants.enderio.conduit.gui.GuiExternalConnection;
import crazypants.enderio.conduit.item.filter.FuzzyMode;
import crazypants.enderio.conduit.item.filter.ItemFilter;
import crazypants.enderio.gui.GuiContainerBaseEIO;
import crazypants.enderio.gui.IconEIO;
public class LimitedItemFilterGui implements IItemFilterGui {
private static final int ID_WHITELIST = GuiExternalConnection.nextButtonId();
private static final int ID_NBT = GuiExternalConnection.nextButtonId();
private static final int ID_META = GuiExternalConnection.nextButtonId();
private static final int ID_ORE_DICT = GuiExternalConnection.nextButtonId();
private static final int ID_STICKY = GuiExternalConnection.nextButtonId();
private static final int ID_FUZZY = GuiExternalConnection.nextButtonId();
private final GuiContainerBaseEIO gui;
private final ToggleButton useMetaB;
private final ToggleButton useNbtB;
private final IconButton whiteListB;
private final ToggleButton useOreDictB;
private final ToggleButton stickyB;
private final CycleButton<FuzzyMode> fuzzyB;
private final IItemFilterContainer filterContainer;
private final ItemFilter filter;
private int buttonIdOffset;
private int xOffset;
private int yOffset;
final boolean isStickyModeAvailable;
private boolean isInput;
public LimitedItemFilterGui(GuiContainerBaseEIO gui, IItemFilterContainer filterContainer,
boolean isStickyModeAvailable, boolean isInput) {
this(gui, filterContainer, isStickyModeAvailable, isInput, isInput ? 104 : 6, 96, isInput ? 0 : 256);
}
public LimitedItemFilterGui(GuiContainerBaseEIO gui, IItemFilterContainer filterContainer,
boolean isStickyModeAvailable, boolean isInput, int xOffset, int yOffset, int buttonIdOffset) {
this.gui = gui;
this.isStickyModeAvailable = isStickyModeAvailable;
this.filterContainer = filterContainer;
this.xOffset = xOffset;
this.yOffset = yOffset;
this.buttonIdOffset = buttonIdOffset;
this.isInput = isInput;
filter = filterContainer.getItemFilter();
int butLeft = xOffset;
int x = butLeft;
int y = yOffset + 40;
whiteListB = new IconButton(gui, ID_WHITELIST + buttonIdOffset, x, y, IconEIO.FILTER_WHITELIST);
whiteListB.setToolTip(getWhitelistTooltips(false));
x += 16;
useMetaB = new ToggleButton(gui, ID_META + buttonIdOffset, x, y, IconEIO.FILTER_META_OFF, IconEIO.FILTER_META);
useMetaB.setSelectedToolTip(EnderIO.lang.localize("gui.conduit.item.matchMetaData"));
useMetaB.setUnselectedToolTip(EnderIO.lang.localize("gui.conduit.item.ignoreMetaData"));
useMetaB.setPaintSelectedBorder(false);
x += 16;
stickyB = new ToggleButton(
gui,
ID_STICKY + buttonIdOffset,
x,
y,
IconEIO.FILTER_STICKY_OFF,
IconEIO.FILTER_STICKY);
stickyB.setSelectedToolTip(EnderIO.lang.localizeList("gui.conduit.item.stickyEnabled"));
stickyB.setUnselectedToolTip(EnderIO.lang.localize("gui.conduit.item.stickyDisbaled"));
stickyB.setPaintSelectedBorder(false);
if (isStickyModeAvailable) x += 16;
useOreDictB = new ToggleButton(
gui,
ID_ORE_DICT + buttonIdOffset,
x,
y,
IconEIO.FILTER_ORE_DICT_OFF,
IconEIO.FILTER_ORE_DICT);
useOreDictB.setSelectedToolTip(EnderIO.lang.localize("gui.conduit.item.oreDicEnabled"));
useOreDictB.setUnselectedToolTip(EnderIO.lang.localize("gui.conduit.item.oreDicDisabled"));
useOreDictB.setPaintSelectedBorder(false);
x += 16;
useNbtB = new ToggleButton(gui, ID_NBT + buttonIdOffset, x, y, IconEIO.FILTER_NBT_OFF, IconEIO.FILTER_NBT);
useNbtB.setSelectedToolTip(EnderIO.lang.localize("gui.conduit.item.matchNBT"));
useNbtB.setUnselectedToolTip(EnderIO.lang.localize("gui.conduit.item.ignoreNBT"));
useNbtB.setPaintSelectedBorder(false);
x += 16;
fuzzyB = new CycleButton(gui, ID_FUZZY + buttonIdOffset, x, y, FuzzyMode.class);
}
public void createFilterSlots() {
filter.createGhostSlots(gui.getGhostSlots(), xOffset + 1, yOffset + 1, new Runnable() {
@Override
public void run() {
sendFilterChange();
}
});
}
@Override
public void mouseClicked(int x, int y, int par3) {}
@Override
public void updateButtons() {
ItemFilter activeFilter = filter;
useNbtB.onGuiInit();
useNbtB.setSelected(activeFilter.isMatchNBT());
useOreDictB.onGuiInit();
useOreDictB.setSelected(activeFilter.isUseOreDict());
if (isStickyModeAvailable) {
stickyB.onGuiInit();
stickyB.setSelected(activeFilter.isSticky());
}
fuzzyB.onGuiInit();
fuzzyB.setMode(activeFilter.getFuzzyMode());
useMetaB.onGuiInit();
useMetaB.setSelected(activeFilter.isMatchMeta());
}
@Override
public void actionPerformed(GuiButton guiButton) {
if (guiButton.id == ID_META + buttonIdOffset) {
filter.setMatchMeta(useMetaB.isSelected());
sendFilterChange();
} else if (guiButton.id == ID_NBT + buttonIdOffset) {
filter.setMatchNBT(useNbtB.isSelected());
sendFilterChange();
} else if (guiButton.id == ID_STICKY + buttonIdOffset) {
filter.setSticky(stickyB.isSelected());
sendFilterChange();
} else if (guiButton.id == ID_ORE_DICT + buttonIdOffset) {
filter.setUseOreDict(useOreDictB.isSelected());
sendFilterChange();
} else if (guiButton.id == ID_FUZZY + buttonIdOffset) {
filter.setFuzzyMode(fuzzyB.getMode());
sendFilterChange();
} else if (guiButton.id == ID_WHITELIST + buttonIdOffset) {
filter.setBlacklist(!filter.isBlacklist());
sendFilterChange();
}
}
private void sendFilterChange() {
updateButtons();
filterContainer.onFilterChanged();
}
@Override
public void deactivate() {
useNbtB.detach();
useMetaB.detach();
useOreDictB.detach();
whiteListB.detach();
stickyB.detach();
fuzzyB.detach();
}
@Override
public void renderCustomOptions(int top, float par1, int par2, int par3) {
GL11.glColor3f(1, 1, 1);
gui.bindGuiTexture(1);
gui.drawTexturedModalRect(gui.getGuiLeft() + xOffset, gui.getGuiTop() + yOffset, 0, 238, 18 * 5, 18);
gui.drawTexturedModalRect(gui.getGuiLeft() + xOffset, gui.getGuiTop() + yOffset + 20, 0, 238, 18 * 5, 18);
}
private String[] getWhitelistTooltips(boolean isBlacklist) {
if (isBlacklist) {
return new String[] { EnderIO.lang.localize("gui.conduit.item.blacklist"),
EnderIO.lang.localize("gui.conduit.item.blacklist.tooltip.0"),
EnderIO.lang.localize("gui.conduit.item.blacklist.tooltip.1") };
} else {
return new String[] { EnderIO.lang.localize("gui.conduit.item.whitelist"),
EnderIO.lang.localize("gui.conduit.item.whitelist.tooltip.0"),
EnderIO.lang.localize("gui.conduit.item.whitelist.tooltip.1") };
}
}
}
@@ -58,6 +58,7 @@ public class PacketExistingItemFilterSnapshot extends AbstractConduitPacket<IIte
@Override
public PacketExistingItemFilterSnapshot onMessage(PacketExistingItemFilterSnapshot message, MessageContext ctx) {
if (isInvalidPacketForGui(message, ctx)) return null;
IItemConduit conduit = message.getTileCasted(ctx);
if (conduit == null) {
return null;
@@ -58,6 +58,7 @@ public class PacketModItemFilter extends AbstractConduitPacket<IItemConduit>
@Override
public IMessage onMessage(PacketModItemFilter message, MessageContext ctx) {
if (isInvalidPacketForGui(message, ctx)) return null;
IItemConduit conduit = message.getTileCasted(ctx);
if (conduit == null) {
return null;
@@ -612,8 +612,7 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
@Override
public ItemStack createItem() {
ItemStack result = new ItemStack(EnderIO.itemItemConduit, 1, metaData);
return result;
return new ItemStack(EnderIO.itemItemConduit, 1, metaData);
}
@Override
@@ -22,6 +22,7 @@ import com.enderio.core.common.util.RoundRobinIterator;
import crazypants.enderio.conduit.ConnectionMode;
import crazypants.enderio.conduit.item.filter.IItemFilter;
import crazypants.enderio.conduit.item.filter.ItemFilterLimited;
import crazypants.enderio.config.Config;
import crazypants.enderio.machine.invpanel.TileInventoryPanel;
@@ -155,6 +156,7 @@ public class NetworkedInventory {
int numSlots = slotIndices.length;
ItemStack extractItem = null;
int maxExtracted = con.getMaximumExtracted(conDir);
final IItemFilter filter = con.getInputFilter(conDir);
int slot = -1;
int slotChecksPerTick = Math.min(numSlots, ItemConduitNetwork.MAX_SLOT_CHECK_PER_TICK);
@@ -162,12 +164,23 @@ public class NetworkedInventory {
int index = nextSlot(numSlots);
slot = slotIndices[index];
ItemStack item = getInventory().getStackInSlot(slot);
if (canExtractItem(item)) {
extractItem = item.copy();
if (getInventory().canExtractItem(slot, extractItem, inventorySide)) {
if (doTransfer(extractItem, slot, maxExtracted)) {
setNextStartingSlot(slot);
return true;
if (item != null) {
if (filter != null && filter.isLimited()) {
final int count = ((ItemFilterLimited) filter).getInsertLimitInv(getInventory(), item);
if (count <= 0) {
continue;
} else if (count < item.stackSize) {
item = item.copy();
item.stackSize = count;
}
}
if (canExtractItem(item)) {
extractItem = item.copy();
if (getInventory().canExtractItem(slot, extractItem, inventorySide)) {
if (doTransfer(extractItem, slot, maxExtracted)) {
setNextStartingSlot(slot);
return true;
}
}
}
}
@@ -183,7 +196,11 @@ public class NetworkedInventory {
if (filter == null) {
return true;
}
return filter.doesItemPassFilter(this, itemStack);
if (filter.isLimited()) {
return filter.isValid() && ((ItemFilterLimited) filter).doesItemPassFilterInv(this, itemStack);
} else {
return filter.doesItemPassFilter(this, itemStack);
}
}
private boolean doTransfer(ItemStack extractedItem, int slot, int maxExtract) {
@@ -278,7 +295,20 @@ public class NetworkedInventory {
}
IItemFilter filter = con.getOutputFilter(conDir);
if (filter != null) {
if (!filter.doesItemPassFilter(this, item)) {
if (filter.isLimited()) {
final int count = filter.getMaxCountThatCanPassFilter(item);
if (count <= 0) {
return 0;
} else {
final int maxInsert = ((ItemFilterLimited) filter).getInsertLimit(getInventory(), item);
if (maxInsert <= 0) {
return 0;
} else if (maxInsert < item.stackSize) {
item = item.copy();
item.stackSize = maxInsert;
}
}
} else if (!filter.doesItemPassFilter(this, item)) {
return 0;
}
}
@@ -30,7 +30,7 @@ public interface IItemFilter {
/**
* Checks if the given item passes the filter or not.
*
*
* @param inv the attached inventory - or null when used without an inventory (eg for a GUI)
* @param item the item to check
* @return true if the item is allowed to pass
@@ -41,10 +41,18 @@ public interface IItemFilter {
boolean isValid();
default boolean isLimited() {
return false;
}
boolean isSticky();
void createGhostSlots(List<GhostSlot> slots, int xOffset, int yOffset, Runnable cb);
default int getMaxCountThatCanPassFilter(ItemStack item) {
return 1;
}
int getSlotCount();
default String getUnlocalizedName() {
@@ -98,7 +98,7 @@ public class ItemFilter implements IInventory, IItemFilter {
return isBlacklist ? !allow : allow;
}
private boolean itemMatched(ItemStack item) {
protected boolean itemMatched(ItemStack item) {
if (item == null) {
return false;
}
@@ -145,7 +145,7 @@ public class ItemFilter implements IInventory, IItemFilter {
return matched;
}
private boolean isOreDicMatch(int filterItemIndex, ItemStack item) {
protected boolean isOreDicMatch(int filterItemIndex, ItemStack item) {
int[] ids1 = getCachedIds(filterItemIndex);
if (ids1 == null || ids1.length == 0) {
return false;
@@ -164,8 +164,9 @@ public class ItemFilter implements IInventory, IItemFilter {
return false;
}
private boolean isNBTMatch(ItemStack filter, ItemStack item) {
if (filter.stackTagCompound == null && item.stackTagCompound == null) return true;
protected boolean isNBTMatch(ItemStack filter, ItemStack item) {
if (filter.stackTagCompound == null && (item.stackTagCompound == null || item.stackTagCompound.hasNoTags()))
return true;
if (filter.stackTagCompound == null || item.stackTagCompound == null) return false;
if (!filter.getTagCompound().hasKey("GEN")) return filter.stackTagCompound.equals(item.stackTagCompound);
NBTTagCompound filterTag = (NBTTagCompound) filter.getTagCompound().copy();
@@ -202,7 +203,7 @@ public class ItemFilter implements IInventory, IItemFilter {
return !isItemListEmpty();
}
private boolean isItemListEmpty() {
protected boolean isItemListEmpty() {
for (ItemStack item : items) {
if (item != null) {
return false;
@@ -0,0 +1,242 @@
package crazypants.enderio.conduit.item.filter;
import java.util.List;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import com.enderio.core.client.gui.widget.GhostSlot;
import cofh.lib.util.helpers.MathHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.conduit.gui.GuiExternalConnection;
import crazypants.enderio.conduit.gui.item.IItemFilterGui;
import crazypants.enderio.conduit.gui.item.ItemConduitFilterContainer;
import crazypants.enderio.conduit.gui.item.LimitedItemFilterGui;
import crazypants.enderio.conduit.item.IItemConduit;
import crazypants.enderio.conduit.item.NetworkedInventory;
public class ItemFilterLimited extends ItemFilter {
public ItemFilterLimited() {
this(10, true);
}
public ItemFilterLimited(int numItems, boolean isAdvanced) {
super(numItems, isAdvanced);
}
@Override
public String getInventoryName() {
return "Limited Item Filter";
}
@Override
@SideOnly(Side.CLIENT)
public IItemFilterGui getGui(GuiExternalConnection gui, IItemConduit itemConduit, boolean isInput) {
ItemConduitFilterContainer cont = new ItemConduitFilterContainer(itemConduit, gui.getDir(), isInput);
LimitedItemFilterGui limitedItemFilterGui = new LimitedItemFilterGui(gui, cont, !isInput, isInput);
limitedItemFilterGui.createFilterSlots();
return limitedItemFilterGui;
}
@Override
public void createGhostSlots(List<GhostSlot> slots, int xOffset, int yOffset, Runnable cb) {
int index = 0;
int numRows = (int) (double) (items.length / 5);
for (int row = 0; row < numRows; ++row) {
for (int col = 0; col < 5; ++col) {
int x = xOffset + col * 18;
int y = yOffset + row * 20;
slots.add(new ItemFilterGhostSlot(index, x, y, cb));
index++;
}
}
}
@Override
public int getMaxCountThatCanPassFilter(ItemStack item) {
if (item == null || item.getItem() == null) {
return 0;
}
int count = 0;
for (int i = 0; i < items.length; i++) {
ItemStack invStack = items[i];
if (invStack != null && itemStackMatched(invStack, item, i)) {
count += invStack.stackSize;
}
}
return count;
}
@Override
public boolean isLimited() {
return true;
}
public int getInsertLimit(ISidedInventory inv, ItemStack item) {
if (item == null || item.getItem() == null) {
return 0;
}
int count = 0;
for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack invStack = inv.getStackInSlot(i);
if (invStack != null && itemStackMatched(invStack, item, i)) {
count += invStack.stackSize;
}
}
return getMaxCountThatCanPassFilter(item) - count;
}
public int getInsertLimitInv(ISidedInventory inv, ItemStack item) {
return -getInsertLimit(inv, item);
}
public boolean doesCountPassFilter(int maxCount) {
return maxCount > 0;
}
@Override
public boolean doesItemPassFilter(NetworkedInventory inv, ItemStack item) {
return isValid() && itemMatched(item) && doesCountPassFilter(getInsertLimit(inv.getInventory(), item));
}
// Filter in extract slot
public boolean doesItemPassFilterInv(NetworkedInventory inv, ItemStack item) {
return isValid() && itemMatched(item) && doesCountPassFilter(getInsertLimitInv(inv.getInventory(), item));
}
protected boolean itemStackMatched(ItemStack item, ItemStack filter, int slot) {
if (item == null) {
return false;
}
boolean checkDamage = fuzzyMode != FuzzyMode.DISABLED;
boolean damageMatched = false;
if (checkDamage && item.getItem().isDamageable()) {
damageMatched = fuzzyMode.compare(item);
}
if (isItemListEmpty()) {
if (checkDamage) {
return damageMatched;
} else {
return false;
}
}
boolean matched = false;
if (filter != null && item.getItem() == filter.getItem()) {
matched = true;
if (checkDamage && !damageMatched) {
matched = false;
} else if (matchMeta && item.getItemDamage() != filter.getItemDamage()) {
matched = false;
} else if (matchNBT && !isNBTMatch(item, filter)) {
matched = false;
}
}
if (!matched && useOreDict && isOreDicMatch(filter, item)) {
matched = true;
}
return matched;
}
public boolean isOreDicMatch(ItemStack filter, ItemStack item) {
int[] id_filter = OreDictionary.getOreIDs(filter);
if (id_filter.length == 0) {
return false;
}
int[] id_item = OreDictionary.getOreIDs(item);
if (id_item.length == 0) {
return false;
}
for (int id1 : id_filter) {
for (int id2 : id_item) {
if (id1 == id2) {
return true;
}
}
}
return false;
}
@Override
public ItemStack decrStackSize(int fromSlot, int amount) {
if ((fromSlot < 0) || (fromSlot >= items.length)) {
return null;
}
oreIds.set(fromSlot, null);
ItemStack item = items[fromSlot];
items[fromSlot] = null;
return item.splitStack(amount);
}
@Override
public String toString() {
return "Limited" + super.toString();
}
@Override
public String getUnlocalizedName() {
return "gui.limited_item_filter";
}
class ItemFilterGhostSlot extends GhostSlot {
private final int slot;
private final Runnable cb;
private final int adjustOnShift;
ItemFilterGhostSlot(int slot, int x, int y, Runnable cb) {
this.x = x;
this.y = y;
this.slot = slot;
this.cb = cb;
this.displayStdOverlay = true;
this.stackSizeLimit = 64;
this.adjustOnShift = 10;
}
@Override
public void putStack(ItemStack stack) {
if (stack != null) {
stack = stack.copy();
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
if (Mouse.isButtonDown(0) || Mouse.getEventDWheel() > 0) {
if (stack.stackSize - 1 == 1) {
stack.stackSize += adjustOnShift - 2;
} else {
stack.stackSize = MathHelper
.clamp(stack.stackSize + adjustOnShift - 1, 1, stack.getMaxStackSize());
}
} else if (Mouse.isButtonDown(1) || Mouse.getEventDWheel() < 0) {
if (stack.stackSize + 1 == 1) {
stack.stackSize++;
} else {
stack.stackSize = MathHelper
.clamp(stack.stackSize - adjustOnShift + 1, 1, stack.getMaxStackSize());
}
}
}
}
items[slot] = stack;
cb.run();
}
@Override
public ItemStack getStack() {
return items[slot];
}
}
}
@@ -0,0 +1,73 @@
package crazypants.enderio.conduit.item.filter;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import com.enderio.core.api.client.gui.IResourceTooltipProvider;
import com.enderio.core.client.handlers.SpecialTooltipHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.ModObject;
import crazypants.enderio.conduit.item.FilterRegister;
public class ItemLimitedItemFilter extends Item implements IItemFilterUpgrade, IResourceTooltipProvider {
public static ItemLimitedItemFilter create() {
ItemLimitedItemFilter result = new ItemLimitedItemFilter();
result.init();
return result;
}
protected ItemLimitedItemFilter() {
setCreativeTab(EnderIOTab.tabEnderIO);
setUnlocalizedName(ModObject.itemLimitedItemFilter.unlocalisedName);
setMaxDamage(0);
setMaxStackSize(64);
}
protected void init() {
GameRegistry.registerItem(this, ModObject.itemLimitedItemFilter.unlocalisedName);
}
@Override
public IItemFilter createFilterFromStack(ItemStack stack) {
IItemFilter filter = new ItemFilterLimited();
if (stack.stackTagCompound != null && stack.stackTagCompound.hasKey("filter")) {
filter.readFromNBT(stack.stackTagCompound.getCompoundTag("filter"));
}
return filter;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
itemIcon = IIconRegister.registerIcon("enderio:limitedItemFilter");
}
@Override
public String getUnlocalizedNameForTooltip(ItemStack stack) {
return getUnlocalizedName();
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
if (FilterRegister.isFilterSet(par1ItemStack)) {
if (SpecialTooltipHandler.showAdvancedTooltips()) {
par3List.add(EnumChatFormatting.ITALIC + EnderIO.lang.localize("itemConduitFilterUpgrade.configured"));
par3List.add(
EnumChatFormatting.ITALIC
+ EnderIO.lang.localize("itemConduitFilterUpgrade.clearConfigMethod"));
}
}
}
}
@@ -13,7 +13,6 @@ import crazypants.enderio.EnderIOTab;
import crazypants.enderio.ModObject;
/**
*
* @author matthias
*/
public class ItemPowerItemFilter extends Item implements IItemFilterUpgrade, IResourceTooltipProvider {
@@ -19,7 +19,6 @@ import crazypants.enderio.conduit.item.NetworkedInventory;
import io.netty.buffer.ByteBuf;
/**
*
* @author matthias
*/
public class PowerItemFilter implements IItemFilter {
@@ -157,11 +157,11 @@ public abstract class AbstractLiquidConduit extends AbstractConduit implements I
boolean res;
if (mode == RedstoneControlMode.OFF) {
// if checking for no signal, must be no signal from both
res = mode.isConditionMet(mode, signal)
res = RedstoneControlMode.isConditionMet(mode, signal)
&& (col != DyeColor.RED || isConditionMetByExternalSignal(dir, mode, col));
} else {
// if checking for a signal, either is fine
res = mode.isConditionMet(mode, signal)
res = RedstoneControlMode.isConditionMet(mode, signal)
|| (col == DyeColor.RED && isConditionMetByExternalSignal(dir, mode, col));
}
return res;
@@ -180,7 +180,12 @@ public abstract class AbstractLiquidConduit extends AbstractConduit implements I
}
}
return mode.isConditionMet(mode, externalSignal);
return RedstoneControlMode.isConditionMet(mode, externalSignal);
}
@Override
protected ConnectionMode getDefaultConnectionMode() {
return ConnectionMode.INPUT;
}
@Override
@@ -1,6 +1,10 @@
package crazypants.enderio.conduit.liquid;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
@@ -1,7 +1,5 @@
package crazypants.enderio.conduit.liquid;
import static com.enderio.core.client.render.CubeRenderer.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -19,6 +17,7 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import com.enderio.core.client.render.BoundingBox;
import com.enderio.core.client.render.CubeRenderer;
import com.enderio.core.client.render.RenderUtil;
import com.enderio.core.common.util.ForgeDirectionOffsets;
import com.enderio.core.common.vecmath.Vector2f;
@@ -96,12 +95,12 @@ public class LiquidConduitRenderer extends DefaultConduitRenderer implements IRe
List<Vertex> corners = component.bound
.getCornersWithUvForFace(component.dir, tex.getMinU(), tex.getMaxU(), tex.getMinV(), tex.getMaxV());
for (Vertex c : corners) {
addVecWithUV(c.xyz, c.uv.x, c.uv.y);
CubeRenderer.addVecWithUV(c.xyz, c.uv.x, c.uv.y);
}
// back face
for (int i = corners.size() - 1; i >= 0; i--) {
Vertex c = corners.get(i);
addVecWithUV(c.xyz, c.uv.x, c.uv.y);
CubeRenderer.addVecWithUV(c.xyz, c.uv.x, c.uv.y);
}
}
}
@@ -304,7 +303,7 @@ public class LiquidConduitRenderer extends DefaultConduitRenderer implements IRe
float transY = (bound.sizeY() - sizeY) / 2;
Vector3d translation = new Vector3d(0, transY, 0);
setupVertices(bound.translate(translation));
CubeRenderer.setupVertices(bound.translate(translation));
}
private void calculateRatios(LiquidConduit conduit) {
@@ -6,6 +6,7 @@ import net.minecraft.world.World;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.IConduitBundle;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class AbstractConduitPacket<T extends IConduit> extends AbstractConduitBundlePacket {
@@ -50,4 +51,12 @@ public class AbstractConduitPacket<T extends IConduit> extends AbstractConduitBu
IConduitBundle bundle = (IConduitBundle) te;
return (T) bundle.getConduit(getConType());
}
/**
* Validates if TileEntity received from client is actually the one player is interacting with. It prevents
* malicious user disturbing random machine settings etc.
*/
protected static boolean isInvalidPacketForGui(AbstractConduitPacket<?> message, MessageContext ctx) {
return PacketUtil.isInvalidPacketForGui(ctx, message.getTileEntity(message.getWorld(ctx)), message.getClass());
}
}
@@ -40,6 +40,7 @@ public class PacketConnectionMode extends AbstractConduitPacket<IConduit>
@Override
public IMessage onMessage(PacketConnectionMode message, MessageContext ctx) {
if (isInvalidPacketForGui(message, ctx)) return null;
IConduit conduit = message.getTileCasted(ctx);
if (conduit == null) {
return null;
@@ -45,6 +45,7 @@ public class PacketExtractMode extends AbstractConduitPacket<IExtractor>
@Override
public IMessage onMessage(PacketExtractMode message, MessageContext ctx) {
if (isInvalidPacketForGui(message, ctx)) return null;
message.getTileCasted(ctx).setExtractionRedstoneMode(message.mode, message.dir);
message.getTileCasted(ctx).setExtractionSignalColor(message.dir, message.color);
message.getWorld(ctx).markBlockForUpdate(message.x, message.y, message.z);
@@ -68,6 +68,7 @@ public class PacketItemConduitFilter extends AbstractConduitPacket<IItemConduit>
@Override
public IMessage onMessage(PacketItemConduitFilter message, MessageContext ctx) {
if (isInvalidPacketForGui(message, ctx)) return null;
IItemConduit conduit = message.getTileCasted(ctx);
conduit.setSelfFeedEnabled(message.dir, message.loopMode);
conduit.setRoundRobinEnabled(message.dir, message.roundRobin);
@@ -40,6 +40,7 @@ public class PacketOCConduitSignalColor extends AbstractConduitPacket<IOCConduit
@Override
public IMessage onMessage(PacketOCConduitSignalColor message, MessageContext ctx) {
if (isInvalidPacketForGui(message, ctx)) return null;
message.getTileCasted(ctx).setSignalColor(message.dir, message.col);
message.getWorld(ctx).markBlockForUpdate(message.x, message.y, message.z);
return null;
@@ -38,6 +38,7 @@ public class PacketRedstoneConduitOutputStrength extends AbstractConduitPacket<I
@Override
public IMessage onMessage(PacketRedstoneConduitOutputStrength message, MessageContext ctx) {
if (isInvalidPacketForGui(message, ctx)) return null;
IInsulatedRedstoneConduit tile = message.getTileCasted(ctx);
if (tile != null) {
tile.setOutputStrength(message.dir, message.isStrong);
@@ -40,6 +40,7 @@ public class PacketRedstoneConduitSignalColor extends AbstractConduitPacket<IIns
@Override
public IMessage onMessage(PacketRedstoneConduitSignalColor message, MessageContext ctx) {
if (isInvalidPacketForGui(message, ctx)) return null;
message.getTileCasted(ctx).setSignalColor(message.dir, message.col);
message.getWorld(ctx).markBlockForUpdate(message.x, message.y, message.z);
return null;
@@ -39,6 +39,7 @@ public class PacketRoundRobinMode extends AbstractConduitPacket<ILiquidConduit>
@Override
public IMessage onMessage(PacketRoundRobinMode message, MessageContext ctx) {
if (isInvalidPacketForGui(message, ctx)) return null;
final ILiquidConduit conduit = message.getTileCasted(ctx);
if (conduit instanceof AbstractEnderLiquidConduit) {
((AbstractEnderLiquidConduit) conduit).setRoundRobin(message.dir, message.roundRobin);
@@ -1,7 +1,14 @@
package crazypants.enderio.conduit.render;
import static com.enderio.core.client.render.CubeRenderer.*;
import static net.minecraftforge.common.util.ForgeDirection.*;
import static com.enderio.core.client.render.CubeRenderer.addVecWithUV;
import static com.enderio.core.client.render.CubeRenderer.setupVertices;
import static com.enderio.core.client.render.CubeRenderer.verts;
import static net.minecraftforge.common.util.ForgeDirection.DOWN;
import static net.minecraftforge.common.util.ForgeDirection.EAST;
import static net.minecraftforge.common.util.ForgeDirection.NORTH;
import static net.minecraftforge.common.util.ForgeDirection.SOUTH;
import static net.minecraftforge.common.util.ForgeDirection.UP;
import static net.minecraftforge.common.util.ForgeDirection.WEST;
import java.util.Collection;
import java.util.List;
@@ -161,6 +161,7 @@ public final class Config {
public static String[] travelStaffBlinkBlackList = new String[] { "minecraft:bedrock", "Thaumcraft:blockWarded" };
public static float travelAnchorZoomScale = 0.2f;
public static boolean travelStaffSearchOptimize = true;
public static boolean validateTravelEventServerside = true;
/** The max distance for travelling to a Travel Anchor. */
public static int teleportStaffMaxDistance = 2048;
@@ -563,6 +564,8 @@ public final class Config {
public static float inventoryPanelExtractCostPerItem = 12.0f;
public static float inventoryPanelExtractCostPerOperation = 32.0f;
public static boolean strictTPItemChecking = true;
public static void load(FMLPreInitializationEvent event) {
PacketHandler.INSTANCE
.registerMessage(PacketConfigSync.class, PacketConfigSync.class, PacketHandler.nextID(), Side.CLIENT);
@@ -1212,6 +1215,13 @@ public final class Config {
+ "This config is experimental, so if you encounter any strange behavior, please report to GTNH developer.")
.getBoolean(travelStaffSearchOptimize);
validateTravelEventServerside = config.get(
sectionStaff.name,
"validateTravelEventServerside",
validateTravelEventServerside,
"If set to true: Server will validate if player actually can teleport. False will allow hacking, but also allows Staff of Traveling Keybind mod to work.")
.getBoolean(validateTravelEventServerside);
teleportStaffMaxDistance = config
.get(
sectionStaff.name,
@@ -2884,6 +2894,12 @@ public final class Config {
0.0f,
10000.0f,
"Internal power used per extract operation (independent of stack size)");
strictTPItemChecking = config.get(
sectionMisc.name,
"strictTPItemChecking",
strictTPItemChecking,
"If true, turn on strict checking of item energy checking. This might cause traveling tools from third party mods to fire fake security warnings on server side and not function correctly.")
.getBoolean(strictTPItemChecking);
}
public static void checkYetaAccess() {
@@ -1,8 +1,13 @@
package crazypants.enderio.item;
import static crazypants.enderio.material.Alloy.*;
import static crazypants.enderio.material.Alloy.CONDUCTIVE_IRON;
import static crazypants.enderio.material.Alloy.DARK_STEEL;
import static crazypants.enderio.material.Alloy.ELECTRICAL_STEEL;
import static crazypants.enderio.material.Alloy.END_STEEL;
import static crazypants.enderio.material.Alloy.ENERGETIC_ALLOY;
import static crazypants.enderio.material.Alloy.SOULARIUM;
import static crazypants.enderio.material.Material.VIBRANT_CYSTAL;
import static crazypants.enderio.material.endergy.AlloyEndergy.*;
import static crazypants.enderio.material.endergy.AlloyEndergy.STELLAR_ALLOY;
import static crazypants.util.RecipeUtil.addShaped;
import net.minecraft.init.Blocks;
@@ -331,6 +331,11 @@ public class ItemDarkSteelPickaxe extends ItemPickaxe
extractEnergy(equipped, power, false);
}
@Override
public int canExtractInternal(ItemStack equipped, int power) {
return Math.min(getEnergyStored(equipped), power);
}
private boolean isTravelUpgradeActive(EntityPlayer ep, ItemStack equipped) {
return isEquipped(ep) && ep.isSneaking() && TravelUpgrade.loadFromItem(equipped) != null;
}
@@ -394,6 +394,11 @@ public class ItemDarkSteelSword extends ItemSword
extractEnergy(equipped, power, false);
}
@Override
public int canExtractInternal(ItemStack equipped, int power) {
return Math.min(getEnergyStored(equipped), power);
}
private boolean isTravelUpgradeActive(EntityPlayer ep, ItemStack equipped) {
return isEquipped(ep) && ep.isSneaking() && TravelUpgrade.loadFromItem(equipped) != null;
}
@@ -489,11 +489,7 @@ public abstract class AbstractMachineEntity extends TileEntityEio
if (stack == null || stack.stackTagCompound == null) {
return;
}
NBTTagCompound root = stack.stackTagCompound;
if (!root.hasKey("eio.abstractMachine")) {
return;
}
readCommon(root);
readCommon(stack.stackTagCompound);
}
@Override
@@ -41,9 +41,9 @@ public class AbstractMachineRenderer implements ISimpleBlockRenderingHandler, II
private CustomCubeRenderer ccr = new CustomCubeRenderer();
private PaintedBlockRenderer paintedRenderer = new PaintedBlockRenderer(this.getRenderId(), null); // passthrough
// renderer for
// paintable
// machines
// renderer for
// paintable
// machines
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
@@ -9,7 +9,10 @@ import com.enderio.core.common.vecmath.VecmathUtil;
import crazypants.enderio.EnderIO;
import crazypants.enderio.network.PacketHandler;
import crazypants.enderio.power.*;
import crazypants.enderio.power.Capacitors;
import crazypants.enderio.power.ICapacitor;
import crazypants.enderio.power.IInternalPoweredTile;
import crazypants.enderio.power.PowerHandlerUtil;
public abstract class AbstractPoweredMachineEntity extends AbstractMachineEntity implements IInternalPoweredTile {
@@ -2,19 +2,25 @@ package crazypants.enderio.machine;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.tileentity.TileEntity;
public class ContainerNoInv extends Container {
import crazypants.enderio.machine.gui.IContainerWithTileEntity;
private IInventory inv;
public class ContainerNoInv extends Container implements IContainerWithTileEntity {
public ContainerNoInv(IInventory inv) {
super();
this.inv = inv;
private final AbstractMachineEntity tile;
public ContainerNoInv(AbstractMachineEntity tile) {
this.tile = tile;
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return inv.isUseableByPlayer(player);
return tile.isUseableByPlayer(player);
}
@Override
public TileEntity getTileEntity() {
return tile;
}
}
@@ -12,7 +12,6 @@ import crazypants.enderio.machine.recipe.RecipeBonusType;
* progress' recipe for a machine is stored to and retrieved from a machines TileEntity soley based on its UID.
*
* @author cp
*
*/
public interface IMachineRecipe {
@@ -50,7 +49,7 @@ public interface IMachineRecipe {
/**
* Returns the output from a single 'cycle' of the recipe (even if the inputs would allow the recipe to be crafted
* several times).
*
* <p>
* This method must not return null. If no output is generated an empty array should be returned.
*
* @param randomChance a random number to be used as a seed for determining whether '% chance' outputs are returned.
@@ -1,9 +1,19 @@
package crazypants.enderio.machine;
import static crazypants.enderio.EnderIO.itemBasicCapacitor;
import static crazypants.enderio.material.Alloy.*;
import static crazypants.enderio.material.Material.*;
import static crazypants.util.RecipeUtil.*;
import static crazypants.enderio.material.Alloy.DARK_STEEL;
import static crazypants.enderio.material.Alloy.ELECTRICAL_STEEL;
import static crazypants.enderio.material.Alloy.END_STEEL;
import static crazypants.enderio.material.Alloy.ENERGETIC_ALLOY;
import static crazypants.enderio.material.Alloy.PHASED_GOLD;
import static crazypants.enderio.material.Alloy.PHASED_IRON;
import static crazypants.enderio.material.Alloy.REDSTONE_ALLOY;
import static crazypants.enderio.material.Alloy.SOULARIUM;
import static crazypants.enderio.material.Material.CONDUIT_BINDER;
import static crazypants.enderio.material.Material.ENDER_CRYSTAL;
import static crazypants.enderio.material.Material.PULSATING_CYSTAL;
import static crazypants.enderio.material.Material.SILICON;
import static crazypants.enderio.material.Material.VIBRANT_CYSTAL;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
@@ -24,6 +34,7 @@ import crazypants.enderio.material.FrankenSkull;
import crazypants.enderio.material.MachinePart;
import crazypants.enderio.material.Material;
import crazypants.enderio.power.Capacitors;
import crazypants.util.RecipeUtil;
public class MachineRecipes {
@@ -62,13 +73,24 @@ public class MachineRecipes {
String silicon = SILICON.oreDict;
if (Config.addPeacefulRecipes) {
addShaped(frankenZombie, "gdg", "dzd", "gdg", 'g', "ingotGold", 'd', "gemDiamond", 'z', zombieController);
addShaped(sentientEnder, "ddd", "ded", "dgd", 'g', "blockGold", 'd', "gemDiamond", 'e', enderRes);
RecipeUtil.addShaped(
frankenZombie,
"gdg",
"dzd",
"gdg",
'g',
"ingotGold",
'd',
"gemDiamond",
'z',
zombieController);
RecipeUtil
.addShaped(sentientEnder, "ddd", "ded", "dgd", 'g', "blockGold", 'd', "gemDiamond", 'e', enderRes);
}
// stirling gen
ItemStack stirlingGen = new ItemStack(EnderIO.blockStirlingGenerator, 1, 0);
addShaped(
RecipeUtil.addShaped(
stirlingGen,
"bbb",
"bfb",
@@ -85,7 +107,7 @@ public class MachineRecipes {
// Combustion Gen
ItemStack res = new ItemStack(EnderIO.blockTank, 1, 0);
ItemStack comGen = new ItemStack(EnderIO.blockCombustionGenerator, 1, 0);
addShaped(
RecipeUtil.addShaped(
comGen,
"eee",
"rmr",
@@ -103,7 +125,7 @@ public class MachineRecipes {
// ZombieGen
ItemStack zg = new ItemStack(EnderIO.blockZombieGenerator, 1, 0);
addShaped(
RecipeUtil.addShaped(
zg,
"eee",
"qzq",
@@ -117,7 +139,7 @@ public class MachineRecipes {
// FrankenzombieGen
ItemStack fg = new ItemStack(EnderIO.blockFrankenZombieGenerator, 1, 0);
addShaped(
RecipeUtil.addShaped(
fg,
"eee",
"qzq",
@@ -131,7 +153,7 @@ public class MachineRecipes {
// EnderGen
ItemStack eg = new ItemStack(EnderIO.blockEnderGenerator, 1, 0);
addShaped(
RecipeUtil.addShaped(
eg,
"eee",
"qzq",
@@ -145,17 +167,18 @@ public class MachineRecipes {
// KillerJoe
ItemStack kj = new ItemStack(EnderIO.blockKillerJoe, 1, 0);
addShaped(kj, "sss", "qzq", "qqq", 's', darkSteel, 'q', fusedQuartz, 'z', frankenZombie);
RecipeUtil.addShaped(kj, "sss", "qzq", "qqq", 's', darkSteel, 'q', fusedQuartz, 'z', frankenZombie);
// Wireless charger
ItemStack wirelessCharger = new ItemStack(EnderIO.blockWirelessCharger);
// addShaped(wirelessCharger, "svs", "imi", "scs", 's', electricSteel, 'i', silicon, 'm', machineChassi, 'c',
// capacitor3, 'v', vibCry);
addShaped(wirelessCharger, "sss", "ses", "scs", 's', electricalSteel, 'c', capacitor3, 'e', enderRes);
RecipeUtil
.addShaped(wirelessCharger, "sss", "ses", "scs", 's', electricalSteel, 'c', capacitor3, 'e', enderRes);
// Crafter
ItemStack crafter = new ItemStack(EnderIO.blockCrafter, 1, 0);
addShaped(
RecipeUtil.addShaped(
crafter,
"iti",
"imi",
@@ -177,7 +200,7 @@ public class MachineRecipes {
} else {
zombieBit = zombieController;
}
addShaped(
RecipeUtil.addShaped(
poweredSpawner,
"ese",
"eme",
@@ -202,15 +225,16 @@ public class MachineRecipes {
} else {
glassSides = "glass";
}
addShaped(reservoir, "gfg", "gcg", "gfg", 'g', glassSides, 'c', Items.cauldron, 'f', fusedQuartz);
RecipeUtil
.addShaped(reservoir, "gfg", "gcg", "gfg", 'g', glassSides, 'c', Items.cauldron, 'f', fusedQuartz);
}
// Tanks
ItemStack basicTank = new ItemStack(EnderIO.blockTank, 1, 0);
addShaped(basicTank, "ibi", "bgb", "ibi", 'g', "glass", 'i', "ingotIron", 'b', Blocks.iron_bars);
RecipeUtil.addShaped(basicTank, "ibi", "bgb", "ibi", 'g', "glass", 'i', "ingotIron", 'b', Blocks.iron_bars);
ItemStack advTank = new ItemStack(EnderIO.blockTank, 1, 1);
addShaped(
RecipeUtil.addShaped(
advTank,
"ibi",
"bgb",
@@ -225,7 +249,7 @@ public class MachineRecipes {
// mill
ItemStack crusher = new ItemStack(EnderIO.blockCrusher, 1, 0);
if (Config.useHardRecipes) {
addShaped(
RecipeUtil.addShaped(
crusher,
"ooo",
"fmf",
@@ -241,7 +265,7 @@ public class MachineRecipes {
'o',
Blocks.obsidian);
} else {
addShaped(
RecipeUtil.addShaped(
crusher,
"fff",
"imi",
@@ -259,7 +283,7 @@ public class MachineRecipes {
// alloy smelter
ItemStack alloySmelter = new ItemStack(EnderIO.blockAlloySmelter, 1, 0);
if (Config.useHardRecipes) {
addShaped(
RecipeUtil.addShaped(
alloySmelter,
"bfb",
"fmf",
@@ -273,7 +297,7 @@ public class MachineRecipes {
'f',
Blocks.furnace);
} else {
addShaped(
RecipeUtil.addShaped(
alloySmelter,
"bfb",
"fmf",
@@ -290,7 +314,7 @@ public class MachineRecipes {
// Vat
ItemStack still = new ItemStack(EnderIO.blockVat, 1, 0);
addShaped(
RecipeUtil.addShaped(
still,
"eve",
"tmt",
@@ -310,13 +334,14 @@ public class MachineRecipes {
ItemStack capBank1 = BlockItemCapBank
.createItemStackWithPower(CapBankType.getMetaFromType(CapBankType.SIMPLE), 0);
addShaped(capBank1, "bcb", "cmc", "bcb", 'b', "ingotIron", 'c', capacitor, 'm', "blockRedstone");
RecipeUtil.addShaped(capBank1, "bcb", "cmc", "bcb", 'b', "ingotIron", 'c', capacitor, 'm', "blockRedstone");
ItemStack capBank2 = BlockItemCapBank
.createItemStackWithPower(CapBankType.getMetaFromType(CapBankType.ACTIVATED), 0);
addShaped(capBank2, "bcb", "cmc", "bcb", 'b', electricalSteel, 'c', capacitor2, 'm', "blockRedstone");
RecipeUtil
.addShaped(capBank2, "bcb", "cmc", "bcb", 'b', electricalSteel, 'c', capacitor2, 'm', "blockRedstone");
ItemStack capBank3 = BlockItemCapBank
.createItemStackWithPower(CapBankType.getMetaFromType(CapBankType.VIBRANT), 0);
addShaped(capBank3, "bcb", "cmc", "bcb", 'b', electricalSteel, 'c', capacitor3, 'm', vibCry);
RecipeUtil.addShaped(capBank3, "bcb", "cmc", "bcb", 'b', electricalSteel, 'c', capacitor3, 'm', vibCry);
ConvertOldRecipe convertRecipe = new ConvertOldRecipe();
GameRegistry.addRecipe(convertRecipe);
@@ -351,7 +376,7 @@ public class MachineRecipes {
// painter
ItemStack painter = new ItemStack(EnderIO.blockPainter, 1, 0);
if (Config.useHardRecipes) {
addShaped(
RecipeUtil.addShaped(
painter,
"qqq",
"mdm",
@@ -367,7 +392,7 @@ public class MachineRecipes {
'd',
"gemDiamond");
} else {
addShaped(
RecipeUtil.addShaped(
painter,
"qdq",
"mMm",
@@ -391,7 +416,7 @@ public class MachineRecipes {
} else {
zombieBit = zombieController;
}
addShaped(
RecipeUtil.addShaped(
farm,
"ehe",
"eme",
@@ -411,7 +436,7 @@ public class MachineRecipes {
// transceiver
ItemStack transceiver = new ItemStack(EnderIO.blockTransceiver, 1, 0);
if (Config.transceiverUseEasyRecipe) {
addShaped(
RecipeUtil.addShaped(
transceiver,
"oeo",
"pdp",
@@ -427,7 +452,7 @@ public class MachineRecipes {
'd',
Items.diamond);
} else {
addShaped(
RecipeUtil.addShaped(
transceiver,
"oeo",
"pdp",
@@ -442,7 +467,7 @@ public class MachineRecipes {
fusedQuartz,
'd',
endCry);
addShapeless(transceiver, new ItemStack(EnderIO.blockHyperCube, 1, 0));
RecipeUtil.addShapeless(transceiver, new ItemStack(EnderIO.blockHyperCube, 1, 0));
}
}
@@ -454,7 +479,7 @@ public class MachineRecipes {
ItemStack vibSolarPanel = new ItemStack(EnderIO.blockSolarPanel, 1, 2);
if (Config.useHardRecipes) {
addShaped(
RecipeUtil.addShaped(
solarPanel,
"efe",
"pfp",
@@ -469,7 +494,7 @@ public class MachineRecipes {
energeticAlloy,
'p',
phasedGold);
addShaped(
RecipeUtil.addShaped(
advSolarPanel,
"efe",
"pfp",
@@ -484,7 +509,7 @@ public class MachineRecipes {
phasedIron,
'p',
phasedGold);
addShaped(
RecipeUtil.addShaped(
vibSolarPanel,
"efe",
"pfp",
@@ -500,7 +525,7 @@ public class MachineRecipes {
'p',
phasedGold);
} else {
addShaped(
RecipeUtil.addShaped(
solarPanel,
"efe",
"pfp",
@@ -515,7 +540,7 @@ public class MachineRecipes {
energeticAlloy,
'c',
redstoneAlloy);
addShaped(
RecipeUtil.addShaped(
advSolarPanel,
"efe",
"pfp",
@@ -530,7 +555,7 @@ public class MachineRecipes {
phasedIron,
'c',
electricalSteel);
addShaped(
RecipeUtil.addShaped(
vibSolarPanel,
"efe",
"pfp",
@@ -553,7 +578,7 @@ public class MachineRecipes {
ItemStack powerConduit = new ItemStack(EnderIO.itemPowerConduit, 1, 0);
ItemStack redstoneConduit = new ItemStack(EnderIO.itemRedstoneConduit, 1, 2);
ItemStack mJMonitor = new ItemStack(EnderIO.blockPowerMonitor, 1, 0);
addShaped(
RecipeUtil.addShaped(
mJMonitor,
"sms",
"sMs",
@@ -571,11 +596,11 @@ public class MachineRecipes {
// Enchanter
ItemStack enchanter = new ItemStack(EnderIO.blockEnchanter);
addShaped(enchanter, "dbd", "sss", " s ", 'd', "gemDiamond", 'b', Items.book, 's', darkSteel);
RecipeUtil.addShaped(enchanter, "dbd", "sss", " s ", 'd', "gemDiamond", 'b', Items.book, 's', darkSteel);
// Vacuum Chest
ItemStack vacuumChest = new ItemStack(EnderIO.blockVacuumChest);
addShaped(vacuumChest, "iii", "ici", "ipi", 'i', "ingotIron", 'c', "chestWood", 'p', pulCry);
RecipeUtil.addShaped(vacuumChest, "iii", "ici", "ipi", 'i', "ingotIron", 'c', "chestWood", 'p', pulCry);
// Soul Binder
Object enderBit;
@@ -588,7 +613,7 @@ public class MachineRecipes {
ItemStack zombieSkull = new ItemStack(Items.skull, 1, 4);
ItemStack skeletonSkull = new ItemStack(Items.skull, 1, 0);
ItemStack soulBinder = new ItemStack(EnderIO.blockSoulFuser);
addShaped(
RecipeUtil.addShaped(
soulBinder,
"ses",
"zmc",
@@ -609,7 +634,7 @@ public class MachineRecipes {
// Attractor
ItemStack attractor = new ItemStack(EnderIO.blockAttractor);
ItemStack attractorCrystal = new ItemStack(EnderIO.itemMaterial, 1, Material.ATTRACTOR_CRYSTAL.ordinal());
addShaped(
RecipeUtil.addShaped(
attractor,
" c ",
"ese",
@@ -629,7 +654,7 @@ public class MachineRecipes {
EnderIO.blockEndermanSkull,
1,
BlockEndermanSkull.SkullType.TORMENTED.ordinal());
addShaped(
RecipeUtil.addShaped(
aversion,
" c ",
"ese",
@@ -646,12 +671,12 @@ public class MachineRecipes {
// Experience
ItemStack xp = new ItemStack(EnderIO.blockExperianceOblisk);
ItemStack xpItem = new ItemStack(EnderIO.itemXpTransfer);
addShaped(xp, " x ", " s ", "sms", 's', soularium, 'm', machineChassi, 'x', xpItem);
RecipeUtil.addShaped(xp, " x ", " s ", "sms", 's', soularium, 'm', machineChassi, 'x', xpItem);
// Weather
ItemStack weather = new ItemStack(EnderIO.blockWeatherObelisk);
ItemStack weatherItem = new ItemStack(EnderIO.itemMaterial, 1, Material.WEATHER_CRYSTAL.ordinal());
addShaped(
RecipeUtil.addShaped(
weather,
" x ",
"ese",
@@ -686,14 +711,14 @@ public class MachineRecipes {
EnderIO.blockElectricLight,
1,
BlockItemElectricLight.Type.WIRELESS_INV.ordinal());
addShapeless(wirelessLamp, poweredLamp, enderRes);
addShapeless(wirelessLamp, wirelessLampInv, Blocks.redstone_torch);
addShapeless(wirelessLampInv, poweredLampInv, enderRes);
addShapeless(wirelessLampInv, wirelessLamp, Blocks.redstone_torch);
RecipeUtil.addShapeless(wirelessLamp, poweredLamp, enderRes);
RecipeUtil.addShapeless(wirelessLamp, wirelessLampInv, Blocks.redstone_torch);
RecipeUtil.addShapeless(wirelessLampInv, poweredLampInv, enderRes);
RecipeUtil.addShapeless(wirelessLampInv, wirelessLamp, Blocks.redstone_torch);
// inventory panel
ItemStack awareness = new ItemStack(EnderIO.itemFunctionUpgrade, 1, FunctionUpgrade.INVENTORY_PANEL.ordinal());
addShaped(
RecipeUtil.addShaped(
awareness,
"bsb",
"ses",
@@ -707,7 +732,7 @@ public class MachineRecipes {
'i',
electricalSteel);
ItemStack invPanel = new ItemStack(EnderIO.blockInventoryPanel);
addShaped(
RecipeUtil.addShaped(
invPanel,
"dad",
"psp",
@@ -727,7 +752,7 @@ public class MachineRecipes {
// powered light
if (Config.useHardRecipes) {
addShaped(
RecipeUtil.addShaped(
poweredLamp,
"ggg",
"sds",
@@ -741,7 +766,7 @@ public class MachineRecipes {
'c',
capacitor);
} else {
addShaped(
RecipeUtil.addShaped(
poweredLamp,
"ggg",
"sds",
@@ -756,19 +781,19 @@ public class MachineRecipes {
capacitor);
}
ItemStack invPoweredLamp = new ItemStack(EnderIO.blockElectricLight, 1, 1);
addShapeless(invPoweredLamp, poweredLamp, Blocks.redstone_torch);
addShapeless(poweredLamp, invPoweredLamp, Blocks.redstone_torch);
RecipeUtil.addShapeless(invPoweredLamp, poweredLamp, Blocks.redstone_torch);
RecipeUtil.addShapeless(poweredLamp, invPoweredLamp, Blocks.redstone_torch);
// light
ItemStack lamp = new ItemStack(EnderIO.blockElectricLight, 1, 2);
addShaped(lamp, " ", "ggg", "isi", 'g', "glass", 's', "glowstone", 'i', "ingotIron");
RecipeUtil.addShaped(lamp, " ", "ggg", "isi", 'g', "glass", 's', "glowstone", 'i', "ingotIron");
ItemStack invLamp = new ItemStack(EnderIO.blockElectricLight, 1, 3);
addShapeless(invLamp, lamp, Blocks.redstone_torch);
addShapeless(lamp, invLamp, Blocks.redstone_torch);
RecipeUtil.addShapeless(invLamp, lamp, Blocks.redstone_torch);
RecipeUtil.addShapeless(lamp, invLamp, Blocks.redstone_torch);
// MJ Reader
addShaped(
RecipeUtil.addShaped(
mJReader,
"epe",
"gcg",
@@ -788,7 +813,7 @@ public class MachineRecipes {
// Slice'N'Splice
ItemStack sns = new ItemStack(EnderIO.blockSliceAndSplice);
addShaped(
RecipeUtil.addShaped(
sns,
"iki",
"ams",
@@ -808,8 +833,28 @@ public class MachineRecipes {
ItemStack itemBuffer = Type.getStack(Type.ITEM);
ItemStack powerBuffer = Type.getStack(Type.POWER);
ItemStack omniBuffer = Type.getStack(Type.OMNI);
addShaped(itemBuffer, "isi", "scs", "isi", 'i', "ingotIron", 's', "ingotElectricalSteel", 'c', "chestWood");
addShaped(powerBuffer, "isi", "sfs", "isi", 'i', "ingotIron", 's', "ingotElectricalSteel", 'f', machineChassis);
addShapeless(omniBuffer, itemBuffer, powerBuffer);
RecipeUtil.addShaped(
itemBuffer,
"isi",
"scs",
"isi",
'i',
"ingotIron",
's',
"ingotElectricalSteel",
'c',
"chestWood");
RecipeUtil.addShaped(
powerBuffer,
"isi",
"sfs",
"isi",
'i',
"ingotIron",
's',
"ingotElectricalSteel",
'f',
machineChassis);
RecipeUtil.addShapeless(omniBuffer, itemBuffer, powerBuffer);
}
}
@@ -9,6 +9,7 @@ import com.enderio.core.common.util.BlockCoord;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketIoMode implements IMessage, IMessageHandler<PacketIoMode, IMessage> {
@@ -61,6 +62,7 @@ public class PacketIoMode implements IMessage, IMessageHandler<PacketIoMode, IMe
public IMessage onMessage(PacketIoMode message, MessageContext ctx) {
EntityPlayer player = ctx.getServerHandler().playerEntity;
TileEntity te = player.worldObj.getTileEntity(message.x, message.y, message.z);
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
if (te instanceof IIoConfigurable) {
IIoConfigurable me = (IIoConfigurable) te;
if (message.face == ForgeDirection.UNKNOWN) {
@@ -8,6 +8,7 @@ import com.enderio.core.common.util.BlockCoord;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketItemBuffer implements IMessage, IMessageHandler<PacketItemBuffer, IMessage> {
@@ -47,6 +48,7 @@ public class PacketItemBuffer implements IMessage, IMessageHandler<PacketItemBuf
public IMessage onMessage(PacketItemBuffer message, MessageContext ctx) {
EntityPlayer player = ctx.getServerHandler().playerEntity;
TileEntity te = player.worldObj.getTileEntity(message.x, message.y, message.z);
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
if (te instanceof IItemBuffer) {
((IItemBuffer) te).setBufferStacks(message.bufferStacks);
}
@@ -1,45 +0,0 @@
package crazypants.enderio.machine;
import net.minecraft.tileentity.TileEntity;
import com.enderio.core.api.common.util.IProgressTile;
import com.enderio.core.common.network.MessageTileEntity;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.EnderIO;
import io.netty.buffer.ByteBuf;
public class PacketProgress extends MessageTileEntity<TileEntity> implements IMessageHandler<PacketProgress, IMessage> {
private float progress;
public PacketProgress() {}
public PacketProgress(IProgressTile tile) {
super(tile.getTileEntity());
progress = tile.getProgress();
}
@Override
public void toBytes(ByteBuf buf) {
super.toBytes(buf);
buf.writeFloat(progress);
}
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
progress = buf.readFloat();
}
@Override
public IMessage onMessage(PacketProgress message, MessageContext ctx) {
TileEntity tile = message.getTileEntity(EnderIO.proxy.getClientWorld());
if (tile instanceof IProgressTile) {
((IProgressTile) tile).setProgress(message.progress);
}
return null;
}
}
@@ -6,6 +6,7 @@ import net.minecraft.tileentity.TileEntity;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketRedstoneMode implements IMessage, IMessageHandler<PacketRedstoneMode, IMessage> {
@@ -52,6 +53,7 @@ public class PacketRedstoneMode implements IMessage, IMessageHandler<PacketRedst
public IMessage onMessage(PacketRedstoneMode message, MessageContext ctx) {
EntityPlayer player = ctx.getServerHandler().playerEntity;
TileEntity te = player.worldObj.getTileEntity(message.x, message.y, message.z);
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
if (te instanceof IRedstoneModeControlable) {
IRedstoneModeControlable me = (IRedstoneModeControlable) te;
me.setRedstoneControlMode(message.mode);
@@ -5,6 +5,7 @@ import net.minecraft.tileentity.TileEntity;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketClientState implements IMessage, IMessageHandler<PacketClientState, IMessage> {
@@ -43,6 +44,7 @@ public class PacketClientState implements IMessage, IMessageHandler<PacketClient
public IMessage onMessage(PacketClientState message, MessageContext ctx) {
TileEntity te = ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.x, message.y, message.z);
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
if (te instanceof TileAlloySmelter) {
TileAlloySmelter me = (TileAlloySmelter) te;
me.setMode(message.mode);
@@ -10,15 +10,14 @@ import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import com.enderio.core.common.ContainerEnder;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.machine.capbank.network.InventoryImpl;
import crazypants.enderio.machine.gui.ContainerEnderTileEntity;
import crazypants.util.BaublesUtil;
import crazypants.util.ShadowInventory;
public class ContainerCapBank extends ContainerEnder<TileCapBank> {
public class ContainerCapBank extends ContainerEnderTileEntity<TileCapBank> {
private InventoryImpl inv;
@@ -4,13 +4,20 @@ import java.util.HashMap;
import java.util.Map;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import crazypants.enderio.machine.capbank.TileCapBank;
public class ClientNetworkManager {
private static final ClientNetworkManager instance = new ClientNetworkManager();
static {
MinecraftForge.EVENT_BUS.register(instance);
}
public static ClientNetworkManager getInstance() {
return instance;
}
@@ -53,4 +60,12 @@ public class ClientNetworkManager {
CapBankClientNetwork network = getOrCreateNetwork(id);
network.addMember(tileCapBank);
}
@SubscribeEvent
public void onWorldUnload(WorldEvent.Unload event) {
if (event.world.isRemote) {
networks.forEach((id, network) -> network.destroyNetwork());
networks.clear();
}
}
}
@@ -8,6 +8,7 @@ import cpw.mods.fml.common.network.ByteBufUtils;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketCrafter extends MessageTileEntity<TileCrafter> implements IMessageHandler<PacketCrafter, IMessage> {
@@ -46,9 +47,8 @@ public class PacketCrafter extends MessageTileEntity<TileCrafter> implements IMe
@Override
public IMessage onMessage(PacketCrafter msg, MessageContext ctx) {
TileCrafter te = msg.getTileEntity(ctx.getServerHandler().playerEntity.worldObj);
if (te != null) {
msg.execute(te);
}
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
msg.execute(te);
return null;
}
@@ -11,9 +11,10 @@ import net.minecraft.item.ItemStack;
import com.enderio.core.client.gui.widget.GhostBackgroundItemSlot;
import com.enderio.core.client.gui.widget.GhostSlot;
import com.enderio.core.common.ContainerEnder;
public class ContainerEnchanter extends ContainerEnder<TileEnchanter> {
import crazypants.enderio.machine.gui.ContainerEnderTileEntity;
public class ContainerEnchanter extends ContainerEnderTileEntity<TileEnchanter> {
public ContainerEnchanter(EntityPlayer player, InventoryPlayer playerInv, TileEnchanter te) {
super(playerInv, te);
@@ -20,7 +20,6 @@ import crazypants.enderio.Log;
/**
* This is not in the FakePlayer hierarchy for reasons.
*
*/
public class FakeFarmPlayer extends EntityPlayerMP {
@@ -1,6 +1,8 @@
package crazypants.enderio.machine.farm;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL11.GL_LIGHTING;
import static org.lwjgl.opengl.GL11.glDisable;
import static org.lwjgl.opengl.GL11.glEnable;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
@@ -120,7 +120,6 @@ public enum Fertilizer {
/**
* Returns the singleton instance for the fertilizer that was given as parameter. If the given item is no
* fertilizer, it will return an instance of Fertilizer.None.
*
*/
public static Fertilizer getInstance(ItemStack stack) {
for (Fertilizer fertilizer : validFertilizers) {
@@ -144,7 +143,7 @@ public enum Fertilizer {
/**
* Tries to apply the given item on the given block using the type-specific method. SFX is played on success.
*
* <p>
* If the item was successfully applied, the stacksize will be decreased if appropriate. The caller will need to
* check for stacksize 0 and null the inventory slot if needed.
*
@@ -5,6 +5,7 @@ import com.enderio.core.common.network.MessageTileEntity;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketFarmLockedSlot extends MessageTileEntity<TileFarmStation>
@@ -34,9 +35,8 @@ public class PacketFarmLockedSlot extends MessageTileEntity<TileFarmStation>
@Override
public IMessage onMessage(PacketFarmLockedSlot message, MessageContext ctx) {
TileFarmStation te = message.getTileEntity(message.getWorld(ctx));
if (te != null) {
te.toggleLockedState(message.buttonID);
}
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
te.toggleLockedState(message.buttonID);
return null;
}
}
@@ -37,7 +37,7 @@ public class NaturaBerryFarmer extends PickableFarmer {
block = farm.getBlock(checkBlock);
if (super.canHarvest(farm, bc, block, meta)) { // redundant check because our canHarvest checks all 5 blocks
// so a bush may be invalid in
// so a bush may be invalid in
// the stack of 5
IHarvestResult blockRes = super.harvestBlock(farm, checkBlock, block, meta);
@@ -11,13 +11,12 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import com.enderio.core.api.common.util.IProgressTile;
import com.enderio.core.common.ContainerEnder;
import com.enderio.core.common.util.Util;
import crazypants.enderio.machine.AbstractMachineEntity;
import crazypants.enderio.machine.SlotDefinition;
public abstract class AbstractMachineContainer<T extends AbstractMachineEntity> extends ContainerEnder<T> {
public abstract class AbstractMachineContainer<T extends AbstractMachineEntity> extends ContainerEnderTileEntity<T> {
protected Slot upgradeSlot;
@@ -0,0 +1,20 @@
package crazypants.enderio.machine.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.tileentity.TileEntity;
import com.enderio.core.common.ContainerEnder;
public class ContainerEnderTileEntity<T extends TileEntity & IInventory> extends ContainerEnder<T>
implements IContainerWithTileEntity {
public ContainerEnderTileEntity(InventoryPlayer playerInv, T inv) {
super(playerInv, inv);
}
@Override
public TileEntity getTileEntity() {
return getInv();
}
}
@@ -0,0 +1,13 @@
package crazypants.enderio.machine.gui;
import net.minecraft.tileentity.TileEntity;
/**
* Container implementing this interface holds TileEntity player is interacting with.
*
* @see crazypants.enderio.network.PacketUtil#isInvalidPacketForGui
*/
public interface IContainerWithTileEntity {
TileEntity getTileEntity();
}
@@ -14,6 +14,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.machine.hypercube.TileHyperCube.IoMode;
import crazypants.enderio.machine.hypercube.TileHyperCube.SubChannel;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketClientState implements IMessage, IMessageHandler<PacketClientState, IMessage> {
@@ -88,6 +89,7 @@ public class PacketClientState implements IMessage, IMessageHandler<PacketClient
public IMessage onMessage(PacketClientState message, MessageContext ctx) {
EntityPlayer player = ctx.getServerHandler().playerEntity;
TileEntity te = player.worldObj.getTileEntity(message.x, message.y, message.z);
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
if (te instanceof TileHyperCube) {
TileHyperCube hc = (TileHyperCube) te;
@@ -18,6 +18,7 @@ import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.machine.invpanel.server.InventoryDatabaseServer;
import crazypants.enderio.machine.invpanel.server.ItemEntry;
import crazypants.enderio.network.PacketHandler;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketRequestMissingItems extends MessageTileEntity<TileInventoryPanel>
@@ -62,6 +63,7 @@ public class PacketRequestMissingItems extends MessageTileEntity<TileInventoryPa
public IMessage onMessage(PacketRequestMissingItems message, MessageContext ctx) {
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
TileEntity te = player.worldObj.getTileEntity(message.x, message.y, message.z);
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
if (te instanceof TileInventoryPanel) {
TileInventoryPanel teInvPanel = (TileInventoryPanel) te;
InventoryDatabaseServer db = teInvPanel.getDatabaseServer();
@@ -8,6 +8,7 @@ import com.enderio.core.common.network.MessageTileEntity;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketSetExtractionDisabled extends MessageTileEntity<TileInventoryPanel>
@@ -38,6 +39,7 @@ public class PacketSetExtractionDisabled extends MessageTileEntity<TileInventory
public IMessage onMessage(PacketSetExtractionDisabled message, MessageContext ctx) {
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
TileEntity te = player.worldObj.getTileEntity(message.x, message.y, message.z);
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
if (te instanceof TileInventoryPanel) {
TileInventoryPanel teInvPanel = (TileInventoryPanel) te;
teInvPanel.setExtractionDisabled(message.extractionDisabled);
@@ -301,7 +301,7 @@ public class TileInventoryPanel extends AbstractMachineEntity implements IFluidH
/**
* This is called by PacketUpdateExtractionDisabled on the client side
*
*
* @param extractionDisabled if extraction is disabled
*/
void updateExtractionDisabled(boolean extractionDisabled) {
@@ -7,6 +7,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.Log;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketPowerMonitor implements IMessage, IMessageHandler<PacketPowerMonitor, IMessage> {
@@ -58,6 +59,7 @@ public class PacketPowerMonitor implements IMessage, IMessageHandler<PacketPower
return null;
}
TilePowerMonitor pm = (TilePowerMonitor) te;
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
pm.engineControlEnabled = message.engineControlEnabled;
pm.startLevel = message.startLevel;
pm.stopLevel = message.stopLevel;
@@ -1,6 +1,14 @@
package crazypants.enderio.machine.obelisk;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL11.GL_ALL_ATTRIB_BITS;
import static org.lwjgl.opengl.GL11.glDepthMask;
import static org.lwjgl.opengl.GL11.glPopAttrib;
import static org.lwjgl.opengl.GL11.glPopMatrix;
import static org.lwjgl.opengl.GL11.glPushAttrib;
import static org.lwjgl.opengl.GL11.glPushMatrix;
import static org.lwjgl.opengl.GL11.glRotatef;
import static org.lwjgl.opengl.GL11.glScalef;
import static org.lwjgl.opengl.GL11.glTranslated;
import java.util.Random;
@@ -106,7 +114,7 @@ public class ObeliskSpecialRenderer<T extends TileEntity> extends TileEntitySpec
protected void renderItemStack(T te, World world, double x, double y, double z, float tick) {
if (ei == null) {
ei = new EntityItem(world, 0, 0, 0, getFloatingItem(te));
ei = new EntityItem(null, 0, 0, 0, getFloatingItem(te));
}
ei.setEntityItemStack(getFloatingItem(te));
@@ -6,6 +6,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.EnderIO;
import crazypants.enderio.network.PacketUtil;
public class PacketActivateWeather extends MessageTileEntity<TileWeatherObelisk>
implements IMessageHandler<PacketActivateWeather, IMessage> {
@@ -22,6 +23,7 @@ public class PacketActivateWeather extends MessageTileEntity<TileWeatherObelisk>
.getTileEntity(ctx.side.isServer() ? message.getWorld(ctx) : EnderIO.proxy.getClientWorld());
if (te != null) {
if (ctx.side.isServer()) {
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
te.startTask();
} else {
te.stopTask();
@@ -3,7 +3,6 @@ package crazypants.enderio.machine.obelisk.xp;
import java.util.Random;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
@@ -49,7 +48,7 @@ public class BlockExperienceObelisk extends BlockObeliskAbstract<TileExperienceO
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileExperienceObelisk) {
return new ContainerNoInv((IInventory) te);
return new ContainerNoInv((TileExperienceObelisk) te);
}
return null;
}
@@ -96,9 +96,10 @@ public class TileEntityPainter extends AbstractPoweredTaskEntity implements ISid
// next result is a different item type
return 0;
} else if (result.hasTagCompound() && inventory[2].hasTagCompound()) {
int cookedId = result.getTagCompound().getInteger(BlockPainter.KEY_SOURCE_BLOCK_ID);
int invId = inventory[2].getTagCompound().getInteger(BlockPainter.KEY_SOURCE_BLOCK_ID);
if (cookedId != invId) {
if (inventory[2].getTagCompound().hasKey("Items")) return 0; // presence of internal items
String cookedId = result.getTagCompound().getString(BlockPainter.KEY_SOURCE_BLOCK_ID);
String invId = inventory[2].getTagCompound().getString(BlockPainter.KEY_SOURCE_BLOCK_ID);
if (!cookedId.equals(invId)) {
// next result has a different source item than the current one
return 0;
}
@@ -7,6 +7,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.machine.RedstoneControlMode;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketClientState implements IMessage, IMessageHandler<PacketClientState, IMessage> {
@@ -62,6 +63,7 @@ public class PacketClientState implements IMessage, IMessageHandler<PacketClient
public IMessage onMessage(PacketClientState message, MessageContext ctx) {
EntityPlayer player = ctx.getServerHandler().playerEntity;
TileEntity te = player.worldObj.getTileEntity(message.x, message.y, message.z);
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
if (te instanceof TileCapacitorBank) {
TileCapacitorBank cb = (TileCapacitorBank) te;
cb.setInputControlMode(message.inputMode);
@@ -151,7 +151,7 @@ public class TileSoulBinder extends AbstractPoweredTaskEntity implements IHaveEx
/**
* Computes the required amount of XP to start the current recipe.
*
*
* @return 0 if no XP is required, negative when more than required XP is stored.
*/
private int getXPRequired() {
@@ -5,6 +5,7 @@ import net.minecraft.tileentity.TileEntity;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketMode implements IMessage, IMessageHandler<PacketMode, IMessage> {
@@ -43,6 +44,7 @@ public class PacketMode implements IMessage, IMessageHandler<PacketMode, IMessag
@Override
public IMessage onMessage(PacketMode message, MessageContext ctx) {
TileEntity te = ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.x, message.y, message.z);
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
if (te instanceof TilePoweredSpawner) {
TilePoweredSpawner me = (TilePoweredSpawner) te;
me.setSpawnMode(message.isSpawnMode);
@@ -71,14 +71,12 @@ public class BlockItemTank extends ItemBlockWithMetadata implements IAdvancedToo
EnderIO.blockTank.addDetailedEntries(itemstack, entityplayer, list, flag);
}
private static final FluidTank dummy = new SmartTank(FluidRegistry.WATER, 16000);
private FluidTank loadTank(ItemStack stack) {
if (stack.hasTagCompound()) {
FluidTank tank = TileTank.loadTank(stack.getTagCompound());
return tank != null ? tank : dummy;
return tank != null ? tank : new SmartTank(FluidRegistry.WATER, 16000);
}
return dummy;
return new SmartTank(FluidRegistry.WATER, 16000);
}
private void saveTank(ItemStack stack, FluidTank tank) {
@@ -6,6 +6,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.machine.tank.GuiTank.VoidMode;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketTankVoidMode extends MessageTileEntity<TileTank>
@@ -35,9 +36,8 @@ public class PacketTankVoidMode extends MessageTileEntity<TileTank>
@Override
public IMessage onMessage(PacketTankVoidMode message, MessageContext ctx) {
TileTank te = message.getTileEntity(ctx.getServerHandler().playerEntity.worldObj);
if (te != null) {
te.setVoidMode(message.mode);
}
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
te.setVoidMode(message.mode);
return null;
}
}
@@ -10,6 +10,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.conduit.item.filter.ItemFilter;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketItemFilter extends MessageTileEntity<TileTransceiver>
@@ -52,9 +53,10 @@ public class PacketItemFilter extends MessageTileEntity<TileTransceiver>
public IMessage onMessage(PacketItemFilter message, MessageContext ctx) {
EntityPlayer player = ctx.getServerHandler().playerEntity;
TileTransceiver tile = message.getTileEntity(player.worldObj);
if (PacketUtil.isInvalidPacketForGui(ctx, tile, getClass())) return null;
boolean isSend = message.isSend;
ItemFilter filter = message.filter;
if (tile != null && filter != null) {
if (filter != null) {
if (isSend) {
tile.setSendItemFilter(filter);
} else {
@@ -9,6 +9,7 @@ import com.enderio.core.common.network.NetworkUtil;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketSendRecieveChannel extends MessageTileEntity<TileTransceiver>
@@ -50,10 +51,11 @@ public class PacketSendRecieveChannel extends MessageTileEntity<TileTransceiver>
public IMessage onMessage(PacketSendRecieveChannel message, MessageContext ctx) {
EntityPlayer player = ctx.getServerHandler().playerEntity;
TileTransceiver tile = message.getTileEntity(player.worldObj);
if (PacketUtil.isInvalidPacketForGui(ctx, tile, getClass())) return null;
Channel channel = message.channel;
boolean isSend = message.isSend;
boolean isAdd = message.isAdd;
if (tile != null && channel != null) {
if (channel != null) {
if (isSend) {
if (isAdd) {
tile.addSendChanel(channel);
@@ -10,11 +10,11 @@ import net.minecraft.item.ItemStack;
import com.enderio.core.client.gui.widget.GhostBackgroundItemSlot;
import com.enderio.core.client.gui.widget.GhostSlot;
import com.enderio.core.common.ContainerEnder;
import crazypants.enderio.EnderIO;
import crazypants.enderio.machine.gui.ContainerEnderTileEntity;
public class ContainerVacuumChest extends ContainerEnder<TileVacuumChest> {
public class ContainerVacuumChest extends ContainerEnderTileEntity<TileVacuumChest> {
private Slot filterSlot;
private Runnable filterChangedCB;
@@ -8,6 +8,7 @@ import cpw.mods.fml.common.network.ByteBufUtils;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketVaccumChest extends MessageTileEntity<TileVacuumChest>
@@ -77,21 +78,20 @@ public class PacketVaccumChest extends MessageTileEntity<TileVacuumChest>
@Override
public IMessage onMessage(PacketVaccumChest msg, MessageContext ctx) {
TileVacuumChest te = msg.getTileEntity(ctx.getServerHandler().playerEntity.worldObj);
if (te != null) {
switch (msg.cmd) {
case CMD_SET_RANGE:
te.setRange(msg.value);
break;
case CMD_SET_SLOT:
te.setItemFilterSlot(msg.value, msg.stack);
break;
case CMD_SET_BLACKLIST:
te.setFilterBlacklist(msg.value != 0);
break;
case CMD_SET_MATCHMETA:
te.setFilterMatchMeta(msg.value != 0);
break;
}
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
switch (msg.cmd) {
case CMD_SET_RANGE:
te.setRange(msg.value);
break;
case CMD_SET_SLOT:
te.setItemFilterSlot(msg.value, msg.stack);
break;
case CMD_SET_BLACKLIST:
te.setFilterBlacklist(msg.value != 0);
break;
case CMD_SET_MATCHMETA:
te.setFilterMatchMeta(msg.value != 0);
break;
}
return null;
}
@@ -7,6 +7,7 @@ import com.enderio.core.common.network.MessageTileEntity;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.network.PacketUtil;
import io.netty.buffer.ByteBuf;
public class PacketDumpTank extends MessageTileEntity<TileVat> implements IMessageHandler<PacketDumpTank, IMessage> {
@@ -47,9 +48,8 @@ public class PacketDumpTank extends MessageTileEntity<TileVat> implements IMessa
@Override
public IMessage onMessage(PacketDumpTank message, MessageContext ctx) {
TileVat te = message.getTileEntity(ctx.getServerHandler().playerEntity.worldObj);
if (te != null) {
message.getTank(te).setFluid(null);
}
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
message.getTank(te).setFluid(null);
return null;
}
}
@@ -1,11 +1,28 @@
package crazypants.enderio.material;
import static com.enderio.core.common.util.OreDictionaryHelper.*;
import static crazypants.enderio.material.Alloy.*;
import static crazypants.enderio.material.Material.*;
import static crazypants.enderio.material.endergy.AlloyEndergy.*;
import static crazypants.enderio.power.Capacitors.*;
import static crazypants.util.RecipeUtil.*;
import static crazypants.enderio.material.Alloy.DARK_STEEL;
import static crazypants.enderio.material.Alloy.END_STEEL;
import static crazypants.enderio.material.Alloy.ENERGETIC_ALLOY;
import static crazypants.enderio.material.Alloy.PHASED_GOLD;
import static crazypants.enderio.material.Alloy.PHASED_IRON;
import static crazypants.enderio.material.Alloy.SOULARIUM;
import static crazypants.enderio.material.Material.BINDER_COMPOSITE;
import static crazypants.enderio.material.Material.CONDUIT_BINDER;
import static crazypants.enderio.material.Material.PRECIENT_CRYSTAL;
import static crazypants.enderio.material.endergy.AlloyEndergy.CRYSTALLINE_ALLOY;
import static crazypants.enderio.material.endergy.AlloyEndergy.ENERGETIC_SILVER;
import static crazypants.enderio.material.endergy.AlloyEndergy.MELODIC_ALLOY;
import static crazypants.enderio.material.endergy.AlloyEndergy.STELLAR_ALLOY;
import static crazypants.enderio.material.endergy.AlloyEndergy.VIVID_ALLOY;
import static crazypants.enderio.power.Capacitors.ACTIVATED_CAPACITOR;
import static crazypants.enderio.power.Capacitors.BASIC_CAPACITOR;
import static crazypants.enderio.power.Capacitors.CRYSTALLINE_CAPACITOR;
import static crazypants.enderio.power.Capacitors.ENDERGETIC_CAPACITOR;
import static crazypants.enderio.power.Capacitors.ENDERGISED_CAPACITOR;
import static crazypants.enderio.power.Capacitors.ENDER_CAPACITOR;
import static crazypants.enderio.power.Capacitors.MELODIC_CAPACITOR;
import static crazypants.enderio.power.Capacitors.SILVER_CAPACITOR;
import static crazypants.enderio.power.Capacitors.STELLAR_CAPACITOR;
import java.util.ArrayList;
@@ -23,6 +40,7 @@ import crazypants.enderio.config.Config;
import crazypants.enderio.item.ItemEnderFood.EnderFood;
import crazypants.enderio.material.endergy.AlloyEndergy;
import crazypants.enderio.power.Capacitors;
import crazypants.util.RecipeUtil;
public class MaterialRecipes {
@@ -63,7 +81,7 @@ public class MaterialRecipes {
// Allow free conversion of additional/legacy oreDict name items into
// our item because we only register recipes for the primary oreDict
// name. Use a 2-to-2 recipe because the 1-to-n is already in use.
addShapeless(alloy.getStackIngot(2), oreDictName, oreDictName);
RecipeUtil.addShapeless(alloy.getStackIngot(2), oreDictName, oreDictName);
}
}
isPrimaryName = true;
@@ -72,7 +90,7 @@ public class MaterialRecipes {
if (isPrimaryName) {
isPrimaryName = false;
} else {
addShapeless(alloy.getStackBlock(2), oreDictName, oreDictName);
RecipeUtil.addShapeless(alloy.getStackBlock(2), oreDictName, oreDictName);
}
}
}
@@ -87,7 +105,7 @@ public class MaterialRecipes {
// Allow free conversion of additional/legacy oreDict name items into
// our item because we only register recipes for the primary oreDict
// name. Use a 2-to-2 recipe because the 1-to-n is already in use.
addShapeless(alloy.getStackIngot(2), oreDictName, oreDictName);
RecipeUtil.addShapeless(alloy.getStackIngot(2), oreDictName, oreDictName);
}
}
isPrimaryName = true;
@@ -96,7 +114,7 @@ public class MaterialRecipes {
if (isPrimaryName) {
isPrimaryName = false;
} else {
addShapeless(alloy.getStackBlock(2), oreDictName, oreDictName);
RecipeUtil.addShapeless(alloy.getStackBlock(2), oreDictName, oreDictName);
}
}
}
@@ -131,9 +149,9 @@ public class MaterialRecipes {
OreDictionary.registerOre("itemSkull", new ItemStack(EnderIO.blockEndermanSkull));
// Glass stuff for compatibility
addShaped(new ItemStack(Blocks.glass_pane, 16, 0), "eee", "eee", 'e', pureGlass);
addShapeless(new ItemStack(Blocks.glass), pureGlass);
addShaped(new ItemStack(Items.glass_bottle, 3, 0), "g g", " g ", 'g', pureGlass);
RecipeUtil.addShaped(new ItemStack(Blocks.glass_pane, 16, 0), "eee", "eee", 'e', pureGlass);
RecipeUtil.addShapeless(new ItemStack(Blocks.glass), pureGlass);
RecipeUtil.addShaped(new ItemStack(Items.glass_bottle, 3, 0), "g g", " g ", 'g', pureGlass);
Material.registerOres(EnderIO.itemMaterial);
MachinePart.registerOres(EnderIO.itemMachinePart);
@@ -170,7 +188,7 @@ public class MaterialRecipes {
// Capacitors
if (Config.useHardRecipes) {
addShaped(
RecipeUtil.addShaped(
BASIC_CAPACITOR.getItemStack(),
" gr",
"gig",
@@ -181,7 +199,7 @@ public class MaterialRecipes {
"ingotGold",
'i',
ingotCopper);
addShaped(
RecipeUtil.addShaped(
ACTIVATED_CAPACITOR.getItemStack(),
"iii",
"cCc",
@@ -192,7 +210,7 @@ public class MaterialRecipes {
BASIC_CAPACITOR.getItemStack(),
'C',
"dustCoal");
addShaped(
RecipeUtil.addShaped(
ENDER_CAPACITOR.getItemStack(),
"iii",
"cCc",
@@ -206,7 +224,7 @@ public class MaterialRecipes {
String prismarine = OreDictionary.doesOreNameExist("shardPrismarine") ? "shardPrismarine"
: "itemPulsatingCrystal";
addShaped(
RecipeUtil.addShaped(
CRYSTALLINE_CAPACITOR.getItemStack(),
"iii",
"cCc",
@@ -217,7 +235,7 @@ public class MaterialRecipes {
capacitorEnder,
'C',
prismarine);
addShaped(
RecipeUtil.addShaped(
MELODIC_CAPACITOR.getItemStack(),
"iii",
"cCc",
@@ -228,7 +246,7 @@ public class MaterialRecipes {
CRYSTALLINE_CAPACITOR.getItemStack(),
'C',
endSteel);
addShaped(
RecipeUtil.addShaped(
STELLAR_CAPACITOR.getItemStack(),
"iii",
"cCc",
@@ -240,7 +258,7 @@ public class MaterialRecipes {
'C',
PRECIENT_CRYSTAL.oreDict);
addShaped(
RecipeUtil.addShaped(
SILVER_CAPACITOR.getItemStack(),
" sr",
"sis",
@@ -251,7 +269,7 @@ public class MaterialRecipes {
"ingotSilver",
'i',
"ingotLead");
addShaped(
RecipeUtil.addShaped(
ENDERGETIC_CAPACITOR.getItemStack(),
"iii",
"cCc",
@@ -262,7 +280,7 @@ public class MaterialRecipes {
SILVER_CAPACITOR.getItemStack(),
'C',
"dustCoal");
addShaped(
RecipeUtil.addShaped(
ENDERGISED_CAPACITOR.getItemStack(),
"iii",
"cCc",
@@ -275,7 +293,7 @@ public class MaterialRecipes {
"glowstone");
} else {
addShaped(
RecipeUtil.addShaped(
BASIC_CAPACITOR.getItemStack(),
" gr",
"gig",
@@ -286,7 +304,7 @@ public class MaterialRecipes {
"ingotGold",
'i',
ingotCopper);
addShaped(
RecipeUtil.addShaped(
ACTIVATED_CAPACITOR.getItemStack(),
" i ",
"cCc",
@@ -297,7 +315,7 @@ public class MaterialRecipes {
BASIC_CAPACITOR.getItemStack(),
'C',
"dustCoal");
addShaped(
RecipeUtil.addShaped(
ENDER_CAPACITOR.getItemStack(),
" i ",
"cCc",
@@ -311,7 +329,7 @@ public class MaterialRecipes {
String prismarine = OreDictionary.doesOreNameExist("shardPrismarine") ? "shardPrismarine"
: "itemPulsatingCrystal";
addShaped(
RecipeUtil.addShaped(
CRYSTALLINE_CAPACITOR.getItemStack(),
" i ",
"cCc",
@@ -322,7 +340,7 @@ public class MaterialRecipes {
capacitorEnder,
'C',
prismarine);
addShaped(
RecipeUtil.addShaped(
MELODIC_CAPACITOR.getItemStack(),
" i ",
"cCc",
@@ -333,7 +351,7 @@ public class MaterialRecipes {
CRYSTALLINE_CAPACITOR.getItemStack(),
'C',
endSteel);
addShaped(
RecipeUtil.addShaped(
STELLAR_CAPACITOR.getItemStack(),
" i ",
"cCc",
@@ -345,7 +363,7 @@ public class MaterialRecipes {
'C',
PRECIENT_CRYSTAL.oreDict);
addShaped(
RecipeUtil.addShaped(
SILVER_CAPACITOR.getItemStack(),
" sr",
"sis",
@@ -356,7 +374,7 @@ public class MaterialRecipes {
"ingotSilver",
'i',
"ingotLead");
addShaped(
RecipeUtil.addShaped(
ENDERGETIC_CAPACITOR.getItemStack(),
" i ",
"cCc",
@@ -367,7 +385,7 @@ public class MaterialRecipes {
SILVER_CAPACITOR.getItemStack(),
'C',
"dustCoal");
addShaped(
RecipeUtil.addShaped(
ENDERGISED_CAPACITOR.getItemStack(),
" i ",
"cCc",
@@ -383,37 +401,37 @@ public class MaterialRecipes {
// Conduit Binder
ItemStack cbc = BINDER_COMPOSITE.getStack(8);
if (Config.useAlternateBinderRecipe) {
addShaped(cbc, "gcg", "sgs", "gcg", 'g', Blocks.gravel, 's', "sand", 'c', Items.clay_ball);
RecipeUtil.addShaped(cbc, "gcg", "sgs", "gcg", 'g', Blocks.gravel, 's', "sand", 'c', Items.clay_ball);
} else {
addShaped(cbc, "ggg", "scs", "ggg", 'g', Blocks.gravel, 's', "sand", 'c', Items.clay_ball);
RecipeUtil.addShaped(cbc, "ggg", "scs", "ggg", 'g', Blocks.gravel, 's', "sand", 'c', Items.clay_ball);
}
GameRegistry.addSmelting(BINDER_COMPOSITE.getStack(), CONDUIT_BINDER.getStack(4), 0);
// Nuggets
ItemStack phasedIronNugget = new ItemStack(EnderIO.itemMaterial, 9, Material.PHASED_IRON_NUGGET.ordinal());
addShapeless(phasedIronNugget, phasedIron);
RecipeUtil.addShapeless(phasedIronNugget, phasedIron);
phasedIronNugget = phasedIronNugget.copy();
phasedIronNugget.stackSize = 1;
addShaped(PHASED_IRON.getStackIngot(), "eee", "eee", "eee", 'e', phasedIronNugget);
RecipeUtil.addShaped(PHASED_IRON.getStackIngot(), "eee", "eee", "eee", 'e', phasedIronNugget);
ItemStack vibrantNugget = new ItemStack(EnderIO.itemMaterial, 9, Material.VIBRANT_NUGGET.ordinal());
addShapeless(vibrantNugget, phasedGold);
RecipeUtil.addShapeless(vibrantNugget, phasedGold);
vibrantNugget = vibrantNugget.copy();
vibrantNugget.stackSize = 1;
addShaped(PHASED_GOLD.getStackIngot(), "eee", "eee", "eee", 'e', vibrantNugget);
RecipeUtil.addShaped(PHASED_GOLD.getStackIngot(), "eee", "eee", "eee", 'e', vibrantNugget);
ItemStack endSteelNugget = new ItemStack(EnderIO.itemMaterial, 9, Material.END_STEEL_NUGGET.ordinal());
addShapeless(endSteelNugget, endSteel);
RecipeUtil.addShapeless(endSteelNugget, endSteel);
endSteelNugget = endSteelNugget.copy();
endSteelNugget.stackSize = 1;
addShaped(END_STEEL.getStackIngot(), "eee", "eee", "eee", 'e', endSteelNugget);
RecipeUtil.addShaped(END_STEEL.getStackIngot(), "eee", "eee", "eee", 'e', endSteelNugget);
// Crystals
ItemStack pulsCry = new ItemStack(EnderIO.itemMaterial, 1, Material.PULSATING_CYSTAL.ordinal());
addShaped(pulsCry, "nnn", "ngn", "nnn", 'n', phasedIronNugget, 'g', "gemDiamond");
RecipeUtil.addShaped(pulsCry, "nnn", "ngn", "nnn", 'n', phasedIronNugget, 'g', "gemDiamond");
ItemStack vibCry = new ItemStack(EnderIO.itemMaterial, 1, Material.VIBRANT_CYSTAL.ordinal());
addShaped(vibCry, "nnn", "ngn", "nnn", 'n', vibrantNugget, 'g', "gemEmerald");
RecipeUtil.addShaped(vibCry, "nnn", "ngn", "nnn", 'n', vibrantNugget, 'g', "gemEmerald");
// Smelting
ItemStack dustIron = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_IRON.ordinal());
@@ -426,23 +444,23 @@ public class MaterialRecipes {
// Ender Dusts
ItemStack enderDust = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_ENDER.ordinal());
addShaped(new ItemStack(Items.ender_pearl), "eee", "eee", "eee", 'e', enderDust);
RecipeUtil.addShaped(new ItemStack(Items.ender_pearl), "eee", "eee", "eee", 'e', enderDust);
// Dark Iron Bars
ItemStack diBars = new ItemStack(EnderIO.blockDarkIronBars, 16, 0);
addShaped(diBars, "ddd", "ddd", 'd', darkSteel);
RecipeUtil.addShaped(diBars, "ddd", "ddd", 'd', darkSteel);
// Dark Iron Bars
ItemStack soBars = new ItemStack(EnderIO.blockSoulariumBars, 16, 0);
addShaped(soBars, "ddd", "ddd", 'd', soularium);
RecipeUtil.addShaped(soBars, "ddd", "ddd", 'd', soularium);
// Dark Iron Bars
ItemStack esBars = new ItemStack(EnderIO.blockEndSteelBars, 16, 0);
addShaped(esBars, "ddd", "ddd", 'd', endSteel);
RecipeUtil.addShaped(esBars, "ddd", "ddd", 'd', endSteel);
// Fused Quartz Frame
addShaped(fusedQuartzFrame, "bsb", "s s", "bsb", 'b', conduitBinder, 's', "stickWood");
addShaped(fusedQuartzFrame, "bsb", "s s", "bsb", 'b', conduitBinder, 's', "woodStick");
RecipeUtil.addShaped(fusedQuartzFrame, "bsb", "s s", "bsb", 'b', conduitBinder, 's', "stickWood");
RecipeUtil.addShaped(fusedQuartzFrame, "bsb", "s s", "bsb", 'b', conduitBinder, 's', "woodStick");
// Machine Chassis
@@ -451,10 +469,10 @@ public class MaterialRecipes {
ItemStack chassis = new ItemStack(EnderIO.itemMachinePart, 1, MachinePart.MACHINE_CHASSI.ordinal());
String mat = Config.useSteelInChassi == true && steelIngots != null && !steelIngots.isEmpty() ? "ingotSteel"
: "ingotIron";
addShaped(chassis, "fif", "ici", "fif", 'f', Blocks.iron_bars, 'i', mat, 'c', capacitor);
RecipeUtil.addShaped(chassis, "fif", "ici", "fif", 'f', Blocks.iron_bars, 'i', mat, 'c', capacitor);
ItemStack soulchassis = new ItemStack(EnderIO.itemMachinePart, 1, MachinePart.SOUL_MACHINE_CHASSIS.ordinal());
addShaped(
RecipeUtil.addShaped(
soulchassis,
"fif",
"ici",
@@ -470,7 +488,7 @@ public class MaterialRecipes {
EnderIO.itemMachinePart,
1,
MachinePart.END_STEEL_MACHINE_CHASSIS.ordinal());
addShaped(
RecipeUtil.addShaped(
endchassis,
"fif",
"ici",
@@ -484,8 +502,8 @@ public class MaterialRecipes {
// Basic Gear
ItemStack gear = new ItemStack(EnderIO.itemMachinePart, 1, MachinePart.BASIC_GEAR.ordinal());
addShaped(gear, "scs", "c c", "scs", 's', "stickWood", 'c', "cobblestone");
addShaped(gear, "scs", "c c", "scs", 's', "woodStick", 'c', "cobblestone");
RecipeUtil.addShaped(gear, "scs", "c c", "scs", 's', "stickWood", 'c', "cobblestone");
RecipeUtil.addShaped(gear, "scs", "c c", "scs", 's', "woodStick", 'c', "cobblestone");
// Weather Crystal
ItemStack main = Config.useHardRecipes
@@ -502,7 +520,7 @@ public class MaterialRecipes {
if (Config.reinforcedObsidianUseDarkSteelBlocks) {
corners = Alloy.DARK_STEEL.getOreBlock();
}
addShaped(
RecipeUtil.addShaped(
reinfObs,
"dbd",
"bob",
@@ -515,25 +533,39 @@ public class MaterialRecipes {
Blocks.obsidian);
}
addShaped(EnderIO.blockDarkSteelAnvil, "bbb", " i ", "iii", 'b', DARK_STEEL.getOreBlock(), 'i', darkSteel);
RecipeUtil.addShaped(
EnderIO.blockDarkSteelAnvil,
"bbb",
" i ",
"iii",
'b',
DARK_STEEL.getOreBlock(),
'i',
darkSteel);
addShaped(new ItemStack(EnderIO.blockDarkSteelLadder, 12), "b", "b", "b", 'b', EnderIO.blockDarkIronBars);
RecipeUtil.addShaped(
new ItemStack(EnderIO.blockDarkSteelLadder, 12),
"b",
"b",
"b",
'b',
EnderIO.blockDarkIronBars);
for (Alloy alloy : Alloy.values()) {
addShaped(alloy.getStackBlock(), "iii", "iii", "iii", 'i', alloy.getOreIngot());
addShaped(alloy.getStackBall(5), " i ", "iii", " i ", 'i', alloy.getOreIngot());
addShapeless(alloy.getStackIngot(9), alloy.getOreBlock());
RecipeUtil.addShaped(alloy.getStackBlock(), "iii", "iii", "iii", 'i', alloy.getOreIngot());
RecipeUtil.addShaped(alloy.getStackBall(5), " i ", "iii", " i ", 'i', alloy.getOreIngot());
RecipeUtil.addShapeless(alloy.getStackIngot(9), alloy.getOreBlock());
}
for (AlloyEndergy alloy : AlloyEndergy.values()) {
addShaped(alloy.getStackBlock(), "iii", "iii", "iii", 'i', alloy.getOreIngot());
addShaped(alloy.getStackBall(5), " i ", "iii", " i ", 'i', alloy.getOreIngot());
addShapeless(alloy.getStackIngot(9), alloy.getOreBlock());
RecipeUtil.addShaped(alloy.getStackBlock(), "iii", "iii", "iii", 'i', alloy.getOreIngot());
RecipeUtil.addShaped(alloy.getStackBall(5), " i ", "iii", " i ", 'i', alloy.getOreIngot());
RecipeUtil.addShapeless(alloy.getStackIngot(9), alloy.getOreBlock());
}
// DS Rod
ItemStack darkRod = new ItemStack(EnderIO.itemMaterial, 1, Material.DARK_STEEL_ROD.ordinal());
addShaped(darkRod, " ns", "nsn", "sn ", 's', darkSteel, 'n', endSteelNugget);
RecipeUtil.addShaped(darkRod, " ns", "nsn", "sn ", 's', darkSteel, 'n', endSteelNugget);
// Food
ItemStack flour = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.FLOUR.ordinal());
@@ -542,14 +574,14 @@ public class MaterialRecipes {
GameRegistry.addSmelting(flour, bread, 0.35f);
ItemStack enderios = EnderFood.ENDERIOS.getStack();
addShapeless(enderios, Items.bowl, Items.milk_bucket, "cropWheat", "dustEnderPearl");
RecipeUtil.addShapeless(enderios, Items.bowl, Items.milk_bucket, "cropWheat", "dustEnderPearl");
if (hasCopper()) {
if (OreDictionaryHelper.hasCopper()) {
ItemStack dustCopper = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_COPPER.ordinal());
ItemStack ingotCoppper = OreDictionaryPreferences.instance.getPreferred(OreDictionaryHelper.INGOT_COPPER);
GameRegistry.addSmelting(dustCopper, ingotCoppper, 0);
}
if (hasTin()) {
if (OreDictionaryHelper.hasTin()) {
ItemStack dustTin = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_TIN.ordinal());
ItemStack ingotTin = OreDictionaryPreferences.instance.getPreferred(OreDictionaryHelper.INGOT_TIN);
GameRegistry.addSmelting(dustTin, ingotTin, 0);
@@ -1,6 +1,10 @@
package crazypants.enderio.material;
import static com.enderio.core.common.util.OreDictionaryHelper.*;
import static com.enderio.core.common.util.OreDictionaryHelper.DUST_ENDERPEARL;
import static com.enderio.core.common.util.OreDictionaryHelper.INGOT_COPPER;
import static com.enderio.core.common.util.OreDictionaryHelper.INGOT_ENDERIUM;
import static com.enderio.core.common.util.OreDictionaryHelper.INGOT_TIN;
import static com.enderio.core.common.util.OreDictionaryHelper.isRegistered;
public enum PowderIngot {
@@ -0,0 +1,54 @@
package crazypants.enderio.network;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.tileentity.TileEntity;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.Side;
import crazypants.enderio.Log;
import crazypants.enderio.machine.gui.IContainerWithTileEntity;
public class PacketUtil {
/**
* Validates if TileEntity received from client is actually the one player is interacting with. It prevents
* malicious user disturbing random machine settings etc.
*/
public static boolean isInvalidPacketForGui(MessageContext ctx, TileEntity receivedTile, Class<?> messageClass) {
if (receivedTile == null) {
// Invalid, but not harmful
return true;
}
if (ctx.side == Side.CLIENT) return false;
EntityPlayer player = ctx.getServerHandler().playerEntity;
Container container = player.openContainer;
if (!(container instanceof IContainerWithTileEntity)) {
Log.LOGGER.warn(
Log.securityMarker,
"Player {} tried to send {} while not opening correct GUI. Target TileEntity at {}, {}, {}",
player.getGameProfile(),
messageClass.getSimpleName(),
receivedTile.xCoord,
receivedTile.yCoord,
receivedTile.zCoord);
return true;
}
TileEntity expectedTile = ((IContainerWithTileEntity) container).getTileEntity();
if (receivedTile != expectedTile) {
Log.LOGGER.warn(
Log.securityMarker,
"Player {} tried to send {} which attempts to modify setting of TileEntity at {}, {}, {}. Expected: {}, {}, {}",
player.getGameProfile(),
messageClass.getSimpleName(),
receivedTile.xCoord,
receivedTile.yCoord,
receivedTile.zCoord,
expectedTile.xCoord,
expectedTile.yCoord,
expectedTile.zCoord);
return true;
}
return false;
}
}
@@ -15,10 +15,11 @@ import com.enderio.core.common.ContainerEnder;
import com.enderio.core.common.TileEntityEnder;
import crazypants.enderio.api.teleport.ITravelAccessable;
import crazypants.enderio.machine.gui.IContainerWithTileEntity;
import crazypants.enderio.network.PacketHandler;
import crazypants.enderio.teleport.packet.PacketPassword;
public class ContainerTravelAccessable extends ContainerEnder<IInventory> {
public class ContainerTravelAccessable extends ContainerEnder<IInventory> implements IContainerWithTileEntity {
ITravelAccessable ta;
TileEntity te;
@@ -97,4 +98,9 @@ public class ContainerTravelAccessable extends ContainerEnder<IInventory> {
}
}
}
@Override
public TileEntity getTileEntity() {
return te;
}
}
@@ -6,14 +6,16 @@ import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import com.enderio.core.client.gui.widget.GhostSlot;
import com.enderio.core.common.ContainerEnder;
import com.enderio.core.common.util.ArrayInventory;
import crazypants.enderio.machine.gui.IContainerWithTileEntity;
import crazypants.enderio.teleport.ContainerTravelAuth.AuthInventory;
public class ContainerTravelAuth extends ContainerEnder<AuthInventory> {
public class ContainerTravelAuth extends ContainerEnder<AuthInventory> implements IContainerWithTileEntity {
static class AuthInventory extends ArrayInventory {
@@ -87,10 +89,12 @@ public class ContainerTravelAuth extends ContainerEnder<AuthInventory> {
}
}
private final TileEntity te;
boolean dirty = false;
public ContainerTravelAuth(InventoryPlayer playerInv) {
public ContainerTravelAuth(InventoryPlayer playerInv, TileEntity te) {
super(playerInv, new AuthInventory(new ItemStack[5]));
this.te = te;
getInv().setContainer(this);
}
@@ -118,6 +122,11 @@ public class ContainerTravelAuth extends ContainerEnder<AuthInventory> {
return null;
}
@Override
public TileEntity getTileEntity() {
return te;
}
private static class AuthGhostSlot extends GhostSlot {
private AuthInventory inv;
@@ -5,6 +5,7 @@ import java.awt.Color;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
@@ -24,7 +25,7 @@ public class GuiTravelAuth extends GuiContainerBaseEIO {
private final EntityPlayer player;
public GuiTravelAuth(EntityPlayer player, ITravelAccessable te, World world) {
super(new ContainerTravelAuth(player.inventory), "travelAuth");
super(new ContainerTravelAuth(player.inventory, (TileEntity) te), "travelAuth");
this.ta = te;
title = EnderIO.lang.localize("gui.travelAccessable.enterCode");
this.player = player;
@@ -84,6 +84,11 @@ public class ItemTeleportStaff extends ItemTravelStaff {
// Do nothing, as we have infinite energy.
}
@Override
public int canExtractInternal(ItemStack equipped, int power) {
return power;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List par3List) {
@@ -132,6 +132,11 @@ public class ItemTravelStaff extends ItemEnergyContainer implements IItemOfTrave
setEnergy(item, res);
}
@Override
public int canExtractInternal(ItemStack equipped, int power) {
return Math.min(getEnergyStored(equipped), power);
}
void setEnergy(ItemStack container, int energy) {
if (container.stackTagCompound == null) {
container.stackTagCompound = new NBTTagCompound();
Loaded 100 of 122 files, more files were not shown because too many files have changed in this diff. Show more