diff options
author | Martin Robertz <dream-master@gmx.net> | 2022-02-11 21:05:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-11 21:05:02 +0100 |
commit | 930217244ed034242083f8f9f95956a6358b66c8 (patch) | |
tree | 0b18c8d3e9d2c63bdc2eb1cc0a42e0e575254165 | |
parent | 4e5f8f13bf413602615d5f6c15bc799c9dade207 (diff) | |
parent | f709147e2f38f5607e9fd6e849d1cbf618f8ff7a (diff) | |
download | GT5-Unofficial-930217244ed034242083f8f9f95956a6358b66c8.tar.gz GT5-Unofficial-930217244ed034242083f8f9f95956a6358b66c8.tar.bz2 GT5-Unofficial-930217244ed034242083f8f9f95956a6358b66c8.zip |
Merge pull request #38 from GTNewHorizons/upstream
MIT
272 files changed, 9543 insertions, 13986 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/.gitmodules diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000000..31a900b34e --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017-2022 TecTech + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. @@ -12,24 +12,8 @@ https://github.com/Technus/TecTech/blob/master/src/main/java/com/github/technus/ - Required After -# MIT License +# License -Copyright (c) 2017 TecTech +Copyright (c) 2017-2022 TecTech and licensed under the MIT License -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +GTNH changes are under the MIT License to maintain upstream compatibility.
\ No newline at end of file diff --git a/build.gradle b/build.gradle index 7914dd81b4..be841eb20c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,10 @@ -//version: 1643020202 +//version: 1644349045 /* DO NOT CHANGE THIS FILE! Also, you may replace this file at any time if there is an update available. Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates. - */ +*/ import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation @@ -40,11 +40,16 @@ plugins { id 'idea' id 'eclipse' id 'scala' - id("org.ajoberstar.grgit") version("3.1.1") - id("com.github.johnrengelman.shadow") version("4.0.4") - id("com.palantir.git-version") version("0.12.3") - id('de.undercouch.download') version('4.1.2') - id("maven-publish") + id 'maven-publish' + id('org.jetbrains.kotlin.jvm') version ('1.6.10') apply false + id('org.ajoberstar.grgit') version('4.1.1') + id('com.github.johnrengelman.shadow') version('4.0.4') + id('com.palantir.git-version') version('0.13.0') apply false + id('de.undercouch.download') version('5.0.1') +} + +if (project.file('.git/HEAD').isFile()) { + apply plugin: 'com.palantir.git-version' } apply plugin: 'forge' @@ -94,24 +99,27 @@ boolean noPublishedSources = project.findProperty("noPublishedSources") ? projec String javaSourceDir = "src/main/java/" String scalaSourceDir = "src/main/scala/" +String kotlinSourceDir = "src/main/kotlin/" String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") -if((getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists()) == false) { - throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala) +String targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") +if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) { + throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin) } if(apiPackage) { targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") - if((getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists()) == false) { - throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala) + targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) { + throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin) } } if(accessTransformersFile) { String targetFile = "src/main/resources/META-INF/" + accessTransformersFile - if(getFile(targetFile).exists() == false) { + if(!getFile(targetFile).exists()) { throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile) } } @@ -123,15 +131,17 @@ if(usesMixins.toBoolean()) { targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/") targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/") - if((getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists()) == false) { - throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala) + targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/") + if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) { + throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin) } String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java" String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala" String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java" - if((getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists()) == false) { - throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava) + String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".kt" + if(!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) { + throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin) } } @@ -139,8 +149,9 @@ if(coreModClass) { String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java" String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".scala" String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java" - if((getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists()) == false) { - throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava) + String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".kt" + if(!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) { + throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin) } } @@ -153,17 +164,32 @@ configurations.all { } // Fix Jenkins' Git: chmod a file should not be detected as a change and append a '.dirty' to the version -'git config core.fileMode false'.execute() +try { + 'git config core.fileMode false'.execute() +} +catch (Exception e) { + logger.error("\u001B[31mgit isn't installed at all\u001B[0m") +} // Pulls version first from the VERSION env and then git tag String identifiedVersion +String versionOverride = System.getenv("VERSION") ?: null try { - String versionOverride = System.getenv("VERSION") ?: null identifiedVersion = versionOverride == null ? gitVersion() : versionOverride - version = minecraftVersion + "-" + identifiedVersion } catch (Exception e) { - throw new IllegalStateException("This mod must be version controlled by Git AND the repository must provide at least one tag, or the VERSION override must be set!"); + logger.error("\n\u001B[1;31mThis mod must be version controlled by Git AND the repository must provide at least one tag,\n" + + "or the VERSION override must be set! \u001B[32m(Don't download from GitHub using the ZIP option, instead\n" + + "clone the repository, see\u001B[33m https://gtnh.miraheze.org/wiki/Development \u001B[32mfor details.)\u001B[0m\n"); + versionOverride = 'NO-GIT-TAG-SET' + identifiedVersion = versionOverride +} +version = minecraftVersion + '-' + identifiedVersion +String modVersion = identifiedVersion + +if( identifiedVersion.equals(versionOverride) ) { + logger.error('\u001B[31m\u001B[7mWe hope you know what you\'re doing using\u001B[0m\u001B[1;34m ' + modVersion + '\u001B[0m\n'); + logger.error('\7\u001B[31mGoing to blindly try to use\u001B[1;34m ' + modVersion + '\u001B[0m\u001B[31m, this probably won\'t work the way you expect!!\u001B[0m\n'); } group = modGroup @@ -200,7 +226,7 @@ minecraft { replace gradleTokenModName, modName } if(gradleTokenVersion) { - replace gradleTokenVersion, versionDetails().lastTag + replace gradleTokenVersion, modVersion } if(gradleTokenGroupName) { replace gradleTokenGroupName, modGroup @@ -380,23 +406,23 @@ processResources // this will ensure that this task is redone when the versions change. inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version - + // replace stuff in mcmod.info, nothing else from(sourceSets.main.resources.srcDirs) { include 'mcmod.info' - // replace version and mcversion + // replace modVersion and minecraftVersion expand "minecraftVersion": project.minecraft.version, - "modVersion": versionDetails().lastTag, - "modId": modId, - "modName": modName + "modVersion": modVersion, + "modId": modId, + "modName": modName } if(usesMixins.toBoolean()) { from refMap } - // copy everything else, thats not the mcmod.info + // copy everything else that's not the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' } @@ -513,8 +539,6 @@ tasks.withType(GenerateModuleMetadata) { enabled = false } - -// publishing publishing { publications { maven(MavenPublication) { @@ -535,13 +559,16 @@ publishing { // Using the identified version, not project.version as it has the prepended 1.7.10 version = System.getenv("RELEASE_VERSION") ?: identifiedVersion - // Remove all non GTNH deps here. - // Original intention was to remove an invalid forgeBin being generated without a groupId (mandatory), but - // it also removes all of the MC deps + // remove extra garbage from who knows where pom.withXml { + def badPomGroup = ['net.minecraft', 'com.google.code.findbugs', 'org.ow2.asm', 'com.typesafe.akka', 'com.typesafe', 'org.scala-lang', + 'org.scala-lang.plugins', 'net.sf.jopt-simple', 'lzma', 'com.mojang', 'org.apache.commons', 'org.apache.httpcomponents', + 'commons-logging', 'java3d', 'net.sf.trove4j', 'com.ibm.icu', 'com.paulscode', 'io.netty', 'com.google.guava', + 'commons-io', 'commons-codec', 'net.java.jinput', 'net.java.jutils', 'com.google.code.gson', 'org.apache.logging.log4j', + 'org.lwjgl.lwjgl', 'tv.twitch', ''] Node pomNode = asNode() pomNode.dependencies.'*'.findAll() { - it.groupId.text() != 'com.github.GTNewHorizons' + badPomGroup.contains(it.groupId.text()) }.each() { it.parent().remove(it) } @@ -647,7 +674,7 @@ def deobf(String sourceURL) { } } -// The method above is to be prefered. Use this method if the filename is not at the end of the URL. +// The method above is to be preferred. Use this method if the filename is not at the end of the URL. def deobf(String sourceURL, String fileName) { String cacheDir = System.getProperty("user.home") + "/.gradle/caches/" String bon2Dir = cacheDir + "forge_gradle/deobf" @@ -659,14 +686,14 @@ def deobf(String sourceURL, String fileName) { return files(deobfFile) } - download { + download.run { src 'https://github.com/GTNewHorizons/BON2/releases/download/2.5.0/BON2-2.5.0.CUSTOM-all.jar' dest bon2File quiet true overwrite false } - download { + download.run { src sourceURL dest obfFile quiet true diff --git a/dependencies.gradle b/dependencies.gradle index 0aada7c20c..64f08c5c2d 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,35 +1,22 @@ // Add your dependencies here dependencies { - shadowImplementation("com.github.GTNewHorizons:AVRcore:master-SNAPSHOT") + shadowImplementation('com.github.GTNewHorizons:AVRcore:master-SNAPSHOT') - compile("com.github.GTNewHorizons:GT5-Unofficial:5.09.40.26:dev") - compile("com.github.GTNewHorizons:Yamcl:0.5.82:dev") - compile("com.github.GTNewHorizons:NotEnoughItems:2.1.22-GTNH:dev") - compile("com.github.GTNewHorizons:CodeChickenLib:1.1.5.1:dev") - compile("com.github.GTNewHorizons:CodeChickenCore:1.1.3:dev") - compile("com.github.GTNewHorizons:StructureLib:1.0.14:dev") - compile("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev") + compile('com.github.GTNewHorizons:GT5-Unofficial:5.09.40.33:dev') + compile('com.github.GTNewHorizons:Yamcl:0.5.82:dev') + compile('com.github.GTNewHorizons:NotEnoughItems:2.2.6-GTNH:dev') + compile('com.github.GTNewHorizons:CodeChickenLib:1.1.5.3:dev') + compile('com.github.GTNewHorizons:CodeChickenCore:1.1.3:dev') + compile('com.github.GTNewHorizons:StructureLib:1.0.15:dev') + compile('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev') - compileOnly("com.github.GTNewHorizons:GTplusplus:1.7.24:dev") { - transitive = false - } - compileOnly("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-70-GTNH:dev") { - transitive = false - } + compileOnly('com.github.GTNewHorizons:OpenModularTurrets:2.2.11-247:dev') {transitive=false} + compileOnly('com.github.GTNewHorizons:OpenComputers:1.7.5.23-GTNH:dev') {transitive=false} + compileOnly('com.github.GTNewHorizons:GTplusplus:1.7.27:dev') {transitive=false} + compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-76-GTNH:dev') {transitive=false} - compileOnly("dan200.computercraft:ComputerCraft:1.75") { - transitive = false - } - compileOnly("li.cil.oc:OpenComputers:MC1.7.10-1.7.5.1356:dev") { - transitive = false - } - compileOnly("curse.maven:cofh-core-69162:2388751") { - transitive = false - } - compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") { - transitive = false - } - - compileOnly files("dependencies/OpenModularTurrets-1.7.10-2.2.10-237-deobf.jar") + compileOnly('curse.maven:cofh-lib-220333:2388748') {transitive=false} + compileOnly('curse.maven:computercraft-67504:2269339') {transitive=false} + compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev') {transitive=false} } diff --git a/dependencies/OpenModularTurrets-1.7.10-2.2.10-237-deobf.jar b/dependencies/OpenModularTurrets-1.7.10-2.2.10-237-deobf.jar Binary files differdeleted file mode 100644 index e854bf7df9..0000000000 --- a/dependencies/OpenModularTurrets-1.7.10-2.2.10-237-deobf.jar +++ /dev/null diff --git a/dependencies/WorldEditCuiFe-v1.0.7-mf-1.7.10-10.13.4.1566.jar b/dependencies/WorldEditCuiFe-v1.0.7-mf-1.7.10-10.13.4.1566.jar Binary files differnew file mode 100644 index 0000000000..2891f1480f --- /dev/null +++ b/dependencies/WorldEditCuiFe-v1.0.7-mf-1.7.10-10.13.4.1566.jar diff --git a/repositories.gradle b/repositories.gradle index a161653e0f..a6115099c8 100644 --- a/repositories.gradle +++ b/repositories.gradle @@ -6,10 +6,6 @@ repositories { url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/" } maven { - name "OpenComputers Repo" - url = "http://maven.cil.li/" - } - maven { name = "sponge" url = "https://repo.spongepowered.org/repository/maven-public" } @@ -22,7 +18,7 @@ repositories { } } maven { - url "https://cursemaven.com" + url = "https://cursemaven.com" } maven { url = "https://jitpack.io" diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index 809a7e877d..fe85fc08c5 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -2,15 +2,20 @@ package com.github.technus.tectech; import com.github.technus.tectech.loader.MainLoader; import com.github.technus.tectech.loader.TecTechConfig; +import com.github.technus.tectech.loader.gui.CreativeTabEM; +import com.github.technus.tectech.loader.gui.CreativeTabTecTech; import com.github.technus.tectech.mechanics.anomaly.AnomalyHandler; import com.github.technus.tectech.mechanics.anomaly.CancerCommand; import com.github.technus.tectech.mechanics.anomaly.ChargeCommand; +import com.github.technus.tectech.mechanics.anomaly.MassCommand; import com.github.technus.tectech.mechanics.commands.ConvertFloat; import com.github.technus.tectech.mechanics.commands.ConvertInteger; import com.github.technus.tectech.mechanics.data.ChunkDataHandler; import com.github.technus.tectech.mechanics.data.PlayerPersistence; -import com.github.technus.tectech.mechanics.elementalMatter.core.commands.GiveEM; -import com.github.technus.tectech.mechanics.elementalMatter.core.commands.ListEM; +import com.github.technus.tectech.mechanics.elementalMatter.core.commands.EMGive; +import com.github.technus.tectech.mechanics.elementalMatter.core.commands.EMList; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry; import com.github.technus.tectech.proxy.CommonProxy; import com.github.technus.tectech.util.XSTR; import cpw.mods.fml.common.FMLCommonHandler; @@ -31,8 +36,12 @@ import java.util.Iterator; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, dependencies = "required-after:Forge@[10.13.4.1614,);" - + "required-after:YAMCore@[0.5.70,);" + "required-after:gregtech;" + "after:CoFHCore;" + "after:Thaumcraft;" + "after:dreamcraft;") +@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, + dependencies = "required-after:Forge@[10.13.4.1614,);" + + "required-after:YAMCore@[0.5.70,);" + "required-after:structurelib;" + + "after:ComputerCraft;" + "after:OpenComputers;" + + "required-after:gregtech;" + "after:dreamcraft;" + + "after:appliedenergistics2;" + "after:CoFHCore;" + "after:Thaumcraft;") public class TecTech { @SidedProxy(clientSide = Reference.CLIENTSIDE, serverSide = Reference.SERVERSIDE) public static CommonProxy proxy; @@ -40,22 +49,27 @@ public class TecTech { @Mod.Instance(Reference.MODID) public static TecTech instance; - public static final XSTR RANDOM = XSTR.XSTR_INSTANCE; - public static final LogHelper LOGGER = new LogHelper(Reference.MODID); + public static final XSTR RANDOM = XSTR.XSTR_INSTANCE; + public static final LogHelper LOGGER = new LogHelper(Reference.MODID); + public static CreativeTabTecTech creativeTabTecTech; + public static CreativeTabEM creativeTabEM; private static IngameErrorLog moduleAdminErrorLogs; - public static TecTechConfig configTecTech; + public static TecTechConfig configTecTech; - public static ChunkDataHandler chunkDataHandler; - public static AnomalyHandler anomalyHandler; + public static ChunkDataHandler chunkDataHandler; + public static AnomalyHandler anomalyHandler; public static PlayerPersistence playerPersistence; + public static final EMDefinitionsRegistry definitionsRegistry = new EMDefinitionsRegistry(); + public static final EMTransformationRegistry transformationInfo = new EMTransformationRegistry(); + /** * For Loader.isModLoaded checks during the runtime */ public static boolean hasCOFH = false; - public static final byte tectechTexturePage1=8; + public static final byte tectechTexturePage1 = 8; public static void AddLoginError(String pMessage) { if (moduleAdminErrorLogs != null) { @@ -84,11 +98,11 @@ public class TecTech { moduleAdminErrorLogs = new IngameErrorLog(); } - playerPersistence=new PlayerPersistence("tec"); + playerPersistence = new PlayerPersistence("tec"); FMLCommonHandler.instance().bus().register(playerPersistence); MinecraftForge.EVENT_BUS.register(playerPersistence); - chunkDataHandler=new ChunkDataHandler(); + chunkDataHandler = new ChunkDataHandler(); FMLCommonHandler.instance().bus().register(chunkDataHandler); MinecraftForge.EVENT_BUS.register(chunkDataHandler); @@ -99,14 +113,14 @@ public class TecTech { public void Load(FMLInitializationEvent event) { hasCOFH = Loader.isModLoaded(Reference.COFHCORE); - if(configTecTech.DISABLE_MATERIAL_LOADING_FFS){ + if (configTecTech.DISABLE_MATERIAL_LOADING_FFS) { try { - Field modifiersField = Field.class.getDeclaredField( "modifiers" ); - modifiersField.setAccessible( true ); - Field field= GT_Proxy.class.getDeclaredField("mEvents"); + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + Field field = GT_Proxy.class.getDeclaredField("mEvents"); field.setAccessible(true); - modifiersField.setInt( field, field.getModifiers() & ~Modifier.FINAL ); - field.set(GT_Mod.gregtechproxy, new Collection() { + modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); + field.set(GT_Mod.gregtechproxy, new Collection<Object>() { @Override public int size() { return 0; @@ -123,8 +137,8 @@ public class TecTech { } @Override - public Iterator iterator() { - return new Iterator() { + public Iterator<Object> iterator() { + return new Iterator<Object>() { @Override public boolean hasNext() { return false; @@ -188,26 +202,27 @@ public class TecTech { } - MainLoader.load(); + MainLoader.load(definitionsRegistry); MainLoader.addAfterGregTechPostLoadRunner(); } @Mod.EventHandler public void PostLoad(FMLPostInitializationEvent PostEvent) { - MainLoader.postLoad(); + MainLoader.postLoad(definitionsRegistry, transformationInfo); - chunkDataHandler.registerChunkMetaDataHandler(anomalyHandler=new AnomalyHandler()); + chunkDataHandler.registerChunkMetaDataHandler(anomalyHandler = new AnomalyHandler()); } @Mod.EventHandler public void serverLoad(FMLServerStartingEvent pEvent) { pEvent.registerServerCommand(new ConvertInteger()); pEvent.registerServerCommand(new ConvertFloat()); - pEvent.registerServerCommand(new ListEM()); - if(DEBUG_MODE) { - pEvent.registerServerCommand(new GiveEM()); + pEvent.registerServerCommand(new EMList()); + if (DEBUG_MODE) { + pEvent.registerServerCommand(new EMGive()); pEvent.registerServerCommand(new CancerCommand()); pEvent.registerServerCommand(new ChargeCommand()); + pEvent.registerServerCommand(new MassCommand()); } } diff --git a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java index 9a2ec930e1..55150f046a 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java +++ b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java @@ -1,5 +1,6 @@ package com.github.technus.tectech.compatibility.dreamcraft; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry; import com.github.technus.tectech.recipe.TT_recipeAdder; import com.github.technus.tectech.thing.CustomItemList; import com.github.technus.tectech.thing.block.QuantumGlassBlock; @@ -23,12 +24,12 @@ import net.minecraftforge.fluids.FluidStack; import java.lang.reflect.Method; -import static com.github.technus.tectech.loader.recipe.RecipeLoader.getOrDefault; +import static com.github.technus.tectech.loader.recipe.BaseRecipeLoader.getOrDefault; /** * Created by Tec on 06.08.2017. */ -public class DreamCraftRecipeLoader implements Runnable { +public class DreamCraftRecipeLoader { //region reflect a bit @SuppressWarnings("rawtypes") private Class CUSTOM_ITEM_LIST; @@ -48,8 +49,7 @@ public class DreamCraftRecipeLoader implements Runnable { } //endregion - @Override - public void run() { + public void run(EMTransformationRegistry transformationInfo) { //region reflect a bit try { CUSTOM_ITEM_LIST = Class.forName("com.dreammaster.gthandler.CustomItemList"); diff --git a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/NoDreamCraftMachineLoader.java b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/NoDreamCraftMachineLoader.java index 798ffec36c..90274c69e6 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/NoDreamCraftMachineLoader.java +++ b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/NoDreamCraftMachineLoader.java @@ -2,10 +2,10 @@ package com.github.technus.tectech.compatibility.dreamcraft; import com.github.technus.tectech.Reference; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.thing.CustomItemList; import com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_TT_Transformer; import com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_WetTransformer; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.common.Loader; import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.ITexture; @@ -105,7 +105,7 @@ public class NoDreamCraftMachineLoader implements Runnable { temp = new GT_MetaTileEntity_BasicHull( 11230, "hull.tier.10", "UEV Machine Hull", 10, imagination); - Util.setTier(10, temp); + TT_Utility.setTier(10, temp); if (GT_Values.GT.isClientSide()) { field.set(temp, method.invoke(temp, iTexture)); } @@ -114,7 +114,7 @@ public class NoDreamCraftMachineLoader implements Runnable { temp = new GT_MetaTileEntity_BasicHull( 11231, "hull.tier.11", "UIV Machine Hull", 11, imagination); - Util.setTier(11, temp); + TT_Utility.setTier(11, temp); if (GT_Values.GT.isClientSide()) { field.set(temp, method.invoke(temp, iTexture)); } @@ -123,7 +123,7 @@ public class NoDreamCraftMachineLoader implements Runnable { temp = new GT_MetaTileEntity_BasicHull( 11232, "hull.tier.12", "UMV Machine Hull", 12, imagination); - Util.setTier(12, temp); + TT_Utility.setTier(12, temp); if (GT_Values.GT.isClientSide()) { field.set(temp, method.invoke(temp, iTexture)); } @@ -132,7 +132,7 @@ public class NoDreamCraftMachineLoader implements Runnable { temp = new GT_MetaTileEntity_BasicHull( 11233, "hull.tier.13", "UXV Machine Hull", 13, imagination); - Util.setTier(13, temp); + TT_Utility.setTier(13, temp); if (GT_Values.GT.isClientSide()) { field.set(temp, method.invoke(temp, iTexture)); } @@ -141,7 +141,7 @@ public class NoDreamCraftMachineLoader implements Runnable { temp = new GT_MetaTileEntity_BasicHull( 11234, "hull.tier.14", "OPV Machine Hull", 14, imagination); - Util.setTier(14, temp); + TT_Utility.setTier(14, temp); if (GT_Values.GT.isClientSide()) { field.set(temp, method.invoke(temp, iTexture)); } @@ -150,7 +150,7 @@ public class NoDreamCraftMachineLoader implements Runnable { temp = new GT_MetaTileEntity_BasicHull( 11235, "hull.tier.15", "MAX Machine Hull", 15, imagination); - Util.setTier(15, temp); + TT_Utility.setTier(15, temp); if (GT_Values.GT.isClientSide()) { field.set(temp, method.invoke(temp, iTexture)); } @@ -162,7 +162,7 @@ public class NoDreamCraftMachineLoader implements Runnable { temp = new GT_MetaTileEntity_TT_Transformer( 11221, "tt.transformer.tier.10", "Extremely Ultimate Transformer", 10);//UIV -> UEV (Use Soft Mallet to invert) - Util.setTier(10, temp); + TT_Utility.setTier(10, temp); if (GT_Values.GT.isClientSide()) { field.set(temp, method.invoke(temp, iTexture)); } @@ -170,7 +170,7 @@ public class NoDreamCraftMachineLoader implements Runnable { temp = new GT_MetaTileEntity_TT_Transformer( 11222, "tt.transformer.tier.11", "Insanely Ultimate Transformer", 11);//UMV -> UIV (Use Soft Mallet to invert) - Util.setTier(11, temp); + TT_Utility.setTier(11, temp); if (GT_Values.GT.isClientSide()) { field.set(temp, method.invoke(temp, iTexture)); } @@ -178,7 +178,7 @@ public class NoDreamCraftMachineLoader implements Runnable { temp = new GT_MetaTileEntity_TT_Transformer( 11223, "tt.transformer.tier.12", "Mega Ultimate Transformer", 12);//UXV -> UMV (Use Soft Mallet to invert) - Util.setTier(12, temp); + TT_Utility.setTier(12, temp); if (GT_Values.GT.isClientSide()) { field.set(temp, method.invoke(temp, iTexture)); } @@ -186,7 +186,7 @@ public class NoDreamCraftMachineLoader implements Runnable { temp = new GT_MetaTileEntity_TT_Transformer( 11224, "tt.transformer.tier.13", "Extended Mega Ultimate Transformer", 13);//OPV -> UXV (Use Soft Mallet to invert) - Util.setTier(13, temp); + TT_Utility.setTier(13, temp); if (GT_Values.GT.isClientSide()) { field.set(temp, method.invoke(temp, iTexture)); } @@ -194,7 +194,7 @@ public class NoDreamCraftMachineLoader implements Runnable { temp = new GT_MetaTileEntity_TT_Transformer( 11225, "tt.transformer.tier.14", "Overpowered Transformer", 14);//MAX -> OPV (Use Soft Mallet to invert) - Util.setTier(14, temp); + TT_Utility.setTier(14, temp); if (GT_Values.GT.isClientSide()) { field.set(temp, method.invoke(temp, iTexture)); } @@ -215,7 +215,7 @@ public class NoDreamCraftMachineLoader implements Runnable { 11910, "transformer.ha.tier.10", "Extremely Ultimate Hi-Amp Transformer", 10, //UIV -> UEV (Use Soft Mallet to invert) translateToLocal("gt.blockmachines.transformer.ha.tier.10.desc")); - Util.setTier(10, temp); + TT_Utility.setTier(10, temp); if (GT_Values.GT.isClientSide()) { field.set(temp, method.invoke(temp, iTexture)); } @@ -225,7 +225,7 @@ public class NoDreamCraftMachineLoader implements Runnable { 11911, "transformer.ha.tier.11", "Insanely Ultimate Hi-Amp Transformer", 11, //UMV -> UIV (Use Soft Mallet to invert) translateToLocal("gt.blockmachines.transformer.ha.tier.11.desc")); - Util.setTier(11, temp); + TT_Utility.setTier(11, temp); if (GT_Values.GT.isClientSide()) { field.set(temp, method.invoke(temp, iTexture)); } @@ -235,7 +235,7 @@ public class NoDreamCraftMachineLoader implements Runnable { 11912, "transformer.ha.tier.12", "Mega Ultimate Hi-Amp Transformer", 12, //UXV -> UMV (Use Soft Mallet to invert) translateToLocal("gt.blockmachines.transformer.ha.tier.12.desc")); - Util.setTier(12, temp); + TT_Utility.setTier(12, temp); if (GT_Values.GT.isClientSide()) { field.set(temp, method.invoke(temp, iTexture)); } @@ -245,7 +245,7 @@ public class NoDreamCraftMachineLoader implements Runnable { 11913, "transformer.ha.tier.13", "Extended Mega Ultimate Hi-Amp Transformer", 13, //OPV -> UXV (Use Soft Mallet to invert) translateToLocal("gt.blockmachines.transformer.ha.tier.13.desc")); - Util.setTier(13, temp); + TT_Utility.setTier(13, temp); if (GT_Values.GT.isClientSide()) { field.set(temp, method.invoke(temp, iTexture)); } @@ -255,7 +255,7 @@ public class NoDreamCraftMachineLoader implements Runnable { 11914, "transformer.ha.tier.14", "Overpowered Hi-Amp Transformer", 14, //MAX -> OPV (Use Soft Mallet to invert) translateToLocal("gt.blockmachines.transformer.ha.tier.14.desc")); - Util.setTier(14, temp); + TT_Utility.setTier(14, temp); if (GT_Values.GT.isClientSide()) { field.set(temp, method.invoke(temp, iTexture)); } diff --git a/src/main/java/com/github/technus/tectech/compatibility/gtpp/GtppAtomLoader.java b/src/main/java/com/github/technus/tectech/compatibility/gtpp/GtppAtomLoader.java index bf96d61795..65219271f9 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/gtpp/GtppAtomLoader.java +++ b/src/main/java/com/github/technus/tectech/compatibility/gtpp/GtppAtomLoader.java @@ -1,17 +1,19 @@ package com.github.technus.tectech.compatibility.gtpp; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry; import gregtech.api.enums.OrePrefixes; import net.minecraftforge.fluids.FluidStack; import java.lang.reflect.Method; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT_144; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition.*; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition.getBestUnstableIsotope; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition.getFirstStableIsotope; -public class GtppAtomLoader implements Runnable{ +public class GtppAtomLoader { //region reflect a bit - private Class ELEMENT; + private Class<?> ELEMENT; private Object ELEMENT_INSTANCE; private Method getUnlocalizedName,getFluid,generate; @@ -40,16 +42,7 @@ public class GtppAtomLoader implements Runnable{ } //endregion - private static Method getMethodWithReplacements(Class<?> owner, String name1, String name2, Class<?>... arguments) throws ReflectiveOperationException { - try { - return owner.getMethod(name1, arguments); - } catch (ReflectiveOperationException e) { - return owner.getMethod(name2, arguments); - } - } - - @Override - public void run() { + public void setTransformations(EMTransformationRegistry transformationInfo) { //region reflect a bit try{ ELEMENT=Class.forName("gtPlusPlus.core.material.ELEMENT"); @@ -57,7 +50,11 @@ public class GtppAtomLoader implements Runnable{ Class<?> clazz=Class.forName("gtPlusPlus.core.material.Material"); getUnlocalizedName=clazz.getMethod("getUnlocalizedName"); - getFluid=getMethodWithReplacements(clazz,"getFluidStack", "getFluid", int.class); + try{ + getFluid=clazz.getMethod("getFluidStack", int.class); + }catch (Exception e){ + getFluid=clazz.getMethod("getFluid", int.class); + } clazz=Class.forName("gtPlusPlus.core.material.MaterialGenerator"); generate=clazz.getMethod("generate", Class.forName("gtPlusPlus.core.material.Material"), boolean.class, boolean.class); @@ -66,34 +63,34 @@ public class GtppAtomLoader implements Runnable{ } //endregion - TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(10), AVOGADRO_CONSTANT_144), getFluid("NEON",144)); + transformationInfo.addFluid(new EMDefinitionStack(getFirstStableIsotope(10), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), getFluid("NEON",144)); generate("GERMANIUM",true,true); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(32), AVOGADRO_CONSTANT_144), OrePrefixes.dust, getUnlocalizedName("GERMANIUM"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(34), AVOGADRO_CONSTANT_144), OrePrefixes.dust, getUnlocalizedName("SELENIUM"),1); - TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(35), AVOGADRO_CONSTANT_144), getFluid("BROMINE",144)); - TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(36), AVOGADRO_CONSTANT_144), getFluid("KRYPTON",144)); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(40), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("ZIRCONIUM"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(43), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("TECHNETIUM"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(44), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("RUTHENIUM"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(45), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("RHODIUM"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(53), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("IODINE"),1); - TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(54), AVOGADRO_CONSTANT_144),getFluid("XENON",144)); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(72), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("HAFNIUM"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(75), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("RHENIUM"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(81), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("THALLIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(32), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), OrePrefixes.dust, getUnlocalizedName("GERMANIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(34), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), OrePrefixes.dust, getUnlocalizedName("SELENIUM"),1); + transformationInfo.addFluid(new EMDefinitionStack(getFirstStableIsotope(35), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), getFluid("BROMINE",144)); + transformationInfo.addFluid(new EMDefinitionStack(getFirstStableIsotope(36), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), getFluid("KRYPTON",144)); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(40), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("ZIRCONIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(43), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("TECHNETIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(44), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("RUTHENIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(45), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("RHODIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(53), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("IODINE"),1); + transformationInfo.addFluid(new EMDefinitionStack(getFirstStableIsotope(54), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),getFluid("XENON",144)); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(72), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("HAFNIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(75), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("RHENIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(81), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("THALLIUM"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(84), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("POLONIUM"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(85), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("ASTATINE"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(87), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("FRANCIUM"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(88), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("RADIUM"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(89), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("ACTINIUM"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(91), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("PROTACTINIUM"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(93), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("NEPTUNIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(84), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("POLONIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(85), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("ASTATINE"),1); + transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(87), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("FRANCIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(88), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("RADIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(89), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("ACTINIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(91), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("PROTACTINIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(93), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("NEPTUNIUM"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(96), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("CURIUM"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(97), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("BERKELIUM"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(98), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("CALIFORNIUM"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(99), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("EINSTEINIUM"),1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(100), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("FERMIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(96), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("CURIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(97), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("BERKELIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(98), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("CALIFORNIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(99), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("EINSTEINIUM"),1); + transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(100), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED),OrePrefixes.dust, getUnlocalizedName("FERMIUM"),1); } } diff --git a/src/main/java/com/github/technus/tectech/compatibility/openComputers/AvrArchitecture.java b/src/main/java/com/github/technus/tectech/compatibility/openComputers/AvrArchitecture.java index 2842a71df3..ceadce9d6d 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/openComputers/AvrArchitecture.java +++ b/src/main/java/com/github/technus/tectech/compatibility/openComputers/AvrArchitecture.java @@ -8,8 +8,8 @@ import com.github.technus.avrClone.instructions.exceptions.DelayEvent; import com.github.technus.avrClone.memory.EepromMemory; import com.github.technus.avrClone.memory.RemovableMemory; import com.github.technus.avrClone.memory.program.ProgramMemory; -import com.github.technus.tectech.util.Converter; import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.util.Converter; import li.cil.oc.Settings; import li.cil.oc.api.Driver; import li.cil.oc.api.driver.Item; @@ -21,7 +21,7 @@ import li.cil.oc.api.machine.Signal; import li.cil.oc.common.SaveHandler; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import org.apache.commons.io.IOUtils; +import org.apache.commons.compress.utils.IOUtils; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; diff --git a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretbases/TurretBaseEM.java b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretbases/TurretBaseEM.java index 9da3b82b40..654b4e37a6 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretbases/TurretBaseEM.java +++ b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretbases/TurretBaseEM.java @@ -10,7 +10,7 @@ import net.minecraft.world.World; import openmodularturrets.blocks.turretbases.BlockAbstractTurretBase; import openmodularturrets.handler.ConfigHandler; -import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; +import static com.github.technus.tectech.TecTech.creativeTabTecTech; /** * Created by Tec on 27/07/2017. diff --git a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretheads/TurretHeadEM.java b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretheads/TurretHeadEM.java index 7b7167b915..da212d4853 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretheads/TurretHeadEM.java +++ b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretheads/TurretHeadEM.java @@ -11,7 +11,7 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import openmodularturrets.tileentity.turretbase.TurretBase; -import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; +import static com.github.technus.tectech.TecTech.creativeTabTecTech; /** * Created by Tec on 27/07/2017. diff --git a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretheads/TurretHeadItemEM.java b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretheads/TurretHeadItemEM.java index f4ad25f053..ce11976020 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretheads/TurretHeadItemEM.java +++ b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/blocks/turretheads/TurretHeadItemEM.java @@ -37,7 +37,7 @@ public class TurretHeadItemEM extends ItemBlock { list.add(EnumChatFormatting.DARK_PURPLE + "--" + translateToLocal("tooltip.damage.label") + "--"); list.add(translateToLocal("tooltip.damage.stat") + ": " + EnumChatFormatting.WHITE + (float)ConfigHandler.getLaserTurretSettings().getDamage() / 2.0F + ' ' + translateToLocal("tooltip.health")); list.add(translateToLocal("tooltip.aoe") + ": " + EnumChatFormatting.WHITE + '0'); - list.add(translateToLocal("tooltip.firerate") + ": " + EnumChatFormatting.WHITE + df.format((double)(20.0F / (float)ConfigHandler.getLaserTurretSettings().getFireRate()))); + list.add(translateToLocal("tooltip.firerate") + ": " + EnumChatFormatting.WHITE + df.format(20.0F / (float)ConfigHandler.getLaserTurretSettings().getFireRate())); list.add(translateToLocal("tooltip.energy.stat") + ": " + EnumChatFormatting.WHITE + ConfigHandler.getLaserTurretSettings().getPowerUsage() + " RF"); list.add(""); list.add(EnumChatFormatting.DARK_GRAY + translateToLocal("flavour.turret.4")); diff --git a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/entity/projectiles/projectileEM.java b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/entity/projectiles/projectileEM.java index 702ed77315..54bd3aaea5 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/entity/projectiles/projectileEM.java +++ b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/entity/projectiles/projectileEM.java @@ -1,10 +1,8 @@ package com.github.technus.tectech.compatibility.openmodularturrets.entity.projectiles; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dHadronDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eQuarkDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMHadronDefinition; import gregtech.api.GregTech_API; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; @@ -26,11 +24,12 @@ public class projectileEM extends LaserProjectile { public float gravity=0; private TurretBase turretBase; - private boolean exotic, antiMatter,isAmped; + private boolean strange, antiMatter,isAmped; private int ampLevel; private float massFactor; + private double mass,charge; public projectileEM(World par1World) { super(par1World); @@ -45,96 +44,91 @@ public class projectileEM extends LaserProjectile { } } - public projectileEM(World par1World, TurretBase turretBase, cElementalInstanceStackMap avalableEM) { + public projectileEM(World par1World, TurretBase turretBase, EMInstanceStack projectileContent) { super(par1World, turretBase); this.turretBase = turretBase; - boolean onlyQuarks=true; - if(avalableEM!=null && avalableEM.hasStacks()) { - for (cElementalInstanceStack stack : avalableEM.values()) { - if (!(stack.definition instanceof eQuarkDefinition)) { - onlyQuarks = false; - } - } - if (onlyQuarks) { - avalableEM.clear(); - } else { - cElementalInstanceStack consumeFromThis=avalableEM.get(TecTech.RANDOM.nextInt(avalableEM.size())); - massFactor =(float) (consumeFromThis.definition.getMass()/ dHadronDefinition.hadron_n_.getMass()); - - if(consumeFromThis.definition.getType()>1 || consumeFromThis.definition.getType()<-1) { - exotic = true; - } - if(consumeFromThis.definition.getType()<0) { - antiMatter = true; - } + if(projectileContent != null){ + mass=projectileContent.getMass(); + charge=projectileContent.getCharge(); + massFactor =(float) (projectileContent.getDefinition().getMass()/ EMHadronDefinition.hadron_n_.getMass()); - if (consumeFromThis.definition.getCharge() == 0) { - gravity = massFactor / 100f; - } else { - gravity = Math.min(0.0025F / Math.abs(consumeFromThis.definition.getCharge()), massFactor / 100f); - } + if(projectileContent.getDefinition().getGeneration()>1 || projectileContent.getDefinition().getGeneration()<-1) { + strange = true; + } + if(projectileContent.getDefinition().getGeneration()<0) { + antiMatter = true; + } - avalableEM.removeAmount(false,consumeFromThis.definition.getStackForm(1)); + if (projectileContent.getDefinition().getCharge() == 0) { + gravity = massFactor / 100f; + } else { + gravity = Math.min(0.0025F / Math.abs(projectileContent.getDefinition().getCharge()), massFactor / 100f); } } - //todo make the recipe require some overflow hatches - - //todo add more subspace pollution } @Override protected void onImpact(MovingObjectPosition movingobjectposition) { if(ticksExisted > 1) { - if(movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - Block hitBlock = worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); - if(hitBlock != null){ - if (hitBlock.getMaterial().isSolid() && TecTech.configTecTech.ENABLE_TURRET_EXPLOSIONS && antiMatter) { - worldObj.playSoundEffect(posX, posY, posZ, "openmodularturrets:laserHit", ConfigHandler.getTurretSoundVolume(), TecTech.RANDOM.nextFloat() + 0.5F); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(209), 1.0F, -1.0F, - movingobjectposition.blockX, - movingobjectposition.blockY, - movingobjectposition.blockZ); - worldObj.createExplosion(null, - movingobjectposition.blockX + 0.5D, - movingobjectposition.blockY + 0.5D, - movingobjectposition.blockZ + 0.5D, (exotic?10:1) * TecTech.configTecTech.TURRET_EXPLOSION_FACTOR * massFactor * (isAmped? ampLevel*.1f +1:1) * (ticksExisted/250f), true); - } else { - return; - } - } - } - - if(movingobjectposition.entityHit != null && !worldObj.isRemote) { + if(!worldObj.isRemote){ worldObj.playSoundEffect(posX, posY, posZ, "openmodularturrets:laserHit", ConfigHandler.getTurretSoundVolume(), TecTech.RANDOM.nextFloat() + 0.5F); - if(movingobjectposition.entityHit != null && !worldObj.isRemote) { - float damage = (exotic?10:1) * TecTech.configTecTech.TURRET_DAMAGE_FACTOR * massFactor * (isAmped? ampLevel*.1f +1:1); - - if(movingobjectposition.entityHit instanceof EntityPlayer) { - if(canDamagePlayer((EntityPlayer)movingobjectposition.entityHit)) { - movingobjectposition.entityHit.setFire((exotic?10:1)*2); + switch (movingobjectposition.typeOfHit){ + case BLOCK: + Block hitBlock = worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); + if(hitBlock != null){ + if (TecTech.configTecTech.ENABLE_TURRET_EXPLOSIONS && antiMatter && hitBlock.getMaterial().isSolid()) { + GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(209), 1.0F, -1.0F, + movingobjectposition.blockX, + movingobjectposition.blockY, + movingobjectposition.blockZ); + worldObj.createExplosion(null, + movingobjectposition.blockX + 0.5D, + movingobjectposition.blockY + 0.5D, + movingobjectposition.blockZ + 0.5D, + TecTech.configTecTech.TURRET_EXPLOSION_FACTOR * (strange ? 10 : 1) * massFactor * (isAmped ? ampLevel * .1f + 1 : 1) * (ticksExisted / 250f), true); + } else { + return; + } + } + break; + case ENTITY: + float damage = (strange ?10:1) * TecTech.configTecTech.TURRET_DAMAGE_FACTOR * massFactor * (isAmped? ampLevel*.1f +1:1); + + if(movingobjectposition.entityHit instanceof EntityPlayer) { + EntityPlayer player=(EntityPlayer)movingobjectposition.entityHit; + if(canDamagePlayer(player)) { + movingobjectposition.entityHit.setFire((strange ?10:1)*2); + movingobjectposition.entityHit.attackEntityFrom(new NormalDamageSource("laser"), damage); + if(antiMatter) { + movingobjectposition.entityHit.hurtResistantTime = 0; + } + if(strange){ + TecTech.anomalyHandler.addCancer(player,mass); + } + if(charge!=0) { + TecTech.anomalyHandler.addCharge(player,charge); + } + } + } else { + movingobjectposition.entityHit.setFire((strange ?10:1)*2); movingobjectposition.entityHit.attackEntityFrom(new NormalDamageSource("laser"), damage); if(antiMatter) { movingobjectposition.entityHit.hurtResistantTime = 0; } } - } else { - movingobjectposition.entityHit.setFire((exotic?10:1)*2); - movingobjectposition.entityHit.attackEntityFrom(new NormalDamageSource("laser"), damage); - if(antiMatter) { - movingobjectposition.entityHit.hurtResistantTime = 0; + + if (TecTech.configTecTech.ENABLE_TURRET_EXPLOSIONS && antiMatter) { + GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(209), 1.0F, -1.0F, + (int)movingobjectposition.entityHit.posX, + (int)movingobjectposition.entityHit.posY, + (int)movingobjectposition.entityHit.posZ); + worldObj.createExplosion(null, + movingobjectposition.entityHit.posX, + movingobjectposition.entityHit.posY, + movingobjectposition.entityHit.posZ, + (strange ?10:1) * TecTech.configTecTech.TURRET_EXPLOSION_FACTOR * massFactor * (isAmped? ampLevel*.1f +1:1) * (ticksExisted/250f), true); } - } - - if (TecTech.configTecTech.ENABLE_TURRET_EXPLOSIONS && antiMatter) { - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(209), 1.0F, -1.0F, - (int)movingobjectposition.entityHit.posX, - (int)movingobjectposition.entityHit.posY, - (int)movingobjectposition.entityHit.posZ); - worldObj.createExplosion(null, - movingobjectposition.entityHit.posX, - movingobjectposition.entityHit.posY, - movingobjectposition.entityHit.posZ, (exotic?10:1) * TecTech.configTecTech.TURRET_EXPLOSION_FACTOR * massFactor * (isAmped? ampLevel*.1f +1:1) * (ticksExisted/250f), true); - } + break; } } setDead(); diff --git a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/tileentity/turret/TileTurretHeadEM.java b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/tileentity/turret/TileTurretHeadEM.java index 2de6b39c4c..742232d8c6 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/tileentity/turret/TileTurretHeadEM.java +++ b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/tileentity/turret/TileTurretHeadEM.java @@ -2,7 +2,8 @@ package com.github.technus.tectech.compatibility.openmodularturrets.tileentity.t import com.github.technus.tectech.compatibility.openmodularturrets.entity.projectiles.projectileEM; import com.github.technus.tectech.compatibility.openmodularturrets.tileentity.turretbase.TileTurretBaseEM; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; import com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM; import net.minecraft.entity.Entity; import net.minecraft.item.Item; @@ -13,11 +14,13 @@ import openmodularturrets.handler.ConfigHandler; import openmodularturrets.tileentity.turrets.TurretHead; import openmodularturrets.util.TurretHeadUtil; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT; + /** * Created by Bass on 27/07/2017. */ public class TileTurretHeadEM extends TurretHead{ - private cElementalInstanceStackMap hatchContentPointer; + private EMInstanceStackMap hatchContentPointer; @Override public int getTurretRange() { @@ -49,7 +52,7 @@ public class TileTurretHeadEM extends TurretHead{ @Override public boolean requiresAmmo() { - return hatchContentPointer == null || !hatchContentPointer.hasStacks(); + return hatchContentPointer == null || hatchContentPointer.isEmpty(); } @Override @@ -64,7 +67,15 @@ public class TileTurretHeadEM extends TurretHead{ @Override public final TurretProjectile createProjectile(World world, Entity target, ItemStack ammo) { - return new projectileEM(world, TurretHeadUtil.getTurretBase(worldObj, xCoord, yCoord, zCoord), hatchContentPointer); + if (hatchContentPointer == null || hatchContentPointer.isEmpty()) { + return new projectileEM(world, TurretHeadUtil.getTurretBase(worldObj, xCoord, yCoord, zCoord), null); + } + EMInstanceStack stack = hatchContentPointer.getRandom(); + double amount = Math.min(EM_COUNT_PER_MATERIAL_AMOUNT, stack.getAmount()); + hatchContentPointer.removeAmount(stack.getDefinition(), EM_COUNT_PER_MATERIAL_AMOUNT); + stack=stack.clone(); + stack.setAmount(amount); + return new projectileEM(world, TurretHeadUtil.getTurretBase(worldObj, xCoord, yCoord, zCoord), stack); } @Override diff --git a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/tileentity/turretbase/TileTurretBaseEM.java b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/tileentity/turretbase/TileTurretBaseEM.java index a31ba4ef2c..0dbc33e007 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/tileentity/turretbase/TileTurretBaseEM.java +++ b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/tileentity/turretbase/TileTurretBaseEM.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.compatibility.openmodularturrets.tileentity.turretbase; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputElemental; import cpw.mods.fml.common.Optional; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -25,7 +25,7 @@ public class TileTurretBaseEM extends TurretBaseTierFiveTileEntity { return "turretBaseEM"; } - public final cElementalInstanceStackMap getContainerHandler() { + public final EMInstanceStackMap getContainerHandler() { World worldIn = getWorldObj(); TileEntity te; if ((te = worldIn.getTileEntity(xCoord + 1, yCoord, zCoord)) instanceof IGregTechTileEntity && @@ -61,8 +61,8 @@ public class TileTurretBaseEM extends TurretBaseTierFiveTileEntity { return null; } - private cElementalInstanceStackMap getFromHatch(GT_MetaTileEntity_Hatch_InputElemental hatch) { + private EMInstanceStackMap getFromHatch(GT_MetaTileEntity_Hatch_InputElemental hatch) { hatch.updateTexture((byte) 8,(byte) 4); - return hatch.getContainerHandler(); + return hatch.getContentHandler(); } } diff --git a/src/main/java/com/github/technus/tectech/compatibility/spartakcore/SpartakCoreRecipeLoader.java b/src/main/java/com/github/technus/tectech/compatibility/spartakcore/SpartakCoreRecipeLoader.java index 3fabfd67b2..b2050bbac5 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/spartakcore/SpartakCoreRecipeLoader.java +++ b/src/main/java/com/github/technus/tectech/compatibility/spartakcore/SpartakCoreRecipeLoader.java @@ -1,5 +1,6 @@ package com.github.technus.tectech.compatibility.spartakcore; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry; import com.github.technus.tectech.recipe.TT_recipeAdder; import com.github.technus.tectech.thing.CustomItemList; import com.github.technus.tectech.thing.block.QuantumGlassBlock; @@ -19,15 +20,13 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import static com.github.technus.tectech.loader.recipe.RecipeLoader.getOrDefault; +import static com.github.technus.tectech.loader.recipe.BaseRecipeLoader.getOrDefault; /** * Created by Spartak1997 on 28.07.2019. */ -public class SpartakCoreRecipeLoader implements Runnable { - - @Override - public void run() { +public class SpartakCoreRecipeLoader { + public void run(EMTransformationRegistry transformationInfo) { //Quantum Glass GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/AspectDefinitionCompat.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/AspectDefinitionCompat.java deleted file mode 100644 index 2d531858d0..0000000000 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/AspectDefinitionCompat.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions; - - -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; - -import java.util.HashMap; - -/** - * Created by Tec on 21.05.2017. - */ -public class AspectDefinitionCompat { - public static AspectDefinitionCompat aspectDefinitionCompat; - static final HashMap<cElementalDefinition,String> defToAspect = new HashMap<>(); - public static final HashMap<String,cElementalDefinition> aspectToDef = new HashMap<>(); - - public void run(){} - - Object getAspect(cElementalDefinition definition){ - return null; - } - - String getAspectTag(cElementalDefinition definition){ - return null; - } - - iElementalDefinition getDefinition(String aspect){ - return null; - } -} diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/AspectDefinitionCompatEnabled.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/AspectDefinitionCompatEnabled.java deleted file mode 100644 index da930a1d79..0000000000 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/AspectDefinitionCompatEnabled.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions; - -import com.github.technus.tectech.mechanics.elementalMatter.core.tElementalException; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; -import thaumcraft.api.aspects.Aspect; - -import java.util.ArrayList; - -import static com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.ePrimalAspectDefinition.*; - -/** - * Created by Tec on 21.05.2017. - */ -public final class AspectDefinitionCompatEnabled extends AspectDefinitionCompat { - @Override - public void run(){ - defToAspect.put(magic_air,"aer"); - defToAspect.put(magic_earth,"terra"); - defToAspect.put(magic_fire,"ignis"); - defToAspect.put(magic_water,"aqua"); - defToAspect.put(magic_order,"ordo"); - defToAspect.put(magic_entropy,"perditio"); - - aspectToDef.put("aer",magic_air); - aspectToDef.put("terra",magic_earth); - aspectToDef.put("ignis",magic_fire); - aspectToDef.put("aqua",magic_water); - aspectToDef.put("ordo",magic_order); - aspectToDef.put("perditio",magic_entropy); - - ArrayList<Aspect> list=Aspect.getCompoundAspects(); - Aspect[] array= list.toArray(new Aspect[0]); - while (!list.isEmpty()) { - for (Aspect aspect : array) { - if (list.contains(aspect)) { - Aspect[] content = aspect.getComponents(); - if (content.length != 2) { - list.remove(aspect); - }else if(aspectToDef.containsKey(content[0].getTag()) && aspectToDef.containsKey(content[1].getTag())){ - try { - dComplexAspectDefinition newAspect; - if(content[0].getTag().equals(content[1].getTag())){ - newAspect = new dComplexAspectDefinition(aspectToDef.get(content[0].getTag()).getStackForm(2) - ); - }else{ - newAspect = new dComplexAspectDefinition(aspectToDef.get(content[0].getTag()).getStackForm(1), aspectToDef.get(content[1].getTag()).getStackForm(1) - ); - } - aspectToDef.put(aspect.getTag(),newAspect); - defToAspect.put(newAspect,aspect.getTag()); - }catch (tElementalException e) { - /**/ - }finally { - list.remove(aspect); - } - } - } - } - } - } - - @Override - Aspect getAspect(cElementalDefinition definition) { - return Aspect.getAspect(defToAspect.get(definition)); - } - - @Override - String getAspectTag(cElementalDefinition definition) { - return defToAspect.get(definition); - } - - @Override - iElementalDefinition getDefinition(String aspect) { - return aspectToDef.get(aspect); - } - -} diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMComplexAspectDefinition.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMComplexAspectDefinition.java new file mode 100644 index 0000000000..c2d93cf0fd --- /dev/null +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMComplexAspectDefinition.java @@ -0,0 +1,229 @@ +package com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.transformations.AspectDefinitionCompat; +import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; +import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMComplexTemplate; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMIndirectType; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; + +import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay.NO_DECAY; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.deadEnd; +import static net.minecraft.util.StatCollector.translateToLocal; + +/** + * Created by Tec on 06.05.2017. + */ +public final class EMComplexAspectDefinition extends EMComplexTemplate { + private final int hash; + private final double mass; + + private static final String nbtType = "`"; + + private final EMConstantStackMap aspectStacks; + + public EMComplexAspectDefinition(EMDefinitionStack... aspects) throws EMException { + this(true, new EMConstantStackMap(aspects)); + } + + private EMComplexAspectDefinition(boolean check, EMDefinitionStack... aspects) throws EMException { + this(check, new EMConstantStackMap(aspects)); + } + + public EMComplexAspectDefinition(EMConstantStackMap aspects) throws EMException { + this(true, aspects); + } + + private EMComplexAspectDefinition(boolean check, EMConstantStackMap aspects) throws EMException { + if (check && !canTheyBeTogether(aspects)) { + throw new EMException("Complex Aspect Definition error"); + } + aspectStacks = aspects; + float mass = 0; + for (EMDefinitionStack stack : aspects.valuesToArray()) { + mass += stack.getMass(); + } + this.mass = mass; + hash = super.hashCode(); + } + + //public but u can just try{}catch(){} the constructor it still calls this method + private static boolean canTheyBeTogether(EMConstantStackMap stacks) { + long amount = 0; + for (EMDefinitionStack aspects : stacks.valuesToArray()) { + if (!(aspects.getDefinition() instanceof EMComplexAspectDefinition) && !(aspects.getDefinition() instanceof EMPrimalAspectDefinition)) { + return false; + } + if((int) aspects.getAmount() != aspects.getAmount()){ + throw new ArithmeticException("Amount cannot be safely converted to int!"); + } + amount += aspects.getAmount(); + } + return amount == 2; + } + + @Override + public String getLocalizedTypeName() { + return translateToLocal("tt.keyword.Aspect"); + } + + @Override + public String getShortLocalizedName() { + String name = AspectDefinitionCompat.aspectDefinitionCompat.getAspectLocalizedName(this); + if (name != null) { + return name.substring(0, 1).toUpperCase() + name.substring(1); + } else { + return getSymbol(); + } + } + + @Override + public String getSymbol() { + StringBuilder symbol = new StringBuilder(8); + for (EMDefinitionStack aspect : aspectStacks.valuesToArray()) { + if (aspect.getDefinition() instanceof EMPrimalAspectDefinition) { + for (int i = 0; i < aspect.getAmount(); i++) { + symbol.append(aspect.getDefinition().getSymbol()); + } + } else { + symbol.append('('); + for (int i = 0; i < aspect.getAmount(); i++) { + symbol.append(aspect.getDefinition().getSymbol()); + } + symbol.append(')'); + } + } + return symbol.toString(); + } + + @Override + public String getShortSymbol() { + StringBuilder symbol = new StringBuilder(8); + for (EMDefinitionStack aspect : aspectStacks.valuesToArray()) { + if (aspect.getDefinition() instanceof EMPrimalAspectDefinition) { + for (int i = 0; i < aspect.getAmount(); i++) { + symbol.append(aspect.getDefinition().getShortSymbol()); + } + } else { + symbol.append('('); + for (int i = 0; i < aspect.getAmount(); i++) { + symbol.append(aspect.getDefinition().getShortSymbol()); + } + symbol.append(')'); + } + } + return symbol.toString(); + } + + @Override + protected String getTagValue() { + return nbtType; + } + + @Override + public double getRawTimeSpan(long currentEnergy) { + return -1; + } + + @Override + public boolean isTimeSpanHalfLife() { + return false; + } + + @Override + public int getCharge() { + return 0; + } + + @Override + public int getGeneration() { + return 0; + } + + @Override + public int getMaxColors() { + return -1; + } + + @Override + public EMConstantStackMap getSubParticles() { + return aspectStacks; + } + + @Override + public EMDecay[] getEnergyInducedDecay(long energyLevel) { + return new EMDecay[]{new EMDecay(0.75F, aspectStacks), deadEnd}; + } + + @Override + public double getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { + return IEMDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - currentEnergyLevel); + } + + @Override + public boolean usesSpecialEnergeticDecayHandling() { + return false; + } + + @Override + public boolean usesMultipleDecayCalls(long energyLevel) { + return false; + } + + @Override + public boolean decayMakesEnergy(long energyLevel) { + return false; + } + + @Override + public boolean fusionMakesEnergy(long energyLevel) { + return false; + } + + @Override + public EMDecay[] getNaturalDecayInstant() { + return NO_DECAY; + } + + @Override + public EMDecay[] getDecayArray() { + return NO_DECAY; + } + + @Override + public double getMass() { + return mass; + } + + @Override + public IEMDefinition getAnti() { + return null; + } + + public static void run(EMDefinitionsRegistry registry) { + registry.registerDefinitionClass(nbtType, new EMIndirectType((definitionsRegistry, nbt)-> + new EMComplexAspectDefinition(EMConstantStackMap.fromNBT(definitionsRegistry,nbt)), EMComplexAspectDefinition.class, "tt.keyword.Aspect")); + if (DEBUG_MODE) { + TecTech.LOGGER.info("Registered Elemental Matter Class: ComplexAspect " + nbtType + ' ' + getClassTypeStatic()); + } + } + + @Override + public int getMatterMassType() { + return getClassTypeStatic(); + } + + public static int getClassTypeStatic() { + return -96; + } + + @Override + public int hashCode() { + return hash; + } +} diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMPrimalAspectDefinition.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMPrimalAspectDefinition.java new file mode 100644 index 0000000000..6fa709ef3e --- /dev/null +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMPrimalAspectDefinition.java @@ -0,0 +1,52 @@ +package com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions; + +import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.transformations.AspectDefinitionCompat; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMType; + +import static com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay.NO_DECAY; +import static net.minecraft.util.StatCollector.translateToLocal; + +/** + * Created by Tec on 06.05.2017. + */ +public final class EMPrimalAspectDefinition extends EMPrimitiveTemplate { + public static final EMPrimalAspectDefinition + magic_air = new EMPrimalAspectDefinition("tt.keyword.Air", "a`", 1e1D, 45,"a`"), + magic_earth = new EMPrimalAspectDefinition("tt.keyword.Earth", "e`", 1e9D, 44,"e`"), + magic_fire = new EMPrimalAspectDefinition("tt.keyword.Fire", "f`", 1e3D, 43,"f`"), + magic_water = new EMPrimalAspectDefinition("tt.keyword.Water", "w`", 1e7D, 42,"w`"), + magic_order = new EMPrimalAspectDefinition("tt.keyword.Order", "o`", 1e5D, 40,"o`"), + magic_entropy = new EMPrimalAspectDefinition("tt.keyword.Chaos", "c`", 1e5D, 41,"c`"); + + private EMPrimalAspectDefinition(String name, String symbol, double mass, int ID,String bind) { + super(name, symbol, 0, mass, 0, -1, ID,bind); + } + + public static void run(EMDefinitionsRegistry registry) { + registry.registerDefinitionClass(new EMType(EMPrimalAspectDefinition.class,"tt.keyword.Primal")); + magic_air.init(registry,null, -1F, -1, -1, NO_DECAY); + magic_earth.init(registry,null, -1F, -1, -1, NO_DECAY); + magic_fire.init(registry,null, -1F, -1, -1, NO_DECAY); + magic_water.init(registry,null, -1F, -1, -1, NO_DECAY); + magic_order.init(registry,null, -1F, -1, -1, NO_DECAY); + magic_entropy.init(registry,null, -1F, -1, -1, NO_DECAY); + } + + @Override + public String getShortLocalizedName() { + String name = AspectDefinitionCompat.aspectDefinitionCompat.getAspectLocalizedName(this); + return name != null ? super.getShortLocalizedName() + " (" + name + ")" : super.getShortLocalizedName(); + } + + @Override + public String getLocalizedTypeName() { + return translateToLocal("tt.keyword.Primal"); + } + + @Override + public boolean isTimeSpanHalfLife() { + return false; + } +}
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/dComplexAspectDefinition.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/dComplexAspectDefinition.java deleted file mode 100644 index ddef29b214..0000000000 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/dComplexAspectDefinition.java +++ /dev/null @@ -1,322 +0,0 @@ -package com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions; - -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDefinitionStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.tElementalException; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aFluidDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aItemDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aOredictDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.ArrayList; - -import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay.noDecay; -import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; -import static net.minecraft.util.StatCollector.translateToLocal; - -/** - * Created by Tec on 06.05.2017. - */ -public final class dComplexAspectDefinition extends cElementalDefinition implements iElementalAspect { - private final int hash; - public final double mass; - - private static final byte nbtType = (byte) 'c'; - - private final cElementalDefinitionStackMap aspectStacks; - - @Deprecated - public dComplexAspectDefinition(cElementalDefinition... aspects) throws tElementalException { - this(true, new cElementalDefinitionStackMap(aspects)); - } - - @Deprecated - private dComplexAspectDefinition(boolean check, cElementalDefinition... aspects) throws tElementalException { - this(check, new cElementalDefinitionStackMap(aspects)); - } - - public dComplexAspectDefinition(cElementalDefinitionStack... aspects) throws tElementalException { - this(true, new cElementalDefinitionStackMap(aspects)); - } - - private dComplexAspectDefinition(boolean check, cElementalDefinitionStack... aspects) throws tElementalException { - this(check, new cElementalDefinitionStackMap(aspects)); - } - - public dComplexAspectDefinition(cElementalDefinitionStackMap aspects) throws tElementalException { - this(true, aspects); - } - - private dComplexAspectDefinition(boolean check, cElementalDefinitionStackMap aspects) throws tElementalException { - if (check && !canTheyBeTogether(aspects)) { - throw new tElementalException("Hadron Definition error"); - } - aspectStacks = aspects; - float mass = 0; - for (cElementalDefinitionStack stack : aspects.values()) { - mass += stack.getMass(); - } - this.mass = mass; - hash = super.hashCode(); - } - - //public but u can just try{}catch(){} the constructor it still calls this method - private static boolean canTheyBeTogether(cElementalDefinitionStackMap stacks) { - long amount = 0; - for (cElementalDefinitionStack aspects : stacks.values()) { - if (!(aspects.definition instanceof dComplexAspectDefinition) && !(aspects.definition instanceof ePrimalAspectDefinition)) { - return false; - } - if((int)aspects.amount!=aspects.amount){ - throw new ArithmeticException("Amount cannot be safely converted to int!"); - } - amount += aspects.amount; - } - return amount == 2; - } - - @Override - public String getName() { - String name = AspectDefinitionCompat.aspectDefinitionCompat.getAspectTag(this); - if (name != null) { - name = name.substring(0, 1).toUpperCase() + name.substring(1); - } else { - name = getSymbol(); - } - return translateToLocal("tt.keyword.Aspect") + ": " + name; - } - - @Override - public String getSymbol() { - StringBuilder symbol = new StringBuilder(8); - for (cElementalDefinitionStack aspect : aspectStacks.values()) { - if (aspect.definition instanceof ePrimalAspectDefinition) { - for (int i = 0; i < aspect.amount; i++) { - symbol.append(aspect.definition.getSymbol()); - } - } else { - symbol.append('('); - for (int i = 0; i < aspect.amount; i++) { - symbol.append(aspect.definition.getSymbol()); - } - symbol.append(')'); - } - } - return symbol.toString(); - } - - @Override - public String getShortSymbol() { - StringBuilder symbol = new StringBuilder(8); - for (cElementalDefinitionStack aspect : aspectStacks.values()) { - if (aspect.definition instanceof ePrimalAspectDefinition) { - for (int i = 0; i < aspect.amount; i++) { - symbol.append(aspect.definition.getShortSymbol()); - } - } else { - symbol.append('('); - for (int i = 0; i < aspect.amount; i++) { - symbol.append(aspect.definition.getShortSymbol()); - } - symbol.append(')'); - } - } - return symbol.toString(); - } - - @Override - public NBTTagCompound toNBT() { - return getNbtTagCompound(nbtType, aspectStacks); - } - - public static NBTTagCompound getNbtTagCompound(byte nbtType, cElementalDefinitionStackMap aspectStacks) { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setByte("t", nbtType); - cElementalDefinitionStack[] quarkStacksValues = aspectStacks.values(); - nbt.setInteger("i", quarkStacksValues.length); - for (int i = 0; i < quarkStacksValues.length; i++) { - nbt.setTag(Integer.toString(i), quarkStacksValues[i].toNBT()); - } - return nbt; - } - - public static dComplexAspectDefinition fromNBT(NBTTagCompound nbt) { - cElementalDefinitionStack[] stacks = new cElementalDefinitionStack[nbt.getInteger("i")]; - for (int i = 0; i < stacks.length; i++) { - stacks[i] = cElementalDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); - } - try { - return new dComplexAspectDefinition(stacks); - } catch (tElementalException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return null; - } - } - - @Override - public double getRawTimeSpan(long currentEnergy) { - return -1; - } - - @Override - public boolean isTimeSpanHalfLife() { - return false; - } - - @Override - public int getCharge() { - return 0; - } - - @Override - public byte getType() { - return 0; - } - - @Override - public byte getColor() { - return -1; - } - - @Override - public cElementalDefinitionStackMap getSubParticles() { - return aspectStacks; - } - - @Override - public cElementalDecay[] getEnergyInducedDecay(long energyLevel) { - return new cElementalDecay[]{new cElementalDecay(0.75F, aspectStacks), eBosonDefinition.deadEnd}; - } - - @Override - public double getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { - return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - currentEnergyLevel); - } - - @Override - public boolean usesSpecialEnergeticDecayHandling() { - return false; - } - - @Override - public boolean usesMultipleDecayCalls(long energyLevel) { - return false; - } - - @Override - public boolean decayMakesEnergy(long energyLevel) { - return false; - } - - @Override - public boolean fusionMakesEnergy(long energyLevel) { - return false; - } - - @Override - public cElementalDecay[] getNaturalDecayInstant() { - return noDecay; - } - - @Override - public cElementalDecay[] getDecayArray() { - return noDecay; - } - - @Override - public double getMass() { - return mass; - } - - @Override - public aFluidDequantizationInfo someAmountIntoFluidStack() { - return null; - } - - @Override - public aItemDequantizationInfo someAmountIntoItemsStack() { - return null; - } - - @Override - public aOredictDequantizationInfo someAmountIntoOredictStack() { - return null; - } - - @Override - public Object materializeIntoAspect() { - return AspectDefinitionCompat.aspectDefinitionCompat.getAspect(this); - } - - @Override - public iElementalDefinition getAnti() { - return null; - } - - public static void run() { - try { - cElementalDefinition.addCreatorFromNBT(nbtType, dComplexAspectDefinition.class.getMethod("fromNBT", NBTTagCompound.class), (byte) -96); - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - if (DEBUG_MODE) { - TecTech.LOGGER.info("Registered Elemental Matter Class: ComplexAspect " + nbtType + ' ' + -96); - } - } - - @Override - public byte getClassType() { - return -96; - } - - public static byte getClassTypeStatic() { - return -96; - } - - @Override - public int hashCode() { - return hash; - } - - @Override - public void addScanShortSymbols(ArrayList<String> lines, int capabilities, long energyLevel) { - if (Util.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS, capabilities)) { - lines.add(getShortSymbol()); - } - } - - @Override - public void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel) { - if (Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { - lines.add(translateToLocal("tt.keyword.CLASS") + " = " + nbtType + ' ' + getClassType()); - } - if (Util.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS, capabilities)) { - lines.add(translateToLocal("tt.keyword.NAME") + " = " + getName()); - //lines.add("SYMBOL = "+getSymbol()); - } - if (Util.areBitsSet(SCAN_GET_CHARGE, capabilities)) { - lines.add(translateToLocal("tt.keyword.CHARGE") + " = " + getCharge() / 3f + " e"); - } - if (Util.areBitsSet(SCAN_GET_COLOR, capabilities)) { - lines.add(getColor() < 0 ? translateToLocal("tt.keyword.COLORLESS") : translateToLocal("tt.keyphrase.CARRIES_COLOR")); - } - if (Util.areBitsSet(SCAN_GET_MASS, capabilities)) { - lines.add(translateToLocal("tt.keyword.MASS") + " = " + getMass() + " eV/c\u00b2"); - } - if (Util.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add(translateToLocal("tt.keyphrase.LIFE_TIME") + " = " + getRawTimeSpan(energyLevel) + " s"); - lines.add(" " + translateToLocal("tt.keyphrase.At_current_energy_level")); - } - } -} diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/ePrimalAspectDefinition.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/ePrimalAspectDefinition.java deleted file mode 100644 index 02e7d2fe21..0000000000 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/ePrimalAspectDefinition.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions; - -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalPrimitive; - -import static com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay.noDecay; -import static net.minecraft.util.StatCollector.translateToLocal; - -/** - * Created by Tec on 06.05.2017. - */ -public final class ePrimalAspectDefinition extends cElementalPrimitive implements iElementalAspect { - public static final ePrimalAspectDefinition - magic_air = new ePrimalAspectDefinition(translateToLocal("tt.keyword.Air"), "a`", 1e1D, 35), - magic_earth = new ePrimalAspectDefinition(translateToLocal("tt.keyword.Earth"), "e`", 1e9D, 34), - magic_fire = new ePrimalAspectDefinition(translateToLocal("tt.keyword.Fire"), "f`", 1e3D, 33), - magic_water = new ePrimalAspectDefinition(translateToLocal("tt.keyword.Water"), "w`", 1e7D, 32), - magic_order = new ePrimalAspectDefinition(translateToLocal("tt.keyword.Order"), "o`", 1e5D, 30), - magic_entropy = new ePrimalAspectDefinition(translateToLocal("tt.keyword.Entropy"), "e`", 1e5D, 31); - - private ePrimalAspectDefinition(String name, String symbol, double mass, int ID) { - super(name, symbol, 0, mass, 0, -1, ID); - } - - public static void run() { - magic_air.init(null, -1F, -1, -1, noDecay); - magic_earth.init(null, -1F, -1, -1, noDecay); - magic_fire.init(null, -1F, -1, -1, noDecay); - magic_water.init(null, -1F, -1, -1, noDecay); - magic_order.init(null, -1F, -1, -1, noDecay); - magic_entropy.init(null, -1F, -1, -1, noDecay); - } - - @Override - public String getName() { - return translateToLocal("tt.keyword.Primal") + ": " + name; - } - - @Override - public Object materializeIntoAspect() { - return AspectDefinitionCompat.aspectDefinitionCompat.getAspect(this); - } - - @Override - public boolean isTimeSpanHalfLife() { - return false; - } -}
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/iElementalAspect.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/iElementalAspect.java deleted file mode 100644 index 3cb2d8e5e8..0000000000 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/iElementalAspect.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions; - -/** - * Created by Tec on 21.05.2017. - */ -public interface iElementalAspect { - Object materializeIntoAspect(); -} diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/transformations/AspectDefinitionCompat.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/transformations/AspectDefinitionCompat.java new file mode 100644 index 0000000000..c1c6c6dcb2 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/transformations/AspectDefinitionCompat.java @@ -0,0 +1,38 @@ +package com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.transformations; + + +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; + +import java.util.HashMap; + +/** + * Created by Tec on 21.05.2017. + */ +public class AspectDefinitionCompat { + public static AspectDefinitionCompat aspectDefinitionCompat; + private final HashMap<IEMDefinition,String> defToAspect = new HashMap<>(); + private final HashMap<String, IEMDefinition> aspectToDef = new HashMap<>(); + + public void run(EMDefinitionsRegistry registry){} + + public String getAspectTag(IEMDefinition definition){ + return null; + } + + public String getAspectLocalizedName(IEMDefinition definition){ + return null; + } + + public IEMDefinition getDefinition(String aspect){ + return null; + } + + public HashMap<IEMDefinition, String> getDefToAspect() { + return defToAspect; + } + + public HashMap<String, IEMDefinition> getAspectToDef() { + return aspectToDef; + } +} diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/transformations/AspectDefinitionCompatEnabled.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/transformations/AspectDefinitionCompatEnabled.java new file mode 100644 index 0000000000..5b47414dc0 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/transformations/AspectDefinitionCompatEnabled.java @@ -0,0 +1,80 @@ +package com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.transformations; + +import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.EMComplexAspectDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import thaumcraft.api.aspects.Aspect; + +import java.util.ArrayList; + +import static com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.EMPrimalAspectDefinition.*; + +/** + * Created by Tec on 21.05.2017. + */ +public final class AspectDefinitionCompatEnabled extends AspectDefinitionCompat { + @Override + public void run(EMDefinitionsRegistry registry){ + getDefToAspect().put(magic_air,"aer"); + getDefToAspect().put(magic_earth,"terra"); + getDefToAspect().put(magic_fire,"ignis"); + getDefToAspect().put(magic_water,"aqua"); + getDefToAspect().put(magic_order,"ordo"); + getDefToAspect().put(magic_entropy,"perditio"); + + getAspectToDef().put("aer",magic_air); + getAspectToDef().put("terra",magic_earth); + getAspectToDef().put("ignis",magic_fire); + getAspectToDef().put("aqua",magic_water); + getAspectToDef().put("ordo",magic_order); + getAspectToDef().put("perditio",magic_entropy); + + ArrayList<Aspect> list=Aspect.getCompoundAspects(); + Aspect[] array= list.toArray(new Aspect[0]); + while (!list.isEmpty()) { + for (Aspect aspect : array) { + if (list.contains(aspect)) { + Aspect[] content = aspect.getComponents(); + if (content.length != 2) { + list.remove(aspect); + }else if(getAspectToDef().containsKey(content[0].getTag()) && getAspectToDef().containsKey(content[1].getTag())){ + try { + EMComplexAspectDefinition newAspect; + if(content[0].getTag().equals(content[1].getTag())){ + newAspect = new EMComplexAspectDefinition( + getAspectToDef().get(content[0].getTag()).getStackForm(2)); + }else{ + newAspect = new EMComplexAspectDefinition( + getAspectToDef().get(content[0].getTag()).getStackForm(1), + getAspectToDef().get(content[1].getTag()).getStackForm(1)); + } + getAspectToDef().put(aspect.getTag(),newAspect); + getDefToAspect().put(newAspect,aspect.getTag()); + registry.registerForDisplay(newAspect); + }catch (EMException e) { + /**/ + }finally { + list.remove(aspect); + } + } + } + } + } + } + + @Override + public String getAspectTag(IEMDefinition definition) { + return getDefToAspect().get(definition); + } + + public String getAspectLocalizedName(IEMDefinition definition){ + Aspect aspect = Aspect.aspects.get(getAspectTag(definition)); + return aspect != null ? aspect.getName() : null; + } + + @Override + public IEMDefinition getDefinition(String aspect) { + return getAspectToDef().get(aspect); + } +} diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/EssentiaCompat.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/EssentiaCompat.java index e77cab2734..a335b81793 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/EssentiaCompat.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/EssentiaCompat.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import net.minecraft.tileentity.TileEntity; @@ -10,19 +10,23 @@ import net.minecraft.tileentity.TileEntity; public class EssentiaCompat { public static EssentiaCompat essentiaContainerCompat; - public boolean check(GT_MetaTileEntity_MultiblockBase_EM meta){ + public <T extends GT_MetaTileEntity_MultiblockBase_EM> boolean check(T meta,TileEntity te){ return false; } - public TileEntity getContainer(GT_MetaTileEntity_MultiblockBase_EM meta){ + public <T extends GT_MetaTileEntity_MultiblockBase_EM> TileEntity getContainer(T meta){ return null; } - public boolean putElementalInstanceStack(TileEntity conatainer, cElementalInstanceStack stack){ + public String getEssentiaName(IEMDefinition stack){ + return null; + } + + public boolean putInContainer(TileEntity container, String name){ return false; } - public cElementalInstanceStack getFromContainer(TileEntity container){ + public IEMDefinition getFromContainer(TileEntity container){ return null; } } diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/EssentiaCompatEnabled.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/EssentiaCompatEnabled.java index 484377b179..bd20269944 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/EssentiaCompatEnabled.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/EssentiaCompatEnabled.java @@ -1,8 +1,6 @@ package com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi; -import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.iElementalAspect; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import net.minecraft.tileentity.TileEntity; import thaumcraft.api.aspects.Aspect; @@ -11,41 +9,46 @@ import thaumcraft.api.aspects.IAspectContainer; import thaumcraft.common.tiles.TileEssentiaReservoir; import thaumcraft.common.tiles.TileJarFillable; -import static com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.AspectDefinitionCompat.aspectToDef; +import static com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.transformations.AspectDefinitionCompat.aspectDefinitionCompat; /** * Created by Tec on 21.05.2017. */ public class EssentiaCompatEnabled extends EssentiaCompat { @Override - public boolean check(GT_MetaTileEntity_MultiblockBase_EM meta) { - TileEntity tile =meta.getBaseMetaTileEntity().getTileEntityAtSide(meta.getBaseMetaTileEntity().getBackFacing()); - return tile instanceof TileEssentiaReservoir || tile instanceof TileJarFillable; + public <T extends GT_MetaTileEntity_MultiblockBase_EM> boolean check(T meta,TileEntity te) { + return te instanceof TileEssentiaReservoir || te instanceof TileJarFillable; } @Override - public TileEntity getContainer(GT_MetaTileEntity_MultiblockBase_EM meta) { + public <T extends GT_MetaTileEntity_MultiblockBase_EM> TileEntity getContainer(T meta) { TileEntity tile =meta.getBaseMetaTileEntity().getTileEntityAtSide(meta.getBaseMetaTileEntity().getBackFacing()); return tile!=null && !tile.isInvalid() && tile instanceof TileEssentiaReservoir || tile instanceof TileJarFillable ?tile:null; } @Override - public boolean putElementalInstanceStack(TileEntity container,cElementalInstanceStack stack){ - if(container==null || container.isInvalid()) { + public String getEssentiaName(IEMDefinition stack) { + return aspectDefinitionCompat.getDefToAspect().get(stack); + } + + @Override + public boolean putInContainer(TileEntity container, String aspectName) { + if (container == null || container.isInvalid() || aspectName == null || aspectName.isEmpty()) { return false; } - if(container instanceof IAspectContainer && stack.definition instanceof iElementalAspect){ - Aspect aspect=(Aspect) ((iElementalAspect) stack.definition).materializeIntoAspect(); - if(aspect!=null){ - ((IAspectContainer) container).addToContainer(aspect,1); - return true; + if (container instanceof IAspectContainer) { + Aspect aspect = Aspect.getAspect(aspectName); + if(aspect==null){ + return false; } + int remaining=((IAspectContainer) container).addToContainer(aspect, 1); + return remaining==0; } return false; } @Override - public cElementalInstanceStack getFromContainer(TileEntity container){ + public IEMDefinition getFromContainer(TileEntity container){ if(container==null || container.isInvalid()) { return null; } @@ -55,10 +58,7 @@ public class EssentiaCompatEnabled extends EssentiaCompat { Aspect[] aspectsArr= aspects.getAspects(); if(aspectsArr!=null && aspectsArr[0]!=null){ if (((IAspectContainer) container).takeFromContainer(aspectsArr[0],1)){ - cElementalDefinition def=aspectToDef.get(aspectsArr[0].getTag()); - if(def!=null){ - return new cElementalInstanceStack(def,1); - } + return aspectDefinitionCompat.getAspectToDef().get(aspectsArr[0].getTag()); } } } diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java index 8e8aee4795..2a9f7ec6d2 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java @@ -1,33 +1,33 @@ package com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi; -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.ePrimalAspectDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; import com.github.technus.tectech.thing.block.QuantumGlassBlock; -import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_quantizer; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.util.CommonValues; +import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.block.material.Material; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.util.ForgeDirection; +import thaumcraft.api.aspects.Aspect; import static com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi.EssentiaCompat.essentiaContainerCompat; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_ITEM_DIMINISHED; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; import static com.github.technus.tectech.util.CommonValues.V; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofTileAdder; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; import static net.minecraft.util.StatCollector.translateToLocal; @@ -42,28 +42,30 @@ public class GT_MetaTileEntity_EM_essentiaDequantizer extends GT_MetaTileEntity_ EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", translateToLocal("gt.blockmachines.multimachine.em.emtoessentia.hint.0"),//1 - Classic Hatches or High Power Casing translateToLocal("gt.blockmachines.multimachine.em.emtoessentia.hint.1"),//2 - Elemental Input Hatch - translateToLocal("gt.blockmachines.multimachine.em.emtoessentia.hint.2"),//3 - Elemental Overflow Hatches or Molecular Casing + translateToLocal("gt.blockmachines.multimachine.em.emtoessentia.hint.2"),//3 - Elemental Overflow Hatches or Elemental Casing translateToLocal("gt.blockmachines.multimachine.em.emtoessentia.hint.3"),//General - Some sort of Essentia Storage }; private static final IStructureDefinition<GT_MetaTileEntity_EM_essentiaDequantizer> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_EM_essentiaDequantizer>builder() - .addShape("main", new String[][]{ - {"DDD", "D~D", "DDD"}, - {"E E", " ", "E E"}, - {"ABA", "BCB", "ABA"}, - {"FFF", "FBF", "FFF"}, - {"BEB", "EGE", "BEB"} - }) - .addElement('A', ofBlock(sBlockCasingsTT, 0)) - .addElement('B', ofBlock(sBlockCasingsTT, 4)) - .addElement('C', ofBlock(sBlockCasingsTT, 8)) - .addElement('D', ofHatchAdderOptional(GT_MetaTileEntity_EM_essentiaDequantizer::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) - .addElement('E', ofBlock(QuantumGlassBlock.INSTANCE, 0)) - .addElement('F', ofHatchAdderOptional(GT_MetaTileEntity_EM_essentiaDequantizer::addElementalMufflerToMachineList, textureOffset + 4, 3, sBlockCasingsTT, 4)) - .addElement('G', ofHatchAdder(GT_MetaTileEntity_EM_essentiaDequantizer::addElementalInputToMachineList, textureOffset + 4, 2)) - .build(); + IStructureDefinition.<GT_MetaTileEntity_EM_essentiaDequantizer>builder() + .addShape("main", new String[][]{ + {"DDD", "D~D", "DDD"}, + {"E E", " * ", "E E"}, + {"ABA", "BCB", "ABA"}, + {"FFF", "FBF", "FFF"}, + {"BEB", "EGE", "BEB"} + }) + .addElement('A', ofBlock(sBlockCasingsTT, 0)) + .addElement('B', ofBlock(sBlockCasingsTT, 4)) + .addElement('C', ofBlock(sBlockCasingsTT, 8)) + .addElement('D', ofHatchAdderOptional(GT_MetaTileEntity_EM_essentiaDequantizer::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) + .addElement('E', ofBlock(QuantumGlassBlock.INSTANCE, 0)) + .addElement('F', ofHatchAdderOptional(GT_MetaTileEntity_EM_essentiaDequantizer::addElementalMufflerToMachineList, textureOffset + 4, 3, sBlockCasingsTT, 4)) + .addElement('G', ofHatchAdder(GT_MetaTileEntity_EM_essentiaDequantizer::addElementalInputToMachineList, textureOffset + 4, 2)) + .addElement('*', ofTileAdder(essentiaContainerCompat::check, StructureLibAPI.getBlockHint(),12)) + .build(); + private String outputEssentiaName= ""; //endregion public GT_MetaTileEntity_EM_essentiaDequantizer(int aID, String aName, String aNameRegional) { @@ -81,7 +83,7 @@ public class GT_MetaTileEntity_EM_essentiaDequantizer extends GT_MetaTileEntity_ @Override public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - return essentiaContainerCompat.check(this) && structureCheck_EM("main", 1, 1, 0); + return structureCheck_EM("main", 1, 1, 0); } @Override @@ -91,24 +93,49 @@ public class GT_MetaTileEntity_EM_essentiaDequantizer extends GT_MetaTileEntity_ stopMachine(); return false; } - cElementalInstanceStackMap inputHatchContainer = eInputHatches.get(0).getContainerHandler(); - if (inputHatchContainer.hasStacks()) { - cElementalInstanceStack stack = inputHatchContainer.getFirst(); - inputHatchContainer.removeAmount(false, new cElementalInstanceStack(stack.definition, 1)); - if (!essentiaContainerCompat.putElementalInstanceStack(container, stack)) { - cleanStackEM_EM(stack); - } - mMaxProgresstime = 20; - mEfficiencyIncrease = 10000; - eAmpereFlow = 1; - if (stack.definition instanceof ePrimalAspectDefinition) { - mEUt = (int) -V[8]; + + EMInstanceStackMap inputHatchContainer = eInputHatches.get(0).getContentHandler(); + if (inputHatchContainer == null || !inputHatchContainer.hasStacks()) { + return false; + } + + EMInstanceStack stack = inputHatchContainer.getRandom(); + if (stack.getAmount() < EM_COUNT_PER_ITEM_DIMINISHED) { + cleanStackEM_EM(inputHatchContainer.removeKey(stack.getDefinition())); + mEUt = (int) -V[6]; + } else { + outputEssentiaName = essentiaContainerCompat.getEssentiaName(stack.getDefinition()); + Aspect aspect = Aspect.getAspect(outputEssentiaName); + if (aspect == null) { + outputEssentiaName = ""; + cleanStackEM_EM(inputHatchContainer.removeKey(stack.getDefinition())); + mEUt = (int) -V[7]; } else { - mEUt = (int) -V[10]; + inputHatchContainer.removeAmount(stack.getDefinition().getStackForm(EM_COUNT_PER_MATERIAL_AMOUNT)); + if (aspect.isPrimal()) { + mEUt = (int) -V[8]; + } else { + mEUt = (int) -V[10]; + } + } + } + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + eAmpereFlow = 1; + return true; + } + + @Override + public void outputAfterRecipe_EM() { + TileEntity container = essentiaContainerCompat.getContainer(this); + if (container == null) { + stopMachine(); + }else{ + if(!essentiaContainerCompat.putInContainer(container,outputEssentiaName)){ + stopMachine(); } - return true; } - return false; + outputEssentiaName = ""; } @Override @@ -128,31 +155,28 @@ public class GT_MetaTileEntity_EM_essentiaDequantizer extends GT_MetaTileEntity_ @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - IGregTechTileEntity iGregTechTileEntity = getBaseMetaTileEntity(); - int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX; - int yDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetY; - int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ; - if (hintsOnly) { - TecTech.proxy.hint_particle(iGregTechTileEntity.getWorld(), - iGregTechTileEntity.getXCoord() + xDir, - iGregTechTileEntity.getYCoord() + yDir, - iGregTechTileEntity.getZCoord() + zDir, - TT_Container_Casings.sHintCasingsTT, 12); - } else { - if (iGregTechTileEntity.getBlockOffset(xDir, 0, zDir).getMaterial() == Material.air) { - iGregTechTileEntity.getWorld().setBlock(iGregTechTileEntity.getXCoord() + xDir, iGregTechTileEntity.getYCoord() + yDir, iGregTechTileEntity.getZCoord() + zDir, TT_Container_Casings.sHintCasingsTT, 12, 2); - } - } - structureBuild_EM("main", 1, 1, 0, hintsOnly, stackSize); + structureBuild_EM("main", 1, 1, 0, stackSize, hintsOnly); } @Override - public IStructureDefinition<GT_MetaTileEntity_EM_essentiaDequantizer> getStructure_EM() { - return STRUCTURE_DEFINITION; + public String[] getStructureDescription(ItemStack stackSize) { + return description; } @Override - public String[] getStructureDescription(ItemStack stackSize) { - return description; + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setString("eOutputEssentia", outputEssentiaName); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + outputEssentiaName = aNBT.getString("eOutputEssentia"); + } + + @Override + public IStructureDefinition<? extends GT_MetaTileEntity_MultiblockBase_EM> getStructure_EM() { + return STRUCTURE_DEFINITION; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java index 1e23408a0b..befc9ac77e 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java @@ -1,33 +1,31 @@ package com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi; -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.ePrimalAspectDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; +import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.EMPrimalAspectDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; import com.github.technus.tectech.thing.block.QuantumGlassBlock; -import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_quantizer; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.util.CommonValues; +import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.block.material.Material; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.util.ForgeDirection; import static com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi.EssentiaCompat.essentiaContainerCompat; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; import static com.github.technus.tectech.util.CommonValues.V; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofTileAdder; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; import static net.minecraft.util.StatCollector.translateToLocal; @@ -42,15 +40,15 @@ public class GT_MetaTileEntity_EM_essentiaQuantizer extends GT_MetaTileEntity_Mu EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", translateToLocal("gt.blockmachines.multimachine.em.essentiatoem.hint.0"),//1 - Classic Hatches or High Power Casing translateToLocal("gt.blockmachines.multimachine.em.essentiatoem.hint.1"),//2 - Elemental Output Hatch - translateToLocal("gt.blockmachines.multimachine.em.essentiatoem.hint.2"),//3 - Elemental Overflow Hatches or Molecular Casing + translateToLocal("gt.blockmachines.multimachine.em.essentiatoem.hint.2"),//3 - Elemental Overflow Hatches or Elemental Casing translateToLocal("gt.blockmachines.multimachine.em.essentiatoem.hint.3"),//General - Some sort of Essentia Storage }; private static final IStructureDefinition<GT_MetaTileEntity_EM_essentiaQuantizer> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_EM_essentiaQuantizer>builder() + IStructureDefinition.<GT_MetaTileEntity_EM_essentiaQuantizer>builder() .addShape("main", new String[][]{ {"FFF", "F~F", "FFF"}, - {"E E", " ", "E E"}, + {"E E", " * ", "E E"}, {"BAB", "ACA", "BAB"}, {"DDD", "DBD", "DDD"}, {"EBE", "BGB", "EBE"} @@ -62,6 +60,7 @@ public class GT_MetaTileEntity_EM_essentiaQuantizer extends GT_MetaTileEntity_Mu .addElement('E', ofBlock(QuantumGlassBlock.INSTANCE, 0)) .addElement('F', ofHatchAdderOptional(GT_MetaTileEntity_EM_essentiaQuantizer::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) .addElement('G', ofHatchAdder(GT_MetaTileEntity_EM_essentiaQuantizer::addElementalOutputToMachineList, textureOffset + 4, 2)) + .addElement('*', ofTileAdder(essentiaContainerCompat::check, StructureLibAPI.getBlockHint(),12)) .build(); //endregion @@ -80,21 +79,20 @@ public class GT_MetaTileEntity_EM_essentiaQuantizer extends GT_MetaTileEntity_Mu @Override public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - return essentiaContainerCompat.check(this) && structureCheck_EM("main", 1, 1, 0); + return structureCheck_EM("main", 1, 1, 0); } @Override public boolean checkRecipe_EM(ItemStack itemStack) { - TileEntity container = essentiaContainerCompat.getContainer(this); - cElementalInstanceStack newStack = essentiaContainerCompat.getFromContainer(container); - if (newStack != null) { + IEMDefinition definition = essentiaContainerCompat.getFromContainer(essentiaContainerCompat.getContainer(this)); + if (definition != null) { mMaxProgresstime = 20; mEfficiencyIncrease = 10000; eAmpereFlow = 1; - outputEM = new cElementalInstanceStackMap[]{ - new cElementalInstanceStackMap(newStack) + outputEM = new EMInstanceStackMap[]{ + new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_MATERIAL_AMOUNT)) }; - if (newStack.definition instanceof ePrimalAspectDefinition) { + if (definition instanceof EMPrimalAspectDefinition) { mEUt = (int) -V[8]; } else { mEUt = (int) -V[10]; @@ -110,7 +108,7 @@ public class GT_MetaTileEntity_EM_essentiaQuantizer extends GT_MetaTileEntity_Mu stopMachine(); return; } - eOutputHatches.get(0).getContainerHandler().putUnifyAll(outputEM[0]); + eOutputHatches.get(0).getContentHandler().putUnifyAll(outputEM[0]); outputEM = null; } @@ -131,22 +129,7 @@ public class GT_MetaTileEntity_EM_essentiaQuantizer extends GT_MetaTileEntity_Mu @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - IGregTechTileEntity iGregTechTileEntity = getBaseMetaTileEntity(); - int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX; - int yDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetY; - int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ; - if (hintsOnly) { - TecTech.proxy.hint_particle(iGregTechTileEntity.getWorld(), - iGregTechTileEntity.getXCoord() + xDir, - iGregTechTileEntity.getYCoord() + yDir, - iGregTechTileEntity.getZCoord() + zDir, - TT_Container_Casings.sHintCasingsTT, 12); - } else { - if (iGregTechTileEntity.getBlockOffset(xDir, 0, zDir).getMaterial() == Material.air) { - iGregTechTileEntity.getWorld().setBlock(iGregTechTileEntity.getXCoord() + xDir, iGregTechTileEntity.getYCoord() + yDir, iGregTechTileEntity.getZCoord() + zDir, TT_Container_Casings.sHintCasingsTT, 12, 2); - } - } - structureBuild_EM("main", 1, 1, 0, hintsOnly, stackSize); + structureBuild_EM("main", 1, 1, 0, stackSize, hintsOnly); } @Override @@ -158,4 +141,4 @@ public class GT_MetaTileEntity_EM_essentiaQuantizer extends GT_MetaTileEntity_Mu public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/entity/fx/BlockHint.java b/src/main/java/com/github/technus/tectech/entity/fx/BlockHint.java deleted file mode 100644 index 3c7f18ff32..0000000000 --- a/src/main/java/com/github/technus/tectech/entity/fx/BlockHint.java +++ /dev/null @@ -1,134 +0,0 @@ -package com.github.technus.tectech.entity.fx; - -import com.github.technus.tectech.TecTech; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.enums.Dyes; -import net.minecraft.block.Block; -import net.minecraft.client.particle.EntityFX; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.init.Blocks; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import org.lwjgl.opengl.GL11; - -@SideOnly(Side.CLIENT) -@Deprecated -public class BlockHint extends EntityFX { - private IIcon[] icons = new IIcon[6]; - private short[] mRGBa = Dyes._NULL.mRGBa; - - public BlockHint(World world){ - this(world,0,0,0, Blocks.stone,0); - } - - /** - * - * @param world - * @param x - * @param y - * @param z - * @param icons DOWN, UP, NORTH, SOUTH, WEST, EAST - */ - public BlockHint(World world, int x, int y, int z, IIcon[] icons) { - super(world, x + .25, y + .5, z + .25); - particleGravity = 0; - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - noClip = true; - particleMaxAge = 2000 + TecTech.RANDOM.nextInt(200); - this.icons=icons; - } - - public BlockHint(World world, int x, int y, int z, Block block, int meta) { - super(world, x+.25, y+.5, z+.25); - particleGravity = 0; - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - noClip = true; - particleMaxAge = 2000 + TecTech.RANDOM.nextInt(200); - for (int i = 0; i < 6; i++) { - icons[i] = block.getIcon(i, meta); - } - } - - public BlockHint withColorTint(short[] coloure){ - this.mRGBa =coloure; - return this; - } - - @Override - public void renderParticle(Tessellator tes, float subTickTime, float p_70539_3_, float p_70539_4_, float p_70539_5_, float p_70539_6_, float p_70539_7_) { - float size = .5f; - float X = (float) (prevPosX + (posX - prevPosX) * (double) subTickTime - EntityFX.interpPosX); - float Y = (float) (prevPosY + (posY - prevPosY) * (double) subTickTime - EntityFX.interpPosY) - size / 2; - float Z = (float) (prevPosZ + (posZ - prevPosZ) * (double) subTickTime - EntityFX.interpPosZ); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glDepthMask(false); - tes.setColorRGBA((int) (mRGBa[0] * .9F), (int) (mRGBa[1] * .95F), (int) (mRGBa[2] * 1F), 192); - - //var8, var9 - X U - //var 10, var 11 - Y V - for(int i=0;i<6;i++){ - if(icons[i]==null) { - continue; - } - double u=icons[i].getMinU(); - double U=icons[i].getMaxU(); - double v=icons[i].getMinV(); - double V=icons[i].getMaxV(); - switch (i){//{DOWN, UP, NORTH, SOUTH, WEST, EAST} - case 0: - tes.addVertexWithUV(X, Y, Z + size, u, V); - tes.addVertexWithUV(X, Y, Z, u, v); - tes.addVertexWithUV(X + size, Y, Z, U, v); - tes.addVertexWithUV(X + size, Y, Z + size, U, V); - break; - case 1: - tes.addVertexWithUV(X, Y + size, Z, u, v); - tes.addVertexWithUV(X, Y + size, Z + size, u, V); - tes.addVertexWithUV(X + size, Y + size, Z + size, U, V); - tes.addVertexWithUV(X + size, Y + size, Z, U, v); - break; - case 2: - tes.addVertexWithUV(X, Y, Z, U, V); - tes.addVertexWithUV(X, Y + size, Z, U, v); - tes.addVertexWithUV(X + size, Y + size, Z, u, v); - tes.addVertexWithUV(X + size, Y, Z, u, V); - break; - case 3: - tes.addVertexWithUV(X + size, Y, Z + size, U, V); - tes.addVertexWithUV(X + size, Y + size, Z + size, U, v); - tes.addVertexWithUV(X, Y + size, Z + size, u, v); - tes.addVertexWithUV(X, Y, Z + size, u, V); - break; - case 4: - tes.addVertexWithUV(X, Y, Z + size, U, V); - tes.addVertexWithUV(X, Y + size, Z + size, U, v); - tes.addVertexWithUV(X, Y + size, Z, u, v); - tes.addVertexWithUV(X, Y, Z, u, V); - break; - case 5: - tes.addVertexWithUV(X + size, Y, Z, U, V); - tes.addVertexWithUV(X + size, Y + size, Z, U, v); - tes.addVertexWithUV(X + size, Y + size, Z + size, u, v); - tes.addVertexWithUV(X + size, Y, Z + size, u, V); - break; - } - } - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glDepthMask(true); - } - - @Override - public int getFXLayer() { - return 1; - } - - @Override - public boolean shouldRenderInPass(int pass) { - return pass==2; - } -} diff --git a/src/main/java/com/github/technus/tectech/entity/fx/WeightlessParticleFX.java b/src/main/java/com/github/technus/tectech/entity/fx/WeightlessParticleFX.java deleted file mode 100644 index 92fa34990e..0000000000 --- a/src/main/java/com/github/technus/tectech/entity/fx/WeightlessParticleFX.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.github.technus.tectech.entity.fx; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.particle.EntityFX; -import net.minecraft.world.World; - -@SideOnly(Side.CLIENT) -@Deprecated -public class WeightlessParticleFX extends EntityFX -{ - public WeightlessParticleFX(World p_i1205_1_, double p_i1205_2_, double p_i1205_4_, double p_i1205_6_, double p_i1205_8_, double p_i1205_10_, double p_i1205_12_) - { - super(p_i1205_1_, p_i1205_2_, p_i1205_4_, p_i1205_6_, p_i1205_8_, p_i1205_10_, p_i1205_12_); - this.motionX = p_i1205_8_ + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.05F); - this.motionY = p_i1205_10_ + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.05F); - this.motionZ = p_i1205_12_ + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.05F); - this.particleRed = this.particleGreen = this.particleBlue = this.rand.nextFloat() * 0.3F + 0.7F; - this.particleScale = this.rand.nextFloat() * this.rand.nextFloat() * 6.0F + 1.0F; - this.particleMaxAge = (int)(16.0D / ((double)this.rand.nextFloat() * 0.8D + 0.2D)) + 2; - this.noClip=true; - } - - /** - * Called to update the entity's position/logic. - */ - public void onUpdate() - { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - - if (this.particleAge++ >= this.particleMaxAge) - { - this.setDead(); - } - - this.setParticleTextureIndex(7 - this.particleAge * 8 / this.particleMaxAge); - //this.motionY += 0.004D; - this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionX *= 0.8999999761581421D; - this.motionY *= 0.8999999761581421D; - this.motionZ *= 0.8999999761581421D; - } -} diff --git a/src/main/java/com/github/technus/tectech/font/TecTechFontRender.java b/src/main/java/com/github/technus/tectech/font/TecTechFontRender.java index 4aea8bce92..60c3df47f9 100644 --- a/src/main/java/com/github/technus/tectech/font/TecTechFontRender.java +++ b/src/main/java/com/github/technus/tectech/font/TecTechFontRender.java @@ -1,85 +1,226 @@ package com.github.technus.tectech.font; +import com.ibm.icu.text.ArabicShaping; +import com.ibm.icu.text.ArabicShapingException; +import com.ibm.icu.text.Bidi; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.settings.GameSettings; +import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; +import java.io.IOException; +import java.io.InputStream; @SideOnly(Side.CLIENT) public class TecTechFontRender extends FontRenderer { public static final TecTechFontRender INSTANCE = new TecTechFontRender(); - private static float DISTANCE_L = .125F; - private static float DISTANCE_L2 = DISTANCE_L *2F; + private static final float DISTANCE_L = .125F; + private static final float DISTANCE_L2 = DISTANCE_L * 2F; - private static float DISTANCE_M = 0.06F; - private static float DISTANCE_M2 = DISTANCE_M *2F; + private static final float DISTANCE_M = 0.06F; + private static final float DISTANCE_M2 = DISTANCE_M * 2F; - private static float DISTANCE_A = 0.06F; - private static float DISTANCE_A2 = DISTANCE_A *2F; + private static final float DISTANCE_A = 0.06F; + private static final float DISTANCE_A2 = DISTANCE_A * 2F; - private static final Method reset; - private static final Method render; - private final GameSettings gameSettings; + private TecTechFontRender() { + super(Minecraft.getMinecraft().gameSettings, new ResourceLocation("textures/font/ascii.png"), Minecraft.getMinecraft().renderEngine, false); + } - static { - Method resetMethod,renderMethod; - try { - resetMethod =FontRenderer.class.getDeclaredMethod("resetStyles"); - renderMethod=FontRenderer.class.getDeclaredMethod("renderString", String.class, int.class, int.class, int.class, boolean.class); - } catch (NoSuchMethodException e) { - try { - resetMethod =FontRenderer.class.getDeclaredMethod("func_78265_b"); - renderMethod=FontRenderer.class.getDeclaredMethod("func_78258_a", String.class, int.class, int.class, int.class, boolean.class); - } catch (NoSuchMethodException ex) { - throw new RuntimeException("Cannot get methods!",ex); + private void resetStyles() { + this.randomStyle = false; + this.boldStyle = false; + this.italicStyle = false; + this.underlineStyle = false; + this.strikethroughStyle = false; + } + + private int renderString(String p_78258_1_, int p_78258_2_, int p_78258_3_, int p_78258_4_, boolean p_78258_5_) { + if (p_78258_1_ == null) { + return 0; + } else { + if (this.bidiFlag) { + p_78258_1_ = this.bidiReorder(p_78258_1_); + } + + if ((p_78258_4_ & -67108864) == 0) { + p_78258_4_ |= -16777216; } + + if (p_78258_5_) { + p_78258_4_ = (p_78258_4_ & 16579836) >> 2 | p_78258_4_ & -16777216; + } + + this.red = (float) (p_78258_4_ >> 16 & 255) / 255.0F; + this.blue = (float) (p_78258_4_ >> 8 & 255) / 255.0F; + this.green = (float) (p_78258_4_ & 255) / 255.0F; + this.alpha = (float) (p_78258_4_ >> 24 & 255) / 255.0F; + this.setColor(this.red, this.blue, this.green, this.alpha); + this.posX = (float) p_78258_2_; + this.posY = (float) p_78258_3_; + this.renderStringAtPos(p_78258_1_, p_78258_5_); + return (int) this.posX; } - resetMethod.setAccessible(true); - renderMethod.setAccessible(true); - reset=resetMethod; - render=renderMethod; } - private TecTechFontRender() { - super(Minecraft.getMinecraft().gameSettings, new ResourceLocation("textures/font/ascii.png"), Minecraft.getMinecraft().renderEngine, false); - gameSettings = Minecraft.getMinecraft().gameSettings; + private String bidiReorder(String p_147647_1_) { + try { + Bidi bidi = new Bidi((new ArabicShaping(8)).shape(p_147647_1_), 127); + bidi.setReorderingMode(0); + return bidi.writeReordered(2); + } catch (ArabicShapingException var3) { + return p_147647_1_; + } } - private void resetStyles2(){ - try { - reset.invoke(this); - } catch (IllegalAccessException | InvocationTargetException e) { - throw new RuntimeException("Cannot run method resetStyles!",e); + private void renderStringAtPos(String p_78255_1_, boolean p_78255_2_) { + for (int i = 0; i < p_78255_1_.length(); ++i) { + char c0 = p_78255_1_.charAt(i); + int j; + int k; + if (c0 == 167 && i + 1 < p_78255_1_.length()) { + j = "0123456789abcdefklmnor".indexOf(p_78255_1_.toLowerCase().charAt(i + 1)); + if (j < 16) { + this.randomStyle = false; + this.boldStyle = false; + this.strikethroughStyle = false; + this.underlineStyle = false; + this.italicStyle = false; + if (j < 0 || j > 15) { + j = 15; + } + + if (p_78255_2_) { + j += 16; + } + + k = this.colorCode[j]; + this.textColor = k; + this.setColor((float) (k >> 16) / 255.0F, (float) (k >> 8 & 255) / 255.0F, (float) (k & 255) / 255.0F, this.alpha); + } else if (j == 16) { + this.randomStyle = true; + } else if (j == 17) { + this.boldStyle = true; + } else if (j == 18) { + this.strikethroughStyle = true; + } else if (j == 19) { + this.underlineStyle = true; + } else if (j == 20) { + this.italicStyle = true; + } else if (j == 21) { + this.randomStyle = false; + this.boldStyle = false; + this.strikethroughStyle = false; + this.underlineStyle = false; + this.italicStyle = false; + this.setColor(this.red, this.blue, this.green, this.alpha); + } + + ++i; + } else { + j = "\u00C0\u00C1\u00C2\u00C8\u00CA\u00CB\u00CD\u00D3\u00D4\u00D5\u00DA\u00DF\u00E3\u00F5\u011F\u0130\u0131\u0152\u0153\u015E\u015F\u0174\u0175\u017E\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9\u00FF\u00D6\u00DC\u00F8\u00A3\u00D8\u00D7\u0192\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u00AE\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u03B2\u0393\u03C0\u03A3\u03C3\u03BC\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u2205\u2208\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u0000".indexOf(c0); + if (this.randomStyle && j != -1) { + do { + k = this.fontRandom.nextInt(this.charWidth.length); + } while (this.charWidth[j] != this.charWidth[k]); + + j = k; + } + + float f1 = this.unicodeFlag ? 0.5F : 1.0F; + boolean flag1 = (c0 == 0 || j == -1 || this.unicodeFlag) && p_78255_2_; + if (flag1) { + this.posX -= f1; + this.posY -= f1; + } + + float f = this.renderCharAtPos(j, c0, this.italicStyle); + if (flag1) { + this.posX += f1; + this.posY += f1; + } + + if (this.boldStyle) { + this.posX += f1; + if (flag1) { + this.posX -= f1; + this.posY -= f1; + } + + this.renderCharAtPos(j, c0, this.italicStyle); + this.posX -= f1; + if (flag1) { + this.posX += f1; + this.posY += f1; + } + + ++f; + } + + this.doDraw(f); + } } + } - private int renderString2(String str, int x, int y, int color, boolean dropShadow){ - try { - return (int)render.invoke(this,str,x,y,color,dropShadow); - } catch (IllegalAccessException | InvocationTargetException e) { - throw new RuntimeException("Cannot run method renderString!",e); + @Override + protected void doDraw(float f) { + Tessellator tessellator = Tessellator.instance; + + if (this.strikethroughStyle) { + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + tessellator.addVertex(this.posX, this.posY + (float) (this.FONT_HEIGHT / 2), 0.0D); + tessellator.addVertex(this.posX + f, this.posY + (float) (this.FONT_HEIGHT / 2), 0.0D); + tessellator.addVertex(this.posX + f, this.posY + (float) (this.FONT_HEIGHT / 2) - 1.0F, 0.0D); + tessellator.addVertex(this.posX, this.posY + (float) (this.FONT_HEIGHT / 2) - 1.0F, 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + if (this.underlineStyle) { + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + int l = this.underlineStyle ? -1 : 0; + tessellator.addVertex(this.posX + (float) l, this.posY + (float) this.FONT_HEIGHT, 0.0D); + tessellator.addVertex(this.posX + f, this.posY + (float) this.FONT_HEIGHT, 0.0D); + tessellator.addVertex(this.posX + f, this.posY + (float) this.FONT_HEIGHT - 1.0F, 0.0D); + tessellator.addVertex(this.posX + (float) l, this.posY + (float) this.FONT_HEIGHT - 1.0F, 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); } + + this.posX += (float) ((int) f); + } + + private float renderCharAtPos(int p_78278_1_, char p_78278_2_, boolean p_78278_3_) { + return p_78278_2_ == ' ' ? 4.0F : ("\u00C0\u00C1\u00C2\u00C8\u00CA\u00CB\u00CD\u00D3\u00D4\u00D5\u00DA\u00DF\u00E3\u00F5\u011F\u0130\u0131\u0152\u0153\u015E\u015F\u0174\u0175\u017E\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9\u00FF\u00D6\u00DC\u00F8\u00A3\u00D8\u00D7\u0192\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u00AE\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u03B2\u0393\u03C0\u03A3\u03C3\u03BC\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u2205\u2208\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u0000".indexOf(p_78278_2_) != -1 && !this.unicodeFlag ? this.renderDefaultChar(p_78278_1_, p_78278_3_) : this.renderUnicodeChar(p_78278_2_, p_78278_3_)); + } + + @Override + protected float renderDefaultChar(int p_78266_1_, boolean p_78266_2_) { + return super.renderDefaultChar(p_78266_1_, p_78266_2_); } + @Override + protected float renderUnicodeChar(char p_78277_1_, boolean p_78277_2_) { + return super.renderUnicodeChar(p_78277_1_, p_78277_2_); + } @Override public int drawString(String str, int x, int y, int color, boolean dropShadow) { - switch (gameSettings.guiScale){ + switch (Minecraft.getMinecraft().gameSettings.guiScale) { case 0: setUnicodeFlag(true); y--; GL11.glPushMatrix(); - if (dropShadow) - { + if (dropShadow) { GL11.glTranslatef(DISTANCE_A, DISTANCE_A, 0F); drawStringBack(str, x, y, color); GL11.glTranslatef(-DISTANCE_A2, 0, 0F); @@ -106,8 +247,7 @@ public class TecTechFontRender extends FontRenderer { y--; GL11.glPushMatrix(); - if (dropShadow) - { + if (dropShadow) { GL11.glTranslatef(DISTANCE_M, DISTANCE_M, 0F); drawStringBack(str, x, y, color); GL11.glTranslatef(-DISTANCE_M2, 0, 0F); @@ -132,8 +272,7 @@ public class TecTechFontRender extends FontRenderer { y--; GL11.glPushMatrix(); - if (dropShadow) - { + if (dropShadow) { GL11.glTranslatef(DISTANCE_L, DISTANCE_L, 0F); drawStringBack(str, x, y, color); GL11.glTranslatef(-DISTANCE_L2, 0, 0F); @@ -159,7 +298,7 @@ public class TecTechFontRender extends FontRenderer { @Override public void drawSplitString(String str, int x, int y, int maxWidth, int color) { - switch (gameSettings.guiScale){ + switch (Minecraft.getMinecraft().gameSettings.guiScale) { case 0: setUnicodeFlag(true); y--; @@ -211,52 +350,62 @@ public class TecTechFontRender extends FontRenderer { } } + @Override + protected void setColor(float r, float g, float b, float a) { + super.setColor(r, g, b, a); + } + + @Override + protected void enableAlpha() { + super.enableAlpha(); + } + + @Override + protected void bindTexture(ResourceLocation location) { + super.bindTexture(location); + } + + @Override + protected InputStream getResourceInputStream(ResourceLocation location) throws IOException { + return super.getResourceInputStream(location); + } + private int drawStringFront(String p_85187_1_, int p_85187_2_, int p_85187_3_, int p_85187_4_) { GL11.glEnable(3008); - resetStyles2(); - return renderString2(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false); + resetStyles(); + return renderString(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false); } private int drawStringBack(String p_85187_1_, int p_85187_2_, int p_85187_3_, int p_85187_4_) { GL11.glEnable(3008); - resetStyles2(); - return renderString2(p_85187_1_, p_85187_2_ + 1, p_85187_3_ + 1, p_85187_4_, true); + resetStyles(); + return renderString(p_85187_1_, p_85187_2_ + 1, p_85187_3_ + 1, p_85187_4_, true); } @Override - public int getStringWidth(String p_78256_1_) - { - if(gameSettings.guiScale==1){ + public int getStringWidth(String p_78256_1_) { + if (Minecraft.getMinecraft().gameSettings.guiScale == 1) { return Minecraft.getMinecraft().fontRenderer.getStringWidth(p_78256_1_); } - if (p_78256_1_ == null) - { + if (p_78256_1_ == null) { return 0; - } - else - { - int i = 0; + } else { + int i = 0; boolean flag = false; - for (int j = 0; j < p_78256_1_.length(); ++j) - { + for (int j = 0; j < p_78256_1_.length(); ++j) { char c0 = p_78256_1_.charAt(j); - int k = this.getCharWidth(c0); + int k = this.getCharWidth(c0); - if (k < 0 && j < p_78256_1_.length() - 1) - { + if (k < 0 && j < p_78256_1_.length() - 1) { ++j; c0 = p_78256_1_.charAt(j); - if (c0 != 108 && c0 != 76) - { - if (c0 == 114 || c0 == 82) - { + if (c0 != 108 && c0 != 76) { + if (c0 == 114 || c0 == 82) { flag = false; } - } - else - { + } else { flag = true; } @@ -265,8 +414,7 @@ public class TecTechFontRender extends FontRenderer { i += k; - if (flag && k > 0) - { + if (flag && k > 0) { ++i; } } @@ -274,4 +422,6 @@ public class TecTechFontRender extends FontRenderer { return i; } } + + } diff --git a/src/main/java/com/github/technus/tectech/loader/ConstructableLoader.java b/src/main/java/com/github/technus/tectech/loader/ConstructableLoader.java deleted file mode 100644 index dc282ec0b6..0000000000 --- a/src/main/java/com/github/technus/tectech/loader/ConstructableLoader.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.github.technus.tectech.loader; - -import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; -import com.github.technus.tectech.mechanics.constructable.IMultiblockInfoContainer; -import com.github.technus.tectech.mechanics.structure.IStructureDefinition; -import com.github.technus.tectech.mechanics.structure.StructureDefinition; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_ElectricBlastFurnace; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; - -import static com.github.technus.tectech.mechanics.constructable.IMultiblockInfoContainer.registerMetaClass; -import static com.github.technus.tectech.mechanics.structure.StructureUtility.ofBlock; -import static com.github.technus.tectech.mechanics.structure.StructureUtility.ofHint; -import static gregtech.api.GregTech_API.sBlockCasings1; - -public class ConstructableLoader implements Runnable { - - @Override - public void run() { - registerMetaClass(GT_MetaTileEntity_ElectricBlastFurnace.class, new IMultiblockInfoContainer<GT_MetaTileEntity_ElectricBlastFurnace>() { - //region Structure - private final IStructureDefinition<GT_MetaTileEntity_ElectricBlastFurnace> definition= - StructureDefinition.<GT_MetaTileEntity_ElectricBlastFurnace>builder() - .addShapeOldApi("main",new String[][]{ - {"000","\"\"\"","\"\"\""," . ",}, - {"0!0","\"A\"","\"A\""," ",}, - {"000","\"\"\"","\"\"\""," ",}, - }) - .addElement('0', ofBlock(sBlockCasings1,11)) - .addElement('\"', ofHint(3)) - .addElement('!', ofHint(2)) - .addElement(' ', ofHint(1)) - .build(); - private final String[] desc=new String[]{ - EnumChatFormatting.AQUA+"Hint Details:", - "1 - Classic Hatches or Heat Proof Casing", - "2 - Muffler Hatch", - "3 - Coil blocks" - }; - //endregion - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly, GT_MetaTileEntity_ElectricBlastFurnace tileEntity, ExtendedFacing aSide) { - IGregTechTileEntity base = tileEntity.getBaseMetaTileEntity(); - definition.buildOrHints(tileEntity, stackSize, "main", base.getWorld(), - aSide, base.getXCoord(), base.getYCoord(), - base.getZCoord(), 1, 3, 0, hintsOnly); - } - - @Override - public String[] getDescription(ItemStack stackSize) { - return desc; - } - }); - } -} diff --git a/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java b/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java index b481b82646..773361bd0f 100644 --- a/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java @@ -1,40 +1,34 @@ package com.github.technus.tectech.loader; -import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.dComplexAspectDefinition; -import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.ePrimalAspectDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalPrimitive; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dHadronDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.iaeaNuclide; +import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.EMComplexAspectDefinition; +import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.EMPrimalAspectDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMHadronDefinition; import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.*; /** * Created by danie_000 on 16.11.2016. */ -public class ElementalLoader implements Runnable { - @Override - public void run() { +public class ElementalLoader { + public void run(EMDefinitionsRegistry registry) { // =================================================================================================== // Definition init // =================================================================================================== - cElementalPrimitive.run(); + EMPrimitiveDefinition.run(registry); - cPrimitiveDefinition.run(); + EMQuarkDefinition.run(registry); + EMLeptonDefinition.run(registry); + EMNeutrinoDefinition.run(registry); + EMGaugeBosonDefinition.run(registry); + EMScalarBosonDefinition.run(registry); - eQuarkDefinition.run(); - eLeptonDefinition.run(); - eNeutrinoDefinition.run(); - eBosonDefinition.run(); + EMHadronDefinition.run(registry); - dHadronDefinition.run(); + EMAtomDefinition.run(registry); - iaeaNuclide.run(); - - dAtomDefinition.run(); - - ePrimalAspectDefinition.run(); - - dComplexAspectDefinition.run(); + EMPrimalAspectDefinition.run(registry); + EMComplexAspectDefinition.run(registry); } } diff --git a/src/main/java/com/github/technus/tectech/loader/MainLoader.java b/src/main/java/com/github/technus/tectech/loader/MainLoader.java index 8a03bd67b8..7965f09aff 100644 --- a/src/main/java/com/github/technus/tectech/loader/MainLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/MainLoader.java @@ -2,20 +2,23 @@ package com.github.technus.tectech.loader; import com.github.technus.tectech.Reference; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.AspectDefinitionCompat; -import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.AspectDefinitionCompatEnabled; +import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.transformations.AspectDefinitionCompat; +import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.transformations.AspectDefinitionCompatEnabled; import com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi.EssentiaCompat; import com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi.EssentiaCompatEnabled; +import com.github.technus.tectech.loader.gui.CreativeTabEM; import com.github.technus.tectech.loader.gui.CreativeTabTecTech; import com.github.technus.tectech.loader.gui.ModGuiHandler; -import com.github.technus.tectech.loader.recipe.RecipeLoader; +import com.github.technus.tectech.loader.recipe.BaseRecipeLoader; import com.github.technus.tectech.loader.thing.ComponentLoader; import com.github.technus.tectech.loader.thing.CoverLoader; import com.github.technus.tectech.loader.thing.MachineLoader; import com.github.technus.tectech.loader.thing.ThingsLoader; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry; import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.metaTileEntity.Textures; -import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_collider; +import com.github.technus.tectech.thing.metaTileEntity.multi.em_collider.GT_MetaTileEntity_EM_collider; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.ProgressManager; import cpw.mods.fml.common.network.NetworkRegistry; @@ -38,44 +41,45 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; -import static com.github.technus.tectech.util.CommonValues.*; import static com.github.technus.tectech.TecTech.*; -import static com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.AspectDefinitionCompat.aspectDefinitionCompat; +import static com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.transformations.AspectDefinitionCompat.aspectDefinitionCompat; import static com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi.EssentiaCompat.essentiaContainerCompat; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; +import static com.github.technus.tectech.util.CommonValues.*; import static gregtech.api.enums.GT_Values.W; public final class MainLoader { - public static DamageSource microwaving, elementalPollution,subspace; + public static DamageSource microwaving, elementalPollution, subspace; - private MainLoader(){} + private MainLoader() { + } - public static void staticLoad(){ - for(int i=0;i<16;i++){ - GT_Values.V[i]=V[i]; - GT_Values.VN[i]=VN[i]; - GT_Values.VOLTAGE_NAMES[i]=VOLTAGE_NAMES[i]; + public static void staticLoad() { + for (int i = 0; i < 16; i++) { + GT_Values.V[i] = V[i]; + GT_Values.VN[i] = VN[i]; + GT_Values.VOLTAGE_NAMES[i] = VOLTAGE_NAMES[i]; } new ComponentLoader(); } - public static void preLoad(){ - creativeTabTecTech =new CreativeTabTecTech("TecTech"); + public static void preLoad() { + creativeTabTecTech = new CreativeTabTecTech("TecTech"); + creativeTabEM = new CreativeTabEM("EM"); //set expanded texture arrays for tiers try { - new Textures(); - }catch (Throwable t){ - LOGGER.error("Loading textures...",t); + Textures.run(); + } catch (Throwable t) { + LOGGER.error("Loading textures...", t); } } - public static void load() { + public static void load(EMDefinitionsRegistry definitionsRegistry) { ProgressManager.ProgressBar progressBarLoad = ProgressManager.push("TecTech Loader", 9); progressBarLoad.step("Elemental Things"); - new ElementalLoader().run(); + new ElementalLoader().run(definitionsRegistry); LOGGER.info("Elemental Init Done"); progressBarLoad.step("Thaumcraft Compatibility"); @@ -103,9 +107,9 @@ public final class MainLoader { LOGGER.info("Entities registered"); progressBarLoad.step("Add damage types"); - microwaving =new DamageSource("microwaving").setDamageBypassesArmor(); - elementalPollution =new DamageSource("elementalPollution").setDamageBypassesArmor(); - subspace =new DamageSource("subspace").setDamageBypassesArmor().setDamageIsAbsolute(); + microwaving = new DamageSource("microwaving").setDamageBypassesArmor(); + elementalPollution = new DamageSource("elementalPollution").setDamageBypassesArmor(); + subspace = new DamageSource("subspace").setDamageBypassesArmor().setDamageIsAbsolute(); LOGGER.info("Damage types addition Done"); progressBarLoad.step("Register Packet Dispatcher"); @@ -120,33 +124,33 @@ public final class MainLoader { ProgressManager.pop(progressBarLoad); } - public static void postLoad() { - ProgressManager.ProgressBar progressBarPostLoad = ProgressManager.push("TecTech Post Loader", 5); + public static void postLoad(EMDefinitionsRegistry definitionsRegistry, EMTransformationRegistry transformationInfo) { + ProgressManager.ProgressBar progressBarPostLoad = ProgressManager.push("TecTech Post Loader", 4); progressBarPostLoad.step("Dreamcraft Compatibility"); - if(Loader.isModLoaded(Reference.DREAMCRAFT)){ + if (Loader.isModLoaded(Reference.DREAMCRAFT)) { try { Class<?> clazz = Class.forName("com.dreammaster.gthandler.casings.GT_Container_CasingsNH"); - TT_Container_Casings.sBlockCasingsNH = (Block)clazz.getField("sBlockCasingsNH").get(null); + TT_Container_Casings.sBlockCasingsNH = (Block) clazz.getField("sBlockCasingsNH").get(null); - if(TT_Container_Casings.sBlockCasingsNH==null){ + if (TT_Container_Casings.sBlockCasingsNH == null) { throw new NullPointerException("sBlockCasingsNH Is not set at this time"); } - }catch (Exception e){ - throw new Error("Unable to get NH casings",e); + } catch (Exception e) { + throw new Error("Unable to get NH casings", e); } } progressBarPostLoad.step("Thaumcraft Compatibility"); if (Loader.isModLoaded(Reference.THAUMCRAFT)) { aspectDefinitionCompat = new AspectDefinitionCompatEnabled(); - aspectDefinitionCompat.run(); + aspectDefinitionCompat.run(definitionsRegistry); } else { aspectDefinitionCompat = new AspectDefinitionCompat(); } progressBarPostLoad.step("Recipes"); - new RecipeLoader().run(); + new BaseRecipeLoader().run(transformationInfo); TecTech.LOGGER.info("Recipe Init Done"); //Hazmat moved to GT5U @@ -163,27 +167,23 @@ public final class MainLoader { TecTech.LOGGER.info("Blocks were not nerfed"); } - progressBarPostLoad.step("Constructable stuff"); - new ConstructableLoader().run(); - TecTech.LOGGER.info("Constructable initialized"); - ProgressManager.pop(progressBarPostLoad); } - private static void registerExtraHazmats() { //Hazmat moved to GT5U - ItemStack EMT_iqC=GT_ModHandler.getModItem("EMT","itemArmorQuantumChestplate",1,W); - ItemStack GRAVI_gC=GT_ModHandler.getModItem("GraviSuite","graviChestPlate",1,W); - ItemStack GRAVI_anC=GT_ModHandler.getModItem("GraviSuite", "advNanoChestPlate", 1, W); + private static void registerExtraHazmats() { + ItemStack EMT_iqC = GT_ModHandler.getModItem("EMT", "itemArmorQuantumChestplate", 1, W); + ItemStack GRAVI_gC = GT_ModHandler.getModItem("GraviSuite", "graviChestPlate", 1, W); + ItemStack GRAVI_anC = GT_ModHandler.getModItem("GraviSuite", "advNanoChestPlate", 1, W); - ItemStack IC2_qH=GT_ModHandler.getIC2Item("quantumHelmet", 1L, W); - ItemStack IC2_qC=GT_ModHandler.getIC2Item("quantumBodyarmor", 1L, W); - ItemStack IC2_qL=GT_ModHandler.getIC2Item("quantumLeggings", 1L, W); - ItemStack IC2_qB=GT_ModHandler.getIC2Item("quantumBoots", 1L, W); + ItemStack IC2_qH = GT_ModHandler.getIC2Item("quantumHelmet", 1L, W); + ItemStack IC2_qC = GT_ModHandler.getIC2Item("quantumBodyarmor", 1L, W); + ItemStack IC2_qL = GT_ModHandler.getIC2Item("quantumLeggings", 1L, W); + ItemStack IC2_qB = GT_ModHandler.getIC2Item("quantumBoots", 1L, W); - ItemStack IC2_nH=GT_ModHandler.getIC2Item("nanoHelmet", 1L, W); - ItemStack IC2_nC=GT_ModHandler.getIC2Item("nanoBodyarmor", 1L, W); - ItemStack IC2_nL=GT_ModHandler.getIC2Item("nanoLeggings", 1L, W); - ItemStack IC2_nB=GT_ModHandler.getIC2Item("nanoBoots", 1L, W); + ItemStack IC2_nH = GT_ModHandler.getIC2Item("nanoHelmet", 1L, W); + ItemStack IC2_nC = GT_ModHandler.getIC2Item("nanoBodyarmor", 1L, W); + ItemStack IC2_nL = GT_ModHandler.getIC2Item("nanoLeggings", 1L, W); + ItemStack IC2_nB = GT_ModHandler.getIC2Item("nanoBoots", 1L, W); GregTech_API.sFrostHazmatList.add(EMT_iqC); GregTech_API.sFrostHazmatList.add(GRAVI_gC); @@ -205,7 +205,7 @@ public final class MainLoader { GregTech_API.sBioHazmatList.add(IC2_qC); GregTech_API.sBioHazmatList.add(IC2_qL); GregTech_API.sBioHazmatList.add(IC2_qB); - + GregTech_API.sBioHazmatList.add(GRAVI_anC); GregTech_API.sBioHazmatList.add(IC2_nH); GregTech_API.sBioHazmatList.add(IC2_nC); @@ -218,7 +218,7 @@ public final class MainLoader { GregTech_API.sGasHazmatList.add(IC2_qC); GregTech_API.sGasHazmatList.add(IC2_qL); GregTech_API.sGasHazmatList.add(IC2_qB); - + GregTech_API.sGasHazmatList.add(GRAVI_anC); GregTech_API.sGasHazmatList.add(IC2_nH); GregTech_API.sGasHazmatList.add(IC2_nC); @@ -238,13 +238,13 @@ public final class MainLoader { GregTech_API.sElectroHazmatList.add(IC2_qC); GregTech_API.sElectroHazmatList.add(IC2_qL); GregTech_API.sElectroHazmatList.add(IC2_qB); - + //todo add GC GS stuff } public static void addAfterGregTechPostLoadRunner() { GregTech_API.sAfterGTPostload.add(() -> { - if(TecTech.configTecTech.NERF_FUSION) { + if (TecTech.configTecTech.NERF_FUSION) { FixBrokenFusionRecipes(); } GT_MetaTileEntity_EM_collider.setValues(getFuelValue(Materials.Helium.getPlasma(125))); @@ -306,7 +306,7 @@ public final class MainLoader { public static int getFuelValue(FluidStack aLiquid) { if (aLiquid == null || GT_Recipe.GT_Recipe_Map.sTurbineFuels == null) return 0; - FluidStack tLiquid; + FluidStack tLiquid; Collection<GT_Recipe> tRecipeList = GT_Recipe.GT_Recipe_Map.sPlasmaFuels.mRecipeList; if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList) if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) @@ -314,8 +314,8 @@ public final class MainLoader { return 0; } - private static void fixBlocks(){ - HashSet<String> modIDs=new HashSet<>(Arrays.asList( + private static void fixBlocks() { + HashSet<String> modIDs = new HashSet<>(Arrays.asList( "minecraft", "IC2", "gregtech", @@ -346,8 +346,8 @@ public final class MainLoader { "utilityworlds", Reference.MODID )); - for(Block block : GameData.getBlockRegistry().typeSafeIterable()) { - GameRegistry.UniqueIdentifier uniqueIdentifier=GameRegistry.findUniqueIdentifierFor(block); + for (Block block : GameData.getBlockRegistry().typeSafeIterable()) { + GameRegistry.UniqueIdentifier uniqueIdentifier = GameRegistry.findUniqueIdentifierFor(block); if (uniqueIdentifier != null) { if (block.blockHardness < 0 || modIDs.contains(uniqueIdentifier.modId)) { continue; diff --git a/src/main/java/com/github/technus/tectech/loader/NetworkDispatcher.java b/src/main/java/com/github/technus/tectech/loader/NetworkDispatcher.java index 1edd924587..8401af51ca 100644 --- a/src/main/java/com/github/technus/tectech/loader/NetworkDispatcher.java +++ b/src/main/java/com/github/technus/tectech/loader/NetworkDispatcher.java @@ -3,10 +3,9 @@ package com.github.technus.tectech.loader; import com.github.technus.tectech.mechanics.data.ChunkDataMessage; import com.github.technus.tectech.mechanics.data.PlayerDataMessage; import com.github.technus.tectech.mechanics.enderStorage.EnderLinkCoverMessage; +import com.github.technus.tectech.mechanics.pipe.PipeActivityMessage; import com.github.technus.tectech.mechanics.spark.RendererMessage; -import com.github.technus.tectech.mechanics.alignment.AlignmentMessage; import com.github.technus.tectech.thing.metaTileEntity.hatch.TextParametersMessage; -import com.github.technus.tectech.mechanics.pipe.PipeActivityMessage; import static com.github.technus.tectech.Reference.MODID; @@ -24,9 +23,6 @@ public class NetworkDispatcher extends eu.usrv.yamcore.network.PacketDispatcher registerMessage(PipeActivityMessage.ServerHandler.class, PipeActivityMessage.PipeActivityQuery.class); registerMessage(PipeActivityMessage.ClientHandler.class, PipeActivityMessage.PipeActivityData.class); - registerMessage(AlignmentMessage.ServerHandler.class, AlignmentMessage.AlignmentQuery.class); - registerMessage(AlignmentMessage.ClientHandler.class, AlignmentMessage.AlignmentData.class); - registerMessage(ChunkDataMessage.ServerHandler.class, ChunkDataMessage.ChunkDataQuery.class); registerMessage(ChunkDataMessage.ClientHandler.class, ChunkDataMessage.ChunkDataData.class); diff --git a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java index 66e549ddb1..aa6d1e5e9f 100644 --- a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java +++ b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java @@ -11,6 +11,7 @@ public class TecTechConfig extends ConfigManager { //final static to allow compiler to remove the debug code when this is false public static boolean DEBUG_MODE = false; + public static boolean POWERLESS_MODE = false; public boolean DISABLE_MATERIAL_LOADING_FFS; public boolean BOOM_ENABLE; @@ -82,6 +83,8 @@ public class TecTechConfig extends ConfigManager { protected void Init() { DEBUG_MODE = _mainConfig.getBoolean("DebugMode", "debug", DEBUG_MODE, "Enables logging and other purely debug features"); + POWERLESS_MODE = _mainConfig.getBoolean("PowerlessMode", "debug", POWERLESS_MODE, + "Enables 0EU/t multi block machinery"); DISABLE_MATERIAL_LOADING_FFS = _mainConfig.getBoolean("DisableMaterialLoading", "debug", DISABLE_MATERIAL_LOADING_FFS, "Set to true to disable gregtech material processing"); diff --git a/src/main/java/com/github/technus/tectech/loader/gui/CreativeTabEM.java b/src/main/java/com/github/technus/tectech/loader/gui/CreativeTabEM.java new file mode 100644 index 0000000000..cd73d1e420 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/gui/CreativeTabEM.java @@ -0,0 +1,19 @@ +package com.github.technus.tectech.loader.gui; + +import com.github.technus.tectech.thing.item.ElementalDefinitionContainer_EM; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +public class CreativeTabEM extends CreativeTabs { + public CreativeTabEM(String name) { + super(name); + } + + @SideOnly(Side.CLIENT) + @Override + public Item getTabIconItem() { + return ElementalDefinitionContainer_EM.INSTANCE; + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/gui/CreativeTabTecTech.java b/src/main/java/com/github/technus/tectech/loader/gui/CreativeTabTecTech.java index d360162fb6..e5b9fea395 100644 --- a/src/main/java/com/github/technus/tectech/loader/gui/CreativeTabTecTech.java +++ b/src/main/java/com/github/technus/tectech/loader/gui/CreativeTabTecTech.java @@ -11,8 +11,6 @@ import net.minecraft.item.Item; import java.util.List; public class CreativeTabTecTech extends CreativeTabs { - public static CreativeTabTecTech creativeTabTecTech; - public CreativeTabTecTech(String name) { super(name); } diff --git a/src/main/java/com/github/technus/tectech/loader/recipe/RecipeLoader.java b/src/main/java/com/github/technus/tectech/loader/recipe/BaseRecipeLoader.java index a2e2f65384..20f58b739b 100644 --- a/src/main/java/com/github/technus/tectech/loader/recipe/RecipeLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/recipe/BaseRecipeLoader.java @@ -2,14 +2,14 @@ package com.github.technus.tectech.loader.recipe; import com.github.technus.tectech.Reference; import com.github.technus.tectech.compatibility.dreamcraft.DreamCraftRecipeLoader; +import com.github.technus.tectech.compatibility.gtpp.GtppAtomLoader; import com.github.technus.tectech.compatibility.spartakcore.SpartakCoreRecipeLoader; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dHadronDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMHadronDefinition; import com.github.technus.tectech.thing.CustomItemList; -import com.github.technus.tectech.thing.casing.TT_Container_Casings; -import com.github.technus.tectech.thing.item.ConstructableTriggerItem; import com.github.technus.tectech.thing.item.EuMeterGT; -import com.github.technus.tectech.thing.item.FrontRotationTriggerItem; +import com.gtnewhorizon.structurelib.StructureLibAPI; import cpw.mods.fml.common.Loader; import gregtech.api.enums.Dyes; import gregtech.api.enums.ItemList; @@ -27,38 +27,44 @@ import static gregtech.api.enums.GT_Values.RA; /** * Created by danie_000 on 16.11.2016. */ -public class RecipeLoader implements Runnable { - public static Materials getOrDefault(String name,Materials def){ - Materials mat=Materials.get(name); +public class BaseRecipeLoader { + public static Materials getOrDefault(String name, Materials def) { + Materials mat = Materials.get(name); return mat == Materials._NULL || mat == null ? def : mat; } - @Override - public void run() { - dAtomDefinition.setTransformation(); - dHadronDefinition.setTransformations(); + public void run(EMTransformationRegistry transformationInfo) { + EMAtomDefinition.setTransformations(transformationInfo); + EMHadronDefinition.setTransformations(transformationInfo); + if (Loader.isModLoaded(Reference.GTPLUSPLUS)) { + new GtppAtomLoader().setTransformations(transformationInfo); + } // =================================================================================================== // Recipes init - common goes here rest goes into methods below // =================================================================================================== for(int i=0;i<=15;i++) { - RA.addAssemblerRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(i), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Cobalt, 1)}, Materials.Aluminium.getMolten(864), new ItemStack(TT_Container_Casings.sHintCasingsTT, 1, i), 32, 120); + RA.addAssemblerRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(i), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Cobalt, 1)}, + Materials.Aluminium.getMolten(864), + new ItemStack(StructureLibAPI.getBlockHint(), 1, i), 32, 120); } //Scrench - GT_ModHandler.addCraftingRecipe(new ItemStack(FrontRotationTriggerItem.INSTANCE,1), - GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, - new Object[]{"fPR", " RP", "S h", - 'P', OrePrefixes.plate.get(Materials.Cobalt), - 'R', OrePrefixes.stick.get(Materials.Cobalt), - 'S', OrePrefixes.stick.get(Materials.Wood),}); +// GT_ModHandler.addCraftingRecipe(new ItemStack(FrontRotationTriggerItem.INSTANCE,1), +// GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, +// new Object[]{"fPR", " RP", "S h", +// 'P', OrePrefixes.plate.get(Materials.Cobalt), +// 'R', OrePrefixes.stick.get(Materials.Cobalt), +// 'S', OrePrefixes.stick.get(Materials.Wood),}); //BLUEprint - /*GT_ModHandler.addShapelessCraftingRecipe(new ItemStack(ConstructableTriggerItem.INSTANCE, 1), - GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, - new Object[]{Dyes.dyeBlue, OrePrefixes.plate.get(Materials.Paper), Dyes.dyeBlue, Dyes.dyeWhite}); - */ +// GT_ModHandler.addShapelessCraftingRecipe(new ItemStack(ConstructableTriggerItem.INSTANCE, 1), +// GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, +// new Object[]{Dyes.dyeBlue, OrePrefixes.plate.get(Materials.Paper), Dyes.dyeBlue, Dyes.dyeWhite}); + + //GT EU reader GT_ModHandler.addCraftingRecipe(new ItemStack(EuMeterGT.INSTANCE,1), GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, @@ -109,11 +115,11 @@ public class RecipeLoader implements Runnable { RA.addAssemblerRecipe(ItemList.Hatch_DataAccess_EV.get(1), CustomItemList.dataOut_Hatch.get(1), CustomItemList.dataOutAss_Hatch.get(1), 2048, 12000); if (Loader.isModLoaded(Reference.DREAMCRAFT)) { - new DreamCraftRecipeLoader().run();//init recipes for GTNH version + new DreamCraftRecipeLoader().run(transformationInfo);//init recipes for GTNH version } else if (Loader.isModLoaded(Reference.SPARTAKCORE)) { - new SpartakCoreRecipeLoader().run();//init recipes for SpartakCore version + new SpartakCoreRecipeLoader().run(transformationInfo);//init recipes for SpartakCore version } else { - new BloodyRecipeLoader().run();//init recipes for NON-GTNH version + new BloodyRecipeLoader().run(transformationInfo);//init recipes for NON-GTNH version } } } diff --git a/src/main/java/com/github/technus/tectech/loader/recipe/BloodyRecipeLoader.java b/src/main/java/com/github/technus/tectech/loader/recipe/BloodyRecipeLoader.java index 7b8cc14f4d..a57f268d4e 100644 --- a/src/main/java/com/github/technus/tectech/loader/recipe/BloodyRecipeLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/recipe/BloodyRecipeLoader.java @@ -1,5 +1,6 @@ package com.github.technus.tectech.loader.recipe; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry; import com.github.technus.tectech.recipe.TT_recipeAdder; import com.github.technus.tectech.thing.CustomItemList; import com.github.technus.tectech.thing.block.QuantumGlassBlock; @@ -22,9 +23,8 @@ import net.minecraftforge.fluids.FluidStack; /** * Created by Tec on 06.08.2017. */ -public class BloodyRecipeLoader implements Runnable { - @Override - public void run() { +public class BloodyRecipeLoader { + public void run(EMTransformationRegistry transformationInfo) { //Quantum Glass GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ CustomItemList.eM_Containment.get(1), diff --git a/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java b/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java index 0bf8c57f24..65cba0a2b7 100644 --- a/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java @@ -6,6 +6,7 @@ import com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity. import com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_essentiaQuantizer; import com.github.technus.tectech.thing.metaTileEntity.hatch.*; import com.github.technus.tectech.thing.metaTileEntity.multi.*; +import com.github.technus.tectech.thing.metaTileEntity.multi.em_collider.GT_MetaTileEntity_EM_collider; import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.GT_MetaTileEntity_EM_machine; import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data; import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_EM; @@ -15,8 +16,9 @@ import cpw.mods.fml.common.Loader; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -import static com.github.technus.tectech.util.CommonValues.V; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT; import static com.github.technus.tectech.thing.CustomItemList.*; +import static com.github.technus.tectech.util.CommonValues.V; /** * Created by danie_000 on 16.11.2016. @@ -73,22 +75,22 @@ public class MachineLoader implements Runnable { // =================================================================================================== eM_muffler_UV.set(new GT_MetaTileEntity_Hatch_OverflowElemental( - 15020, "hatch.emmuffler.tier.08", "UV Overflow Output Hatch", 8, 1e10f).getStackForm(1L)); + 15020, "hatch.emmuffler.tier.08", "UV Overflow Output Hatch", 8, 1e10f* EM_COUNT_PER_MATERIAL_AMOUNT).getStackForm(1L)); eM_muffler_UHV.set(new GT_MetaTileEntity_Hatch_OverflowElemental( - 15021, "hatch.emmuffler.tier.09", "UHV Overflow Output Hatch", 9, 5e10f).getStackForm(1L)); + 15021, "hatch.emmuffler.tier.09", "UHV Overflow Output Hatch", 9, 5e10f* EM_COUNT_PER_MATERIAL_AMOUNT).getStackForm(1L)); eM_muffler_UEV.set(new GT_MetaTileEntity_Hatch_OverflowElemental( - 15022, "hatch.emmuffler.tier.10", "UEV Overflow Output Hatch", 10, 25e10f).getStackForm(1L)); + 15022, "hatch.emmuffler.tier.10", "UEV Overflow Output Hatch", 10, 25e10f* EM_COUNT_PER_MATERIAL_AMOUNT).getStackForm(1L)); eM_muffler_UIV.set(new GT_MetaTileEntity_Hatch_OverflowElemental( - 15023, "hatch.emmuffler.tier.11", "UIV Overflow Output Hatch", 11, 125e10f).getStackForm(1L)); + 15023, "hatch.emmuffler.tier.11", "UIV Overflow Output Hatch", 11, 125e10f* EM_COUNT_PER_MATERIAL_AMOUNT).getStackForm(1L)); eM_muffler_UMV.set(new GT_MetaTileEntity_Hatch_OverflowElemental( - 15024, "hatch.emmuffler.tier.12", "UMV Overflow Output Hatch", 12, 125e11f).getStackForm(1L)); + 15024, "hatch.emmuffler.tier.12", "UMV Overflow Output Hatch", 12, 125e11f* EM_COUNT_PER_MATERIAL_AMOUNT).getStackForm(1L)); eM_muffler_UXV.set(new GT_MetaTileEntity_Hatch_OverflowElemental( - 15025, "hatch.emmuffler.tier.13", "UXV Overflow Output Hatch", 13, 125e12f).getStackForm(1L)); + 15025, "hatch.emmuffler.tier.13", "UXV Overflow Output Hatch", 13, 125e12f* EM_COUNT_PER_MATERIAL_AMOUNT).getStackForm(1L)); // =================================================================================================== diff --git a/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java b/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java index 4adeeec315..7c32bb70d2 100644 --- a/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java @@ -7,7 +7,10 @@ import com.github.technus.tectech.compatibility.openmodularturrets.blocks.turret import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.block.QuantumStuffBlock; import com.github.technus.tectech.thing.block.ReactorSimBlock; -import com.github.technus.tectech.thing.casing.*; +import com.github.technus.tectech.thing.casing.GT_Block_CasingsBA0; +import com.github.technus.tectech.thing.casing.GT_Block_CasingsNH; +import com.github.technus.tectech.thing.casing.GT_Block_CasingsTT; +import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.item.*; import cpw.mods.fml.common.Loader; import gregtech.api.enums.Textures; @@ -33,8 +36,6 @@ public class ThingsLoader implements Runnable { TecTech.LOGGER.info("Elemental Casing registered"); TT_Container_Casings.sBlockCasingsBA0 = new GT_Block_CasingsBA0(); TecTech.LOGGER.info("Nikolai's Casing registered"); - TT_Container_Casings.sHintCasingsTT = new GT_Block_HintTT(); - TecTech.LOGGER.info("Hint Blocks registered"); QuantumGlassBlock.run(); TecTech.LOGGER.info("Quantum Glass registered"); @@ -52,8 +53,6 @@ public class ThingsLoader implements Runnable { ReactorSimBlock.run(); TecTech.LOGGER.info("Reactor Simulator registered"); - ConstructableTriggerItem.run(); - FrontRotationTriggerItem.run(); ParametrizerMemoryCard.run(); ElementalDefinitionScanStorage_EM.run(); EuMeterGT.run(); diff --git a/src/main/java/com/github/technus/tectech/mechanics/alignment/AlignmentLimits.java b/src/main/java/com/github/technus/tectech/mechanics/alignment/AlignmentLimits.java deleted file mode 100644 index 779406371a..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/alignment/AlignmentLimits.java +++ /dev/null @@ -1,184 +0,0 @@ -package com.github.technus.tectech.mechanics.alignment; - -import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; -import com.github.technus.tectech.mechanics.alignment.enumerable.Flip; -import com.github.technus.tectech.mechanics.alignment.enumerable.Rotation; -import net.minecraftforge.common.util.ForgeDirection; - -import java.util.Arrays; -import java.util.Optional; -import java.util.Random; -import java.util.function.Function; - -import static com.github.technus.tectech.mechanics.alignment.IAlignment.STATES_COUNT; - -@Deprecated -public class AlignmentLimits implements IAlignmentLimits { - - protected final boolean[] validStates=new boolean[STATES_COUNT]; - - public AlignmentLimits() { - allowAll(); - } - - AlignmentLimits allowAll(){ - Arrays.fill(validStates,true); - return this; - } - - AlignmentLimits denyAll(){ - Arrays.fill(validStates,false); - return this; - } - - AlignmentLimits randomAll(Random random){ - for (int i = 0; i < validStates.length; i++) { - validStates[i]=random.nextBoolean(); - } - return this; - } - - AlignmentLimits deny(ExtendedFacing... deny){ - if(deny!=null){ - for (ExtendedFacing extendedFacing : deny) { - validStates[extendedFacing.getIndex()]=false; - } - } - return this; - } - - AlignmentLimits allow(ExtendedFacing... allow){ - if(allow!=null){ - for (ExtendedFacing extendedFacing : allow) { - validStates[extendedFacing.getIndex()]=false; - } - } - return this; - } - - AlignmentLimits deny(ForgeDirection... deny){ - if(deny!=null){ - for (ExtendedFacing value : ExtendedFacing.VALUES) { - for (ForgeDirection direction : deny) { - if (value.getDirection() == direction) { - validStates[value.getIndex()] = false; - break; - } - } - } - } - return this; - } - - AlignmentLimits allow(ForgeDirection... allow){ - if(allow!=null){ - for (ExtendedFacing value : ExtendedFacing.VALUES) { - for (ForgeDirection direction : allow) { - if (value.getDirection() == direction) { - validStates[value.getIndex()] = true; - break; - } - } - } - } - return this; - } - - AlignmentLimits deny(Rotation... deny){ - if(deny!=null){ - for (ExtendedFacing value : ExtendedFacing.VALUES) { - for (Rotation rotation : deny) { - if (value.getRotation() == rotation) { - validStates[value.getIndex()] = false; - break; - } - } - } - } - return this; - } - - AlignmentLimits allow(Rotation... allow){ - if(allow!=null){ - for (ExtendedFacing value : ExtendedFacing.VALUES) { - for (Rotation rotation : allow) { - if (value.getRotation() == rotation) { - validStates[value.getIndex()] = true; - break; - } - } - } - } - return this; - } - - AlignmentLimits deny(Flip... deny){ - if(deny!=null){ - for (ExtendedFacing value : ExtendedFacing.VALUES) { - for (Flip flip : deny) { - if (value.getFlip() == flip) { - validStates[value.getIndex()] = false; - break; - } - } - } - } - return this; - } - - AlignmentLimits allow(Flip... allow){ - if(allow!=null){ - for (ExtendedFacing value : ExtendedFacing.VALUES) { - for (Flip flip : allow) { - if (value.getFlip() == flip) { - validStates[value.getIndex()] = true; - break; - } - } - } - } - return this; - } - - AlignmentLimits predicateApply(Function<ExtendedFacing,Optional<Boolean>> predicate){ - for (ExtendedFacing value : ExtendedFacing.VALUES) { - predicate.apply(value).ifPresent(bool->validStates[value.getIndex()]=bool); - } - return this; - } - - AlignmentLimits ensureDuplicates(){ - for (ExtendedFacing value : ExtendedFacing.VALUES) { - if(validStates[value.getIndex()]){ - validStates[value.getDuplicate().getIndex()]=true; - } - } - return this; - } - - /** - * Prefers rotation over flip, so both flip will get translated to opposite rotation and no flip - * @param flip the preferred flip to be used Horizontal or vertical - * @return this - */ - AlignmentLimits ensureNoDuplicates(Flip flip){ - if(flip==Flip.BOTH||flip==Flip.NONE){ - throw new IllegalArgumentException("Preffered Flip must be Horizontal or Vertical"); - } - flip=flip.getOpposite(); - for (ExtendedFacing value : ExtendedFacing.VALUES) { - if(validStates[value.getIndex()]){ - if(value.getFlip()==Flip.BOTH || value.getFlip()==flip){ - validStates[value.getIndex()]=false; - validStates[value.getDuplicate().getIndex()]=true; - } - } - } - return this; - } - - @Override - public boolean isNewExtendedFacingValid(ForgeDirection direction, Rotation rotation, Flip flip) { - return validStates[IAlignment.getAlignmentIndex(direction,rotation,flip)]; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/alignment/AlignmentMessage.java b/src/main/java/com/github/technus/tectech/mechanics/alignment/AlignmentMessage.java deleted file mode 100644 index 61fc398171..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/alignment/AlignmentMessage.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.github.technus.tectech.mechanics.alignment; - -import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import cpw.mods.fml.common.network.ByteBufUtils; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import eu.usrv.yamcore.network.client.AbstractClientMessageHandler; -import eu.usrv.yamcore.network.server.AbstractServerMessageHandler; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import io.netty.buffer.ByteBuf; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.DimensionManager; - -@Deprecated -public class AlignmentMessage implements IMessage { - int mPosX; - int mPosY; - int mPosZ; - int mPosD; - int mAlign; - - public AlignmentMessage() { - } - - private AlignmentMessage(GT_MetaTileEntity_MultiblockBase_EM metaTile) { - IGregTechTileEntity base=metaTile.getBaseMetaTileEntity(); - mPosX=base.getXCoord(); - mPosY=base.getYCoord(); - mPosZ=base.getZCoord(); - mPosD=base.getWorld().provider.dimensionId; - mAlign =metaTile.getExtendedFacing().getIndex(); - } - - private AlignmentMessage(World world, int x, int y, int z, IAlignment front) { - mPosX=x; - mPosY=y; - mPosZ=z; - mPosD=world.provider.dimensionId; - mAlign =front.getExtendedFacing().getIndex(); - } - - @Override - public void fromBytes(ByteBuf pBuffer) { - NBTTagCompound tTag = ByteBufUtils.readTag(pBuffer); - mPosX = tTag.getInteger("posx"); - mPosY = tTag.getInteger("posy"); - mPosZ = tTag.getInteger("posz"); - mPosD = tTag.getInteger("posd"); - mAlign = tTag.getInteger("rotf"); - } - - @Override - public void toBytes(ByteBuf pBuffer) { - NBTTagCompound tFXTag = new NBTTagCompound(); - tFXTag.setInteger("posx", mPosX); - tFXTag.setInteger("posy", mPosY); - tFXTag.setInteger("posz", mPosZ); - tFXTag.setInteger("posd", mPosD); - tFXTag.setInteger("rotf", mAlign); - - ByteBufUtils.writeTag(pBuffer, tFXTag); - } - - public static class AlignmentQuery extends AlignmentMessage { - public AlignmentQuery() { - } - - public AlignmentQuery(GT_MetaTileEntity_MultiblockBase_EM metaTile) { - super(metaTile); - } - - public AlignmentQuery(World world, int x, int y, int z, IAlignment front) { - super(world,x,y,z,front); - } - } - - public static class AlignmentData extends AlignmentMessage { - public AlignmentData() { - } - - private AlignmentData(AlignmentQuery query){ - mPosX=query.mPosX; - mPosY=query.mPosY; - mPosZ=query.mPosZ; - mPosD=query.mPosD; - mAlign =query.mAlign; - } - - public AlignmentData(GT_MetaTileEntity_MultiblockBase_EM metaTile) { - super(metaTile); - } - - public AlignmentData(World world, int x, int y, int z, IAlignment front) { - super(world,x,y,z,front); - } - } - - public static class ClientHandler extends AbstractClientMessageHandler<AlignmentData> { - @Override - public IMessage handleClientMessage(EntityPlayer pPlayer, AlignmentData pMessage, MessageContext pCtx) { - if(pPlayer.worldObj.provider.dimensionId==pMessage.mPosD){ - TileEntity te=pPlayer.worldObj.getTileEntity(pMessage.mPosX,pMessage.mPosY,pMessage.mPosZ); - if(te instanceof IGregTechTileEntity){ - IMetaTileEntity meta = ((IGregTechTileEntity) te).getMetaTileEntity(); - if(meta instanceof IAlignment){ - ((IAlignment) meta).setExtendedFacing(ExtendedFacing.byIndex(pMessage.mAlign)); - } - }else if (te instanceof IAlignment){ - ((IAlignment) te).setExtendedFacing(ExtendedFacing.byIndex(pMessage.mAlign)); - } - } - return null; - } - } - - public static class ServerHandler extends AbstractServerMessageHandler<AlignmentQuery> { - @Override - public IMessage handleServerMessage(EntityPlayer pPlayer, AlignmentQuery pMessage, MessageContext pCtx) { - World world= DimensionManager.getWorld(pMessage.mPosD); - if(world!=null) { - TileEntity te = world.getTileEntity(pMessage.mPosX, pMessage.mPosY, pMessage.mPosZ); - if (te instanceof IGregTechTileEntity) { - IMetaTileEntity meta = ((IGregTechTileEntity) te).getMetaTileEntity(); - if (meta instanceof IAlignment) { - pMessage.mAlign =((IAlignment) meta).getExtendedFacing().getIndex(); - return new AlignmentData(pMessage); - } - } else if (te instanceof IAlignment) { - pMessage.mAlign =((IAlignment) te).getExtendedFacing().getIndex(); - return new AlignmentData(pMessage); - } - } - return null; - } - } -}
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/mechanics/alignment/AlignmentUtility.java b/src/main/java/com/github/technus/tectech/mechanics/alignment/AlignmentUtility.java deleted file mode 100644 index af3369465c..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/alignment/AlignmentUtility.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.github.technus.tectech.mechanics.alignment; - -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.util.FakePlayer; - -@Deprecated -public class AlignmentUtility { - private AlignmentUtility(){ - - } - - public static boolean handle(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ){ - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if(tTileEntity==null || aPlayer instanceof FakePlayer) { - return aPlayer instanceof EntityPlayerMP; - } - if (aPlayer instanceof EntityPlayerMP) { - if (tTileEntity instanceof IGregTechTileEntity) { - IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); - if (metaTE instanceof IAlignmentProvider) { - IAlignment alignment = ((IAlignmentProvider) metaTE).getAlignment(); - if(aPlayer.isSneaking()){ - alignment.toolSetFlip(null); - }else { - alignment.toolSetRotation(null); - } - return true; - } - } else if (tTileEntity instanceof IAlignmentProvider) { - IAlignment alignment = ((IAlignmentProvider) tTileEntity).getAlignment(); - if(aPlayer.isSneaking()){ - alignment.toolSetFlip(null); - }else { - alignment.toolSetRotation(null); - } - return true; - } - } - return false; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/alignment/IAlignment.java b/src/main/java/com/github/technus/tectech/mechanics/alignment/IAlignment.java deleted file mode 100644 index 0ea202cc98..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/alignment/IAlignment.java +++ /dev/null @@ -1,188 +0,0 @@ -package com.github.technus.tectech.mechanics.alignment; - -import com.github.technus.tectech.mechanics.alignment.enumerable.Direction; -import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; -import com.github.technus.tectech.mechanics.alignment.enumerable.Flip; -import com.github.technus.tectech.mechanics.alignment.enumerable.Rotation; -import net.minecraftforge.common.util.ForgeDirection; - -import java.util.Arrays; - -@Deprecated -public interface IAlignment extends IAlignmentLimits,IAlignmentProvider { - int DIRECTIONS_COUNT= Direction.VALUES.length; - int ROTATIONS_COUNT= Rotation.VALUES.length; - int FLIPS_COUNT= Flip.VALUES.length; - int STATES_COUNT = ExtendedFacing.VALUES.length; - - ExtendedFacing getExtendedFacing(); - - void setExtendedFacing(ExtendedFacing alignment); - - IAlignmentLimits getAlignmentLimits(); - - void setAlignmentLimits(IAlignmentLimits limits); - - @Override - default IAlignment getAlignment(){ - return this; - } - - static int getAlignmentIndex(ForgeDirection direction, Rotation rotation, Flip flip){ - return (direction.ordinal()*ROTATIONS_COUNT+rotation.getIndex())*FLIPS_COUNT+flip.getIndex(); - } - - default ForgeDirection getDirection(){ - return getExtendedFacing().getDirection(); - } - - default void setDirection(ForgeDirection direction){ - setExtendedFacing(getExtendedFacing().with(direction)); - } - - default Rotation getRotation(){ - return getExtendedFacing().getRotation(); - } - - default void setRotation(Rotation rotation){ - setExtendedFacing(getExtendedFacing().with(rotation)); - } - - default Flip getFlip(){ - return getExtendedFacing().getFlip(); - } - - default void setFlip(Flip flip){ - setExtendedFacing(getExtendedFacing().with(flip)); - } - - default boolean toolSetDirection(ForgeDirection direction){ - if(direction==null || direction==ForgeDirection.UNKNOWN){ - for (int i = 0,j=getDirection().ordinal()+1, valuesLength = Direction.VALUES.length; i < valuesLength; i++) { - if(toolSetDirection(Direction.VALUES[j%valuesLength].getForgeDirection())){ - return true; - } - } - }else { - for (ExtendedFacing extendedFacing : ExtendedFacing.FOR_FACING.get(direction)) { - if(checkedSetExtendedFacing(extendedFacing)){ - return true; - } - } - } - return false; - } - - default boolean checkedSetDirection(ForgeDirection direction){ - if (isNewDirectionValid(direction)){ - setDirection(direction); - return true; - } - return false; - } - - default boolean canSetToDirectionAny(ForgeDirection direction){ - for (ExtendedFacing extendedFacing : ExtendedFacing.FOR_FACING.get(direction)) { - if(isNewExtendedFacingValid(extendedFacing)){ - return true; - } - } - return false; - } - - default boolean toolSetRotation(Rotation rotation) { - if(rotation==null){ - int flips = Flip.VALUES.length; - int rotations = Rotation.VALUES.length; - for (int ii = 0,jj=getFlip().ordinal(); ii < flips; ii++) { - for (int i = 0,j=getRotation().ordinal()+1; i < rotations; i++) { - if(checkedSetExtendedFacing(ExtendedFacing.of(getDirection(),Rotation.VALUES[j%rotations],Flip.VALUES[jj%flips]))){ - return true; - } - } - } - return false; - }else { - return checkedSetRotation(rotation); - } - } - - default boolean checkedSetRotation(Rotation rotation){ - if (isNewRotationValid(rotation)){ - setRotation(rotation); - return true; - } - return false; - } - - default boolean toolSetFlip(Flip flip){ - if(flip==null){ - for (int i = 0,j=getFlip().ordinal()+1, valuesLength = Flip.VALUES.length; i < valuesLength; i++) { - if(toolSetFlip(Flip.VALUES[j%valuesLength])){ - return true; - } - } - return false; - }else { - return checkedSetFlip(flip); - } - } - - default boolean checkedSetFlip(Flip flip){ - if (isNewFlipValid(flip)){ - setFlip(flip); - return true; - } - return false; - } - - default boolean toolSetExtendedFacing(ExtendedFacing extendedFacing){ - if(extendedFacing==null){ - for (int i = 0,j=getExtendedFacing().ordinal()+1, valuesLength = ExtendedFacing.VALUES.length; i < valuesLength; i++) { - if(toolSetExtendedFacing(ExtendedFacing.VALUES[j%valuesLength])){ - return true; - } - } - return false; - }else { - return checkedSetExtendedFacing(extendedFacing); - } - } - - default boolean checkedSetExtendedFacing(ExtendedFacing alignment){ - if (isNewExtendedFacingValid(alignment)){ - setExtendedFacing(alignment); - return true; - } - return false; - } - - default boolean isNewDirectionValid(ForgeDirection direction) { - return isNewExtendedFacingValid(direction,getRotation(),getFlip()); - } - - default boolean isNewRotationValid(Rotation rotation){ - return isNewExtendedFacingValid(getDirection(),rotation,getFlip()); - } - - default boolean isNewFlipValid(Flip flip){ - return isNewExtendedFacingValid(getDirection(),getRotation(),flip); - } - - default boolean isExtendedFacingValid() { - return isNewExtendedFacingValid(getDirection(),getRotation(),getFlip()); - } - - @Override - default boolean isNewExtendedFacingValid(ForgeDirection direction, Rotation rotation, Flip flip){ - return getAlignmentLimits().isNewExtendedFacingValid(direction, rotation, flip); - } - - @Override - default boolean isNewExtendedFacingValid(ExtendedFacing alignment){ - return getAlignmentLimits().isNewExtendedFacingValid( - alignment.getDirection(), - alignment.getRotation(), - alignment.getFlip()); - } -}
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/mechanics/alignment/IAlignmentLimits.java b/src/main/java/com/github/technus/tectech/mechanics/alignment/IAlignmentLimits.java deleted file mode 100644 index a1f505baff..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/alignment/IAlignmentLimits.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.github.technus.tectech.mechanics.alignment; -import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; -import com.github.technus.tectech.mechanics.alignment.enumerable.Flip; -import com.github.technus.tectech.mechanics.alignment.enumerable.Rotation; -import net.minecraftforge.common.util.ForgeDirection; - -@Deprecated -public interface IAlignmentLimits { - - IAlignmentLimits UNLIMITED= (direction, rotation, flip) -> true; - - boolean isNewExtendedFacingValid(ForgeDirection direction, Rotation rotation, Flip flip); - - default boolean isNewExtendedFacingValid(ExtendedFacing alignment){ - return isNewExtendedFacingValid( - alignment.getDirection(), - alignment.getRotation(), - alignment.getFlip()); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/alignment/IAlignmentProvider.java b/src/main/java/com/github/technus/tectech/mechanics/alignment/IAlignmentProvider.java deleted file mode 100644 index 23bf9ae266..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/alignment/IAlignmentProvider.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.github.technus.tectech.mechanics.alignment; - -@Deprecated -public interface IAlignmentProvider { - IAlignment getAlignment(); -}
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/mechanics/alignment/IntegerAxisSwap.java b/src/main/java/com/github/technus/tectech/mechanics/alignment/IntegerAxisSwap.java deleted file mode 100644 index 2ec6ea6893..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/alignment/IntegerAxisSwap.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.github.technus.tectech.mechanics.alignment; - -import com.github.technus.tectech.util.Vec3Impl; -import net.minecraft.util.Vec3; -import net.minecraftforge.common.util.ForgeDirection; - -import static com.github.technus.tectech.mechanics.alignment.enumerable.Direction.getAxisVector; -import static java.lang.Math.abs; - -@Deprecated -public class IntegerAxisSwap { - private final Vec3Impl forFirstAxis; - private final Vec3Impl forSecondAxis; - private final Vec3Impl forThirdAxis; - - public IntegerAxisSwap(ForgeDirection forFirstAxis, ForgeDirection forSecondAxis, ForgeDirection forThirdAxis) { - this.forFirstAxis = getAxisVector(forFirstAxis); - this.forSecondAxis = getAxisVector(forSecondAxis); - this.forThirdAxis = getAxisVector(forThirdAxis); - if(abs(this.forFirstAxis.get0())+abs(this.forSecondAxis.get0())+abs(this.forThirdAxis.get0())!=1 || - abs(this.forFirstAxis.get1())+abs(this.forSecondAxis.get1())+abs(this.forThirdAxis.get1())!=1 || - abs(this.forFirstAxis.get2())+abs(this.forSecondAxis.get2())+abs(this.forThirdAxis.get2())!=1){ - throw new IllegalArgumentException("Axis are overlapping/missing! "+ - forFirstAxis.name()+" "+ - forSecondAxis.name()+" "+ - forThirdAxis.name()); - } - } - - public Vec3Impl translate(Vec3Impl point){ - return new Vec3Impl( - forFirstAxis.get0()*point.get0() +forFirstAxis.get1()*point.get1() +forFirstAxis.get2()*point.get2(), - forSecondAxis.get0()*point.get0()+forSecondAxis.get1()*point.get1()+forSecondAxis.get2()*point.get2(), - forThirdAxis.get0()*point.get0() +forThirdAxis.get1()*point.get1() +forThirdAxis.get2()*point.get2() - ); - } - - public Vec3Impl inverseTranslate(Vec3Impl point){ - return new Vec3Impl( - forFirstAxis.get0()*point.get0()+forSecondAxis.get0()*point.get1()+forThirdAxis.get0()*point.get2(), - forFirstAxis.get1()*point.get0()+forSecondAxis.get1()*point.get1()+forThirdAxis.get1()*point.get2(), - forFirstAxis.get2()*point.get0()+forSecondAxis.get2()*point.get1()+forThirdAxis.get2()*point.get2() - ); - } - - public Vec3 translate(Vec3 point){ - return Vec3.createVectorHelper( - forFirstAxis.get0()*point.xCoord +forFirstAxis.get1()*point.yCoord +forFirstAxis.get2()*point.zCoord, - forSecondAxis.get0()*point.xCoord+forSecondAxis.get1()*point.yCoord+forSecondAxis.get2()*point.zCoord, - forThirdAxis.get0()*point.xCoord +forThirdAxis.get1()*point.yCoord +forThirdAxis.get2()*point.zCoord - ); - } - - public Vec3 inverseTranslate(Vec3 point){ - return Vec3.createVectorHelper( - forFirstAxis.get0()*point.xCoord+forSecondAxis.get0()*point.yCoord+forThirdAxis.get0()*point.zCoord, - forFirstAxis.get1()*point.xCoord+forSecondAxis.get1()*point.yCoord+forThirdAxis.get1()*point.zCoord, - forFirstAxis.get2()*point.xCoord+forSecondAxis.get2()*point.yCoord+forThirdAxis.get2()*point.zCoord - ); - } - - public void translate(int[] point,int[] out){ - out[0]=forFirstAxis.get0()*point[0] +forFirstAxis.get1()*point[1] +forFirstAxis.get2()*point[2]; - out[1]=forSecondAxis.get0()*point[0]+forSecondAxis.get1()*point[1]+forSecondAxis.get2()*point[2]; - out[2]=forThirdAxis.get0()*point[0] +forThirdAxis.get1()*point[1] +forThirdAxis.get2()*point[2]; - } - - public void inverseTranslate(int[] point,int[] out){ - out[0]=forFirstAxis.get0()*point[0]+forSecondAxis.get0()*point[1]+forThirdAxis.get0()*point[2]; - out[1]=forFirstAxis.get1()*point[0]+forSecondAxis.get1()*point[1]+forThirdAxis.get1()*point[2]; - out[2]=forFirstAxis.get2()*point[0]+forSecondAxis.get2()*point[1]+forThirdAxis.get2()*point[2]; - } - - public void translate(double[] point,double[] out){ - out[0]=forFirstAxis.get0()*point[0] +forFirstAxis.get1()*point[1] +forFirstAxis.get2()*point[2]; - out[1]=forSecondAxis.get0()*point[0]+forSecondAxis.get1()*point[1]+forSecondAxis.get2()*point[2]; - out[2]=forThirdAxis.get0()*point[0] +forThirdAxis.get1()*point[1] +forThirdAxis.get2()*point[2]; - } - - public void inverseTranslate(double[] point,double[] out){ - out[0]=forFirstAxis.get0()*point[0]+forSecondAxis.get0()*point[1]+forThirdAxis.get0()*point[2]; - out[1]=forFirstAxis.get1()*point[0]+forSecondAxis.get1()*point[1]+forThirdAxis.get1()*point[2]; - out[2]=forFirstAxis.get2()*point[0]+forSecondAxis.get2()*point[1]+forThirdAxis.get2()*point[2]; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Direction.java b/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Direction.java deleted file mode 100644 index 56356b3606..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Direction.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.github.technus.tectech.mechanics.alignment.enumerable; - -import com.github.technus.tectech.util.Vec3Impl; -import net.minecraftforge.common.util.ForgeDirection; - -@Deprecated -public enum Direction { - DOWN(ForgeDirection.DOWN), - UP(ForgeDirection.UP), - NORTH(ForgeDirection.NORTH), - SOUTH(ForgeDirection.SOUTH), - WEST(ForgeDirection.WEST), - EAST(ForgeDirection.EAST); - - private final ForgeDirection forgeDirection; - private final Vec3Impl axisVector; - public static final Direction[] VALUES=values(); - - Direction(ForgeDirection forgeDirection) { - this.forgeDirection = forgeDirection; - axisVector=new Vec3Impl(forgeDirection.offsetX,forgeDirection.offsetY,forgeDirection.offsetZ); - } - - public ForgeDirection getForgeDirection() { - return forgeDirection; - } - - public Vec3Impl getAxisVector() { - return axisVector; - } - - public static Vec3Impl getAxisVector(ForgeDirection forgeDirection){ - return VALUES[forgeDirection.ordinal()].axisVector; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/ExtendedFacing.java b/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/ExtendedFacing.java deleted file mode 100644 index 8e384e098c..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/ExtendedFacing.java +++ /dev/null @@ -1,359 +0,0 @@ -package com.github.technus.tectech.mechanics.alignment.enumerable; - -import com.github.technus.tectech.mechanics.alignment.IAlignment; -import com.github.technus.tectech.mechanics.alignment.IntegerAxisSwap; -import com.github.technus.tectech.util.Vec3Impl; -import net.minecraft.util.Vec3; -import net.minecraftforge.common.util.ForgeDirection; - -import java.util.*; - -import static com.github.technus.tectech.mechanics.alignment.IAlignment.FLIPS_COUNT; -import static com.github.technus.tectech.mechanics.alignment.IAlignment.ROTATIONS_COUNT; -import static java.lang.Math.abs; -import static java.util.Arrays.stream; -import static java.util.stream.Collectors.toMap; - -@Deprecated -public enum ExtendedFacing { - DOWN_NORMAL_NONE("down normal none"), - DOWN_NORMAL_HORIZONTAL("down normal horizontal"), - DOWN_NORMAL_VERTICAL("down normal vertical"), - DOWN_NORMAL_BOTH("down normal both"), - DOWN_CLOCKWISE_NONE("down clockwise none"), - DOWN_CLOCKWISE_HORIZONTAL("down clockwise horizontal"), - DOWN_CLOCKWISE_VERTICAL("down clockwise vertical"), - DOWN_CLOCKWISE_BOTH("down clockwise both"), - DOWN_UPSIDE_DOWN_NONE("down upside down none"), - DOWN_UPSIDE_DOWN_HORIZONTAL("down upside down horizontal"), - DOWN_UPSIDE_DOWN_VERTICAL("down upside down vertical"), - DOWN_UPSIDE_DOWN_BOTH("down upside down both"), - DOWN_COUNTER_CLOCKWISE_NONE("down counter clockwise none"), - DOWN_COUNTER_CLOCKWISE_HORIZONTAL("down counter clockwise horizontal"), - DOWN_COUNTER_CLOCKWISE_VERTICAL("down counter clockwise vertical"), - DOWN_COUNTER_CLOCKWISE_BOTH("down counter clockwise both"), - UP_NORMAL_NONE("up normal none"), - UP_NORMAL_HORIZONTAL("up normal horizontal"), - UP_NORMAL_VERTICAL("up normal vertical"), - UP_NORMAL_BOTH("up normal both"), - UP_CLOCKWISE_NONE("up clockwise none"), - UP_CLOCKWISE_HORIZONTAL("up clockwise horizontal"), - UP_CLOCKWISE_VERTICAL("up clockwise vertical"), - UP_CLOCKWISE_BOTH("up clockwise both"), - UP_UPSIDE_DOWN_NONE("up upside down none"), - UP_UPSIDE_DOWN_HORIZONTAL("up upside down horizontal"), - UP_UPSIDE_DOWN_VERTICAL("up upside down vertical"), - UP_UPSIDE_DOWN_BOTH("up upside down both"), - UP_COUNTER_CLOCKWISE_NONE("up counter clockwise none"), - UP_COUNTER_CLOCKWISE_HORIZONTAL("up counter clockwise horizontal"), - UP_COUNTER_CLOCKWISE_VERTICAL("up counter clockwise vertical"), - UP_COUNTER_CLOCKWISE_BOTH("up counter clockwise both"), - NORTH_NORMAL_NONE("north normal none"), - NORTH_NORMAL_HORIZONTAL("north normal horizontal"), - NORTH_NORMAL_VERTICAL("north normal vertical"), - NORTH_NORMAL_BOTH("north normal both"), - NORTH_CLOCKWISE_NONE("north clockwise none"), - NORTH_CLOCKWISE_HORIZONTAL("north clockwise horizontal"), - NORTH_CLOCKWISE_VERTICAL("north clockwise vertical"), - NORTH_CLOCKWISE_BOTH("north clockwise both"), - NORTH_UPSIDE_DOWN_NONE("north upside down none"), - NORTH_UPSIDE_DOWN_HORIZONTAL("north upside down horizontal"), - NORTH_UPSIDE_DOWN_VERTICAL("north upside down vertical"), - NORTH_UPSIDE_DOWN_BOTH("north upside down both"), - NORTH_COUNTER_CLOCKWISE_NONE("north counter clockwise none"), - NORTH_COUNTER_CLOCKWISE_HORIZONTAL("north counter clockwise horizontal"), - NORTH_COUNTER_CLOCKWISE_VERTICAL("north counter clockwise vertical"), - NORTH_COUNTER_CLOCKWISE_BOTH("north counter clockwise both"), - SOUTH_NORMAL_NONE("south normal none"), - SOUTH_NORMAL_HORIZONTAL("south normal horizontal"), - SOUTH_NORMAL_VERTICAL("south normal vertical"), - SOUTH_NORMAL_BOTH("south normal both"), - SOUTH_CLOCKWISE_NONE("south clockwise none"), - SOUTH_CLOCKWISE_HORIZONTAL("south clockwise horizontal"), - SOUTH_CLOCKWISE_VERTICAL("south clockwise vertical"), - SOUTH_CLOCKWISE_BOTH("south clockwise both"), - SOUTH_UPSIDE_DOWN_NONE("south upside down none"), - SOUTH_UPSIDE_DOWN_HORIZONTAL("south upside down horizontal"), - SOUTH_UPSIDE_DOWN_VERTICAL("south upside down vertical"), - SOUTH_UPSIDE_DOWN_BOTH("south upside down both"), - SOUTH_COUNTER_CLOCKWISE_NONE("south counter clockwise none"), - SOUTH_COUNTER_CLOCKWISE_HORIZONTAL("south counter clockwise horizontal"), - SOUTH_COUNTER_CLOCKWISE_VERTICAL("south counter clockwise vertical"), - SOUTH_COUNTER_CLOCKWISE_BOTH("south counter clockwise both"), - WEST_NORMAL_NONE("west normal none"), - WEST_NORMAL_HORIZONTAL("west normal horizontal"), - WEST_NORMAL_VERTICAL("west normal vertical"), - WEST_NORMAL_BOTH("west normal both"), - WEST_CLOCKWISE_NONE("west clockwise none"), - WEST_CLOCKWISE_HORIZONTAL("west clockwise horizontal"), - WEST_CLOCKWISE_VERTICAL("west clockwise vertical"), - WEST_CLOCKWISE_BOTH("west clockwise both"), - WEST_UPSIDE_DOWN_NONE("west upside down none"), - WEST_UPSIDE_DOWN_HORIZONTAL("west upside down horizontal"), - WEST_UPSIDE_DOWN_VERTICAL("west upside down vertical"), - WEST_UPSIDE_DOWN_BOTH("west upside down both"), - WEST_COUNTER_CLOCKWISE_NONE("west counter clockwise none"), - WEST_COUNTER_CLOCKWISE_HORIZONTAL("west counter clockwise horizontal"), - WEST_COUNTER_CLOCKWISE_VERTICAL("west counter clockwise vertical"), - WEST_COUNTER_CLOCKWISE_BOTH("west counter clockwise both"), - EAST_NORMAL_NONE("east normal none"), - EAST_NORMAL_HORIZONTAL("east normal horizontal"), - EAST_NORMAL_VERTICAL("east normal vertical"), - EAST_NORMAL_BOTH("east normal both"), - EAST_CLOCKWISE_NONE("east clockwise none"), - EAST_CLOCKWISE_HORIZONTAL("east clockwise horizontal"), - EAST_CLOCKWISE_VERTICAL("east clockwise vertical"), - EAST_CLOCKWISE_BOTH("east clockwise both"), - EAST_UPSIDE_DOWN_NONE("east upside down none"), - EAST_UPSIDE_DOWN_HORIZONTAL("east upside down horizontal"), - EAST_UPSIDE_DOWN_VERTICAL("east upside down vertical"), - EAST_UPSIDE_DOWN_BOTH("east upside down both"), - EAST_COUNTER_CLOCKWISE_NONE("east counter clockwise none"), - EAST_COUNTER_CLOCKWISE_HORIZONTAL("east counter clockwise horizontal"), - EAST_COUNTER_CLOCKWISE_VERTICAL("east counter clockwise vertical"), - EAST_COUNTER_CLOCKWISE_BOTH("east counter clockwise both"); - - public static final ExtendedFacing DEFAULT=NORTH_NORMAL_NONE; - public static final ExtendedFacing[] VALUES = values(); - public static final Map<ForgeDirection, List<ExtendedFacing>> FOR_FACING=new HashMap<>(); - static { - stream(values()).forEach(extendedFacing -> - FOR_FACING.compute(extendedFacing.direction,((forgeDirection, extendedFacings) -> { - if(extendedFacings==null){ - extendedFacings = new ArrayList<>(); - } - extendedFacings.add(extendedFacing); - return extendedFacings; - }))); - } - private static final Map<String, ExtendedFacing> NAME_LOOKUP = stream(VALUES).collect(toMap(ExtendedFacing::getName2, (extendedFacing) -> extendedFacing)); - - private final ForgeDirection direction; - private final ForgeDirection a,b,c; - private final Rotation rotation; - private final Flip flip; - - private final String name; - private final IntegerAxisSwap integerAxisSwap; - - ExtendedFacing(String name) { - this.name = name; - direction= Direction.VALUES[ordinal()/(Rotation.COUNT*Flip.COUNT)].getForgeDirection(); - rotation=Rotation.VALUES[ordinal()/Flip.COUNT-direction.ordinal()*Rotation.COUNT]; - flip=Flip.VALUES[ordinal()%Flip.COUNT]; - ForgeDirection a,b,c; - switch (direction){ - case DOWN: - a= ForgeDirection.WEST; - b= ForgeDirection.SOUTH; - c= ForgeDirection.UP; - break; - case UP: - a= ForgeDirection.EAST; - b= ForgeDirection.SOUTH; - c= ForgeDirection.DOWN; - break; - case NORTH: - a= ForgeDirection.WEST; - b= ForgeDirection.DOWN; - c= ForgeDirection.SOUTH; - break; - case SOUTH: - a= ForgeDirection.EAST; - b= ForgeDirection.DOWN; - c= ForgeDirection.NORTH; - break; - case WEST: - a= ForgeDirection.SOUTH; - b= ForgeDirection.DOWN; - c= ForgeDirection.EAST; - break; - case EAST: - a= ForgeDirection.NORTH; - b= ForgeDirection.DOWN; - c= ForgeDirection.WEST; - break; - default:throw new RuntimeException("Is impossible..."); - } - switch (flip){//This duplicates some axis swaps since flip boolean would do, but seems more convenient to use - case HORIZONTAL: - a=a.getOpposite(); - break; - case BOTH: - a=a.getOpposite(); - case VERTICAL: - b=b.getOpposite(); - break; - case NONE: break; - default:throw new RuntimeException("Even more impossible..."); - } - switch (rotation) { - case CLOCKWISE: { - ForgeDirection _a=a; - a =b; - b =_a.getOpposite(); - break; - } - case UPSIDE_DOWN: - a=a.getOpposite(); - b=b.getOpposite(); - break; - case COUNTER_CLOCKWISE: { - ForgeDirection _a=a; - a =b.getOpposite(); - b =_a; - break; - } - case NORMAL: break; - default: - throw new RuntimeException("More impossible..."); - } - this.a=a; - this.b=b; - this.c=c; - integerAxisSwap =new IntegerAxisSwap(a,b,c); - } - - public static ExtendedFacing of(ForgeDirection direction, Rotation rotation, Flip flip){ - if(direction==ForgeDirection.UNKNOWN){ - return VALUES[IAlignment.getAlignmentIndex(ForgeDirection.NORTH, rotation, flip)]; - } - return VALUES[IAlignment.getAlignmentIndex(direction, rotation, flip)]; - } - - public static ExtendedFacing of(ForgeDirection direction){ - if(direction==ForgeDirection.UNKNOWN){ - return DEFAULT; - } - return VALUES[IAlignment.getAlignmentIndex(direction, Rotation.NORMAL, Flip.NONE)]; - } - - public ExtendedFacing with(ForgeDirection direction){ - return of(direction,rotation,flip); - } - - public ExtendedFacing with(Rotation rotation){ - return of(direction,rotation,flip); - } - - public ExtendedFacing with(Flip flip){ - return of(direction,rotation,flip); - } - - public ExtendedFacing getOppositeDirection() { - return of(direction.getOpposite(),rotation,flip); - } - - public ExtendedFacing getOppositeRotation() { - return of(direction,rotation.getOpposite(),flip); - } - - public ExtendedFacing getOppositeFlip() { - return of(direction,rotation,flip.getOpposite()); - } - - /** - * Gets the same effective facing achieved by different rot/flip combo - * @return same effective facing, but different enum value - */ - public ExtendedFacing getDuplicate(){ - return of(direction,rotation.getOpposite(),flip.getOpposite()); - } - - public int getIndex(){ - return ordinal(); - } - - public String getName2() { - return this.name; - } - - public static ExtendedFacing byName(String name) { - return name == null ? null : NAME_LOOKUP.get(name.toLowerCase(Locale.ROOT)); - } - - public static ExtendedFacing byIndex(int index) { - return VALUES[abs(index % VALUES.length)]; - } - - public static ExtendedFacing random(Random rand) { - return VALUES[rand.nextInt(VALUES.length)]; - } - - public ForgeDirection getDirection() { - return direction; - } - - public Rotation getRotation() { - return rotation; - } - - public Flip getFlip() { - return flip; - } - - /** - * Translates relative to front facing offset to world offset - * @param abcOffset A,B,C offset (facing relative L-->R,U-->D,F-->B) - * @return X,Y,Z offset in world - */ - public Vec3 getWorldOffset(Vec3 abcOffset) { - return integerAxisSwap.inverseTranslate(abcOffset); - } - public Vec3Impl getWorldOffset(Vec3Impl abcOffset) { - return integerAxisSwap.inverseTranslate(abcOffset); - } - public void getWorldOffset(int[] point,int[] out){ - integerAxisSwap.inverseTranslate(point,out); - } - public void getWorldOffset(double[] point,double[] out){ - integerAxisSwap.inverseTranslate(point,out); - } - - - /** - * Translates world offset to relative front facing offset - * @param xyzOffset X,Y,Z offset in world - * @return A,B,C offset (facing relative L-->R,U-->D,F-->B) - */ - public Vec3 getOffsetABC(Vec3 xyzOffset){ - return integerAxisSwap.translate(xyzOffset); - } - public Vec3Impl getOffsetABC(Vec3Impl xyzOffset){ - return integerAxisSwap.translate(xyzOffset); - } - public void getOffsetABC(int[] point,int[] out){ - integerAxisSwap.translate(point,out); - } - public void getOffsetABC(double[] point,double[] out){ - integerAxisSwap.translate(point,out); - } - - public IntegerAxisSwap getIntegerAxisSwap() { - return integerAxisSwap; - } - - public ForgeDirection getRelativeLeftInWorld() { - return a; - } - - public ForgeDirection getRelativeRightInWorld() { - return a.getOpposite(); - } - - public ForgeDirection getRelativeDownInWorld() { - return b; - } - - public ForgeDirection getRelativeUpInWorld() { - return b.getOpposite(); - } - - public ForgeDirection getRelativeBackInWorld() { - return c; - } - - public ForgeDirection getRelativeForwardInWorld() { - return c.getOpposite(); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Flip.java b/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Flip.java deleted file mode 100644 index 400f94f869..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Flip.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.github.technus.tectech.mechanics.alignment.enumerable; - -import javax.annotation.Nonnull; -import java.util.Locale; -import java.util.Map; -import java.util.Random; - -import static java.lang.Math.abs; -import static java.util.Arrays.stream; -import static java.util.stream.Collectors.toMap; - -@Deprecated -public enum Flip { - NONE(3, "none"), - HORIZONTAL(2, "horizontal"), - VERTICAL(1, "vertical"), - BOTH(0, "both"); - - private final int opposite; - private final String name; - - public static final Flip[] VALUES = values(); - public static final int COUNT = VALUES.length; - private static final Map<String, Flip> NAME_LOOKUP = stream(VALUES).collect(toMap(Flip::getName2, (flip) -> flip)); - - Flip(int oppositeIn, String nameIn) { - this.opposite = oppositeIn; - this.name = nameIn; - } - - public int getIndex(){ - return ordinal(); - } - - public Flip getOpposite() { - return VALUES[opposite]; - } - - public String getName2() { - return this.name; - } - - public static Flip byName(String name) { - return name == null ? null : NAME_LOOKUP.get(name.toLowerCase(Locale.ROOT)); - } - - public static Flip byIndex(int index) { - return VALUES[abs(index % VALUES.length)]; - } - - public static Flip random(@Nonnull Random rand) { - return VALUES[rand.nextInt(VALUES.length)]; - } - - public String toString() { - return this.name; - } - - public String getName() { - return this.name; - } - - public boolean isNotFlipped(){ - return this==NONE; - } - - public boolean isBothFlipped(){ - return this==BOTH; - } - - public boolean isHorizontallyFlipped() { - return this==HORIZONTAL || isBothFlipped(); - } - - public boolean isVerticallyFliped() { - return this==VERTICAL || isBothFlipped(); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Rotation.java b/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Rotation.java deleted file mode 100644 index ed4872828a..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Rotation.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.github.technus.tectech.mechanics.alignment.enumerable; - -import javax.annotation.Nonnull; -import java.util.Locale; -import java.util.Map; -import java.util.Random; - -import static java.lang.Math.abs; -import static java.util.Arrays.stream; -import static java.util.stream.Collectors.toMap; - -@Deprecated -public enum Rotation { - NORMAL(2, "normal"), - CLOCKWISE(3, "clockwise"), - UPSIDE_DOWN(0, "upside down"), - COUNTER_CLOCKWISE(1, "counter clockwise"); - - private final int opposite; - private final String name; - - public static final Rotation[] VALUES = values(); - public static final int COUNT = VALUES.length; - private static final Map<String, Rotation> NAME_LOOKUP = stream(VALUES).collect(toMap(Rotation::getName2, (rotation) -> rotation)); - - Rotation(int oppositeIn, String nameIn) { - this.opposite = oppositeIn; - this.name = nameIn; - } - - public int getIndex(){ - return ordinal(); - } - - public Rotation getOpposite() { - return VALUES[opposite]; - } - - public String getName2() { - return this.name; - } - - public static Rotation byName(String name) { - return name == null ? null : NAME_LOOKUP.get(name.toLowerCase(Locale.ROOT)); - } - - public static Rotation byIndex(int index) { - return VALUES[abs(index % VALUES.length)]; - } - - public static Rotation random(@Nonnull Random rand) { - return VALUES[rand.nextInt(VALUES.length)]; - } - - public String toString() { - return this.name; - } - - public String getName() { - return this.name; - } - - public boolean isNotRotated(){ - return this==NORMAL; - } - - public boolean isClockwise(){ - return this==CLOCKWISE; - } - - public boolean isCounterClockwise(){ - return this==COUNTER_CLOCKWISE; - } - - public boolean isUpsideDown(){ - return this==UPSIDE_DOWN; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java b/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java index dd388bc233..bd25b05a0c 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java +++ b/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java @@ -1,14 +1,14 @@ package com.github.technus.tectech.mechanics.anomaly; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.loader.MainLoader; import com.github.technus.tectech.loader.NetworkDispatcher; import com.github.technus.tectech.mechanics.data.ChunkDataHandler; import com.github.technus.tectech.mechanics.data.ChunkDataMessage; import com.github.technus.tectech.mechanics.data.IChunkMetaDataHandler; import com.github.technus.tectech.mechanics.data.PlayerDataMessage; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.common.gameevent.TickEvent; import gregtech.api.GregTech_API; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -20,6 +20,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; +import net.minecraft.tileentity.TileEntity; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; @@ -28,19 +29,27 @@ import net.minecraftforge.event.world.ChunkEvent; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; + +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED; +import static com.github.technus.tectech.util.TT_Utility.crossProduct3D; +import static com.github.technus.tectech.util.TT_Utility.normalize3D; public class AnomalyHandler implements IChunkMetaDataHandler { - public static final double SWAP_THRESHOLD = dAtomDefinition.getSomethingHeavy().getMass() * 10000D; - public static final int COUNT_DIV=32; - public static final double PER_PARTICLE=SWAP_THRESHOLD/COUNT_DIV; - public static final String INTENSITY = "intensity",SPACE_CANCER="space_cancer", SPACE_CHARGE ="space_charge"; - public static final int MEAN_DELAY =50; - private static final float CHARGE_EFFECTIVENESS = 10; - private static final float CHARGE_EXPLOSIVENESS = 5; - - private boolean fixMe=false; - private final ArrayList<EntityPlayer> playersWithCharge = new ArrayList<>(); - private final ArrayList<Chunk> worldDataArrayList = new ArrayList<>(512); + private static final double SWAP_THRESHOLD = EMAtomDefinition.getSomethingHeavy().getMass() * 1000D * EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED;//can be const as it is computed later... + private static final int COUNT_DIV = 32; + private static final double PER_PARTICLE = SWAP_THRESHOLD / COUNT_DIV; + private static final String INTENSITY = "intensity", SPACE_CANCER = "space_cancer", SPACE_CHARGE = "space_charge", SPACE_MASS = "space_mass"; + private static final int MEAN_DELAY = 50; + private static final double CANCER_EFFECTIVENESS = 1 / EM_COUNT_PER_MATERIAL_AMOUNT; + private static final double MASS_EFFECTIVENESS = 1 / EM_COUNT_PER_MATERIAL_AMOUNT; + private static final double CHARGE_EFFECTIVENESS = 10 / EM_COUNT_PER_MATERIAL_AMOUNT; + private static final double CHARGE_EXPLOSIVENESS = 5 / EM_COUNT_PER_MATERIAL_AMOUNT; + + private boolean fixMe = false; + private final List<EntityPlayer> playersWithCharge = new ArrayList<>(); + private final ArrayList<Chunk> worldDataArrayList = new ArrayList<>(512); @Override public String getTagName() { @@ -61,9 +70,10 @@ public class AnomalyHandler implements IChunkMetaDataHandler { @Override public void tickWorld(HashMap<Integer, ChunkDataHandler.ChunkHashMap> data, TickEvent.WorldTickEvent aEvent) { if (TecTech.RANDOM.nextInt(MEAN_DELAY) == 0) { - int dim = aEvent.world.provider.dimensionId; - data.get(dim).forEach((chunkCoordIntPair, compound) -> { - if (compound.getDouble(INTENSITY) >= SWAP_THRESHOLD) { + int dim = aEvent.world.provider.dimensionId; + ChunkDataHandler.ChunkHashMap chunkHashMap = data.get(dim); + chunkHashMap.forEach((chunkCoordIntPair, compound) -> { + if (compound.getDouble(INTENSITY) > SWAP_THRESHOLD) { Chunk chunk = aEvent.world.getChunkFromChunkCoords(chunkCoordIntPair.chunkXPos, chunkCoordIntPair.chunkZPos); if (chunk.isChunkLoaded) { worldDataArrayList.add(chunk); @@ -71,22 +81,26 @@ public class AnomalyHandler implements IChunkMetaDataHandler { } }); if (worldDataArrayList.size() >= 2) { - Chunk a = worldDataArrayList.remove(TecTech.RANDOM.nextInt(worldDataArrayList.size())); - Chunk b = worldDataArrayList.remove(TecTech.RANDOM.nextInt(worldDataArrayList.size())); - double avg = .5 * (data.get(dim).get(a.getChunkCoordIntPair()).getDouble(INTENSITY) + - data.get(dim).get(b.getChunkCoordIntPair()).getDouble(INTENSITY)); - data.get(dim).get(a.getChunkCoordIntPair()).setDouble(INTENSITY, Math.min(SWAP_THRESHOLD, avg * (TecTech.RANDOM.nextFloat() + .5F) * 0.5F)); - data.get(dim).get(b.getChunkCoordIntPair()).setDouble(INTENSITY, Math.min(SWAP_THRESHOLD, avg * (TecTech.RANDOM.nextFloat() + .5F) * 0.5F)); - data.get(dim).markForTransmissionToClient(a.getChunkCoordIntPair()); - data.get(dim).markForTransmissionToClient(b.getChunkCoordIntPair()); - swapSomething(a, b, (float) Math.min(Math.log10(avg), 20)); + Chunk a = worldDataArrayList.remove(TecTech.RANDOM.nextInt(worldDataArrayList.size())); + Chunk b = worldDataArrayList.get(TecTech.RANDOM.nextInt(worldDataArrayList.size())); + ChunkCoordIntPair aCoords = a.getChunkCoordIntPair(); + ChunkCoordIntPair bCoords = b.getChunkCoordIntPair(); + + double newValue = (chunkHashMap.get(aCoords).getDouble(INTENSITY) + + chunkHashMap.get(bCoords).getDouble(INTENSITY)) / 2 - SWAP_THRESHOLD / 8; + float split = TecTech.RANDOM.nextFloat(); + + chunkHashMap.get(aCoords).setDouble(INTENSITY, newValue * split); + chunkHashMap.get(bCoords).setDouble(INTENSITY, newValue * (1 - split)); + chunkHashMap.markForTransmissionToClient(aCoords); + chunkHashMap.markForTransmissionToClient(bCoords); + swapSomething(a, b, newValue); } worldDataArrayList.clear(); } for (Object o : aEvent.world.playerEntities) { if (o instanceof EntityPlayer && !((EntityPlayer) o).capabilities.isCreativeMode) { - float charge = TecTech.playerPersistence.getDataOrSetToNewTag((EntityPlayer) o).getFloat(SPACE_CHARGE); - if (charge != 0) { + if (getCharge((EntityPlayer) o) != 0) { playersWithCharge.add((EntityPlayer) o); } } @@ -94,25 +108,25 @@ public class AnomalyHandler implements IChunkMetaDataHandler { if (playersWithCharge.size() > 0) { outer: for (EntityPlayer other : playersWithCharge) { - float fieldOther = TecTech.playerPersistence.getDataOrSetToNewTag(other).getFloat(SPACE_CHARGE); + double fieldOther = getCharge(other); for (EntityPlayer player : playersWithCharge) { if (other == player) { continue outer; } - float field = TecTech.playerPersistence.getDataOrSetToNewTag(player).getFloat(SPACE_CHARGE); - float difference = Math.abs(field - fieldOther); - if (difference != 0) { + double field = getCharge(player); + double absDifference = Math.abs(field - fieldOther); + if (absDifference != 0) { if (player.getDistanceSqToEntity(other) < 1) { - float avg = (fieldOther + field) / 2; - addAnomaly(other.worldObj.provider.dimensionId, new ChunkCoordIntPair(other.chunkCoordX, other.chunkCoordZ), Math.min(SWAP_THRESHOLD, PER_PARTICLE * difference)); - other.worldObj.createExplosion(other, other.posX, other.posY, other.posZ, Math.min(CHARGE_EXPLOSIVENESS * difference, 25), true); - player.worldObj.createExplosion(player, player.posX, player.posY, player.posZ, Math.min(CHARGE_EXPLOSIVENESS * difference, 25), true); - TecTech.playerPersistence.getDataOrSetToNewTag(player).setFloat(SPACE_CHARGE, avg); - TecTech.playerPersistence.getDataOrSetToNewTag(other).setFloat(SPACE_CHARGE, avg); - TecTech.playerPersistence.saveData(player); - TecTech.playerPersistence.saveData(other); - NetworkDispatcher.INSTANCE.sendToAll(new PlayerDataMessage.PlayerDataData(player)); - NetworkDispatcher.INSTANCE.sendToAll(new PlayerDataMessage.PlayerDataData(other)); + double avg = (fieldOther + field) / 2; + //addAnomaly(other.worldObj.provider.dimensionId, new ChunkCoordIntPair(other.chunkCoordX, other.chunkCoordZ), Math.min(SWAP_THRESHOLD, PER_PARTICLE * absDifference)); + if (TecTech.configTecTech.BOOM_ENABLE) { + other.worldObj.createExplosion(other, other.posX, other.posY, other.posZ, (float) Math.min(CHARGE_EXPLOSIVENESS * absDifference, 25), true); + player.worldObj.createExplosion(player, player.posX, player.posY, player.posZ, (float) Math.min(CHARGE_EXPLOSIVENESS * absDifference, 25), true); + } + GT_Utility.sendSoundToPlayers(other.worldObj, GregTech_API.sSoundList.get(209), 1.0F, -1, (int) other.posX, (int) other.posY, (int) other.posZ); + GT_Utility.sendSoundToPlayers(player.worldObj, GregTech_API.sSoundList.get(209), 1.0F, -1, (int) player.posX, (int) player.posY, (int) player.posZ); + setCharge(player, avg); + setCharge(other, avg); } } } @@ -121,15 +135,16 @@ public class AnomalyHandler implements IChunkMetaDataHandler { } } - private void swapSomething(Chunk a,Chunk b,float power) { - for (int i = 0; i < 64; i++) { - int x = TecTech.RANDOM.nextInt(16); - int y = TecTech.RANDOM.nextInt(a.worldObj.getActualHeight()); - int z = TecTech.RANDOM.nextInt(16); + private void swapSomething(Chunk a, Chunk b, double mass) { + float explosionPower = (float) Math.log(mass / EM_COUNT_PER_MATERIAL_AMOUNT); + for (int i = 0; i < Math.min((int) explosionPower, 64); i++) { + int x = TecTech.RANDOM.nextInt(16); + int y = TecTech.RANDOM.nextInt(a.worldObj.getActualHeight()); + int z = TecTech.RANDOM.nextInt(16); Block aBlock = a.getBlock(x, y, z); Block bBlock = a.getBlock(x, y, z); - int aMeta = a.getBlockMetadata(x, y, z); - int bMeta = a.getBlockMetadata(x, y, z); + int aMeta = a.getBlockMetadata(x, y, z); + int bMeta = a.getBlockMetadata(x, y, z); if (a.getTileEntityUnsafe(x, y, z) == null && b.getTileEntityUnsafe(x, y, z) == null) { a.worldObj.setBlock((a.xPosition << 4) + x, y, (a.zPosition << 4) + z, bBlock, bMeta, 3); b.worldObj.setBlock((b.xPosition << 4) + x, y, (b.zPosition << 4) + z, aBlock, aMeta, 3); @@ -143,26 +158,28 @@ public class AnomalyHandler implements IChunkMetaDataHandler { a.worldObj.setBlockToAir((a.xPosition << 4) + x, y, (a.zPosition << 4) + z); b.worldObj.setBlockToAir((b.xPosition << 4) + x, y, (b.zPosition << 4) + z); } - if (TecTech.RANDOM.nextBoolean()) { - a.worldObj.createExplosion(null, (a.xPosition << 4) + x + .5, y + .5, (a.zPosition << 4) + z + .5, power, true); + if (TecTech.configTecTech.BOOM_ENABLE) { + if (TecTech.RANDOM.nextBoolean()) { + a.worldObj.createExplosion(null, (a.xPosition << 4) + x + .5, y + .5, (a.zPosition << 4) + z + .5, explosionPower * TecTech.RANDOM.nextFloat(), true); + } GT_Utility.sendSoundToPlayers(a.worldObj, GregTech_API.sSoundList.get(209), 1.0F, -1, (a.xPosition << 4) + x, y, (a.zPosition << 4) + z); - } - if (TecTech.RANDOM.nextBoolean()) { - b.worldObj.createExplosion(null, (b.xPosition << 4) + x + .5, y + .5, (b.zPosition << 4) + z + .5, power, true); + if (TecTech.RANDOM.nextBoolean()) { + b.worldObj.createExplosion(null, (b.xPosition << 4) + x + .5, y + .5, (b.zPosition << 4) + z + .5, explosionPower * TecTech.RANDOM.nextFloat(), true); + } GT_Utility.sendSoundToPlayers(b.worldObj, GregTech_API.sSoundList.get(209), 1.0F, -1, (b.xPosition << 4) + x, y, (b.zPosition << 4) + z); } } - int x = (b.xPosition - a.xPosition) << 4; - int z = (b.xPosition - a.xPosition) << 4; - List<EntityLivingBase> aE = a.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, Util.fromChunk(a)); - List<EntityLivingBase> bE = b.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, Util.fromChunk(b)); - aE.forEach(o -> { + int x = (b.xPosition - a.xPosition) << 4; + int z = (b.xPosition - a.xPosition) << 4; + List<EntityLivingBase> aE = a.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, TT_Utility.fromChunk(a)); + List<EntityLivingBase> bE = b.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, TT_Utility.fromChunk(b)); + for (EntityLivingBase entityLivingBase : aE) { if (TecTech.RANDOM.nextBoolean()) { - o.setPositionAndUpdate(o.posX + x, o.posY, o.posZ + z); - o.attackEntityFrom(MainLoader.subspace,8+TecTech.RANDOM.nextInt(8)); - if(o instanceof EntityPlayer){ - EntityPlayer player=((EntityPlayer) o); - if(!player.capabilities.isCreativeMode) { + if (entityLivingBase instanceof EntityPlayer) { + EntityPlayer player = ((EntityPlayer) entityLivingBase); + if (!player.capabilities.isCreativeMode) { + player.setPositionAndUpdate(entityLivingBase.posX + x, entityLivingBase.posY, entityLivingBase.posZ + z); + player.attackEntityFrom(MainLoader.subspace, 8 + TecTech.RANDOM.nextInt((int) (explosionPower / 4))); player.addPotionEffect(new PotionEffect(Potion.hunger.id, 1200)); player.addPotionEffect(new PotionEffect(Potion.weakness.id, 1000)); player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 800)); @@ -171,44 +188,43 @@ public class AnomalyHandler implements IChunkMetaDataHandler { player.addPotionEffect(new PotionEffect(Potion.poison.id, 200)); player.addPotionEffect(new PotionEffect(Potion.blindness.id, 100)); player.addPotionEffect(new PotionEffect(Potion.wither.id, 60)); - TecTech.playerPersistence.getDataOrSetToNewTag(player).setFloat(SPACE_CHARGE, - TecTech.playerPersistence.getDataOrSetToNewTag(player).getFloat(SPACE_CHARGE)-(float)Math.abs(TecTech.RANDOM.nextGaussian())); - TecTech.playerPersistence.saveData(player); - NetworkDispatcher.INSTANCE.sendToAll(new PlayerDataMessage.PlayerDataData(player)); + addCharge(player, -mass * TecTech.RANDOM.nextFloat()); } + } else { + entityLivingBase.setPositionAndUpdate(entityLivingBase.posX + x, entityLivingBase.posY, entityLivingBase.posZ + z); + entityLivingBase.attackEntityFrom(MainLoader.subspace, 8 + TecTech.RANDOM.nextInt((int) (explosionPower / 4))); } } - }); - bE.forEach(o -> { + } + for (EntityLivingBase o : bE) { if (TecTech.RANDOM.nextBoolean()) { - o.setPositionAndUpdate(o.posX - x, o.posY, o.posZ - z); - o.attackEntityFrom(MainLoader.subspace,8+TecTech.RANDOM.nextInt(8)); - if(o instanceof EntityPlayer){ - EntityPlayer player=((EntityPlayer) o); - if(!player.capabilities.isCreativeMode) { + if (o instanceof EntityPlayer) { + EntityPlayer player = ((EntityPlayer) o); + if (!player.capabilities.isCreativeMode) { + player.setPositionAndUpdate(o.posX - x, o.posY, o.posZ - z); + player.attackEntityFrom(MainLoader.subspace, 8 + TecTech.RANDOM.nextInt((int) -(explosionPower / 4))); player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 800)); player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 600)); player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 400)); player.addPotionEffect(new PotionEffect(Potion.jump.id, 200)); player.addPotionEffect(new PotionEffect(Potion.resistance.id, 100)); player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 60)); - TecTech.playerPersistence.getDataOrSetToNewTag(player).setFloat(SPACE_CHARGE, - TecTech.playerPersistence.getDataOrSetToNewTag(player).getFloat(SPACE_CHARGE)+(float)Math.abs(TecTech.RANDOM.nextGaussian())); - - TecTech.playerPersistence.saveData(player); - NetworkDispatcher.INSTANCE.sendToAll(new PlayerDataMessage.PlayerDataData(player)); + addCharge(player, mass * TecTech.RANDOM.nextFloat()); } + } else { + o.setPositionAndUpdate(o.posX + x, o.posY, o.posZ + z); + o.attackEntityFrom(MainLoader.subspace, 8 + TecTech.RANDOM.nextInt((int) (explosionPower / 4))); } } - }); + } } @Override public void tickPlayer(HashMap<Integer, ChunkDataHandler.ChunkHashMap> data, TickEvent.PlayerTickEvent aEvent) { if (aEvent.side.isClient()) { - EntityPlayer player = TecTech.proxy.getPlayer(); - ChunkCoordIntPair pair = new ChunkCoordIntPair(player.chunkCoordX, player.chunkCoordZ); - NBTTagCompound compound = data.get(player.worldObj.provider.dimensionId).get(pair); + EntityPlayer player = TecTech.proxy.getPlayer(); + ChunkCoordIntPair pair = new ChunkCoordIntPair(player.chunkCoordX, player.chunkCoordZ); + NBTTagCompound compound = data.get(player.worldObj.provider.dimensionId).get(pair); if (compound != null) { for (int i = 0, badness = (int) Math.min(COUNT_DIV, compound.getDouble(INTENSITY) / PER_PARTICLE); i < badness; i++) { TecTech.proxy.em_particle(player.worldObj, @@ -218,38 +234,36 @@ public class AnomalyHandler implements IChunkMetaDataHandler { } } - data.get(player.worldObj.provider.dimensionId).forEach((chunkCoordIntPair, dat) -> { + for (Map.Entry<ChunkCoordIntPair, NBTTagCompound> entry : data.get(player.worldObj.provider.dimensionId).entrySet()) { + ChunkCoordIntPair chunkCoordIntPair = entry.getKey(); + NBTTagCompound dat = entry.getValue(); if (Math.abs(chunkCoordIntPair.getCenterXPos() - player.posX) + Math.abs(chunkCoordIntPair.getCenterZPosition() - player.posZ) < 256) { - for (int i = 0, pow = (int) Math.min(32, dat.getDouble(INTENSITY) / PER_PARTICLE); i < pow; i++) { + for (int i = 0, pow = (int) Math.min(COUNT_DIV, dat.getDouble(INTENSITY) / PER_PARTICLE); i < pow; i++) { TecTech.proxy.em_particle(player.worldObj, chunkCoordIntPair.getCenterXPos() + TecTech.RANDOM.nextGaussian() * 32D, player.posY + TecTech.RANDOM.nextFloat() * 128D - 64D, chunkCoordIntPair.getCenterZPosition() + TecTech.RANDOM.nextGaussian() * 32D); } } - }); + } } else if (TecTech.RANDOM.nextInt(50) == 0) { - EntityPlayer player = aEvent.player; - ChunkCoordIntPair pair = new ChunkCoordIntPair(player.chunkCoordX, player.chunkCoordZ); - NBTTagCompound compound = data.get(player.worldObj.provider.dimensionId).get(pair); - NBTTagCompound playerTag = TecTech.playerPersistence.getDataOrSetToNewTag(player); - boolean saveRequired = false; - if(player.capabilities.isCreativeMode){ - if (playerTag.getDouble(SPACE_CANCER) != 0) { - playerTag.setDouble(SPACE_CANCER, 0); - saveRequired = true; - } - }else { + EntityPlayer player = aEvent.player; + ChunkCoordIntPair pair = new ChunkCoordIntPair(player.chunkCoordX, player.chunkCoordZ); + NBTTagCompound compound = data.get(player.worldObj.provider.dimensionId).get(pair); + NBTTagCompound playerTag = TecTech.playerPersistence.getDataOrSetToNewTag(player); + boolean saveRequired = false; + if (!player.capabilities.isCreativeMode) { + double cancer = getCancer(player); if (compound != null) { int badness = (int) Math.min(COUNT_DIV, compound.getDouble(INTENSITY) / PER_PARTICLE); if (badness > 0) { - playerTag.setDouble(SPACE_CANCER, Math.min(2, playerTag.getDouble(SPACE_CANCER) + 9.765625E-4f * badness)); - player.attackEntityFrom(MainLoader.subspace,Math.max(1,badness/8f)); + playerTag.setDouble(SPACE_CANCER, Math.min(2, cancer + 9.765625E-4f * badness)); + player.attackEntityFrom(MainLoader.subspace, Math.max(1, badness / 8f)); saveRequired = true; } } else if (playerTag.getDouble(SPACE_CANCER) > 0 && !player.isDead) { if (player.ticksExisted % 10 == 0) { - playerTag.setDouble(SPACE_CANCER, Math.max(0, playerTag.getDouble(SPACE_CANCER) - 7.6293945E-5f)); + playerTag.setDouble(SPACE_CANCER, Math.max(0, cancer - 7.6293945E-5f)); saveRequired = true; } } @@ -264,41 +278,67 @@ public class AnomalyHandler implements IChunkMetaDataHandler { @Override public void tickRender(HashMap<Integer, ChunkDataHandler.ChunkHashMap> data, TickEvent.RenderTickEvent aEvent) { - EntityPlayer player=TecTech.proxy.getPlayer(); - if(player!=null) { - if(!player.capabilities.isCreativeMode) { - NBTTagCompound tagCompound = TecTech.playerPersistence.getDataOrSetToNewTag(player); - if (tagCompound != null) { - float cancer = tagCompound.getFloat(SPACE_CANCER); - if (cancer > 0) { - player.setInvisible(fixMe = TecTech.RANDOM.nextFloat() * 2 < cancer); - player.setAngles((TecTech.RANDOM.nextFloat() - .5F) * 36 * cancer, (TecTech.RANDOM.nextFloat() - .5F) * 36 * cancer); - cancer*=cancer/2F; - if (cancer > 1.75f) { - player.setVelocity((TecTech.RANDOM.nextFloat() - .5F) * cancer, (TecTech.RANDOM.nextFloat() - .5F) * cancer, (TecTech.RANDOM.nextFloat() - .5F) * cancer); - } else { - player.addVelocity((TecTech.RANDOM.nextFloat() - .5F) * cancer, (TecTech.RANDOM.nextFloat() - .5F) * cancer, (TecTech.RANDOM.nextFloat() - .5F) * cancer); - } + EntityPlayer player = TecTech.proxy.getPlayer(); + if (player != null) { + if (!player.capabilities.isCreativeMode) { + double cancer = getCancer(player) * CANCER_EFFECTIVENESS; + if (cancer > 0) { + player.setInvisible(fixMe = TecTech.RANDOM.nextFloat() * 2 < cancer); + player.setAngles((TecTech.RANDOM.nextFloat() - .5F) * 36 * (float) cancer, (TecTech.RANDOM.nextFloat() - .5F) * 36 * (float) cancer); + cancer *= cancer / 2F; + if (cancer > 1.75f) { + player.setVelocity((TecTech.RANDOM.nextFloat() - .5F) * cancer, (TecTech.RANDOM.nextFloat() - .5F) * cancer, (TecTech.RANDOM.nextFloat() - .5F) * cancer); + } else { + player.addVelocity((TecTech.RANDOM.nextFloat() - .5F) * cancer, (TecTech.RANDOM.nextFloat() - .5F) * cancer, (TecTech.RANDOM.nextFloat() - .5F) * cancer); } } - float charge = TecTech.playerPersistence.getDataOrSetToNewTag(player).getFloat(SPACE_CHARGE); - if(charge!=0) { + double charge = getCharge(player); + if (charge != 0) { for (Object o : player.worldObj.playerEntities) { if (o instanceof EntityPlayer && !((EntityPlayer) o).capabilities.isCreativeMode) { - EntityPlayer otherPlayer=(EntityPlayer)o; - float chargeOther = TecTech.playerPersistence.getDataOrSetToNewTag(otherPlayer).getFloat(SPACE_CHARGE); + EntityPlayer otherPlayer = (EntityPlayer) o; + double chargeOther = getCharge(otherPlayer); if (chargeOther != 0 && player != o) { - float reaction = chargeOther * charge; - if (reaction !=0) { + double reaction = chargeOther * charge; + if (reaction != 0) { double distanceSq = otherPlayer.getDistanceSqToEntity(player); if (distanceSq >= 1) { double effect = CHARGE_EFFECTIVENESS * reaction / (distanceSq * distanceSq * distanceSq); - double dX = player.posX - otherPlayer.posX; - double dY = player.posY - otherPlayer.posY; - double dZ = player.posZ - otherPlayer.posZ; - player.addVelocity(effect * dX, effect * dY, effect * dZ); - otherPlayer.addVelocity(-effect * dX, -effect * dY, -effect * dZ); + double dX = (player.posX - otherPlayer.posX) * effect; + double dY = (player.posY - otherPlayer.posY) * effect; + double dZ = (player.posZ - otherPlayer.posZ) * effect; + player.addVelocity(dX, dY, dZ); + otherPlayer.addVelocity(-dX, -dY, -dZ); + } + } + } + } + } + } + + double mass = getMass(player); + if (mass != 0) { + for (Object o : player.worldObj.playerEntities) { + if (o instanceof EntityPlayer && !((EntityPlayer) o).capabilities.isCreativeMode) { + EntityPlayer otherPlayer = (EntityPlayer) o; + double massOther = getMass(otherPlayer); + if (massOther != 0 && player != o) { + double reaction = massOther * mass; + if (reaction != 0) { + double distanceSq = otherPlayer.getDistanceSqToEntity(player); + if (distanceSq >= 1) { + double effect = MASS_EFFECTIVENESS * reaction / (distanceSq * distanceSq * distanceSq); + double effect1 = effect / mass; + double effect2 = effect / massOther; + double[] dPos = new double[]{player.posX - otherPlayer.posX, player.posY - otherPlayer.posY, player.posZ - otherPlayer.posZ}; + double[] vel = new double[]{player.motionX, player.motionY, player.motionZ}; + double[] out = new double[3]; + crossProduct3D(dPos, vel, out); + crossProduct3D(out, dPos, vel); + normalize3D(vel,out); + player.addVelocity(effect1 * out[0], effect1 * out[1], effect1 * out[2]); + otherPlayer.addVelocity(effect2 * -out[0], effect2 * -out[1], effect2 * -out[2]); } } } @@ -306,9 +346,9 @@ public class AnomalyHandler implements IChunkMetaDataHandler { } } } - if (fixMe){ + if (fixMe) { player.setInvisible(false); - fixMe=false; + fixMe = false; } } } @@ -328,19 +368,25 @@ public class AnomalyHandler implements IChunkMetaDataHandler { return 100; } - public void addAnomaly(IGregTechTileEntity iGregTechTileEntity, double amount) { - if (iGregTechTileEntity.isServerSide()) { - World w = iGregTechTileEntity.getWorld(); + public void addAnomaly(IGregTechTileEntity gtTile, double amount) { + addAnomaly(gtTile.getWorld(), gtTile.getXCoord(), gtTile.getZCoord(), amount); + } + + public void addAnomaly(TileEntity tileEntity, double amount) { + addAnomaly(tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.zCoord, amount); + } + + public void addAnomaly(World w, int x, int z, double amount) { + if (!w.isRemote) { addAnomaly(w.provider.dimensionId, new ChunkCoordIntPair( - iGregTechTileEntity.getXCoord() >> 4, - iGregTechTileEntity.getZCoord() >> 4), + x >> 4, + z >> 4), amount); } } public void addAnomaly(int world, ChunkCoordIntPair chunk, double amount) { - amount=Math.abs(amount); NBTTagCompound old = TecTech.chunkDataHandler.getChunkData(this, world, chunk); if (old == null) { NBTTagCompound data = new NBTTagCompound(); @@ -351,4 +397,57 @@ public class AnomalyHandler implements IChunkMetaDataHandler { } TecTech.chunkDataHandler.getChunkData(this, world).markForTransmissionToClient(chunk); } + + public double getCharge(EntityPlayer player) { + return getDouble(player, SPACE_CHARGE); + } + + public void setCharge(EntityPlayer player, double amount) { + setDouble(player, SPACE_CHARGE, amount); + } + + public void addCharge(EntityPlayer player, double amount) { + addDouble(player, SPACE_CHARGE, amount); + } + + public double getMass(EntityPlayer player) { + return getDouble(player, SPACE_MASS); + } + + public void setMass(EntityPlayer player, double amount) { + setDouble(player, SPACE_MASS, amount); + } + + public void addMass(EntityPlayer player, double amount) { + addDouble(player, SPACE_MASS, amount); + } + + public double getCancer(EntityPlayer player) { + return getDouble(player, SPACE_CANCER); + } + + public void setCancer(EntityPlayer player, double amount) { + setDouble(player, SPACE_CANCER, amount); + } + + public void addCancer(EntityPlayer player, double amount) { + addDouble(player, SPACE_CANCER, amount); + } + + public double getDouble(EntityPlayer player, String name) { + return TecTech.playerPersistence.getDataOrSetToNewTag(player).getDouble(name); + } + + public void setDouble(EntityPlayer player, String name, double amount) { + TecTech.playerPersistence.getDataOrSetToNewTag(player).setDouble(name, amount); + TecTech.playerPersistence.saveData(player); + NetworkDispatcher.INSTANCE.sendToAll(new PlayerDataMessage.PlayerDataData(player)); + } + + public void addDouble(EntityPlayer player, String name, double amount) { + NBTTagCompound data = TecTech.playerPersistence.getDataOrSetToNewTag(player); + data.setDouble(name, amount + data.getDouble(name)); + TecTech.playerPersistence.saveData(player); + NetworkDispatcher.INSTANCE.sendToAll(new PlayerDataMessage.PlayerDataData(player)); + } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/anomaly/CancerCommand.java b/src/main/java/com/github/technus/tectech/mechanics/anomaly/CancerCommand.java index a153671a59..fdbd98fee0 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/anomaly/CancerCommand.java +++ b/src/main/java/com/github/technus/tectech/mechanics/anomaly/CancerCommand.java @@ -1,32 +1,34 @@ package com.github.technus.tectech.mechanics.anomaly; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.loader.NetworkDispatcher; -import com.github.technus.tectech.mechanics.data.PlayerDataMessage; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentText; import java.util.ArrayList; import java.util.List; -import static com.github.technus.tectech.mechanics.anomaly.AnomalyHandler.SPACE_CANCER; - public class CancerCommand implements ICommand { ArrayList<String> aliases=new ArrayList<>(); public CancerCommand(){ aliases.add("cancer_EM"); aliases.add("cancer"); + aliases.add("sanser_EM"); aliases.add("sanser"); + aliases.add("sancer_EM"); aliases.add("sancer"); } @Override public void processCommand(ICommandSender sender, String[] args) { if (sender instanceof EntityPlayerMP && !sender.getEntityWorld().isRemote) { + EntityPlayerMP player=(EntityPlayerMP)sender; + if(args==null || args.length==0){ + sender.addChatMessage(new ChatComponentText("Cancer amount: "+TecTech.anomalyHandler.getCancer(player))); + return; + } double amount; try { amount = Double.parseDouble(args[0]); @@ -34,18 +36,10 @@ public class CancerCommand implements ICommand { sender.addChatMessage(new ChatComponentText("Cannot parse amount!")); return; } - if(amount<0||amount>2){ - sender.addChatMessage(new ChatComponentText("Invalid amount provided!")); - return; - } - EntityPlayerMP player=(EntityPlayerMP)sender; - NBTTagCompound playerTag = TecTech.playerPersistence.getDataOrSetToNewTag(player); if(player.capabilities.isCreativeMode){ sender.addChatMessage(new ChatComponentText("Doesn't really work in creative mode!")); }else { - playerTag.setDouble(SPACE_CANCER, amount); - TecTech.playerPersistence.saveData(player); - NetworkDispatcher.INSTANCE.sendTo(new PlayerDataMessage.PlayerDataData(player), player); + TecTech.anomalyHandler.setCancer(player,amount); sender.addChatMessage(new ChatComponentText("Cancer set to: "+amount)); } } @@ -73,7 +67,7 @@ public class CancerCommand implements ICommand { @Override public String getCommandUsage(ICommandSender p_71518_1_) { - return "cancer_EM [Amount 0.0-2.0]"; + return "cancer_EM [Amount]"; } @Override diff --git a/src/main/java/com/github/technus/tectech/mechanics/anomaly/ChargeCommand.java b/src/main/java/com/github/technus/tectech/mechanics/anomaly/ChargeCommand.java index da365a92f8..b486b73295 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/anomaly/ChargeCommand.java +++ b/src/main/java/com/github/technus/tectech/mechanics/anomaly/ChargeCommand.java @@ -1,19 +1,14 @@ package com.github.technus.tectech.mechanics.anomaly; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.loader.NetworkDispatcher; -import com.github.technus.tectech.mechanics.data.PlayerDataMessage; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentText; import java.util.ArrayList; import java.util.List; -import static com.github.technus.tectech.mechanics.anomaly.AnomalyHandler.SPACE_CHARGE; - public class ChargeCommand implements ICommand { ArrayList<String> aliases=new ArrayList<>(); @@ -25,6 +20,11 @@ public class ChargeCommand implements ICommand { @Override public void processCommand(ICommandSender sender, String[] args) { if (sender instanceof EntityPlayerMP && !sender.getEntityWorld().isRemote) { + EntityPlayerMP player=(EntityPlayerMP)sender; + if(args==null || args.length==0){ + sender.addChatMessage(new ChatComponentText("Charge amount: "+TecTech.anomalyHandler.getCharge(player))); + return; + } double amount; try { amount = Double.parseDouble(args[0]); @@ -32,14 +32,10 @@ public class ChargeCommand implements ICommand { sender.addChatMessage(new ChatComponentText("Cannot parse amount!")); return; } - EntityPlayerMP player=(EntityPlayerMP)sender; - NBTTagCompound playerTag = TecTech.playerPersistence.getDataOrSetToNewTag(player); if(player.capabilities.isCreativeMode){ sender.addChatMessage(new ChatComponentText("Doesn't really work in creative mode!")); }else { - playerTag.setDouble(SPACE_CHARGE, amount); - TecTech.playerPersistence.saveData(player); - NetworkDispatcher.INSTANCE.sendToAll(new PlayerDataMessage.PlayerDataData(player)); + TecTech.anomalyHandler.setCharge(player,amount); sender.addChatMessage(new ChatComponentText("Charge set to: "+amount)); } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/anomaly/MassCommand.java b/src/main/java/com/github/technus/tectech/mechanics/anomaly/MassCommand.java new file mode 100644 index 0000000000..05bba9433b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/anomaly/MassCommand.java @@ -0,0 +1,81 @@ +package com.github.technus.tectech.mechanics.anomaly; + +import com.github.technus.tectech.TecTech; +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.util.ChatComponentText; + +import java.util.ArrayList; +import java.util.List; + +public class MassCommand implements ICommand { + ArrayList<String> aliases=new ArrayList<>(); + + public MassCommand(){ + aliases.add("mass_EM"); + aliases.add("mass"); + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + if (sender instanceof EntityPlayerMP && !sender.getEntityWorld().isRemote) { + EntityPlayerMP player=(EntityPlayerMP)sender; + if(args==null || args.length==0){ + sender.addChatMessage(new ChatComponentText("Msdd amount: "+TecTech.anomalyHandler.getMass(player))); + return; + } + double amount; + try { + amount = Double.parseDouble(args[0]); + }catch (NumberFormatException e){ + sender.addChatMessage(new ChatComponentText("Cannot parse amount!")); + return; + } + if(player.capabilities.isCreativeMode){ + sender.addChatMessage(new ChatComponentText("Doesn't really work in creative mode!")); + }else { + TecTech.anomalyHandler.setMass(player,amount); + sender.addChatMessage(new ChatComponentText("Mass set to: "+amount)); + } + } + } + + @Override + public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_) { + return false; + } + + @Override + public List<String> getCommandAliases() { + return aliases; + } + + @Override + public String getCommandName() { + return aliases.get(0); + } + + @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args) { + return null; + } + + @Override + public String getCommandUsage(ICommandSender p_71518_1_) { + return "mass_EM [Amount]"; + } + + @Override + public int compareTo(Object o) { + if(o instanceof ICommand){ + return getCommandName().compareTo(((ICommand) o).getCommandName()); + } + return 0; + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender sender) { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/commands/ConvertFloat.java b/src/main/java/com/github/technus/tectech/mechanics/commands/ConvertFloat.java index 5885226f6f..ff515ab7d3 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/commands/ConvertFloat.java +++ b/src/main/java/com/github/technus/tectech/mechanics/commands/ConvertFloat.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.mechanics.commands; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.TT_Utility; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.util.ChatComponentText; @@ -25,7 +25,7 @@ public class ConvertFloat implements ICommand { float value=Float.parseFloat(args[0]); sender.addChatMessage(new ChatComponentText( EnumChatFormatting.AQUA.toString()+ EnumChatFormatting.BOLD + - Util.intBitsToShortString(Float.floatToIntBits(value))+" "+ + TT_Utility.intBitsToShortString(Float.floatToIntBits(value))+" "+ EnumChatFormatting.RESET+EnumChatFormatting.BLUE +value)); }catch (Exception e){ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"Invalid Float "+args[0])); diff --git a/src/main/java/com/github/technus/tectech/mechanics/commands/ConvertInteger.java b/src/main/java/com/github/technus/tectech/mechanics/commands/ConvertInteger.java index 41edd66684..37651e7478 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/commands/ConvertInteger.java +++ b/src/main/java/com/github/technus/tectech/mechanics/commands/ConvertInteger.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.mechanics.commands; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.TT_Utility; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.util.ChatComponentText; @@ -25,7 +25,7 @@ public class ConvertInteger implements ICommand { int value=Integer.parseInt(args[0]); sender.addChatMessage(new ChatComponentText( EnumChatFormatting.AQUA.toString()+ EnumChatFormatting.BOLD + - Util.intBitsToShortString(value)+" "+ + TT_Utility.intBitsToShortString(value)+" "+ EnumChatFormatting.RESET+EnumChatFormatting.BLUE +value)); }catch (Exception e){ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"Invalid Integer "+args[0])); diff --git a/src/main/java/com/github/technus/tectech/mechanics/constructable/ConstructableUtility.java b/src/main/java/com/github/technus/tectech/mechanics/constructable/ConstructableUtility.java deleted file mode 100644 index 6d605eef6e..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/constructable/ConstructableUtility.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.github.technus.tectech.mechanics.constructable; - -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.alignment.IAlignment; -import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.util.FakePlayer; -import net.minecraftforge.common.util.ForgeDirection; - -@Deprecated -public class ConstructableUtility { - private ConstructableUtility(){ - - } - - public static boolean handle(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if(tTileEntity==null || aPlayer instanceof FakePlayer) { - return aPlayer instanceof EntityPlayerMP; - } - if (aPlayer instanceof EntityPlayerMP) { - //struct gen - if (aPlayer.isSneaking() && aPlayer.capabilities.isCreativeMode) { - if (tTileEntity instanceof IGregTechTileEntity) { - IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); - if (metaTE instanceof IConstructable) { - ((IConstructable) metaTE).construct(aStack, false); - } else if (IMultiblockInfoContainer.contains(metaTE.getClass())) { - IMultiblockInfoContainer<IMetaTileEntity> iMultiblockInfoContainer =IMultiblockInfoContainer.get(metaTE.getClass()); - if(metaTE instanceof IAlignment){ - iMultiblockInfoContainer.construct(aStack, false, metaTE, ( - (IAlignment) metaTE).getExtendedFacing()); - }else { - iMultiblockInfoContainer.construct(aStack, false, metaTE, - ExtendedFacing.of(ForgeDirection.getOrientation(((IGregTechTileEntity) tTileEntity).getFrontFacing()))); - } - } - } else if (tTileEntity instanceof IConstructable) { - ((IConstructable) tTileEntity).construct(aStack, false); - } else if (IMultiblockInfoContainer.contains(tTileEntity.getClass())) { - IMultiblockInfoContainer<TileEntity> iMultiblockInfoContainer =IMultiblockInfoContainer.get(tTileEntity.getClass()); - if(tTileEntity instanceof IAlignment){ - iMultiblockInfoContainer.construct(aStack, false, tTileEntity, - ((IAlignment) tTileEntity).getExtendedFacing()); - }else { - iMultiblockInfoContainer.construct(aStack, false, tTileEntity, - ExtendedFacing.of(ForgeDirection.getOrientation(aSide))); - } - } - } - return true; - }else if (TecTech.proxy.isThePlayer(aPlayer)){//particles and text client side - //if ((!aPlayer.isSneaking() || !aPlayer.capabilities.isCreativeMode)) { - if(tTileEntity instanceof IGregTechTileEntity) { - IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); - if (metaTE instanceof IConstructable) { - ((IConstructable) metaTE).construct(aStack, true); - TecTech.proxy.printInchat(((IConstructable) metaTE).getStructureDescription(aStack)); - return false; - } else if(IMultiblockInfoContainer.contains(metaTE.getClass())){ - IMultiblockInfoContainer<IMetaTileEntity> iMultiblockInfoContainer =IMultiblockInfoContainer.get(metaTE.getClass()); - if(metaTE instanceof IAlignment){ - iMultiblockInfoContainer.construct(aStack, true, metaTE, - ((IAlignment) metaTE).getExtendedFacing()); - }else { - iMultiblockInfoContainer.construct(aStack, true, metaTE, - ExtendedFacing.of(ForgeDirection.getOrientation(((IGregTechTileEntity) tTileEntity).getFrontFacing()))); - } - TecTech.proxy.printInchat(IMultiblockInfoContainer.get(metaTE.getClass()).getDescription(aStack)); - return false; - } - } else if(tTileEntity instanceof IConstructable){ - ((IConstructable) tTileEntity).construct(aStack,true); - TecTech.proxy.printInchat(((IConstructable) tTileEntity).getStructureDescription(aStack)); - return false; - } else if(IMultiblockInfoContainer.contains(tTileEntity.getClass())){ - IMultiblockInfoContainer<TileEntity> iMultiblockInfoContainer = IMultiblockInfoContainer.get(tTileEntity.getClass()); - if(tTileEntity instanceof IAlignment){ - iMultiblockInfoContainer.construct(aStack, true, tTileEntity, - ((IAlignment) tTileEntity).getExtendedFacing()); - }else { - iMultiblockInfoContainer.construct(aStack, true, tTileEntity, - ExtendedFacing.of(ForgeDirection.getOrientation(aSide))); - } - TecTech.proxy.printInchat(IMultiblockInfoContainer.get(tTileEntity.getClass()).getDescription(aStack)); - return false; - } - //} else { - // if(tTileEntity instanceof IGregTechTileEntity) { - // IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); - // if (metaTE instanceof IConstructable) { - // TecTech.proxy.printInchat(((IConstructable) metaTE).getStructureDescription(aStack.stackSize)); - // return false; - // } else if(multiblockMap.containsKey(metaTE.getClass().getCanonicalName())){ - // TecTech.proxy.printInchat(multiblockMap.get(metaTE.getClass().getCanonicalName()).getDescription(aStack.stackSize)); - // return false; - // } - // } else if(tTileEntity instanceof IConstructable){ - // TecTech.proxy.printInchat(((IConstructable) tTileEntity).getStructureDescription(aStack.stackSize)); - // return false; - // } else if(multiblockMap.containsKey(tTileEntity.getClass().getCanonicalName())){ - // TecTech.proxy.printInchat(multiblockMap.get(tTileEntity.getClass().getCanonicalName()).getDescription(aStack.stackSize)); - // return false; - // } - //} - } - return false; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/constructable/IConstructable.java b/src/main/java/com/github/technus/tectech/mechanics/constructable/IConstructable.java deleted file mode 100644 index ed0cdfbf7d..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/constructable/IConstructable.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.github.technus.tectech.mechanics.constructable; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.item.ItemStack; - -/** - * Created by Tec on 24.03.2017. - */ -@Deprecated -public interface IConstructable { - void construct(ItemStack stackSize, boolean hintsOnly); - - @SideOnly(Side.CLIENT) - String[] getStructureDescription(ItemStack stackSize); -} - diff --git a/src/main/java/com/github/technus/tectech/mechanics/constructable/IMultiblockInfoContainer.java b/src/main/java/com/github/technus/tectech/mechanics/constructable/IMultiblockInfoContainer.java deleted file mode 100644 index da124fcf4d..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/constructable/IMultiblockInfoContainer.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.github.technus.tectech.mechanics.constructable; - -import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; - -import java.util.HashMap; - -/** - * To implement IConstructable on not own TileEntities - */ -@Deprecated -public interface IMultiblockInfoContainer<T> { - HashMap<String, IMultiblockInfoContainer<?>> MULTIBLOCK_MAP = new HashMap<>(); - - static <T extends TileEntity> void registerTileClass(Class<T> clazz, IMultiblockInfoContainer<?> info){ - MULTIBLOCK_MAP.put(clazz.getCanonicalName(),info); - } - - static <T extends IMetaTileEntity> void registerMetaClass(Class<T> clazz, IMultiblockInfoContainer<?> info){ - MULTIBLOCK_MAP.put(clazz.getCanonicalName(),info); - } - - @SuppressWarnings("unchecked") - static <T> IMultiblockInfoContainer<T> get(Class<?> tClass){ - return (IMultiblockInfoContainer<T>)MULTIBLOCK_MAP.get(tClass.getCanonicalName()); - } - - static boolean contains(Class<?> tClass){ - return MULTIBLOCK_MAP.containsKey(tClass.getCanonicalName()); - } - - void construct(ItemStack stackSize, boolean hintsOnly, T tileEntity, ExtendedFacing aSide); - - @SideOnly(Side.CLIENT) - String[] getDescription(ItemStack stackSize); -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/data/ChunkDataMessage.java b/src/main/java/com/github/technus/tectech/mechanics/data/ChunkDataMessage.java index 6094d08ba4..216c4057ef 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/data/ChunkDataMessage.java +++ b/src/main/java/com/github/technus/tectech/mechanics/data/ChunkDataMessage.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.mechanics.data; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.MessageContext; @@ -80,7 +80,7 @@ public class ChunkDataMessage implements IMessage { public static class ClientHandler extends AbstractClientMessageHandler<ChunkDataData> { @Override public IMessage handleClientMessage(EntityPlayer pPlayer, ChunkDataData pMessage, MessageContext pCtx) { - if(Util.checkChunkExist(pPlayer.worldObj,pMessage.chunk)){ + if(TT_Utility.checkChunkExist(pPlayer.worldObj,pMessage.chunk)){ TecTech.chunkDataHandler.putChunkData(pMessage.handler, pMessage.worldId,pMessage.chunk, pMessage.data); } return null; diff --git a/src/main/java/com/github/technus/tectech/mechanics/data/PlayerPersistence.java b/src/main/java/com/github/technus/tectech/mechanics/data/PlayerPersistence.java index f69bccc871..b31b1a6b76 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/data/PlayerPersistence.java +++ b/src/main/java/com/github/technus/tectech/mechanics/data/PlayerPersistence.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.mechanics.data; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.loader.NetworkDispatcher; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent; import net.minecraft.entity.player.EntityPlayer; @@ -32,7 +32,7 @@ public class PlayerPersistence { if(tag!=null){ return tag; } - tag=Util.getPlayerData(uuid1,uuid2,extension); + tag= TT_Utility.getPlayerData(uuid1,uuid2,extension); if(tag==null){ tag=new NBTTagCompound(); } @@ -58,7 +58,7 @@ public class PlayerPersistence { } public void saveData(EntityPlayer player){ - Util.savePlayerFile(player,extension,getDataOrSetToNewTag(player)); + TT_Utility.savePlayerFile(player,extension,getDataOrSetToNewTag(player)); } @SubscribeEvent diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/README b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/README index f6c0b35e5f..c774b126c8 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/README +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/README @@ -41,4 +41,7 @@ Trees: InstanceStack - inst stack |||||multiple to 1 - InstanceStackTree - inst container - real things go here
\ No newline at end of file + InstanceStackTree - inst container - real things go here + + Preset for world: + 2;7,16x22,16x35:11,16x35:3,16x35;0;
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/EMException.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/EMException.java new file mode 100644 index 0000000000..d607dfad73 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/EMException.java @@ -0,0 +1,22 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core; + +/** + * Created by danie_000 on 19.11.2016. + */ +public final class EMException extends RuntimeException { + public EMException(String message) { + super(message); + } + + public EMException(String message, Throwable cause) { + super(message, cause); + } + + public EMException(Throwable cause) { + super(cause); + } + + public EMException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/IEMContainer.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/IEMContainer.java new file mode 100644 index 0000000000..d731078988 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/IEMContainer.java @@ -0,0 +1,12 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core; + +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; + +/** + * Created by danie_000 on 25.01.2017. + */ +public interface IEMContainer { + EMInstanceStackMap getContentHandler(); + + void purgeOverflow(); +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecay.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecay.java deleted file mode 100644 index e67f773a86..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecay.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core; - -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; - -import static com.github.technus.tectech.util.DoubleCount.add; - -/** - * Created by danie_000 on 22.10.2016. - */ -public final class cElementalDecay { - public static final cElementalDecay[] noDecay = null; - //DECAY IMPOSSIBLE!!! - //Do not use regular NULL java will not make it work with varargs!!! - //Or cast null into ARRAY type but this static is more convenient!!! - public static final cElementalDecay[] noProduct = new cElementalDecay[0]; - //this in turn can be used to tell that the thing should just vanish - public final cElementalDefinitionStackMap outputStacks; - public final double probability; - - public cElementalDecay(iElementalDefinition... outSafe) { - this(1D, outSafe); - } - - public cElementalDecay(double probability, iElementalDefinition... outSafe) { - cElementalDefinitionStack[] outArr = new cElementalDefinitionStack[outSafe.length]; - for (int i = 0; i < outArr.length; i++) { - outArr[i] = new cElementalDefinitionStack(outSafe[i], 1D); - } - outputStacks = new cElementalDefinitionStackMap(outArr); - this.probability = probability; - } - - public cElementalDecay(cElementalDefinitionStack... outSafe) { - this(1D, outSafe); - } - - public cElementalDecay(double probability, cElementalDefinitionStack... out) { - outputStacks = new cElementalDefinitionStackMap(out); - this.probability = probability; - } - - public cElementalDecay(cElementalDefinitionStackMap tree) { - this(1D, tree); - } - - public cElementalDecay(double probability, cElementalDefinitionStackMap tree) { - outputStacks = tree; - this.probability = probability; - } - - public cElementalInstanceStackMap getResults(double lifeMult, double age, long energyTotalForProducts, double amountDecaying) { - cElementalInstanceStackMap decayResult = new cElementalInstanceStackMap(); - if (outputStacks == null) { - return decayResult;//This is to prevent null pointer exceptions. - } - //Deny decay code is in instance! - double qtty = 0D; - for (cElementalDefinitionStack stack : outputStacks.values()) { - qtty= add(qtty,stack.amount); - } - if (qtty <= 0D) { - return decayResult; - } - //energyTotalForProducts /= qtty; - //lifeMult /= (float) qtty; - for (cElementalDefinitionStack stack : outputStacks.values()) { - decayResult.putUnify(new cElementalInstanceStack(stack.definition, - amountDecaying * stack.amount, - lifeMult, age/*new products*/, (long)(energyTotalForProducts / Math.max(1D, Math.abs(stack.amount)))));//get instances from stack - } - return decayResult; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDefinitionStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDefinitionStackMap.java deleted file mode 100644 index ce0840bc8b..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDefinitionStackMap.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core; - -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.TreeMap; - -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.cPrimitiveDefinition.nbtE__; - -/** - * Created by Tec on 12.05.2017. - */ -public final class cElementalDefinitionStackMap/*IMMUTABLE*/ extends cElementalStackMap {//Target class for construction of definitions/recipes - //Constructors + Clone, all make a whole new OBJ. - public static final cElementalDefinitionStackMap EMPTY = new cElementalDefinitionStackMap(); - - private cElementalDefinitionStackMap() { - map = new TreeMap<>(); - } - - @Deprecated - public cElementalDefinitionStackMap(iElementalDefinition... in) { - map=new cElementalMutableDefinitionStackMap(in).map; - } - - public cElementalDefinitionStackMap(cElementalDefinitionStack... in) { - map=new cElementalMutableDefinitionStackMap(in).map; - } - - public cElementalDefinitionStackMap(TreeMap<iElementalDefinition, cElementalDefinitionStack> in) { - map = new TreeMap<>(in); - } - - cElementalDefinitionStackMap(cElementalMutableDefinitionStackMap unsafeMap){ - map=unsafeMap.map; - } - - //IMMUTABLE DON'T NEED IT - @Override - public cElementalDefinitionStackMap clone() { - return this; - } - - public cElementalMutableDefinitionStackMap toMutable() { - return new cElementalMutableDefinitionStackMap(map); - } - - @Override - @Deprecated//BETTER TO JUST MAKE A MUTABLE VERSION AND DO SHIT ON IT - public TreeMap<iElementalDefinition, cElementalDefinitionStack> getRawMap() { - return toMutable().getRawMap(); - } - - public static cElementalDefinitionStackMap fromNBT(NBTTagCompound nbt) throws tElementalException { - cElementalDefinitionStack[] defStacks = new cElementalDefinitionStack[nbt.getInteger("i")]; - for (int i = 0; i < defStacks.length; i++) { - defStacks[i] = cElementalDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); - if (defStacks[i].definition.equals(nbtE__)) { - throw new tElementalException("Something went Wrong"); - } - } - return new cElementalDefinitionStackMap(defStacks); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalInstanceStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalInstanceStackMap.java deleted file mode 100644 index e1fdc6a553..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalInstanceStackMap.java +++ /dev/null @@ -1,565 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core; - -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.iHasElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; - -import java.util.*; - -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT_UNCERTAINTY; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.cPrimitiveDefinition.nbtE__; -import static com.github.technus.tectech.util.DoubleCount.add; -import static com.github.technus.tectech.util.DoubleCount.sub; - -/** - * Created by danie_000 on 22.01.2017. - */ -public final class cElementalInstanceStackMap implements Comparable<cElementalInstanceStackMap> { - TreeMap<iElementalDefinition, cElementalInstanceStack> map; - - //Constructors - public cElementalInstanceStackMap() { - map = new TreeMap<>(); - } - - public cElementalInstanceStackMap(cElementalInstanceStack... inSafe) { - this(true, inSafe); - } - - public cElementalInstanceStackMap(boolean clone, cElementalInstanceStack... in) { - map = new TreeMap<>(); - if (clone) { - cElementalInstanceStack[] stacks=new cElementalInstanceStack[in.length]; - for(int i=0;i<stacks.length;i++) { - stacks[i] = in[i].clone(); - } - putUnifyAll(stacks); - } else { - putUnifyAll(in); - } - } - - @Deprecated - private cElementalInstanceStackMap(TreeMap<iElementalDefinition, cElementalInstanceStack> inSafe) { - this(true, inSafe); - } - - @Deprecated - private cElementalInstanceStackMap(boolean clone, TreeMap<iElementalDefinition, cElementalInstanceStack> in) { - if (clone) { - map = new TreeMap<>(); - for(cElementalInstanceStack stack:in.values()) { - putUnify(stack.clone()); - } - } else { - map = in; - } - } - - public cElementalInstanceStackMap(cElementalInstanceStackMap inSafe) { - this(true, inSafe.map); - } - - public cElementalInstanceStackMap(boolean copy, cElementalInstanceStackMap in) { - this(copy, in.map); - } - - @Override - public cElementalInstanceStackMap clone() { - return new cElementalInstanceStackMap(map); - } - - public cElementalMutableDefinitionStackMap toDefinitionMapForComparison() { - cElementalDefinitionStack[] list = new cElementalDefinitionStack[map.size()]; - int i = 0; - for (cElementalInstanceStack stack : map.values()) { - list[i++] = new cElementalDefinitionStack(stack.definition, stack.amount); - } - return new cElementalMutableDefinitionStackMap(list); - } - - //@Deprecated - //public cElementalStackMap toDefinitionMap(boolean mutable) { - // TreeMap<iElementalDefinition, cElementalDefinitionStack> newMap = new TreeMap<>(); - // for (cElementalInstanceStack stack : map.values()) { - // newMap.put(stack.definition, new cElementalDefinitionStack(stack.definition, stack.amount)); - // } - // if (mutable) { - // return new cElementalMutableDefinitionStackMap(newMap); - // } - // return new cElementalDefinitionStackMap(newMap); - //} - - @Deprecated - public Map<iElementalDefinition, cElementalInstanceStack> getRawMap() { - return map; - } - - public Set<Map.Entry<iElementalDefinition, cElementalInstanceStack>> getEntrySet() { - return map.entrySet(); - } - - - //Removers - public void clear() { - map.clear(); - } - - public cElementalInstanceStack remove(iElementalDefinition def) { - return map.remove(def); - } - - @Deprecated - public cElementalInstanceStack remove(iHasElementalDefinition has) { - return map.remove(has.getDefinition()); - } - - public void removeAll(iElementalDefinition... definitions) { - for (iElementalDefinition def : definitions) { - map.remove(def); - } - } - - @Deprecated - private void removeAll(iHasElementalDefinition... hasElementalDefinition) { - for (iHasElementalDefinition has : hasElementalDefinition) { - map.remove(has.getDefinition()); - } - } - - //Remove amounts - public boolean removeAmount(boolean testOnly, cElementalInstanceStack instance) { - cElementalInstanceStack target = map.get(instance.definition); - if (target == null) { - return false; - } - if (testOnly) { - return target.amount >= instance.amount; - } else { - double diff = sub(target.amount,instance.amount); - if (diff > 0) { - target.amount = diff; - return true; - } else if (diff == 0) { - map.remove(instance.definition); - return true; - } - } - return false; - } - - public boolean removeAmount(boolean testOnly, iHasElementalDefinition stack) { - cElementalInstanceStack target = map.get(stack.getDefinition()); - if (target == null) { - return false; - } - if (testOnly) { - return target.amount >= stack.getAmount(); - } else { - double diff = sub(target.amount,stack.getAmount()); - if (diff > 0) { - target.amount = diff; - return true; - } else if (diff == 0) { - map.remove(stack.getDefinition()); - return true; - } - } - return false; - } - - @Deprecated - public boolean removeAmount(boolean testOnly, iElementalDefinition def) { - return removeAmount(testOnly, new cElementalDefinitionStack(def, 1D)); - } - - public boolean removeAllAmounts(boolean testOnly, cElementalInstanceStack... instances) { - boolean test = true; - for (cElementalInstanceStack stack : instances) { - test &= removeAmount(true, stack); - } - if (testOnly || !test) { - return test; - } - for (cElementalInstanceStack stack : instances) { - removeAmount(false, stack); - } - return true; - } - - public boolean removeAllAmounts(boolean testOnly, iHasElementalDefinition... stacks) { - boolean test = true; - for (iHasElementalDefinition stack : stacks) { - test &= removeAmount(true, stack); - } - if (testOnly || !test) { - return test; - } - for (iHasElementalDefinition stack : stacks) { - removeAmount(false, stack); - } - return true; - } - - @Deprecated - public boolean removeAllAmounts(boolean testOnly, iElementalDefinition... definitions) { - cElementalDefinitionStack[] stacks = new cElementalDefinitionStack[definitions.length]; - for (int i = 0; i < stacks.length; i++) { - stacks[i] = new cElementalDefinitionStack(definitions[i], 1); - } - return removeAllAmounts(testOnly, stacks); - } - - public boolean removeAllAmounts(boolean testOnly, cElementalStackMap container) { - boolean test=true; - for (Map.Entry<iElementalDefinition, cElementalDefinitionStack> entry : container.map.entrySet()) { - test &= removeAmount(true, entry.getValue()); - } - if (testOnly || !test) { - return test; - } - for (Map.Entry<iElementalDefinition, cElementalDefinitionStack> entry : container.map.entrySet()) { - removeAmount(false, entry.getValue()); - } - return true; - } - - public boolean removeAllAmounts(boolean testOnly, cElementalInstanceStackMap container) { - boolean test=true; - for (Map.Entry<iElementalDefinition, cElementalInstanceStack> entry : container.map.entrySet()) { - test &= removeAmount(true, entry.getValue()); - } - if (testOnly || !test) { - return test; - } - for (Map.Entry<iElementalDefinition, cElementalInstanceStack> entry : container.map.entrySet()) { - test &= removeAmount(false, entry.getValue()); - } - return true; - } - - //Remove overflow - public double removeOverflow(int stacksCount, double stackCapacity) { - double massRemoved = 0; - - if (map.size() > stacksCount) { - iElementalDefinition[] keys = keys(); - for (int i = stacksCount; i < keys.length; i++) { - massRemoved += map.get(keys[i]).getDefinitionStack().getMass(); - map.remove(keys[i]); - } - } - - for (cElementalInstanceStack instance : values()) { - if (instance.amount > stackCapacity) { - massRemoved += instance.definition.getMass() * (instance.amount - stackCapacity); - instance.amount = stackCapacity; - } - } - return massRemoved; - } - - //Put replace - public cElementalInstanceStack putReplace(cElementalInstanceStack instanceUnsafe) { - return map.put(instanceUnsafe.definition, instanceUnsafe); - } - - public void putReplaceAll(cElementalInstanceStack... instances) { - for (cElementalInstanceStack instance : instances) { - map.put(instance.definition, instance); - } - } - - private void putReplaceAll(Map<iElementalDefinition, cElementalInstanceStack> inTreeUnsafe) { - map.putAll(inTreeUnsafe); - } - - public void putReplaceAll(cElementalInstanceStackMap inContainerUnsafe) { - putReplaceAll(inContainerUnsafe.map); - } - - //Put unify - public cElementalInstanceStack putUnify(cElementalInstanceStack instance) { - cElementalInstanceStack stack=map.get(instance.definition); - if(stack==null) { - return map.put(instance.definition, instance); - } - return map.put(instance.definition, stack.unifyIntoThis(instance)); - } - - public void putUnifyAll(cElementalInstanceStack... instances) { - for (cElementalInstanceStack instance : instances) { - putUnify(instance); - } - } - - private void putUnifyAll(Map<iElementalDefinition, cElementalInstanceStack> inTreeUnsafe) { - for (cElementalInstanceStack in : inTreeUnsafe.values()) { - putUnify(in); - } - } - - public void putUnifyAll(cElementalInstanceStackMap containerUnsafe) { - putUnifyAll(containerUnsafe.map); - } - - //Getters - public cElementalInstanceStack getFirst(){ - return map.firstEntry().getValue(); - } - - public cElementalInstanceStack getLast(){ - return map.lastEntry().getValue(); - } - - public cElementalInstanceStack getInstance(iElementalDefinition def) { - return map.get(def); - } - - public cElementalInstanceStack get(int i){ - Collection<cElementalInstanceStack> var = map.values(); - return var.toArray(new cElementalInstanceStack[0])[i]; - } - - public String[] getShortSymbolsInfo() { - String[] info = new String[map.size()]; - int i = 0; - for (cElementalInstanceStack instance : map.values()) { - info[i++] = instance.definition.getShortSymbol(); - } - return info; - } - - public String[] getElementalInfo() { - String[] info = new String[map.size()]; - int i = 0; - for (cElementalInstanceStack instance : map.values()) { - info[i++] = EnumChatFormatting.BLUE + instance.definition.getName()+ - " "+ EnumChatFormatting.AQUA + instance.definition.getSymbol()+ EnumChatFormatting.RESET+ - " #: " + EnumChatFormatting.GREEN + String.format("%.3E",instance.amount/ AVOGADRO_CONSTANT) +" mol"+ EnumChatFormatting.RESET+ - " E: " + EnumChatFormatting.GREEN + instance.getEnergy() + EnumChatFormatting.RESET+ - " T: " + EnumChatFormatting.GREEN + (instance.getLifeTime()<0?"STABLE":String.format("%.3E",instance.getLifeTime())); - } - return info; - } - - public ArrayList<String> getScanShortSymbols(int[] capabilities) { - ArrayList<String> list=new ArrayList<>(16); - for(Map.Entry<iElementalDefinition,cElementalInstanceStack> e:map.entrySet()){ - e.getValue().addScanShortSymbols(list,capabilities); - } - return list; - } - - public ArrayList<String> getScanInfo(int[] capabilities) { - ArrayList<String> list=new ArrayList<>(16); - for(Map.Entry<iElementalDefinition,cElementalInstanceStack> e:map.entrySet()){ - e.getValue().addScanResults(list,capabilities); - } - return list; - } - - public cElementalInstanceStack[] values() { - Collection<cElementalInstanceStack> var = map.values(); - return var.toArray(new cElementalInstanceStack[0]); - } - - public iElementalDefinition[] keys() { - Set<iElementalDefinition> var = map.keySet(); - return var.toArray(new iElementalDefinition[0]); - } - - public double getMass() { - double mass = 0; - for (cElementalInstanceStack stack : map.values()) { - mass += stack.getMass(); - } - return mass; - } - - public double getCharge() { - double charge = 0; - for (cElementalInstanceStack stack : map.values()) { - charge += stack.getCharge(); - } - return charge; - } - - public double getCountOfAllAmounts(){ - double sum=0; - for(cElementalInstanceStack stack:map.values()){ - sum= add(sum,stack.amount); - } - return sum; - } - - //Tests - public boolean containsDefinition(iElementalDefinition def) { - return map.containsKey(def); - } - - public boolean containsInstance(cElementalInstanceStack inst) { - return map.containsValue(inst); - } - - public int size() { - return map.size(); - } - - public boolean hasStacks() { - return !map.isEmpty(); - } - - public boolean isEmpty(){ - return map.isEmpty(); - } - - //Tick Content - public double tickContentByOneSecond(double lifeTimeMult, int postEnergize) { - return tickContent(lifeTimeMult,postEnergize,1D); - } - - public double tickContent(double lifeTimeMult, int postEnergize, double seconds){ - cleanUp(); - double diff=0; - for (cElementalInstanceStack instance : values()) { - cElementalDecayResult newInstances = instance.decay(lifeTimeMult, instance.age += seconds, postEnergize); - if (newInstances == null) { - instance.nextColor(); - } else { - diff=add(diff,newInstances.getMassDiff()); - removeAmount(false,instance); - putUnifyAll(newInstances.getOutput()); - } - } - return diff; - } - - //NBT - public NBTTagCompound getShortSymbolsNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - String[] info = getShortSymbolsInfo(); - nbt.setInteger("i", info.length); - for (int i = 0; i < info.length; i++) { - nbt.setString(Integer.toString(i), info[i]); - } - return nbt; - } - - public NBTTagCompound getInfoNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - String[] info = getElementalInfo(); - nbt.setInteger("i", info.length); - for (int i = 0; i < info.length; i++) { - nbt.setString(Integer.toString(i), info[i]); - } - return nbt; - } - - public NBTTagCompound getScanShortSymbolsNBT(int[] capabilities) { - NBTTagCompound nbt = new NBTTagCompound(); - ArrayList<String> info = getScanShortSymbols(capabilities); - nbt.setInteger("i", info.size()); - for (int i = 0; i < info.size(); i++) { - nbt.setString(Integer.toString(i), info.get(i)); - } - return nbt; - } - - public NBTTagCompound getScanInfoNBT(int[] capabilities) { - NBTTagCompound nbt = new NBTTagCompound(); - ArrayList<String> info = getScanInfo(capabilities); - nbt.setInteger("i", info.size()); - for (int i = 0; i < info.size(); i++) { - nbt.setString(Integer.toString(i), info.get(i)); - } - return nbt; - } - - public NBTTagCompound toNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setInteger("i", map.size()); - int i = 0; - for (cElementalInstanceStack instance : map.values()) { - nbt.setTag(Integer.toString(i++), instance.toNBT()); - } - return nbt; - } - - public static cElementalInstanceStackMap fromNBT(NBTTagCompound nbt) throws tElementalException { - cElementalInstanceStack[] instances = new cElementalInstanceStack[nbt.getInteger("i")]; - for (int i = 0; i < instances.length; i++) { - instances[i] = cElementalInstanceStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); - if (instances[i].definition.equals(nbtE__)) { - throw new tElementalException("Something went Wrong"); - } - } - return new cElementalInstanceStackMap(false, instances); - } - - //stackUp - public static cElementalInstanceStack[] stackUp(cElementalInstanceStack... in) { - cElementalInstanceStackMap inTree = new cElementalInstanceStackMap(); - inTree.putUnifyAll(in); - return inTree.values(); - } - - @Override - public int compareTo(cElementalInstanceStackMap o) { - int sizeDiff = map.size() - o.map.size(); - if (sizeDiff != 0) { - return sizeDiff; - } - cElementalInstanceStack[] ofThis = values(), ofThat = o.values(); - for (int i = 0; i < ofThat.length; i++) { - int result = ofThis[i].compareTo(ofThat[i]); - if (result != 0) { - return result; - } - } - return 0; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof cElementalInstanceStackMap) { - return compareTo((cElementalInstanceStackMap) obj) == 0; - } - if (obj instanceof cElementalStackMap) { - return toDefinitionMapForComparison().compareTo((cElementalStackMap) obj) == 0; - } - return false; - } - - @Override - public int hashCode() {//Hash only definitions to compare contents not amounts or data - int hash = -(map.size() << 4); - for (cElementalInstanceStack stack : map.values()) { - hash += stack.definition.hashCode(); - } - return hash; - } - - @Override - public String toString() { - StringBuilder build=new StringBuilder("Instance Stack Map\n"); - for(cElementalInstanceStack stack:map.values()){ - build.append(stack.toString()).append('\n'); - } - return build.toString(); - } - - public cElementalInstanceStackMap takeAllToNewMap(){ - TreeMap<iElementalDefinition, cElementalInstanceStack> map=this.map; - this.map=new TreeMap<>(); - return new cElementalInstanceStackMap(map); - } - - public void cleanUp(){ - map.entrySet().removeIf(entry -> entry.getValue().amount < AVOGADRO_CONSTANT_UNCERTAINTY); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalMutableDefinitionStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalMutableDefinitionStackMap.java deleted file mode 100644 index 020f5a5f8c..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalMutableDefinitionStackMap.java +++ /dev/null @@ -1,278 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core; - -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.iHasElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.Map; -import java.util.TreeMap; - -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.cPrimitiveDefinition.nbtE__; -import static com.github.technus.tectech.util.DoubleCount.sub; - -/** - * Created by danie_000 on 22.01.2017. - */ -public final class cElementalMutableDefinitionStackMap extends cElementalStackMap {//Transient class for construction of definitions/recipes - //Constructors + Clone, all make a whole new OBJ. - public cElementalMutableDefinitionStackMap() { - map = new TreeMap<>(); - } - - @Deprecated - public cElementalMutableDefinitionStackMap(iElementalDefinition... in) { - map=new TreeMap<>(); - for (iElementalDefinition def : in) { - putUnify(new cElementalDefinitionStack(def, 1)); - } - } - - public cElementalMutableDefinitionStackMap(cElementalDefinitionStack... in) { - map=new TreeMap<>(); - putUnifyAll(in); - } - - public cElementalMutableDefinitionStackMap(TreeMap<iElementalDefinition, cElementalDefinitionStack> in) { - this(true, in); - } - - public cElementalMutableDefinitionStackMap(boolean clone, TreeMap<iElementalDefinition, cElementalDefinitionStack> in) { - if (clone) { - map = new TreeMap<>(in); - } else { - map = in; - } - } - - @Override - public cElementalMutableDefinitionStackMap clone() { - return new cElementalMutableDefinitionStackMap(map); - } - - public cElementalDefinitionStackMap toImmutable() { - return new cElementalDefinitionStackMap(map); - } - public cElementalDefinitionStackMap toImmutable_optimized_unsafeLeavesExposedElementalTree() { - return new cElementalDefinitionStackMap(this); - } - - @Override - @Deprecated - public TreeMap<iElementalDefinition, cElementalDefinitionStack> getRawMap() { - return map; - } - - - //Removers - public void clear() { - map.clear(); - } - - public cElementalDefinitionStack remove(iElementalDefinition def) { - return map.remove(def); - } - - @Deprecated - public cElementalDefinitionStack remove(iHasElementalDefinition has) { - return map.remove(has.getDefinition()); - } - - public void removeAll(iElementalDefinition... definitions) { - for (iElementalDefinition def : definitions) { - map.remove(def); - } - } - - @Deprecated - public void removeAll(iHasElementalDefinition... hasElementalDefinition) { - for (iHasElementalDefinition has : hasElementalDefinition) { - map.remove(has.getDefinition()); - } - } - - //Remove amounts - public boolean removeAmount(boolean testOnly, cElementalInstanceStack instance) { - cElementalDefinitionStack target = map.get(instance.definition); - if (target == null) { - return false; - } - if (testOnly) { - return target.amount >= instance.amount; - } else { - double diff = sub(target.amount,instance.amount); - if (diff > 0) { - map.put(target.definition, new cElementalDefinitionStack(target.definition, diff)); - return true; - } else if (diff == 0) { - map.remove(instance.definition); - return true; - } - } - return false; - } - - public boolean removeAmount(boolean testOnly, iHasElementalDefinition stack) { - cElementalDefinitionStack target = map.get(stack.getDefinition()); - if (target == null) { - return false; - } - if (testOnly) { - return target.amount >= stack.getAmount(); - } else { - double diff = sub(target.amount,stack.getAmount()); - if (diff > 0) { - map.put(target.definition, new cElementalDefinitionStack(target.definition, diff)); - return true; - } else if (diff == 0) { - map.remove(stack.getDefinition()); - return true; - } - } - return false; - } - - @Deprecated - public boolean removeAmount(boolean testOnly, iElementalDefinition def) { - return removeAmount(testOnly, new cElementalDefinitionStack(def, 1)); - } - - public boolean removeAllAmounts(boolean testOnly, cElementalInstanceStack... instances) { - boolean test = true; - for (cElementalInstanceStack stack : instances) { - test &= removeAmount(true, stack); - } - if (testOnly || !test) { - return test; - } - for (cElementalInstanceStack stack : instances) { - removeAmount(false, stack); - } - return true; - } - - public boolean removeAllAmounts(boolean testOnly, iHasElementalDefinition... stacks) { - boolean test = true; - for (iHasElementalDefinition stack : stacks) { - test &= removeAmount(true, stack); - } - if (testOnly || !test) { - return test; - } - for (iHasElementalDefinition stack : stacks) { - removeAmount(false, stack); - } - return true; - } - - @Deprecated - public boolean removeAllAmounts(boolean testOnly, iElementalDefinition... definitions) { - cElementalDefinitionStack[] stacks = new cElementalDefinitionStack[definitions.length]; - for (int i = 0; i < stacks.length; i++) { - stacks[i] = new cElementalDefinitionStack(definitions[i], 1); - } - return removeAllAmounts(testOnly, stacks); - } - - public boolean removeAllAmounts(boolean testOnly, cElementalStackMap container) { - boolean test=true; - for (Map.Entry<iElementalDefinition, cElementalDefinitionStack> entry : container.map.entrySet()) { - test &= removeAmount(true, entry.getValue()); - } - if (testOnly || !test) { - return test; - } - for (Map.Entry<iElementalDefinition, cElementalDefinitionStack> entry : container.map.entrySet()) { - removeAmount(false, entry.getValue()); - } - return true; - } - - public boolean removeAllAmounts(boolean testOnly, cElementalInstanceStackMap container) { - boolean test=true; - for (Map.Entry<iElementalDefinition, cElementalInstanceStack> entry : container.map.entrySet()) { - test &= removeAmount(true, entry.getValue()); - } - if (testOnly || !test) { - return test; - } - for (Map.Entry<iElementalDefinition, cElementalInstanceStack> entry : container.map.entrySet()) { - test &= removeAmount(false, entry.getValue()); - } - return true; - } - - //Put replace - public cElementalDefinitionStack putReplace(cElementalDefinitionStack defStackUnsafe) { - return map.put(defStackUnsafe.definition, defStackUnsafe); - } - - public void putReplaceAll(cElementalDefinitionStack... defStacks) { - for (cElementalDefinitionStack defStack : defStacks) { - map.put(defStack.definition, defStack); - } - } - - public void putReplaceAll(cElementalStackMap inContainerUnsafe) { - map.putAll(inContainerUnsafe.map); - } - - //Put unify - public cElementalDefinitionStack putUnify(cElementalDefinitionStack def) { - cElementalDefinitionStack stack=map.get(def.definition); - if(stack==null) { - return map.put(def.definition, def); - } - return map.put(def.definition, stack.addAmountIntoNewInstance(def.amount)); - } - - @Deprecated - public cElementalDefinitionStack putUnify(iElementalDefinition def) { - return putUnify(new cElementalDefinitionStack(def, 1)); - } - - public void putUnifyAll(cElementalDefinitionStack... defs) { - for (cElementalDefinitionStack def : defs) { - putUnify(def); - } - } - - @Deprecated - public void putUnifyAll(iElementalDefinition... defs) { - for (iElementalDefinition def : defs) { - putUnify(def); - } - } - - private void putUnifyAll(Map<iElementalDefinition, cElementalDefinitionStack> inTreeUnsafe) { - for (cElementalDefinitionStack in : inTreeUnsafe.values()) { - putUnify(in); - } - } - - public void putUnifyAll(cElementalStackMap containerUnsafe) { - for (cElementalDefinitionStack in : containerUnsafe.map.values()) { - putUnify(in); - } - } - - public static cElementalMutableDefinitionStackMap fromNBT(NBTTagCompound nbt) throws tElementalException { - cElementalDefinitionStack[] defStacks = new cElementalDefinitionStack[nbt.getInteger("i")]; - for (int i = 0; i < defStacks.length; i++) { - defStacks[i] = cElementalDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); - if (defStacks[i].definition.equals(nbtE__)) { - throw new tElementalException("Something went Wrong"); - } - } - return new cElementalMutableDefinitionStackMap(defStacks); - } - - public void cleanUp(){ - for(Map.Entry<iElementalDefinition, cElementalDefinitionStack> entry:map.entrySet()){ - if(entry.getValue().amount<=0) { - map.remove(entry.getKey()); - } - } - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalStackMap.java deleted file mode 100644 index f8e7aa39e4..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalStackMap.java +++ /dev/null @@ -1,181 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core; - -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; - -import java.util.Collection; -import java.util.Set; -import java.util.TreeMap; - -import static com.github.technus.tectech.util.DoubleCount.add; - -/** - * Created by Tec on 12.05.2017. - */ -abstract class cElementalStackMap implements Comparable<cElementalStackMap> { - protected TreeMap<iElementalDefinition, cElementalDefinitionStack> map; - - @Override - public abstract cElementalStackMap clone(); - - @Deprecated - public abstract TreeMap<iElementalDefinition, cElementalDefinitionStack> getRawMap(); - - //Getters - public final cElementalDefinitionStack getFirst(){ - return map.firstEntry().getValue(); - } - - public final cElementalDefinitionStack getLast(){ - return map.lastEntry().getValue(); - } - - public final cElementalDefinitionStack getDefinitionStack(iElementalDefinition def) { - return map.get(def); - } - - public String[] getShortSymbolsInfo() { - String[] info = new String[map.size()]; - int i = 0; - for (cElementalDefinitionStack instance : map.values()) { - info[i++] = instance.definition.getShortSymbol(); - } - return info; - } - - public final String[] getElementalInfo() { - String[] info = new String[map.size() * 3]; - int i = 0; - for (cElementalDefinitionStack defStack : map.values()) { - info[i] = EnumChatFormatting.BLUE + defStack.definition.getName(); - info[i + 1] = EnumChatFormatting.AQUA + defStack.definition.getSymbol(); - info[i + 2] = "Amount " + EnumChatFormatting.GREEN + defStack.amount; - i += 3; - } - return info; - } - - public final cElementalDefinitionStack[] values() { - Collection<cElementalDefinitionStack> var = map.values(); - return var.toArray(new cElementalDefinitionStack[0]); - } - - public final iElementalDefinition[] keys() { - Set<iElementalDefinition> var = map.keySet(); - return var.toArray(new iElementalDefinition[0]); - } - - public double getCountOfAllAmounts(){ - double sum=0; - for(cElementalDefinitionStack stack:map.values()){ - sum= add(sum,stack.amount); - } - return sum; - } - - //Tests - public final boolean containsDefinition(iElementalDefinition def) { - return map.containsKey(def); - } - - public final boolean containsDefinitionStack(cElementalDefinitionStack inst) { - return map.containsValue(inst); - } - - public final int size() { - return map.size(); - } - - public final boolean hasStacks() { - return !map.isEmpty(); - } - - public final boolean isEmpty(){ - return map.isEmpty(); - } - - //NBT - public final NBTTagCompound getShortSymbolsNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - String[] info = getShortSymbolsInfo(); - nbt.setInteger("i", info.length); - for (int i = 0; i < info.length; i++) { - nbt.setString(Integer.toString(i), info[i]); - } - return nbt; - } - - public final NBTTagCompound getInfoNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - String[] info = getElementalInfo(); - nbt.setInteger("i", info.length); - for (int i = 0; i < info.length; i++) { - nbt.setString(Integer.toString(i), info[i]); - } - return nbt; - } - - public final NBTTagCompound toNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setInteger("i", map.size()); - int i = 0; - for (cElementalDefinitionStack defStack : map.values()) { - nbt.setTag(Integer.toString(i++), defStack.toNBT()); - } - return nbt; - } - - @Override - public final int compareTo(cElementalStackMap o) {//this actually compares rest - int sizeDiff = map.size() - o.map.size(); - if (sizeDiff != 0) { - return sizeDiff; - } - cElementalDefinitionStack[] ofThis = values(), ofO = o.values(); - for (int i = 0; i < ofO.length; i++) { - int result = ofThis[i].compareTo(ofO[i]); - if (result != 0) { - return result; - } - } - return 0; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof cElementalStackMap) { - return compareTo((cElementalStackMap) obj) == 0; - } - if (obj instanceof cElementalInstanceStackMap) { - return compareTo(((cElementalInstanceStackMap) obj).toDefinitionMapForComparison()) == 0; - } - return false; - } - - @Override - public final int hashCode() {//Hash only definitions to compare contents not amounts or data - int hash = -(map.size() << 4); - for (cElementalDefinitionStack stack : map.values()) { - hash += stack.definition.hashCode(); - } - return hash; - } - - public double getMass(){ - double mass=0; - for(cElementalDefinitionStack stack:map.values()){ - mass+=stack.getMass(); - } - return mass; - } - - public long getCharge(){ - long charge=0; - for(cElementalDefinitionStack stack:map.values()){ - charge+=stack.getCharge(); - } - return charge; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/EMGive.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/EMGive.java new file mode 100644 index 0000000000..eed30a7974 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/EMGive.java @@ -0,0 +1,143 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.commands; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMIndirectType; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMDefinitionStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; +import com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM; +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChatComponentText; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * Created by danie_000 on 30.12.2017. + */ +public class EMGive implements ICommand { + ArrayList<String> aliases = new ArrayList<>(); + + public EMGive() { + aliases.add("em_give"); + aliases.add("give_em"); + aliases.add("gib_em"); + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + if (sender instanceof EntityPlayerMP && !sender.getEntityWorld().isRemote) { + if (args.length < 3) { + sender.addChatMessage(new ChatComponentText(getCommandUsage(sender))); + } else { + TecTech.LOGGER.info("Spawninig EM for " + ((EntityPlayerMP) sender).getDisplayName() + " - " + Arrays.toString(args)); + + ArrayList<String> list = new ArrayList<>(Arrays.asList(args)); + String energy = list.remove(0); + + EMDefinitionStack def = getDefinitionStack(TecTech.definitionsRegistry, list); + if (def != null) { + EMInstanceStack instanceStack = new EMInstanceStack(def, 1, 0, Long.parseLong(energy)); + + sender.addChatMessage(new ChatComponentText(instanceStack.getDefinition().getSymbol() + " - " + instanceStack.getDefinition().getLocalizedName())); + + EMInstanceStackMap instanceMap = new EMInstanceStackMap(instanceStack); + + ItemStack itemStack = new ItemStack(DebugElementalInstanceContainer_EM.INSTANCE); + DebugElementalInstanceContainer_EM.INSTANCE.setContent(itemStack, instanceMap); + + ((EntityPlayerMP) sender).inventory.addItemStackToInventory(itemStack); + } + } + } + } + + private EMDefinitionStack getDefinitionStack(EMDefinitionsRegistry registry, ArrayList<String> args) { + double amount; + if (args.size() == 0) { + return null; + } + String defTag = args.remove(0); + if ("<".equals(defTag)) { + return null; + } + try { + amount = Double.parseDouble(defTag); + if (args.size() == 0) { + return null; + } + defTag = args.remove(0); + if ("<".equals(defTag)) { + return null; + } + } catch (Exception e) { + amount = 1; + } + IEMDefinition definition = registry.getDirectBinds().get(defTag); + if (definition != null) { + return definition.getStackForm(amount); + } + EMIndirectType emIndirectType = registry.getIndirectBinds().get(defTag); + if (emIndirectType != null) { + EMDefinitionStackMap stacks = new EMDefinitionStackMap(); + while (args.size() > 0) { + EMDefinitionStack definitionStack = getDefinitionStack(registry, args); + if (definitionStack == null) { + break; + } else { + stacks.putUnifyExact(definitionStack); + } + } + return emIndirectType.create(registry, stacks.toNBT(registry)).getStackForm(amount); + } + return null; + } + + @Override + public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_) { + return false; + } + + @Override + public List<String> getCommandAliases() { + return aliases; + } + + @Override + public String getCommandName() { + return aliases.get(0); + } + + @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args) { + if (args.length > 2 && args.length % 2 == 1) { + return new ArrayList<>(TecTech.definitionsRegistry.getBinds().keySet()); + } + return null; + } + + @Override + public String getCommandUsage(ICommandSender p_71518_1_) { + return "em_give Energy Count ClassOrId ( (Count ClassOrId ... <) ...<)"; + } + + @Override + public int compareTo(Object o) { + if (o instanceof ICommand) { + return getCommandName().compareTo(((ICommand) o).getCommandName()); + } + return 0; + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender sender) { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/EMList.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/EMList.java new file mode 100644 index 0000000000..0f71a24d82 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/EMList.java @@ -0,0 +1,96 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.commands; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMType; +import com.github.technus.tectech.util.TT_Utility; +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentText; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Created by danie_000 on 30.12.2017. + */ +public class EMList implements ICommand { + ArrayList<String> aliases=new ArrayList<>(); + + public EMList(){ + aliases.add("em_list"); + aliases.add("list_em"); + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + if (!sender.getEntityWorld().isRemote) { + if(args.length == 0) { + listClasses(sender); + }else { + String concated = TT_Utility.getConcated(args, " "); + listDefinitions(sender,concated, concated.replaceAll(" ","_"),concated.replaceAll("_"," ")); + } + } + } + + private void listDefinitions(ICommandSender sender,String raw, String unlocalized,String localized) { + sender.addChatMessage(new ChatComponentText(" Available Direct: tag - name symbol")); + for (EMType directType : TecTech.definitionsRegistry.getDirectTypes().values()) { + if ("*".equals(raw) || localized.equalsIgnoreCase(directType.getLocalizedName()) || unlocalized.equalsIgnoreCase(directType.getUnlocalizedName())) { + directType.getDefinitions().forEach((bind, definition) -> + sender.addChatMessage(new ChatComponentText(bind + " - " + definition.getLocalizedName() + " " + definition.getSymbol()))); + } + } + } + + private void listClasses(ICommandSender sender) { + sender.addChatMessage(new ChatComponentText(" Available Direct: name (use as parameter to learn more")); + TecTech.definitionsRegistry.getDirectTypes().forEach((aClass, emDirectType) -> + sender.addChatMessage(new ChatComponentText(emDirectType.getLocalizedName()))); + sender.addChatMessage(new ChatComponentText(" Available Indirect: tag - name")); + TecTech.definitionsRegistry.getIndirectBinds().forEach((bind, emIndirectType) -> + sender.addChatMessage(new ChatComponentText(bind+" - "+emIndirectType.getLocalizedName()))); + } + + @Override + public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_) { + return false; + } + + @Override + public List<String> getCommandAliases() { + return aliases; + } + + @Override + public String getCommandName() { + return aliases.get(0); + } + + @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args) { + if(args.length==1){ + return TecTech.definitionsRegistry.getDirectTypes().values().stream().map(EMType::getLocalizedName).map(s->s.replaceAll(" ","_")).collect(Collectors.toList()); + } + return null; + } + + @Override + public String getCommandUsage(ICommandSender p_71518_1_) { + return "em_list (optional Direct Name or *)"; + } + + @Override + public int compareTo(Object o) { + if(o instanceof ICommand){ + return getCommandName().compareTo(((ICommand) o).getCommandName()); + } + return 0; + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender sender) { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/GiveEM.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/GiveEM.java deleted file mode 100644 index 912d44ff43..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/GiveEM.java +++ /dev/null @@ -1,160 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core.commands; - -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalMutableDefinitionStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalPrimitive; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; -import com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM; -import net.minecraft.command.ICommand; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ChatComponentText; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.cPrimitiveDefinition.nbtE__; - -/** - * Created by danie_000 on 30.12.2017. - */ -public class GiveEM implements ICommand { - ArrayList<String> aliases=new ArrayList<>(); - - public GiveEM(){ - aliases.add("em_give"); - aliases.add("give_em"); - aliases.add("gib_em"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - if (sender instanceof EntityPlayerMP && !sender.getEntityWorld().isRemote) { - if(args.length < 3) { - sender.addChatMessage(new ChatComponentText(getCommandUsage(sender))); - }else{ - TecTech.LOGGER.info("Spawninig EM for "+((EntityPlayerMP) sender).getDisplayName()+" - "+Arrays.toString(args)); - - ArrayList<String> list = new ArrayList<>(Arrays.asList(args)); - String energy=list.remove(0); - - cElementalDefinitionStack def= getDefinitionStack(list); - if(def!=null) { - cElementalInstanceStack instanceStack = new cElementalInstanceStack(def, 1D, 0D, Long.parseLong(energy)); - - sender.addChatMessage(new ChatComponentText(instanceStack.definition.getSymbol() + " - " + instanceStack.definition.getName())); - - cElementalInstanceStackMap instanceMap = new cElementalInstanceStackMap(instanceStack); - - ItemStack itemStack = new ItemStack(DebugElementalInstanceContainer_EM.INSTANCE); - NBTTagCompound contents = new NBTTagCompound(); - contents.setTag("info", instanceMap.getInfoNBT()); - contents.setTag("content", instanceMap.toNBT()); - itemStack.setTagCompound(contents); - - ((EntityPlayerMP) sender).inventory.addItemStackToInventory(itemStack); - } - } - } - } - - private cElementalDefinitionStack getDefinitionStack(ArrayList<String> args){ - if(args.get(0).equals("<")){ - args.remove(0); - return null; - } - double amount=Double.parseDouble(args.remove(0)); - try{ - int id=Integer.parseInt(args.get(0)); - args.remove(0); - iElementalDefinition primitive=cElementalPrimitive.getBindsPrimitive().get(id); - return new cElementalDefinitionStack(primitive,amount); - }catch (NumberFormatException e){ - byte clazz = (byte) args.remove(0).charAt(0); - Method constructor = cElementalDefinition.getBindsComplex().get(clazz); - - cElementalMutableDefinitionStackMap stacks=new cElementalMutableDefinitionStackMap(); - while(args.size()>0){ - cElementalDefinitionStack tempStack=getDefinitionStack(args); - if(tempStack==null) { - break; - }else { - stacks.putUnify(tempStack); - } - } - - try { - return ((iElementalDefinition) constructor.invoke(null, stacks.toNBT())).getStackForm(amount); - } catch (Exception e1) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return nbtE__.getStackForm(amount); - } - } - } - - @Override - public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_) { - return false; - } - - @Override - public List<String> getCommandAliases() { - return aliases; - } - - @Override - public String getCommandName() { - return aliases.get(0); - } - - @Override - public List<String> addTabCompletionOptions(ICommandSender sender, String[] args) { - if(args.length==2){ - return completionsForClassOrID(); - } - return null; - } - - private List<String> completionsForClassOrID(){ - ArrayList<String> strings=new ArrayList<>(8); - Map<Byte,Method> binds= cElementalDefinition.getBindsComplex(); - for (Map.Entry<Byte,Method> e:binds.entrySet()) { - strings.add(String.valueOf((char)e.getKey().byteValue())); - } - Map<Integer, cElementalPrimitive> bindsBO = cElementalPrimitive.getBindsPrimitive(); - for (Map.Entry<Integer,cElementalPrimitive> e:bindsBO.entrySet()) { - strings.add(String.valueOf(e.getKey().byteValue())); - } - return strings; - } - - @Override - public String getCommandUsage(ICommandSender p_71518_1_) { - return "em_give Energy Count ClassOrId (Count ClassOrId ... <)"; - } - - @Override - public int compareTo(Object o) { - if(o instanceof ICommand){ - return getCommandName().compareTo(((ICommand) o).getCommandName()); - } - return 0; - } - - @Override - public boolean canCommandSenderUseCommand(ICommandSender sender) { - return true; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/ListEM.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/ListEM.java deleted file mode 100644 index 20110c0b0d..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/ListEM.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core.commands; - -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalPrimitive; -import net.minecraft.command.ICommand; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.ChatComponentText; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * Created by danie_000 on 30.12.2017. - */ -public class ListEM implements ICommand { - ArrayList<String> aliases=new ArrayList<>(); - - public ListEM(){ - aliases.add("em_list"); - aliases.add("list_em"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - if (!sender.getEntityWorld().isRemote) { - if(args.length == 0) { - sender.addChatMessage(new ChatComponentText(" Available Classes: tag - name")); - Map<Byte,Method> binds= cElementalDefinition.getBindsComplex(); - for (Map.Entry<Byte,Method> e:binds.entrySet()) { - sender.addChatMessage(new ChatComponentText((char) e.getKey().byteValue() +" - "+e.getValue().getReturnType().getSimpleName())); - } - }else if(args.length==1){ - sender.addChatMessage(new ChatComponentText(" Available Primitives: symbol - name")); - if(args[0].equals(String.valueOf((char)cElementalPrimitive.nbtType))){ - Map<Integer, cElementalPrimitive> bindsBO = cElementalPrimitive.getBindsPrimitive(); - for (Map.Entry<Integer,cElementalPrimitive> e:bindsBO.entrySet()) { - sender.addChatMessage(new ChatComponentText(e.getKey() + " - "+e.getValue().getName())); - } - }else{ - sender.addChatMessage(new ChatComponentText("Complex definition - needs contents")); - } - }else{ - sender.addChatMessage(new ChatComponentText(getCommandUsage(sender))); - } - } - } - - @Override - public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_) { - return false; - } - - @Override - public List<String> getCommandAliases() { - return aliases; - } - - @Override - public String getCommandName() { - return aliases.get(0); - } - - @Override - public List<String> addTabCompletionOptions(ICommandSender sender, String[] args) { - if(args.length==0){ - Map<Byte,Method> binds= cElementalDefinition.getBindsComplex(); - ArrayList<String> strings=new ArrayList<>(binds.size()); - for (Map.Entry<Byte,Method> e:binds.entrySet()) { - strings.add(String.valueOf((char)e.getKey().byteValue())+' '+e.getValue().getReturnType().getSimpleName()); - } - return strings; - } - return null; - } - - @Override - public String getCommandUsage(ICommandSender p_71518_1_) { - return "em_list (optional class tag)"; - } - - @Override - public int compareTo(Object o) { - if(o instanceof ICommand){ - return getCommandName().compareTo(((ICommand) o).getCommandName()); - } - return 0; - } - - @Override - public boolean canCommandSenderUseCommand(ICommandSender sender) { - return true; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/decay/EMDecay.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/decay/EMDecay.java new file mode 100644 index 0000000000..dfd1551c49 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/decay/EMDecay.java @@ -0,0 +1,90 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.decay; + +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; + +import static com.github.technus.tectech.util.DoubleCount.mul; + +/** + * Created by danie_000 on 22.10.2016. + */ +public final class EMDecay { + public static final EMDecay[] NO_DECAY = null; + //DECAY IMPOSSIBLE!!! + //Do not use regular NULL java will not make it work with varargs!!! + //Or cast null into ARRAY type but this static is more convenient!!! + public static final EMDecay[] NO_PRODUCT = new EMDecay[0]; + //this in turn can be used to tell that the thing should just vanish + private final EMConstantStackMap outputStacks; + private final double probability; + + public EMDecay(IEMDefinition... outSafe) { + this(1D, outSafe); + } + + public EMDecay(double probability, IEMDefinition... outSafe) { + EMDefinitionStack[] outArr = new EMDefinitionStack[outSafe.length]; + for (int i = 0; i < outArr.length; i++) { + outArr[i] = new EMDefinitionStack(outSafe[i], 1D); + } + outputStacks = new EMConstantStackMap(outArr); + this.probability = probability; + } + + public EMDecay(EMDefinitionStack... outSafe) { + this(1D, outSafe); + } + + public EMDecay(double probability, EMDefinitionStack... out) { + outputStacks = new EMConstantStackMap(out); + this.probability = probability; + } + + public EMDecay(EMConstantStackMap tree) { + this(1D, tree); + } + + public EMDecay(double probability, EMConstantStackMap tree) { + outputStacks = tree; + this.probability = probability; + } + + public EMInstanceStackMap getResults(double lifeMult, double age, long newEnergyLevel, double amountDecaying) { + EMInstanceStackMap decayResult = new EMInstanceStackMap(); + if (getOutputStacks() == null) { + return decayResult;//This is to prevent null pointer exceptions. + } + //Deny decay code is in instance! + boolean empty=true; + for (EMDefinitionStack stack : getOutputStacks().valuesToArray()) { + if(stack.getAmount() >0){ + empty=false; + break; + } + } + if (empty) { + return decayResult; + } + //newEnergyLevel /= qtty; + //lifeMult /= (float) qtty; + for (EMDefinitionStack stack : getOutputStacks().valuesToArray()) { + decayResult.putUnify(new EMInstanceStack(stack.getDefinition(), + mul(amountDecaying, stack.getAmount()), + lifeMult, + age/*new products*/, + (long)(newEnergyLevel / Math.max(1D, Math.abs(stack.getAmount())))));//get instances from stack + } + return decayResult; + } + + public EMConstantStackMap getOutputStacks() { + return outputStacks; + } + + public double getProbability() { + return probability; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecayResult.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/decay/EMDecayResult.java index 4ca63d14fe..0a00a519f9 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecayResult.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/decay/EMDecayResult.java @@ -1,22 +1,25 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core; +package com.github.technus.tectech.mechanics.elementalMatter.core.decay; -public class cElementalDecayResult { - private final cElementalInstanceStackMap output; - private double massAffected; - private double massDiff; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; - public cElementalDecayResult(cElementalInstanceStackMap output, double massAffected, double massDiff) { +public class EMDecayResult { + private final EMInstanceStackMap output; + private double massAffected; + private double massDiff; + + public EMDecayResult(EMInstanceStackMap output, double massAffected, double massDiff) { this.output = output; this.massAffected = massAffected; this.massDiff = massDiff; } - public cElementalInstanceStackMap getOutput() { + public EMInstanceStackMap getOutput() { return output; } /** * How much was lost in the process (decayed or removed) + * * @return */ public double getMassAffected() { @@ -25,6 +28,7 @@ public class cElementalDecayResult { /** * Difference of mass of actually decayed elements + * * @return */ public double getMassDiff() { diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMComplexTemplate.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMComplexTemplate.java new file mode 100644 index 0000000000..be22092163 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMComplexTemplate.java @@ -0,0 +1,67 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.definitions; + +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; +import net.minecraft.nbt.NBTTagCompound; + +/** + * Created by danie_000 on 23.01.2017. + */ +public abstract class EMComplexTemplate implements IEMDefinition { + /** + * Just empty array? + */ + public static final IEMDefinition[] nothing = new EMPrimitiveTemplate[0]; + + @Override + public final EMComplexTemplate clone() { + return this;//IMMUTABLE + } + + @Override + public int compareTo(IEMDefinition o) { + int classCompare = compareClassID(o); + if (classCompare != 0) { + return classCompare; + } + //that allows neat check if the same thing and + //top hierarchy amount can be used to store amount info + return getSubParticles().compareWithAmountsInternal(o.getSubParticles()); + } + + @Override + public final boolean equals(Object obj) { + if(this==obj) { + return true; + } + if (obj instanceof IEMDefinition) { + return compareTo((IEMDefinition) obj) == 0; + } + if (obj instanceof IEMStack) { + return compareTo(((IEMStack) obj).getDefinition()) == 0; + } + return false; + } + + @Override + public int hashCode() {//Internal amounts should be also hashed + int hash = -(getSubParticles().size() << 16); + for (EMDefinitionStack stack : getSubParticles().valuesToArray()) { + int amount=(int) stack.getAmount(); + hash += ((amount & 0x1) == 0 ? -amount : amount) * (stack.getDefinition().hashCode()<<4); + } + return hash; + } + + @Override + public String toString() { + return getLocalizedName()+ " " + getSymbol(); + } + + public NBTTagCompound toNBT(EMDefinitionsRegistry registry) { + return registry.indirectToNBT(getTagValue(),getSubParticles()); + } + + protected abstract String getTagValue(); +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMPrimitiveTemplate.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMPrimitiveTemplate.java new file mode 100644 index 0000000000..272e7cffc0 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMPrimitiveTemplate.java @@ -0,0 +1,197 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.definitions; + +import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; +import net.minecraft.nbt.NBTTagCompound; + +import static net.minecraft.util.StatCollector.translateToLocal; + +/** + * Created by danie_000 on 22.10.2016. + * EXTEND THIS TO ADD NEW PRIMITIVES, WATCH OUT FOR ID'S!!! + */ +public abstract class EMPrimitiveTemplate extends EMComplexTemplate { + private final String name; + private final String symbol; + //float-mass in eV/c^2 + private final double mass; + //int -electric charge in 1/3rds of electron charge for optimization + private final int charge; + //byte color; 0=Red 1=Green 2=Blue 0=Cyan 1=Magenta 2=Yellow, else ignored (-1 - uncolorable) + private final int color; + //-1/-2/-3 anti matter generations, +1/+2/+3 matter generations, 0 self anti + private final int generation; + + private IEMDefinition anti;//IMMUTABLE + private EMDecay[] elementalDecays; + private byte naturalDecayInstant; + private byte energeticDecayInstant; + private double rawLifeTime; + + private final int ID; + private final String bind; + + //no _ at end - normal particle + // _ at end - anti particle + // __ at end - self is antiparticle + + protected EMPrimitiveTemplate(String name, String symbol, int generation, double mass, int charge, int color, int ID, String bind) { + this.name = name; + this.symbol = symbol; + this.generation = generation; + this.mass = mass; + this.charge = charge; + this.color = color; + this.ID = ID; + this.bind=bind; + } + + // + protected void init(EMDefinitionsRegistry registry,IEMDefinition antiParticle, double rawLifeTime, int naturalInstant, int energeticInstant, EMDecay... elementalDecaysArray) { + anti = antiParticle; + this.rawLifeTime = rawLifeTime; + naturalDecayInstant = (byte) naturalInstant; + energeticDecayInstant = (byte) energeticInstant; + elementalDecays =elementalDecaysArray; + registry.registerForDisplay(this); + registry.registerDirectDefinition(bind,this); + } + + @Override + public String getSymbol() { + return symbol; + } + + @Override + public String getShortSymbol() { + return getSymbol(); + } + + @Override + public String getShortLocalizedName() { + return translateToLocal(getUnlocalizedName()); + } + + @Override + public IEMDefinition getAnti() { + return anti;//no need for copy + } + + @Override + public int getCharge() { + return charge; + } + + @Override + public int getMaxColors() { + return color; + } + + @Override + public double getMass() { + return mass; + } + + @Override + public EMDecay[] getNaturalDecayInstant() { + if (naturalDecayInstant < 0) { + return elementalDecays; + }else if (naturalDecayInstant>=elementalDecays.length){ + return EMDecay.NO_PRODUCT; + } + return new EMDecay[]{elementalDecays[naturalDecayInstant]}; + } + + @Override + public EMDecay[] getEnergyInducedDecay(long energyLevel) { + if (energeticDecayInstant < 0) { + return elementalDecays; + }else if (energeticDecayInstant>=elementalDecays.length){ + return EMDecay.NO_PRODUCT; + } + return new EMDecay[]{elementalDecays[energeticDecayInstant]}; + } + + @Override + public double getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { + return IEMDefinition.DEFAULT_ENERGY_REQUIREMENT *(newEnergyLevel-currentEnergyLevel); + } + + @Override + public boolean usesSpecialEnergeticDecayHandling() { + return false; + } + + @Override + public boolean usesMultipleDecayCalls(long energyLevel) { + return false; + } + + @Override + public boolean decayMakesEnergy(long energyLevel) { + return false; + } + + @Override + public boolean fusionMakesEnergy(long energyLevel) { + return false; + } + + @Override + public EMDecay[] getDecayArray() { + return elementalDecays; + } + + @Override + public double getRawTimeSpan(long currentEnergy) { + return rawLifeTime; + } + + @Override + public final EMConstantStackMap getSubParticles() { + return null; + } + + @Override + public int getGeneration() { + return generation; + } + + @Override + public final NBTTagCompound toNBT(EMDefinitionsRegistry registry) { + return registry.directToNBT(bind); + } + + @Override + protected final String getTagValue() { + return bind; + } + + @Override + public final int getMatterMassType() { + return getClassTypeStatic(); + } + + public static int getClassTypeStatic(){ + return Short.MIN_VALUE; + } + + @Override + public final int compareTo(IEMDefinition o) { + if (getMatterMassType() == o.getMatterMassType()) { + int oID = ((EMPrimitiveTemplate) o).ID; + return Integer.compare(ID, oID); + } + return compareClassID(o); + } + + @Override + public final int hashCode() { + return ID; + } + + public String getUnlocalizedName() { + return name; + } +}
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/IEMDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/IEMDefinition.java new file mode 100644 index 0000000000..ee123735f8 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/IEMDefinition.java @@ -0,0 +1,131 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.definitions; + +import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; +import com.github.technus.tectech.util.TT_Utility; +import net.minecraft.nbt.NBTTagCompound; + +import java.util.ArrayList; + +import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; +import static com.github.technus.tectech.util.TT_Utility.areBitsSet; +import static net.minecraft.util.StatCollector.translateToLocal; + +/** + * Created by danie_000 on 11.11.2016. + */ +public interface IEMDefinition extends Comparable<IEMDefinition>, Cloneable {//IMMUTABLE + double STABLE_RAW_LIFE_TIME = 1.5e36D; + double NO_DECAY_RAW_LIFE_TIME = -1D; + long DEFAULT_ENERGY_LEVEL = 0; + double DEFAULT_ENERGY_REQUIREMENT = 25000D;//legit cuz normal atoms should only emit a gamma if they don't have defined energy levels + //add text based creators for recipe formula input? + + //Nomenclature + String getLocalizedTypeName(); + + String getShortLocalizedName(); + + default String getLocalizedName() { + return getLocalizedTypeName() + ": " + getShortLocalizedName(); + } + + String getShortSymbol(); + + String getSymbol(); + + default void addScanShortSymbols(ArrayList<String> lines, int capabilities, long energyLevel, EMDefinitionsRegistry registry) { + if (areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CLASS_TYPE | SCAN_GET_CHARGE | SCAN_GET_MASS | SCAN_GET_TIMESPAN_INFO, capabilities)) { + lines.add(getShortSymbol()); + } + } + + default void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel, EMDefinitionsRegistry registry) { + if (TT_Utility.areBitsSet(SCAN_GET_CLASS_TYPE | SCAN_GET_CHARGE | SCAN_GET_MASS | SCAN_GET_TIMESPAN_INFO, capabilities)) { + lines.add(translateToLocal("tt.keyword.scan.class") + + " = " + registry.getTypes().get(getClass()).getLocalizedName()); + if (areBitsSet(SCAN_GET_NOMENCLATURE, capabilities)) { + lines.add(translateToLocal("tt.keyword.scan.name") + + " = " + getLocalizedName()); + lines.add(translateToLocal("tt.keyword.scan.symbol") + + " = " + getSymbol()); + } + } + if (areBitsSet(SCAN_GET_CHARGE, capabilities)) { + lines.add(translateToLocal("tt.keyword.scan.charge") + + " = " + getCharge() / 3D + " " + translateToLocal("tt.keyword.unit.charge")); + } + if (areBitsSet(SCAN_GET_COLORABLE, capabilities)) { + lines.add(hasColor() ? + translateToLocal("tt.keyword.scan.colored") : + translateToLocal("tt.keyword.scan.colorless")); + } + if (areBitsSet(SCAN_GET_MASS, capabilities)) { + lines.add(translateToLocal("tt.keyword.scan.mass") + + " = " + getMass() + " " + translateToLocal("tt.keyword.unit.mass")); + } + if (areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)) { + lines.add((isTimeSpanHalfLife() ? + translateToLocal("tt.keyword.scan.half_life") : + translateToLocal("tt.keyword.scan.life_time")) + + " = " + getRawTimeSpan(energyLevel) + " " + translateToLocal("tt.keyword.unit.time")); + lines.add(" " + translateToLocal("tt.keyphrase.scan.at_current_energy_level")); + } + } + + int getMatterMassType();//bigger number means bigger things usually, but it is just used to differentiate between classes of iED + + int getGeneration(); + + //Not dynamically changing stuff + IEMDefinition getAnti();//gives new anti particle def + + EMDecay[] getDecayArray();//possible decays + + EMDecay[] getNaturalDecayInstant();//natural decay if lifespan <1tick + + EMDecay[] getEnergyInducedDecay(long energyLevel);//energetic decay + + boolean usesSpecialEnergeticDecayHandling(); + + boolean usesMultipleDecayCalls(long energyLevel); + + boolean decayMakesEnergy(long energyLevel); + + boolean fusionMakesEnergy(long energyLevel); + + double getEnergyDiffBetweenStates(long currentEnergy, long newEnergyLevel);//positive or negative + + double getMass();//mass... MeV/c^2 + + int getCharge();//charge 1/3 electron charge + + //dynamically changing stuff + int getMaxColors(); + + default boolean hasColor() { + return getMaxColors() > 0; + } + + double getRawTimeSpan(long currentEnergy);//defined in static fields or generated + + boolean isTimeSpanHalfLife(); + + EMConstantStackMap getSubParticles();//contents... null if none + + NBTTagCompound toNBT(EMDefinitionsRegistry registry); + + default EMDefinitionStack getStackForm(double amount) { + return new EMDefinitionStack(this, amount); + } + + default IEMDefinition clone() { + return this; + } + + default int compareClassID(IEMDefinition obj) { + return getMatterMassType() - obj.getMatterMassType(); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/registry/EMDefinitionsRegistry.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/registry/EMDefinitionsRegistry.java new file mode 100644 index 0000000000..458965da66 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/registry/EMDefinitionsRegistry.java @@ -0,0 +1,189 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry; + +import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.IEMMapRead; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; +import net.minecraft.nbt.NBTTagCompound; + +import java.util.*; + +import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMPrimitiveDefinition.nbtE__; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMPrimitiveDefinition.null__; + +public class EMDefinitionsRegistry { + private static final String TAG_NAME = "EM"; + + private final NavigableSet<IEMDefinition> stacksRegistered = new TreeSet<>(); + + private final Map<Integer, IEMDefinition> hashMap = new HashMap<>(); + private final Map<Integer, IEMDefinition> hashMapR = Collections.unmodifiableMap(hashMap); + + private final Map<Class<? extends IEMDefinition>, EMType> types = new HashMap<>(); + private final Map<Class<? extends IEMDefinition>, EMType> typesR = Collections.unmodifiableMap(types); + private final Map<Class<? extends IEMDefinition>, EMType> directTypes = new HashMap<>(); + private final Map<Class<? extends IEMDefinition>, EMType> directTypesR = Collections.unmodifiableMap(directTypes); + private final Map<Class<? extends IEMDefinition>, EMIndirectType> indirectTypes = new HashMap<>(); + private final Map<Class<? extends IEMDefinition>, EMIndirectType> indirectTypesR = Collections.unmodifiableMap(indirectTypes); + + private final Map<String, EMType> binds = new HashMap<>(); + private final Map<String, EMType> bindsR = Collections.unmodifiableMap(binds); + private final Map<String, IEMDefinition> directBinds = new HashMap<>(); + private final Map<String, IEMDefinition> directBindsR = Collections.unmodifiableMap(directBinds); + private final Map<String, EMIndirectType> indirectBinds = new HashMap<>(); + private final Map<String, EMIndirectType> indirectBindsR = Collections.unmodifiableMap(indirectBinds); + + public NBTTagCompound directToNBT(String bind) { + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setString(TAG_NAME, bind); + return nbt; + } + + public NBTTagCompound indirectToNBT(String bind, IEMMapRead<EMDefinitionStack> content) { + NBTTagCompound nbt = content.toNBT(this); + nbt.setString(TAG_NAME, bind); + return nbt; + } + + public IEMDefinition fromNBT(NBTTagCompound nbt) { + IEMDefinition definition; + try { + String bind = nbt.getString(TAG_NAME); + definition = directBinds.get(bind); + if (definition == null) { + definition = indirectBinds.get(bind).create(this, nbt); + } + } catch (Exception e) { + EMException emException = new EMException("Failed to create from: " + nbt.toString(), e); + if (DEBUG_MODE) { + emException.printStackTrace(); + return nbtE__; + } else { + throw emException; + } + } + if (!DEBUG_MODE) { + if (definition == nbtE__) { + throw new EMException("Deserialized to NBT ERROR!"); + } else if (definition == null) { + throw new EMException("Deserialized to NULL POINTER!"); + } else if (definition == null__) { + throw new EMException("Deserialized to NULL!"); + } + } + if (definition == null) { + return null__; + } + return definition; + } + + public boolean isOccupied(String bind) { + return binds.containsKey(bind); + } + + protected void addType(EMType emType) { + if (types.put(emType.getClazz(), emType) != null) { + EMException e = new EMException("Class collision! " + emType.getClazz().getName()); + if (DEBUG_MODE) { + e.printStackTrace(); + } else { + throw e; + } + } + } + + protected void bindType(String bind, EMType emType) { + if (binds.put(bind, emType) != null) { + EMException e = new EMException("NBT Bind collision! " + bind); + if (DEBUG_MODE) { + e.printStackTrace(); + } else { + throw e; + } + } + } + + public void registerDefinitionClass(String bind, EMIndirectType emIndirectType) { + addType(emIndirectType); + indirectTypes.put(emIndirectType.getClazz(), emIndirectType); + bindType(bind, emIndirectType); + indirectBinds.put(bind, emIndirectType); + } + + public void registerDefinitionClass(EMType emDirectType) { + addType(emDirectType); + } + + public void registerDirectDefinition(String bind, IEMDefinition definition) { + if (hashMap.put(definition.hashCode(), definition) != null) { + EMException e = new EMException("Hash collision! " + definition.hashCode()); + if (DEBUG_MODE) { + e.printStackTrace(); + } else { + throw e; + } + } + EMType emType = directTypes.get(definition.getClass()); + if (emType == null) { + emType = types.get(definition.getClass()); + if (emType != null) { + directTypes.put(definition.getClass(), emType); + } else { + EMException e = new EMException("Direct Type bind missing! " + definition.getClass().getName()); + if (DEBUG_MODE) { + e.printStackTrace(); + } else { + throw e; + } + } + } + if (emType != null) { + directTypes.put(definition.getClass(), emType); + bindType(bind, emType); + emType.addDefinition(bind, definition); + directBinds.put(bind, definition); + } + } + + public void registerForDisplay(IEMDefinition definition) { + stacksRegistered.add(definition); + IEMDefinition anti = definition.getAnti(); + if (anti != null) { + stacksRegistered.add(anti); + } + } + + @Deprecated + public Map<Integer, IEMDefinition> getHashMapping() { + return hashMapR; + } + + public NavigableSet<IEMDefinition> getStacksRegisteredForDisplay() { + return stacksRegistered; + } + + public Map<String, EMType> getBinds() { + return bindsR; + } + + public Map<String, IEMDefinition> getDirectBinds() { + return directBindsR; + } + + public Map<String, EMIndirectType> getIndirectBinds() { + return indirectBindsR; + } + + public Map<Class<? extends IEMDefinition>, EMType> getTypes() { + return typesR; + } + + public Map<Class<? extends IEMDefinition>, EMType> getDirectTypes() { + return directTypesR; + } + + public Map<Class<? extends IEMDefinition>, EMIndirectType> getIndirectTypes() { + return indirectTypesR; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/registry/EMIndirectType.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/registry/EMIndirectType.java new file mode 100644 index 0000000000..680dd029a4 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/registry/EMIndirectType.java @@ -0,0 +1,37 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry; + +import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import net.minecraft.nbt.NBTTagCompound; + +import java.util.function.BiFunction; + +import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMPrimitiveDefinition.nbtE__; + +public class EMIndirectType extends EMType { + private final BiFunction<EMDefinitionsRegistry, NBTTagCompound, IEMDefinition> creator; + + public EMIndirectType(BiFunction<EMDefinitionsRegistry, NBTTagCompound, IEMDefinition> creator, Class<? extends IEMDefinition> clazz, String unlocalizedName) { + super(clazz, unlocalizedName); + this.creator = creator; + } + + protected BiFunction<EMDefinitionsRegistry,NBTTagCompound, IEMDefinition> getCreator() { + return creator; + } + + public IEMDefinition create(EMDefinitionsRegistry registry,NBTTagCompound nbt){ + try { + return creator.apply(registry, nbt); + }catch (Exception e){ + EMException emException = new EMException("Failed to create from: " + nbt.toString(), e); + if (DEBUG_MODE) { + emException.printStackTrace(); + return nbtE__; + } else { + throw emException; + } + } + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/registry/EMType.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/registry/EMType.java new file mode 100644 index 0000000000..73097db663 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/registry/EMType.java @@ -0,0 +1,63 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry; + +import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static net.minecraft.util.StatCollector.translateToLocal; + +public class EMType { + private final Map<String, IEMDefinition> definitions = new HashMap<>(); + private final Map<String, IEMDefinition> definitionsR = Collections.unmodifiableMap(definitions); + private final Class<? extends IEMDefinition> clazz; + private final String unlocalizedName; + + public EMType(Class<? extends IEMDefinition> clazz, String unlocalizedName) { + this.clazz = clazz; + this.unlocalizedName = unlocalizedName; + } + + public Class<? extends IEMDefinition> getClazz() { + return clazz; + } + + public String getUnlocalizedName() { + return unlocalizedName; + } + + public String getLocalizedName() { + return translateToLocal(getUnlocalizedName()); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + return clazz==((EMType) o).clazz; + } + + @Override + public int hashCode() { + return clazz.hashCode(); + } + + public void addDefinition(String bind, IEMDefinition definition) { + if (definitions.put(bind, definition) != null) { + EMException e = new EMException("NBT Bind collision on Direct bind!"); + if (DEBUG_MODE) { + e.printStackTrace(); + } else { + throw e; + } + } + } + + public Map<String, IEMDefinition> getDefinitions() { + return definitionsR; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/iElementalInstanceContainer.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/iElementalInstanceContainer.java deleted file mode 100644 index 20fe1ffc5b..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/iElementalInstanceContainer.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core; - -/** - * Created by danie_000 on 25.01.2017. - */ -public interface iElementalInstanceContainer extends Cloneable { - cElementalInstanceStackMap getContainerHandler(); - - void purgeOverflow(); -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMConstantStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMConstantStackMap.java new file mode 100644 index 0000000000..ed2ebbab57 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMConstantStackMap.java @@ -0,0 +1,52 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.maps; + +import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; +import net.minecraft.nbt.NBTTagCompound; + +import java.util.Collections; +import java.util.NavigableMap; +import java.util.TreeMap; + +import static com.github.technus.tectech.util.TT_Utility.unpackNBT; + +/** + * Created by Tec on 12.05.2017. + */ +public final class EMConstantStackMap/*IMMUTABLE*/ extends EMStackMap<EMDefinitionStack> {//Target class for construction of definitions/recipes + //Constructors + Clone, all make a whole new OBJ. + public static final EMConstantStackMap EMPTY = new EMConstantStackMap(); + + private EMConstantStackMap() { + super(Collections.emptyNavigableMap()); + } + + public EMConstantStackMap(EMDefinitionStack... in) { + this(new EMDefinitionStackMap(in).getBackingMap()); + } + + public EMConstantStackMap(NavigableMap<IEMDefinition, EMDefinitionStack> in) { + super(Collections.unmodifiableNavigableMap(in)); + } + + @Override + public Class<EMDefinitionStack> getType() { + return EMDefinitionStack.class; + } + + //IMMUTABLE DON'T NEED IT + @Override + public EMConstantStackMap clone() { + return this; + } + + public EMDefinitionStackMap toMutable() { + return new EMDefinitionStackMap(new TreeMap<>(getBackingMap())); + } + + public static EMConstantStackMap fromNBT(EMDefinitionsRegistry registry, NBTTagCompound nbt) throws EMException { + return new EMConstantStackMap(unpackNBT(EMDefinitionStack.class,inner -> EMDefinitionStack.fromNBT(registry, inner),nbt)); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMDefinitionStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMDefinitionStackMap.java new file mode 100644 index 0000000000..6892e2cd59 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMDefinitionStackMap.java @@ -0,0 +1,50 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.maps; + +import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; +import net.minecraft.nbt.NBTTagCompound; + +import java.util.NavigableMap; +import java.util.TreeMap; + +import static com.github.technus.tectech.util.TT_Utility.unpackNBT; + +/** + * Created by danie_000 on 22.01.2017. + */ +public final class EMDefinitionStackMap extends EMStackMap<EMDefinitionStack> implements IEMMapWriteExact<EMDefinitionStack> {//Transient class for construction of definitions/recipes + //Constructors + Clone, all make a whole new OBJ. + public EMDefinitionStackMap() {} + + public EMDefinitionStackMap(EMDefinitionStack... in) { + putUnifyAllExact(in); + } + + public EMDefinitionStackMap(NavigableMap<IEMDefinition, EMDefinitionStack> in) { + super(in); + } + + @Override + public Class<EMDefinitionStack> getType() { + return EMDefinitionStack.class; + } + + @Override + public EMDefinitionStackMap clone() { + return new EMDefinitionStackMap(new TreeMap<>(getBackingMap())); + } + + public EMConstantStackMap toImmutable() { + return new EMConstantStackMap(new TreeMap<>(getBackingMap())); + } + + public EMConstantStackMap toImmutable_optimized_unsafe_LeavesExposedElementalTree() { + return new EMConstantStackMap(getBackingMap()); + } + + public static EMDefinitionStackMap fromNBT(EMDefinitionsRegistry registry, NBTTagCompound nbt) throws EMException { + return new EMDefinitionStackMap(unpackNBT(EMDefinitionStack.class,inner -> EMDefinitionStack.fromNBT(registry, inner),nbt)); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMInstanceStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMInstanceStackMap.java new file mode 100644 index 0000000000..8a92c819df --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMInstanceStackMap.java @@ -0,0 +1,205 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.maps; + +import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; +import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecayResult; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; +import com.github.technus.tectech.util.TT_Utility; +import gregtech.api.util.GT_Utility; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; + +import java.util.ArrayList; +import java.util.Map; +import java.util.NavigableMap; +import java.util.TreeMap; + +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.AVOGADRO_CONSTANT; +import static com.github.technus.tectech.util.DoubleCount.add; +import static com.github.technus.tectech.util.TT_Utility.unpackNBT; +import static net.minecraft.util.StatCollector.translateToLocal; + +/** + * Created by danie_000 on 22.01.2017. + */ +public final class EMInstanceStackMap extends EMStackMap<EMInstanceStack> implements IEMMapWrite<EMInstanceStack> { + //Constructors + public EMInstanceStackMap() { + } + + public EMInstanceStackMap(EMInstanceStack... inSafe) { + this(true, inSafe); + } + + public EMInstanceStackMap(boolean clone, EMInstanceStack... in) { + if (clone) { + EMInstanceStack[] stacks = new EMInstanceStack[in.length]; + for (int i = 0; i < stacks.length; i++) { + stacks[i] = in[i].clone(); + } + putUnifyAll(stacks); + } else { + putUnifyAll(in); + } + } + + private EMInstanceStackMap(NavigableMap<IEMDefinition, EMInstanceStack> inSafe) { + this(true, inSafe); + } + + private EMInstanceStackMap(boolean clone, NavigableMap<IEMDefinition, EMInstanceStack> in) { + super(clone ? new TreeMap<>() : in); + if (clone) { + for (EMInstanceStack stack : in.values()) { + putUnify(stack.clone()); + } + } + } + + @Override + public Class<EMInstanceStack> getType() { + return EMInstanceStack.class; + } + + @Override + public EMInstanceStackMap clone() { + return new EMInstanceStackMap(getBackingMap()); + } + + //Remove overflow + public double removeOverflow(int stacksCount, double stackCapacity) { + double massRemoved = 0; + + if (size() > stacksCount) { + IEMDefinition[] keys = keySetToArray(); + for (int i = stacksCount; i < keys.length; i++) { + massRemoved += get(keys[i]).getDefinitionStack().getMass(); + removeKey(keys[i]); + } + } + + for (EMInstanceStack instance : valuesToArray()) { + if (instance.getAmount() > stackCapacity) { + massRemoved += instance.getDefinition().getMass() * (instance.getAmount() - stackCapacity); + instance.setAmount(stackCapacity); + } + } + return massRemoved; + } + + //Getters + public String[] getElementalInfo() { + String[] info = new String[size()]; + int i = 0; + for (Map.Entry<IEMDefinition, EMInstanceStack> entry : entrySet()) { + EMInstanceStack instance = entry.getValue(); + info[i++] = EnumChatFormatting.BLUE + instance.getDefinition().getLocalizedName() + " " + EnumChatFormatting.AQUA + instance.getDefinition().getSymbol() + EnumChatFormatting.RESET + + " " + translateToLocal("tt.keyword.short.amount") + ": " + EnumChatFormatting.GREEN + TT_Utility.formatNumberExp(instance.getAmount() / AVOGADRO_CONSTANT) + " " + translateToLocal("tt.keyword.unit.mol") + EnumChatFormatting.RESET + + " " + translateToLocal("tt.keyword.short.energy") + ": " + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(instance.getDefinition().getEnergyDiffBetweenStates(0, instance.getEnergy())) + " " + translateToLocal("tt.keyword.unit.energy") + EnumChatFormatting.RESET + + " " + translateToLocal("tt.keyword.short.charge") + ": " + EnumChatFormatting.GREEN + TT_Utility.formatNumberExp(instance.getCharge()) + " " + translateToLocal("tt.keyword.unit.charge") + EnumChatFormatting.RESET + + " " + translateToLocal("tt.keyword.short.time") + ": " + EnumChatFormatting.GREEN + (instance.getLifeTime() < 0 ? + translateToLocal("tt.keyword.stable") : TT_Utility.formatNumberShortExp(instance.getLifeTime()) + " " + translateToLocal("tt.keyword.unit.time")) + EnumChatFormatting.RESET; + } + return info; + } + + public ArrayList<String> getScanInfo(int[] capabilities) { + ArrayList<String> list = new ArrayList<>(16); + for (Map.Entry<IEMDefinition, EMInstanceStack> e : entrySet()) { + e.getValue().addScanResults(list, capabilities); + } + return list; + } + + public double tickContent(double lifeTimeMult, int postEnergize, double seconds) { + //cleanUp(); + double diff = 0; + for (EMInstanceStack instance : takeAllToArray()) { + instance.setAge(instance.getAge() + seconds); + EMDecayResult newInstances = instance.decay(lifeTimeMult, instance.getAge(), postEnergize); + if (newInstances == null) { + putUnify(instance); + } else { + diff = add(diff, newInstances.getMassDiff()); + putUnifyAll(newInstances.getOutput()); + } + } + return diff; + } + + //NBT + public static EMInstanceStackMap fromNBT(EMDefinitionsRegistry registry, NBTTagCompound nbt) throws EMException { + return new EMInstanceStackMap(false, unpackNBT(EMInstanceStack.class, inner -> EMInstanceStack.fromNBT(registry, inner), nbt)); + } + + @Override + public String toString() { + StringBuilder build = new StringBuilder("Instance Stack Map\n"); + for (Map.Entry<IEMDefinition, EMInstanceStack> stack : entrySet()) { + build.append(stack.getValue().toString()).append('\n'); + } + return build.toString(); + } + + public EMInstanceStack[] takeAllToArray() { + EMInstanceStack[] newStack = valuesToArray();//just in case to uncouple The map + clear(); + return newStack; + } + + public EMInstanceStackMap takeAll() { + EMInstanceStackMap newStack = new EMInstanceStackMap(false, new TreeMap<>(getBackingMap()));//just in case to uncouple The map + clear(); + return newStack; + } + + @Deprecated + public EMDefinitionStackMap toDefinitionMapForComparison() { + EMDefinitionStack[] list = new EMDefinitionStack[size()]; + int i = 0; + for (Map.Entry<IEMDefinition, EMInstanceStack> entry : entrySet()) { + EMInstanceStack value = entry.getValue(); + list[i++] = new EMDefinitionStack(value.getDefinition(), value.getAmount()); + } + return new EMDefinitionStackMap(list); + } + + @Override + public EMInstanceStack putUnify(EMInstanceStack stack) { + EMInstanceStack target = get(stack.getDefinition()); + if (target == null) { + putReplace(stack); + return stack; + } + double newAmount = add(target.getAmount(), stack.getAmount()); + if (IEMStack.isValidAmount(newAmount)) { + stack = target.unifyIntoThis(stack); + putReplace(stack); + return stack; + } else { + removeKey(stack.getDefinition()); + return null; + } + } + + @Override + public EMInstanceStack putUnifyExact(EMInstanceStack stack) { + EMInstanceStack target = get(stack.getDefinition()); + if (target == null) { + putReplace(stack); + return stack; + } + double newAmount = target.getAmount() + stack.getAmount(); + if (IEMStack.isValidAmount(newAmount)) { + stack = target.unifyIntoThis(stack); + putReplace(stack); + return stack; + } else { + removeKey(stack.getDefinition()); + return null; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMStackMap.java new file mode 100644 index 0000000000..84b4123f32 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMStackMap.java @@ -0,0 +1,56 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.maps; + +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; + +import java.util.Map; +import java.util.NavigableMap; +import java.util.TreeMap; + +/** + * Created by Tec on 12.05.2017. + */ +abstract class EMStackMap<T extends IEMStack> implements IEMMapRead<T> { + private final NavigableMap<IEMDefinition, T> backingMap; + + protected EMStackMap() { + this(new TreeMap<>()); + } + + protected EMStackMap(NavigableMap<IEMDefinition, T> map) { + this.backingMap =map; + } + + @Override + public NavigableMap<IEMDefinition, T> getBackingMap() { + return backingMap; + } + + @Override + public abstract EMStackMap<T> clone(); + + @Override + public boolean equals(Object obj) { + if(this == obj){ + return true; + } + if (obj instanceof IEMMapRead) { + return compareTo((IEMMapRead<? extends IEMStack>) obj) == 0; + } + return false; + } + + @Override + public int hashCode() {//Hash only definitions to compare contents not amounts or data + int hash = -(size() << 4); + for (Map.Entry<IEMDefinition, T> entry : entrySet()) { + hash += entry.getValue().getDefinition().hashCode(); + } + return hash; + } + + @Override + public int compareTo(IEMMapRead<? extends IEMStack> o) { + return IEMMapRead.super.compareTo(o); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapRead.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapRead.java new file mode 100644 index 0000000000..6bd12a849b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapRead.java @@ -0,0 +1,279 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.maps; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; +import com.github.technus.tectech.util.TT_Utility; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; + +import java.lang.reflect.Array; +import java.util.*; + +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.AVOGADRO_CONSTANT; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_EPSILON; +import static com.github.technus.tectech.util.DoubleCount.ulpSigned; +import static com.github.technus.tectech.util.TT_Utility.packNBT; +import static net.minecraft.util.StatCollector.translateToLocal; + +public interface IEMMapRead<T extends IEMStack> extends Comparable<IEMMapRead<? extends IEMStack>>, Cloneable { + NavigableMap<IEMDefinition,T> getBackingMap(); + + IEMMapRead<T> clone(); + + default Set<Map.Entry<IEMDefinition, T>> entrySet(){ + return getBackingMap().entrySet(); + } + + default Set<IEMDefinition> keySet(){ + return getBackingMap().keySet(); + } + + default IEMDefinition[] keySetToArray() { + return keySetToArray(new IEMDefinition[size()]); + } + + default IEMDefinition[] keySetToArray(IEMDefinition[] array) { + return keySet().toArray(array); + } + + default Collection<T> values(){ + return getBackingMap().values(); + } + + @SuppressWarnings("unchecked") + default T[] valuesToArray(){ + return valuesToArray((T[]) Array.newInstance(getType(),size())); + } + + default T[] valuesToArray(T[] array){ + return values().toArray(array); + } + + Class<T> getType(); + + //Getters + default T getFirst(){ + return getBackingMap().firstEntry().getValue(); + } + + default T getLast(){ + return getBackingMap().lastEntry().getValue(); + } + + default T get(IEMStack stack) { + return get(stack.getDefinition()); + } + + default T get(IEMDefinition def) { + return getBackingMap().get(def); + } + + default T getNaturallySorted(int pos) { + if(pos<0 || pos>=size()){ + throw new IndexOutOfBoundsException("Index was: "+pos+" size was: "+size()); + } + for (Map.Entry<IEMDefinition, T> entry : entrySet()) { + if(pos==0){ + return entry.getValue(); + } + pos--; + } + return null; + } + + default T getRandom() { + return getNaturallySorted(TecTech.RANDOM.nextInt(size())); + } + + default String[] getShortSymbolsInfo() { + String[] info = new String[size()]; + int i = 0; + for (Map.Entry<IEMDefinition, T> instance : entrySet()) { + info[i++] = instance.getValue().getDefinition().getShortSymbol(); + } + return info; + } + + default String[] getElementalInfo() { + String[] info = new String[size()]; + int i = 0; + for (Map.Entry<IEMDefinition, T> entry : entrySet()) { + T instance = entry.getValue(); + info[i++] = EnumChatFormatting.BLUE + instance.getDefinition().getLocalizedName() + " " + EnumChatFormatting.AQUA + instance.getDefinition().getSymbol() + EnumChatFormatting.RESET + + " " + translateToLocal("tt.keyword.short.amount") + ": " + EnumChatFormatting.GREEN + TT_Utility.formatNumberExp(instance.getAmount() / AVOGADRO_CONSTANT) + " " + translateToLocal("tt.keyword.unit.mol") + EnumChatFormatting.RESET + + " " + translateToLocal("tt.keyword.short.charge") + ": " + EnumChatFormatting.GREEN + TT_Utility.formatNumberExp(instance.getCharge()) + " " + translateToLocal("tt.keyword.unit.charge") + EnumChatFormatting.RESET; + } + return info; + } + + //NBT + default NBTTagCompound toNBT(EMDefinitionsRegistry registry) { + return packNBT(t -> t.toNBT(registry),valuesToArray()); + } + + @Override + default int compareTo(IEMMapRead<? extends IEMStack> o) {//this actually compares rest + int sizeDiff = size() - o.size(); + if (sizeDiff != 0) { + return sizeDiff; + } + + Iterator<Map.Entry<IEMDefinition, T>> iterator = entrySet().iterator(); + Iterator<? extends Map.Entry<IEMDefinition, ? extends IEMStack>> iteratorO = o.entrySet().iterator(); + + while (iterator.hasNext()) { + int result = iterator.next().getValue().compareTo(iteratorO.next().getValue()); + if (result != 0) { + return result; + } + } + return 0; + } + + /** + * use only for nested operations! + * @param o + * @return + */ + default int compareWithAmountsInternal(IEMMapRead<? extends IEMStack> o) { + if (o == null) { + return 1; + } + + int lenDiff = size() - o.size(); + if (lenDiff != 0) { + return lenDiff; + } + + Iterator<Map.Entry<IEMDefinition, T>> iterator = entrySet().iterator(); + Iterator<? extends Map.Entry<IEMDefinition, ? extends IEMStack>> iteratorO = o.entrySet().iterator(); + + while (iterator.hasNext()) { + T first = iterator.next().getValue(); + IEMStack second = iteratorO.next().getValue(); + int result = first.compareTo(second); + if (result != 0) { + return result; + } + result=Double.compare(first.getAmount(),second.getAmount()); + if (result != 0) { + return result; + } + } + return 0; + } + + default double getMass(){ + double mass=0; + for (Map.Entry<IEMDefinition, T> entry : entrySet()) { + mass+=entry.getValue().getMass(); + } + return mass; + } + + default long getCharge(){ + long charge=0; + for (Map.Entry<IEMDefinition, T> entry : entrySet()) { + charge+=entry.getValue().getCharge(); + } + return charge; + } + + //Tests + default boolean containsKey(IEMDefinition def) { + return getBackingMap().containsKey(def); + } + + default boolean containsKey(IEMStack def) { + return containsKey(def.getDefinition()); + } + + default boolean containsAllKeys(IEMDefinition... definitions) { + for (IEMDefinition def : definitions) { + if (!containsKey(def)) { + return false; + } + } + return true; + } + + default boolean containsAllKeys(IEMStack... hasElementalDefinition) { + for (IEMStack has : hasElementalDefinition) { + if (!containsKey(has)) { + return false; + } + } + return true; + } + + default boolean containsAmountExact(IEMDefinition def, double amount) { + T target = get(def); + return target != null && target.getAmount() >= amount; + } + + default boolean containsAmountExact(IEMStack stack) { + return containsAmountExact(stack.getDefinition(),stack.getAmount()); + } + + default boolean containsAllAmountsExact(IEMStack... stacks) { + for (IEMStack stack : stacks) { + if(!containsAmountExact(stack)){ + return false; + } + } + return true; + } + + default boolean containsAllAmountsExact(IEMMapRead<? extends IEMStack> container) { + for (Map.Entry<IEMDefinition, ? extends IEMStack> entry : container.entrySet()) { + if(!containsAmountExact(entry.getValue())){ + return false; + } + } + return true; + } + + default boolean containsAmount(IEMDefinition def, double amountToConsume) { + double amountRequired=amountToConsume- EM_COUNT_EPSILON; + if(amountRequired==amountToConsume){ + amountRequired-=ulpSigned(amountRequired); + } + return containsAmountExact(def,amountRequired); + } + + default boolean containsAmount(IEMStack stack) { + return containsAmount(stack.getDefinition(),stack.getAmount()); + } + + default boolean containsAllAmounts(IEMStack... stacks) { + for (IEMStack stack : stacks) { + if(!containsAmount(stack)){ + return false; + } + } + return true; + } + + default boolean containsAllAmounts(IEMMapRead<? extends IEMStack> container) { + for (Map.Entry<IEMDefinition, ? extends IEMStack> entry : container.entrySet()) { + if(!containsAmount(entry.getValue())){ + return false; + } + } + return true; + } + + default int size() { + return getBackingMap().size(); + } + + default boolean hasStacks() { + return !isEmpty(); + } + + default boolean isEmpty(){ + return getBackingMap().isEmpty(); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWrite.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWrite.java new file mode 100644 index 0000000000..5f5581183d --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWrite.java @@ -0,0 +1,112 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.maps; + +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry; + +import java.util.Map; + +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_EPSILON; +import static com.github.technus.tectech.util.DoubleCount.*; + +public interface IEMMapWrite<T extends IEMStack> extends IEMMapWriteExact<T> { + IEMMapWrite<T> clone(); + + /** + * Consumes amount from map + * @param def def to consume + * @param amountToConsume should be comparable to {@link EMTransformationRegistry#EM_COUNT_PER_MATERIAL_AMOUNT} + * @return consumed successfully + */ + default boolean removeAmount(IEMDefinition def, double amountToConsume){ + double amountRequired=amountToConsume- EM_COUNT_EPSILON; + if(amountRequired==amountToConsume){ + amountRequired-=ulpSigned(amountRequired); + } + return removeAmount(def,amountToConsume,amountRequired); + } + + default boolean removeAmount(IEMDefinition def, double amountToConsume, double amountRequired){ + T current=get(def); + if(current!=null){ + if(current.getAmount()>=amountRequired){ + double newAmount=sub(current.getAmount(),amountToConsume); + if(IEMStack.isValidAmount(newAmount)){ + current=(T)current.mutateAmount(newAmount); + putReplace(current); + }else { + removeKey(current.getDefinition()); + } + return true; + } + } + return false; + } + + default boolean removeAmount(IEMStack stack) { + return removeAmount(stack.getDefinition(),stack.getAmount()); + } + + default boolean removeAllAmounts(IEMStack... stacks) { + boolean test = true; + for (IEMStack stack : stacks) { + test &= containsAmount(stack); + } + if (!test) { + return test; + } + for (IEMStack stack : stacks) { + removeAmount(stack); + } + return true; + } + + default boolean removeAllAmounts(IEMMapRead<? extends IEMStack> map) { + boolean test=true; + for (Map.Entry<IEMDefinition, ? extends IEMStack> entry : map.entrySet()) { + test &= containsAmount(entry.getValue()); + } + if (!test) { + return test; + } + for (Map.Entry<IEMDefinition, ? extends IEMStack> entry : map.entrySet()) { + removeAmount(entry.getValue()); + } + return true; + } + + //Put unify + /** + * + * @param stack thing to put + * @return new mapping or null if merging actually removed stuff + */ + default T putUnify(T stack) { + T target=get(stack.getDefinition()); + if(target==null) { + putReplace(stack); + return stack; + } + double newAmount = add(target.getAmount(), stack.getAmount()); + if (IEMStack.isValidAmount(newAmount)) { + stack=(T) target.mutateAmount(newAmount); + putReplace(stack); + return stack; + }else { + removeKey(stack.getDefinition()); + return null; + } + } + + default void putUnifyAll(T... defs) { + for (T def : defs) { + putUnify(def); + } + } + + default void putUnifyAll(IEMMapRead<T> inTreeUnsafe) { + for (Map.Entry<IEMDefinition, T> in : inTreeUnsafe.entrySet()) { + putUnify(in.getValue()); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWriteExact.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWriteExact.java new file mode 100644 index 0000000000..ef1bc5a4f6 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/IEMMapWriteExact.java @@ -0,0 +1,162 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.maps; + +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; + +import java.util.Map; + +public interface IEMMapWriteExact<T extends IEMStack> extends IEMMapRead<T> { + default void cleanUp(){ + entrySet().removeIf(entry -> entry.getValue().isInvalidAmount()); + } + + default void clear() { + getBackingMap().clear(); + } + + IEMMapWriteExact<T> clone(); + + //Remove + default T removeKey(IEMDefinition def) { + return getBackingMap().remove(def); + } + + default boolean removeKeys(IEMDefinition... definitions) { + boolean hadAll=true; + for (IEMDefinition def : definitions) { + hadAll&=removeKey(def)!=null; + } + return hadAll; + } + + default boolean removeKeys(IEMStack... hasElementalDefinition) { + boolean hadAll=true; + for (IEMStack has : hasElementalDefinition) { + hadAll&=removeKey(has.getDefinition())!=null; + } + return hadAll; + } + + default boolean removeAllKeys(IEMDefinition... definitions) { + boolean hadAll=containsAllKeys(definitions); + if(hadAll){ + for (IEMDefinition def : definitions) { + removeKey(def); + } + } + return hadAll; + } + + default boolean removeAllKeys(IEMStack... hasElementalDefinition) { + boolean hadAll=containsAllKeys(hasElementalDefinition); + if(hadAll){ + for (IEMStack stack : hasElementalDefinition) { + removeKey(stack.getDefinition()); + } + } + return hadAll; + } + + default void putReplace(T defStackUnsafe) { + getBackingMap().put(defStackUnsafe.getDefinition(), defStackUnsafe); + } + + default void putReplaceAll(T... defStacksUnsafe) { + for (T defStack : defStacksUnsafe) { + putReplace(defStack); + } + } + + default void putReplaceAll(IEMMapRead<T> inContainerUnsafe) { + getBackingMap().putAll(inContainerUnsafe.getBackingMap()); + } + + /** + * Should only be used when modifying definitions to alter the integer count correctly + * @param def + * @return + */ + default boolean removeAmountExact(IEMStack def){ + return removeAmountExact(def.getDefinition(),def.getAmount()); + } + + /** + * Should only be used when modifying definitions to alter the integer count correctly + * @param def + * @param amountToConsume + * @return + */ + default boolean removeAmountExact(IEMDefinition def, double amountToConsume){ + T current=get(def); + if(current!=null){ + double newAmount=current.getAmount()-amountToConsume; + if(newAmount>=0){ + if(current.isValidAmount()){ + current=(T)current.mutateAmount(newAmount); + putReplace(current); + } else { + removeKey(current.getDefinition()); + } + return true; + } + } + return false; + } + + default boolean removeAllAmountsExact(IEMStack... stacks) { + boolean test = true; + for (IEMStack stack : stacks) { + test &= containsAmountExact(stack); + } + if (!test) { + return test; + } + for (IEMStack stack : stacks) { + removeAmountExact(stack); + } + return true; + } + + default boolean removeAllAmountsExact(IEMMapRead<? extends IEMStack> map) { + boolean test=true; + for (Map.Entry<IEMDefinition, ? extends IEMStack> entry : map.entrySet()) { + test &= containsAmountExact(entry.getValue()); + } + if (!test) { + return test; + } + for (Map.Entry<IEMDefinition, ? extends IEMStack> entry : map.entrySet()) { + removeAmountExact(entry.getValue()); + } + return true; + } + + default T putUnifyExact(T stack) { + T target=get(stack.getDefinition()); + if(target==null) { + putReplace(stack); + return stack; + } + double newAmount = target.getAmount()+stack.getAmount(); + if (IEMStack.isValidAmount(newAmount)) { + stack=(T) target.mutateAmount(newAmount); + putReplace(stack); + return stack; + }else { + removeKey(stack.getDefinition()); + return null; + } + } + + default void putUnifyAllExact(T... defs) { + for (T def : defs) { + putUnifyExact(def); + } + } + + default void putUnifyAllExact(IEMMapRead<T> inTreeUnsafe) { + for (Map.Entry<IEMDefinition, T> in : inTreeUnsafe.entrySet()) { + putUnifyExact(in.getValue()); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipe.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipe.java deleted file mode 100644 index e191cc0e0a..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipe.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -/** - * Created by Tec on 02.03.2017. - */ -public class rElementalRecipe implements Comparable<rElementalRecipe> { - public final short ID; - public final cElementalDefinitionStackMap inEM; - public final cElementalDefinitionStackMap outEM; - public final ItemStack[] outItems; - public final FluidStack[] outFluids; - public Object[] extension; - - public rElementalRecipe( - cElementalDefinitionStackMap inEM,//not null plz - short id, - cElementalDefinitionStackMap outEM, - ItemStack[] outItems, - FluidStack[] outFluids) { - this.inEM = inEM; - this.outEM = outEM; - this.outItems = outItems; - this.outFluids = outFluids; - ID = id;//allows multiple recipes with the same input EM,so u can actually extend... - } - - public rElementalRecipe extend(Object... data) { - extension = data; - return this; - } - - @Override - public int compareTo(rElementalRecipe o) { - int compare = inEM.compareTo(o.inEM); - if(compare!=0) { - return compare; - } - return Short.compare(ID, o.ID); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof rElementalRecipe) { - return compareTo((rElementalRecipe) obj) == 0; - } - return false; - } - - @Override - public int hashCode() { - return inEM.hashCode(); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipeMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipeMap.java deleted file mode 100644 index ed5e46f43f..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipeMap.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core; - -import java.util.HashMap; -import java.util.Map; - -/** - * Created by Tec on 02.03.2017. - */ -public class rElementalRecipeMap {//TODO FIX - //Multimap for multiple recipes from the same thing - you know parameters might differ the output - private final HashMap<cElementalDefinitionStackMap, HashMap<Short, rElementalRecipe>> recipes; - - public rElementalRecipeMap() { - recipes = new HashMap<>(); - } - - public rElementalRecipe put(rElementalRecipe in) { - HashMap<Short, rElementalRecipe> r = recipes.computeIfAbsent(in.inEM, k -> new HashMap<>()); - return r.put(in.ID, in);//IF THIS RETURN SHIT, it means that inputs are using the exact same types of matter as input - (non amount wise collision) - //It is either bad, or unimportant if you use different id's - } - - public void putAll(rElementalRecipe... contents) { - for (rElementalRecipe recipe : contents) { - put(recipe); - } - } - - public rElementalRecipe remove(cElementalStackMap map, short id) { - return recipes.get(map).remove(id);//suspicious but ok, equals and hashcode methods are adjusted for that - } - - public HashMap<Short, rElementalRecipe> remove(cElementalStackMap map) { - return recipes.remove(map);//suspicious but ok, equals and hashcode methods are adjusted for that - } - - public HashMap<Short, rElementalRecipe> findExact(cElementalInstanceStackMap in) { - return recipes.get(in.toDefinitionMapForComparison());//suspicious but ok, equals and hashcode methods are adjusted for that - } - - //Recipe founding should not check amounts - this checks if the types of matter in map are equal to any recipe! - //Return a recipeShortMap when the content of input is equal (ignoring amounts and instance data) - @Deprecated - public HashMap<Short, rElementalRecipe> findExact(cElementalStackMap in) { - return recipes.get(in);//suspicious but ok, equals and hashcode methods are adjusted for that - } - - //this does check if the map contains all the requirements for any recipe, and the required amounts - //Return a recipeShortMap when the content of input matches the recipe input - does not ignore amounts but ignores instance data! - @Deprecated - public HashMap<Short, rElementalRecipe> findMatch(cElementalMutableDefinitionStackMap in, boolean testOnlyTruePreferred) { - for (Map.Entry<cElementalDefinitionStackMap, HashMap<Short, rElementalRecipe>> cElementalDefinitionStackMapHashMapEntry : recipes.entrySet()) { - if (in.removeAllAmounts(testOnlyTruePreferred, cElementalDefinitionStackMapHashMapEntry.getKey())) { - return cElementalDefinitionStackMapHashMapEntry.getValue(); - } - } - return null; - } - - public HashMap<Short, rElementalRecipe> findMatch(cElementalInstanceStackMap in, boolean testOnly) { - for (Map.Entry<cElementalDefinitionStackMap, HashMap<Short, rElementalRecipe>> cElementalDefinitionStackMapHashMapEntry : recipes.entrySet()) { - if (in.removeAllAmounts(testOnly, cElementalDefinitionStackMapHashMapEntry.getKey())) { - return cElementalDefinitionStackMapHashMapEntry.getValue(); - } - } - return null; - } - - //To check for instance data and other things use recipe extensions! -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/recipes/EMRecipe.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/recipes/EMRecipe.java new file mode 100644 index 0000000000..4b0792eac9 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/recipes/EMRecipe.java @@ -0,0 +1,87 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.recipes; + +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.IEMMapRead; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +/** + * Created by Tec on 02.03.2017. + */ +public class EMRecipe<T> implements Comparable<EMRecipe<T>> { + private final int ID; + private final EMConstantStackMap inEM; + private final IEMMapRead<? extends IEMStack> outEM; + private final ItemStack[] outItems; + private final FluidStack[] outFluids; + private T extension; + + public EMRecipe( + EMConstantStackMap inEM,//not null plz + int id, + IEMMapRead<? extends IEMStack> outEM, + ItemStack[] outItems, + FluidStack[] outFluids) { + this.inEM = inEM; + this.outEM = outEM; + this.outItems = outItems; + this.outFluids = outFluids; + ID = id;//allows multiple recipes with the same input EM,so u can actually extend... + } + + public EMRecipe<T> extend(T data) { + setExtension(data); + return this; + } + + @Override + public int compareTo(EMRecipe<T> o) { + int compare = getInEM().compareTo(o.getInEM()); + if(compare!=0) { + return compare; + } + return Integer.compare(getID(), o.getID()); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof EMRecipe) { + return compareTo((EMRecipe) obj) == 0; + } + return false; + } + + @Override + public int hashCode() { + return getInEM().hashCode(); + } + + public int getID() { + return ID; + } + + public EMConstantStackMap getInEM() { + return inEM; + } + + public IEMMapRead<? extends IEMStack> getOutEM() { + return outEM; + } + + public ItemStack[] getOutItems() { + return outItems; + } + + public FluidStack[] getOutFluids() { + return outFluids; + } + + public T getExtension() { + return extension; + } + + public void setExtension(T extension) { + this.extension = extension; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/recipes/EMRecipeMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/recipes/EMRecipeMap.java new file mode 100644 index 0000000000..95a4aaf595 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/recipes/EMRecipeMap.java @@ -0,0 +1,66 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.recipes; + +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.IEMMapRead; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; + +import java.util.HashMap; +import java.util.Map; + +/** + * Created by Tec on 02.03.2017. + */ +public class EMRecipeMap<T> {//TODO FIX + //Multimap for multiple recipes from the same thing - you know parameters might differ the output + private final Map<EMConstantStackMap, Map<Integer, EMRecipe<T>>> recipes; + + public EMRecipeMap() { + recipes = new HashMap<>(); + } + + public EMRecipe<T> put(EMRecipe<T> in) { + Map<Integer, EMRecipe<T>> r = getRecipes().computeIfAbsent(in.getInEM(), k -> new HashMap<>()); + return r.put(in.getID(), in);//IF THIS RETURN SHIT, it means that inputs are using the exact same types of matter as input - (non amount wise collision) + //It is either bad, or unimportant if you use different id's + } + + public void putAll(EMRecipe<T>... contents) { + for (EMRecipe<T> recipe : contents) { + put(recipe); + } + } + + public EMRecipe<T> remove(IEMMapRead<EMDefinitionStack> map, int id) { + Map<Integer, EMRecipe<T>> recipesMap = getRecipes().get(map); + return recipesMap != null ? recipesMap.remove(id) : null;//todo check, suspicious but ok, equals and hashcode methods are adjusted for that + } + + public Map<Integer, EMRecipe<T>> remove(IEMMapRead<EMDefinitionStack> map) { + return getRecipes().remove(map);//todo check, suspicious but ok, equals and hashcode methods are adjusted for that + } + + //Recipe founding should not check amounts - this checks if the types of matter in map are equal to any recipe! + //Return a recipeShortMap when the content of input is equal (ignoring amounts and instance data) + @Deprecated + public Map<Integer, EMRecipe<T>> findExact(IEMMapRead<? extends IEMStack> in) { + return getRecipes().get(in);//suspicious but ok, equals and hashcode methods are adjusted for that + } + + //this does check if the map contains all the requirements for any recipe, and the required amounts + //Return a recipeShortMap when the content of input matches the recipe input - does not ignore amounts but ignores instance data! + public Map<Integer, EMRecipe<T>> findMatch(IEMMapRead<? extends IEMStack> in) { + for (Map.Entry<EMConstantStackMap, Map<Integer, EMRecipe<T>>> cElementalDefinitionStackMapHashMapEntry : getRecipes().entrySet()) { + if (in.containsAllAmounts(cElementalDefinitionStackMapHashMapEntry.getKey())) { + return cElementalDefinitionStackMapHashMapEntry.getValue(); + } + } + return null; + } + + public Map<EMConstantStackMap, Map<Integer, EMRecipe<T>>> getRecipes() { + return recipes; + } + + //To check for instance data and other things use recipe extensions! +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMDefinitionStack.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMDefinitionStack.java new file mode 100644 index 0000000000..2abee4c36e --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMDefinitionStack.java @@ -0,0 +1,73 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.stacks; + +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import net.minecraft.nbt.NBTTagCompound; + +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMPrimitiveDefinition.null__; + +/** + * Created by danie_000 on 20.11.2016. + */ +public final class EMDefinitionStack implements IEMStack { + private final IEMDefinition definition; + private final double amount; + + public EMDefinitionStack(IEMDefinition def, double amount) { + definition = def == null ? null__ : def; + this.amount = amount; + } + + @Override + public EMDefinitionStack clone() { + return this;//IMMUTABLE + } + + @Override + public EMDefinitionStack mutateAmount(double newAmount) { + if(getAmount() == newAmount){ + return this; + } + return new EMDefinitionStack(getDefinition(), newAmount);//IMMUTABLE + } + + @Override + public IEMDefinition getDefinition() { + return definition;//IMMUTABLE + } + + @Override + public double getAmount() { + return amount; + } + + public NBTTagCompound toNBT(EMDefinitionsRegistry registry) { + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setTag("d", getDefinition().toNBT(registry)); + nbt.setDouble("Q", getAmount()); + return nbt; + } + + public static EMDefinitionStack fromNBT(EMDefinitionsRegistry registry,NBTTagCompound nbt) { + return new EMDefinitionStack( + registry.fromNBT(nbt.getCompoundTag("d")), + nbt.getLong("q")+nbt.getDouble("Q")); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof IEMDefinition) { + return getDefinition().compareTo((IEMDefinition) obj) == 0; + } + if (obj instanceof IEMStack) { + return getDefinition().compareTo(((IEMStack) obj).getDefinition()) == 0; + } + return false; + } + + //Amount shouldn't be hashed if this is just indicating amount and not structure + @Override + public int hashCode() { + return getDefinition().hashCode(); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMInstanceStack.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMInstanceStack.java new file mode 100644 index 0000000000..0dbd56609e --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/EMInstanceStack.java @@ -0,0 +1,591 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.stacks; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay; +import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecayResult; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +import com.github.technus.tectech.util.TT_Utility; +import net.minecraft.client.Minecraft; +import net.minecraft.crash.CrashReport; +import net.minecraft.nbt.NBTTagCompound; + +import java.util.ArrayList; + +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.AVOGADRO_CONSTANT; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.deadEnd; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMPrimitiveDefinition.null__; +import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; +import static com.github.technus.tectech.util.DoubleCount.*; +import static java.lang.Math.max; +import static java.lang.Math.min; +import static net.minecraft.util.StatCollector.translateToLocal; + +/** + * Created by danie_000 on 22.10.2016. + */ +public final class EMInstanceStack implements IEMStack { + public static int MIN_MULTIPLE_DECAY_CALLS = 4, MAX_MULTIPLE_DECAY_CALLS = 16; + public static double DECAY_CALL_PER = EM_COUNT_PER_MATERIAL_AMOUNT;//todo + + private final IEMDefinition definition; + private double amount; + + private double age; + //energy - if positive then particle should try to decay + private long energy; + //byte color; 0=Red 1=Green 2=Blue 0=Cyan 1=Magenta 2=Yellow, else ignored (-1 - uncolorable) + private int color; + private double lifeTime; + private double lifeTimeMult; + + public EMInstanceStack(IEMStack stackSafe) { + this(stackSafe.getDefinition(), stackSafe.getAmount(), 1D, 0D, 0); + } + + public EMInstanceStack(IEMStack stackSafe, double lifeTimeMult, double age, long energy) { + this(stackSafe.getDefinition(), stackSafe.getAmount(), lifeTimeMult, age, energy); + } + + public EMInstanceStack(IEMDefinition defSafe, double amount) { + this(defSafe, amount, 1D, 0D, 0); + } + + public EMInstanceStack(IEMDefinition defSafe, double amount, double lifeTimeMult, double age, long energy) { + definition = defSafe == null ? null__ : defSafe; + if (getDefinition().hasColor()) { + this.color = (byte) TecTech.RANDOM.nextInt(getDefinition().getMaxColors()); + } else {//transforms colorable??? into proper color + this.color = getDefinition().getMaxColors(); + } + this.lifeTimeMult = lifeTimeMult; + lifeTime = getDefinition().getRawTimeSpan(energy) * this.lifeTimeMult; + setEnergy(energy); + this.setAge(age); + this.setAmount(amount); + } + + //Clone proxy + private EMInstanceStack(EMInstanceStack stack) { + definition = stack.getDefinition(); + color = stack.color; + setAge(stack.getAge()); + setAmount(stack.getAmount()); + lifeTime = stack.lifeTime; + lifeTimeMult = stack.lifeTimeMult; + energy = stack.energy; + } + + @Override + public EMInstanceStack clone() { + return new EMInstanceStack(this); + } + + @Override + public EMInstanceStack mutateAmount(double newAmount) { + this.setAmount(newAmount); + return this; + } + + @Override + public double getAmount() { + return amount; + } + + public long getEnergy() { + return energy; + } + + public void setEnergy(long newEnergyLevel) { + energy = newEnergyLevel; + setLifeTimeMultiplier(getLifeTimeMultiplier()); + } + + public double getEnergySettingCost(long currentEnergyLevel, long newEnergyLevel) { + return getDefinition().getEnergyDiffBetweenStates(currentEnergyLevel, newEnergyLevel) * getAmount(); + } + + public double getEnergySettingCost(long newEnergyLevel) { + return getEnergySettingCost(energy, newEnergyLevel) * getAmount(); + } + + public EMDefinitionStack getDefinitionStack() { + return new EMDefinitionStack(getDefinition(), getAmount()); + } + + @Override + public IEMDefinition getDefinition() { + return definition; + } + + public int getColor() { + return color; + } + + public void setColor(int color) {//does not allow changing magic element + if (this.color < 0 || this.color > 2 || color < 0 || color >= 3) { + return; + } + this.color = color; + } + + public void nextColor() {//does not allow changing magic element + if (definition.hasColor()) { + color = (byte) TecTech.RANDOM.nextInt(definition.getMaxColors()); + } + } + + public double getLifeTime() { + return lifeTime; + } + + public void setLifeTimeMultiplier(double mult) { + if (mult <= 0) //since infinity*0=nan + { + throw new IllegalArgumentException("multiplier must be >0"); + } + lifeTimeMult = mult; + if (getDefinition().getRawTimeSpan(energy) <= 0) { + return; + } + lifeTime = getDefinition().getRawTimeSpan(energy) * lifeTimeMult; + } + + public double getLifeTimeMultiplier() { + return lifeTimeMult; + } + + public EMDecayResult tickStackByOneSecond(double lifeTimeMult, int postEnergize) { + return tickStack(lifeTimeMult, postEnergize, 1D); + } + + public EMDecayResult tickStack(double lifeTimeMult, int postEnergize, double seconds) { + setAge(getAge() + seconds); + EMDecayResult newInstances = decay(lifeTimeMult, getAge(), postEnergize); + if (newInstances == null) { + nextColor(); + } else { + for (EMInstanceStack newInstance : newInstances.getOutput().valuesToArray()) { + newInstance.nextColor(); + } + } + return newInstances; + } + + public EMDecayResult decay() { + return decay(1D, getAge(), 0);//try to decay without changes + } + + public EMDecayResult decay(double apparentAge, long postEnergize) { + return decay(1D, apparentAge, postEnergize); + } + + public EMDecayResult decay(double lifeTimeMult, double apparentAge, long postEnergize) { + long newEnergyLevel = postEnergize + energy; + if (newEnergyLevel > 0) { + newEnergyLevel -= 1; + } else if (newEnergyLevel < 0) { + newEnergyLevel += 1; + } + EMDecayResult output; + if (getDefinition().usesMultipleDecayCalls(energy)) { + double amountTemp = getAmount(); + int decayCnt = (int) min(MAX_MULTIPLE_DECAY_CALLS, max(getAmount() / DECAY_CALL_PER, MIN_MULTIPLE_DECAY_CALLS)); + setAmount(div(getAmount(), decayCnt)); + decayCnt--; + + output = decayMechanics(lifeTimeMult, apparentAge, newEnergyLevel); + if (output == null) { + setAmount(amountTemp); + return null; + } + + for (int i = 0; i < decayCnt; i++) { + EMDecayResult map = decayMechanics(lifeTimeMult, apparentAge, newEnergyLevel); + if (map != null) { + output.getOutput().putUnifyAll(map.getOutput()); + output.setMassDiff(add(output.getMassDiff(), map.getMassDiff())); + output.setMassAffected(output.getMassDiff() + map.getMassDiff()); + } + } + setAmount(amountTemp); + } else { + output = decayMechanics(lifeTimeMult, apparentAge, newEnergyLevel); + } + if (output != null) { + output.getOutput().cleanUp(); + } + return output; + } + + private EMDecayResult decayMechanics(double lifeTimeMult, double apparentAge, long newEnergyLevel) { + if (energy > 0 && !getDefinition().usesSpecialEnergeticDecayHandling()) { + setLifeTimeMultiplier(getLifeTimeMultiplier()); + return decayCompute(getDefinition().getEnergyInducedDecay(energy), lifeTimeMult, -1D, newEnergyLevel); + } else if (getDefinition().getRawTimeSpan(energy) < 0) { + return null;//return null, decay cannot be achieved + } else if (getDefinition().isTimeSpanHalfLife()) { + return exponentialDecayCompute(energy > 0 ? getDefinition().getEnergyInducedDecay(energy) : getDefinition().getDecayArray(), lifeTimeMult, -1D, newEnergyLevel); + } else { + if (1 > lifeTime) { + return decayCompute(energy > 0 ? getDefinition().getEnergyInducedDecay(energy) : getDefinition().getNaturalDecayInstant(), lifeTimeMult, 0D, newEnergyLevel); + } else if (apparentAge > lifeTime) { + return decayCompute(energy > 0 ? getDefinition().getEnergyInducedDecay(energy) : getDefinition().getDecayArray(), lifeTimeMult, 0D, newEnergyLevel); + } + } + return null;//return null since decay cannot be achieved + } + + //Use to get direct decay output providing correct decay array + private EMDecayResult exponentialDecayCompute(EMDecay[] decays, double lifeTimeMult, double newProductsAge, long newEnergyLevel) { + double newAmount = div(getAmount(), Math.pow(2D, 1D/* 1 second */ / lifeTime)); + + //if(definition.getSymbol().startsWith("U ")) { + // System.out.println("newAmount = " + newAmount); + // System.out.println("amountRemaining = " + amountRemaining); + // for(cElementalDecay decay:decays){ + // System.out.println("prob = "+decay.probability); + // for(cElementalDefinitionStack stack:decay.outputStacks.values()){ + // System.out.println("stack = " + stack.getDefinition().getSymbol() + " " + stack.amount); + // } + // } + //} + if (newAmount == getAmount()) { + newAmount -= ulpSigned(newAmount); + } else if (newAmount < 1) { + return decayCompute(decays, lifeTimeMult, newProductsAge, newEnergyLevel); + } + + //split to non decaying and decaying part + double amount = this.getAmount(); + this.setAmount(this.getAmount() - newAmount); + EMDecayResult products = decayCompute(decays, lifeTimeMult, newProductsAge, newEnergyLevel); + this.setAmount(newAmount); + if (products != null) { + products.getOutput().putUnify(clone()); + } + this.setAmount(amount); + return products; + } + + //Use to get direct decay output providing correct decay array + private EMDecayResult decayCompute(EMDecay[] decays, double lifeTimeMult, double newProductsAge, long newEnergyLevel) { + if (decays == null) { + return null;//Can not decay so it won't + } + boolean makesEnergy = getDefinition().decayMakesEnergy(energy); + double mass = getMass(); + if (decays.length == 0) { + return makesEnergy ? null : new EMDecayResult(new EMInstanceStackMap(), mass, 0); + //provide non null 0 length array for annihilation + } else if (decays.length == 1) {//only one type of decay :D, doesn't need dead end + if (decays[0] == deadEnd) { + return makesEnergy ? null : new EMDecayResult(decays[0].getResults(lifeTimeMult, newProductsAge, newEnergyLevel, getAmount()), mass, 0); + } + EMInstanceStackMap output = decays[0].getResults(lifeTimeMult, newProductsAge, newEnergyLevel, getAmount()); + if (newProductsAge < 0) { + if (output.size() == 1) { + if (output.size() == 1 && output.getFirst().getDefinition().equals(getDefinition())) { + output.getFirst().setEnergy(energy); + output.getFirst().setAge(getAge()); + } + } else { + for (EMInstanceStack stack : output.valuesToArray()) { + if (stack.getDefinition().equals(getDefinition())) { + stack.setAge(getAge()); + } + } + } + } else { + if (output.size() == 1 && output.getFirst().getDefinition().equals(getDefinition())) { + output.getFirst().setEnergy(energy); + } + } + if (energy <= 0 && output.getMass() > mass) { + return null;//no energy usage to decay + } + return new EMDecayResult(new EMInstanceStackMap(), mass, makesEnergy ? output.getMass() - mass : 0); + } else { + EMDecayResult totalOutput = new EMDecayResult(new EMInstanceStackMap(), getMass(), 0); + EMInstanceStackMap output = totalOutput.getOutput(), results; + int differentDecays = decays.length; + double[] probabilities = new double[differentDecays]; + for (int i = 0; i < probabilities.length; i++) { + probabilities[i] = decays[i].getProbability(); + } + double[] qttyOfDecay; + try { + qttyOfDecay = distribute(getAmount(), probabilities); + } catch (ArithmeticException e) { + Minecraft.getMinecraft().crashed(new CrashReport("Decay failed for: " + this, e)); + return null; + } + //long amountRemaining = this.amount, amount = this.amount; + //float remainingProbability = 1D; +// + //for (int i = 0; i < differentDecays; i++) { + // if (decays[i].probability >= 1D) { + // long thisDecayAmount = (long) Math.floor(remainingProbability * (double) amount); + // if (thisDecayAmount > 0) { + // if (thisDecayAmount <= amountRemaining) { + // amountRemaining -= thisDecayAmount; + // qttyOfDecay[i] += thisDecayAmount; + // }else {//in case too much was made + // qttyOfDecay[i] += amountRemaining; + // amountRemaining = 0; + // //remainingProbability=0; + // } + // } + // break; + // } + // long thisDecayAmount = (long) Math.floor(decays[i].probability * (double) amount); + // if (thisDecayAmount <= amountRemaining && thisDecayAmount > 0) {//some was made + // amountRemaining -= thisDecayAmount; + // qttyOfDecay[i] += thisDecayAmount; + // } else if (thisDecayAmount > amountRemaining) {//too much was made + // qttyOfDecay[i] += amountRemaining; + // amountRemaining = 0; + // //remainingProbability=0; + // break; + // } + // remainingProbability -= decays[i].probability; + // if(remainingProbability<=0) { + // break; + // } + //} + + //for (int i = 0; i < amountRemaining; i++) { + // double rand = TecTech.RANDOM.nextDouble(); + // for (int j = 0; j < differentDecays; j++) {//looking for the thing it decayed into + // rand -= decays[j].probability; + // if (rand <= 0D) { + // qttyOfDecay[j]++; + // break; + // } + // } + //} + + if (getDefinition().decayMakesEnergy(energy)) { + for (int i = differentDecays - 1; i >= 0; i--) { + if (decays[i] == deadEnd) { + EMInstanceStack clone = clone(); + clone.setAmount(qttyOfDecay[i]); + output.putUnify(clone); + } else { + results = decays[i].getResults(lifeTimeMult, newProductsAge, newEnergyLevel, qttyOfDecay[i]); + output.putUnifyAll(results); + totalOutput.setMassDiff(add(totalOutput.getMassDiff(), results.getMass() - mass)); + } + } + } else { + for (int i = differentDecays - 1; i >= 0; i--) { + results = decays[i].getResults(lifeTimeMult, newProductsAge, newEnergyLevel, qttyOfDecay[i]); + output.putUnifyAll(results); + } + } + + if (newProductsAge < 0) { + if (output.size() == 1 && output.getFirst().getDefinition().equals(getDefinition())) { + output.getFirst().setEnergy(energy); + output.getFirst().setAge(getAge()); + } else { + for (EMInstanceStack stack : output.valuesToArray()) { + if (stack.getDefinition().equals(getDefinition())) { + stack.setAge(getAge()); + } + } + } + } else { + if (output.size() == 1 && output.getFirst().getDefinition().equals(getDefinition())) { + output.getFirst().setEnergy(energy); + output.getFirst().setAge(getAge()); + } + } + if (energy <= 0 && output.getMass() > getMass()) { + return null;//no energy usage to decay + } + return totalOutput; + } + } + + public EMInstanceStack unifyIntoThis(EMInstanceStack... instances) { + if (instances == null) { + return this; + } + //returns with the definition from the first object passed + double energyTotal = getEnergySettingCost(0, energy); + long maxEnergy = energy; + long minEnergy = energy; + + for (EMInstanceStack instance : instances) { + //if (instance != null && compareTo(instance) == 0) { + setAmount(add(getAmount(), instance.getAmount())); + energyTotal += instance.getEnergySettingCost(0, instance.energy); + maxEnergy = max(instance.energy, maxEnergy); + minEnergy = min(instance.energy, maxEnergy); + lifeTimeMult = min(lifeTimeMult, instance.lifeTimeMult); + setAge(max(getAge(), instance.getAge())); + //} + } + + if (energyTotal >= 0) { + for (; maxEnergy > 0; maxEnergy--) { + if (getEnergySettingCost(0, maxEnergy) < energyTotal) { + break; + } + } + setEnergy(maxEnergy); + } else { + for (; minEnergy < 0; minEnergy++) { + if (getEnergySettingCost(minEnergy, 0) < energyTotal) { + break; + } + } + setEnergy(minEnergy); + } + return this; + } + + public EMInstanceStack unifyIntoThisExact(EMInstanceStack... instances) { + if (instances == null) { + return this; + } + //returns with the definition from the first object passed + double energyTotal = getEnergySettingCost(0, energy); + long maxEnergy = energy; + long minEnergy = energy; + + for (EMInstanceStack instance : instances) { + //if (instance != null && compareTo(instance) == 0) { + setAmount(getAmount() + instance.getAmount()); + energyTotal += instance.getEnergySettingCost(0, instance.energy); + maxEnergy = max(instance.energy, maxEnergy); + minEnergy = min(instance.energy, maxEnergy); + lifeTimeMult = min(lifeTimeMult, instance.lifeTimeMult); + setAge(max(getAge(), instance.getAge())); + //} + } + + if (energyTotal >= 0) { + for (; maxEnergy > 0; maxEnergy--) { + if (getEnergySettingCost(0, maxEnergy) < energyTotal) { + break; + } + } + setEnergy(maxEnergy); + } else { + for (; minEnergy < 0; minEnergy++) { + if (getEnergySettingCost(minEnergy, 0) < energyTotal) { + break; + } + } + setEnergy(minEnergy); + } + return this; + } + + public void addScanResults(ArrayList<String> lines, int[] detailsOnDepthLevels) { + int capabilities = detailsOnDepthLevels[0]; + if (TT_Utility.areBitsSet(SCAN_GET_DEPTH_LEVEL, capabilities)) { + lines.add(translateToLocal("tt.keyword.scan.depth") + " = " + 0); + } + getDefinition().addScanResults(lines, capabilities, energy, TecTech.definitionsRegistry); + + if (TT_Utility.areBitsSet(SCAN_GET_TIMESPAN_MULT, capabilities)) { + lines.add(translateToLocal("tt.keyword.scan.life_mult") + " = " + lifeTimeMult); + } + if (TT_Utility.areBitsSet(SCAN_GET_AGE, capabilities)) { + lines.add(translateToLocal("tt.keyword.scan.age") + " = " + getAge() + " " + translateToLocal("tt.keyword.unit.time")); + } + if (TT_Utility.areBitsSet(SCAN_GET_COLOR_VALUE, capabilities)) { + lines.add(translateToLocal("tt.keyword.scan.color") + " = " + color); + } + if (TT_Utility.areBitsSet(SCAN_GET_ENERGY, capabilities)) { + lines.add(translateToLocal("tt.keyword.scan.energy") + " = " + getDefinition().getEnergyDiffBetweenStates(0, energy) + " " + translateToLocal("tt.keyword.unit.energy")); + } + if (TT_Utility.areBitsSet(SCAN_GET_ENERGY_LEVEL, capabilities)) { + lines.add(translateToLocal("tt.keyword.scan.energyLevel") + " = " + energy); + } + if (TT_Utility.areBitsSet(SCAN_GET_AMOUNT, capabilities)) { + lines.add(translateToLocal("tt.keyword.scan.amount") + " = " + getAmount() / AVOGADRO_CONSTANT + " " + translateToLocal("tt.keyword.unit.mol")); + } + + scanContents(lines, getDefinition().getSubParticles(), 1, detailsOnDepthLevels); + } + + private void scanContents(ArrayList<String> lines, EMConstantStackMap definitions, int depth, int[] detailsOnDepthLevels) { + if (definitions != null && depth < detailsOnDepthLevels.length) { + int deeper = depth + 1; + for (EMDefinitionStack definitionStack : definitions.valuesToArray()) { + lines.add("");//def separator + if (TT_Utility.areBitsSet(SCAN_GET_DEPTH_LEVEL, detailsOnDepthLevels[depth])) { + lines.add(translateToLocal("tt.keyword.scan.depth") +" = " + depth); + } + getDefinition().addScanResults(lines, detailsOnDepthLevels[depth], energy, TecTech.definitionsRegistry); + if (TT_Utility.areBitsSet(SCAN_GET_AMOUNT, detailsOnDepthLevels[depth])) { + lines.add(translateToLocal("tt.keyword.scan.count")+" = " + definitionStack.getAmount()); + } + scanContents(lines, definitionStack.getDefinition().getSubParticles(), deeper, detailsOnDepthLevels); + } + } + } + + public NBTTagCompound toNBT(EMDefinitionsRegistry registry) { + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setTag("d", getDefinition().toNBT(registry)); + nbt.setDouble("Q", getAmount()); + nbt.setDouble("M", getLifeTimeMultiplier()); + nbt.setDouble("A", getAge()); + nbt.setLong("e", getEnergy()); + nbt.setInteger("c", getColor()); + return nbt; + } + + public static EMInstanceStack fromNBT(EMDefinitionsRegistry registry, NBTTagCompound nbt) { + EMInstanceStack instance = new EMInstanceStack( + registry.fromNBT(nbt.getCompoundTag("d")), + nbt.getDouble("Q"), + nbt.getDouble("M"), + nbt.getDouble("A"), + nbt.getLong("e")); + instance.setColor(nbt.getInteger("c")); + return instance; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof IEMDefinition) { + return getDefinition().compareTo((IEMDefinition) obj) == 0; + } + if (obj instanceof IEMStack) { + return getDefinition().compareTo(((IEMStack) obj).getDefinition()) == 0; + } + return false; + } + + //Amount shouldn't be hashed if this is just indicating amount and not structure, DOES NOT CARE ABOUT creativeTabTecTech INFO + @Override + public int hashCode() { + return getDefinition().hashCode(); + } + + @Override + public String toString() { + return getDefinition().toString() + ' ' + getAmount() / AVOGADRO_CONSTANT + " " + translateToLocal("tt.keyword.unit.mol") + " " + getMass() + " "+translateToLocal("tt.keyword.unit.mass"); + } + + public void setAmount(double amount) { + this.amount = amount; + } + + public double getAge() { + return age; + } + + public void setAge(double age) { + this.age = age; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/IEMStack.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/IEMStack.java new file mode 100644 index 0000000000..e5cfab9752 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/IEMStack.java @@ -0,0 +1,56 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.stacks; + +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import net.minecraft.nbt.NBTTagCompound; + +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_MINIMUM; + +/** + * Created by danie_000 on 30.01.2017. + */ +public interface IEMStack extends Comparable<IEMStack>, Cloneable { + static boolean isValidAmount(double amount) { + return amount >= EM_COUNT_MINIMUM; + } + + static boolean isInvalidAmount(double amount) { + return amount < EM_COUNT_MINIMUM; + } + default boolean isValidAmount() { + return isValidAmount(getAmount()); + } + + default boolean isInvalidAmount() { + return isInvalidAmount(getAmount()); + } + + IEMDefinition getDefinition(); + + double getAmount(); + + default double getCharge() { + return getDefinition().getCharge() * getAmount(); + } + + default double getMass() { + return getDefinition().getMass() * getAmount(); + } + + IEMStack clone(); + + /** + * Will return stack with mutated amount, it might be a new object! + * + * @param newAmount new amount + * @return new stack (or previous one if was mutable) + */ + IEMStack mutateAmount(double newAmount); + + NBTTagCompound toNBT(EMDefinitionsRegistry registry); + + @Override + default int compareTo(IEMStack o) { + return getDefinition().compareTo(o.getDefinition()); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalDefinitionStack.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalDefinitionStack.java deleted file mode 100644 index a2d22c30ed..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalDefinitionStack.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core.stacks; - -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; -import net.minecraft.nbt.NBTTagCompound; - -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.cPrimitiveDefinition.null__; -import static com.github.technus.tectech.util.DoubleCount.add; - -/** - * Created by danie_000 on 20.11.2016. - */ -public final class cElementalDefinitionStack implements iHasElementalDefinition { - public final iElementalDefinition definition; - public final double amount; - - public cElementalDefinitionStack(iElementalDefinition def, double amount) { - definition = def == null ? null__ : def; - this.amount = amount; - } - - @Override - public cElementalDefinitionStack clone() { - return this;//IMMUTABLE - } - - @Override - public iElementalDefinition getDefinition() { - return definition;//IMMUTABLE - } - - @Override - public double getAmount() { - return amount; - } - - @Override - public double getCharge() { - return definition.getCharge() * amount; - } - - @Override - public double getMass() { - return definition.getMass() * amount; - } - - public NBTTagCompound toNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setTag("d", definition.toNBT()); - nbt.setDouble("Q", amount); - return nbt; - } - - public static cElementalDefinitionStack fromNBT(NBTTagCompound nbt) { - return new cElementalDefinitionStack( - cElementalDefinition.fromNBT(nbt.getCompoundTag("d")), - nbt.getLong("q")+nbt.getDouble("Q")); - } - - public cElementalDefinitionStack addAmountIntoNewInstance(double amount) { - if(amount==0) { - return this; - } - return new cElementalDefinitionStack(definition, add(amount,this.amount)); - } - - public cElementalDefinitionStack addAmountIntoNewInstance(cElementalDefinitionStack... other) { - if (other == null || other.length == 0) { - return this; - } - double l = 0; - for (cElementalDefinitionStack stack : other) { - l= add(l,stack.amount); - } - return addAmountIntoNewInstance(l); - } - - @Override - public int compareTo(iHasElementalDefinition o) { - return definition.compareTo(o.getDefinition()); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof iElementalDefinition) { - return definition.compareTo((iElementalDefinition) obj) == 0; - } - if (obj instanceof iHasElementalDefinition) { - return definition.compareTo(((iHasElementalDefinition) obj).getDefinition()) == 0; - } - return false; - } - - //Amount shouldn't be hashed if this is just indicating amount and not structure - @Override - public int hashCode() { - return definition.hashCode(); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java deleted file mode 100644 index 559d7ab8d9..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java +++ /dev/null @@ -1,560 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core.stacks; - -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecayResult; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDefinitionStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; -import com.github.technus.tectech.util.Util; -import net.minecraft.client.Minecraft; -import net.minecraft.crash.CrashReport; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.ArrayList; - -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.cPrimitiveDefinition.null__; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition.deadEnd; -import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; -import static com.github.technus.tectech.util.DoubleCount.*; -import static java.lang.Math.*; - -/** - * Created by danie_000 on 22.10.2016. - */ -public final class cElementalInstanceStack implements iHasElementalDefinition { - public static int MIN_MULTIPLE_DECAY_CALLS=4,MAX_MULTIPLE_DECAY_CALLS=16; - public static double DECAY_CALL_PER=AVOGADRO_CONSTANT;//todo - - public final iElementalDefinition definition; - //energy - if positive then particle should try to decay - private long energy; - //byte color; 0=Red 1=Green 2=Blue 0=Cyan 1=Magenta 2=Yellow, else ignored (-1 - uncolorable) - private byte color; - public double age; - public double amount; - private double lifeTime; - private double lifeTimeMult; - - public cElementalInstanceStack(cElementalDefinitionStack stackSafe) { - this(stackSafe.definition, stackSafe.amount, 1D, 0D, 0); - } - - public cElementalInstanceStack(cElementalDefinitionStack stackSafe, double lifeTimeMult, double age, long energy) { - this(stackSafe.definition, stackSafe.amount, lifeTimeMult, age, energy); - } - - public cElementalInstanceStack(iElementalDefinition defSafe, double amount) { - this(defSafe, amount, 1D, 0D, 0); - } - - public cElementalInstanceStack(iElementalDefinition defSafe, double amount, double lifeTimeMult, double age, long energy) { - definition = defSafe == null ? null__ : defSafe; - byte bColor = definition.getColor(); - if (bColor < 0 || bColor > 2) {//transforms colorable??? into proper color - this.color = bColor; - } else { - this.color = (byte) TecTech.RANDOM.nextInt(3); - } - this.lifeTimeMult = lifeTimeMult; - lifeTime = definition.getRawTimeSpan(energy) * this.lifeTimeMult; - setEnergy(energy); - this.age = age; - this.amount = amount; - } - - //Clone proxy - private cElementalInstanceStack(cElementalInstanceStack stack) { - definition = stack.definition; - color = stack.color; - age = stack.age; - amount = stack.amount; - lifeTime = stack.lifeTime; - lifeTimeMult = stack.lifeTimeMult; - energy = stack.energy; - } - - @Override - public cElementalInstanceStack clone() { - return new cElementalInstanceStack(this); - } - - @Override - public double getAmount() { - return amount; - } - - @Override - public double getCharge() { - return definition.getCharge() * amount; - } - - @Override - public double getMass() { - return definition.getMass() * amount; - } - - public long getEnergy() { - return energy; - } - - public void setEnergy(long newEnergyLevel){ - energy=newEnergyLevel; - setLifeTimeMultiplier(getLifeTimeMultiplier()); - } - - public double getEnergySettingCost(long currentEnergyLevel, long newEnergyLevel){ - return definition.getEnergyDiffBetweenStates(currentEnergyLevel,newEnergyLevel)*amount; - } - - public double getEnergySettingCost(long newEnergyLevel){ - return definition.getEnergyDiffBetweenStates(energy,newEnergyLevel)*amount; - } - - public cElementalDefinitionStack getDefinitionStack() { - return new cElementalDefinitionStack(definition, amount); - } - - @Override - public iElementalDefinition getDefinition() { - return definition; - } - - public byte getColor() { - return color; - } - - public byte setColor(byte color) {//does not allow changing magic element - if (this.color < 0 || this.color > 2 || color < 0 || color >= 3) { - return this.color; - } - return this.color = color; - } - - public byte nextColor() {//does not allow changing magic element - if (color < 0 || color > 2) { - return color; - } - return color = (byte) TecTech.RANDOM.nextInt(3); - } - - public double getLifeTime() { - return lifeTime; - } - - public double setLifeTimeMultiplier(double mult) { - if(mult<=0) //since infinity*0=nan - { - throw new IllegalArgumentException("multiplier must be >0"); - } - lifeTimeMult = mult; - if (definition.getRawTimeSpan(energy) <= 0) { - return lifeTime; - } - lifeTime = definition.getRawTimeSpan(energy) * lifeTimeMult; - return lifeTime; - } - - public double getLifeTimeMultiplier() { - return lifeTimeMult; - } - - public cElementalDecayResult tickStackByOneSecond(double lifeTimeMult, int postEnergize){ - return tickStack(lifeTimeMult,postEnergize,1D); - } - - public cElementalDecayResult tickStack(double lifeTimeMult, int postEnergize, double seconds){ - cElementalDecayResult newInstances = decay(lifeTimeMult, age += seconds, postEnergize); - if (newInstances == null) { - nextColor(); - } else { - for (cElementalInstanceStack newInstance : newInstances.getOutput().values()) { - newInstance.nextColor(); - } - } - return newInstances; - } - - public cElementalDecayResult decay() { - return decay(1D, age, 0);//try to decay without changes - } - - public cElementalDecayResult decay(double apparentAge, long postEnergize) { - return decay(1D,apparentAge,postEnergize); - } - - public cElementalDecayResult decay(double lifeTimeMult, double apparentAge, long postEnergize) { - long newEnergyLevel = postEnergize + energy; - if (newEnergyLevel > 0) { - newEnergyLevel -= 1; - } else if (newEnergyLevel < 0) { - newEnergyLevel += 1; - } - cElementalDecayResult output; - if(definition.usesMultipleDecayCalls(energy)){ - double amountTemp=amount; - int decayCnt=(int) min(MAX_MULTIPLE_DECAY_CALLS,max(amount/DECAY_CALL_PER,MIN_MULTIPLE_DECAY_CALLS)); - amount= div(amount,decayCnt); - decayCnt--; - - output=decayMechanics(lifeTimeMult,apparentAge,newEnergyLevel); - if(output==null){ - amount=amountTemp; - return null; - } - - for(int i=0;i<decayCnt;i++){ - cElementalDecayResult map=decayMechanics(lifeTimeMult,apparentAge,newEnergyLevel); - if(map!=null){ - output.getOutput().putUnifyAll(map.getOutput()); - output.setMassDiff(add(output.getMassDiff(),map.getMassDiff())); - output.setMassAffected(output.getMassDiff()+map.getMassDiff()); - } - } - amount=amountTemp; - }else{ - output=decayMechanics(lifeTimeMult,apparentAge,newEnergyLevel); - } - if(output!=null){ - output.getOutput().cleanUp(); - } - return output; - } - - private cElementalDecayResult decayMechanics(double lifeTimeMult, double apparentAge, long newEnergyLevel) { - if (energy > 0 && !definition.usesSpecialEnergeticDecayHandling()) { - setLifeTimeMultiplier(getLifeTimeMultiplier()); - return decayCompute(definition.getEnergyInducedDecay(energy), lifeTimeMult, -1D, newEnergyLevel); - } else if (definition.getRawTimeSpan(energy) < 0) { - return null;//return null, decay cannot be achieved - } else if (definition.isTimeSpanHalfLife()) { - return exponentialDecayCompute(energy > 0 ? definition.getEnergyInducedDecay(energy) : definition.getDecayArray(), lifeTimeMult, -1D, newEnergyLevel); - } else { - if (1 > lifeTime) { - return decayCompute(energy > 0 ? definition.getEnergyInducedDecay(energy) : definition.getNaturalDecayInstant(), lifeTimeMult, 0D, newEnergyLevel); - } else if (apparentAge > lifeTime) { - return decayCompute(energy > 0 ? definition.getEnergyInducedDecay(energy) : definition.getDecayArray(), lifeTimeMult, 0D, newEnergyLevel); - } - } - return null;//return null since decay cannot be achieved - } - - //Use to get direct decay output providing correct decay array - private cElementalDecayResult exponentialDecayCompute(cElementalDecay[] decays, double lifeTimeMult, double newProductsAge, long newEnergyLevel) { - double newAmount= div(amount,Math.pow(2D,1D/* 1 second *//lifeTime)); - - //if(definition.getSymbol().startsWith("U ")) { - // System.out.println("newAmount = " + newAmount); - // System.out.println("amountRemaining = " + amountRemaining); - // for(cElementalDecay decay:decays){ - // System.out.println("prob = "+decay.probability); - // for(cElementalDefinitionStack stack:decay.outputStacks.values()){ - // System.out.println("stack = " + stack.getDefinition().getSymbol() + " " + stack.amount); - // } - // } - //} - if(newAmount==amount) { - newAmount-=ulp(newAmount); - } else if(newAmount<1) { - return decayCompute(decays, lifeTimeMult, newProductsAge, newEnergyLevel); - } - - //split to non decaying and decaying part - double amount=this.amount; - this.amount-=newAmount; - cElementalDecayResult products=decayCompute(decays,lifeTimeMult,newProductsAge,newEnergyLevel); - this.amount=newAmount; - if(products!=null){ - products.getOutput().putUnify(clone()); - } - this.amount=amount; - return products; - } - - //Use to get direct decay output providing correct decay array - private cElementalDecayResult decayCompute(cElementalDecay[] decays, double lifeTimeMult, double newProductsAge, long newEnergyLevel) { - if (decays == null) { - return null;//Can not decay so it wont - } - boolean makesEnergy=definition.decayMakesEnergy(energy); - double mass=getMass(); - if (decays.length == 0) { - return makesEnergy ? null : new cElementalDecayResult(new cElementalInstanceStackMap(), mass, 0); - //provide non null 0 length array for annihilation - } else if (decays.length == 1) {//only one type of decay :D, doesn't need dead end - if(decays[0]==deadEnd) { - return makesEnergy ? null : new cElementalDecayResult(decays[0].getResults(lifeTimeMult, newProductsAge, newEnergyLevel, amount), mass, 0); - } - cElementalInstanceStackMap output = decays[0].getResults(lifeTimeMult, newProductsAge, newEnergyLevel, amount); - if(newProductsAge<0){ - if(output.size()==1) { - if(output.size()==1 && output.get(0).definition.equals(definition)) { - output.get(0).setEnergy(energy); - output.get(0).age=age; - } - }else { - for (cElementalInstanceStack stack : output.values()) { - if (stack.definition.equals(definition)) { - stack.age = age; - } - } - } - }else{ - if(output.size()==1 && output.get(0).definition.equals(definition)) { - output.get(0).setEnergy(energy); - } - } - if(energy <= 0 && output.getMass() > mass){ - return null;//no energy usage to decay - } - return new cElementalDecayResult(new cElementalInstanceStackMap(), mass, makesEnergy ? output.getMass()-mass:0); - } else { - cElementalDecayResult totalOutput = new cElementalDecayResult(new cElementalInstanceStackMap(),getMass(),0); - cElementalInstanceStackMap output=totalOutput.getOutput(),results; - int differentDecays = decays.length; - double[] probabilities=new double[differentDecays]; - for (int i = 0; i < probabilities.length; i++) { - probabilities[i]=decays[i].probability; - } - double[] qttyOfDecay; - try{ - qttyOfDecay = distribute(amount, probabilities); - }catch (ArithmeticException e){ - Minecraft.getMinecraft().crashed(new CrashReport("Decay failed for: "+this.toString(),e)); - return null; - } - //long amountRemaining = this.amount, amount = this.amount; - //float remainingProbability = 1D; -// - //for (int i = 0; i < differentDecays; i++) { - // if (decays[i].probability >= 1D) { - // long thisDecayAmount = (long) Math.floor(remainingProbability * (double) amount); - // if (thisDecayAmount > 0) { - // if (thisDecayAmount <= amountRemaining) { - // amountRemaining -= thisDecayAmount; - // qttyOfDecay[i] += thisDecayAmount; - // }else {//in case too much was made - // qttyOfDecay[i] += amountRemaining; - // amountRemaining = 0; - // //remainingProbability=0; - // } - // } - // break; - // } - // long thisDecayAmount = (long) Math.floor(decays[i].probability * (double) amount); - // if (thisDecayAmount <= amountRemaining && thisDecayAmount > 0) {//some was made - // amountRemaining -= thisDecayAmount; - // qttyOfDecay[i] += thisDecayAmount; - // } else if (thisDecayAmount > amountRemaining) {//too much was made - // qttyOfDecay[i] += amountRemaining; - // amountRemaining = 0; - // //remainingProbability=0; - // break; - // } - // remainingProbability -= decays[i].probability; - // if(remainingProbability<=0) { - // break; - // } - //} - - //for (int i = 0; i < amountRemaining; i++) { - // double rand = TecTech.RANDOM.nextDouble(); - // for (int j = 0; j < differentDecays; j++) {//looking for the thing it decayed into - // rand -= decays[j].probability; - // if (rand <= 0D) { - // qttyOfDecay[j]++; - // break; - // } - // } - //} - - if(definition.decayMakesEnergy(energy)){ - for (int i = differentDecays - 1; i >= 0; i--) { - if(decays[i]==deadEnd){ - cElementalInstanceStack clone=clone(); - clone.amount=qttyOfDecay[i]; - output.putUnify(clone); - }else { - results=decays[i].getResults(lifeTimeMult, newProductsAge, newEnergyLevel, qttyOfDecay[i]); - output.putUnifyAll(results); - totalOutput.setMassDiff(add(totalOutput.getMassDiff(),results.getMass()-mass)); - } - } - }else{ - for (int i = differentDecays - 1; i >= 0; i--) { - results=decays[i].getResults(lifeTimeMult, newProductsAge, newEnergyLevel, qttyOfDecay[i]); - output.putUnifyAll(results); - } - } - - if(newProductsAge<0) { - if (output.size() == 1 && output.get(0).definition.equals(definition)) { - output.get(0).setEnergy(energy); - output.get(0).age = age; - } else { - for (cElementalInstanceStack stack : output.values()) { - if (stack.definition.equals(definition)) { - stack.age = age; - } - } - } - }else{ - if(output.size()==1 && output.get(0).definition.equals(definition)) { - output.get(0).setEnergy(energy); - output.get(0).age=age; - } - } - if(energy <= 0 && output.getMass() > getMass()){ - return null;//no energy usage to decay - } - return totalOutput; - } - } - - public cElementalInstanceStack unifyIntoThis(cElementalInstanceStack... instances) { - if (instances == null) { - return this; - } - //returns with the definition from the first object passed - double energyTotal = this.energy * amount; - long maxEnergy=this.energy; - double lifeTimeMul = lifeTimeMult; - - for (cElementalInstanceStack instance : instances) { - if (instance != null && compareTo(instance) == 0) { - amount= add(amount,instance.amount); - energyTotal += instance.energy * instance.amount; - if(instance.energy>maxEnergy){ - maxEnergy=instance.energy; - } - lifeTimeMul = min(lifeTimeMul, instance.lifeTimeMult); - age = max(age, instance.age); - } - } - - if (amount != 0) { - energyTotal /= Math.abs(amount); - } - - double wholeParts=Math.floor(energyTotal); - energyTotal= min(energyTotal-wholeParts,1D)+(wholeParts>=0?-0.11709966304863834D:0.11709966304863834D); - long energy=(long) wholeParts + ((energyTotal > TecTech.RANDOM.nextDouble()) ? 1 : 0); - if(energy*energyTotal<0){ - energy=0; - } - setEnergy(min(maxEnergy,energy)); - return this; - } - - public void addScanShortSymbols(ArrayList<String> lines, int[] detailsOnDepthLevels){ - int capabilities=detailsOnDepthLevels[0]; - definition.addScanShortSymbols(lines,capabilities,energy); - //scanShortSymbolsContents(lines,definition.getSubParticles(),1,detailsOnDepthLevels); - } - - //private void scanShortSymbolsContents(ArrayList<String> lines, cElementalDefinitionStackMap definitions, int depth, int[] detailsOnDepthLevels){ - // if(definitions!=null && depth<detailsOnDepthLevels.length){ - // int deeper=depth+1; - // for(cElementalDefinitionStack definitionStack:definitions.values()) { - // definition.addScanShortSymbols(lines,detailsOnDepthLevels[depth],energy); - // scanSymbolsContents(lines,definitionStack.definition.getSubParticles(),deeper,detailsOnDepthLevels); - // } - // } - //} - - public void addScanResults(ArrayList<String> lines, int[] detailsOnDepthLevels){ - int capabilities=detailsOnDepthLevels[0]; - if(Util.areBitsSet(SCAN_GET_DEPTH_LEVEL,capabilities)) { - lines.add("DEPTH = " + 0); - } - definition.addScanResults(lines,capabilities,energy); - if(Util.areBitsSet(SCAN_GET_TIMESPAN_MULT,capabilities)) { - lines.add("TIME MULT = " + lifeTimeMult); - if(Util.areBitsSet(SCAN_GET_TIMESPAN_INFO,capabilities)) { - lines.add("TIME SPAN = " + lifeTime + " s"); - } - } - if(Util.areBitsSet(SCAN_GET_AGE,capabilities)) { - lines.add("AGE = " + age + " s"); - } - if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) { - lines.add("COLOR = " + color + " RGB or CMY"); - } - if(Util.areBitsSet(SCAN_GET_ENERGY_LEVEL,capabilities)) { - lines.add("ENERGY = " + energy); - } - if(Util.areBitsSet(SCAN_GET_AMOUNT,capabilities)) { - lines.add("AMOUNT = " + amount/ AVOGADRO_CONSTANT +" mol"); - } - scanContents(lines,definition.getSubParticles(),1,detailsOnDepthLevels); - } - - private void scanContents(ArrayList<String> lines, cElementalDefinitionStackMap definitions, int depth, int[] detailsOnDepthLevels){ - if(definitions!=null && depth<detailsOnDepthLevels.length){ - int deeper=depth+1; - for(cElementalDefinitionStack definitionStack:definitions.values()) { - lines.add("");//def separator - if(Util.areBitsSet(SCAN_GET_DEPTH_LEVEL,detailsOnDepthLevels[depth])) { - lines.add("DEPTH = " + depth); - } - definition.addScanResults(lines,detailsOnDepthLevels[depth],energy); - if(Util.areBitsSet(SCAN_GET_AMOUNT,detailsOnDepthLevels[depth])) { - lines.add("AMOUNT = " + definitionStack.amount); - } - scanContents(lines,definitionStack.definition.getSubParticles(),deeper,detailsOnDepthLevels); - } - } - } - - public NBTTagCompound toNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setTag("d", definition.toNBT()); - nbt.setDouble("Q", amount); - nbt.setLong("e", energy); - nbt.setByte("c", color); - nbt.setDouble("A", age); - nbt.setDouble("M", lifeTimeMult); - return nbt; - } - - public static cElementalInstanceStack fromNBT(NBTTagCompound nbt) { - NBTTagCompound definition = nbt.getCompoundTag("d"); - cElementalInstanceStack instance = new cElementalInstanceStack( - cElementalDefinition.fromNBT(definition), - nbt.getLong("q")+nbt.getDouble("Q"), - nbt.getFloat("m")+nbt.getDouble("M"), - nbt.getLong("a")+nbt.getDouble("A"), - nbt.getLong("e")); - instance.setColor(nbt.getByte("c")); - return instance; - } - - @Override - public int compareTo(iHasElementalDefinition o) {//use for unification - return definition.compareTo(o.getDefinition()); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof iElementalDefinition) { - return definition.compareTo((iElementalDefinition) obj) == 0; - } - if (obj instanceof iHasElementalDefinition) { - return definition.compareTo(((iHasElementalDefinition) obj).getDefinition()) == 0; - } - return false; - } - - //Amount shouldn't be hashed if this is just indicating amount and not structure, DOES NOT CARE ABOUT creativeTabTecTech INFO - @Override - public int hashCode() { - return definition.hashCode(); - } - - @Override - public String toString() { - return definition.toString() + '\n' + amount/ AVOGADRO_CONSTANT + " mol\n" + getMass(); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/iHasElementalDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/iHasElementalDefinition.java deleted file mode 100644 index 1d8af7bab7..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/iHasElementalDefinition.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core.stacks; - -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; - -/** - * Created by danie_000 on 30.01.2017. - */ -public interface iHasElementalDefinition extends Comparable<iHasElementalDefinition>,Cloneable { - iElementalDefinition getDefinition(); - - double getAmount(); - - double getCharge(); - - double getMass(); - - iHasElementalDefinition clone(); -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/tElementalException.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/tElementalException.java deleted file mode 100644 index 2adadfd062..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/tElementalException.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core; - -/** - * Created by danie_000 on 19.11.2016. - */ -public final class tElementalException extends Exception { - public tElementalException(String message) { - super(message); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalDefinition.java deleted file mode 100644 index 51025148a7..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalDefinition.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core.templates; - -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.iHasElementalDefinition; -import net.minecraft.nbt.NBTTagCompound; - -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; - -import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.cPrimitiveDefinition.nbtE__; - -/** - * Created by danie_000 on 23.01.2017. - */ -public abstract class cElementalDefinition extends iElementalDefinition { - //Nothing array - public static final iElementalDefinition[] nothing = new cElementalPrimitive[0]; - - //add text based creators for recipe formula input? - private static final Map<Byte, Method> nbtCreationBind = new HashMap<>();//creator methods in subclasses - private static final HashSet<Byte> classSet = new HashSet<>(); - - protected static void addCreatorFromNBT(byte shortcutNBT, Method constructorFromNBT,byte classID) { - if(nbtCreationBind.put(shortcutNBT, constructorFromNBT)!=null) { - throw new Error("Duplicate NBT shortcut! " + shortcutNBT + " used for NBT based creation"); - } - if(!classSet.add(classID)) { - throw new Error("Duplicate Class ID! " + classID + " used for class comparison"); - } - } - - public static Map<Byte, Method> getBindsComplex(){ - return nbtCreationBind; - } - - @Override - public final cElementalDefinition clone() { - return this;//IMMUTABLE - } - - public static iElementalDefinition fromNBT(NBTTagCompound nbt) { - try { - return (iElementalDefinition) nbtCreationBind.get(nbt.getByte("t")).invoke(null, nbt); - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return nbtE__; - } - } - - @Override - public int compareTo(iElementalDefinition o) { - int classCompare = compareClassID(o); - if (classCompare != 0) { - return classCompare; - } - - //only of the internal def stacks!!! - //that allows neat check if the same thing and - //top hierarchy amount can be used to store amount info - return compareInnerContentsWithAmounts(getSubParticles().values(), o.getSubParticles().values()); - } - - //use only for nested operations! - private static int compareInnerContentsWithAmounts(cElementalDefinitionStack[] tc, cElementalDefinitionStack[] sc) { - if (tc == null) { - if (sc == null) { - return 0; - } else { - return -1; - } - } - if (sc == null) { - return 1; - } - - int lenDiff = tc.length - sc.length; - if (lenDiff != 0) { - return lenDiff; - } - - for (int i = 0; i < tc.length; i++) { - int cn = tc[i].definition.compareTo(sc[i].definition); - if (cn != 0) { - return cn; - } - - if (tc[i].amount > sc[i].amount) { - return 1; - } - if (tc[i].amount < sc[i].amount) { - return -1; - } - } - return 0; - } - - @Override - public final cElementalDefinitionStack getStackForm(double amount) { - return new cElementalDefinitionStack(this, amount); - } - - @Override - public final boolean equals(Object obj) { - if(this==obj) { - return true; - } - if (obj instanceof iElementalDefinition) { - return compareTo((iElementalDefinition) obj) == 0; - } - if (obj instanceof iHasElementalDefinition) { - return compareTo(((iHasElementalDefinition) obj).getDefinition()) == 0; - } - return false; - } - - @Override - public int hashCode() {//Internal amounts should be also hashed - int hash = -(getSubParticles().size() << 4); - for (cElementalDefinitionStack stack : getSubParticles().values()) { - int amount=(int)stack.amount; - hash += ((amount & 0x1) == 0 ? -amount : amount) + stack.definition.hashCode(); - } - return hash; - } - - @Override - public String toString() { - return getName()+ '\n' + getSymbol(); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java deleted file mode 100644 index 6ee8591c58..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java +++ /dev/null @@ -1,275 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core.templates; - -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDefinitionStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.tElementalException; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aFluidDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aItemDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aOredictDequantizationInfo; -import net.minecraft.client.Minecraft; -import net.minecraft.crash.CrashReport; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.*; - -import static com.github.technus.tectech.util.Util.areBitsSet; -import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.cPrimitiveDefinition.null__; -import static com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM.STACKS_REGISTERED; -import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; - -/** - * Created by danie_000 on 22.10.2016. - * EXTEND THIS TO ADD NEW PRIMITIVES, WATCH OUT FOR ID'S!!! (-1 to 32 can be assumed as used) - */ -public abstract class cElementalPrimitive extends cElementalDefinition { - public static final byte nbtType = (byte) 'p'; - - private static final Map<Integer, cElementalPrimitive> bindsBO = new HashMap<>(); - - public static Map<Integer, cElementalPrimitive> getBindsPrimitive() { - return bindsBO; - } - - public final String name; - public final String symbol; - //float-mass in eV/c^2 - public final double mass; - //int -electric charge in 1/3rds of electron charge for optimization - public final byte charge; - //byte color; 0=Red 1=Green 2=Blue 0=Cyan 1=Magenta 2=Yellow, else ignored (-1 - uncolorable) - public final byte color; - //-1/-2/-3 anti matter generations, +1/+2/+3 matter generations, 0 self anti - public final byte type; - - private cElementalPrimitive anti;//IMMUTABLE - private cElementalDecay[] elementalDecays; - private byte naturalDecayInstant; - private byte energeticDecayInstant; - private double rawLifeTime; - - public final int ID; - - //no _ at end - normal particle - // _ at end - anti particle - // __ at end - self is antiparticle - - protected cElementalPrimitive(String name, String symbol, int type, double mass, int charge, int color, int ID) { - this.name = name; - this.symbol = symbol; - this.type = (byte) type; - this.mass = mass; - this.charge = (byte) charge; - this.color = (byte) color; - this.ID = ID; - if (bindsBO.put(ID, this) != null) { - Minecraft.getMinecraft().crashed(new CrashReport("Primitive definition", new tElementalException("Duplicate ID"))); - } - STACKS_REGISTERED.add(this); - } - - // - protected void init(cElementalPrimitive antiParticle, double rawLifeTime, int naturalInstant, int energeticInstant, cElementalDecay... elementalDecaysArray) { - anti = antiParticle; - this.rawLifeTime = rawLifeTime; - naturalDecayInstant = (byte) naturalInstant; - energeticDecayInstant = (byte) energeticInstant; - elementalDecays =elementalDecaysArray; - } - - @Override - public String getName() { - return "Undefined: " + name; - } - - @Override - public String getSymbol() { - return symbol; - } - - @Override - public String getShortSymbol() { - return symbol; - } - - @Override - public iElementalDefinition getAnti() { - return anti;//no need for copy - } - - @Override - public int getCharge() { - return charge; - } - - @Override - public byte getColor() { - return color; - } - - @Override - public double getMass() { - return mass; - } - - @Override - public cElementalDecay[] getNaturalDecayInstant() { - if (naturalDecayInstant < 0) { - return elementalDecays; - }else if (naturalDecayInstant>=elementalDecays.length){ - return cElementalDecay.noProduct; - } - return new cElementalDecay[]{elementalDecays[naturalDecayInstant]}; - } - - @Override - public cElementalDecay[] getEnergyInducedDecay(long energyLevel) { - if (energeticDecayInstant < 0) { - return elementalDecays; - }else if (energeticDecayInstant>=elementalDecays.length){ - return cElementalDecay.noProduct; - } - return new cElementalDecay[]{elementalDecays[energeticDecayInstant]}; - } - - @Override - public double getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { - return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT *(newEnergyLevel-currentEnergyLevel); - } - - @Override - public boolean usesSpecialEnergeticDecayHandling() { - return false; - } - - @Override - public boolean usesMultipleDecayCalls(long energyLevel) { - return false; - } - - @Override - public boolean decayMakesEnergy(long energyLevel) { - return false; - } - - @Override - public boolean fusionMakesEnergy(long energyLevel) { - return false; - } - - @Override - public cElementalDecay[] getDecayArray() { - return elementalDecays; - } - - @Override - public double getRawTimeSpan(long currentEnergy) { - return rawLifeTime; - } - - @Override - public final cElementalDefinitionStackMap getSubParticles() { - return null; - } - - @Override - public aFluidDequantizationInfo someAmountIntoFluidStack() { - return null; - } - - @Override - public aItemDequantizationInfo someAmountIntoItemsStack() { - return null; - } - - @Override - public aOredictDequantizationInfo someAmountIntoOredictStack() { - return null; - } - - @Override - public byte getType() { - return type; - } - - @Override - public final NBTTagCompound toNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setByte("t", nbtType); - nbt.setInteger("c", ID); - return nbt; - } - - public static cElementalPrimitive fromNBT(NBTTagCompound content) { - cElementalPrimitive primitive = bindsBO.get(content.getInteger("c")); - return primitive == null ? null__ : primitive; - } - - @Override - public final byte getClassType() { - return -128; - } - - public static byte getClassTypeStatic(){ - return -128; - } - - @Override - public void addScanShortSymbols(ArrayList<String> lines, int capabilities, long energyLevel) { - if(areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add(getShortSymbol()); - } - } - - @Override - public void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel) { - if(areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { - lines.add("CLASS = " + nbtType + ' ' + getClassType()); - } - if(areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add("NAME = "+getName()); - lines.add("SYMBOL = "+getSymbol()); - } - if(areBitsSet(SCAN_GET_CHARGE,capabilities)) { - lines.add("CHARGE = " + getCharge() / 3D + " e"); - } - if(areBitsSet(SCAN_GET_COLOR,capabilities)) { - lines.add(getColor() < 0 ? "COLORLESS" : "CARRIES COLOR"); - } - if(areBitsSet(SCAN_GET_MASS,capabilities)) { - lines.add("MASS = " + getMass() + " eV/c\u00b2"); - } - if(areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)){ - lines.add((isTimeSpanHalfLife()?"HALF LIFE = ":"LIFE TIME = ")+getRawTimeSpan(energyLevel)+ " s"); - lines.add(" "+"At current energy level"); - } - } - - public static void run() { - try { - cElementalDefinition.addCreatorFromNBT(nbtType, cElementalPrimitive.class.getMethod("fromNBT", NBTTagCompound.class),(byte)-128); - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - if(DEBUG_MODE) { - TecTech.LOGGER.info("Registered Elemental Matter Class: Primitive " + nbtType + ' ' + -128); - } - } - - @Override - public final int compareTo(iElementalDefinition o) { - if (getClassType() == o.getClassType()) { - int oID = ((cElementalPrimitive) o).ID; - return Integer.compare(ID, oID); - } - return compareClassID(o); - } - - @Override - public final int hashCode() { - return ID; - } -}
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/iElementalDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/iElementalDefinition.java deleted file mode 100644 index 90ac2eb339..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/iElementalDefinition.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core.templates; - -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDefinitionStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aFluidDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aItemDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aOredictDequantizationInfo; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.ArrayList; - -/** - * Created by danie_000 on 11.11.2016. - */ -public abstract class iElementalDefinition implements Comparable<iElementalDefinition>,Cloneable {//IMMUTABLE - public static final double STABLE_RAW_LIFE_TIME =1.5e36D; - public static final double NO_DECAY_RAW_LIFE_TIME=-1D; - public static final long DEFAULT_ENERGY_LEVEL=0; - public static final double DEFAULT_ENERGY_REQUIREMENT=25000D;//legit cuz normal atoms should only emit a gamma if they don't have defined energy levels - - //Nomenclature - public abstract String getName(); - - public abstract String getSymbol(); - - public abstract String getShortSymbol(); - - public abstract void addScanShortSymbols(ArrayList<String> lines, int capabilities, long energyLevel); - - public abstract void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel); - - public abstract byte getType(); - - public abstract byte getClassType();//bigger number means bigger things usually, but it is just used to differentiate between classes of iED - - //Not dynamically changing stuff - public abstract iElementalDefinition getAnti();//gives new anti particle def - - public abstract cElementalDecay[] getDecayArray();//possible decays - - public abstract cElementalDecay[] getNaturalDecayInstant();//natural decay if lifespan <1tick - - public abstract cElementalDecay[] getEnergyInducedDecay(long energyLevel);//energetic decay - - public abstract boolean usesSpecialEnergeticDecayHandling(); - - public abstract boolean usesMultipleDecayCalls(long energyLevel); - - public abstract boolean decayMakesEnergy(long energyLevel); - - public abstract boolean fusionMakesEnergy(long energyLevel); - - public abstract double getEnergyDiffBetweenStates(long currentEnergy, long newEnergyLevel);//positive or negative - - public abstract double getMass();//mass... MeV/c^2 - - public abstract int getCharge();//charge 1/3 electron charge - - //dynamically changing stuff - public abstract byte getColor();//-1 nope cannot 0 it can but undefined - - public abstract double getRawTimeSpan(long currentEnergy);//defined in static fields or generated - - public abstract boolean isTimeSpanHalfLife(); - - public abstract cElementalDefinitionStackMap getSubParticles();//contents... null if none - - public abstract aFluidDequantizationInfo someAmountIntoFluidStack(); - - public abstract aItemDequantizationInfo someAmountIntoItemsStack(); - - public abstract aOredictDequantizationInfo someAmountIntoOredictStack(); - - public abstract NBTTagCompound toNBT(); - - public abstract cElementalDefinitionStack getStackForm(double amount); - - @Override - public abstract iElementalDefinition clone(); - - final int compareClassID(iElementalDefinition obj) { - return (int) getClassType() - obj.getClassType(); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMDequantizationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMDequantizationInfo.java new file mode 100644 index 0000000000..855be96797 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMDequantizationInfo.java @@ -0,0 +1,56 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.transformations; + +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class EMDequantizationInfo { + private final IEMStack definition; + private Object stack; + + public EMDequantizationInfo(IEMStack definition) { + this.definition = definition; + } + + public IEMStack getInput() { + return definition; + } + + public FluidStack getFluid() { + return ((FluidStack) stack).copy(); + } + + public void setFluid(FluidStack fluid) { + this.stack = fluid; + } + + public ItemStack getItem() { + return ((ItemStack) stack).copy(); + } + + public void setItem(ItemStack item) { + this.stack = item; + } + + public OreDictionaryStack getOre() { + return (OreDictionaryStack) stack; + } + + public void setOre(OreDictionaryStack ore) { + this.stack = ore; + } + + public Object getStack() { + return stack; + } + + @Override + public boolean equals(Object o) { + return o instanceof EMDequantizationInfo && definition.equals(((EMDequantizationInfo) o).definition); + } + + @Override + public int hashCode() { + return definition.hashCode(); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aFluidQuantizationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMFluidQuantizationInfo.java index 563b87f8ee..cf0cc6218c 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aFluidQuantizationInfo.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMFluidQuantizationInfo.java @@ -1,33 +1,31 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.transformations; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.iHasElementalDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; /** * Created by Tec on 23.05.2017. */ -public class aFluidQuantizationInfo implements iExchangeInfo<FluidStack,iHasElementalDefinition> { +public class EMFluidQuantizationInfo { private final FluidStack in; - private final iHasElementalDefinition out; + private final IEMStack out; - public aFluidQuantizationInfo(FluidStack fluidStackIn, iHasElementalDefinition emOut){ + public EMFluidQuantizationInfo(FluidStack fluidStackIn, IEMStack emOut){ in=fluidStackIn; out=emOut; } - public aFluidQuantizationInfo(Fluid fluid, int fluidAmount, iHasElementalDefinition emOut){ + public EMFluidQuantizationInfo(Fluid fluid, int fluidAmount, IEMStack emOut){ in=new FluidStack(fluid,fluidAmount); out=emOut; } - @Override public FluidStack input() { return in.copy(); } - @Override - public iHasElementalDefinition output() { + public IEMStack output() { return out.clone(); } @@ -38,6 +36,6 @@ public class aFluidQuantizationInfo implements iExchangeInfo<FluidStack,iHasElem @Override public boolean equals(Object obj) { - return obj instanceof aFluidQuantizationInfo && hashCode() == obj.hashCode(); + return obj instanceof EMFluidQuantizationInfo && hashCode() == obj.hashCode(); } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aItemQuantizationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMItemQuantizationInfo.java index 8f33f5096d..c5db63b3ad 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aItemQuantizationInfo.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMItemQuantizationInfo.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.transformations; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.iHasElementalDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; @@ -11,30 +11,28 @@ import net.minecraftforge.oredict.OreDictionary; /** * Created by Tec on 23.05.2017. */ -public class aItemQuantizationInfo implements iExchangeInfo<ItemStack,iHasElementalDefinition> { +public class EMItemQuantizationInfo { private final ItemStack in; - private final boolean skipNBT; - private final iHasElementalDefinition out; + private final boolean skipNBT; + private final IEMStack out; - public aItemQuantizationInfo(ItemStack itemStackIn, boolean skipNBT, iHasElementalDefinition emOut) { + public EMItemQuantizationInfo(ItemStack itemStackIn, boolean skipNBT, IEMStack emOut) { in = itemStackIn; out = emOut; this.skipNBT = skipNBT; } - public aItemQuantizationInfo(OrePrefixes prefix, Materials material, int amount, boolean skipNBT, iHasElementalDefinition emOut) { + public EMItemQuantizationInfo(OrePrefixes prefix, Materials material, int amount, boolean skipNBT, IEMStack emOut) { in = GT_OreDictUnificator.get(prefix, material, amount); out = emOut; this.skipNBT = skipNBT; } - @Override public ItemStack input() { return in.copy(); } - @Override - public iHasElementalDefinition output() { + public IEMStack output() { return out.clone(); } @@ -45,15 +43,15 @@ public class aItemQuantizationInfo implements iExchangeInfo<ItemStack,iHasElemen @Override public boolean equals(Object obj) { - if(obj instanceof aItemQuantizationInfo){ + if(obj instanceof EMItemQuantizationInfo){ //alias - ItemStack stack=((aItemQuantizationInfo) obj).in; - if(!in.getUnlocalizedName().equals(((aItemQuantizationInfo) obj).in.getUnlocalizedName())) { + ItemStack stack=((EMItemQuantizationInfo) obj).in; + if(!in.getUnlocalizedName().equals(((EMItemQuantizationInfo) obj).in.getUnlocalizedName())) { return false; } if(!GameRegistry.findUniqueIdentifierFor(in.getItem()).equals( - GameRegistry.findUniqueIdentifierFor(((aItemQuantizationInfo) obj).in.getItem()))) { + GameRegistry.findUniqueIdentifierFor(((EMItemQuantizationInfo) obj).in.getItem()))) { return false; } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMOredictQuantizationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMOredictQuantizationInfo.java new file mode 100644 index 0000000000..3c54dd86ac --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMOredictQuantizationInfo.java @@ -0,0 +1,55 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.transformations; + +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import net.minecraftforge.oredict.OreDictionary; + +/** + * Created by Tec on 23.05.2017. + */ +public class EMOredictQuantizationInfo { + private final int id; + private final int amount; + private final IEMStack out; + + public EMOredictQuantizationInfo(int id, int amount, IEMStack out) { + this.id = id; + this.amount = amount; + this.out = out; + } + + public EMOredictQuantizationInfo(String name, int qty, IEMStack emOut) { + this(OreDictionary.getOreID(name),qty,emOut); + } + + public EMOredictQuantizationInfo(OrePrefixes prefix, Materials material, int qty, IEMStack emOut) { + this(prefix, material.mName, qty,emOut); + } + + public EMOredictQuantizationInfo(OrePrefixes prefix, String materialName, int qty, IEMStack emOut) { + this(OreDictionary.getOreID(prefix.name() + materialName),qty,emOut); + } + + public IEMStack getOut() { + return out; + } + + @Override + public int hashCode() { + return getId(); + } + + @Override + public boolean equals(Object obj) { + return obj instanceof EMOredictQuantizationInfo && hashCode() == obj.hashCode(); + } + + public int getId() { + return id; + } + + public int getAmount() { + return amount; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMTransformationRegistry.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMTransformationRegistry.java new file mode 100644 index 0000000000..5e41beb9fd --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMTransformationRegistry.java @@ -0,0 +1,134 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.transformations; + +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.Function; + +import static java.lang.Math.pow; + +/** + * Created by Tec on 26.05.2017. + */ +public class EMTransformationRegistry { + /** + * Atom count per Mol + */ + public static final double AVOGADRO_CONSTANT = 6.02214076e23D; + /** + * Scale to 1m^3 of C-12 + */ + public static final double EM_COUNT_PER_CUBE = AVOGADRO_CONSTANT * 1650_000D / 0.012; + public static final double EM_COUNT_PER_MATERIAL_AMOUNT = EM_COUNT_PER_CUBE / 144 / 9; + public static final double EM_COUNT_PER_ITEM = EM_COUNT_PER_CUBE * 9; + public static final double EM_COUNT_PER_1k = EM_COUNT_PER_MATERIAL_AMOUNT * 1000; + + public static final double EM_COUNT_MINIMUM = 1 / EM_COUNT_PER_CUBE; + /** + * Quantity considered to be indifferent when computing stuff + */ + public static final double EM_COUNT_EPSILON = EM_COUNT_PER_CUBE / pow(2, 40); + + public static final double EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED = EM_COUNT_PER_MATERIAL_AMOUNT - EM_COUNT_EPSILON; + public static final double EM_COUNT_PER_CUBE_DIMINISHED = EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED * 144 * 9; + public static final double EM_COUNT_PER_ITEM_DIMINISHED = EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED * 144; + public static final double EM_COUNT_PER_1k_DIMINISHED = EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED * 1000; + + private final Map<Integer, EMFluidQuantizationInfo> fluidQuantization; + private final Map<EMItemQuantizationInfo, EMItemQuantizationInfo> itemQuantization; + private final Map<Integer, EMOredictQuantizationInfo> oredictQuantization; + + private final Map<IEMDefinition, EMDequantizationInfo> infoMap; + private final Function<IEMStack, EMDequantizationInfo> creator; + + public EMTransformationRegistry() { + this(EMDequantizationInfo::new); + } + + public EMTransformationRegistry(Function<IEMStack, EMDequantizationInfo> creator) { + this(creator, + new HashMap<>(16), new HashMap<>(16), new HashMap<>(64), + new HashMap<>(256) + ); + } + + public EMTransformationRegistry(Function<IEMStack, EMDequantizationInfo> creator, + Map<Integer, EMFluidQuantizationInfo> fluidQuantization, + Map<EMItemQuantizationInfo, EMItemQuantizationInfo> itemQuantization, + Map<Integer, EMOredictQuantizationInfo> oredictQuantization, + Map<IEMDefinition, EMDequantizationInfo> infoMap) { + this.creator = creator; + this.fluidQuantization = fluidQuantization; + this.itemQuantization = itemQuantization; + this.oredictQuantization = oredictQuantization; + this.infoMap = infoMap; + } + + protected EMDequantizationInfo compute(IEMStack em) { + return infoMap.computeIfAbsent(em.getDefinition(), stack -> creator.apply(em)); + } + + public void addFluid(IEMStack em, FluidStack fluidStack) { + getFluidQuantization().put(fluidStack.getFluidID(), new EMFluidQuantizationInfo(fluidStack, em)); + compute(em).setFluid(fluidStack); + } + + public void addFluid(IEMStack em, Fluid fluid, int fluidAmount) { + addFluid(em, new FluidStack(fluid, fluidAmount)); + } + + protected void addItemQuantization(EMItemQuantizationInfo aIQI) { + getItemQuantization().put(aIQI, aIQI); + } + + public void addItem(IEMStack em, ItemStack itemStack, boolean skipNBT) { + addItemQuantization(new EMItemQuantizationInfo(itemStack, skipNBT, em)); + compute(em).setItem(itemStack); + } + + public void addItem(IEMStack em, OrePrefixes prefix, Materials material, int amount, boolean skipNBT) { + addItem(em, GT_OreDictUnificator.get(prefix, material, amount), skipNBT); + } + + public void addOredict(IEMStack em, int id, int qty) { + getOredictQuantization().put(id, new EMOredictQuantizationInfo(id, qty, em)); + compute(em).setOre(new OreDictionaryStack(qty, id)); + } + + public void addOredict(IEMStack em, String name, int qty) { + addOredict(em, OreDictionary.getOreID(name), qty); + } + + public void addOredict(IEMStack em, OrePrefixes prefix, Materials material, int qty) { + addOredict(em, prefix, material.mName, qty); + } + + public void addOredict(IEMStack em, OrePrefixes prefix, String materialName, int qty) { + addOredict(em, OreDictionary.getOreID(prefix.name() + materialName), qty); + } + + public Map<Integer, EMFluidQuantizationInfo> getFluidQuantization() { + return fluidQuantization; + } + + public Map<EMItemQuantizationInfo, EMItemQuantizationInfo> getItemQuantization() { + return itemQuantization; + } + + public Map<Integer, EMOredictQuantizationInfo> getOredictQuantization() { + return oredictQuantization; + } + + public Map<IEMDefinition, EMDequantizationInfo> getInfoMap() { + return infoMap; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/OreDictionaryStack.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/OreDictionaryStack.java new file mode 100644 index 0000000000..f5d8d42061 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/OreDictionaryStack.java @@ -0,0 +1,19 @@ +package com.github.technus.tectech.mechanics.elementalMatter.core.transformations; + +public class OreDictionaryStack { + private final int amount; + private final int id; + + public OreDictionaryStack(int amount, int id) { + this.amount = amount; + this.id = id; + } + + public int getAmount() { + return amount; + } + + public int getOreId() { + return id; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aFluidDequantizationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aFluidDequantizationInfo.java deleted file mode 100644 index 3d8b7a881f..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aFluidDequantizationInfo.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core.transformations; - -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.iHasElementalDefinition; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; - -/** - * Created by Tec on 23.05.2017. - */ -public class aFluidDequantizationInfo implements iExchangeInfo<iHasElementalDefinition,FluidStack> { - private final iHasElementalDefinition in; - private final FluidStack out; - - public aFluidDequantizationInfo(iHasElementalDefinition emIn, FluidStack fluidStackOut){ - in=emIn; - out=fluidStackOut; - } - - public aFluidDequantizationInfo(iHasElementalDefinition emIn, Fluid fluid, int fluidAmount){ - in=emIn; - out=new FluidStack(fluid,fluidAmount); - } - - @Override - public iHasElementalDefinition input() { - return in.clone();//MEH! - } - - @Override - public FluidStack output() { - return out.copy(); - } - - @Override - public int hashCode() { - return in.getDefinition().hashCode(); - } - - @Override - public boolean equals(Object obj) { - return obj instanceof aFluidDequantizationInfo && hashCode() == obj.hashCode(); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aItemDequantizationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aItemDequantizationInfo.java deleted file mode 100644 index 8b42c61d6c..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aItemDequantizationInfo.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core.transformations; - -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.iHasElementalDefinition; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.util.GT_OreDictUnificator; -import net.minecraft.item.ItemStack; - -/** - * Created by Tec on 23.05.2017. - */ -public class aItemDequantizationInfo implements iExchangeInfo<iHasElementalDefinition,ItemStack> { - private final iHasElementalDefinition in; - private final ItemStack out; - - public aItemDequantizationInfo(iHasElementalDefinition emIn, ItemStack itemStackOut){ - in=emIn; - out=itemStackOut; - } - - public aItemDequantizationInfo(iHasElementalDefinition emIn, OrePrefixes prefix, Materials material, int amount) { - in = emIn; - out = GT_OreDictUnificator.get(prefix, material, amount); - } - - @Override - public iHasElementalDefinition input() { - return in.clone(); - } - - @Override - public ItemStack output() { - return out.copy(); - } - - @Override - public int hashCode() { - return in.getDefinition().hashCode(); - } - - @Override - public boolean equals(Object obj) { - return obj instanceof aItemDequantizationInfo && hashCode() == obj.hashCode(); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aOredictDequantizationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aOredictDequantizationInfo.java deleted file mode 100644 index bbf94682b4..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aOredictDequantizationInfo.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core.transformations; - -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.iHasElementalDefinition; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; - -/** - * Created by Tec on 23.05.2017. - */ -public class aOredictDequantizationInfo implements iExchangeInfo<iHasElementalDefinition,String> { - private final iHasElementalDefinition in; - public final String out; - public final int amount; - - public aOredictDequantizationInfo(iHasElementalDefinition emIn, String name, int qty) { - in = emIn; - out =name; - amount = qty; - } - - public aOredictDequantizationInfo(iHasElementalDefinition emIn, OrePrefixes prefix, Materials material, int qty) { - in = emIn; - out = prefix.name() + material.mName; - amount = qty; - } - - public aOredictDequantizationInfo(iHasElementalDefinition emIn, OrePrefixes prefix, String materialName, int qty) { - in = emIn; - out = prefix.name() + materialName; - amount = qty; - } - - @Override - public iHasElementalDefinition input() { - return in.clone();//MEH! - } - - @Override - public String output() { - return out; - } - - @Override - public int hashCode() { - return in.getDefinition().hashCode(); - } - - @Override - public boolean equals(Object obj) { - return obj instanceof aOredictDequantizationInfo && hashCode() == obj.hashCode(); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aOredictQuantizationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aOredictQuantizationInfo.java deleted file mode 100644 index 964d317b80..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/aOredictQuantizationInfo.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core.transformations; - -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.iHasElementalDefinition; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; - -/** - * Created by Tec on 23.05.2017. - */ -public class aOredictQuantizationInfo implements iExchangeInfo<String,iHasElementalDefinition> { - public final String in; - public final int amount; - private final iHasElementalDefinition out; - - public aOredictQuantizationInfo(String name, int qty, iHasElementalDefinition emOut){ - in=name; - amount=qty; - out=emOut; - } - - public aOredictQuantizationInfo(OrePrefixes prefix, Materials material, int qty, iHasElementalDefinition emOut){ - in=prefix.name() + material.mName; - amount=qty; - out=emOut; - } - - public aOredictQuantizationInfo(OrePrefixes prefix, String materialName, int qty, iHasElementalDefinition emOut){ - in=prefix.name() + materialName; - amount=qty; - out=emOut; - } - - @Override - public String input() { - return in; - } - - @Override - public iHasElementalDefinition output() { - return out.clone(); - } - - @Override - public int hashCode() { - return in.hashCode(); - } - - @Override - public boolean equals(Object obj) { - return obj instanceof aOredictQuantizationInfo && hashCode() == obj.hashCode(); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java deleted file mode 100644 index 55ee24e2f6..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core.transformations; - -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.iHasElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.oredict.OreDictionary; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import static com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM.STACKS_REGISTERED; - -/** - * Created by Tec on 26.05.2017. - */ -public class bTransformationInfo { - public static final double AVOGADRO_CONSTANT =6.02214076e23D; - public static final double AVOGADRO_CONSTANT_UNCERTAINTY =(144*1000)/6.02214076e23D; - public static final double AVOGADRO_CONSTANT_144 = AVOGADRO_CONSTANT *144D; - - public static final Map<Integer,aFluidQuantizationInfo> fluidQuantization=new HashMap<>(32); - public static final Map<aItemQuantizationInfo,aItemQuantizationInfo> itemQuantization=new HashMap<>(32); - public static final Map<Integer,aOredictQuantizationInfo> oredictQuantization=new HashMap<>(32); - - public Map<iElementalDefinition,aFluidDequantizationInfo> fluidDequantization; - public Map<iElementalDefinition,aItemDequantizationInfo> itemDequantization; - public Map<iElementalDefinition,aOredictDequantizationInfo> oredictDequantization; - - public bTransformationInfo(int fluidCap,int itemCap, int oreCap){ - fluidDequantization = fluidCap > 0 ? new HashMap<>(fluidCap) : Collections.emptyMap(); - itemDequantization = itemCap > 0 ? new HashMap<>(itemCap) : Collections.emptyMap(); - oredictDequantization = oreCap > 0 ? new HashMap<>(oreCap) : Collections.emptyMap(); - } - - public void addFluid(iHasElementalDefinition em, FluidStack fluidStack){ - fluidQuantization.put(fluidStack.getFluidID(),new aFluidQuantizationInfo(fluidStack,em)); - fluidDequantization.put(em.getDefinition(),new aFluidDequantizationInfo(em,fluidStack)); - STACKS_REGISTERED.add(em.getDefinition()); - STACKS_REGISTERED.add(em.getDefinition().getAnti()); - } - - public void addFluid(iHasElementalDefinition em, Fluid fluid, int fluidAmount){ - fluidQuantization.put(fluid.getID(),new aFluidQuantizationInfo(fluid,fluidAmount,em)); - fluidDequantization.put(em.getDefinition(),new aFluidDequantizationInfo(em,fluid,fluidAmount)); - STACKS_REGISTERED.add(em.getDefinition()); - STACKS_REGISTERED.add(em.getDefinition().getAnti()); - } - - private void addItemQuantization(aItemQuantizationInfo aIQI){ - itemQuantization.put(aIQI,aIQI); - } - - public void addItem(iHasElementalDefinition em, ItemStack itemStack, boolean skipNBT){ - addItemQuantization(new aItemQuantizationInfo(itemStack,skipNBT,em)); - itemDequantization.put(em.getDefinition(),new aItemDequantizationInfo(em,itemStack)); - STACKS_REGISTERED.add(em.getDefinition()); - STACKS_REGISTERED.add(em.getDefinition().getAnti()); - } - - public void addItem(iHasElementalDefinition em, OrePrefixes prefix, Materials material, int amount, boolean skipNBT){ - addItemQuantization(new aItemQuantizationInfo(prefix,material,amount,skipNBT,em)); - itemDequantization.put(em.getDefinition(),new aItemDequantizationInfo(em,prefix,material,amount)); - STACKS_REGISTERED.add(em.getDefinition()); - STACKS_REGISTERED.add(em.getDefinition().getAnti()); - } - - public void addOredict(iHasElementalDefinition em, String name, int qty){ - oredictQuantization.put(OreDictionary.getOreID(name),new aOredictQuantizationInfo(name,qty,em)); - oredictDequantization.put(em.getDefinition(),new aOredictDequantizationInfo(em,name,qty)); - STACKS_REGISTERED.add(em.getDefinition()); - STACKS_REGISTERED.add(em.getDefinition().getAnti()); - } - - public void addOredict(iHasElementalDefinition em, OrePrefixes prefix, Materials material, int qty){ - oredictQuantization.put(OreDictionary.getOreID(prefix.name() + material.mName),new aOredictQuantizationInfo(prefix,material,qty,em)); - oredictDequantization.put(em.getDefinition(),new aOredictDequantizationInfo(em,prefix,material,qty)); - STACKS_REGISTERED.add(em.getDefinition()); - STACKS_REGISTERED.add(em.getDefinition().getAnti()); - } - - public void addOredict(iHasElementalDefinition em, OrePrefixes prefix, String materialName, int qty){ - oredictQuantization.put(OreDictionary.getOreID(prefix.name() + materialName),new aOredictQuantizationInfo(prefix,materialName,qty,em)); - oredictDequantization.put(em.getDefinition(),new aOredictDequantizationInfo(em,prefix,materialName,qty)); - STACKS_REGISTERED.add(em.getDefinition()); - STACKS_REGISTERED.add(em.getDefinition().getAnti()); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/iExchangeInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/iExchangeInfo.java deleted file mode 100644 index 2e8ef92073..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/iExchangeInfo.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core.transformations; - -/** - * Created by Tec on 23.05.2017. - */ -public interface iExchangeInfo<IN,OUT> { - OUT output();//what should be given - ItemStack,FluidStack,AspectStack, (EM definitionStack->)EM instance stack - etc. - //This must return new Object! - if obj is immutable don't care that much (applies to defStacks) - - IN input();//same as above but for input -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMAtomDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMAtomDefinition.java new file mode 100644 index 0000000000..03c57a754e --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMAtomDefinition.java @@ -0,0 +1,1682 @@ +package com.github.technus.tectech.mechanics.elementalMatter.definitions.complex; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; +import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMComplexTemplate; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMIndirectType; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMDefinitionStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMLeptonDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMNeutrinoDefinition; +import com.github.technus.tectech.util.TT_Utility; +import com.github.technus.tectech.util.XSTR; + +import java.util.*; + +import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.boson_Y__; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.deadEnd; +import static com.github.technus.tectech.util.XSTR.XSTR_INSTANCE; +import static gregtech.api.enums.Materials.*; +import static gregtech.api.enums.OrePrefixes.dust; +import static java.lang.Math.abs; +import static net.minecraft.util.StatCollector.translateToLocal; + +/** + * Created by danie_000 on 18.11.2016. + */ +public class EMAtomDefinition extends EMComplexTemplate { + private static final String[] SYMBOL = new String[]{"Nt", "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og"}; + private static final String[] NAME = new String[]{"Neutronium", "Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminium", "Silicon", "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Caesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum", "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium", "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Nihonium", "Flerovium", "Moscovium", "Livermorium", "Tennessine", "Oganesson"}; + private static final String[] SYMBOL_IUPAC = new String[]{"n", "u", "b", "t", "q", "p", "h", "s", "o", "e", "N", "U", "B", "T", "Q", "P", "H", "S", "O", "E"}; + + public static final long ATOM_COMPLEXITY_LIMIT = 65536L; + private static final byte BYTE_OFFSET = 32; + + private final int hash; + public static double refMass, refUnstableMass; + + private static final String nbtType = "a"; + private static final Random xstr = new XSTR();//NEEDS SEPARATE! + private static Map<Integer, TreeSet<Integer>> stableIsotopes = new HashMap<>(); + private static final Map<Integer, EMAtomDefinition> stableAtoms = new HashMap<>(); + private static Map<Integer, TreeMap<Double, Integer>> mostStableUnstableIsotopes = new HashMap<>(); + private static final Map<Integer, EMAtomDefinition> unstableAtoms = new HashMap<>(); + private static EMDefinitionStack alpha, deuterium, tritium, helium_3, beryllium_8, carbon_14, neon_24, silicon_34, uranium_238, uranium_235, plutonium_239, plutonium_241; + private static final HashMap<EMAtomDefinition, Double> lifetimeOverrides = new HashMap<>(); + + private final EMNuclideIAEA iaea; + + private static EMAtomDefinition somethingHeavy; + + public static EMAtomDefinition getSomethingHeavy() { + return somethingHeavy; + } + + private static final ArrayList<Runnable> overrides = new ArrayList<>(); + + public static void addOverride(EMAtomDefinition atom, double rawLifeTime) { + lifetimeOverrides.put(atom, rawLifeTime); + } + + //float-mass in eV/c^2 + private final double mass; + //public final int charge; + private final int charge; + //int -electric charge in 1/3rds of electron charge for optimization + private final int chargeLeptons; + private final double rawLifeTime; + //generation max present inside - minus if contains any anti quark + private final byte type; + + private final byte decayMode;//t neutron to proton+,0,f proton to neutron + //public final boolean stable; + + private final int neutralCount; + private final int element; + + private final boolean iaeaDefinitionExistsAndHasEnergyLevels; + + private final EMConstantStackMap elementalStacks; + + //stable is rawLifeTime>=10^9 + + public EMAtomDefinition(EMDefinitionStack... things) throws EMException { + this(true, new EMConstantStackMap(things)); + } + + private EMAtomDefinition(boolean check, EMDefinitionStack... things) throws EMException { + this(check, new EMConstantStackMap(things)); + } + + public EMAtomDefinition(EMConstantStackMap things) throws EMException { + this(true, things); + } + + private EMAtomDefinition(boolean check, EMConstantStackMap things) throws EMException { + if (check && !canTheyBeTogether(things)) { + throw new EMException("Atom Definition error"); + } + elementalStacks = things; + + double mass = 0; + int cLeptons = 0; + int cNucleus = 0; + int neutralCount = 0, element = 0; + int type = 0; + boolean containsAnti = false; + for (EMDefinitionStack stack : elementalStacks.valuesToArray()) { + IEMDefinition def = stack.getDefinition(); + int amount = (int) stack.getAmount(); + if ((int) stack.getAmount() != stack.getAmount()) { + throw new ArithmeticException("Amount cannot be safely converted to int!"); + } + mass += stack.getMass(); + if (def.getGeneration() < 0) { + containsAnti = true; + } + type = Math.max(type, abs(def.getGeneration())); + + if (def instanceof EMLeptonDefinition) { + cLeptons += stack.getCharge(); + } else { + cNucleus += stack.getCharge(); + if (def.getCharge() == 3) { + element += amount; + } else if (def.getCharge() == -3) { + element -= amount; + } else if (def.getCharge() == 0) { + neutralCount += amount; + } + } + } + this.type = containsAnti ? (byte) -type : (byte) type; + //this.mass = mass; + chargeLeptons = cLeptons; + charge = cNucleus + cLeptons; + this.neutralCount = neutralCount; + this.element = element; + + element = abs(element); + + //stability curve + int StableIsotope = stableIzoCurve(element); + int izoDiff = neutralCount - StableIsotope; + int izoDiffAbs = abs(izoDiff); + + xstr.setSeed((element + 1L) * (neutralCount + 100L)); + iaea = EMNuclideIAEA.get(element, neutralCount); + if (getIaea() != null) { + if (Double.isNaN(getIaea().getMass())) { + this.mass = mass; + } else { + this.mass = getIaea().getMass(); + } + + if (Double.isNaN(getIaea().getHalfTime())) { + Double overriddenLifeTime = lifetimeOverrides.get(this); + double rawLifeTimeTemp; + if (overriddenLifeTime != null) { + rawLifeTimeTemp = overriddenLifeTime; + } else { + rawLifeTimeTemp = calculateLifeTime(izoDiff, izoDiffAbs, element, neutralCount, containsAnti); + } + rawLifeTime = Math.min(rawLifeTimeTemp, STABLE_RAW_LIFE_TIME); + } else { + rawLifeTime = containsAnti ? getIaea().getHalfTime() * 1.5514433E-21d * (1d + xstr.nextDouble() * 9d) : getIaea().getHalfTime(); + } + iaeaDefinitionExistsAndHasEnergyLevels = getIaea().getEnergeticStatesArray().length > 1; + } else { + this.mass = mass; + + Double overriddenLifeTime = lifetimeOverrides.get(this); + double rawLifeTimeTemp; + if (overriddenLifeTime != null) { + rawLifeTimeTemp = overriddenLifeTime; + } else { + rawLifeTimeTemp = calculateLifeTime(izoDiff, izoDiffAbs, element, neutralCount, containsAnti); + } + rawLifeTime = Math.min(rawLifeTimeTemp, STABLE_RAW_LIFE_TIME); + + iaeaDefinitionExistsAndHasEnergyLevels = false; + } + + if (getIaea() == null || getIaea().getEnergeticStatesArray()[0].energy != 0) { + if (izoDiff == 0) { + decayMode = 0; + } else { + decayMode = izoDiff > 0 ? (byte) Math.min(2, 1 + izoDiffAbs / 4) : (byte) -Math.min(2, 1 + izoDiffAbs / 4); + } + } else { + decayMode = izoDiff > 0 ? (byte) (Math.min(2, 1 + izoDiffAbs / 4) + BYTE_OFFSET) : (byte) (-Math.min(2, 1 + izoDiffAbs / 4) + BYTE_OFFSET); + } + //this.stable = this.rawLifeTime >= STABLE_RAW_LIFE_TIME; + hash = super.hashCode(); + } + + private static int stableIzoCurve(int element) { + return (int) Math.round(-1.19561E-06D * Math.pow(element, 4D) + + 1.60885E-04D * Math.pow(element, 3D) + + 3.76604E-04D * Math.pow(element, 2D) + + 1.08418E+00D * (double) element); + } + + private static double calculateLifeTime(int izoDiff, int izoDiffAbs, int element, int isotope, boolean containsAnti) { + double rawLifeTime; + + if (element <= 83 && isotope < 127 && (izoDiffAbs == 0 || element == 1 && isotope == 0 || element == 2 && isotope == 1 || izoDiffAbs == 1 && element > 2 && element % 2 == 1 || izoDiffAbs == 3 && element > 30 && element % 2 == 0 || izoDiffAbs == 5 && element > 30 && element % 2 == 0 || izoDiffAbs == 2 && element > 20 && element % 2 == 1)) { + rawLifeTime = (1D + xstr.nextDouble() * 9D) * (containsAnti ? 2.381e4D : 1.5347e25D); + } else { + //Y = (X-A)/(B-A) * (D-C) + C + double unstabilityEXP; + if (element == 0) { + return 1e-35D; + } else if (element == 1) { + unstabilityEXP = 1.743D - abs(izoDiff - 1) * 9.743D; + } else if (element == 2) { + switch (isotope) { + case 4: + unstabilityEXP = 1.61D; + break; + case 5: + unstabilityEXP = -7.523D; + break; + case 6: + unstabilityEXP = -1.51D; + break; + default: + unstabilityEXP = -(izoDiffAbs * 6.165D); + break; + } + } else if (element <= 83 || isotope <= 127 && element <= 120) { + double elementPow4 = Math.pow(element, 4); + + unstabilityEXP = Math.min(element / 2.4D, 6 + ((element + 1) % 2) * 3e6D / elementPow4) + -izoDiff * elementPow4 / 1e8D - abs(izoDiff - 1 + element / 60D) * (3D - element / 12.5D + element * element / 1500D); + } else if (element < 180) { + unstabilityEXP = Math.min((element - 85) * 2, 16 + ((isotope + 1) % 2) * 2.5D - (element - 85) / 3D) - abs(izoDiff) * (3D - element / 13D + element * element / 1600D); + } else { + return -1; + } + if ((isotope == 127 || isotope == 128) && element < 120 && element > 83) { + unstabilityEXP -= 1.8D; + } + if (element > 83 && element < 93 && isotope % 2 == 0 && izoDiff == 3) { + unstabilityEXP += 6; + } + if (element > 93 && element < 103 && isotope % 2 == 0 && izoDiff == 4) { + unstabilityEXP += 6; + } + rawLifeTime = (containsAnti ? 1e-8D : 1) * Math.pow(10D, unstabilityEXP) * (1D + xstr.nextDouble() * 9D); + } + + if (rawLifeTime < 8e-15D) { + return 1e-35D; + } + if (rawLifeTime > 8e28D) { + return 8e30D; + } + return rawLifeTime; + } + + private static boolean canTheyBeTogether(EMConstantStackMap stacks) { + boolean nuclei = false; + long qty = 0; + for (EMDefinitionStack stack : stacks.valuesToArray()) { + if (stack.getDefinition() instanceof EMHadronDefinition) { + if (((EMHadronDefinition) stack.getDefinition()).getAmount() != 3) { + return false; + } + nuclei = true; + } else if (!(stack.getDefinition() instanceof EMLeptonDefinition)) { + return false; + } + if ((int) stack.getAmount() != stack.getAmount()) { + throw new ArithmeticException("Amount cannot be safely converted to int!"); + } + qty += stack.getAmount(); + } + return nuclei && qty < ATOM_COMPLEXITY_LIMIT; + } + + @Override + public int getCharge() { + return charge; + } + + public int getChargeLeptons() { + return chargeLeptons; + } + + public int getChargeHadrons() { + return getCharge() - getChargeLeptons(); + } + + public int getIonizationElementWise() { + return getElement() * 3 + getChargeLeptons(); + } + + @Override + public double getMass() { + return mass; + } + + @Override + public int getGeneration() { + return type; + } + + @Override + public double getRawTimeSpan(long currentEnergy) { + if (currentEnergy <= 0) { + return rawLifeTime; + } + if (iaeaDefinitionExistsAndHasEnergyLevels) { + if (currentEnergy >= getIaea().getEnergeticStatesArray().length) { + return getIaea().getEnergeticStatesArray()[getIaea().getEnergeticStatesArray().length - 1].Thalf / (currentEnergy - getIaea().getEnergeticStatesArray().length + 1); + } + return getIaea().getEnergeticStatesArray()[(int) currentEnergy].Thalf; + } + return rawLifeTime / (currentEnergy + 1); + } + + @Override + public boolean isTimeSpanHalfLife() { + return true; + } + + @Override + public int getMaxColors() { + return -10; + } + + @Override + public String getLocalizedTypeName() { + return translateToLocal("tt.keyword.Element"); + } + + @Override + public String getShortLocalizedName() { + int element = abs(getElement()); + boolean anti = getElement() < 0; + boolean weird = abs(getGeneration()) != 1; + if(element>=NAME.length){ + StringBuilder s = new StringBuilder(); + if(anti){ + s.append(translateToLocal("tt.IUPAC.Anti")); + do { + s.append(translateToLocal("tt.IUPAC."+SYMBOL_IUPAC[element % 10])); + element = element / 10; + } while (element > 0); + }else { + while (element >= 10) { + s.append(translateToLocal("tt.IUPAC."+SYMBOL_IUPAC[element % 10])); + element = element / 10; + } + s.append(translateToLocal("tt.IUPAC."+SYMBOL_IUPAC[element + 10])); + } + if(weird){ + s.append(translateToLocal("tt.keyword.Weird")); + } + return s.toString(); + } + return translateToLocal("tt.element."+(anti?"Anti":"")+NAME[element])+(weird?translateToLocal("tt.keyword.Weird"):""); + } + + @Override + public String getSymbol() { + String ionName = ""; + int ionization = getCharge() / 3; + if(ionization>0){ + ionName = ionization == 1 ? TT_Utility.toSuperscript("+") : TT_Utility.toSuperscript(ionization + "+"); + }else if(ionization<0) { + ionName = ionization == -1 ? TT_Utility.toSuperscript("-") : TT_Utility.toSuperscript(-ionization + "-"); + } + return TT_Utility.toSuperscript(Long.toString(getNeutralCount() + (long)getElement())) +getShortSymbol()+ ionName; + } + + @Override + public String getShortSymbol() { + int element = abs(getElement()); + boolean anti = getElement() < 0; + boolean weird = abs(getGeneration()) != 1; + if(element>=SYMBOL.length){ + StringBuilder s = new StringBuilder(anti?"~":""); + while (element >= 10) { + s.append(SYMBOL_IUPAC[element % 10]); + element = element / 10; + } + s.append(SYMBOL_IUPAC[element + 10]); + if(weird){ + s.append(translateToLocal("tt.keyword.Weird")); + } + return s.toString(); + } + return (anti?"~":"")+SYMBOL[element]+(weird?translateToLocal("tt.keyword.Weird"):""); + } + + @Override + public EMConstantStackMap getSubParticles() { + return elementalStacks.clone(); + } + + @Override + public EMDecay[] getDecayArray() { + ArrayList<EMDecay> decaysList = new ArrayList<>(4); + return getDecayArray(decaysList, getDecayMode(), true); + } + + private EMDecay[] getDecayArray(ArrayList<EMDecay> decaysList, int decayMode, boolean tryAnti) {//todo? + if (getGeneration() == 1) { + switch (decayMode) { + case -2: + if (TecTech.RANDOM.nextBoolean() && ElectronCapture(decaysList)) { + return decaysList.toArray(EMDecay.NO_PRODUCT); + } else if (PbetaDecay(decaysList)) { + return decaysList.toArray(EMDecay.NO_PRODUCT); + } + break; + case -1: + if (Emmision(decaysList, EMHadronDefinition.hadron_p1)) { + return decaysList.toArray(EMDecay.NO_PRODUCT); + } + break; + case 0: + if (alphaDecay(decaysList)) { + return decaysList.toArray(EMDecay.NO_PRODUCT); + } + break; + case 1: + if (Emmision(decaysList, EMHadronDefinition.hadron_n1)) { + return decaysList.toArray(EMDecay.NO_PRODUCT); + } + break; + case 2: + if (MbetaDecay(decaysList)) { + return decaysList.toArray(EMDecay.NO_PRODUCT); + } + break; + default: + if (decayMode > 8) { + if (iaeaDecay(decaysList, 0)) { + return decaysList.toArray(EMDecay.NO_PRODUCT); + } + return getDecayArray(decaysList, decayMode - BYTE_OFFSET, false); + } + } + return EMDecay.NO_DECAY; + } else if (getGeneration() == -1) { + EMAtomDefinition anti = getAnti(); + if (anti != null) { + return anti.getDecayArray(decaysList, decayMode, false); + } + } + return getNaturalDecayInstant(); + } + + private boolean iaeaDecay(ArrayList<EMDecay> decaysList, long energy) { + EMNuclideIAEA.energeticState state; + if (energy > getIaea().getEnergeticStatesArray().length) { + state = getIaea().getEnergeticStatesArray()[getIaea().getEnergeticStatesArray().length - 1]; + } else if (energy <= 0) { + state = getIaea().getEnergeticStatesArray()[0]; + } else { + state = getIaea().getEnergeticStatesArray()[(int) energy]; + } + for (int i = 0; i < state.decaymodes.length; i++) { + if (!getDecayFromIaea(decaysList, state.decaymodes[i], energy)) { + decaysList.clear(); + return false; + } + } + return !decaysList.isEmpty(); + } + + private boolean getDecayFromIaea(ArrayList<EMDecay> decaysList, EMNuclideIAEA.iaeaDecay decay, long energy) { + EMDefinitionStackMap withThis = elementalStacks.toMutable(), newStuff = new EMDefinitionStackMap(); + switch (decay.decayName) { + case "D": { + if (withThis.removeAllAmountsExact(deuterium.getDefinition().getSubParticles())) { + withThis.putReplace(deuterium); + decaysList.add(new EMDecay(decay.chance, withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } + } + break; + case "3H": { + if (withThis.removeAllAmountsExact(tritium.getDefinition().getSubParticles())) { + withThis.putReplace(tritium); + decaysList.add(new EMDecay(decay.chance, withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } + } + break; + case "3HE": { + if (withThis.removeAllAmountsExact(helium_3.getDefinition().getSubParticles())) { + withThis.putReplace(helium_3); + decaysList.add(new EMDecay(decay.chance, withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } + } + break; + case "8BE": { + if (withThis.removeAllAmountsExact(beryllium_8.getDefinition().getSubParticles())) { + withThis.putReplace(beryllium_8); + decaysList.add(new EMDecay(decay.chance, withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } + } + break; + case "14C": { + if (withThis.removeAllAmountsExact(carbon_14.getDefinition().getSubParticles())) { + newStuff.putReplace(carbon_14); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "24NE": { + if (withThis.removeAllAmountsExact(neon_24.getDefinition().getSubParticles())) { + newStuff.putReplace(neon_24); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "34SI": { + if (withThis.removeAllAmountsExact(silicon_34.getDefinition().getSubParticles())) { + newStuff.putReplace(silicon_34); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "A": + case "A?": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n2, EMHadronDefinition.hadron_p2)) { + newStuff.putReplace(alpha); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "B+": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p1)) { + withThis.putUnifyExact(EMHadronDefinition.hadron_n1); + newStuff.putReplace(EMLeptonDefinition.lepton_e_1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve1); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "2B+": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p2)) { + withThis.putUnifyExact(EMHadronDefinition.hadron_n2); + newStuff.putReplace(EMLeptonDefinition.lepton_e_2); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve2); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "B-": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n1)) { + withThis.putUnifyExact(EMHadronDefinition.hadron_p1); + newStuff.putReplace(EMLeptonDefinition.lepton_e1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve_1); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "2B-": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n2)) { + withThis.putUnifyExact(EMHadronDefinition.hadron_p2); + newStuff.putReplace(EMLeptonDefinition.lepton_e2); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve_2); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "EC": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p1, EMLeptonDefinition.lepton_e1)) { + withThis.putUnifyExact(EMHadronDefinition.hadron_n1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve1); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "2EC": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p2, EMLeptonDefinition.lepton_e2)) { + withThis.putUnifyExact(EMHadronDefinition.hadron_n2); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve2); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "B++EC": + case "EC+B+": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p2, EMLeptonDefinition.lepton_e1)) { + withThis.putUnifyExact(EMHadronDefinition.hadron_n2); + newStuff.putReplace(EMLeptonDefinition.lepton_e_1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve2); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "B+A": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p3, EMHadronDefinition.hadron_n1)) { + newStuff.putReplace(EMLeptonDefinition.lepton_e_1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve1); + newStuff.putReplace(alpha); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "B+P": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p2)) { + withThis.putUnifyExact(EMHadronDefinition.hadron_n1); + newStuff.putReplace(EMLeptonDefinition.lepton_e_1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve1); + newStuff.putReplace(EMHadronDefinition.hadron_p1); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "B+2P": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p3)) { + withThis.putUnifyExact(EMHadronDefinition.hadron_n1); + newStuff.putReplace(EMLeptonDefinition.lepton_e_1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve1); + newStuff.putReplace(EMHadronDefinition.hadron_p2); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "B-A": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n3, EMHadronDefinition.hadron_p1)) { + newStuff.putReplace(EMLeptonDefinition.lepton_e1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve_1); + newStuff.putReplace(alpha); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "B-N": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n2)) { + withThis.putUnifyExact(EMHadronDefinition.hadron_p1); + newStuff.putReplace(EMLeptonDefinition.lepton_e1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve_1); + newStuff.putReplace(EMHadronDefinition.hadron_n1); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "B-2N": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n3)) { + withThis.putUnifyExact(EMHadronDefinition.hadron_p1); + newStuff.putReplace(EMLeptonDefinition.lepton_e1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve_1); + newStuff.putReplace(EMHadronDefinition.hadron_n2); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "B-P": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n1)) { + newStuff.putReplace(EMLeptonDefinition.lepton_e1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve_1); + newStuff.putReplace(EMHadronDefinition.hadron_p1); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "ECA": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n1, EMLeptonDefinition.lepton_e1, EMHadronDefinition.hadron_p3)) { + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve1); + newStuff.putReplace(alpha); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "ECP": { + if (withThis.removeAllAmountsExact(EMLeptonDefinition.lepton_e1, EMHadronDefinition.hadron_p2)) { + withThis.putUnifyExact(EMHadronDefinition.hadron_n1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve1); + newStuff.putReplace(EMHadronDefinition.hadron_p1); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "EC2P": { + if (withThis.removeAllAmountsExact(EMLeptonDefinition.lepton_e1, EMHadronDefinition.hadron_p3)) { + withThis.putUnifyExact(EMHadronDefinition.hadron_n1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve1); + newStuff.putReplace(EMHadronDefinition.hadron_p2); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "ECP+EC2P": {//todo look at branching ratios + if (withThis.removeAllAmountsExact(EMLeptonDefinition.lepton_e2, EMHadronDefinition.hadron_p5)) { + withThis.putUnifyExact(EMHadronDefinition.hadron_n1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve2); + newStuff.putReplace(EMHadronDefinition.hadron_p3); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "N": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n1)) { + newStuff.putReplace(EMHadronDefinition.hadron_n1); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "2N": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n2)) { + newStuff.putReplace(EMHadronDefinition.hadron_n2); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "P": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p1)) { + newStuff.putReplace(EMHadronDefinition.hadron_p1); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "2P": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p2)) { + newStuff.putReplace(EMHadronDefinition.hadron_p2); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "SF": { + if (Fission(decaysList, withThis, newStuff, decay.chance, false)) { + return true; + } + } + break; + case "B-F": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n1)) { + withThis.putUnifyExact(EMHadronDefinition.hadron_p1); + newStuff.putReplace(EMLeptonDefinition.lepton_e1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve_1); + try { + if (Fission(decaysList, withThis, newStuff, decay.chance, false)) { + return true; + } + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "ECF": + case "ECSF": + case "EC(+SF)": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p1, EMLeptonDefinition.lepton_e1)) { + withThis.putUnifyExact(EMHadronDefinition.hadron_n1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve1); + try { + if (Fission(decaysList, withThis, newStuff, decay.chance, false)) { + return true; + } + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "SF(+EC+B+)": + case "SF+EC+B+": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p2, EMLeptonDefinition.lepton_e1)) { + withThis.putUnifyExact(EMHadronDefinition.hadron_n2); + newStuff.putReplace(EMLeptonDefinition.lepton_e_1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve2); + try { + if (Fission(decaysList, withThis, newStuff, decay.chance, false)) { + return true; + } + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "SF+EC+B-": { + if (withThis.removeAllAmountsExact(EMLeptonDefinition.lepton_e1)) { + newStuff.putReplace(EMLeptonDefinition.lepton_e1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve_1); + try { + if (Fission(decaysList, withThis, newStuff, decay.chance, false)) { + return true; + } + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "IT": + case "IT?": + case "G": { + if (energy > 0) { + decaysList.add(new EMDecay(decay.chance, this, boson_Y__)); + } else { + if (DEBUG_MODE) { + TecTech.LOGGER.info("Tried to emit Gamma from ground state"); + } + decaysList.add(new EMDecay(decay.chance, this)); + } + return true; + } //break; + case "IT+EC+B+": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p2, EMLeptonDefinition.lepton_e1)) { + withThis.putUnifyExact(EMHadronDefinition.hadron_n2); + newStuff.putReplace(EMLeptonDefinition.lepton_e_1); + newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve2); + newStuff.putReplace(EMGaugeBosonDefinition.boson_Y__1); + try { + newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + } + break; + case "DEAD_END": + decaysList.add(deadEnd); + return true; + default: + throw new Error("Unsupported decay mode: " + decay.decayName + ' ' + getNeutralCount() + ' ' + getElement()); + } + if (DEBUG_MODE) { + TecTech.LOGGER.info("Failed to decay " + getElement() + ' ' + getNeutralCount() + ' ' + decay.decayName); + } + return false; + } + + private boolean Emmision(ArrayList<EMDecay> decaysList, EMDefinitionStack emit) { + EMDefinitionStackMap tree = elementalStacks.toMutable(); + if (tree.removeAmountExact(emit)) { + try { + decaysList.add(new EMDecay(1, new EMDefinitionStack(new EMAtomDefinition(tree.toImmutable_optimized_unsafe_LeavesExposedElementalTree()), 1), emit)); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + return false; + } + + private boolean alphaDecay(ArrayList<EMDecay> decaysList) { + EMDefinitionStackMap tree = elementalStacks.toMutable(); + if (tree.removeAllAmountsExact(alpha.getDefinition().getSubParticles())) { + try { + decaysList.add(new EMDecay(1, new EMDefinitionStack(new EMAtomDefinition(tree.toImmutable_optimized_unsafe_LeavesExposedElementalTree()), 1), alpha)); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + return false; + } + + private boolean MbetaDecay(ArrayList<EMDecay> decaysList) { + EMDefinitionStackMap tree = elementalStacks.toMutable(); + if (tree.removeAmountExact(EMHadronDefinition.hadron_n1)) { + try { + tree.putUnifyExact(EMHadronDefinition.hadron_p1); + decaysList.add(new EMDecay(1, new EMDefinitionStack(new EMAtomDefinition(tree.toImmutable_optimized_unsafe_LeavesExposedElementalTree()), 1), EMLeptonDefinition.lepton_e1, EMNeutrinoDefinition.lepton_Ve_1)); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + return false; + } + + private boolean PbetaDecay(ArrayList<EMDecay> decaysList) { + EMDefinitionStackMap tree = elementalStacks.toMutable(); + if (tree.removeAmountExact(EMHadronDefinition.hadron_p1)) { + try { + tree.putUnifyExact(EMHadronDefinition.hadron_n1); + decaysList.add(new EMDecay(1, new EMDefinitionStack(new EMAtomDefinition(tree.toImmutable_optimized_unsafe_LeavesExposedElementalTree()), 1), EMLeptonDefinition.lepton_e_1, EMNeutrinoDefinition.lepton_Ve1)); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + return false; + } + + private boolean ElectronCapture(ArrayList<EMDecay> decaysList) { + EMDefinitionStackMap tree = elementalStacks.toMutable(); + if (tree.removeAllAmountsExact(EMHadronDefinition.hadron_p1, EMLeptonDefinition.lepton_e1)) { + try { + tree.putUnifyExact(EMHadronDefinition.hadron_n1); + decaysList.add(new EMDecay(1, new EMDefinitionStack(new EMAtomDefinition(tree.toImmutable_optimized_unsafe_LeavesExposedElementalTree()), 1), EMNeutrinoDefinition.lepton_Ve1)); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } + return false; + } + + private boolean Fission(ArrayList<EMDecay> decaysList, EMDefinitionStackMap fissile, EMDefinitionStackMap particles, double probability, boolean spontaneousCheck) { + EMDefinitionStackMap heavy = new EMDefinitionStackMap(); + double[] liquidDrop = liquidDropFunction(abs(getElement()) <= 97); + + for (EMDefinitionStack stack : fissile.valuesToArray()) { + if (spontaneousCheck && stack.getDefinition() instanceof EMHadronDefinition && + (stack.getAmount() <= 80 || stack.getAmount() < 90 && XSTR_INSTANCE.nextInt(10) < stack.getAmount() - 80)) { + return false; + } + if (stack.getDefinition().getCharge() == 0) { + //if(stack.definition instanceof dHadronDefinition){ + double neutrals = stack.getAmount() * liquidDrop[2]; + int neutrals_cnt = (int) Math.floor(neutrals); + neutrals_cnt += neutrals - neutrals_cnt > XSTR_INSTANCE.nextDouble() ? 1 : 0; + particles.putUnifyExact(new EMDefinitionStack(stack.getDefinition(), neutrals_cnt)); + + int heavy_cnt = (int) Math.ceil(stack.getAmount() * liquidDrop[1]); + while (heavy_cnt + neutrals_cnt > stack.getAmount()) { + heavy_cnt--; + } + fissile.removeAmountExact(new EMDefinitionStack(stack.getDefinition(), heavy_cnt + neutrals_cnt)); + heavy.putReplace(new EMDefinitionStack(stack.getDefinition(), heavy_cnt)); + //}else{ + // particles.add(stack); + // light.remove(stack.definition); + //} + } else { + int heavy_cnt = (int) Math.ceil(stack.getAmount() * liquidDrop[0]); + if (heavy_cnt % 2 == 1 && XSTR_INSTANCE.nextDouble() > 0.05D) { + heavy_cnt--; + } + EMDefinitionStack new_stack = new EMDefinitionStack(stack.getDefinition(), heavy_cnt); + fissile.removeAmountExact(new_stack); + heavy.putReplace(new_stack); + } + } + + try { + particles.putReplace(new EMDefinitionStack(new EMAtomDefinition(fissile.toImmutable_optimized_unsafe_LeavesExposedElementalTree()), 1)); + particles.putReplace(new EMDefinitionStack(new EMAtomDefinition(heavy.toImmutable_optimized_unsafe_LeavesExposedElementalTree()), 1)); + decaysList.add(new EMDecay(probability, particles.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + return true; + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + return false; + } + + private static double[] liquidDropFunction(boolean asymmetric) { + double[] out = new double[3]; + + out[0] = XSTR_INSTANCE.nextGaussian(); + + if (out[0] < 1 && out[0] >= -1) { + if (XSTR_INSTANCE.nextBoolean()) { + out[0] = XSTR_INSTANCE.nextDouble() * 2d - 1d; + } + } + + if (asymmetric && out[0] > XSTR_INSTANCE.nextDouble() && XSTR_INSTANCE.nextInt(4) == 0) { + out[0] = -out[0]; + } + + //scale to splitting ratio + out[0] = out[0] * 0.05d + .6d; + + if (out[0] < 0 || out[0] > 1) { + return liquidDropFunction(asymmetric); + } + if (out[0] < .5d) { + out[0] = 1d - out[0]; + } + + //extra neutrals + out[2] = 0.012d + XSTR_INSTANCE.nextDouble() * 0.01d; + + if (asymmetric) { + out[1] = out[0]; + } else { + out[1] = out[0] - out[2] * .5d; + } + + return out; + } + + @Override + public EMDecay[] getEnergyInducedDecay(long energyLevel) { + if (iaeaDefinitionExistsAndHasEnergyLevels) { + ArrayList<EMDecay> decays = new ArrayList<>(4); + if (iaeaDecay(decays, energyLevel)) { + return decays.toArray(EMDecay.NO_PRODUCT); + } + } + if (energyLevel < abs(getCharge()) / 3 + getNeutralCount()) { + return new EMDecay[]{new EMDecay(1, this, boson_Y__)}; + } + return getNaturalDecayInstant(); + } + + @Override + public double getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { + if (iaeaDefinitionExistsAndHasEnergyLevels) { + double result = 0; + boolean backwards = newEnergyLevel < currentEnergyLevel; + if (backwards) { + long temp = currentEnergyLevel; + currentEnergyLevel = newEnergyLevel; + newEnergyLevel = temp; + } + + if (currentEnergyLevel <= 0) { + if (newEnergyLevel <= 0) { + return IEMDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - currentEnergyLevel); + } else { + result += IEMDefinition.DEFAULT_ENERGY_REQUIREMENT * -currentEnergyLevel; + } + } else { + result -= getIaea().getEnergeticStatesArray()[(int) Math.min(getIaea().getEnergeticStatesArray().length - 1, currentEnergyLevel)].energy; + } + if (newEnergyLevel >= getIaea().getEnergeticStatesArray().length) { + if (currentEnergyLevel >= getIaea().getEnergeticStatesArray().length) { + return IEMDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - currentEnergyLevel); + } else { + result += IEMDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - getIaea().getEnergeticStatesArray().length + 1); + } + result += getIaea().getEnergeticStatesArray()[getIaea().getEnergeticStatesArray().length - 1].energy; + } else { + result += getIaea().getEnergeticStatesArray()[(int) newEnergyLevel].energy; + } + + return backwards ? -result : result; + } + return IEMDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - currentEnergyLevel); + } + + @Override + public boolean usesSpecialEnergeticDecayHandling() { + return iaeaDefinitionExistsAndHasEnergyLevels; + } + + @Override + public boolean usesMultipleDecayCalls(long energyLevel) { + if (!iaeaDefinitionExistsAndHasEnergyLevels) return false; + EMNuclideIAEA.energeticState state; + if (energyLevel > getIaea().getEnergeticStatesArray().length) { + state = getIaea().getEnergeticStatesArray()[getIaea().getEnergeticStatesArray().length - 1]; + } else if (energyLevel <= 0) { + state = getIaea().getEnergeticStatesArray()[0]; + } else { + state = getIaea().getEnergeticStatesArray()[(int) energyLevel]; + } + for (EMNuclideIAEA.iaeaDecay decay : state.decaymodes) { + if (decay.decayName.contains("F")) return true;//if is fissile + } + return false; + } + + @Override + public boolean decayMakesEnergy(long energyLevel) { + return iaeaDefinitionExistsAndHasEnergyLevels; + } + + @Override + public boolean fusionMakesEnergy(long energyLevel) { + return getIaea() != null || iaeaDefinitionExistsAndHasEnergyLevels; + } + + @Override + public EMDecay[] getNaturalDecayInstant() { + //disembody + ArrayList<EMDefinitionStack> decaysInto = new ArrayList<>(); + for (EMDefinitionStack elementalStack : elementalStacks.valuesToArray()) { + if (elementalStack.getDefinition().getGeneration() == 1 || elementalStack.getDefinition().getGeneration() == -1) { + //covers both quarks and antiquarks + decaysInto.add(elementalStack); + } else { + //covers both quarks and antiquarks + decaysInto.add(new EMDefinitionStack(boson_Y__, 2)); + } + } + return new EMDecay[]{new EMDecay(0.75D, decaysInto.toArray(new EMDefinitionStack[0])), deadEnd}; + } + + //@Override + //public iElementalDefinition getAnti() { + // EMDefinitionStack[] stacks = this.elementalStacks.values(); + // EMDefinitionStack[] antiElements = new EMDefinitionStack[stacks.length]; + // for (int i = 0; i < antiElements.length; i++) { + // antiElements[i] = new EMDefinitionStack(stacks[i].definition.getAnti(), stacks[i].amount); + // } + // try { + // return new dAtomDefinition(false, antiElements); + // } catch (tElementalException e) { + // if (DEBUG_MODE) e.printStackTrace(); + // return null; + // } + //} + + @Override + public EMAtomDefinition getAnti() { + EMDefinitionStackMap anti = new EMDefinitionStackMap(); + for (EMDefinitionStack stack : elementalStacks.valuesToArray()) { + anti.putReplace(new EMDefinitionStack(stack.getDefinition().getAnti(), stack.getAmount())); + } + try { + return new EMAtomDefinition(anti.toImmutable_optimized_unsafe_LeavesExposedElementalTree()); + } catch (EMException e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + return null; + } + } + + public EMNuclideIAEA getIaea() { + return iaea; + } + + public byte getDecayMode() { + return decayMode; + } + + public int getNeutralCount() { + return neutralCount; + } + + public int getElement() { + return element; + } + + @Override + protected String getTagValue() { + return nbtType; + } + + public static void run(EMDefinitionsRegistry registry) { + registry.registerDefinitionClass(nbtType, new EMIndirectType((definitionsRegistry, nbt) -> + new EMAtomDefinition(EMConstantStackMap.fromNBT(definitionsRegistry, nbt)), EMAtomDefinition.class, "tt.keyword.Element")); + EMNuclideIAEA.run(); + + for (Runnable r : overrides) { + r.run(); + } + + for (Map.Entry<EMAtomDefinition, Double> entry : lifetimeOverrides.entrySet()) { + try { + lifetimeOverrides.put(new EMAtomDefinition(entry.getKey().elementalStacks), entry.getValue()); + } catch (EMException e) { + e.printStackTrace(); //Impossible + } + } + + //populate stable isotopes + for (int element = 1; element < 83; element++) {//Up to Bismuth exclusive + for (int isotope = 0; isotope < 130; isotope++) { + xstr.setSeed((long) (element + 1) * (isotope + 100)); + //stability curve + int StableIsotope = stableIzoCurve(element); + int izoDiff = isotope - StableIsotope; + int izoDiffAbs = abs(izoDiff); + double rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); + EMNuclideIAEA nuclide = EMNuclideIAEA.get(element, isotope); + if (rawLifeTime >= STABLE_RAW_LIFE_TIME || nuclide != null && nuclide.getHalfTime() >= STABLE_RAW_LIFE_TIME) { + TreeSet<Integer> isotopes = stableIsotopes.computeIfAbsent(element, k -> new TreeSet<>()); + isotopes.add(isotope); + } + } + } + + //populate unstable isotopes + for (int element = 1; element < 150; element++) { + for (int isotope = 100; isotope < 180; isotope++) { + xstr.setSeed((long) (element + 1) * (isotope + 100)); + //stability curve + int Isotope = stableIzoCurve(element); + int izoDiff = isotope - Isotope; + int izoDiffAbs = abs(izoDiff); + double rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); + TreeMap<Double, Integer> isotopes = mostStableUnstableIsotopes.computeIfAbsent(element, k -> new TreeMap<>()); + isotopes.put(rawLifeTime, isotope);//todo dont add stable ones + } + } + + try { + for (Map.Entry<Integer, TreeSet<Integer>> integerTreeSetEntry : stableIsotopes.entrySet()) { + stableAtoms.put(integerTreeSetEntry.getKey(), new EMAtomDefinition( + new EMDefinitionStack(EMHadronDefinition.hadron_p, integerTreeSetEntry.getKey()), + new EMDefinitionStack(EMHadronDefinition.hadron_n, integerTreeSetEntry.getValue().first()), + new EMDefinitionStack(EMLeptonDefinition.lepton_e, integerTreeSetEntry.getKey()))); + if (DEBUG_MODE) { + TecTech.LOGGER.info("Added Stable Atom:" + integerTreeSetEntry.getKey() + ' ' + integerTreeSetEntry.getValue().first() + ' ' + stableAtoms.get(integerTreeSetEntry.getKey()).getMass()); + } + } + for (Map.Entry<Integer, TreeMap<Double, Integer>> integerTreeMapEntry : mostStableUnstableIsotopes.entrySet()) { + unstableAtoms.put(integerTreeMapEntry.getKey(), new EMAtomDefinition( + new EMDefinitionStack(EMHadronDefinition.hadron_p, integerTreeMapEntry.getKey()), + new EMDefinitionStack(EMHadronDefinition.hadron_n, integerTreeMapEntry.getValue().lastEntry().getValue()), + new EMDefinitionStack(EMLeptonDefinition.lepton_e, integerTreeMapEntry.getKey()))); + if (DEBUG_MODE) { + TecTech.LOGGER.info("Added Unstable Atom:" + integerTreeMapEntry.getKey() + ' ' + integerTreeMapEntry.getValue().lastEntry().getValue() + ' ' + unstableAtoms.get(integerTreeMapEntry.getKey()).getMass()); + } + } + + deuterium = new EMAtomDefinition( + EMHadronDefinition.hadron_p1, + EMHadronDefinition.hadron_n1, + EMLeptonDefinition.lepton_e1).getStackForm(1); + registry.registerForDisplay(deuterium.getDefinition()); + + tritium = new EMAtomDefinition( + EMHadronDefinition.hadron_p1, + EMHadronDefinition.hadron_n2, + EMLeptonDefinition.lepton_e1).getStackForm(1); + registry.registerForDisplay(tritium.getDefinition()); + + helium_3 = new EMAtomDefinition( + EMHadronDefinition.hadron_p2, + EMHadronDefinition.hadron_n1, + EMLeptonDefinition.lepton_e2).getStackForm(1); + registry.registerForDisplay(helium_3.getDefinition()); + + alpha = new EMAtomDefinition( + EMHadronDefinition.hadron_p2, + EMHadronDefinition.hadron_n2).getStackForm(1); + registry.registerForDisplay(alpha.getDefinition()); + + beryllium_8 = new EMAtomDefinition( + new EMDefinitionStack(EMHadronDefinition.hadron_p, 4), + new EMDefinitionStack(EMHadronDefinition.hadron_n, 4), + new EMDefinitionStack(EMLeptonDefinition.lepton_e, 4)).getStackForm(1); + registry.registerForDisplay(beryllium_8.getDefinition()); + + carbon_14 = new EMAtomDefinition( + new EMDefinitionStack(EMHadronDefinition.hadron_p, 6), + new EMDefinitionStack(EMHadronDefinition.hadron_n, 8), + new EMDefinitionStack(EMLeptonDefinition.lepton_e, 6)).getStackForm(1); + registry.registerForDisplay(carbon_14.getDefinition()); + + neon_24 = new EMAtomDefinition( + new EMDefinitionStack(EMHadronDefinition.hadron_p, 10), + new EMDefinitionStack(EMHadronDefinition.hadron_n, 14), + new EMDefinitionStack(EMLeptonDefinition.lepton_e, 10)).getStackForm(1); + registry.registerForDisplay(neon_24.getDefinition()); + + silicon_34 = new EMAtomDefinition( + new EMDefinitionStack(EMHadronDefinition.hadron_p, 14), + new EMDefinitionStack(EMHadronDefinition.hadron_n, 20), + new EMDefinitionStack(EMLeptonDefinition.lepton_e, 14)).getStackForm(1); + registry.registerForDisplay(silicon_34.getDefinition()); + + uranium_238 = new EMAtomDefinition( + new EMDefinitionStack(EMLeptonDefinition.lepton_e, 92), + new EMDefinitionStack(EMHadronDefinition.hadron_p, 92), + new EMDefinitionStack(EMHadronDefinition.hadron_n, 146)).getStackForm(1); + registry.registerForDisplay(uranium_238.getDefinition()); + + uranium_235 = new EMAtomDefinition( + new EMDefinitionStack(EMLeptonDefinition.lepton_e, 92), + new EMDefinitionStack(EMHadronDefinition.hadron_p, 92), + new EMDefinitionStack(EMHadronDefinition.hadron_n, 143)).getStackForm(1); + registry.registerForDisplay(uranium_235.getDefinition()); + + TecTech.LOGGER.info("Diff Mass U : " + (uranium_238.getDefinition().getMass() - uranium_235.getDefinition().getMass())); + + plutonium_239 = new EMAtomDefinition( + new EMDefinitionStack(EMLeptonDefinition.lepton_e, 94), + new EMDefinitionStack(EMHadronDefinition.hadron_p, 94), + new EMDefinitionStack(EMHadronDefinition.hadron_n, 145)).getStackForm(1); + registry.registerForDisplay(plutonium_239.getDefinition()); + + plutonium_241 = new EMAtomDefinition( + new EMDefinitionStack(EMLeptonDefinition.lepton_e, 94), + new EMDefinitionStack(EMHadronDefinition.hadron_p, 94), + new EMDefinitionStack(EMHadronDefinition.hadron_n, 147)).getStackForm(1); + registry.registerForDisplay(plutonium_241.getDefinition()); + + TecTech.LOGGER.info("Diff Mass Pu: " + (plutonium_241.getDefinition().getMass() - plutonium_239.getDefinition().getMass())); + + somethingHeavy=(EMAtomDefinition) plutonium_241.getDefinition(); + + } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + + if (DEBUG_MODE) { + TecTech.LOGGER.info("Registered Elemental Matter Class: Atom " + nbtType + ' ' + getClassTypeStatic()); + } + + for (int i = 1; i <= 118; i++) { + EMAtomDefinition firstStableIsotope = getFirstStableIsotope(i); + if(firstStableIsotope==null){ + firstStableIsotope = getBestUnstableIsotope(i); + if(firstStableIsotope==null){ + continue; + } + } + registry.registerForDisplay(firstStableIsotope); + } + } + + public static void setTransformations(EMTransformationRegistry transformationInfo) { + /*----STABLE ATOMS----**/ + refMass = getFirstStableIsotope(1).getMass() * EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED; + + transformationInfo.addFluid(new EMDefinitionStack(getFirstStableIsotope(1), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), Hydrogen.mGas, 144); + transformationInfo.addFluid(new EMDefinitionStack(getFirstStableIsotope(2), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), Helium.mGas, 144); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(3), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Lithium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(4), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Beryllium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(5), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Boron, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(6), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Carbon, 1); + transformationInfo.addFluid(new EMDefinitionStack(getFirstStableIsotope(7), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), Nitrogen.mGas, 144); + transformationInfo.addFluid(new EMDefinitionStack(getFirstStableIsotope(8), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), Oxygen.mGas, 144); + transformationInfo.addFluid(new EMDefinitionStack(getFirstStableIsotope(9), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), Fluorine.mGas, 144); + //transformationInfo.addFluid(new EMDefinitionStack(getFirstStableIsotope(10), AVOGADRO_CONSTANT_144),Neon.mGas.getID(), 144); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(11), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Sodium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(12), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Magnesium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(13), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Aluminium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(14), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Silicon, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(15), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Phosphorus, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(16), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Sulfur, 1); + transformationInfo.addFluid(new EMDefinitionStack(getFirstStableIsotope(17), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), Argon.mGas, 144); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(19), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Potassium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(20), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Calcium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(21), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Scandium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(22), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Titanium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(23), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Vanadium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(24), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Chrome, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(25), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Manganese, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(26), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Iron, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(27), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Cobalt, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(28), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Nickel, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(29), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Copper, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(30), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Zinc, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(31), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Gallium, 1); + //transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(32), AVOGADRO_CONSTANT_144),dust, Germanium,1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(33), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Arsenic, 1); + //transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(34), AVOGADRO_CONSTANT_144),dust, Selenium,1); + //transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(35), AVOGADRO_CONSTANT_144),dust, Bromine,1); + //transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(36), AVOGADRO_CONSTANT_144),dust, Krypton,1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(37), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Rubidium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(38), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Strontium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(39), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Yttrium, 1); + //transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(40), AVOGADRO_CONSTANT_144),dust, Zirconium,1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(41), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Niobium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(42), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Molybdenum, 1); + //transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(43), AVOGADRO_CONSTANT_144),dust, Technetium,1); + //transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(44), AVOGADRO_CONSTANT_144),dust, Ruthenium,1); + //transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(45), AVOGADRO_CONSTANT_144),dust, Rhodium,1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(46), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Palladium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(47), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Silver, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(48), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Cadmium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(49), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Indium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(50), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Tin, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(51), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Antimony, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(52), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Tellurium, 1); + //transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(53), AVOGADRO_CONSTANT_144),dust, Iodine,1); + //transformationInfo.addFluid(new EMDefinitionStack(getFirstStableIsotope(54), AVOGADRO_CONSTANT_144),Xenon.mGas.getID(), 144); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(55), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Caesium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(56), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Barium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(57), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Lanthanum, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(58), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Cerium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(59), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Praseodymium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(60), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Neodymium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(62), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Samarium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(63), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Europium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(64), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Gadolinium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(65), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Terbium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(66), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Dysprosium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(67), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Holmium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(68), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Erbium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(69), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Thulium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(70), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Ytterbium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(71), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Lutetium, 1); + //transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(72), AVOGADRO_CONSTANT_144),dust, Hafnum,1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(73), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Tantalum, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(74), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Tungsten, 1); + //transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(75), AVOGADRO_CONSTANT_144),dust, Rhenium,1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(76), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Osmium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(77), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Iridium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(78), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Platinum, 1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(79), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Gold, 1); + transformationInfo.addFluid(new EMDefinitionStack(getFirstStableIsotope(80), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), Mercury.mFluid, 144); + //transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(81), AVOGADRO_CONSTANT_144),dust, Thallium,1); + transformationInfo.addOredict(new EMDefinitionStack(getFirstStableIsotope(82), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Lead, 1); + + /*----UNSTABLE ATOMS----**/ + refUnstableMass = getFirstStableIsotope(82).getMass() * EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED; + + transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(61), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Promethium, 1); + transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(83), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Bismuth, 1); + //transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(84),AVOGADRO_CONSTANT_144),dust, Polonium,1); + //transformationInfo.addFluid(new EMDefinitionStack(getBestUnstableIsotope(85),AVOGADRO_CONSTANT_144),Astatine.mPlasma.getID(), 144); + transformationInfo.addFluid(new EMDefinitionStack(getBestUnstableIsotope(86), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), Radon.mGas, 144); + //transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(87),AVOGADRO_CONSTANT_144),dust, Francium,1); + //transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(88),AVOGADRO_CONSTANT_144),dust, Radium,1); + //transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(89),AVOGADRO_CONSTANT_144),dust, Actinium,1); + transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(90), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Thorium, 1); + //transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(91),AVOGADRO_CONSTANT_144),dust, Protactinium,1); + ////transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(92),AVOGADRO_CONSTANT_144), dust, Uranium,1); + //transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(93),AVOGADRO_CONSTANT_144),dust, Neptunium,1); + ////transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(94),AVOGADRO_CONSTANT_144), dust, Plutonium,1); + transformationInfo.addOredict(new EMDefinitionStack(getBestUnstableIsotope(95), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Americium, 1); + + + transformationInfo.addFluid(new EMDefinitionStack(deuterium.getDefinition(), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), Deuterium.mGas, 144); + transformationInfo.addFluid(new EMDefinitionStack(tritium.getDefinition(), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), Tritium.mGas, 144); + transformationInfo.addFluid(new EMDefinitionStack(helium_3.getDefinition(), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), Helium_3.mGas, 144); + + transformationInfo.addOredict(new EMDefinitionStack(uranium_238.getDefinition(), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Uranium/*238*/, 1); + transformationInfo.addOredict(new EMDefinitionStack(uranium_235.getDefinition(), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Uranium235, 1); + + transformationInfo.addOredict(new EMDefinitionStack(plutonium_239.getDefinition(), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Plutonium/*239*/, 1); + transformationInfo.addOredict(new EMDefinitionStack(plutonium_241.getDefinition(), EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED), dust, Plutonium241, 1); + } + + public static EMAtomDefinition getFirstStableIsotope(int element) { + return stableAtoms.get(element); + } + + public static EMAtomDefinition getBestUnstableIsotope(int element) { + return unstableAtoms.get(element); + } + + @Override + public int getMatterMassType() { + return getClassTypeStatic(); + } + + public static int getClassTypeStatic() { + return 64; + } + + @Override + public int hashCode() { + return hash; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMHadronDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMHadronDefinition.java new file mode 100644 index 0000000000..9fb551e45c --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMHadronDefinition.java @@ -0,0 +1,467 @@ +package com.github.technus.tectech.mechanics.elementalMatter.definitions.complex; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; +import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMComplexTemplate; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMIndirectType; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMDefinitionStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMDequantizationInfo; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMOredictQuantizationInfo; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.OreDictionaryStack; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMQuarkDefinition; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.boson_Y__; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.deadEnd; +import static net.minecraft.util.StatCollector.translateToLocal; + +/** + * Created by danie_000 on 17.11.2016. + */ +public class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize map i/o + private final int hash; + + private static final String nbtType = "h"; + //Helpers + public static final Map<EMHadronDefinition, String> SYMBOL_MAP = new HashMap<>(); + public static final Map<EMHadronDefinition, String> UNLOCALIZED_NAME_MAP = new HashMap<>(); + public static EMHadronDefinition hadron_p, hadron_n, hadron_p_, hadron_n_; + public static EMDefinitionStack hadron_p1, hadron_n1, hadron_p2, hadron_n2, hadron_p3, hadron_n3, hadron_p5; + private static double protonMass = 0D; + private static double neutronMass = 0D; + private static final double actualProtonMass = 938272081.3D; + private static final double actualNeutronMass = 939565413.3D; + + //float-mass in eV/c^2 + private final double mass; + //int -electric charge in 1/3rds of electron charge for optimization + private final int charge; + private final double rawLifeTime; + private final int amount; + //generation max present inside - minus if contains any antiquark + private final byte type; + //private final FluidStack fluidThing; + //private final ItemStack itemThing; + + private final EMConstantStackMap quarkStacks; + + public EMHadronDefinition(EMDefinitionStack... quarks) throws EMException { + this(true, new EMConstantStackMap(quarks)); + } + + private EMHadronDefinition(boolean check, EMDefinitionStack... quarks) throws EMException { + this(check, new EMConstantStackMap(quarks)); + } + + public EMHadronDefinition(EMConstantStackMap quarks) throws EMException { + this(true, quarks); + } + + private EMHadronDefinition(boolean check, EMConstantStackMap quarks) throws EMException { + if (check && !canTheyBeTogether(quarks)) { + throw new EMException("Hadron Definition error"); + } + quarkStacks = quarks; + + int amount = 0; + int charge = 0; + int type = 0; + boolean containsAnti = false; + double mass = 0; + for (EMDefinitionStack quarkStack : quarkStacks.valuesToArray()) { + amount += quarkStack.getAmount(); + if ((int) quarkStack.getAmount() != quarkStack.getAmount()) { + throw new ArithmeticException("Amount cannot be safely converted to int!"); + } + mass += quarkStack.getMass(); + charge += quarkStack.getCharge(); + type = Math.max(Math.abs(quarkStack.getDefinition().getGeneration()), type); + if (quarkStack.getDefinition().getGeneration() < 0) { + containsAnti = true; + } + } + this.amount = amount; + this.charge = charge; + this.type = containsAnti ? (byte) -type : (byte) type; + long mult = (long) this.getAmount() * this.getAmount() * (this.getAmount() - 1); + mass = mass * 5.543D * mult;//yes it becomes heavier + + if (mass == protonMass && this.getAmount() == 3) { + rawLifeTime = IEMDefinition.STABLE_RAW_LIFE_TIME; + mass = actualProtonMass; + } else if (mass == neutronMass && this.getAmount() == 3) { + rawLifeTime = 882D; + mass = actualNeutronMass; + } else { + if (this.getAmount() == 3) { + rawLifeTime = 1.34D / mass * Math.pow(9.81, charge); + } else if (this.getAmount() == 2) { + rawLifeTime = 1.21D / mass / Math.pow(19.80, charge); + } else { + rawLifeTime = 1.21D / mass / Math.pow(9.80, charge); + } + } + this.mass = mass; + hash = super.hashCode(); + } + + //public but u can just try{}catch(){} the constructor it still calls this method + private static boolean canTheyBeTogether(EMConstantStackMap stacks) { + long amount = 0; + for (EMDefinitionStack quarks : stacks.valuesToArray()) { + if (!(quarks.getDefinition() instanceof EMQuarkDefinition)) { + return false; + } + if ((int) quarks.getAmount() != quarks.getAmount()) { + throw new ArithmeticException("Amount cannot be safely converted to int!"); + } + amount += quarks.getAmount(); + } + return amount >= 2 && amount <= 12; + } + + @Override + public String getShortLocalizedName() { + StringBuilder name = new StringBuilder(); + String sym = translateToLocal(UNLOCALIZED_NAME_MAP.get(this)); + if (sym != null) { + name.append(' ').append(sym); + } else { + for (EMDefinitionStack quark : quarkStacks.valuesToArray()) { + name.append(' ').append(quark.getDefinition().getSymbol()).append((int) quark.getAmount()); + } + } + return name.toString(); + } + + @Override + public String getLocalizedTypeName() { + switch (getAmount()) { + case 2: + return translateToLocal("tt.keyword.Meson"); + case 3: + return translateToLocal("tt.keyword.Baryon"); + case 4: + return translateToLocal("tt.keyword.Tetraquark"); + case 5: + return translateToLocal("tt.keyword.Pentaquark"); + case 6: + return translateToLocal("tt.keyword.Hexaquark"); + default: + return translateToLocal("tt.keyword.Hadron"); + } + } + + @Override + public String getSymbol() { + String sym = SYMBOL_MAP.get(this); + if (sym != null) { + return sym; + } else { + StringBuilder symbol = new StringBuilder(8); + for (EMDefinitionStack quark : quarkStacks.valuesToArray()) { + for (int i = 0; i < quark.getAmount(); i++) { + symbol.append(quark.getDefinition().getSymbol()); + } + } + return symbol.toString(); + } + } + + @Override + public String getShortSymbol() { + String sym = SYMBOL_MAP.get(this); + if (sym != null) { + return sym; + } else { + StringBuilder symbol = new StringBuilder(8); + for (EMDefinitionStack quark : quarkStacks.valuesToArray()) { + for (int i = 0; i < quark.getAmount(); i++) { + symbol.append(quark.getDefinition().getShortSymbol()); + } + } + return symbol.toString(); + } + } + + @Override + public int getMaxColors() { + return -7; + } + + @Override + public EMConstantStackMap getSubParticles() { + return quarkStacks; + } + + @Override + public EMDecay[] getNaturalDecayInstant() { + EMDefinitionStack[] quarkStacks = this.quarkStacks.valuesToArray(); + if (getAmount() == 2 && quarkStacks.length == 2 && quarkStacks[0].getDefinition().getMass() == quarkStacks[1].getDefinition().getMass() && quarkStacks[0].getDefinition().getGeneration() == -quarkStacks[1].getDefinition().getGeneration()) { + return EMDecay.NO_PRODUCT; + } + ArrayList<EMDefinitionStack> decaysInto = new ArrayList<>(); + for (EMDefinitionStack quarks : quarkStacks) { + if (quarks.getDefinition().getGeneration() == 1 || quarks.getDefinition().getGeneration() == -1) { + //covers both quarks and antiquarks + decaysInto.add(quarks); + } else { + //covers both quarks and antiquarks + decaysInto.add(new EMDefinitionStack(boson_Y__, 2)); + } + } + return new EMDecay[]{ + new EMDecay(0.75D, decaysInto.toArray(new EMDefinitionStack[0])), + deadEnd + }; + } + + @Override + public EMDecay[] getEnergyInducedDecay(long energyLevel) { + EMDefinitionStack[] quarkStacks = this.quarkStacks.valuesToArray(); + if (getAmount() == 2 && quarkStacks.length == 2 && quarkStacks[0].getDefinition().getMass() == quarkStacks[1].getDefinition().getMass() && quarkStacks[0].getDefinition().getGeneration() == -quarkStacks[1].getDefinition().getGeneration()) { + return EMDecay.NO_PRODUCT; + } + return new EMDecay[]{new EMDecay(0.75D, quarkStacks), deadEnd}; //decay into quarks + } + + @Override + public double getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { + return IEMDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - currentEnergyLevel); + } + + @Override + public boolean usesSpecialEnergeticDecayHandling() { + return false; + } + + @Override + public boolean usesMultipleDecayCalls(long energyLevel) { + return false; + } + + @Override + public boolean decayMakesEnergy(long energyLevel) { + return false; + } + + @Override + public boolean fusionMakesEnergy(long energyLevel) { + return false; + } + + @Override + public EMDecay[] getDecayArray() { + EMDefinitionStack[] quarkStacks = this.quarkStacks.valuesToArray(); + if (getAmount() == 2 && quarkStacks.length == 2 && + quarkStacks[0].getDefinition().getMass() == quarkStacks[1].getDefinition().getMass() && + quarkStacks[0].getDefinition().getGeneration() == -quarkStacks[1].getDefinition().getGeneration()) { + return EMDecay.NO_PRODUCT; + } else if (getAmount() != 3) { + return new EMDecay[]{new EMDecay(0.95D, quarkStacks), deadEnd}; //decay into quarks + } else { + ArrayList<EMQuarkDefinition> newBaryon = new ArrayList<>(); + IEMDefinition[] Particles = new IEMDefinition[2]; + for (EMDefinitionStack quarks : quarkStacks) { + for (int i = 0; i < quarks.getAmount(); i++) { + newBaryon.add((EMQuarkDefinition) quarks.getDefinition()); + } + } + //remove last + EMQuarkDefinition lastQuark = newBaryon.remove(2); + + EMDefinitionStack[] decay; + if (Math.abs(lastQuark.getGeneration()) > 1) { + decay = lastQuark.getDecayArray()[1].getOutputStacks().valuesToArray(); + } else { + decay = lastQuark.getDecayArray()[2].getOutputStacks().valuesToArray(); + } + newBaryon.add((EMQuarkDefinition) decay[0].getDefinition()); + Particles[0] = decay[1].getDefinition(); + Particles[1] = decay[2].getDefinition(); + + EMDefinitionStack[] contentOfBaryon = newBaryon.stream() + .map(eQuarkDefinition -> new EMDefinitionStack(eQuarkDefinition, 1)) + .toArray(EMDefinitionStack[]::new); + + try { + return new EMDecay[]{ + new EMDecay(0.001D, new EMHadronDefinition(false, contentOfBaryon), Particles[0], Particles[1], boson_Y__), + new EMDecay(0.99D, new EMHadronDefinition(false, contentOfBaryon), Particles[0], Particles[1]), + deadEnd}; + } catch (EMException e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + return new EMDecay[]{deadEnd}; + } + } + } + + @Override + public double getMass() { + return mass; + } + + @Override + public int getCharge() { + return charge; + } + + @Override + public double getRawTimeSpan(long currentEnergy) { + return getRawLifeTime(); + } + + @Override + public boolean isTimeSpanHalfLife() { + return true; + } + + @Override + public int getGeneration() { + return type; + } + + //@Override + //public iElementalDefinition getAnti() { + // cElementalDefinitionStack[] stacks = this.quarkStacks.values(); + // cElementalDefinitionStack[] antiElements = new cElementalDefinitionStack[stacks.length]; + // for (int i = 0; i < antiElements.length; i++) { + // antiElements[i] = new cElementalDefinitionStack(stacks[i].definition.getAnti(), stacks[i].amount); + // } + // try { + // return new dHadronDefinition(false, antiElements); + // } catch (tElementalException e) { + // if (DEBUG_MODE) e.printStackTrace(); + // return null; + // } + //} + + @Override + public IEMDefinition getAnti() { + EMDefinitionStackMap anti = new EMDefinitionStackMap(); + for (EMDefinitionStack stack : quarkStacks.valuesToArray()) { + anti.putReplace(new EMDefinitionStack(stack.getDefinition().getAnti(), stack.getAmount())); + } + try { + return new EMHadronDefinition(anti.toImmutable_optimized_unsafe_LeavesExposedElementalTree()); + } catch (EMException e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + return null; + } + } + + @Override + protected String getTagValue() { + return nbtType; + } + + public static void run(EMDefinitionsRegistry registry) { + registry.registerDefinitionClass(nbtType, new EMIndirectType((definitionsRegistry, nbt) -> + new EMHadronDefinition(EMConstantStackMap.fromNBT(definitionsRegistry, nbt)), EMHadronDefinition.class, "tt.keyword.Hadron")); + try { + hadron_p = new EMHadronDefinition(new EMConstantStackMap(EMQuarkDefinition.quark_u.getStackForm(2), EMQuarkDefinition.quark_d.getStackForm(1))); + protonMass = hadron_p.getMass(); + //redefine the proton with proper lifetime (the lifetime is based on mass comparison) + hadron_p = new EMHadronDefinition(new EMConstantStackMap(EMQuarkDefinition.quark_u.getStackForm(2), EMQuarkDefinition.quark_d.getStackForm(1))); + SYMBOL_MAP.put(hadron_p, "p"); + UNLOCALIZED_NAME_MAP.put(hadron_p, "tt.keyword.Proton"); + registry.registerForDisplay(hadron_p); + registry.registerDirectDefinition("p",hadron_p); + + hadron_p_ = (EMHadronDefinition) hadron_p.getAnti(); + SYMBOL_MAP.put(hadron_p_, "~p"); + UNLOCALIZED_NAME_MAP.put(hadron_p_, "tt.keyword.AntiProton"); + registry.registerForDisplay(hadron_p_); + registry.registerDirectDefinition("~p",hadron_p_); + + hadron_n = new EMHadronDefinition(new EMConstantStackMap(EMQuarkDefinition.quark_u.getStackForm(1), EMQuarkDefinition.quark_d.getStackForm(2))); + neutronMass = hadron_n.getMass(); + //redefine the neutron with proper lifetime (the lifetime is based on mass comparison) + hadron_n = new EMHadronDefinition(new EMConstantStackMap(EMQuarkDefinition.quark_u.getStackForm(1), EMQuarkDefinition.quark_d.getStackForm(2))); + SYMBOL_MAP.put(hadron_n, "n"); + UNLOCALIZED_NAME_MAP.put(hadron_n, "tt.keyword.Neutron"); + registry.registerForDisplay(hadron_n); + registry.registerDirectDefinition("n",hadron_n); + + hadron_n_ = (EMHadronDefinition) hadron_n.getAnti(); + SYMBOL_MAP.put(hadron_n_, "~n"); + UNLOCALIZED_NAME_MAP.put(hadron_n_, "tt.keyword.AntiNeutron"); + registry.registerForDisplay(hadron_n_); + registry.registerDirectDefinition("~n",hadron_n_); + + TecTech.LOGGER.info("Old Neutron Mass: " + neutronMass); + TecTech.LOGGER.info("Old Proton Mass: " + protonMass); + TecTech.LOGGER.info("New Neutron Mass: " + EMHadronDefinition.hadron_n.getMass()); + TecTech.LOGGER.info("New Proton Mass: " + EMHadronDefinition.hadron_p.getMass()); + } catch (EMException e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + protonMass = -1; + neutronMass = -1; + } + hadron_p1 = new EMDefinitionStack(hadron_p, 1D); + hadron_n1 = new EMDefinitionStack(hadron_n, 1D); + hadron_p2 = new EMDefinitionStack(hadron_p, 2D); + hadron_n2 = new EMDefinitionStack(hadron_n, 2D); + hadron_p3 = new EMDefinitionStack(hadron_p, 3D); + hadron_n3 = new EMDefinitionStack(hadron_n, 3D); + hadron_p5 = new EMDefinitionStack(hadron_p, 5D); + + if (DEBUG_MODE) { + TecTech.LOGGER.info("Registered Elemental Matter Class: Hadron " + nbtType + ' ' + getClassTypeStatic()); + } + } + + public static void setTransformations(EMTransformationRegistry transformationInfo) {//Todo use Neutronium atom? + //Added to atom map, but should be in its own + EMDefinitionStack neutrons = new EMDefinitionStack(hadron_n, 1000 * EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED); + EMDequantizationInfo emDequantizationInfo = new EMDequantizationInfo(neutrons); + emDequantizationInfo.setOre(new OreDictionaryStack(1,OreDictionary.getOreID(OrePrefixes.dust.name() + Materials.Neutronium.mName)));//todo shitty looking, but works... + transformationInfo.getInfoMap().put(neutrons.getDefinition(), emDequantizationInfo); + transformationInfo.getOredictQuantization().put( + OreDictionary.getOreID(OrePrefixes.ingotHot.name() + Materials.Neutronium.mName), + new EMOredictQuantizationInfo(OrePrefixes.ingotHot, Materials.Neutronium, 1, neutrons) + ); + } + + @Override + public int getMatterMassType() { + return getClassTypeStatic(); + } + + public static int getClassTypeStatic() { + return -64; + } + + @Override + public int hashCode() { + return hash; + } + + public double getRawLifeTime() { + return rawLifeTime; + } + + public int getAmount() { + return amount; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/iaeaNuclide.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMNuclideIAEA.java index 8b09bfd2e0..e5fab5e6bf 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/iaeaNuclide.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMNuclideIAEA.java @@ -7,10 +7,10 @@ import java.util.HashMap; import java.util.HashSet; import java.util.TreeMap; -import static com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition.STABLE_RAW_LIFE_TIME; -import static com.github.technus.tectech.util.Util.splitButDifferent; +import static com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition.STABLE_RAW_LIFE_TIME; +import static com.github.technus.tectech.util.TT_Utility.splitButDifferent; -public final class iaeaNuclide { +public final class EMNuclideIAEA { public static final double AMU_TO_EV_DIV_C_C=9.31494061E08D,MICRO_AMU_TO_EV_DIV_C_C=9.31494061E02D; //Nuclide T1/2 T1/2 [s] Decay Modes ? Q Q?- Q? QEC Q?- n Sn Sp Binding/A Atomic Mass Mass Excess Discovery @@ -18,13 +18,13 @@ public final class iaeaNuclide { //Z,N,symb,radius, unc, energy, unc, jp, half-life operator, half_life, unc,unit, half_life [s], unc, decay, decay %, unc, decay, decay %, unc, decay, decay %, unc,isospin,magn. dipole, unc, elect. quad , unc,Qb-,unc,Qb- n,unc,Qa, unc, Qec, unc,Sn,unc, Sp,unc,Binding/A,unc,atomic mass, unc, mass excess,unc, //Z,N,symbol,energy , unc, jp,half-life operator, half_life, unc,unit, half_life [s], unc, decay, decay %, unc, decay, decay %, unc, decay, decay %, unc,isospin,magn. dipole, unc, elect. quadrupole , unc, - private static final HashMap<Integer,iaeaNuclide> NUCLIDES=new HashMap<>(); + private static final HashMap<Integer, EMNuclideIAEA> NUCLIDES =new HashMap<>(); public static void run(){ String line=""; try { - BufferedReader reader = new BufferedReader(new InputStreamReader(iaeaNuclide.class.getResourceAsStream("nuclides.csv"))); + BufferedReader reader = new BufferedReader(new InputStreamReader(EMNuclideIAEA.class.getResourceAsStream("nuclides.csv"))); ArrayList<String[]> blockOfData=new ArrayList<>(4); while((line=reader.readLine())!=null) { String[] split= splitButDifferent(line,","); @@ -32,13 +32,13 @@ public final class iaeaNuclide { throw new Error("Invalid count (" + split.length + ") of separators in IAEA nuclides database " + line); } if(!split[1].isEmpty() && !blockOfData.isEmpty()) { - new iaeaNuclide(blockOfData.toArray(new String[blockOfData.size()][])); + new EMNuclideIAEA(blockOfData.toArray(new String[blockOfData.size()][])); blockOfData.clear(); } blockOfData.add(split); } if(!blockOfData.isEmpty()) { - new iaeaNuclide(blockOfData.toArray(new String[blockOfData.size()][])); + new EMNuclideIAEA(blockOfData.toArray(new String[blockOfData.size()][])); blockOfData.clear(); } reader.close(); @@ -48,7 +48,7 @@ public final class iaeaNuclide { } try { - BufferedReader reader = new BufferedReader(new InputStreamReader(iaeaNuclide.class.getResourceAsStream("nuclidesTable.csv"))); + BufferedReader reader = new BufferedReader(new InputStreamReader(EMNuclideIAEA.class.getResourceAsStream("nuclidesTable.csv"))); while((line=reader.readLine())!=null) { String[] split= splitButDifferent(line,","); if(split.length!=47) { @@ -63,7 +63,7 @@ public final class iaeaNuclide { } try { - BufferedReader reader = new BufferedReader(new InputStreamReader(iaeaNuclide.class.getResourceAsStream("energyLevels.csv"))); + BufferedReader reader = new BufferedReader(new InputStreamReader(EMNuclideIAEA.class.getResourceAsStream("energyLevels.csv"))); while((line=reader.readLine())!=null) { String[] split= splitButDifferent(line,","); if(split.length!=27) { @@ -77,27 +77,28 @@ public final class iaeaNuclide { e.printStackTrace(); } - for(iaeaNuclide nuclide:NUCLIDES.values()) { + for(EMNuclideIAEA nuclide:NUCLIDES.values()) { nuclide.makeArrayOfEnergyStates(); } } - public static iaeaNuclide get(int protons, int neutrons){ + public static EMNuclideIAEA get(int protons, int neutrons){ return NUCLIDES.get((protons<<16)+neutrons); } - public final short N,Z; - public final double halfTime;//sec - public final double mass;//eV/c^2 - public final short discovery;//year - private TreeMap<Double,energeticState> energeticStates; - public energeticState[] energeticStatesArray; + private final short N; + private final short Z; + private final double halfTime;//sec + private final double mass;//eV/c^2 + private final short discovery;//year + private TreeMap<Double,energeticState> energeticStates; + private energeticState[] energeticStatesArray; - private iaeaNuclide(String[][] rows){ + private EMNuclideIAEA(String[][] rows){ N=Short.parseShort(rows[1][2]); Z=Short.parseShort(rows[1][0]); - NUCLIDES.put(((int)Z <<16)+N,this); + NUCLIDES.put(((int) getZ() <<16)+ getN(),this); String[] parts = splitButDifferent(rows[0][16], "|"); double Mass=doubleOrNaN(parts[0],"mass"); @@ -125,7 +126,7 @@ public final class iaeaNuclide { // if (add(cells[17])) System.out.println(N + " " + Z); // if (add(cells[20])) System.out.println(N + " " + Z); //} - new energeticState(this, halfTime, getDecaysFixed( + new energeticState(this, getHalfTime(), getDecaysFixed( cells[14], doubleOrNaN(cells[15],"chance1"), cells[17], @@ -137,11 +138,11 @@ public final class iaeaNuclide { private static final energeticState[] empty=new energeticState[0]; private void makeArrayOfEnergyStates(){ if(energeticStates==null || energeticStates.isEmpty()) { - energeticStatesArray = empty; + setEnergeticStatesArray(empty); } else { - energeticStatesArray = energeticStates.values().toArray(new energeticState[0]); - double life=halfTime; - for (energeticState energeticState : energeticStatesArray) { + setEnergeticStatesArray(energeticStates.values().toArray(new energeticState[0])); + double life= getHalfTime(); + for (energeticState energeticState : getEnergeticStatesArray()) { if(Double.isNaN(energeticState.Thalf)){ energeticState.Thalf=life; }else { @@ -161,19 +162,47 @@ public final class iaeaNuclide { } return value != 0 ?value:Double.NaN; } catch (Exception e) { - System.out.println("Invalid Value " + name + ' ' + N + ' ' + Z + ' ' + s); + System.out.println("Invalid Value " + name + ' ' + getN() + ' ' + getZ() + ' ' + s); e.printStackTrace(); } } return Double.NaN; } + public short getN() { + return N; + } + + public short getZ() { + return Z; + } + + public double getHalfTime() { + return halfTime; + } + + public double getMass() { + return mass; + } + + public short getDiscovery() { + return discovery; + } + + public energeticState[] getEnergeticStatesArray() { + return energeticStatesArray; + } + + public void setEnergeticStatesArray(energeticState[] energeticStatesArray) { + this.energeticStatesArray = energeticStatesArray; + } + public static final class energeticState{ public final double energy; public double Thalf; public final iaeaDecay[] decaymodes; - private energeticState(iaeaNuclide nuclide,double Thalf,iaeaDecay[] decaymodes){ + private energeticState(EMNuclideIAEA nuclide, double Thalf, iaeaDecay[] decaymodes){ energy=0; this.Thalf=Thalf; this.decaymodes=decaymodes; @@ -184,17 +213,17 @@ public final class iaeaNuclide { } private energeticState(String[] cells){ - iaeaNuclide nuclide= get((int)doubleOrNaN(cells[0],"protons"),(int)doubleOrNaN(cells[1],"neutrons")); + EMNuclideIAEA nuclide = get((int)doubleOrNaN(cells[0],"protons"),(int)doubleOrNaN(cells[1],"neutrons")); if(nuclide==null) { throw new Error("Missing nuclide " + (int) doubleOrNaN(cells[0], "protons") + ' ' + (int) doubleOrNaN(cells[1], "neutrons")); } energy =doubleOrNaN(cells[3],"energy level",nuclide)*1000D;//to eV if(energy<0) { - throw new Error("Invalid energy " + nuclide.N + ' ' + nuclide.Z + ' ' + cells[3]); + throw new Error("Invalid energy " + nuclide.getN() + ' ' + nuclide.getZ() + ' ' + cells[3]); } Thalf =doubleOrNaN(cells[10],"half life",nuclide); if(nuclide.energeticStates==null) { - new Exception("Should be initialized before doing this... "+ nuclide.N + ' ' +nuclide.Z).printStackTrace(); + new Exception("Should be initialized before doing this... "+ nuclide.getN() + ' ' + nuclide.getZ()).printStackTrace(); nuclide.energeticStates = new TreeMap<>(); } nuclide.energeticStates.put(energy,this); @@ -216,7 +245,7 @@ public final class iaeaNuclide { return doubleOrNaN(s,name,null); } - private double doubleOrNaN(String s, String name, iaeaNuclide nuclide){ + private double doubleOrNaN(String s, String name, EMNuclideIAEA nuclide){ s = s.replaceAll("#", ""); if (!s.isEmpty()) { try { @@ -225,7 +254,7 @@ public final class iaeaNuclide { if(nuclide==null){ System.out.println("Invalid Value " + name + ' ' + s); }else { - System.out.println("Invalid Value " + name + ' ' + nuclide.N + ' ' + nuclide.Z + ' ' + s); + System.out.println("Invalid Value " + name + ' ' + nuclide.getN() + ' ' + nuclide.getZ() + ' ' + s); } e.printStackTrace(); } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dAtomDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dAtomDefinition.java deleted file mode 100644 index 965c46cef6..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dAtomDefinition.java +++ /dev/null @@ -1,1689 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.definitions.complex; - -import com.github.technus.tectech.Reference; -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.compatibility.gtpp.GtppAtomLoader; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDefinitionStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalMutableDefinitionStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.tElementalException; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aFluidDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aItemDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aOredictDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eLeptonDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eNeutrinoDefinition; -import com.github.technus.tectech.util.Util; -import com.github.technus.tectech.util.XSTR; -import cpw.mods.fml.common.Loader; -import gregtech.api.enums.Materials; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.*; - -import static com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.dComplexAspectDefinition.getNbtTagCompound; -import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT_144; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition.boson_Y__; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition.deadEnd; -import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; -import static com.github.technus.tectech.util.XSTR.XSTR_INSTANCE; -import static gregtech.api.enums.OrePrefixes.dust; - -/** - * Created by danie_000 on 18.11.2016. - */ -public final class dAtomDefinition extends cElementalDefinition { - public static final long ATOM_COMPLEXITY_LIMIT=65536L; - private static final byte BYTE_OFFSET=32; - - private final int hash; - public static final bTransformationInfo TRANSFORMATION_INFO = new bTransformationInfo(16,0,64); - public static double refMass, refUnstableMass; - - private static final byte nbtType = (byte) 'a'; - private static final Random xstr = new XSTR();//NEEDS SEPARATE! - private static Map<Integer, TreeSet<Integer>> stableIsotopes = new HashMap<>(); - private static final Map<Integer, dAtomDefinition> stableAtoms = new HashMap<>(); - private static Map<Integer, TreeMap<Double, Integer>> mostStableUnstableIsotopes = new HashMap<>(); - private static final Map<Integer, dAtomDefinition> unstableAtoms = new HashMap<>(); - private static cElementalDefinitionStack alpha,deuterium,tritium,helium_3,beryllium_8,carbon_14,neon_24,silicon_34; - private static final HashMap<dAtomDefinition,Double> lifetimeOverrides = new HashMap<>(); - - public final iaeaNuclide iaea; - - private static dAtomDefinition somethingHeavy; - public static dAtomDefinition getSomethingHeavy() { - return somethingHeavy; - } - - private static final ArrayList<Runnable> overrides = new ArrayList<>(); - public static void addOverride(dAtomDefinition atom, double rawLifeTime){ - lifetimeOverrides.put(atom,rawLifeTime); - } - - //float-mass in eV/c^2 - public final double mass; - //public final int charge; - public final int charge; - //int -electric charge in 1/3rds of electron charge for optimization - public final int chargeLeptons; - private double rawLifeTime; - //generation max present inside - minus if contains any anti quark - public final byte type; - - public final byte decayMode;//t neutron to proton+,0,f proton to neutron - //public final boolean stable; - - public final int neutralCount; - public final int element; - - private final boolean iaeaDefinitionExistsAndHasEnergyLevels; - - private final cElementalDefinitionStackMap elementalStacks; - - //stable is rawLifeTime>=10^9 - - @Deprecated - public dAtomDefinition(iElementalDefinition... things) throws tElementalException { - this(true, new cElementalDefinitionStackMap(things)); - } - - @Deprecated - private dAtomDefinition(boolean check, iElementalDefinition... things) throws tElementalException { - this(check, new cElementalDefinitionStackMap(things)); - } - - public dAtomDefinition(cElementalDefinitionStack... things) throws tElementalException { - this(true, new cElementalDefinitionStackMap(things)); - } - - private dAtomDefinition(boolean check, cElementalDefinitionStack... things) throws tElementalException { - this(check, new cElementalDefinitionStackMap(things)); - } - - public dAtomDefinition(cElementalDefinitionStackMap things) throws tElementalException { - this(true, things); - } - - private dAtomDefinition(boolean check, cElementalDefinitionStackMap things) throws tElementalException { - if (check && !canTheyBeTogether(things)) { - throw new tElementalException("Atom Definition error"); - } - elementalStacks = things; - - double mass = 0; - int cLeptons = 0; - int cNucleus = 0; - int neutralCount = 0, element = 0; - int type = 0; - boolean containsAnti = false; - for (cElementalDefinitionStack stack : elementalStacks.values()) { - iElementalDefinition def = stack.definition; - int amount = (int)stack.amount; - if((int)stack.amount!=stack.amount){ - throw new ArithmeticException("Amount cannot be safely converted to int!"); - } - mass += stack.getMass(); - if (def.getType() < 0) { - containsAnti = true; - } - type = Math.max(type, Math.abs(def.getType())); - - if (def instanceof eLeptonDefinition) { - cLeptons += stack.getCharge(); - } else { - cNucleus += stack.getCharge(); - if (def.getCharge() == 3) { - element += amount; - } else if (def.getCharge() == -3) { - element -= amount; - } else if (def.getCharge() == 0) { - neutralCount += amount; - } - } - } - this.type = containsAnti ? (byte) -type : (byte) type; - //this.mass = mass; - chargeLeptons = cLeptons; - charge = cNucleus + cLeptons; - this.neutralCount = neutralCount; - this.element = element; - - element = Math.abs(element); - - //stability curve - int StableIsotope = stableIzoCurve(element); - int izoDiff = neutralCount - StableIsotope; - int izoDiffAbs = Math.abs(izoDiff); - - xstr.setSeed((element + 1L) * (neutralCount + 100L)); - iaea =iaeaNuclide.get(element,neutralCount); - if(iaea!=null){ - if(Double.isNaN(iaea.mass)) { - this.mass = mass; - } else { - this.mass = iaea.mass; - } - - if(Double.isNaN(iaea.halfTime)) { - Double overriddenLifeTime= lifetimeOverrides.get(this); - double rawLifeTimeTemp; - if(overriddenLifeTime!=null) { - rawLifeTimeTemp = overriddenLifeTime; - } else { - rawLifeTimeTemp = calculateLifeTime(izoDiff, izoDiffAbs, element, neutralCount, containsAnti); - } - rawLifeTime = Math.min(rawLifeTimeTemp, STABLE_RAW_LIFE_TIME); - }else { - rawLifeTime = containsAnti ? iaea.halfTime * 1.5514433E-21d * (1d + xstr.nextDouble() * 9d) : iaea.halfTime; - } - iaeaDefinitionExistsAndHasEnergyLevels =iaea.energeticStatesArray.length>1; - }else{ - this.mass=mass; - - Double overriddenLifeTime= lifetimeOverrides.get(this); - double rawLifeTimeTemp; - if(overriddenLifeTime!=null) { - rawLifeTimeTemp = overriddenLifeTime; - } else { - rawLifeTimeTemp = calculateLifeTime(izoDiff, izoDiffAbs, element, neutralCount, containsAnti); - } - rawLifeTime = Math.min(rawLifeTimeTemp, STABLE_RAW_LIFE_TIME); - - iaeaDefinitionExistsAndHasEnergyLevels =false; - } - - if(iaea==null || iaea.energeticStatesArray[0].energy!=0) { - if (izoDiff == 0) { - decayMode = 0; - } else { - decayMode = izoDiff > 0 ? (byte) Math.min(2, 1 + izoDiffAbs / 4) : (byte) -Math.min(2, 1 + izoDiffAbs / 4); - } - }else{ - decayMode = izoDiff > 0 ? (byte) (Math.min(2, 1 + izoDiffAbs / 4)+ BYTE_OFFSET) : (byte) (-Math.min(2, 1 + izoDiffAbs / 4) + BYTE_OFFSET); - } - //this.stable = this.rawLifeTime >= STABLE_RAW_LIFE_TIME; - hash=super.hashCode(); - } - - private static int stableIzoCurve(int element) { - return (int) Math.round(-1.19561E-06D * Math.pow(element, 4D) + - 1.60885E-04D * Math.pow(element, 3D) + - 3.76604E-04D * Math.pow(element, 2D) + - 1.08418E+00D * (double) element); - } - - private static double calculateLifeTime(int izoDiff, int izoDiffAbs, int element, int isotope, boolean containsAnti) { - double rawLifeTime; - - if (element <= 83 && isotope < 127 && (izoDiffAbs == 0 || element == 1 && isotope == 0 || element == 2 && isotope == 1 || izoDiffAbs == 1 && element > 2 && element % 2 == 1 || izoDiffAbs == 3 && element > 30 && element % 2 == 0 || izoDiffAbs == 5 && element > 30 && element % 2 == 0 || izoDiffAbs == 2 && element > 20 && element % 2 == 1)) { - rawLifeTime = (1D + xstr.nextDouble() * 9D) * (containsAnti ? 2.381e4D : 1.5347e25D); - } else { - //Y = (X-A)/(B-A) * (D-C) + C - double unstabilityEXP; - if (element == 0) { - return 1e-35D; - } else if (element == 1) { - unstabilityEXP = 1.743D - Math.abs(izoDiff - 1) * 9.743D; - } else if (element == 2) { - switch (isotope) { - case 4: - unstabilityEXP = 1.61D; - break; - case 5: - unstabilityEXP = -7.523D; - break; - case 6: - unstabilityEXP = -1.51D; - break; - default: - unstabilityEXP = -(izoDiffAbs * 6.165D); - break; - } - } else if (element <= 83 || isotope <= 127 && element <= 120) { - double elementPow4 = Math.pow(element, 4); - - unstabilityEXP = Math.min(element / 2.4D, 6 + ((element + 1) % 2) * 3e6D / elementPow4) + -izoDiff * elementPow4 / 1e8D - Math.abs(izoDiff - 1 + element / 60D) * (3D - element / 12.5D + element * element / 1500D); - } else if (element < 180) { - unstabilityEXP = Math.min((element - 85) * 2, 16 + ((isotope + 1) % 2) * 2.5D - (element - 85) / 3D) - Math.abs(izoDiff) * (3D - element / 13D + element * element / 1600D); - } else { - return -1; - } - if ((isotope == 127 || isotope == 128) && element < 120 && element > 83) { - unstabilityEXP -= 1.8D; - } - if (element > 83 && element < 93 && isotope % 2 == 0 && izoDiff == 3) { - unstabilityEXP += 6; - } - if (element > 93 && element < 103 && isotope % 2 == 0 && izoDiff == 4) { - unstabilityEXP += 6; - } - rawLifeTime = (containsAnti ? 1e-8D : 1) * Math.pow(10D, unstabilityEXP) * (1D + xstr.nextDouble() * 9D); - } - - if (rawLifeTime < 8e-15D) { - return 1e-35D; - } - if (rawLifeTime > 8e28D) { - return 8e30D; - } - return rawLifeTime; - } - - private static boolean canTheyBeTogether(cElementalDefinitionStackMap stacks) { - boolean nuclei = false; - long qty=0; - for (cElementalDefinitionStack stack : stacks.values()) { - if (stack.definition instanceof dHadronDefinition) { - if (((dHadronDefinition) stack.definition).amount != 3) { - return false; - } - nuclei = true; - } else if (!(stack.definition instanceof eLeptonDefinition)) { - return false; - } - if((int)stack.amount!=stack.amount){ - throw new ArithmeticException("Amount cannot be safely converted to int!"); - } - qty+=stack.amount; - } - return nuclei && qty<ATOM_COMPLEXITY_LIMIT; - } - - @Override - public int getCharge() { - return charge; - } - - public int getChargeLeptons() { - return chargeLeptons; - } - - public int getChargeHadrons() { - return charge - chargeLeptons; - } - - public int getIonizationElementWise() { - return element * 3 + chargeLeptons; - } - - @Override - public double getMass() { - return mass; - } - - @Override - public byte getType() { - return type; - } - - @Override - public double getRawTimeSpan(long currentEnergy) { - if(currentEnergy<=0) { - return rawLifeTime; - } - if(iaeaDefinitionExistsAndHasEnergyLevels){ - if(currentEnergy>=iaea.energeticStatesArray.length){ - return iaea.energeticStatesArray[iaea.energeticStatesArray.length-1].Thalf/(currentEnergy-iaea.energeticStatesArray.length+1); - } - return iaea.energeticStatesArray[(int)currentEnergy].Thalf; - } - return rawLifeTime/(currentEnergy+1); - } - - @Override - public boolean isTimeSpanHalfLife() { - return true; - } - - @Override - public byte getColor() { - return -10; - } - - @Override - public String getName() { - int element = Math.abs(this.element); - boolean negative = this.element < 0; - try { - if (Math.abs(type) != 1) { - return (negative ? "~? " : "? ") + Nomenclature.NAME[element]; - } - return negative ? '~' + Nomenclature.NAME[element] : Nomenclature.NAME[element]; - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return (negative ? "Element: ~" : "Element: ") + element; - } - } - - @Override - public String getSymbol() { - int element = Math.abs(this.element); - boolean negative = this.element < 0; - try { - return (negative ? "~" : "") + Nomenclature.SYMBOL[element] + " N:" + neutralCount + " I:" + (neutralCount+element) + " C:" + getCharge(); - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - try { - int s100 = element / 100, s1 = element / 10 % 10, s10 = element % 10; - return (negative ? "~" : "") + Nomenclature.SYMBOL_IUPAC[10 + s100] + Nomenclature.SYMBOL_IUPAC[s10] + Nomenclature.SYMBOL_IUPAC[s1] + " N:" + neutralCount + " I:" + (neutralCount+element) + " C:" + getCharge(); - } catch (Exception E) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return (negative ? "~" : "") + "? N:" + neutralCount + " I:" + (neutralCount+element) + " C:" + getCharge(); - } - } - } - - @Override - public String getShortSymbol() { - int element = Math.abs(this.element); - boolean negative = this.element < 0; - try { - return (negative ? "~" : "") + Nomenclature.SYMBOL[element]; - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - try { - int s100 = element / 100, s1 = element / 10 % 10, s10 = element % 10; - return (negative ? "~" : "") + Nomenclature.SYMBOL_IUPAC[10 + s100] + Nomenclature.SYMBOL_IUPAC[s10] + Nomenclature.SYMBOL_IUPAC[s1]; - } catch (Exception E) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return (negative ? "~" : "") + "?"; - } - } - } - - @Override - public cElementalDefinitionStackMap getSubParticles() { - return elementalStacks.clone(); - } - - @Override - public cElementalDecay[] getDecayArray() { - ArrayList<cElementalDecay> decaysList=new ArrayList<>(4); - return getDecayArray(decaysList,decayMode,true); - } - - private cElementalDecay[] getDecayArray(ArrayList<cElementalDecay> decaysList,int decayMode,boolean tryAnti) {//todo? - if (type == 1) { - switch (decayMode) { - case -2: - if(TecTech.RANDOM.nextBoolean() && ElectronCapture(decaysList)) { - return decaysList.toArray(cElementalDecay.noProduct); - } else if(PbetaDecay(decaysList)) { - return decaysList.toArray(cElementalDecay.noProduct); - } - break; - case -1: - if(Emmision(decaysList, dHadronDefinition.hadron_p1)) { - return decaysList.toArray(cElementalDecay.noProduct); - } - break; - case 0: - if(alphaDecay(decaysList)) { - return decaysList.toArray(cElementalDecay.noProduct); - } - break; - case 1: - if(Emmision(decaysList, dHadronDefinition.hadron_n1)) { - return decaysList.toArray(cElementalDecay.noProduct); - } - break; - case 2: - if(MbetaDecay(decaysList)) { - return decaysList.toArray(cElementalDecay.noProduct); - } - break; - default: - if(decayMode>8){ - if(iaeaDecay(decaysList,0)) { - return decaysList.toArray(cElementalDecay.noProduct); - } - return getDecayArray(decaysList,decayMode- BYTE_OFFSET,false); - } - } - return cElementalDecay.noDecay; - }else if(type ==-1){ - dAtomDefinition anti=getAnti(); - if(anti!=null) { - return anti.getDecayArray(decaysList, decayMode, false); - } - } - return getNaturalDecayInstant(); - } - - private boolean iaeaDecay(ArrayList<cElementalDecay> decaysList,long energy){ - iaeaNuclide.energeticState state; - if(energy>iaea.energeticStatesArray.length) { - state = iaea.energeticStatesArray[iaea.energeticStatesArray.length - 1]; - } else if(energy<=0) { - state = iaea.energeticStatesArray[0]; - } else { - state = iaea.energeticStatesArray[(int) energy]; - } - for (int i=0;i<state.decaymodes.length;i++){ - if(!getDecayFromIaea(decaysList,state.decaymodes[i],energy)) { - decaysList.clear(); - return false; - } - } - return !decaysList.isEmpty(); - } - - private boolean getDecayFromIaea(ArrayList<cElementalDecay> decaysList, iaeaNuclide.iaeaDecay decay, long energy){ - cElementalMutableDefinitionStackMap withThis=elementalStacks.toMutable(),newStuff=new cElementalMutableDefinitionStackMap(); - switch (decay.decayName){ - case "D": { - if (withThis.removeAllAmounts(false, deuterium.definition.getSubParticles())){ - withThis.putReplace(deuterium); - decaysList.add(new cElementalDecay(decay.chance,withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - } - } break; - case "3H": { - if (withThis.removeAllAmounts(false, tritium.definition.getSubParticles())){ - withThis.putReplace(tritium); - decaysList.add(new cElementalDecay(decay.chance,withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - } - } break; - case "3HE": { - if (withThis.removeAllAmounts(false, helium_3.definition.getSubParticles())){ - withThis.putReplace(helium_3); - decaysList.add(new cElementalDecay(decay.chance,withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - } - } break; - case "8BE": { - if (withThis.removeAllAmounts(false, beryllium_8.definition.getSubParticles())){ - withThis.putReplace(beryllium_8); - decaysList.add(new cElementalDecay(decay.chance,withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - } - } break; - case "14C": { - if (withThis.removeAllAmounts(false, carbon_14.definition.getSubParticles())){ - newStuff.putReplace(carbon_14); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "24NE": { - if (withThis.removeAllAmounts(false, neon_24.definition.getSubParticles())){ - newStuff.putReplace(neon_24); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "34SI": { - if (withThis.removeAllAmounts(false, silicon_34.definition.getSubParticles())){ - newStuff.putReplace(silicon_34); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "A": case "A?": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n2,dHadronDefinition.hadron_p2)){ - newStuff.putReplace(alpha); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "B+": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p1)){ - withThis.putUnify(dHadronDefinition.hadron_n1); - newStuff.putReplace(eLeptonDefinition.lepton_e_1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "2B+": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2)){ - withThis.putUnify(dHadronDefinition.hadron_n2); - newStuff.putReplace(eLeptonDefinition.lepton_e_2); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "B-": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n1)){ - withThis.putUnify(dHadronDefinition.hadron_p1); - newStuff.putReplace(eLeptonDefinition.lepton_e1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "2B-": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n2)){ - withThis.putUnify(dHadronDefinition.hadron_p2); - newStuff.putReplace(eLeptonDefinition.lepton_e2); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_2); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "EC": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p1,eLeptonDefinition.lepton_e1)){ - withThis.putUnify(dHadronDefinition.hadron_n1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "2EC": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2,eLeptonDefinition.lepton_e2)){ - withThis.putUnify(dHadronDefinition.hadron_n2); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "B++EC": case "EC+B+": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2,eLeptonDefinition.lepton_e1)){ - withThis.putUnify(dHadronDefinition.hadron_n2); - newStuff.putReplace(eLeptonDefinition.lepton_e_1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "B+A": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p3, dHadronDefinition.hadron_n1)){ - newStuff.putReplace(eLeptonDefinition.lepton_e_1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - newStuff.putReplace(alpha); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "B+P": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2)){ - withThis.putUnify(dHadronDefinition.hadron_n1); - newStuff.putReplace(eLeptonDefinition.lepton_e_1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - newStuff.putReplace(dHadronDefinition.hadron_p1); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "B+2P": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p3)){ - withThis.putUnify(dHadronDefinition.hadron_n1); - newStuff.putReplace(eLeptonDefinition.lepton_e_1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - newStuff.putReplace(dHadronDefinition.hadron_p2); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "B-A": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n3, dHadronDefinition.hadron_p1)){ - newStuff.putReplace(eLeptonDefinition.lepton_e1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); - newStuff.putReplace(alpha); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "B-N": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n2)){ - withThis.putUnify(dHadronDefinition.hadron_p1); - newStuff.putReplace(eLeptonDefinition.lepton_e1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); - newStuff.putReplace(dHadronDefinition.hadron_n1); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "B-2N": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n3)){ - withThis.putUnify(dHadronDefinition.hadron_p1); - newStuff.putReplace(eLeptonDefinition.lepton_e1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); - newStuff.putReplace(dHadronDefinition.hadron_n2); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "B-P": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n1)){ - newStuff.putReplace(eLeptonDefinition.lepton_e1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); - newStuff.putReplace(dHadronDefinition.hadron_p1); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "ECA": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n1,eLeptonDefinition.lepton_e1,dHadronDefinition.hadron_p3)){ - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - newStuff.putReplace(alpha); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "ECP": { - if (withThis.removeAllAmounts(false, eLeptonDefinition.lepton_e1,dHadronDefinition.hadron_p2)){ - withThis.putUnify(dHadronDefinition.hadron_n1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - newStuff.putReplace(dHadronDefinition.hadron_p1); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "EC2P": { - if (withThis.removeAllAmounts(false, eLeptonDefinition.lepton_e1,dHadronDefinition.hadron_p3)){ - withThis.putUnify(dHadronDefinition.hadron_n1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - newStuff.putReplace(dHadronDefinition.hadron_p2); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "ECP+EC2P": {//todo look at branching ratios - if (withThis.removeAllAmounts(false, eLeptonDefinition.lepton_e2,dHadronDefinition.hadron_p5)){ - withThis.putUnify(dHadronDefinition.hadron_n1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); - newStuff.putReplace(dHadronDefinition.hadron_p3); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "N": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n1)){ - newStuff.putReplace(dHadronDefinition.hadron_n1); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "2N": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n2)){ - newStuff.putReplace(dHadronDefinition.hadron_n2); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "P": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p1)){ - newStuff.putReplace(dHadronDefinition.hadron_p1); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "2P": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2)){ - newStuff.putReplace(dHadronDefinition.hadron_p2); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "SF": { - if (Fission(decaysList, withThis, newStuff, decay.chance, false)) { - return true; - } - } break; - case "B-F": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n1)){ - withThis.putUnify(dHadronDefinition.hadron_p1); - newStuff.putReplace(eLeptonDefinition.lepton_e1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); - try{ - if(Fission(decaysList,withThis,newStuff,decay.chance,false)) { - return true; - } - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "ECF": case "ECSF": case "EC(+SF)": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p1,eLeptonDefinition.lepton_e1)){ - withThis.putUnify(dHadronDefinition.hadron_n1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - try{ - if(Fission(decaysList,withThis,newStuff,decay.chance,false)) { - return true; - } - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "SF(+EC+B+)": case "SF+EC+B+": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2,eLeptonDefinition.lepton_e1)){ - withThis.putUnify(dHadronDefinition.hadron_n2); - newStuff.putReplace(eLeptonDefinition.lepton_e_1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); - try{ - if(Fission(decaysList,withThis,newStuff,decay.chance,false)) { - return true; - } - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "SF+EC+B-": { - if (withThis.removeAllAmounts(false, eLeptonDefinition.lepton_e1)){ - newStuff.putReplace(eLeptonDefinition.lepton_e1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); - try{ - if(Fission(decaysList,withThis,newStuff,decay.chance,false)) { - return true; - } - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "IT": case "IT?": case "G": { - if(energy>0){ - decaysList.add(new cElementalDecay(decay.chance, this, boson_Y__)); - }else{ - if(DEBUG_MODE) { - TecTech.LOGGER.info("Tried to emit Gamma from ground state"); - } - decaysList.add(new cElementalDecay(decay.chance, this)); - } - return true; - } //break; - case "IT+EC+B+": { - if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_p2,eLeptonDefinition.lepton_e1)){ - withThis.putUnify(dHadronDefinition.hadron_n2); - newStuff.putReplace(eLeptonDefinition.lepton_e_1); - newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); - newStuff.putReplace(eBosonDefinition.boson_Y__1); - try{ - newStuff.putReplace(new dAtomDefinition(withThis.toImmutable_optimized_unsafeLeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - }catch (Exception e){ - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - } - } break; - case "DEAD_END": - decaysList.add(deadEnd); - return true; - default: throw new Error("Unsupported decay mode: " + decay.decayName + ' ' + neutralCount+ ' ' +element); - } - if(DEBUG_MODE) { - TecTech.LOGGER.info("Failed to decay " + element + ' ' + neutralCount + ' ' + decay.decayName); - } - return false; - } - - private boolean Emmision(ArrayList<cElementalDecay> decaysList, cElementalDefinitionStack emit) { - cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); - if (tree.removeAmount(false, emit)) { - try { - decaysList.add(new cElementalDecay(1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), emit)); - return true; - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - } - return false; - } - - private boolean alphaDecay(ArrayList<cElementalDecay> decaysList) { - cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); - if (tree.removeAllAmounts(false, alpha.definition.getSubParticles())) { - try { - decaysList.add(new cElementalDecay(1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), alpha)); - return true; - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - } - return false; - } - - private boolean MbetaDecay(ArrayList<cElementalDecay> decaysList) { - cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); - if (tree.removeAmount(false, dHadronDefinition.hadron_n1)) { - try { - tree.putUnify(dHadronDefinition.hadron_p1); - decaysList.add(new cElementalDecay(1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), eLeptonDefinition.lepton_e1, eNeutrinoDefinition.lepton_Ve_1)); - return true; - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - } - return false; - } - - private boolean PbetaDecay(ArrayList<cElementalDecay> decaysList) { - cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); - if (tree.removeAmount(false, dHadronDefinition.hadron_p1)) { - try { - tree.putUnify(dHadronDefinition.hadron_n1); - decaysList.add(new cElementalDecay(1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), eLeptonDefinition.lepton_e_1, eNeutrinoDefinition.lepton_Ve1)); - return true; - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - } - return false; - } - - private boolean ElectronCapture(ArrayList<cElementalDecay> decaysList) { - cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); - if (tree.removeAllAmounts(false, dHadronDefinition.hadron_p1,eLeptonDefinition.lepton_e1)) { - try { - tree.putUnify(dHadronDefinition.hadron_n1); - decaysList.add(new cElementalDecay(1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_optimized_unsafeLeavesExposedElementalTree()), 1), eNeutrinoDefinition.lepton_Ve1)); - return true; - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - } - return false; - } - - private boolean Fission(ArrayList<cElementalDecay> decaysList, cElementalMutableDefinitionStackMap fissile, cElementalMutableDefinitionStackMap particles,double probability,boolean spontaneousCheck) { - cElementalMutableDefinitionStackMap heavy = new cElementalMutableDefinitionStackMap(); - double[] liquidDrop= liquidDropFunction(Math.abs(element)<=97); - - for(cElementalDefinitionStack stack: fissile.values()){ - if(spontaneousCheck && stack.definition instanceof dHadronDefinition && - (stack.amount<=80 || stack.amount<90 && XSTR_INSTANCE.nextInt(10)<stack.amount-80)) { - return false; - } - if(stack.definition.getCharge()==0){ - //if(stack.definition instanceof dHadronDefinition){ - double neutrals=stack.amount*liquidDrop[2]; - int neutrals_cnt=(int)Math.floor(neutrals); - neutrals_cnt+=neutrals-neutrals_cnt>XSTR_INSTANCE.nextDouble()?1:0; - particles.putUnify(new cElementalDefinitionStack(stack.definition, neutrals_cnt)); - - int heavy_cnt=(int)Math.ceil(stack.amount*liquidDrop[1]); - while(heavy_cnt+neutrals_cnt>stack.amount) { - heavy_cnt--; - } - fissile.removeAmount(false,new cElementalDefinitionStack(stack.definition,heavy_cnt+neutrals_cnt)); - heavy.putReplace(new cElementalDefinitionStack(stack.definition, heavy_cnt)); - //}else{ - // particles.add(stack); - // light.remove(stack.definition); - //} - }else{ - int heavy_cnt=(int)Math.ceil(stack.amount*liquidDrop[0]); - if(heavy_cnt%2==1 && XSTR_INSTANCE.nextDouble()>0.05D) { - heavy_cnt--; - } - cElementalDefinitionStack new_stack=new cElementalDefinitionStack(stack.definition, heavy_cnt); - fissile.removeAmount(false,new_stack); - heavy.putReplace(new_stack); - } - } - - try { - particles.putReplace(new cElementalDefinitionStack(new dAtomDefinition(fissile.toImmutable_optimized_unsafeLeavesExposedElementalTree()),1)); - particles.putReplace(new cElementalDefinitionStack(new dAtomDefinition(heavy.toImmutable_optimized_unsafeLeavesExposedElementalTree()),1)); - decaysList.add(new cElementalDecay(probability, particles.toImmutable_optimized_unsafeLeavesExposedElementalTree())); - return true; - } catch (Exception e) { - if(DEBUG_MODE) { - e.printStackTrace(); - } - } - return false; - } - - private static double[] liquidDropFunction(boolean asymmetric) { - double[] out = new double[3]; - - out[0] = XSTR_INSTANCE.nextGaussian(); - - if (out[0] < 1 && out[0] >= -1) { - if (XSTR_INSTANCE.nextBoolean()) { - out[0] = XSTR_INSTANCE.nextDouble() * 2d - 1d; - } - } - - if (asymmetric && out[0] > XSTR_INSTANCE.nextDouble() && XSTR_INSTANCE.nextInt(4) == 0) { - out[0] = -out[0]; - } - - //scale to splitting ratio - out[0] = out[0] * 0.05d + .6d; - - if (out[0] < 0 || out[0] > 1) { - return liquidDropFunction(asymmetric); - } - if (out[0] < .5d) { - out[0] = 1d - out[0]; - } - - //extra neutrals - out[2] = 0.012d + XSTR_INSTANCE.nextDouble() * 0.01d; - - if (asymmetric) { - out[1] = out[0]; - } else { - out[1] = out[0] - out[2] * .5d; - } - - return out; - } - - @Override - public cElementalDecay[] getEnergyInducedDecay(long energyLevel) { - if (iaeaDefinitionExistsAndHasEnergyLevels) { - ArrayList<cElementalDecay> decays=new ArrayList<>(4); - if(iaeaDecay(decays,energyLevel)){ - return decays.toArray(cElementalDecay.noProduct); - } - } - if(energyLevel< Math.abs(charge)/3+neutralCount) { - return new cElementalDecay[]{new cElementalDecay(1, this, boson_Y__)}; - } - return getNaturalDecayInstant(); - } - - @Override - public double getEnergyDiffBetweenStates(long currentEnergyLevel,long newEnergyLevel) { - if(iaeaDefinitionExistsAndHasEnergyLevels){ - double result=0; - boolean backwards=newEnergyLevel<currentEnergyLevel; - if(backwards){ - long temp=currentEnergyLevel; - currentEnergyLevel=newEnergyLevel; - newEnergyLevel=temp; - } - - if(currentEnergyLevel<=0){ - if(newEnergyLevel<=0) { - return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - currentEnergyLevel); - } else { - result += iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT * -currentEnergyLevel; - } - }else { - result -= iaea.energeticStatesArray[(int) Math.min(iaea.energeticStatesArray.length - 1, currentEnergyLevel)].energy; - } - if(newEnergyLevel>=iaea.energeticStatesArray.length){ - if(currentEnergyLevel>=iaea.energeticStatesArray.length) { - return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - currentEnergyLevel); - } else { - result += iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - iaea.energeticStatesArray.length + 1); - } - result+=iaea.energeticStatesArray[iaea.energeticStatesArray.length-1].energy; - }else { - result += iaea.energeticStatesArray[(int) Math.max(0, newEnergyLevel)].energy; - } - - return backwards?-result:result; - } - return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT *(newEnergyLevel-currentEnergyLevel); - } - - @Override - public boolean usesSpecialEnergeticDecayHandling() { - return iaeaDefinitionExistsAndHasEnergyLevels; - } - - @Override - public boolean usesMultipleDecayCalls(long energyLevel) { - if(!iaeaDefinitionExistsAndHasEnergyLevels) return false; - iaeaNuclide.energeticState state; - if(energyLevel>iaea.energeticStatesArray.length) { - state = iaea.energeticStatesArray[iaea.energeticStatesArray.length - 1]; - } else if(energyLevel<=0) { - state = iaea.energeticStatesArray[0]; - } else { - state = iaea.energeticStatesArray[(int) energyLevel]; - } - for (iaeaNuclide.iaeaDecay decay:state.decaymodes){ - if(decay.decayName.contains("F")) return true;//if is fissile - } - return false; - } - - @Override - public boolean decayMakesEnergy(long energyLevel) { - return iaeaDefinitionExistsAndHasEnergyLevels; - } - - @Override - public boolean fusionMakesEnergy(long energyLevel) { - return iaea!=null || iaeaDefinitionExistsAndHasEnergyLevels; - } - - @Override - public cElementalDecay[] getNaturalDecayInstant() { - //disembody - ArrayList<cElementalDefinitionStack> decaysInto = new ArrayList<>(); - for (cElementalDefinitionStack elementalStack : elementalStacks.values()) { - if (elementalStack.definition.getType() == 1 || elementalStack.definition.getType() == -1) { - //covers both quarks and antiquarks - decaysInto.add(elementalStack); - } else { - //covers both quarks and antiquarks - decaysInto.add(new cElementalDefinitionStack(boson_Y__, 2)); - } - } - return new cElementalDecay[]{new cElementalDecay(0.75D, decaysInto.toArray(new cElementalDefinitionStack[0])), deadEnd}; - } - - //@Override - //public iElementalDefinition getAnti() { - // cElementalDefinitionStack[] stacks = this.elementalStacks.values(); - // cElementalDefinitionStack[] antiElements = new cElementalDefinitionStack[stacks.length]; - // for (int i = 0; i < antiElements.length; i++) { - // antiElements[i] = new cElementalDefinitionStack(stacks[i].definition.getAnti(), stacks[i].amount); - // } - // try { - // return new dAtomDefinition(false, antiElements); - // } catch (tElementalException e) { - // if (DEBUG_MODE) e.printStackTrace(); - // return null; - // } - //} - - @Override - public dAtomDefinition getAnti() { - cElementalMutableDefinitionStackMap anti = new cElementalMutableDefinitionStackMap(); - for (cElementalDefinitionStack stack : elementalStacks.values()) { - anti.putReplace(new cElementalDefinitionStack(stack.definition.getAnti(), stack.amount)); - } - try { - return new dAtomDefinition(anti.toImmutable_optimized_unsafeLeavesExposedElementalTree()); - } catch (tElementalException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return null; - } - } - - @Override - public aFluidDequantizationInfo someAmountIntoFluidStack() { - return TRANSFORMATION_INFO.fluidDequantization.get(this); - } - - @Override - public aItemDequantizationInfo someAmountIntoItemsStack() { - return TRANSFORMATION_INFO.itemDequantization.get(this); - } - - @Override - public aOredictDequantizationInfo someAmountIntoOredictStack() { - return TRANSFORMATION_INFO.oredictDequantization.get(this); - } - - private static final class Nomenclature { - private static final String[] SYMBOL = new String[]{"Nt", "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og"}; - private static final String[] NAME = new String[]{"Neutronium", "Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminium", "Silicon", "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Caesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum", "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium", "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Nihonium", "Flerovium", "Moscovium", "Livermorium", "Tennessine", "Oganesson"}; - private static final String[] SYMBOL_IUPAC = new String[]{"n", "u", "b", "t", "q", "p", "h", "s", "o", "e", "N", "U", "B", "T", "Q", "P", "H", "S", "O", "E"}; - } - - @Override - public NBTTagCompound toNBT() { - return getNbtTagCompound(nbtType, elementalStacks); - } - - public static dAtomDefinition fromNBT(NBTTagCompound nbt) { - cElementalDefinitionStack[] stacks = new cElementalDefinitionStack[nbt.getInteger("i")]; - for (int i = 0; i < stacks.length; i++) { - stacks[i] = cElementalDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); - } - try { - return new dAtomDefinition(stacks); - } catch (tElementalException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return null; - } - } - - public static void run() { - for (Runnable r : overrides) { - r.run(); - } - - for(Map.Entry<dAtomDefinition,Double> entry:lifetimeOverrides.entrySet()){ - try { - lifetimeOverrides.put(new dAtomDefinition(entry.getKey().elementalStacks), entry.getValue()); - }catch (tElementalException e){ - e.printStackTrace(); //Impossible - } - } - - //populate stable isotopes - for (int element = 1; element < 83; element++)//Up to Bismuth exclusive - { - for (int isotope = 0; isotope < 130; isotope++) { - xstr.setSeed((long) (element + 1) * (isotope + 100)); - //stability curve - int StableIsotope = stableIzoCurve(element); - int izoDiff = isotope - StableIsotope; - int izoDiffAbs = Math.abs(izoDiff); - double rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); - iaeaNuclide nuclide = iaeaNuclide.get(element, isotope); - if (rawLifeTime >= STABLE_RAW_LIFE_TIME || nuclide != null && nuclide.halfTime >= STABLE_RAW_LIFE_TIME) { - TreeSet<Integer> isotopes = stableIsotopes.computeIfAbsent(element, k -> new TreeSet<>()); - isotopes.add(isotope); - } - } - } - - //populate unstable isotopes - for (int element = 83; element < 150; element++) { - for (int isotope = 100; isotope < 180; isotope++) { - xstr.setSeed((long) (element + 1) * (isotope + 100)); - //stability curve - int Isotope = stableIzoCurve(element); - int izoDiff = isotope - Isotope; - int izoDiffAbs = Math.abs(izoDiff); - double rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); - TreeMap<Double, Integer> isotopes = mostStableUnstableIsotopes.computeIfAbsent(element, k -> new TreeMap<>()); - isotopes.put(rawLifeTime, isotope); - } - } - - try { - for (Map.Entry<Integer, TreeSet<Integer>> integerTreeSetEntry : stableIsotopes.entrySet()) { - stableAtoms.put(integerTreeSetEntry.getKey(), new dAtomDefinition( - new cElementalDefinitionStack(dHadronDefinition.hadron_p, integerTreeSetEntry.getKey()), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, integerTreeSetEntry.getValue().first()), - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, integerTreeSetEntry.getKey()))); - if (DEBUG_MODE) { - TecTech.LOGGER.info("Added Stable Atom:" + integerTreeSetEntry.getKey() + ' ' + integerTreeSetEntry.getValue().first() + ' ' + stableAtoms.get(integerTreeSetEntry.getKey()).getMass()); - } - } - for (Map.Entry<Integer, TreeMap<Double, Integer>> integerTreeMapEntry : mostStableUnstableIsotopes.entrySet()) { - unstableAtoms.put(integerTreeMapEntry.getKey(), new dAtomDefinition( - new cElementalDefinitionStack(dHadronDefinition.hadron_p, integerTreeMapEntry.getKey()), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, integerTreeMapEntry.getValue().lastEntry().getValue()), - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, integerTreeMapEntry.getKey()))); - if (DEBUG_MODE) { - TecTech.LOGGER.info("Added Unstable Atom:" + integerTreeMapEntry.getKey() + ' ' + integerTreeMapEntry.getValue().lastEntry().getValue() + ' ' + unstableAtoms.get(integerTreeMapEntry.getKey()).getMass()); - } - } - deuterium=new dAtomDefinition( - dHadronDefinition.hadron_p1, - dHadronDefinition.hadron_n1, - eLeptonDefinition.lepton_e1).getStackForm(1); - tritium=new dAtomDefinition( - dHadronDefinition.hadron_p1, - dHadronDefinition.hadron_n2, - eLeptonDefinition.lepton_e1).getStackForm(1); - helium_3=new dAtomDefinition( - dHadronDefinition.hadron_p2, - dHadronDefinition.hadron_n1, - eLeptonDefinition.lepton_e2).getStackForm(1); - alpha = new dAtomDefinition( - dHadronDefinition.hadron_p2, - dHadronDefinition.hadron_n2).getStackForm(1); - beryllium_8=new dAtomDefinition( - new cElementalDefinitionStack(dHadronDefinition.hadron_p, 4), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 4), - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 4)).getStackForm(1); - carbon_14=new dAtomDefinition( - new cElementalDefinitionStack(dHadronDefinition.hadron_p, 6), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 8), - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 6)).getStackForm(1); - neon_24=new dAtomDefinition( - new cElementalDefinitionStack(dHadronDefinition.hadron_p, 10), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 14), - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 10)).getStackForm(1); - silicon_34=new dAtomDefinition( - new cElementalDefinitionStack(dHadronDefinition.hadron_p, 14), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 20), - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 14)).getStackForm(1); - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - - try { - cElementalDefinition.addCreatorFromNBT(nbtType, dAtomDefinition.class.getMethod("fromNBT", NBTTagCompound.class),(byte)64); - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - if(DEBUG_MODE) { - TecTech.LOGGER.info("Registered Elemental Matter Class: Atom " + nbtType + ' ' + 64); - } - } - - public static void setTransformation(){ - /*----STABLE ATOMS----**/ - refMass = getFirstStableIsotope(1).getMass() * AVOGADRO_CONSTANT_144; - - TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(1), AVOGADRO_CONSTANT_144),Materials.Hydrogen.mGas,144); - TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(2), AVOGADRO_CONSTANT_144),Materials.Helium.mGas, 144); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(3), AVOGADRO_CONSTANT_144), dust, Materials.Lithium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(4), AVOGADRO_CONSTANT_144), dust, Materials.Beryllium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(5), AVOGADRO_CONSTANT_144), dust, Materials.Boron,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(6), AVOGADRO_CONSTANT_144), dust, Materials.Carbon,1); - TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(7), AVOGADRO_CONSTANT_144),Materials.Nitrogen.mGas, 144); - TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(8), AVOGADRO_CONSTANT_144),Materials.Oxygen.mGas, 144); - TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(9), AVOGADRO_CONSTANT_144),Materials.Fluorine.mGas, 144); - //transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(10), AVOGADRO_CONSTANT_144),Materials.Neon.mGas.getID(), 144); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(11), AVOGADRO_CONSTANT_144), dust, Materials.Sodium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(12), AVOGADRO_CONSTANT_144), dust, Materials.Magnesium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(13), AVOGADRO_CONSTANT_144), dust, Materials.Aluminium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(14), AVOGADRO_CONSTANT_144), dust, Materials.Silicon,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(15), AVOGADRO_CONSTANT_144), dust, Materials.Phosphorus,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(16), AVOGADRO_CONSTANT_144), dust, Materials.Sulfur,1); - TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(17), AVOGADRO_CONSTANT_144),Materials.Argon.mGas, 144); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(19), AVOGADRO_CONSTANT_144), dust, Materials.Potassium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(20), AVOGADRO_CONSTANT_144), dust, Materials.Calcium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(21), AVOGADRO_CONSTANT_144), dust, Materials.Scandium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(22), AVOGADRO_CONSTANT_144), dust, Materials.Titanium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(23), AVOGADRO_CONSTANT_144), dust, Materials.Vanadium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(24), AVOGADRO_CONSTANT_144), dust, Materials.Chrome,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(25), AVOGADRO_CONSTANT_144), dust, Materials.Manganese,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(26), AVOGADRO_CONSTANT_144), dust, Materials.Iron,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(27), AVOGADRO_CONSTANT_144), dust, Materials.Cobalt,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(28), AVOGADRO_CONSTANT_144), dust, Materials.Nickel,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(29), AVOGADRO_CONSTANT_144), dust, Materials.Copper,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(30), AVOGADRO_CONSTANT_144), dust, Materials.Zinc,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(31), AVOGADRO_CONSTANT_144), dust, Materials.Gallium,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(32), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Germanium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(33), AVOGADRO_CONSTANT_144), dust, Materials.Arsenic,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(34), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Selenium,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(35), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Bromine,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(36), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Krypton,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(37), AVOGADRO_CONSTANT_144), dust, Materials.Rubidium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(38), AVOGADRO_CONSTANT_144), dust, Materials.Strontium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(39), AVOGADRO_CONSTANT_144), dust, Materials.Yttrium,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(40), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Zirconium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(41), AVOGADRO_CONSTANT_144), dust, Materials.Niobium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(42), AVOGADRO_CONSTANT_144), dust, Materials.Molybdenum,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(43), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Technetium,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(44), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Ruthenium,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(45), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Rhodium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(46), AVOGADRO_CONSTANT_144), dust, Materials.Palladium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(47), AVOGADRO_CONSTANT_144), dust, Materials.Silver,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(48), AVOGADRO_CONSTANT_144), dust, Materials.Cadmium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(49), AVOGADRO_CONSTANT_144), dust, Materials.Indium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(50), AVOGADRO_CONSTANT_144), dust, Materials.Tin,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(51), AVOGADRO_CONSTANT_144), dust, Materials.Antimony,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(52), AVOGADRO_CONSTANT_144), dust, Materials.Tellurium,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(53), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Iodine,1); - //transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(54), AVOGADRO_CONSTANT_144),Materials.Xenon.mGas.getID(), 144); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(55), AVOGADRO_CONSTANT_144), dust, Materials.Caesium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(56), AVOGADRO_CONSTANT_144), dust, Materials.Barium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(57), AVOGADRO_CONSTANT_144), dust, Materials.Lanthanum,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(58), AVOGADRO_CONSTANT_144), dust, Materials.Cerium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(59), AVOGADRO_CONSTANT_144), dust, Materials.Praseodymium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(60), AVOGADRO_CONSTANT_144), dust, Materials.Neodymium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(61), AVOGADRO_CONSTANT_144), dust, Materials.Promethium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(62), AVOGADRO_CONSTANT_144), dust, Materials.Samarium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(63), AVOGADRO_CONSTANT_144), dust, Materials.Europium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(64), AVOGADRO_CONSTANT_144), dust, Materials.Gadolinium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(65), AVOGADRO_CONSTANT_144), dust, Materials.Terbium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(66), AVOGADRO_CONSTANT_144), dust, Materials.Dysprosium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(67), AVOGADRO_CONSTANT_144), dust, Materials.Holmium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(68), AVOGADRO_CONSTANT_144), dust, Materials.Erbium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(69), AVOGADRO_CONSTANT_144), dust, Materials.Thulium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(70), AVOGADRO_CONSTANT_144), dust, Materials.Ytterbium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(71), AVOGADRO_CONSTANT_144), dust, Materials.Lutetium,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(72), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Hafnum,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(73), AVOGADRO_CONSTANT_144), dust, Materials.Tantalum,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(74), AVOGADRO_CONSTANT_144), dust, Materials.Tungsten,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(75), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Rhenium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(76), AVOGADRO_CONSTANT_144), dust, Materials.Osmium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(77), AVOGADRO_CONSTANT_144), dust, Materials.Iridium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(78), AVOGADRO_CONSTANT_144), dust, Materials.Platinum,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(79), AVOGADRO_CONSTANT_144), dust, Materials.Gold,1); - TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(80), AVOGADRO_CONSTANT_144),Materials.Mercury.mFluid, 144); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(81), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Thallium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(82), AVOGADRO_CONSTANT_144), dust, Materials.Lead,1); - - /*----UNSTABLE ATOMS----**/ - refUnstableMass = getFirstStableIsotope(82).getMass() * AVOGADRO_CONSTANT_144; - - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(83), AVOGADRO_CONSTANT_144), dust, Materials.Bismuth,1); - //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(84),AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Polonium,1); - //transformation.addFluid(new cElementalDefinitionStack(getBestUnstableIsotope(85),AVOGADRO_CONSTANT_144),Materials.Astatine.mPlasma.getID(), 144); - TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(getBestUnstableIsotope(86), AVOGADRO_CONSTANT_144),Materials.Radon.mGas, 144); - //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(87),AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Francium,1); - //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(88),AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Radium,1); - //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(89),AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Actinium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(90), AVOGADRO_CONSTANT_144), dust, Materials.Thorium,1); - //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(91),AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Protactinium,1); - ////transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(92),AVOGADRO_CONSTANT_144), dust, Materials.Uranium,1); - //transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(93),AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Neptunium,1); - ////transformation.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(94),AVOGADRO_CONSTANT_144), dust, Materials.Plutonium,1); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(getBestUnstableIsotope(95), AVOGADRO_CONSTANT_144), dust, Materials.Americium,1); - - try { - dAtomDefinition temp; - TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(deuterium.definition, AVOGADRO_CONSTANT_144),Materials.Deuterium.mGas, 144); - - TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(tritium.definition, AVOGADRO_CONSTANT_144),Materials.Tritium.mGas, 144); - - TRANSFORMATION_INFO.addFluid(new cElementalDefinitionStack(helium_3.definition, AVOGADRO_CONSTANT_144),Materials.Helium_3.mGas, 144); - - temp=new dAtomDefinition( - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 92), - new cElementalDefinitionStack(dHadronDefinition.hadron_p, 92), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 146) - ); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(temp, AVOGADRO_CONSTANT_144), dust, Materials.Uranium/*238*/,1); - - double tempMass=temp.getMass(); - - temp=new dAtomDefinition( - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 92), - new cElementalDefinitionStack(dHadronDefinition.hadron_p, 92), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 143) - ); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(temp, AVOGADRO_CONSTANT_144), dust, Materials.Uranium235,1); - - TecTech.LOGGER.info("Diff Mass U : "+(tempMass-temp.getMass())); - - temp=new dAtomDefinition( - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 94), - new cElementalDefinitionStack(dHadronDefinition.hadron_p, 94), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 145) - ); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(temp, AVOGADRO_CONSTANT_144), dust, Materials.Plutonium/*239*/,1); - - somethingHeavy=new dAtomDefinition( - new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 94), - new cElementalDefinitionStack(dHadronDefinition.hadron_p, 94), - new cElementalDefinitionStack(dHadronDefinition.hadron_n, 147) - ); - TRANSFORMATION_INFO.addOredict(new cElementalDefinitionStack(somethingHeavy, AVOGADRO_CONSTANT_144), dust, Materials.Plutonium241,1); - - TecTech.LOGGER.info("Diff Mass Pu: "+(somethingHeavy.getMass()-temp.getMass())); - - TecTech.LOGGER.info("Neutron Mass: "+dHadronDefinition.hadron_n.getMass()); - - } catch (tElementalException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - - if(Loader.isModLoaded(Reference.GTPLUSPLUS)) { - new GtppAtomLoader().run(); - } - } - - public static dAtomDefinition getFirstStableIsotope(int element) { - return stableAtoms.get(element); - } - - public static dAtomDefinition getBestUnstableIsotope(int element) { - return unstableAtoms.get(element); - } - - @Override - public byte getClassType() { - return 64; - } - - public static byte getClassTypeStatic(){ - return 64; - } - - @Override - public int hashCode() { - return hash; - } - - @Override - public void addScanShortSymbols(ArrayList<String> lines, int capabilities, long energyLevel) { - if(Util.areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add(getShortSymbol()); - } - } - - @Override - public void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel) { - if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { - lines.add("CLASS = " + nbtType + ' ' + getClassType()); - } - if(Util.areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add("NAME = "+getName()); - lines.add("SYMBOL = "+getSymbol()); - } - if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) { - lines.add("CHARGE = " + getCharge() / 3D + " e"); - } - if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) { - lines.add(getColor() < 0 ? "COLORLESS" : "CARRIES COLOR"); - } - if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) { - lines.add("MASS = " + getMass() + " eV/c\u00b2"); - } - if(iaeaDefinitionExistsAndHasEnergyLevels && Util.areBitsSet(SCAN_GET_ENERGY_STATES,capabilities)){ - for(int i=1;i<iaea.energeticStatesArray.length;i++){ - lines.add("E LEVEL "+i+" = "+iaea.energeticStatesArray[i].energy+" eV"); - } - } - if(Util.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)){ - lines.add("HALF LIFE = "+getRawTimeSpan(energyLevel)+ " s"); - lines.add(" At current energy level"); - } - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dHadronDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dHadronDefinition.java deleted file mode 100644 index c5efaf1403..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/dHadronDefinition.java +++ /dev/null @@ -1,520 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.definitions.complex; - -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDefinitionStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalMutableDefinitionStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.tElementalException; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.*; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eQuarkDefinition; -import com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM; -import com.github.technus.tectech.util.Util; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.oredict.OreDictionary; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import static com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.dComplexAspectDefinition.getNbtTagCompound; -import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT_144; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition.TRANSFORMATION_INFO; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition.boson_Y__; -import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; -import static gregtech.api.enums.OrePrefixes.dust; - -/** - * Created by danie_000 on 17.11.2016. - */ -public final class dHadronDefinition extends cElementalDefinition {//TODO Optimize map i/o - private final int hash; - - private static final byte nbtType = (byte) 'h'; - //Helpers - public static final Map<dHadronDefinition,String> SYMBOL_MAP =new HashMap<>(); - public static final Map<dHadronDefinition,String> NAME_MAP =new HashMap<>(); - public static dHadronDefinition hadron_p, hadron_n, hadron_p_, hadron_n_; - public static cElementalDefinitionStack hadron_p1, hadron_n1, hadron_p2, hadron_n2, hadron_p3, hadron_n3, hadron_p5; - private static double protonMass = 0D; - private static double neutronMass = 0D; - private static final double actualProtonMass=938272081.3D; - private static final double actualNeutronMass=939565413.3D; - - //float-mass in eV/c^2 - public final double mass; - //int -electric charge in 1/3rds of electron charge for optimization - public final int charge; - public final double rawLifeTime; - public final int amount; - //generation max present inside - minus if contains any antiquark - public final byte type; - //private final FluidStack fluidThing; - //private final ItemStack itemThing; - - private final cElementalDefinitionStackMap quarkStacks; - - @Deprecated - public dHadronDefinition(eQuarkDefinition... quarks) throws tElementalException { - this(true, new cElementalDefinitionStackMap(quarks)); - } - - @Deprecated - private dHadronDefinition(boolean check, eQuarkDefinition... quarks) throws tElementalException { - this(check, new cElementalDefinitionStackMap(quarks)); - } - - public dHadronDefinition(cElementalDefinitionStack... quarks) throws tElementalException { - this(true, new cElementalDefinitionStackMap(quarks)); - } - - private dHadronDefinition(boolean check, cElementalDefinitionStack... quarks) throws tElementalException { - this(check, new cElementalDefinitionStackMap(quarks)); - } - - public dHadronDefinition(cElementalDefinitionStackMap quarks) throws tElementalException { - this(true, quarks); - } - - private dHadronDefinition(boolean check, cElementalDefinitionStackMap quarks) throws tElementalException { - if (check && !canTheyBeTogether(quarks)) { - throw new tElementalException("Hadron Definition error"); - } - quarkStacks = quarks; - - int amount = 0; - int charge = 0; - int type = 0; - boolean containsAnti = false; - double mass = 0; - for (cElementalDefinitionStack quarkStack : quarkStacks.values()) { - amount += quarkStack.amount; - if((int)quarkStack.amount!=quarkStack.amount){ - throw new ArithmeticException("Amount cannot be safely converted to int!"); - } - mass += quarkStack.getMass(); - charge += quarkStack.getCharge(); - type = Math.max(Math.abs(quarkStack.definition.getType()), type); - if (quarkStack.definition.getType() < 0) { - containsAnti = true; - } - } - this.amount = amount; - this.charge = charge; - this.type = containsAnti ? (byte) -type : (byte) type; - long mult = this.amount * this.amount * (this.amount - 1); - mass = mass * 5.543D * mult;//yes it becomes heavier - - if (mass == protonMass && this.amount == 3) { - rawLifeTime = iElementalDefinition.STABLE_RAW_LIFE_TIME; - mass=actualProtonMass; - } else if (mass == neutronMass && this.amount == 3) { - rawLifeTime = 882D; - mass=actualNeutronMass; - } else { - if (this.amount == 3) { - rawLifeTime = 1.34D / mass * Math.pow(9.81, charge); - } else if (this.amount == 2) { - rawLifeTime = 1.21D / mass / Math.pow(19.80, charge); - } else { - rawLifeTime = 1.21D / mass / Math.pow(9.80, charge); - } - } - this.mass=mass; - hash=super.hashCode(); - } - - //public but u can just try{}catch(){} the constructor it still calls this method - private static boolean canTheyBeTogether(cElementalDefinitionStackMap stacks) { - long amount = 0; - for (cElementalDefinitionStack quarks : stacks.values()) { - if (!(quarks.definition instanceof eQuarkDefinition)) { - return false; - } - if((int)quarks.amount!=quarks.amount){ - throw new ArithmeticException("Amount cannot be safely converted to int!"); - } - amount += quarks.amount; - } - return amount >= 2 && amount <= 12; - } - - @Override - public String getName() { - StringBuilder name= new StringBuilder(getSimpleName()); - name.append(':'); - String sym= NAME_MAP.get(this); - if(sym!=null){ - name.append(' ').append(sym); - }else { - for (cElementalDefinitionStack quark : quarkStacks.values()) { - name.append(' ').append(quark.definition.getSymbol()).append((int)quark.amount); - } - } - return name.toString(); - } - - private String getSimpleName() { - switch (amount) { - case 2: - return "Meson"; - case 3: - return "Baryon"; - case 4: - return "Tetraquark"; - case 5: - return "Pentaquark"; - case 6: - return "Hexaquark"; - default: - return "Hadron"; - } - } - - @Override - public String getSymbol() { - String sym=SYMBOL_MAP.get(this); - if(sym!=null){ - return sym; - }else { - StringBuilder symbol = new StringBuilder(8); - for (cElementalDefinitionStack quark : quarkStacks.values()) { - for (int i = 0; i < quark.amount; i++) { - symbol.append(quark.definition.getSymbol()); - } - } - return symbol.toString(); - } - } - - @Override - public String getShortSymbol() { - String sym=SYMBOL_MAP.get(this); - if(sym!=null){ - return sym; - }else { - StringBuilder symbol = new StringBuilder(8); - for (cElementalDefinitionStack quark : quarkStacks.values()) { - for (int i = 0; i < quark.amount; i++) { - symbol.append(quark.definition.getShortSymbol()); - } - } - return symbol.toString(); - } - } - - @Override - public byte getColor() { - return -7; - } - - @Override - public cElementalDefinitionStackMap getSubParticles() { - return quarkStacks; - } - - @Override - public cElementalDecay[] getNaturalDecayInstant() { - cElementalDefinitionStack[] quarkStacks = this.quarkStacks.values(); - if (amount == 2 && quarkStacks.length == 2 && quarkStacks[0].definition.getMass() == quarkStacks[1].definition.getMass() && quarkStacks[0].definition.getType() == -quarkStacks[1].definition.getType()) { - return cElementalDecay.noProduct; - } - ArrayList<cElementalDefinitionStack> decaysInto = new ArrayList<>(); - for (cElementalDefinitionStack quarks : quarkStacks) { - if (quarks.definition.getType() == 1 || quarks.definition.getType() == -1) { - //covers both quarks and antiquarks - decaysInto.add(quarks); - } else { - //covers both quarks and antiquarks - decaysInto.add(new cElementalDefinitionStack(boson_Y__, 2)); - } - } - return new cElementalDecay[]{ - new cElementalDecay(0.75D, decaysInto.toArray(new cElementalDefinitionStack[0])), - eBosonDefinition.deadEnd - }; - } - - @Override - public cElementalDecay[] getEnergyInducedDecay(long energyLevel) { - cElementalDefinitionStack[] quarkStacks = this.quarkStacks.values(); - if (amount == 2 && quarkStacks.length == 2 && quarkStacks[0].definition.getMass() == quarkStacks[1].definition.getMass() && quarkStacks[0].definition.getType() == -quarkStacks[1].definition.getType()) { - return cElementalDecay.noProduct; - } - return new cElementalDecay[]{new cElementalDecay(0.75D, quarkStacks), eBosonDefinition.deadEnd}; //decay into quarks - } - - @Override - public double getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { - return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT *(newEnergyLevel-currentEnergyLevel); - } - - @Override - public boolean usesSpecialEnergeticDecayHandling() { - return false; - } - - @Override - public boolean usesMultipleDecayCalls(long energyLevel) { - return false; - } - - @Override - public boolean decayMakesEnergy(long energyLevel) { - return false; - } - - @Override - public boolean fusionMakesEnergy(long energyLevel) { - return false; - } - - @Override - public cElementalDecay[] getDecayArray() { - cElementalDefinitionStack[] quarkStacks = this.quarkStacks.values(); - if (amount == 2 && quarkStacks.length == 2 && - quarkStacks[0].definition.getMass() == quarkStacks[1].definition.getMass() && - quarkStacks[0].definition.getType() == -quarkStacks[1].definition.getType()) { - return cElementalDecay.noProduct; - } else if (amount != 3) { - return new cElementalDecay[]{new cElementalDecay(0.95D, quarkStacks), eBosonDefinition.deadEnd}; //decay into quarks - } else { - ArrayList<eQuarkDefinition> newBaryon = new ArrayList<>(); - iElementalDefinition[] Particles = new iElementalDefinition[2]; - for (cElementalDefinitionStack quarks : quarkStacks) { - for (int i = 0; i < quarks.amount; i++) { - newBaryon.add((eQuarkDefinition) quarks.definition); - } - } - //remove last - eQuarkDefinition lastQuark = newBaryon.remove(2); - - cElementalDefinitionStack[] decay; - if (Math.abs(lastQuark.getType()) > 1) { - decay = lastQuark.getDecayArray()[1].outputStacks.values(); - } else { - decay = lastQuark.getDecayArray()[2].outputStacks.values(); - } - newBaryon.add((eQuarkDefinition) decay[0].definition); - Particles[0] = decay[1].definition; - Particles[1] = decay[2].definition; - - eQuarkDefinition[] contentOfBaryon = newBaryon.toArray(new eQuarkDefinition[3]); - - try { - return new cElementalDecay[]{ - new cElementalDecay(0.001D, new dHadronDefinition(false, contentOfBaryon), Particles[0], Particles[1], boson_Y__), - new cElementalDecay(0.99D, new dHadronDefinition(false, contentOfBaryon), Particles[0], Particles[1]), - eBosonDefinition.deadEnd}; - } catch (tElementalException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return new cElementalDecay[]{eBosonDefinition.deadEnd}; - } - } - } - - @Override - public double getMass() { - return mass; - } - - @Override - public int getCharge() { - return charge; - } - - @Override - public double getRawTimeSpan(long currentEnergy) { - return rawLifeTime; - } - - @Override - public boolean isTimeSpanHalfLife() { - return true; - } - - @Override - public byte getType() { - return type; - } - - //@Override - //public iElementalDefinition getAnti() { - // cElementalDefinitionStack[] stacks = this.quarkStacks.values(); - // cElementalDefinitionStack[] antiElements = new cElementalDefinitionStack[stacks.length]; - // for (int i = 0; i < antiElements.length; i++) { - // antiElements[i] = new cElementalDefinitionStack(stacks[i].definition.getAnti(), stacks[i].amount); - // } - // try { - // return new dHadronDefinition(false, antiElements); - // } catch (tElementalException e) { - // if (DEBUG_MODE) e.printStackTrace(); - // return null; - // } - //} - - @Override - public iElementalDefinition getAnti() { - cElementalMutableDefinitionStackMap anti = new cElementalMutableDefinitionStackMap(); - for (cElementalDefinitionStack stack : quarkStacks.values()) { - anti.putReplace(new cElementalDefinitionStack(stack.definition.getAnti(), stack.amount)); - } - try { - return new dHadronDefinition(anti.toImmutable_optimized_unsafeLeavesExposedElementalTree()); - } catch (tElementalException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return null; - } - } - - @Override - public aFluidDequantizationInfo someAmountIntoFluidStack() { - return null; - } - - @Override - public aItemDequantizationInfo someAmountIntoItemsStack() { - return null; - } - - @Override - public aOredictDequantizationInfo someAmountIntoOredictStack() { - return null; - } - - @Override - public NBTTagCompound toNBT() { - return getNbtTagCompound(nbtType, quarkStacks); - } - - public static dHadronDefinition fromNBT(NBTTagCompound nbt) { - cElementalDefinitionStack[] stacks = new cElementalDefinitionStack[nbt.getInteger("i")]; - for (int i = 0; i < stacks.length; i++) { - stacks[i] = cElementalDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); - } - try { - return new dHadronDefinition(stacks); - } catch (tElementalException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return null; - } - } - - public static void run() { - try { - hadron_p = new dHadronDefinition(new cElementalDefinitionStackMap(eQuarkDefinition.quark_u.getStackForm(2), eQuarkDefinition.quark_d.getStackForm(1))); - protonMass = hadron_p.mass; - //redefine the proton with proper lifetime (the lifetime is based on mass comparison) - hadron_p = new dHadronDefinition(new cElementalDefinitionStackMap(eQuarkDefinition.quark_u.getStackForm(2), eQuarkDefinition.quark_d.getStackForm(1))); - SYMBOL_MAP.put(hadron_p,"p"); - NAME_MAP.put(hadron_p,"Proton"); - DebugElementalInstanceContainer_EM.STACKS_REGISTERED.add(hadron_p); - hadron_p_ = (dHadronDefinition) hadron_p.getAnti(); - SYMBOL_MAP.put(hadron_p_,"~p"); - NAME_MAP.put(hadron_p_,"Anti Proton"); - DebugElementalInstanceContainer_EM.STACKS_REGISTERED.add(hadron_p_); - hadron_n = new dHadronDefinition(new cElementalDefinitionStackMap(eQuarkDefinition.quark_u.getStackForm(1), eQuarkDefinition.quark_d.getStackForm(2))); - neutronMass = hadron_n.mass; - //redefine the neutron with proper lifetime (the lifetime is based on mass comparison) - hadron_n = new dHadronDefinition(new cElementalDefinitionStackMap(eQuarkDefinition.quark_u.getStackForm(1), eQuarkDefinition.quark_d.getStackForm(2))); - SYMBOL_MAP.put(hadron_n, "n"); - NAME_MAP.put(hadron_n, "Neutron"); - DebugElementalInstanceContainer_EM.STACKS_REGISTERED.add(hadron_n); - hadron_n_ = (dHadronDefinition) hadron_n.getAnti(); - SYMBOL_MAP.put(hadron_n_,"~n"); - NAME_MAP.put(hadron_n_,"Anti Neutron"); - DebugElementalInstanceContainer_EM.STACKS_REGISTERED.add(hadron_n_); - } catch (tElementalException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - protonMass = -1; - neutronMass = -1; - } - hadron_p1 = new cElementalDefinitionStack(hadron_p, 1D); - hadron_n1 = new cElementalDefinitionStack(hadron_n, 1D); - hadron_p2 = new cElementalDefinitionStack(hadron_p, 2D); - hadron_n2 = new cElementalDefinitionStack(hadron_n, 2D); - hadron_p3 = new cElementalDefinitionStack(hadron_p, 3D); - hadron_n3 = new cElementalDefinitionStack(hadron_n, 3D); - hadron_p5 = new cElementalDefinitionStack(hadron_p, 5D); - - try { - cElementalDefinition.addCreatorFromNBT(nbtType, dHadronDefinition.class.getMethod("fromNBT", NBTTagCompound.class),(byte)-64); - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - if(DEBUG_MODE) { - TecTech.LOGGER.info("Registered Elemental Matter Class: Hadron " + nbtType + ' ' + -64); - } - } - - public static void setTransformations(){ - //Added to atom map, but should be in its own - cElementalDefinitionStack neutrons=new cElementalDefinitionStack(hadron_n, 1000* AVOGADRO_CONSTANT_144); - TRANSFORMATION_INFO.oredictDequantization.put(neutrons.definition,new aOredictDequantizationInfo(neutrons, dust, Materials.Neutronium,1)); - bTransformationInfo.oredictQuantization.put( - OreDictionary.getOreID(OrePrefixes.ingotHot.name()+Materials.Neutronium.mName), - new aOredictQuantizationInfo(OrePrefixes.ingotHot,Materials.Neutronium,1 ,neutrons) - ); - } - - @Override - public byte getClassType() { - return -64; - } - - public static byte getClassTypeStatic(){ - return -64; - } - - @Override - public int hashCode() { - return hash; - } - - @Override - public void addScanShortSymbols(ArrayList<String> lines, int capabilities, long energyLevel) { - if(Util.areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add(getShortSymbol()); - } - } - - @Override - public void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel) { - if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { - lines.add("CLASS = " + nbtType + ' ' + getClassType()); - } - if(Util.areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add("NAME = "+getSimpleName()); - //lines.add("SYMBOL = "+getSymbol()); - } - if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) { - lines.add("CHARGE = " + getCharge() / 3D + " e"); - } - if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) { - lines.add(getColor() < 0 ? "COLORLESS" : "CARRIES COLOR"); - } - if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) { - lines.add("MASS = " + getMass() + " eV/c\u00b2"); - } - if(Util.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)){ - lines.add("HALF LIFE = "+getRawTimeSpan(energyLevel)+ " s"); - lines.add(" "+"At current energy level"); - } - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMBosonDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMBosonDefinition.java new file mode 100644 index 0000000000..affebf91a2 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMBosonDefinition.java @@ -0,0 +1,16 @@ +package com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive; + +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate; + +import static net.minecraft.util.StatCollector.translateToLocal; + +public abstract class EMBosonDefinition extends EMPrimitiveTemplate { + protected EMBosonDefinition(String name, String symbol, int generation, double mass, int charge, int color, int ID, String bind) { + super(name, symbol, generation, mass, charge, color, ID, bind); + } + + @Override + public String getLocalizedTypeName() { + return translateToLocal("tt.keyword.Boson"); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMFermionDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMFermionDefinition.java new file mode 100644 index 0000000000..4c0e1d28bc --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMFermionDefinition.java @@ -0,0 +1,16 @@ +package com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive; + +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate; + +import static net.minecraft.util.StatCollector.translateToLocal; + +public abstract class EMFermionDefinition extends EMPrimitiveTemplate { + protected EMFermionDefinition(String name, String symbol, int generation, double mass, int charge, int color, int ID, String bind) { + super(name, symbol, generation, mass, charge, color, ID, bind); + } + + @Override + public String getLocalizedTypeName() { + return translateToLocal("tt.keyword.Fermion"); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMGaugeBosonDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMGaugeBosonDefinition.java new file mode 100644 index 0000000000..8b1e1d556b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMGaugeBosonDefinition.java @@ -0,0 +1,84 @@ +package com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive; + +import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMType; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; +import com.github.technus.tectech.util.TT_Utility; + +import static com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay.NO_DECAY; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMLeptonDefinition.*; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMNeutrinoDefinition.*; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMQuarkDefinition.*; +import static net.minecraft.util.StatCollector.translateToLocal; + +/** + * Created by danie_000 on 22.10.2016. + */ +public class EMGaugeBosonDefinition extends EMBosonDefinition { + public static final EMGaugeBosonDefinition + boson_g__ = new EMGaugeBosonDefinition("tt.keyword.Gluon", "g", 0, 0, 8, 27, "g"), + boson_Y__ = new EMGaugeBosonDefinition("tt.keyword.Photon", "\u03b3", 1e-18D, 0, -1, 28, "Y"), + boson_Z = new EMGaugeBosonDefinition("tt.keyword.Weak0", "Z0", 91.1876e9, 0, -1, 29, "Z0"), + boson_W_ = new EMGaugeBosonDefinition("tt.keyword.WeakPlus", "W+", 80.379e9, 3, -1, 30, "W+"), + boson_W = new EMGaugeBosonDefinition("tt.keyword.WeakMinus", "W-", 80.379e9, -3, -1, 31, "W-"); + //deadEnd + public static final EMDecay deadEnd = new EMDecay(boson_Y__, boson_Y__); + public static final EMDefinitionStack boson_Y__1 = new EMDefinitionStack(boson_Y__, 1); + public static final EMDecay deadEndHalf = new EMDecay(boson_Y__1); + + protected EMGaugeBosonDefinition(String name, String symbol, double mass, int charge, int color, int ID, String bind) { + super(name, TT_Utility.toSuperscript(symbol), 0, mass, charge, color, ID, bind); + } + + public static void run(EMDefinitionsRegistry registry) { + registry.registerDefinitionClass(new EMType(EMGaugeBosonDefinition.class, "tt.keyword.GaugeBoson")); + boson_g__.init(registry, boson_g__, 3e-50, 0, 0, deadEndHalf); + boson_Y__.init(registry, boson_Y__, NO_DECAY_RAW_LIFE_TIME, -1, -1, NO_DECAY); + boson_Z.init(registry, boson_Z, 3e-25, 11, 11, + new EMDecay(0.03363, lepton_e, lepton_e_), + new EMDecay(0.03366, lepton_m, lepton_m_), + new EMDecay(0.03367, lepton_t, lepton_t_), + new EMDecay(0.068333, lepton_Ve, lepton_Ve_), + new EMDecay(0.068333, lepton_Vm, lepton_Vm_), + new EMDecay(0.068333, lepton_Vt, lepton_Vt_), + new EMDecay(0.118, quark_u, quark_u_), + new EMDecay(0.118, quark_c, quark_c_), + new EMDecay(0.152, quark_d, quark_d_), + new EMDecay(0.152, quark_s, quark_s_), + new EMDecay(0.152, quark_b, quark_b_), + deadEnd); + boson_W.init(registry, boson_W_, 3e-25, 9, 9, + new EMDecay(0.108, lepton_e, lepton_Ve_), + new EMDecay(0.108, lepton_m, lepton_Vm_), + new EMDecay(0.108, lepton_t, lepton_Vt_), + new EMDecay(0.112666, quark_u_, quark_d), + new EMDecay(0.112666, quark_u_, quark_s), + new EMDecay(0.112666, quark_u_, quark_b), + new EMDecay(0.112666, quark_c_, quark_d), + new EMDecay(0.112666, quark_c_, quark_s), + new EMDecay(0.112666, quark_c_, quark_b), + deadEnd); + boson_W_.init(registry, boson_W, 3e-25, 9, 9, + new EMDecay(0.108, lepton_e_, lepton_Ve), + new EMDecay(0.108, lepton_m_, lepton_Vm), + new EMDecay(0.108, lepton_t_, lepton_Vt), + new EMDecay(0.112666, quark_u, quark_d_), + new EMDecay(0.112666, quark_u, quark_s_), + new EMDecay(0.112666, quark_u, quark_b_), + new EMDecay(0.112666, quark_c, quark_d_), + new EMDecay(0.112666, quark_c, quark_s_), + new EMDecay(0.112666, quark_c, quark_b_), + deadEnd); + } + + @Override + public String getLocalizedTypeName() { + return translateToLocal("tt.keyword.GaugeBoson"); + } + + @Override + public boolean isTimeSpanHalfLife() { + return false; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMLeptonDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMLeptonDefinition.java new file mode 100644 index 0000000000..0926b34425 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMLeptonDefinition.java @@ -0,0 +1,74 @@ +package com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive; + +import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMType; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; +import com.github.technus.tectech.util.TT_Utility; + +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.boson_Y__; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.deadEnd; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMNeutrinoDefinition.*; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMScalarBosonDefinition.boson_H__; +import static net.minecraft.util.StatCollector.translateToLocal; + +/** + * Created by danie_000 on 22.10.2016. + */ +public class EMLeptonDefinition extends EMFermionDefinition { + public static final EMLeptonDefinition + lepton_e = new EMLeptonDefinition("tt.keyword.Electron", "\u03b2-", 1, 0.511e6D, -3, 15,"e-"), + lepton_m = new EMLeptonDefinition("tt.keyword.Muon", "\u03bc-", 2, 105.658e6D, -3, 17,"m-"), + lepton_t = new EMLeptonDefinition("tt.keyword.Tauon", "\u03c4-", 3, 1776.83e6D, -3, 19,"t-"), + lepton_e_ = new EMLeptonDefinition("tt.keyword.Positron", "\u03b2+", -1, 0.511e6D, 3, 16,"e+"), + lepton_m_ = new EMLeptonDefinition("tt.keyword.Antimuon", "\u03bc+", -2, 105.658e6D, 3, 18,"m+"), + lepton_t_ = new EMLeptonDefinition("tt.keyword.Antitauon", "\u03c4+", -3, 1776.83e6D, 3, 20,"t+"); + + public static final EMDefinitionStack lepton_e1 = new EMDefinitionStack(lepton_e, 1); + public static final EMDefinitionStack lepton_e2 = new EMDefinitionStack(lepton_e, 2); + public static final EMDefinitionStack lepton_e_1 = new EMDefinitionStack(lepton_e_, 1); + public static final EMDefinitionStack lepton_e_2 = new EMDefinitionStack(lepton_e_, 2); + + protected EMLeptonDefinition(String name, String symbol, int type, double mass, int charge, int ID,String bind) { + super(name, TT_Utility.toSuperscript(symbol), type, mass, charge, -1, ID,bind); + //this.itemThing=null; + //this.fluidThing=null; + } + + public static void run(EMDefinitionsRegistry registry) { + registry.registerDefinitionClass(new EMType(EMLeptonDefinition.class,"tt.keyword.Lepton")); + lepton_e.init(registry,lepton_e_, STABLE_RAW_LIFE_TIME, 0, 1, + deadEnd, + new EMDecay(lepton_e,boson_Y__)); + lepton_m.init(registry,lepton_m_, 2.197019e-6D, 0, 1, + new EMDecay(0.9D, lepton_e, lepton_Ve_, lepton_Vm), + deadEnd);//makes photons and don't care + lepton_t.init(registry,lepton_t_, 2.903e-13D, 1, 3, + new EMDecay(0.05F, lepton_m, lepton_Vm_, lepton_Vt, boson_H__), + new EMDecay(0.1D, lepton_e, lepton_Ve_, lepton_Vm), + new EMDecay(0.8D, lepton_m, lepton_Vm_, lepton_Vt, boson_Y__), + deadEnd);//makes photons and don't care + + lepton_e_.init(registry,lepton_e, STABLE_RAW_LIFE_TIME, 0, 1, + deadEnd, + new EMDecay(lepton_e,boson_Y__)); + lepton_m_.init(registry,lepton_m, 2.197019e-6F, 0, 1, + new EMDecay(0.9F, lepton_e_, lepton_Ve, lepton_Vm_), + deadEnd);//makes photons and don't care + lepton_t_.init(registry,lepton_t, 2.903e-13F, 1, 3, + new EMDecay(0.05F, lepton_m_, lepton_Vm, lepton_Vt_, boson_H__), + new EMDecay(0.1F, lepton_e_, lepton_Ve, lepton_Vm_), + new EMDecay(0.8F, lepton_m_, lepton_Vm, lepton_Vt_, boson_Y__), + deadEnd);//makes photons and don't care + } + + @Override + public String getLocalizedName() { + return translateToLocal("tt.keyword.Lepton")+": " + getShortLocalizedName(); + } + + @Override + public boolean isTimeSpanHalfLife() { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMNeutrinoDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMNeutrinoDefinition.java new file mode 100644 index 0000000000..fee5774e15 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMNeutrinoDefinition.java @@ -0,0 +1,63 @@ +package com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive; + +import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMType; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; + +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.deadEnd; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.deadEndHalf; +import static net.minecraft.util.StatCollector.translateToLocal; + +/** + * Created by danie_000 on 22.10.2016. + */ +public class EMNeutrinoDefinition extends EMLeptonDefinition { + public static final EMNeutrinoDefinition + lepton_Ve = new EMNeutrinoDefinition("tt.keyword.ElectronNeutrino", "\u03bd\u03b2", 1, 2e0D, 21,"Ve"), + lepton_Vm = new EMNeutrinoDefinition("tt.keyword.MuonNeutrino", "\u03bd\u03bc", 2, 0.15e6D, 23,"Vm"), + lepton_Vt = new EMNeutrinoDefinition("tt.keyword.TauonNeutrino", "\u03bd\u03c4", 3, 15e6D, 25,"Vt"), + lepton_Ve_ = new EMNeutrinoDefinition("tt.keyword.PositronNeutrino", "~\u03bd\u03b2", -1, 2e0D, 22,"~Ve"), + lepton_Vm_ = new EMNeutrinoDefinition("tt.keyword.AntimuonNeutrino", "~\u03bd\u03bc", -2, 0.15e6D, 24,"~Vm"), + lepton_Vt_ = new EMNeutrinoDefinition("tt.keyword.AntitauonNeutrino", "~\u03bd\u03c4", -3, 15e6D, 26,"~Vt"); + + public static final EMDefinitionStack lepton_Ve1 = new EMDefinitionStack(lepton_Ve, 1); + public static final EMDefinitionStack lepton_Ve2 = new EMDefinitionStack(lepton_Ve, 2); + public static final EMDefinitionStack lepton_Ve_1 = new EMDefinitionStack(lepton_Ve_, 1); + public static final EMDefinitionStack lepton_Ve_2 = new EMDefinitionStack(lepton_Ve_, 2); + + protected EMNeutrinoDefinition(String name, String symbol, int type, double mass, int ID,String bind) { + super(name, symbol, type, mass, 0, ID,bind); + } + + public static void run(EMDefinitionsRegistry registry) { + registry.registerDefinitionClass(new EMType(EMNeutrinoDefinition.class,"tt.keyword.Neutrino")); + lepton_Ve.init(registry,lepton_Ve_, 1D, -1, -1, + EMDecay.NO_PRODUCT); + lepton_Vm.init(registry,lepton_Vm_, 1D, 1, 0, + new EMDecay(0.825D, nothing), + deadEndHalf); + lepton_Vt.init(registry,lepton_Vt_, 1, 1, 0, + new EMDecay(0.75F, nothing), + deadEnd); + + lepton_Ve_.init(registry,lepton_Ve, 1, -1, -1, + EMDecay.NO_PRODUCT); + lepton_Vm_.init(registry,lepton_Vm, 1, 1, 0, + new EMDecay(0.825F, nothing), + deadEndHalf); + lepton_Vt_.init(registry,lepton_Vt, 1, 1, 0, + new EMDecay(0.75F, nothing), + deadEnd); + } + + @Override + public String getLocalizedTypeName() { + return translateToLocal("tt.keyword.Neutrino"); + } + + @Override + public boolean isTimeSpanHalfLife() { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMPrimitiveDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMPrimitiveDefinition.java new file mode 100644 index 0000000000..c2b77f7704 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMPrimitiveDefinition.java @@ -0,0 +1,58 @@ +package com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive; + +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMType; + +import static com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay.NO_DECAY; +import static net.minecraft.util.StatCollector.translateToLocal; + +/** + * Created by danie_000 on 22.10.2016. + */ +public class EMPrimitiveDefinition extends EMPrimitiveTemplate { + public static final EMPrimitiveDefinition + nbtE__ = new EMPrimitiveDefinition ( "tt.keyword.PrimitiveNBTERROR" , "!" , 0 , 0D , -1 , Integer.MIN_VALUE , "!" ), + null__ = new EMPrimitiveDefinition ( "tt.keyword.PrimitiveNULLPOINTER" , "." , 0 , 0D , -3 , Integer.MIN_VALUE+1 , "." ), + space = new EMPrimitiveDefinition ( "tt.keyword.PrimitiveSpace" , "_" , 0 , 0D , -4 , Integer.MIN_VALUE + 2 , "_" ), + space_ = new EMPrimitiveDefinition ( "tt.keyword.PrimitivePresence" , "~_" , 0 , 0D , -4 , Integer.MIN_VALUE + 3 , "~_" ), + mass = new EMPrimitiveDefinition ( "tt.keyword.PrimitiveMass" , "*" , 0 , 1 , -4 , Integer.MIN_VALUE + 4 , "*" ), + mass_ = new EMPrimitiveDefinition ( "tt.keyword.PrimitiveDarkMass" , "~*" , 0 , 1 , -4 , Integer.MIN_VALUE + 5 , "~*" ), + energy = new EMPrimitiveDefinition ( "tt.keyword.PrimitiveEnergy" , "E" , 4 , 0D , -4 , Integer.MIN_VALUE + 6 , "E" ), + energy_ = new EMPrimitiveDefinition ( "tt.keyword.PrimitiveDarkEnergy" , "~E" , -4 , 0 , -4 , Integer.MIN_VALUE + 7 , "~E" ), + magic = new EMPrimitiveDefinition ( "tt.keyword.PrimitiveMagic" , "Ma" , 5 , 1e5D , 0 , Integer.MIN_VALUE + 8 , "Ma" ), + magic_ = new EMPrimitiveDefinition ( "tt.keyword.PrimitiveAntimagic" , "~Ma" , -5 , 1e5D , 0 , Integer.MIN_VALUE + 9 , "~Ma" ); + + + protected EMPrimitiveDefinition(String name, String symbol, int type, double mass, int color, int ID, String bind) { + super(name, symbol, type, mass, 0, color, ID, bind); + } + + public static void run(EMDefinitionsRegistry registry) { + registry.registerDefinitionClass(new EMType(EMPrimitiveDefinition.class, "tt.keyword.Primitive")); + nbtE__.init(registry, null, NO_DECAY_RAW_LIFE_TIME, -1, -1, NO_DECAY); + null__.init(registry, null, NO_DECAY_RAW_LIFE_TIME, -1, -1, NO_DECAY); + + space.init(registry, space_, NO_DECAY_RAW_LIFE_TIME, -1, -1, NO_DECAY); + space_.init(registry, space, NO_DECAY_RAW_LIFE_TIME, -1, -1, NO_DECAY); + + mass.init(registry, mass_, NO_DECAY_RAW_LIFE_TIME, -1, -1, NO_DECAY); + mass_.init(registry, mass, NO_DECAY_RAW_LIFE_TIME, -1, -1, NO_DECAY); + + energy.init(registry, energy_, NO_DECAY_RAW_LIFE_TIME, -1, -1, NO_DECAY); + energy_.init(registry, energy, NO_DECAY_RAW_LIFE_TIME, -1, -1, NO_DECAY); + + magic.init(registry, magic_, NO_DECAY_RAW_LIFE_TIME, -1, -1, NO_DECAY); + magic_.init(registry, magic, NO_DECAY_RAW_LIFE_TIME, -1, -1, NO_DECAY); + } + + @Override + public String getLocalizedTypeName() { + return translateToLocal("tt.keyword.Primitive"); + } + + @Override + public boolean isTimeSpanHalfLife() { + return false; + } +}
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMQuarkDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMQuarkDefinition.java new file mode 100644 index 0000000000..a93b16ca0d --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMQuarkDefinition.java @@ -0,0 +1,110 @@ +package com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive; + +import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMType; + +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.deadEnd; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMLeptonDefinition.*; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMNeutrinoDefinition.*; +import static net.minecraft.util.StatCollector.translateToLocal; + +/** + * Created by danie_000 on 22.10.2016. + */ +public class EMQuarkDefinition extends EMFermionDefinition { + public static final EMQuarkDefinition + quark_u = new EMQuarkDefinition("tt.keyword.QuarkUp", "u", 1, 2.3e6D, 2, 3,"u"), + quark_c = new EMQuarkDefinition("tt.keyword.QuarkCharm", "c", 2, 1.29e9D, 2, 9,"c"), + quark_t = new EMQuarkDefinition("tt.keyword.QuarkTop", "t", 3, 172.44e9D, 2, 13,"t"), + quark_d = new EMQuarkDefinition("tt.keyword.QuarkDown", "d", 1, 4.8e6D, -1, 5,"d"), + quark_s = new EMQuarkDefinition("tt.keyword.QuarkStrange", "s", 2, 95e6D, -1, 7,"s"), + quark_b = new EMQuarkDefinition("tt.keyword.QuarkBottom", "b", 3, 4.65e9D, -1, 11,"b"), + quark_u_ = new EMQuarkDefinition("tt.keyword.QuarkAntiUp", "~u", -1, 2.3e6D, -2, 4,"~u"), + quark_c_ = new EMQuarkDefinition("tt.keyword.QuarkAntiCharm", "~c", -2, 1.29e9D, -2, 10,"~c"), + quark_t_ = new EMQuarkDefinition("tt.keyword.QuarkAntiTop", "~t", -3, 172.44e9D, -2, 14,"~t"), + quark_d_ = new EMQuarkDefinition("tt.keyword.QuarkAntiDown", "~d", -1, 4.8e6D, 1, 6,"~d"), + quark_s_ = new EMQuarkDefinition("tt.keyword.QuarkAntiStrange", "~s", -2, 95e6D, 1, 8,"~s"), + quark_b_ = new EMQuarkDefinition("tt.keyword.QuarkAntiBottom", "~b", -3, 4.65e9D, 1, 12,"~b"); + + protected EMQuarkDefinition(String name, String symbol, int type, double mass, int charge, int ID,String bind) { + super(name, symbol, type, mass, charge, 0, ID,bind); + } + + public static void run(EMDefinitionsRegistry registry) { + registry.registerDefinitionClass(new EMType(EMQuarkDefinition.class,"tt.keyword.Quark")); + quark_u.init(registry,quark_u_, STABLE_RAW_LIFE_TIME, 3, -1, + new EMDecay(1.23201e-5D, quark_b/*,lepton_t_,lepton_Vt*/), + new EMDecay(0.050778116D, quark_s/*,lepton_m_,lepton_Vm*/), + new EMDecay(0.9D, quark_d, lepton_e_, lepton_Ve), + deadEnd);//makes photons and don't care + quark_c.init(registry,quark_c_, 0.5e-13D, 1, -1, + new EMDecay(0.00169744D, quark_b/*,lepton_t_,lepton_Vt*/), + new EMDecay(0.05071504D, quark_d, lepton_m_, lepton_Vm), + new EMDecay(0.9D, quark_s, lepton_e_, lepton_Ve), + deadEnd);//makes photons and don't care + quark_t.init(registry,quark_t_, 2.5e-26D, 0, -1, + new EMDecay(7.51689e-5D, quark_d, lepton_t_, lepton_Vt), + new EMDecay(0.00163216D, quark_s, lepton_m_, lepton_Vm), + new EMDecay(0.9D, quark_b, lepton_e_, lepton_Ve), + deadEnd);//makes photons and don't care + + quark_d.init(registry,quark_d_, STABLE_RAW_LIFE_TIME, 3, -1, + new EMDecay(7.51689e-5D, quark_t/*,lepton_t,lepton_Vt_*/), + new EMDecay(0.05071504D, quark_c/*,lepton_m,lepton_Vm_*/), + new EMDecay(0.9D, quark_u, lepton_e, lepton_Ve_), + deadEnd);//makes photons and don't care + quark_s.init(registry,quark_s_, 0.6e-9D, 1, -1, + new EMDecay(0.00163216D, quark_t/*,lepton_t,lepton_Vt_*/), + new EMDecay(0.050778116D, quark_u, lepton_m, lepton_Vm_), + new EMDecay(0.9D, quark_c, lepton_e, lepton_Ve_), + deadEnd);//makes photons and don't care + quark_b.init(registry,quark_b_, 0.7e-13D, 0, -1, + new EMDecay(1.23201e-5D, quark_u, lepton_t, lepton_Vt_), + new EMDecay(0.00169744D, quark_c, lepton_m, lepton_Vm_), + new EMDecay(0.9D, quark_t, lepton_e, lepton_Ve_), + deadEnd);//makes photons and don't care + + quark_u_.init(registry,quark_u, STABLE_RAW_LIFE_TIME, 3, -1, + new EMDecay(1.23201e-5D, quark_b_/*,lepton_t,lepton_Vt_*/), + new EMDecay(0.050778116D, quark_s_/*,lepton_m,lepton_Vm_*/), + new EMDecay(0.9D, quark_d_, lepton_e, lepton_Ve_), + deadEnd);//makes photons and don't care + quark_c_.init(registry,quark_c, 0.5e-13D, 1, -1, + new EMDecay(0.00169744F, quark_b_/*,lepton_t,lepton_Vt_*/), + new EMDecay(0.05071504F, quark_d_, lepton_m, lepton_Vm_), + new EMDecay(0.9F, quark_s_, lepton_e, lepton_Ve_), + deadEnd);//makes photons and don't care + quark_t_.init(registry,quark_t, 2.5e-26F, 0, -1, + new EMDecay(7.51689e-5F, quark_d_, lepton_t, lepton_Vt_), + new EMDecay(0.00163216F, quark_s_, lepton_m, lepton_Vm_), + new EMDecay(0.9F, quark_b_, lepton_e, lepton_Ve_), + deadEnd);//makes photons and don't care + + quark_d_.init(registry,quark_d, STABLE_RAW_LIFE_TIME, 3, -1, + new EMDecay(7.51689e-5F, quark_t_/*,lepton_t_,lepton_Vt*/), + new EMDecay(0.05071504F, quark_c_/*,lepton_m_,lepton_Vm*/), + new EMDecay(0.9F, quark_u_, lepton_e_, lepton_Ve), + deadEnd);//makes photons and don't care + quark_s_.init(registry,quark_s, 0.6e-9F, 1, -1, + new EMDecay(0.00163216F, quark_t_/*,lepton_t_,lepton_Vt*/), + new EMDecay(0.050778116F, quark_u_, lepton_m_, lepton_Vm), + new EMDecay(0.9F, quark_c_, lepton_e_, lepton_Ve), + deadEnd);//makes photons and don't care + quark_b_.init(registry,quark_b, 0.7e-13F, 0, -1, + new EMDecay(1.23201e-5F, quark_u_, lepton_t_, lepton_Vt), + new EMDecay(0.00169744F, quark_c_, lepton_m_, lepton_Vm), + new EMDecay(0.9F, quark_t_, lepton_e_, lepton_Ve), + deadEnd);//makes photons and don't care + } + + @Override + public String getLocalizedTypeName() { + return translateToLocal("tt.keyword.Quark"); + } + + @Override + public boolean isTimeSpanHalfLife() { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMScalarBosonDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMScalarBosonDefinition.java new file mode 100644 index 0000000000..c90e89108b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMScalarBosonDefinition.java @@ -0,0 +1,47 @@ +package com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive; + +import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMType; +import com.github.technus.tectech.util.TT_Utility; + +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.*; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMLeptonDefinition.*; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMQuarkDefinition.*; +import static net.minecraft.util.StatCollector.translateToLocal; + +/** + * Created by danie_000 on 22.10.2016. + */ +public class EMScalarBosonDefinition extends EMBosonDefinition { + public static final EMScalarBosonDefinition + boson_H__ = new EMScalarBosonDefinition("tt.keyword.Higgs", "H0", 125.09e9D, -2, 32,"H0"); + + private EMScalarBosonDefinition(String name, String symbol, double mass, int color, int ID,String bind) { + super(name,TT_Utility.toSuperscript(symbol), 0, mass, 0, color, ID,bind); + } + + public static void run(EMDefinitionsRegistry registry) { + registry.registerDefinitionClass(new EMType(EMScalarBosonDefinition.class,"tt.keyword.ScalarBoson")); + boson_H__.init(registry,boson_H__, 1.56e-22D, 8, 8, + new EMDecay ( 0.0002171 , lepton_m , lepton_m_ ), + new EMDecay ( 0.001541 , boson_Z, boson_Y__ ), + new EMDecay ( 0.02641 , boson_Z, boson_Z), + new EMDecay ( 0.02884 , quark_c , quark_c_ ), + new EMDecay ( 0.06256 , lepton_t , lepton_t_ ), + new EMDecay ( 0.0818 , boson_g__ , boson_g__ ), + new EMDecay ( 0.2152 , boson_W_, boson_W), + new EMDecay ( 0.5809 , quark_b , quark_b_ ), + deadEnd); + } + + @Override + public String getLocalizedTypeName() { + return translateToLocal("tt.keyword.ScalarBoson"); + } + + @Override + public boolean isTimeSpanHalfLife() { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/cPrimitiveDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/cPrimitiveDefinition.java deleted file mode 100644 index a3efe12b7e..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/cPrimitiveDefinition.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive; - -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalPrimitive; - -import static com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay.noDecay; - -/** - * Created by danie_000 on 22.10.2016. - */ -public final class cPrimitiveDefinition extends cElementalPrimitive { - public static final cPrimitiveDefinition - nbtE__ = new cPrimitiveDefinition("NBT ERROR", "!", 0, 0D, Integer.MIN_VALUE, Integer.MIN_VALUE+10_000), - null__ = new cPrimitiveDefinition("NULL POINTER", ".", 0, 0D, -3, Integer.MAX_VALUE-10_000), - space__ = new cPrimitiveDefinition("Space", "_", 0, 0D, -4, 0), - magic = new cPrimitiveDefinition("Magic", "Ma", 4, 1e5D, 0, 1), - magic_ = new cPrimitiveDefinition("Antimagic", "~Ma", -4, 1e5D, 0, 2); - - private cPrimitiveDefinition(String name, String symbol, int type, double mass, int color, int ID) { - super(name, symbol, type, mass, 0, color, ID); - } - - public static void run() { - nbtE__.init(null__, NO_DECAY_RAW_LIFE_TIME, -1, -1, noDecay); - null__.init(null__, NO_DECAY_RAW_LIFE_TIME, -1, -1, noDecay); - space__.init(space__, NO_DECAY_RAW_LIFE_TIME, -1, -1, noDecay); - magic.init(magic_, NO_DECAY_RAW_LIFE_TIME, -1, -1, noDecay); - magic_.init(magic, NO_DECAY_RAW_LIFE_TIME, -1, -1, noDecay); - } - - @Override - public String getName() { - return "Primitive: " + name; - } - - @Override - public boolean isTimeSpanHalfLife() { - return false; - } -}
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eBosonDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eBosonDefinition.java deleted file mode 100644 index 9a82cdd6c0..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eBosonDefinition.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive; - -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalPrimitive; - -import static com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay.*; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eLeptonDefinition.*; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eQuarkDefinition.*; - -/** - * Created by danie_000 on 22.10.2016. - */ -public final class eBosonDefinition extends cElementalPrimitive { - public static final eBosonDefinition - boson_Y__ = new eBosonDefinition("Photon", "\u03b3", 1e-18D, -1, 27), - boson_H__ = new eBosonDefinition("Higgs", "\u0397", 126.09e9D, -2, 28); - //deadEnd - public static final cElementalDecay deadEnd = new cElementalDecay(boson_Y__, boson_Y__); - public static final cElementalDecay deadEndHalf = new cElementalDecay(boson_Y__); - public static final cElementalDefinitionStack boson_Y__1=new cElementalDefinitionStack(boson_Y__,1); - - private eBosonDefinition(String name, String symbol, double mass, int color, int ID) { - super(name, symbol, 0, mass, 0, color, ID); - } - - public static void run() { - boson_Y__.init(null, NO_DECAY_RAW_LIFE_TIME, -1, -1, noDecay); - boson_H__.init(null, 1.56e-22D, 2, 2, - new cElementalDecay(0.01D, quark_b, quark_b_), - new cElementalDecay(0.02D, lepton_t, lepton_t_), - new cElementalDecay(0.96D, new cElementalDefinitionStack(boson_Y__, 4)), - deadEnd); - } - - @Override - public String getName() { - return "Boson: " + name; - } - - @Override - public boolean isTimeSpanHalfLife() { - return this==boson_H__; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eLeptonDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eLeptonDefinition.java deleted file mode 100644 index 1e3b7189a8..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eLeptonDefinition.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive; - -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalPrimitive; - -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition.*; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition.boson_Y__; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eNeutrinoDefinition.*; - -/** - * Created by danie_000 on 22.10.2016. - */ -public final class eLeptonDefinition extends cElementalPrimitive { - public static final eLeptonDefinition - lepton_e = new eLeptonDefinition("Electron", "\u03b2-", 1, 0.511e6D, -3, 15), - lepton_m = new eLeptonDefinition("Muon", "\u03bc-", 2, 105.658e6D, -3, 17), - lepton_t = new eLeptonDefinition("Tauon", "\u03c4-", 3, 1776.83e6D, -3, 19), - lepton_e_ = new eLeptonDefinition("Positron", "\u03b2+", -1, 0.511e6D, 3, 16), - lepton_m_ = new eLeptonDefinition("Antimuon", "\u03bc+", -2, 105.658e6D, 3, 18), - lepton_t_ = new eLeptonDefinition("Antitauon", "\u03c4+", -3, 1776.83e6D, 3, 20); - - public static final cElementalDefinitionStack lepton_e1 = new cElementalDefinitionStack(lepton_e, 1); - public static final cElementalDefinitionStack lepton_e2 = new cElementalDefinitionStack(lepton_e, 2); - public static final cElementalDefinitionStack lepton_e_1 = new cElementalDefinitionStack(lepton_e_, 1); - public static final cElementalDefinitionStack lepton_e_2 = new cElementalDefinitionStack(lepton_e_, 2); - - private eLeptonDefinition(String name, String symbol, int type, double mass, int charge, int ID) { - super(name, symbol, type, mass, charge, -1, ID); - //this.itemThing=null; - //this.fluidThing=null; - } - - public static void run() { - lepton_e.init(lepton_e_, STABLE_RAW_LIFE_TIME, 0, 1, - deadEnd, - new cElementalDecay(lepton_e,boson_Y__)); - lepton_m.init(lepton_m_, 2.197019e-6D, 0, 1, - new cElementalDecay(0.9D, lepton_e, lepton_Ve_, lepton_Vm), - deadEnd);//makes photons and don't care - lepton_t.init(lepton_t_, 2.906e-13D, 1, 3, - new cElementalDecay(0.05F, lepton_m, lepton_Vm_, lepton_Vt, boson_H__), - new cElementalDecay(0.1D, lepton_e, lepton_Ve_, lepton_Vm), - new cElementalDecay(0.8D, lepton_m, lepton_Vm_, lepton_Vt, boson_Y__), - deadEnd);//makes photons and don't care - - lepton_e_.init(lepton_e, STABLE_RAW_LIFE_TIME, 0, 1, - deadEnd, - new cElementalDecay(lepton_e,boson_Y__)); - lepton_m_.init(lepton_m, 2.197019e-6F, 0, 1, - new cElementalDecay(0.9F, lepton_e_, lepton_Ve, lepton_Vm_), - deadEnd);//makes photons and don't care - lepton_t_.init(lepton_t, 2.906e-13F, 1, 3, - new cElementalDecay(0.05F, lepton_m_, lepton_Vm, lepton_Vt_, boson_H__), - new cElementalDecay(0.1F, lepton_e_, lepton_Ve, lepton_Vm_), - new cElementalDecay(0.8F, lepton_m_, lepton_Vm, lepton_Vt_, boson_Y__), - deadEnd);//makes photons and don't care - } - - @Override - public String getName() { - return "Lepton: " + name; - } - - @Override - public boolean isTimeSpanHalfLife() { - return true; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eNeutrinoDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eNeutrinoDefinition.java deleted file mode 100644 index c55e7f6364..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eNeutrinoDefinition.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive; - -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalPrimitive; - -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eBosonDefinition.*; - -/** - * Created by danie_000 on 22.10.2016. - */ -public final class eNeutrinoDefinition extends cElementalPrimitive { - public static final eNeutrinoDefinition - lepton_Ve = new eNeutrinoDefinition("Electron neutrino", "\u03bd\u03b2", 1, 2e0D, 21), - lepton_Vm = new eNeutrinoDefinition("Muon neutrino", "\u03bd\u03bc", 2, 0.15e6D, 23), - lepton_Vt = new eNeutrinoDefinition("Tauon neutrino", "\u03bd\u03c4", 3, 15e6D, 25), - lepton_Ve_ = new eNeutrinoDefinition("Positron neutrino", "~\u03bd\u03b2", -1, 2e0D, 22), - lepton_Vm_ = new eNeutrinoDefinition("Antimuon neutrino", "~\u03bd\u03bc", -2, 0.15e6D, 24), - lepton_Vt_ = new eNeutrinoDefinition("Antitauon neutrino", "~\u03bd\u03c4", -3, 15e6D, 26); - - public static final cElementalDefinitionStack lepton_Ve1 = new cElementalDefinitionStack(lepton_Ve, 1); - public static final cElementalDefinitionStack lepton_Ve2 = new cElementalDefinitionStack(lepton_Ve, 2); - public static final cElementalDefinitionStack lepton_Ve_1 = new cElementalDefinitionStack(lepton_Ve_, 1); - public static final cElementalDefinitionStack lepton_Ve_2 = new cElementalDefinitionStack(lepton_Ve_, 2); - - private eNeutrinoDefinition(String name, String symbol, int type, double mass, int ID) { - super(name, symbol, type, mass, 0, -1, ID); - } - - public static void run() { - lepton_Ve.init(lepton_Ve_, 1D, -1, -1, - cElementalDecay.noProduct); - lepton_Vm.init(lepton_Vm_, 1D, 1, 0, - new cElementalDecay(0.825D, nothing), - deadEndHalf); - lepton_Vt.init(lepton_Vt_, 1, 1, 0, - new cElementalDecay(0.75F, nothing), - deadEnd); - - lepton_Ve_.init(lepton_Ve, 1, -1, -1, - cElementalDecay.noProduct); - lepton_Vm_.init(lepton_Vm, 1, 1, 0, - new cElementalDecay(0.825F, nothing), - deadEndHalf); - lepton_Vt_.init(lepton_Vt, 1, 1, 0, - new cElementalDecay(0.75F, nothing), - deadEnd); - } - - @Override - public String getName() { - return "Lepton: " + name; - } - - @Override - public boolean isTimeSpanHalfLife() { - return true; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eQuarkDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eQuarkDefinition.java deleted file mode 100644 index 9e5b2e66bb..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/eQuarkDefinition.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive; - -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalPrimitive; - -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eLeptonDefinition.*; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eNeutrinoDefinition.*; - -/** - * Created by danie_000 on 22.10.2016. - */ -public final class eQuarkDefinition extends cElementalPrimitive { - public static final eQuarkDefinition - quark_u = new eQuarkDefinition("Up", "u", 1, 2.3e6D, 2, 3), - quark_c = new eQuarkDefinition("Charm", "c", 2, 1.29e9D, 2, 9), - quark_t = new eQuarkDefinition("Top", "t", 3, 172.44e9D, 2, 13), - quark_d = new eQuarkDefinition("Down", "d", 1, 4.8e6D, -1, 5), - quark_s = new eQuarkDefinition("Strange", "s", 2, 95e6D, -1, 7), - quark_b = new eQuarkDefinition("Bottom", "b", 3, 4.65e9D, -1, 11), - quark_u_ = new eQuarkDefinition("AntiUp", "~u", -1, 2.3e6D, -2, 4), - quark_c_ = new eQuarkDefinition("AntiCharm", "~c", -2, 1.29e9D, -2, 10), - quark_t_ = new eQuarkDefinition("AntiTop", "~t", -3, 172.44e9D, -2, 14), - quark_d_ = new eQuarkDefinition("AntiDown", "~d", -1, 4.8e6D, 1, 6), - quark_s_ = new eQuarkDefinition("AntiStrange", "~s", -2, 95e6D, 1, 8), - quark_b_ = new eQuarkDefinition("AntiBottom", "~b", -3, 4.65e9D, 1, 12); - - private eQuarkDefinition(String name, String symbol, int type, double mass, int charge, int ID) { - super(name, symbol, type, mass, charge, 0, ID); - } - - public static void run() { - quark_u.init(quark_u_, STABLE_RAW_LIFE_TIME, 3, -1, - new cElementalDecay(1.23201e-5D, quark_b/*,lepton_t_,lepton_Vt*/), - new cElementalDecay(0.050778116D, quark_s/*,lepton_m_,lepton_Vm*/), - new cElementalDecay(0.9D, quark_d, lepton_e_, lepton_Ve), - eBosonDefinition.deadEnd);//makes photons and don't care - quark_c.init(quark_c_, 0.5e-13D, 1, -1, - new cElementalDecay(0.00169744D, quark_b/*,lepton_t_,lepton_Vt*/), - new cElementalDecay(0.05071504D, quark_d, lepton_m_, lepton_Vm), - new cElementalDecay(0.9D, quark_s, lepton_e_, lepton_Ve), - eBosonDefinition.deadEnd);//makes photons and don't care - quark_t.init(quark_t_, 2.5e-26D, 0, -1, - new cElementalDecay(7.51689e-5D, quark_d, lepton_t_, lepton_Vt), - new cElementalDecay(0.00163216D, quark_s, lepton_m_, lepton_Vm), - new cElementalDecay(0.9D, quark_b, lepton_e_, lepton_Ve), - eBosonDefinition.deadEnd);//makes photons and don't care - - quark_d.init(quark_d_, STABLE_RAW_LIFE_TIME, 3, -1, - new cElementalDecay(7.51689e-5D, quark_t/*,lepton_t,lepton_Vt_*/), - new cElementalDecay(0.05071504D, quark_c/*,lepton_m,lepton_Vm_*/), - new cElementalDecay(0.9D, quark_u, lepton_e, lepton_Ve_), - eBosonDefinition.deadEnd);//makes photons and don't care - quark_s.init(quark_s_, 0.6e-9D, 1, -1, - new cElementalDecay(0.00163216D, quark_t/*,lepton_t,lepton_Vt_*/), - new cElementalDecay(0.050778116D, quark_u, lepton_m, lepton_Vm_), - new cElementalDecay(0.9D, quark_c, lepton_e, lepton_Ve_), - eBosonDefinition.deadEnd);//makes photons and don't care - quark_b.init(quark_b_, 0.7e-13D, 0, -1, - new cElementalDecay(1.23201e-5D, quark_u, lepton_t, lepton_Vt_), - new cElementalDecay(0.00169744D, quark_c, lepton_m, lepton_Vm_), - new cElementalDecay(0.9D, quark_t, lepton_e, lepton_Ve_), - eBosonDefinition.deadEnd);//makes photons and don't care - - quark_u_.init(quark_u, STABLE_RAW_LIFE_TIME, 3, -1, - new cElementalDecay(1.23201e-5D, quark_b_/*,lepton_t,lepton_Vt_*/), - new cElementalDecay(0.050778116D, quark_s_/*,lepton_m,lepton_Vm_*/), - new cElementalDecay(0.9D, quark_d_, lepton_e, lepton_Ve_), - eBosonDefinition.deadEnd);//makes photons and don't care - quark_c_.init(quark_c, 0.5e-13D, 1, -1, - new cElementalDecay(0.00169744F, quark_b_/*,lepton_t,lepton_Vt_*/), - new cElementalDecay(0.05071504F, quark_d_, lepton_m, lepton_Vm_), - new cElementalDecay(0.9F, quark_s_, lepton_e, lepton_Ve_), - eBosonDefinition.deadEnd);//makes photons and don't care - quark_t_.init(quark_t, 2.5e-26F, 0, -1, - new cElementalDecay(7.51689e-5F, quark_d_, lepton_t, lepton_Vt_), - new cElementalDecay(0.00163216F, quark_s_, lepton_m, lepton_Vm_), - new cElementalDecay(0.9F, quark_b_, lepton_e, lepton_Ve_), - eBosonDefinition.deadEnd);//makes photons and don't care - - quark_d_.init(quark_d, STABLE_RAW_LIFE_TIME, 3, -1, - new cElementalDecay(7.51689e-5F, quark_t_/*,lepton_t_,lepton_Vt*/), - new cElementalDecay(0.05071504F, quark_c_/*,lepton_m_,lepton_Vm*/), - new cElementalDecay(0.9F, quark_u_, lepton_e_, lepton_Ve), - eBosonDefinition.deadEnd);//makes photons and don't care - quark_s_.init(quark_s, 0.6e-9F, 1, -1, - new cElementalDecay(0.00163216F, quark_t_/*,lepton_t_,lepton_Vt*/), - new cElementalDecay(0.050778116F, quark_u_, lepton_m_, lepton_Vm), - new cElementalDecay(0.9F, quark_c_, lepton_e_, lepton_Ve), - eBosonDefinition.deadEnd);//makes photons and don't care - quark_b_.init(quark_b, 0.7e-13F, 0, -1, - new cElementalDecay(1.23201e-5F, quark_u_, lepton_t_, lepton_Vt), - new cElementalDecay(0.00169744F, quark_c_, lepton_m_, lepton_Vm), - new cElementalDecay(0.9F, quark_t_, lepton_e_, lepton_Ve), - eBosonDefinition.deadEnd);//makes photons and don't care - } - - @Override - public String getName() { - return "Quark: " + name; - } - - @Override - public boolean isTimeSpanHalfLife() { - return true; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/spark/RendererMessage.java b/src/main/java/com/github/technus/tectech/mechanics/spark/RendererMessage.java index 7fdce41ef9..dcc9bfd8fd 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/spark/RendererMessage.java +++ b/src/main/java/com/github/technus/tectech/mechanics/spark/RendererMessage.java @@ -10,7 +10,6 @@ import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; -import net.minecraftforge.common.DimensionManager; import thaumcraft.client.fx.bolt.FXLightningBolt; import java.io.*; diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IBlockPosConsumer.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IBlockPosConsumer.java deleted file mode 100644 index d37e29c36a..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IBlockPosConsumer.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.github.technus.tectech.mechanics.structure; - -import net.minecraft.world.World; - -@Deprecated -public interface IBlockPosConsumer { - void consume(World world, int x, int y, int z); -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/ICustomBlockSetting.java b/src/main/java/com/github/technus/tectech/mechanics/structure/ICustomBlockSetting.java deleted file mode 100644 index 10d9dcca73..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/ICustomBlockSetting.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.github.technus.tectech.mechanics.structure; - -import net.minecraft.block.Block; -import net.minecraft.world.World; - -@Deprecated -public interface ICustomBlockSetting { - /** - * Default block setting calls {@link World#setBlock(int x, int y, int z, Block block, int meta, int updateType)} like: - * {@code world.setBlock(x,y,z,this/block,meta,2)} where updateType 2 means to update lighting and stuff - * @param world world that should be affected - * @param x x position to set - * @param y y position to set - * @param z z position to set - * @param meta required meta - */ - void setBlock(World world, int x, int y, int z, int meta); -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureDefinition.java deleted file mode 100644 index cb40214eac..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureDefinition.java +++ /dev/null @@ -1,168 +0,0 @@ -package com.github.technus.tectech.mechanics.structure; - -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -import java.util.Arrays; - -import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; - -@Deprecated -public interface IStructureDefinition<T> { - /** - * Used internally - * @param name same name as for other methods here - * @return the array of elements to process - */ - IStructureElement<T>[] getStructureFor(String name); - - default boolean check(T object,String piece, World world, ExtendedFacing extendedFacing, - int basePositionX, int basePositionY, int basePositionZ, - int basePositionA, int basePositionB, int basePositionC, - boolean forceCheckAllBlocks){ - return iterate(object, null, getStructureFor(piece), world, extendedFacing, basePositionX, basePositionY, basePositionZ, - basePositionA, basePositionB, basePositionC,false,forceCheckAllBlocks); - } - - default boolean hints(T object, ItemStack trigger,String piece, World world, ExtendedFacing extendedFacing, - int basePositionX, int basePositionY, int basePositionZ, - int basePositionA, int basePositionB, int basePositionC) { - return iterate(object, trigger, getStructureFor(piece), world, extendedFacing, basePositionX, basePositionY, basePositionZ, - basePositionA, basePositionB, basePositionC,true,null); - } - - default boolean build(T object, ItemStack trigger,String piece, World world, ExtendedFacing extendedFacing, - int basePositionX, int basePositionY, int basePositionZ, - int basePositionA, int basePositionB, int basePositionC) { - return iterate(object, trigger, getStructureFor(piece), world, extendedFacing, basePositionX, basePositionY, basePositionZ, - basePositionA, basePositionB, basePositionC,false,null); - } - - default boolean buildOrHints(T object, ItemStack trigger,String piece, World world, ExtendedFacing extendedFacing, - int basePositionX, int basePositionY, int basePositionZ, - int basePositionA, int basePositionB, int basePositionC, - boolean hintsOnly){ - return iterate(object, trigger, getStructureFor(piece), world, extendedFacing, basePositionX, basePositionY, basePositionZ, - basePositionA, basePositionB, basePositionC,hintsOnly,null); - } - - static <T> boolean iterate(T object, ItemStack trigger, IStructureElement<T>[] elements, World world, ExtendedFacing extendedFacing, - int basePositionX, int basePositionY, int basePositionZ, - int basePositionA, int basePositionB, int basePositionC, - boolean hintsOnly, Boolean checkBlocksIfNotNullForceCheckAllIfTrue){ - if(world.isRemote ^ hintsOnly){ - return false; - } - - //change base position to base offset - basePositionA=-basePositionA; - basePositionB=-basePositionB; - basePositionC=-basePositionC; - - int[] abc = new int[]{basePositionA,basePositionB,basePositionC}; - int[] xyz = new int[3]; - - if(checkBlocksIfNotNullForceCheckAllIfTrue!=null){ - if(checkBlocksIfNotNullForceCheckAllIfTrue){ - for (IStructureElement<T> element : elements) { - if(element.isNavigating()) { - abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); - abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); - abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); - }else { - extendedFacing.getWorldOffset(abc, xyz); - xyz[0] += basePositionX; - xyz[1] += basePositionY; - xyz[2] += basePositionZ; - - if (world.blockExists(xyz[0], xyz[1], xyz[2])) { - if(!element.check(object, world, xyz[0], xyz[1], xyz[2])){ - if(DEBUG_MODE){ - TecTech.LOGGER.info("Multi ["+basePositionX+", "+basePositionY+", "+basePositionZ+"] failed @ "+ - Arrays.toString(xyz)+" "+Arrays.toString(abc)); - } - return false; - } - } else { - if(DEBUG_MODE){ - TecTech.LOGGER.info("Multi ["+basePositionX+", "+basePositionY+", "+basePositionZ+"] !blockExists @ "+ - Arrays.toString(xyz)+" "+Arrays.toString(abc)); - } - return false; - } - abc[0]+=1; - } - } - } else { - for (IStructureElement<T> element : elements) { - if(element.isNavigating()) { - abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); - abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); - abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); - }else { - extendedFacing.getWorldOffset(abc, xyz); - xyz[0] += basePositionX; - xyz[1] += basePositionY; - xyz[2] += basePositionZ; - - if (world.blockExists(xyz[0], xyz[1], xyz[2])) { - if(!element.check(object, world, xyz[0], xyz[1], xyz[2])){ - if(DEBUG_MODE){ - TecTech.LOGGER.info("Multi ["+basePositionX+", "+basePositionY+", "+basePositionZ+"] failed @ "+ - Arrays.toString(xyz)+" "+Arrays.toString(abc)); - } - return false; - } - } else { - if(DEBUG_MODE){ - TecTech.LOGGER.info("Multi ["+basePositionX+", "+basePositionY+", "+basePositionZ+"] !blockExists @ "+ - Arrays.toString(xyz)+" "+Arrays.toString(abc)); - } - } - abc[0]+=1; - } - } - } - }else { - if(hintsOnly) { - for (IStructureElement<T> element : elements) { - if(element.isNavigating()) { - abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); - abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); - abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); - }else { - extendedFacing.getWorldOffset(abc, xyz); - xyz[0] += basePositionX; - xyz[1] += basePositionY; - xyz[2] += basePositionZ; - - element.spawnHint(object, world, xyz[0], xyz[1], xyz[2], trigger); - - abc[0]+=1; - } - } - } else { - for (IStructureElement<T> element : elements) { - if(element.isNavigating()) { - abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); - abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); - abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); - }else { - extendedFacing.getWorldOffset(abc, xyz); - xyz[0] += basePositionX; - xyz[1] += basePositionY; - xyz[2] += basePositionZ; - - if (world.blockExists(xyz[0], xyz[1], xyz[2])) { - element.placeBlock(object, world, xyz[0], xyz[1], xyz[2], trigger); - } - abc[0]+=1; - } - } - } - } - return true; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElement.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElement.java deleted file mode 100644 index ac5f4f7296..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElement.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.github.technus.tectech.mechanics.structure; - -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -/** - * Use StructureUtility to instantiate - */ -@Deprecated -public interface IStructureElement<T> { - boolean check(T t,World world,int x,int y,int z); - - boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger); - - boolean placeBlock(T t,World world,int x,int y,int z, ItemStack trigger); - - default int getStepA(){ - return 1; - } - - default int getStepB(){ - return 0; - } - - default int getStepC(){ - return 0; - } - - default boolean resetA(){ - return false; - } - - default boolean resetB(){ - return false; - } - - default boolean resetC(){ - return false; - } - - default boolean isNavigating(){ - return false; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementChain.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementChain.java deleted file mode 100644 index 2051e06c4d..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementChain.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.github.technus.tectech.mechanics.structure; - -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -/** - * Use StructureUtility to instantiate - */ -@Deprecated -public interface IStructureElementChain<T> extends IStructureElement<T> { - IStructureElement<T>[] fallbacks(); - - @Override - default boolean check(T t, World world, int x, int y, int z){ - for (IStructureElement<T> fallback : fallbacks()) { - if (fallback.check(t, world, x, y, z)) { - return true; - } - } - return false; - } - - @Override - default boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - for (IStructureElement<T> fallback : fallbacks()) { - if (fallback.spawnHint(t, world, x, y, z, trigger)) { - return true; - } - } - return false; - } - - @Override - default boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - for (IStructureElement<T> fallback : fallbacks()) { - if (fallback.placeBlock(t, world, x, y, z, trigger)) { - return true; - } - } - return false; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementCheckOnly.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementCheckOnly.java deleted file mode 100644 index a866da828d..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementCheckOnly.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.github.technus.tectech.mechanics.structure; - -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -@Deprecated -public interface IStructureElementCheckOnly<T> extends IStructureElement<T> { - @Override - default boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger){ - return false; - } - - @Override - default boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger){ - return false; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementDeferred.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementDeferred.java deleted file mode 100644 index e1714e520c..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementDeferred.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.github.technus.tectech.mechanics.structure; - -/** - * Use StructureUtility to instantiate - */ -@Deprecated -public interface IStructureElementDeferred<T> extends IStructureElement<T> { -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementNoPlacement.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementNoPlacement.java deleted file mode 100644 index 1ba5dc30f5..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementNoPlacement.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.github.technus.tectech.mechanics.structure; - -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -@Deprecated -public interface IStructureElementNoPlacement<T> extends IStructureElement<T> { - @Override - default boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger){ - return false; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureNavigate.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureNavigate.java deleted file mode 100644 index 5e73f25640..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureNavigate.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.github.technus.tectech.mechanics.structure; - -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -/** - * Use StructureUtility to instantiate - */ -@Deprecated -interface IStructureNavigate<T> extends IStructureElement<T> { - @Override - default boolean check(T t, World world, int x, int y, int z){ - return true; - } - - @Override - default boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - return true; - } - - @Override - default boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return true; - } - - default boolean isNavigating(){ - return true; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/Structure.java b/src/main/java/com/github/technus/tectech/mechanics/structure/Structure.java deleted file mode 100644 index b37ae0bbda..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/Structure.java +++ /dev/null @@ -1,263 +0,0 @@ -package com.github.technus.tectech.mechanics.structure; - -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.structure.adders.IHatchAdder; -import com.github.technus.tectech.thing.casing.TT_Container_Casings; -import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.IGT_HatchAdder; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; - -@Deprecated -public class Structure { - private Structure() { - } - - @Deprecated - @SafeVarargs - public static <T> IHatchAdder<T>[] adders(IHatchAdder<T>... iHatchAdder) { - return iHatchAdder; - } - - //Check Machine Structure based on string[][] (effectively char[][][]), ond offset of the controller - //This only checks for REGULAR BLOCKS! - @Deprecated - public static <T extends IMetaTileEntity> boolean checker( - String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR-1 blocks - Block[] blockType,//use numbers 0-9 for casing types - byte[] blockMeta,//use numbers 0-9 for casing types - IGT_HatchAdder<T>[] addingMethods, - short[] casingTextures, - Block[] blockTypeFallback,//use numbers 0-9 for casing types - byte[] blockMetaFallback,//use numbers 0-9 for casing types - int horizontalOffset, int verticalOffset, int depthOffset, - T metaTile, - ExtendedFacing extendedFacing, - boolean forceCheck) { - IGregTechTileEntity aBaseMetaTileEntity = metaTile.getBaseMetaTileEntity(); - World world = aBaseMetaTileEntity.getWorld(); - if (world.isRemote) { - return false; - } - //TE Rotation - if (extendedFacing == null) { - extendedFacing = ExtendedFacing.of(ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing())); - } - - IGregTechTileEntity igt; - - int[] xyz = new int[3]; - int[] abc = new int[3]; - int pointer; - int baseX = aBaseMetaTileEntity.getXCoord(), - baseZ = aBaseMetaTileEntity.getZCoord(), - baseY = aBaseMetaTileEntity.getYCoord(); - //a,b,c - relative to block face! - //x,y,z - relative to block position on map! - //yPos - absolute height of checked block - - //perform your duties - abc[2] = -depthOffset; - for (String[] _structure : structure) {//front to back - abc[1] = -verticalOffset; - for (String __structure : _structure) {//top to bottom - abc[0] = -horizontalOffset; - for (char block : __structure.toCharArray()) {//left to right - if (block < ' ') { - //Control chars allow skipping - abc[1] += block; - break; - } else if (block > '@') { - //characters allow to skip check A-1 skip, B-2 skips etc. - abc[0] += block - '@'; - }//else if (block < '+')//used to mark THINGS - // a++; - else if (block == '.') { - abc[0]++; - } else { - //get x y z from rotation - extendedFacing.getWorldOffset(abc, xyz); - xyz[0] += baseX; - xyz[1] += baseY; - xyz[2] += baseZ; - - //that must be here since in some cases other axis (b,c) controls y - if (xyz[1] < 0 || xyz[1] >= 256) { - return false; - } - - //Check block - if (world.blockExists(xyz[0], xyz[1], xyz[2])) {//this actually checks if the chunk is loaded at this pos - switch (block) { - case '-'://must be air - if (world.getBlock(xyz[0], xyz[1], xyz[2]).getMaterial() != Material.air) { - return false; - } - break; - case '+'://must not be air - if (world.getBlock(xyz[0], xyz[1], xyz[2]).getMaterial() == Material.air) { - return false; - } - break; - default://check for block (countable) - Block worldblock = world.getBlock(xyz[0], xyz[1], xyz[2]); - int dmg = worldblock.getDamageValue(world, xyz[0], xyz[1], xyz[2]); - if ((pointer = block - '0') >= 0) { - //countable air -> net.minecraft.block.BlockAir - if (worldblock != blockType[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Struct-block-error " + xyz[0] + ' ' + xyz[1] + ' ' + xyz[2] + " / " + abc[0] + ' ' + abc[1] + ' ' + abc[2] + " / " + worldblock.getUnlocalizedName() + ' ' + blockType[pointer].getUnlocalizedName()); - } - return false; - } - if (dmg != blockMeta[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Struct-meta-id-error " + xyz[0] + ' ' + xyz[1] + ' ' + xyz[2] + " / " + abc[0] + ' ' + abc[1] + ' ' + abc[2] + " / " + dmg + ' ' + blockMeta[pointer]); - } - return false; - } - } else if ((pointer = block - ' ') >= 0) { - igt = aBaseMetaTileEntity.getIGregTechTileEntity(xyz[0], xyz[1], xyz[2]); - if (igt == null || !addingMethods[pointer].apply(metaTile, igt, casingTextures[pointer])) { - if (worldblock != blockTypeFallback[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Fallback-struct-block-error " + xyz[0] + ' ' + xyz[1] + ' ' + xyz[2] + " / " + abc[0] + ' ' + abc[1] + ' ' + abc[2] + " / " + worldblock.getUnlocalizedName() + ' ' + (blockTypeFallback[pointer] == null ? "null" : blockTypeFallback[pointer].getUnlocalizedName())); - } - return false; - } - if (dmg != blockMetaFallback[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Fallback-Struct-meta-id-error " + xyz[0] + ' ' + xyz[1] + ' ' + xyz[2] + " / " + abc[0] + ' ' + abc[1] + ' ' + abc[2] + " / " + dmg + ' ' + blockMetaFallback[pointer]); - } - return false; - } - } - } - } - } else if (forceCheck) { - return false; - } - abc[0]++;//block in horizontal layer - } - } - abc[1]++;//horizontal layer - } - abc[2]++;//depth - } - return true; - } - - @Deprecated - public static boolean builder(String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR+1 blocks - Block[] blockType,//use numbers 0-9 for casing types - byte[] blockMeta,//use numbers 0-9 for casing types - int horizontalOffset, int verticalOffset, int depthOffset, - IGregTechTileEntity tileEntity, ExtendedFacing extendedFacing, boolean hintsOnly) { - World world = tileEntity.getWorld(); - int baseX = tileEntity.getXCoord(); - int baseY = tileEntity.getYCoord(); - int baseZ = tileEntity.getZCoord(); - if (world == null || (!world.isRemote && hintsOnly)) { - return false; - } - - //TE Rotation - int[] xyz = new int[3]; - int[] abc = new int[3]; - int pointer; - - //a,b,c - relative to block face! - //x,y,z - relative to block position on map! - - //perform your duties - abc[2] = -depthOffset; - for (String[] _structure : structure) {//front to back - abc[1] = -verticalOffset; - for (String __structure : _structure) {//top to bottom - abc[0] = -horizontalOffset; - for (char block : __structure.toCharArray()) {//left to right - if (block < ' ') {//Control chars allow skipping - abc[1] += block; - break; - } - if (block > '@')//characters allow to skip check a-1 skip, b-2 skips etc. - { - abc[0] += block - '@'; - }//else if (block < '+')//used to mark THINGS - // a++; - else if (block == '.')// this TE - { - abc[0]++; - } else { - //get x y z from rotation - extendedFacing.getWorldOffset(abc, xyz); - xyz[0] += baseX; - xyz[1] += baseY; - xyz[2] += baseZ; - - //that must be here since in some cases other axis (b,c) controls y - if (xyz[1] < 0 || xyz[1] >= 256) { - return false; - } - - //Check block - if (world.blockExists(xyz[0], xyz[1], xyz[2])) {//this actually checks if the chunk is loaded - if (hintsOnly) { - switch (block) { - case '-'://must be air - TecTech.proxy.hint_particle(world, xyz[0], xyz[1], xyz[2], TT_Container_Casings.sHintCasingsTT, 13); - break; - case '+'://must not be air - TecTech.proxy.hint_particle(world, xyz[0], xyz[1], xyz[2], TT_Container_Casings.sHintCasingsTT, 14); - break; - default: //check for block - if ((pointer = block - '0') >= 0) { - if (world.getBlock(xyz[0], xyz[1], xyz[2]) != blockType[pointer] || blockType[pointer].getDamageValue(world, xyz[0], xyz[1], xyz[2]) != blockMeta[pointer]) { - TecTech.proxy.hint_particle(world, xyz[0], xyz[1], xyz[2], blockType[pointer], blockMeta[pointer]); - } - } else if ((pointer = block - ' ') >= 0) { - if (pointer < 12) { - TecTech.proxy.hint_particle(world, xyz[0], xyz[1], xyz[2], TT_Container_Casings.sHintCasingsTT, pointer); - } else { - TecTech.proxy.hint_particle(world, xyz[0], xyz[1], xyz[2], TT_Container_Casings.sHintCasingsTT, 12); - } - } else { - TecTech.proxy.hint_particle(world, xyz[0], xyz[1], xyz[2], TT_Container_Casings.sHintCasingsTT, 15); - } - } - } else { - switch (block) { - case '-'://must be air - world.setBlock(xyz[0], xyz[1], xyz[2], Blocks.air, 0, 2); - break; - case '+'://must not be air - world.setBlock(xyz[0], xyz[1], xyz[2], TT_Container_Casings.sBlockCasingsTT, 14, 2); - break; - default: //check for block - if ((pointer = block - '0') >= 0) { - if (blockType[pointer] instanceof ICustomBlockSetting) { - ((ICustomBlockSetting) blockType[pointer]).setBlock(world, xyz[0], xyz[1], xyz[2], blockMeta[pointer]); - } else { - world.setBlock(xyz[0], xyz[1], xyz[2], blockType[pointer], blockMeta[pointer], 2); - } - } - } - } - } - abc[0]++;//block in horizontal layer - } - } - abc[1]++;//horizontal layer - } - abc[2]++;//depth - } - return true; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureDefinition.java deleted file mode 100644 index ca1dbce77b..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureDefinition.java +++ /dev/null @@ -1,289 +0,0 @@ -package com.github.technus.tectech.mechanics.structure; - -import com.github.technus.tectech.util.Vec3Impl; - -import java.util.*; - -import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.mechanics.structure.StructureUtility.*; - -@Deprecated -public class StructureDefinition<T> implements IStructureDefinition<T> { - private final Map<Character, IStructureElement<T>> elements; - private final Map<String, String> shapes; - private final Map<String, IStructureElement<T>[]> structures; - - public static <B> Builder<B> builder() { - return new Builder<>(); - } - - private StructureDefinition( - Map<Character, IStructureElement<T>> elements, - Map<String, String> shapes, - Map<String, IStructureElement<T>[]> structures) { - this.elements =elements; - this.shapes=shapes; - this.structures = structures; - } - - public static class Builder<T> { - private static final char A='\uA000'; - private static final char B='\uB000'; - private static final char C='\uC000'; - private char d ='\uD000'; - private final Map<Vec3Impl,Character> navigates; - private final Map<Character, IStructureElement<T>> elements; - private final Map<String, String> shapes; - - private Builder() { - navigates=new HashMap<>(); - elements = new HashMap<>(); - shapes = new HashMap<>(); - } - - public Map<Character, IStructureElement<T>> getElements() { - return elements; - } - - public Map<String, String> getShapes() { - return shapes; - } - - /** - * Casings go: 0 1 2 3 4 5 6 7 8 9 : ; < = > ? - * <br/> - * HatchAdders go: space ! " # $ % & ' ( ) * - * @param name - * @param structurePiece - * @return - */ - @Deprecated - public Builder<T> addShapeOldApi(String name, String[][] structurePiece) { - StringBuilder builder = new StringBuilder(); - if (structurePiece.length > 0) { - for (String[] strings : structurePiece) { - if (strings.length > 0) { - for (String string : strings) { - for (int i = 0; i < string.length(); i++) { - char ch = string.charAt(i); - if(ch<' '){ - for (int b = 0; b < ch; b++) { - builder.append(B); - } - }else if(ch>'@'){ - for (int a = '@'; a < ch; a++) { - builder.append(A); - } - }else if(ch=='.'){ - builder.append(A); - }else{ - builder.append(ch); - } - } - builder.append(B); - } - builder.setLength(builder.length() - 1); - } - builder.append(C); - } - builder.setLength(builder.length() - 1); - } - int a=0,b=0,c=0; - for (int i = 0; i < builder.length(); i++) { - char ch = builder.charAt(i); - if(ch==A){ - a++; - }else if(ch==B){ - a=0; - b++; - }else if(ch==C){ - a=0; - b=0; - c++; - }else if(a!=0 || b!=0 || c!=0){ - Vec3Impl vec3 = new Vec3Impl(a, b, c); - Character navigate = navigates.get(vec3); - if(navigate==null){ - navigate= d++; - navigates.put(vec3,navigate); - addElement(navigate,step(vec3)); - } - builder.setCharAt(i-1,navigate); - a=0; - b=0; - c=0; - } - } - - String built = builder.toString().replaceAll("[\\uA000\\uB000\\uC000]",""); - - if(built.contains("+")){ - addElement('+',notAir()); - } - if (built.contains("-")) { - addElement('-', isAir()); - } - shapes.put(name, built); - return this; - } - - /** - * Adds shape - * +- is air/no air checks - * space bar is skip - * ~ is also skip (but marks controller position, optional and logically it is a space...) - * rest needs to be defined - * - * next char is next block(a) - * next string is next line(b) - * next string[] is next slice(c) - * - * char A000-FFFF range is reserved for generated skips - * @param name unlocalized/code name - * @param structurePiece generated or written struct - DO NOT STORE IT ANYWHERE, or at least set them to null afterwards - * @return this builder - */ - public Builder<T> addShape(String name, String[][] structurePiece) { - StringBuilder builder = new StringBuilder(); - if (structurePiece.length > 0) { - for (String[] strings : structurePiece) { - if (strings.length > 0) { - for (String string : strings) { - builder.append(string).append(B); - } - builder.setLength(builder.length() - 1); - } - builder.append(C); - } - builder.setLength(builder.length() - 1); - } - int a=0,b=0,c=0; - for (int i = 0; i < builder.length(); i++) { - char ch = builder.charAt(i); - if(ch ==' ' || ch =='~'){ - builder.setCharAt(i,A); - ch=A; - } - if(ch==A){ - a++; - }else if(ch==B){ - a=0; - b++; - }else if(ch==C){ - a=0; - b=0; - c++; - }else if(a!=0 || b!=0 || c!=0){ - Vec3Impl vec3 = new Vec3Impl(a, b, c); - Character navigate = navigates.get(vec3); - if(navigate==null){ - navigate=d++; - navigates.put(vec3,navigate); - addElement(navigate,step(vec3)); - } - builder.setCharAt(i-1,navigate); - a=0; - b=0; - c=0; - } - } - - String built = builder.toString().replaceAll("[\\uA000\\uB000\\uC000]",""); - - if(built.contains("+")){ - addElement('+',notAir()); - } - if (built.contains("-")) { - addElement('-', isAir()); - } - shapes.put(name, built); - return this; - } - - public Builder<T> addElement(Character name, IStructureElement<T> structurePiece) { - elements.putIfAbsent(name, structurePiece); - return this; - } - - public IStructureDefinition<T> build() { - Map<String, IStructureElement<T>[]> structures = compileStructureMap(); - if(DEBUG_MODE){ - return new StructureDefinition<>(new HashMap<>(elements), new HashMap<>(shapes), structures); - }else { - return structures::get; - } - } - - @SuppressWarnings("unchecked") - private Map<String, IStructureElement<T>[]> compileElementSetMap() { - Set<Integer> missing = new HashSet<>(); - shapes.values().stream().map(CharSequence::chars).forEach(intStream -> intStream.forEach(c -> { - IStructureElement<T> iStructureElement = elements.get((char) c); - if (iStructureElement == null) { - missing.add(c); - } - })); - if (missing.isEmpty()) { - Map<String, IStructureElement<T>[]> map = new HashMap<>(); - shapes.forEach((key, value) -> { - Set<Character> chars=new HashSet<>(); - for (char c : value.toCharArray()) { - chars.add(c); - } - IStructureElement<T>[] compiled = new IStructureElement[chars.size()]; - int i=0; - for (Character aChar : chars) { - compiled[i++]=elements.get(aChar); - } - map.put(key, compiled); - }); - return map; - } else { - throw new RuntimeException("Missing Structure Element bindings for (chars as integers): " + - Arrays.toString(missing.toArray())); - } - } - - @SuppressWarnings("unchecked") - private Map<String, IStructureElement<T>[]> compileStructureMap() { - Set<Integer> mising = new HashSet<>(); - shapes.values().stream().map(CharSequence::chars).forEach(intStream -> intStream.forEach(c -> { - IStructureElement<T> iStructureElement = elements.get((char) c); - if (iStructureElement == null) { - mising.add(c); - } - })); - if (mising.isEmpty()) { - Map<String, IStructureElement<T>[]> map = new HashMap<>(); - shapes.forEach((key, value) -> { - IStructureElement<T>[] compiled = new IStructureElement[value.length()]; - for (int i = 0; i < value.length(); i++) { - compiled[i] = elements.get(value.charAt(i)); - } - map.put(key, compiled); - }); - return map; - } else { - throw new RuntimeException("Missing Structure Element bindings for (chars as integers): " + - Arrays.toString(mising.toArray())); - } - } - } - - public Map<Character, IStructureElement<T>> getElements(){ - return elements; - } - - public Map<String, String> getShapes() { - return shapes; - } - - public Map<String, IStructureElement<T>[]> getStructures() { - return structures; - } - - @Override - public IStructureElement<T>[] getStructureFor(String name) { - return structures.get(name); - } -}
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java deleted file mode 100644 index f469925dbc..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java +++ /dev/null @@ -1,1396 +0,0 @@ -package com.github.technus.tectech.mechanics.structure; - -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; -import com.github.technus.tectech.mechanics.structure.adders.IBlockAdder; -import com.github.technus.tectech.mechanics.structure.adders.IHatchAdder; -import com.github.technus.tectech.mechanics.structure.adders.ITileAdder; -import com.github.technus.tectech.util.Vec3Impl; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; - -import java.util.*; -import java.util.function.BiFunction; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.Supplier; - -import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sHintCasingsTT; -import static java.lang.Integer.MIN_VALUE; - -/** - * Fluent API for structure checking! - * - * (Just import static this class to have a nice fluent syntax while defining structure definitions) - */ -@Deprecated -public class StructureUtility { - private static final String NICE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz=|!@#$%&()[]{};:<>/?_,.*^'`"; - @SuppressWarnings("rawtypes") - private static final Map<Vec3Impl, IStructureNavigate> STEP = new HashMap<>(); - @SuppressWarnings("rawtypes") - private static final IStructureElement AIR = new IStructureElement() { - @Override - public boolean check(Object t, World world, int x, int y, int z) { - return world.isAirBlock(x, y, z); - } - - @Override - public boolean spawnHint(Object o, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, sHintCasingsTT, 13); - return true; - } - - @Override - public boolean placeBlock(Object o, World world, int x, int y, int z, ItemStack trigger) { - world.setBlock(x, y, z, Blocks.air, 0, 2); - return false; - } - }; - @SuppressWarnings("rawtypes") - private static final IStructureElement NOT_AIR = new IStructureElement() { - @Override - public boolean check(Object t, World world, int x, int y, int z) { - return !world.isAirBlock(x, y, z); - } - - @Override - public boolean spawnHint(Object o, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, sHintCasingsTT, 14); - return true; - } - - @Override - public boolean placeBlock(Object o, World world, int x, int y, int z, ItemStack trigger) { - world.setBlock(x, y, z, sHintCasingsTT, 14, 2); - return true; - } - }; - @SuppressWarnings("rawtypes") - private static final IStructureElement ERROR = new IStructureElement() { - @Override - public boolean check(Object t, World world, int x, int y, int z) { - return false; - } - - @Override - public boolean spawnHint(Object o, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, sHintCasingsTT, 15); - return true; - } - - @Override - public boolean placeBlock(Object o, World world, int x, int y, int z, ItemStack trigger) { - return true; - } - }; - - private StructureUtility() { - - } - - @SuppressWarnings("unchecked") - public static <T> IStructureElement<T> isAir() { - return AIR; - } - - @SuppressWarnings("unchecked") - public static <T> IStructureElement<T> notAir() { - return NOT_AIR; - } - - /** - * Check returns false. - * Placement is always handled by this and does nothing. - * Makes little to no use it in fallback chain. - * - * @param <T> - * @return - */ - @SuppressWarnings("unchecked") - public static <T> IStructureElement<T> error() { - return ERROR; - } - - //region hint only - - /** - * Check always returns: true. - * - * @param dots - * @param <T> - * @return - */ - public static <T> IStructureElementNoPlacement<T> ofHint(int dots) { - int meta = dots - 1; - return new IStructureElementNoPlacement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - return true; - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, sHintCasingsTT, meta); - return false; - } - }; - } - - /** - * Check always returns: true. - * - * @param icons - * @param <T> - * @return - */ - public static <T> IStructureElementNoPlacement<T> ofHintDeferred(Supplier<IIcon[]> icons) { - return new IStructureElementNoPlacement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - return true; - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, icons.get()); - return false; - } - }; - } - - /** - * Check always returns: true. - * - * @param icons - * @param RGBa - * @param <T> - * @return - */ - public static <T> IStructureElementNoPlacement<T> ofHintDeferred(Supplier<IIcon[]> icons, short[] RGBa) { - return new IStructureElementNoPlacement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - return true; - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle_tinted(world, x, y, z, icons.get(), RGBa); - return false; - } - }; - } - - //endregion - - //region block - - /** - * Does not allow Block duplicates (with different meta) - */ - public static <T> IStructureElementNoPlacement<T> ofBlocksFlatHint(Map<Block, Integer> blocsMap, Block hintBlock, int hintMeta) { - if (blocsMap == null || blocsMap.isEmpty() || hintBlock == null) { - throw new IllegalArgumentException(); - } - return new IStructureElementNoPlacement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - Block worldBlock = world.getBlock(x, y, z); - return blocsMap.getOrDefault(worldBlock, MIN_VALUE) == worldBlock.getDamageValue(world, x, y, z); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); - return true; - } - }; - } - - /** - * Allows block duplicates (with different meta) - */ - public static <T> IStructureElementNoPlacement<T> ofBlocksMapHint(Map<Block, Collection<Integer>> blocsMap, Block hintBlock, int hintMeta) { - if (blocsMap == null || blocsMap.isEmpty() || hintBlock == null) { - throw new IllegalArgumentException(); - } - for (Collection<Integer> value : blocsMap.values()) { - if (value.isEmpty()) { - throw new IllegalArgumentException(); - } - } - return new IStructureElementNoPlacement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - Block worldBlock = world.getBlock(x, y, z); - return blocsMap.getOrDefault(worldBlock, Collections.emptySet()).contains(worldBlock.getDamageValue(world, x, y, z)); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); - return true; - } - }; - } - - public static <T> IStructureElementNoPlacement<T> ofBlockHint(Block block, int meta, Block hintBlock, int hintMeta) { - if (block == null || hintBlock == null) { - throw new IllegalArgumentException(); - } - return new IStructureElementNoPlacement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - Block worldBlock = world.getBlock(x, y, z); - return block == worldBlock && meta == worldBlock.getDamageValue(world, x, y, z); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); - return true; - } - }; - } - - public static <T> IStructureElementNoPlacement<T> ofBlockHint(Block block, int meta) { - return ofBlockHint(block, meta, block, meta); - } - - public static <T> IStructureElementNoPlacement<T> ofBlockAdderHint(IBlockAdder<T> iBlockAdder, Block hintBlock, int hintMeta) { - if (iBlockAdder == null || hintBlock == null) { - throw new IllegalArgumentException(); - } - return new IStructureElementNoPlacement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - Block worldBlock = world.getBlock(x, y, z); - return iBlockAdder.apply(t, worldBlock, worldBlock.getDamageValue(world, x, y, z)); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); - return true; - } - }; - } - - /** - * Does not allow Block duplicates (with different meta) - */ - public static <T> IStructureElement<T> ofBlocksFlat(Map<Block, Integer> blocsMap, Block defaultBlock, int defaultMeta) { - if (blocsMap == null || blocsMap.isEmpty() || defaultBlock == null) { - throw new IllegalArgumentException(); - } - if(defaultBlock instanceof ICustomBlockSetting){ - return new IStructureElement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - Block worldBlock = world.getBlock(x, y, z); - return blocsMap.getOrDefault(worldBlock, MIN_VALUE) == worldBlock.getDamageValue(world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - ((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta); - return true; - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); - return true; - } - }; - }else { - return new IStructureElement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - Block worldBlock = world.getBlock(x, y, z); - return blocsMap.getOrDefault(worldBlock, MIN_VALUE) == worldBlock.getDamageValue(world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); - return true; - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); - return true; - } - }; - } - } - - /** - * Allows block duplicates (with different meta) - */ - public static <T> IStructureElement<T> ofBlocksMap(Map<Block, Collection<Integer>> blocsMap, Block defaultBlock, int defaultMeta) { - if (blocsMap == null || blocsMap.isEmpty() || defaultBlock == null) { - throw new IllegalArgumentException(); - } - for (Collection<Integer> value : blocsMap.values()) { - if (value.isEmpty()) { - throw new IllegalArgumentException(); - } - } - if(defaultBlock instanceof ICustomBlockSetting){ - return new IStructureElement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - Block worldBlock = world.getBlock(x, y, z); - return blocsMap.getOrDefault(worldBlock, Collections.emptySet()).contains(worldBlock.getDamageValue(world, x, y, z)); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - ((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta); - return true; - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); - return true; - } - }; - }else { - return new IStructureElement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - Block worldBlock = world.getBlock(x, y, z); - return blocsMap.getOrDefault(worldBlock, Collections.emptySet()).contains(worldBlock.getDamageValue(world, x, y, z)); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); - return true; - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); - return true; - } - }; - } - } - - public static <T> IStructureElement<T> ofBlock(Block block, int meta, Block defaultBlock, int defaultMeta) { - if (block == null || defaultBlock == null) { - throw new IllegalArgumentException(); - } - if(block instanceof ICustomBlockSetting){ - return new IStructureElement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - Block worldBlock = world.getBlock(x, y, z); - return block == worldBlock && meta == worldBlock.getDamageValue(world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - ((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta); - return true; - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); - return true; - } - }; - } else { - return new IStructureElement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - Block worldBlock = world.getBlock(x, y, z); - return block == worldBlock && meta == worldBlock.getDamageValue(world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); - return true; - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); - return true; - } - }; - } - } - - /** - * Same as above but ignores target meta id - */ - public static <T> IStructureElement<T> ofBlockAnyMeta(Block block, Block defaultBlock, int defaultMeta) { - if (block == null || defaultBlock == null) { - throw new IllegalArgumentException(); - } - if(block instanceof ICustomBlockSetting){ - return new IStructureElement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - return block == world.getBlock(x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - ((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta); - return true; - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); - return true; - } - }; - } else { - return new IStructureElement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - return block == world.getBlock(x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); - return true; - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); - return true; - } - }; - } - } - - public static <T> IStructureElement<T> ofBlock(Block block, int meta) { - return ofBlock(block, meta, block, meta); - } - - /** - * Same as above but ignores target meta id - */ - public static <T> IStructureElement<T> ofBlockAnyMeta(Block block) { - return ofBlockAnyMeta(block, block, 0); - } - - /** - * Same as above but allows to set hint particle render - */ - public static <T> IStructureElement<T> ofBlockAnyMeta(Block block,int defaultMeta) { - return ofBlockAnyMeta(block, block, defaultMeta); - } - - //endregion - - //region adders - - public static <T> IStructureElement<T> ofBlockAdder(IBlockAdder<T> iBlockAdder, Block defaultBlock, int defaultMeta) { - if (iBlockAdder == null || defaultBlock == null) { - throw new IllegalArgumentException(); - } - if(defaultBlock instanceof ICustomBlockSetting){ - return new IStructureElement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - Block worldBlock = world.getBlock(x, y, z); - return iBlockAdder.apply(t, worldBlock, worldBlock.getDamageValue(world, x, y, z)); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - ((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta); - return true; - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); - return true; - } - }; - }else { - return new IStructureElement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - Block worldBlock = world.getBlock(x, y, z); - return iBlockAdder.apply(t, worldBlock, worldBlock.getDamageValue(world, x, y, z)); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); - return true; - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); - return true; - } - }; - } - } - - public static <T> IStructureElement<T> ofBlockAdder(IBlockAdder<T> iBlockAdder, int dots) { - return ofBlockAdder(iBlockAdder, sHintCasingsTT, dots - 1); - } - - public static <T> IStructureElementNoPlacement<T> ofTileAdder(ITileAdder<T> iTileAdder, Block hintBlock, int hintMeta) { - if (iTileAdder == null || hintBlock == null) { - throw new IllegalArgumentException(); - } - return new IStructureElementNoPlacement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - TileEntity tileEntity = world.getTileEntity(x, y, z); - return tileEntity instanceof IGregTechTileEntity && iTileAdder.apply(t, tileEntity); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); - return true; - } - }; - } - - public static <T> IStructureElementNoPlacement<T> ofHatchAdder(IHatchAdder<T> iHatchAdder, int textureIndex, int dots) { - return ofHatchAdder(iHatchAdder, textureIndex, sHintCasingsTT, dots - 1); - } - - public static <T> IStructureElementNoPlacement<T> ofHatchAdder(IHatchAdder<T> iHatchAdder, int textureIndex, Block hintBlock, int hintMeta) { - if (iHatchAdder == null || hintBlock == null) { - throw new IllegalArgumentException(); - } - return new IStructureElementNoPlacement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - TileEntity tileEntity = world.getTileEntity(x, y, z); - return tileEntity instanceof IGregTechTileEntity && iHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) textureIndex); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); - return true; - } - }; - } - - public static <T> IStructureElement<T> ofHatchAdderOptional(IHatchAdder<T> iHatchAdder, int textureIndex, int dots, Block placeCasing, int placeCasingMeta) { - return ofHatchAdderOptional(iHatchAdder, textureIndex, sHintCasingsTT, dots - 1, placeCasing, placeCasingMeta); - } - - public static <T> IStructureElement<T> ofHatchAdderOptional(IHatchAdder<T> iHatchAdder, int textureIndex, Block hintBlock, int hintMeta, Block placeCasing, int placeCasingMeta) { - if (iHatchAdder == null || hintBlock == null) { - throw new IllegalArgumentException(); - } - if(placeCasing instanceof ICustomBlockSetting){ - return new IStructureElement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - TileEntity tileEntity = world.getTileEntity(x, y, z); - Block worldBlock = world.getBlock(x, y, z); - return (tileEntity instanceof IGregTechTileEntity && - iHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) textureIndex)) || - (worldBlock == placeCasing && worldBlock.getDamageValue(world, x, y, z) == placeCasingMeta); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); - return true; - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - ((ICustomBlockSetting) placeCasing).setBlock(world, x, y, z, placeCasingMeta); - return true; - } - }; - }else { - return new IStructureElement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - TileEntity tileEntity = world.getTileEntity(x, y, z); - Block worldBlock = world.getBlock(x, y, z); - return (tileEntity instanceof IGregTechTileEntity && - iHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) textureIndex)) || - (worldBlock == placeCasing && worldBlock.getDamageValue(world, x, y, z) == placeCasingMeta); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); - return true; - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - world.setBlock(x, y, z, placeCasing, placeCasingMeta, 2); - return true; - } - }; - } - } - - //endregion - - //region side effects - - public static <B extends IStructureElement<T>, T> IStructureElement<T> onElementPass(Consumer<T> onCheckPass, B element) { - return new IStructureElement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - boolean check = element.check(t, world, x, y, z); - if (check) { - onCheckPass.accept(t); - } - return check; - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return element.placeBlock(t, world, x, y, z, trigger); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - return element.spawnHint(t, world, x, y, z, trigger); - } - }; - } - - public static <B extends IStructureElement<T>, T> IStructureElement<T> onElementFail(Consumer<T> onFail, B element) { - return new IStructureElement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - boolean check = element.check(t, world, x, y, z); - if (!check) { - onFail.accept(t); - } - return check; - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return element.placeBlock(t, world, x, y, z, trigger); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - return element.spawnHint(t, world, x, y, z, trigger); - } - }; - } - - //endregion - - /** - * Take care while chaining, as it will try to call every structure element until it returns true. - * If none does it will finally return false. - * - * @param elementChain - * @param <T> - * @return - */ - @SafeVarargs - public static <T> IStructureElementChain<T> ofChain(IStructureElement<T>... elementChain) { - if (elementChain == null || elementChain.length == 0) { - throw new IllegalArgumentException(); - } - for (IStructureElement<T> iStructureElement : elementChain) { - if (iStructureElement == null) { - throw new IllegalArgumentException(); - } - } - return () -> elementChain; - } - - /** - * Take care while chaining, as it will try to call every structure element until it returns true. - * If none does it will finally return false. - * - * @param elementChain - * @param <T> - * @return - */ - @SuppressWarnings("unchecked") - public static <T> IStructureElementChain<T> ofChain(List<IStructureElement<T>> elementChain) { - return ofChain(elementChain.toArray(new IStructureElement[0])); - } - - //region defer - - public static <T> IStructureElementDeferred<T> defer(Supplier<IStructureElement<T>> to) { - if (to == null) { - throw new IllegalArgumentException(); - } - return new IStructureElementDeferred<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - return to.get().check(t, world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return to.get().placeBlock(t, world, x, y, z, trigger); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - return to.get().spawnHint(t, world, x, y, z, trigger); - } - }; - } - - public static <T> IStructureElementDeferred<T> defer(Function<T, IStructureElement<T>> to) { - if (to == null) { - throw new IllegalArgumentException(); - } - return new IStructureElementDeferred<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - return to.apply(t).check(t, world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return to.apply(t).placeBlock(t, world, x, y, z, trigger); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - return to.apply(t).spawnHint(t, world, x, y, z, trigger); - } - }; - } - - public static <T, K> IStructureElementDeferred<T> defer(Function<T, K> keyExtractor, Map<K, IStructureElement<T>> map) { - if (keyExtractor == null || map == null) { - throw new IllegalArgumentException(); - } - return new IStructureElementDeferred<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - return map.get(keyExtractor.apply(t)).check(t, world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return map.get(keyExtractor.apply(t)).placeBlock(t, world, x, y, z, trigger); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - return map.get(keyExtractor.apply(t)).spawnHint(t, world, x, y, z, trigger); - } - }; - } - - public static <T, K> IStructureElementDeferred<T> defer(Function<T, K> keyExtractor, Map<K, IStructureElement<T>> map, IStructureElement<T> defaultElem) { - if (keyExtractor == null || map == null) { - throw new IllegalArgumentException(); - } - return new IStructureElementDeferred<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - return map.getOrDefault(keyExtractor.apply(t), defaultElem).check(t, world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return map.getOrDefault(keyExtractor.apply(t), defaultElem).placeBlock(t, world, x, y, z, trigger); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - return map.getOrDefault(keyExtractor.apply(t), defaultElem).spawnHint(t, world, x, y, z, trigger); - } - }; - } - - @SafeVarargs - public static <T> IStructureElementDeferred<T> defer(Function<T, Integer> keyExtractor, IStructureElement<T>... array) { - if (keyExtractor == null || array == null) { - throw new IllegalArgumentException(); - } - return new IStructureElementDeferred<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - return array[keyExtractor.apply(t)].check(t, world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return array[keyExtractor.apply(t)].placeBlock(t, world, x, y, z, trigger); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - return array[keyExtractor.apply(t)].spawnHint(t, world, x, y, z, trigger); - } - }; - } - - @SuppressWarnings("unchecked") - public static <T> IStructureElementDeferred<T> defer(Function<T, Integer> keyExtractor, List<IStructureElement<T>> array) { - return defer(keyExtractor, array.toArray(new IStructureElement[0])); - } - - public static <T> IStructureElementDeferred<T> defer(BiFunction<T, ItemStack, IStructureElement<T>> to) { - if (to == null) { - throw new IllegalArgumentException(); - } - return new IStructureElementDeferred<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - return to.apply(t, null).check(t, world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return to.apply(t, trigger).placeBlock(t, world, x, y, z, trigger); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - return to.apply(t, trigger).spawnHint(t, world, x, y, z, trigger); - } - }; - } - - public static <T, K> IStructureElementDeferred<T> defer(BiFunction<T, ItemStack, K> keyExtractor, Map<K, IStructureElement<T>> map) { - if (keyExtractor == null || map == null) { - throw new IllegalArgumentException(); - } - return new IStructureElementDeferred<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - return map.get(keyExtractor.apply(t, null)).check(t, world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return map.get(keyExtractor.apply(t, trigger)).placeBlock(t, world, x, y, z, trigger); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - return map.get(keyExtractor.apply(t, trigger)).spawnHint(t, world, x, y, z, trigger); - } - }; - } - - public static <T, K> IStructureElementDeferred<T> defer(BiFunction<T, ItemStack, K> keyExtractor, Map<K, IStructureElement<T>> map, IStructureElement<T> defaultElem) { - if (keyExtractor == null || map == null) { - throw new IllegalArgumentException(); - } - return new IStructureElementDeferred<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - return map.getOrDefault(keyExtractor.apply(t, null), defaultElem).check(t, world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).placeBlock(t, world, x, y, z, trigger); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).spawnHint(t, world, x, y, z, trigger); - } - }; - } - - @SafeVarargs - public static <T> IStructureElementDeferred<T> defer(BiFunction<T, ItemStack, Integer> keyExtractor, IStructureElement<T>... array) { - if (keyExtractor == null || array == null) { - throw new IllegalArgumentException(); - } - return new IStructureElementDeferred<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - return array[keyExtractor.apply(t, null)].check(t, world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return array[keyExtractor.apply(t, trigger)].placeBlock(t, world, x, y, z, trigger); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - return array[keyExtractor.apply(t, trigger)].spawnHint(t, world, x, y, z, trigger); - } - }; - } - - @SuppressWarnings("unchecked") - public static <T> IStructureElementDeferred<T> defer(BiFunction<T, ItemStack, Integer> keyExtractor, List<IStructureElement<T>> array) { - return defer(keyExtractor, array.toArray(new IStructureElement[0])); - } - - public static <T> IStructureElementDeferred<T> defer(Function<T, IStructureElement<T>> toCheck, BiFunction<T, ItemStack, IStructureElement<T>> to) { - if (to == null) { - throw new IllegalArgumentException(); - } - return new IStructureElementDeferred<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - return toCheck.apply(t).check(t, world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return to.apply(t, trigger).placeBlock(t, world, x, y, z, trigger); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - return to.apply(t, trigger).spawnHint(t, world, x, y, z, trigger); - } - }; - } - - public static <T, K> IStructureElementDeferred<T> defer(Function<T, K> keyExtractorCheck, BiFunction<T, ItemStack, K> keyExtractor, Map<K, IStructureElement<T>> map) { - if (keyExtractor == null || map == null) { - throw new IllegalArgumentException(); - } - return new IStructureElementDeferred<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - return map.get(keyExtractorCheck.apply(t)).check(t, world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return map.get(keyExtractor.apply(t, trigger)).placeBlock(t, world, x, y, z, trigger); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - return map.get(keyExtractor.apply(t, trigger)).spawnHint(t, world, x, y, z, trigger); - } - }; - } - - public static <T, K> IStructureElementDeferred<T> defer(Function<T, K> keyExtractorCheck, BiFunction<T, ItemStack, K> keyExtractor, Map<K, IStructureElement<T>> map, IStructureElement<T> defaultElem) { - if (keyExtractor == null || map == null) { - throw new IllegalArgumentException(); - } - return new IStructureElementDeferred<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - return map.getOrDefault(keyExtractorCheck.apply(t), defaultElem).check(t, world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).placeBlock(t, world, x, y, z, trigger); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).spawnHint(t, world, x, y, z, trigger); - } - }; - } - - @SafeVarargs - public static <T> IStructureElementDeferred<T> defer(Function<T, Integer> keyExtractorCheck, BiFunction<T, ItemStack, Integer> keyExtractor, IStructureElement<T>... array) { - if (keyExtractor == null || array == null) { - throw new IllegalArgumentException(); - } - return new IStructureElementDeferred<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - return array[keyExtractorCheck.apply(t)].check(t, world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return array[keyExtractor.apply(t, trigger)].placeBlock(t, world, x, y, z, trigger); - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - return array[keyExtractor.apply(t, trigger)].spawnHint(t, world, x, y, z, trigger); - } - }; - } - - @SuppressWarnings("unchecked") - public static <T> IStructureElementDeferred<T> defer(Function<T, Integer> keyExtractorCheck, BiFunction<T, ItemStack, Integer> keyExtractor, List<IStructureElement<T>> array) { - return defer(keyExtractorCheck, keyExtractor, array.toArray(new IStructureElement[0])); - } - - //endregion - - /** - * Used internally, to generate skips for structure definitions - * - * @param a - * @param b - * @param c - * @param <T> - * @return - */ - public static <T> IStructureNavigate<T> step(int a, int b, int c) { - return step(new Vec3Impl(a, b, c)); - } - - /** - * Used internally, to generate skips for structure definitions - * - * @param step - * @param <T> - * @return - */ - @SuppressWarnings("unchecked") - public static <T> IStructureNavigate<T> step(Vec3Impl step) { - if (step == null || step.get0() < 0 || step.get1() < 0 || step.get2() < 0) { - throw new IllegalArgumentException(); - } - return STEP.computeIfAbsent(step, vec3 -> { - if (vec3.get2() > 0) { - return stepC(vec3.get0(), vec3.get1(), vec3.get2()); - } else if (vec3.get1() > 0) { - return stepB(vec3.get0(), vec3.get1(), vec3.get2()); - } else { - return stepA(vec3.get0(), vec3.get1(), vec3.get2()); - } - }); - } - - private static <T> IStructureNavigate<T> stepA(int a, int b, int c) { - return new IStructureNavigate<T>() { - @Override - public int getStepA() { - return a; - } - - @Override - public int getStepB() { - return b; - } - - @Override - public int getStepC() { - return c; - } - }; - } - - private static <T> IStructureNavigate<T> stepB(int a, int b, int c) { - return new IStructureNavigate<T>() { - @Override - public int getStepA() { - return a; - } - - @Override - public int getStepB() { - return b; - } - - @Override - public int getStepC() { - return c; - } - - @Override - public boolean resetA() { - return true; - } - }; - } - - private static <T> IStructureNavigate<T> stepC(int a, int b, int c) { - return new IStructureNavigate<T>() { - @Override - public int getStepA() { - return a; - } - - @Override - public int getStepB() { - return b; - } - - @Override - public int getStepC() { - return c; - } - - @Override - public boolean resetA() { - return true; - } - - @Override - public boolean resetB() { - return true; - } - }; - } - - /** - * Used only to get pseudo code in structure writer... - * - * @param world - * @return - */ - public static String getPseudoJavaCode(World world, ExtendedFacing extendedFacing, - int basePositionX, int basePositionY, int basePositionZ, - int basePositionA, int basePositionB, int basePositionC, - int sizeA, int sizeB, int sizeC, boolean transpose) { - Map<Block, Set<Integer>> blocks = new TreeMap<>(Comparator.comparing(Block::getUnlocalizedName)); - Set<Class<? extends TileEntity>> tiles = new TreeSet<>(Comparator.comparing(Class::getCanonicalName)); - Set<Class<? extends IMetaTileEntity>> gtTiles = new TreeSet<>(Comparator.comparing(Class::getCanonicalName)); - iterate(world, extendedFacing, basePositionX, basePositionY, basePositionZ, - basePositionA, basePositionB, basePositionC, - sizeA, sizeB, sizeC, ((w, x, y, z) -> { - TileEntity tileEntity = w.getTileEntity(x, y, z); - if (tileEntity == null) { - Block block = w.getBlock(x, y, z); - if (block != null && block != Blocks.air) { - blocks.compute(block, (b, set) -> { - if (set == null) { - set = new TreeSet<>(); - } - set.add(block.getDamageValue(world, x, y, z)); - return set; - }); - } - } else { - if (tileEntity instanceof IGregTechTileEntity) { - IMetaTileEntity meta = ((IGregTechTileEntity) tileEntity).getMetaTileEntity(); - if (meta != null) { - gtTiles.add(meta.getClass()); - } else { - tiles.add(tileEntity.getClass()); - } - } else { - tiles.add(tileEntity.getClass()); - } - } - })); - Map<String, Character> map = new HashMap<>(); - StringBuilder builder = new StringBuilder(); - { - int i = 0; - char c; - builder.append("\n\nStructure:\n") - .append("\nBlocks:\n"); - for (Map.Entry<Block, Set<Integer>> entry : blocks.entrySet()) { - Block block = entry.getKey(); - Set<Integer> set = entry.getValue(); - for (Integer meta : set) { - c = NICE_CHARS.charAt(i++); - if (i > NICE_CHARS.length()) { - return "Too complicated for nice chars"; - } - map.put(block.getUnlocalizedName() + '\0' + meta, c); - builder.append(c).append(" -> ofBlock...(") - .append(block.getUnlocalizedName()).append(", ").append(meta).append(", ...);\n"); - } - } - builder.append("\nTiles:\n"); - for (Class<? extends TileEntity> tile : tiles) { - c = NICE_CHARS.charAt(i++); - if (i > NICE_CHARS.length()) { - return "Too complicated for nice chars"; - } - map.put(tile.getCanonicalName(), c); - builder.append(c).append(" -> ofTileAdder(") - .append(tile.getCanonicalName()).append(", ...);\n"); - } - builder.append("\nMeta:\n"); - for (Class<? extends IMetaTileEntity> gtTile : gtTiles) { - c = NICE_CHARS.charAt(i++); - if (i > NICE_CHARS.length()) { - return "Too complicated for nice chars"; - } - map.put(gtTile.getCanonicalName(), c); - builder.append(c).append(" -> ofHatchAdder(") - .append(gtTile.getCanonicalName()).append(", textureId, ...);\n"); - } - } - builder.append("\nOffsets:\n") - .append(basePositionA).append(' ').append(basePositionB).append(' ').append(basePositionC).append('\n'); - if (transpose) { - builder.append("\nTransposed Scan:\n") - .append("new String[][]{\n") - .append(" {\""); - iterate(world, extendedFacing, basePositionX, basePositionY, basePositionZ, - basePositionA, basePositionB, basePositionC, true, - sizeA, sizeB, sizeC, ((w, x, y, z) -> { - TileEntity tileEntity = w.getTileEntity(x, y, z); - if (tileEntity == null) { - Block block = w.getBlock(x, y, z); - if (block != null && block != Blocks.air) { - builder.append(map.get(block.getUnlocalizedName() + '\0' + block.getDamageValue(world, x, y, z))); - } else { - builder.append(' '); - } - } else { - if (tileEntity instanceof IGregTechTileEntity) { - IMetaTileEntity meta = ((IGregTechTileEntity) tileEntity).getMetaTileEntity(); - if (meta != null) { - builder.append(map.get(meta.getClass().getCanonicalName())); - } else { - builder.append(map.get(tileEntity.getClass().getCanonicalName())); - } - } else { - builder.append(map.get(tileEntity.getClass().getCanonicalName())); - } - } - }), - () -> builder.append("\",\""), - () -> { - builder.setLength(builder.length() - 2); - builder.append("},\n {\""); - }); - builder.setLength(builder.length() - 8); - builder.append("\n}\n\n"); - } else { - builder.append("\nNormal Scan:\n") - .append("new String[][]{{\n") - .append(" \""); - iterate(world, extendedFacing, basePositionX, basePositionY, basePositionZ, - basePositionA, basePositionB, basePositionC, false, - sizeA, sizeB, sizeC, ((w, x, y, z) -> { - TileEntity tileEntity = w.getTileEntity(x, y, z); - if (tileEntity == null) { - Block block = w.getBlock(x, y, z); - if (block != null && block != Blocks.air) { - builder.append(map.get(block.getUnlocalizedName() + '\0' + block.getDamageValue(world, x, y, z))); - } else { - builder.append(' '); - } - } else { - if (tileEntity instanceof IGregTechTileEntity) { - IMetaTileEntity meta = ((IGregTechTileEntity) tileEntity).getMetaTileEntity(); - if (meta != null) { - builder.append(map.get(meta.getClass().getCanonicalName())); - } else { - builder.append(map.get(tileEntity.getClass().getCanonicalName())); - } - } else { - builder.append(map.get(tileEntity.getClass().getCanonicalName())); - } - } - }), - () -> builder.append("\",\n").append(" \""), - () -> { - builder.setLength(builder.length() - 7); - builder.append("\n").append("},{\n").append(" \""); - }); - builder.setLength(builder.length() - 8); - builder.append("}\n\n"); - } - return (builder.toString().replaceAll("\"\"", "E")); - } - - public static void iterate(World world, ExtendedFacing extendedFacing, - int basePositionX, int basePositionY, int basePositionZ, - int basePositionA, int basePositionB, int basePositionC, - int sizeA, int sizeB, int sizeC, - IBlockPosConsumer iBlockPosConsumer) { - sizeA -= basePositionA; - sizeB -= basePositionB; - sizeC -= basePositionC; - - int[] abc = new int[3]; - int[] xyz = new int[3]; - - for (abc[2] = -basePositionC; abc[2] < sizeC; abc[2]++) { - for (abc[1] = -basePositionB; abc[1] < sizeB; abc[1]++) { - for (abc[0] = -basePositionA; abc[0] < sizeA; abc[0]++) { - extendedFacing.getWorldOffset(abc, xyz); - iBlockPosConsumer.consume(world, xyz[0] + basePositionX, xyz[1] + basePositionY, xyz[2] + basePositionZ); - } - - } - } - } - - public static void iterate(World world, ExtendedFacing extendedFacing, - int basePositionX, int basePositionY, int basePositionZ, - int basePositionA, int basePositionB, int basePositionC, - boolean transpose, int sizeA, int sizeB, int sizeC, - IBlockPosConsumer iBlockPosConsumer, - Runnable nextB, - Runnable nextC) { - sizeA -= basePositionA; - sizeB -= basePositionB; - sizeC -= basePositionC; - - int[] abc = new int[3]; - int[] xyz = new int[3]; - if (transpose) { - for (abc[1] = -basePositionB; abc[1] < sizeB; abc[1]++) { - for (abc[2] = -basePositionC; abc[2] < sizeC; abc[2]++) { - for (abc[0] = -basePositionA; abc[0] < sizeA; abc[0]++) { - extendedFacing.getWorldOffset(abc, xyz); - iBlockPosConsumer.consume(world, xyz[0] + basePositionX, xyz[1] + basePositionY, xyz[2] + basePositionZ); - } - nextB.run(); - } - nextC.run(); - } - } else { - for (abc[2] = -basePositionC; abc[2] < sizeC; abc[2]++) { - for (abc[1] = -basePositionB; abc[1] < sizeB; abc[1]++) { - for (abc[0] = -basePositionA; abc[0] < sizeA; abc[0]++) { - extendedFacing.getWorldOffset(abc, xyz); - iBlockPosConsumer.consume(world, xyz[0] + basePositionX, xyz[1] + basePositionY, xyz[2] + basePositionZ); - } - nextB.run(); - } - nextC.run(); - } - } - } - - /** - * Transposes shape (swaps B and C axis, can be used to un-transpose transposed shape) - * WARNING! Do not use on old api... - * - * @param structurePiece shape (transposed shape) - * @return transposed shape (untransposed shape) - */ - public static String[][] transpose(String[][] structurePiece) { - String[][] shape = new String[structurePiece[0].length][structurePiece.length]; - for (int i = 0; i < structurePiece.length; i++) { - for (int j = 0; j < structurePiece[i].length; j++) { - shape[j][i] = structurePiece[i][j]; - } - } - return shape; - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IBlockAdder.java b/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IBlockAdder.java deleted file mode 100644 index 29229f7902..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IBlockAdder.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.github.technus.tectech.mechanics.structure.adders; - - -import net.minecraft.block.Block; - -@Deprecated -public interface IBlockAdder<T> { - /** - * Callback on block added, needs to check if block is valid (and add it) - * @param block block attempted to add - * @param meta meta of block attempted to add - * @return is structure still valid - */ - boolean apply(T t,Block block, Integer meta); -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IHatchAdder.java b/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IHatchAdder.java deleted file mode 100644 index 197dd2fd45..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IHatchAdder.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.github.technus.tectech.mechanics.structure.adders; - - -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - -@Deprecated -public interface IHatchAdder<T> { - /** - * Callback to add hatch, needs to check if hatch is valid (and add it) - * @param iGregTechTileEntity hatch - * @param aShort requested texture index, or null if not... - * @return managed to add hatch (structure still valid) - */ - boolean apply(T t,IGregTechTileEntity iGregTechTileEntity, Short aShort); -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/adders/ITileAdder.java b/src/main/java/com/github/technus/tectech/mechanics/structure/adders/ITileAdder.java deleted file mode 100644 index c262bbb154..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/adders/ITileAdder.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.github.technus.tectech.mechanics.structure.adders; - -import net.minecraft.tileentity.TileEntity; - -@Deprecated -public interface ITileAdder<T> { - /** - * Callback to add hatch, needs to check if tile is valid (and add it) - * @param tileEntity tile - * @return managed to add hatch (structure still valid) - */ - boolean apply(T t,TileEntity tileEntity); -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/tesla/TeslaCoverConnection.java b/src/main/java/com/github/technus/tectech/mechanics/tesla/TeslaCoverConnection.java index 0b84236709..87ad7d7443 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/tesla/TeslaCoverConnection.java +++ b/src/main/java/com/github/technus/tectech/mechanics/tesla/TeslaCoverConnection.java @@ -4,7 +4,6 @@ import com.google.common.base.Objects; import com.gtnewhorizon.structurelib.util.Vec3Impl; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.teslaSimpleNodeSetAdd; import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.teslaSimpleNodeSetRemove; public class TeslaCoverConnection implements ITeslaConnectableSimple { diff --git a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java index 32e3e867bd..45e981a705 100644 --- a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java +++ b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java @@ -211,8 +211,8 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { int tSpecial = ((CachedDefaultRecipe) arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; short ampere=(short) (tSpecial & 0xFFFF),minComputationPerSec=(short)(tSpecial>>>16); if (tEUt != 0) { - drawText(10, 73, trans("152","Max Total: ") + GT_Utility.formatNumbers((1+ (computation-minComputationPerSec) /minComputationPerSec) * (long)tEUt * ampere * 20) + " EU", -16777216); - drawText(10, 83, trans("153","Usage: ") + GT_Utility.formatNumbers((long)tEUt*ampere) + " EU/t", -16777216); + drawText(10, 73, trans("152","Max Total: ") + GT_Utility.formatNumbers((1 + (computation - minComputationPerSec) / minComputationPerSec) * (long) tEUt * ampere * 20) + " EU", -16777216); + drawText(10, 83, trans("153","Usage: ") + GT_Utility.formatNumbers((long) tEUt * ampere) + " EU/t", -16777216); if (mRecipeMap.mShowVoltageAmperageInNEI) { drawText(10, 93, trans("154","Voltage: ") + GT_Utility.formatNumbers(tEUt) + " EU", -16777216); drawText(10, 103, trans("155","Amperage: ") + GT_Utility.formatNumbers(ampere), -16777216); diff --git a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java index 093d39eeee..f4064004c9 100644 --- a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java +++ b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java @@ -211,8 +211,8 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { int tSpecial = ((CachedDefaultRecipe) arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; short ampere=(short) (tSpecial & 0xFFFF),minComputationPerSec=(short)(tSpecial>>>16); if (tEUt != 0) { - drawText(10, 73, trans("152","Max Total: ") + GT_Utility.formatNumbers((1+ (computation-minComputationPerSec) /minComputationPerSec) * (long)tEUt * ampere * 20) + " EU", -16777216); - drawText(10, 83, trans("153","Usage: ") + GT_Utility.formatNumbers((long)tEUt*ampere) + " EU/t", -16777216); + drawText(10, 73, trans("152","Max Total: ") + GT_Utility.formatNumbers((1 + (computation - minComputationPerSec) / minComputationPerSec) * (long) tEUt * ampere * 20) + " EU", -16777216); + drawText(10, 83, trans("153","Usage: ") + GT_Utility.formatNumbers((long) tEUt * ampere) + " EU/t", -16777216); if (mRecipeMap.mShowVoltageAmperageInNEI) { drawText(10, 93, trans("154","Voltage: ") + GT_Utility.formatNumbers(tEUt) + " EU", -16777216); drawText(10, 103, trans("155","Amperage: ") + GT_Utility.formatNumbers(ampere), -16777216); diff --git a/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java b/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java index 6a2a81057e..043bd87a21 100644 --- a/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java +++ b/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java @@ -1,10 +1,7 @@ package com.github.technus.tectech.proxy; import com.github.technus.tectech.Reference; -import com.github.technus.tectech.TecTech; import com.github.technus.tectech.compatibility.openmodularturrets.TT_turret_loader; -import com.github.technus.tectech.entity.fx.BlockHint; -import com.github.technus.tectech.entity.fx.WeightlessParticleFX; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.block.QuantumGlassRender; import com.github.technus.tectech.thing.block.QuantumStuffBlock; @@ -12,11 +9,11 @@ import com.github.technus.tectech.thing.block.QuantumStuffRender; import com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM; import com.github.technus.tectech.thing.item.ElementalDefinitionContainer_EM; import com.github.technus.tectech.thing.item.renderElemental.RenderElementalName; +import com.gtnewhorizon.structurelib.entity.fx.WeightlessParticleFX; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.Loader; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.gui.GuiNewChat; @@ -24,7 +21,6 @@ import net.minecraft.client.particle.EntityFX; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; -import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.common.util.ForgeDirection; @@ -42,6 +38,7 @@ public class ClientProxy extends CommonProxy { MinecraftForgeClient.registerItemRenderer(ElementalDefinitionContainer_EM.INSTANCE, RenderElementalName.INSTANCE); MinecraftForgeClient.registerItemRenderer(DebugElementalInstanceContainer_EM.INSTANCE, RenderElementalName.INSTANCE); + //MinecraftForgeClient.registerItemRenderer(ElementalDefinitionScanStorage_EM.INSTANCE, RenderElementalName.INSTANCE); if(Loader.isModLoaded("openmodularturrets")) { new TT_turret_loader().run(); @@ -49,42 +46,6 @@ public class ClientProxy extends CommonProxy { } @Override - public void hint_particle_tinted(World w,int x, int y, int z, IIcon[] icons,short[] RGBa) { - Minecraft.getMinecraft().effectRenderer.addEffect(new BlockHint(w,x,y,z,icons).withColorTint(RGBa)); - - EntityFX particle = new WeightlessParticleFX(w, x + RANDOM.nextFloat() * 0.5F, y + RANDOM.nextFloat() * 0.5F, z + RANDOM.nextFloat() * 0.5F, 0, 0, 0); - particle.setRBGColorF(0, 0.6F * RANDOM.nextFloat(), 0.8f); - Minecraft.getMinecraft().effectRenderer.addEffect(particle); - } - - @Override - public void hint_particle_tinted(World w,int x, int y, int z, Block block, int meta,short[] RGBa) { - Minecraft.getMinecraft().effectRenderer.addEffect(new BlockHint(w,x,y,z,block,meta).withColorTint(RGBa)); - - EntityFX particle = new WeightlessParticleFX(w, x + RANDOM.nextFloat() * 0.5F, y + RANDOM.nextFloat() * 0.5F, z + RANDOM.nextFloat() * 0.5F, 0, 0, 0); - particle.setRBGColorF(0, 0.6F * RANDOM.nextFloat(), 0.8f); - Minecraft.getMinecraft().effectRenderer.addEffect(particle); - } - - @Override - public void hint_particle(World w,int x, int y, int z, IIcon[] icons) { - Minecraft.getMinecraft().effectRenderer.addEffect(new BlockHint(w,x,y,z,icons)); - - EntityFX particle = new WeightlessParticleFX(w, x + RANDOM.nextFloat() * 0.5F, y + RANDOM.nextFloat() * 0.5F, z + RANDOM.nextFloat() * 0.5F, 0, 0, 0); - particle.setRBGColorF(0, 0.6F * RANDOM.nextFloat(), 0.8f); - Minecraft.getMinecraft().effectRenderer.addEffect(particle); - } - - @Override - public void hint_particle(World w,int x, int y, int z, Block block, int meta) { - Minecraft.getMinecraft().effectRenderer.addEffect(new BlockHint(w,x,y,z,block,meta)); - - EntityFX particle = new WeightlessParticleFX(w, x + RANDOM.nextFloat() * 0.5F, y + RANDOM.nextFloat() * 0.5F, z + RANDOM.nextFloat() * 0.5F, 0, 0, 0); - particle.setRBGColorF(0, 0.6F * RANDOM.nextFloat(), 0.8f); - Minecraft.getMinecraft().effectRenderer.addEffect(particle); - } - - @Override public void em_particle(IGregTechTileEntity aMuffler, byte facing) {//CUTE! ForgeDirection aDir = ForgeDirection.getOrientation(facing); float xPos = aDir.offsetX * 0.76F + aMuffler.getXCoord() + 0.25F; diff --git a/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java b/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java index 490cdf1092..0fbe8d890e 100644 --- a/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java +++ b/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java @@ -2,22 +2,16 @@ package com.github.technus.tectech.proxy; import cpw.mods.fml.common.network.IGuiHandler; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.server.MinecraftServer; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; -import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraft.world.WorldServer; public class CommonProxy implements IGuiHandler { public void registerRenderInfo() {} - public void hint_particle_tinted(World w,int x, int y, int z, IIcon[] icons,short[] RGBa){} - public void hint_particle_tinted(World w,int x, int y, int z, Block block, int meta,short[] RGBa){} - public void hint_particle(World w,int x, int y, int z, IIcon[] icons){} - public void hint_particle(World w,int x, int y, int z, Block block, int meta){} public void em_particle(IGregTechTileEntity aMuffler, byte facing) {}//CUTE! public void pollutor_particle(IGregTechTileEntity aPollutor, byte facing) {}//CUTE! public void em_particle(World w,double x, double y, double z){} diff --git a/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java b/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java index b0b349a268..68607ae737 100644 --- a/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java +++ b/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java @@ -1,9 +1,10 @@ package com.github.technus.tectech.recipe; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDefinitionStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.IEMMapRead; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.util.GT_Recipe; import net.minecraft.item.ItemStack; @@ -14,19 +15,17 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; -import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; - public class TT_recipe extends GT_Recipe { - public static final String E_RECIPE_ID = "eRecipeID"; - public final cElementalDefinitionStackMap[] input; - public final cElementalDefinitionStackMap[] output; - public final cElementalDefinitionStackMap[] eCatalyst; - public final IAdditionalCheck additionalCheck; + public static final String E_RECIPE_ID = "eRecipeID"; + public final EMConstantStackMap[] input; + public final IEMMapRead<? extends IEMStack>[] output; + public final EMConstantStackMap[] eCatalyst; + public final IAdditionalCheck additionalCheck; public TT_recipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue, - cElementalDefinitionStackMap[] in, cElementalDefinitionStackMap[] out, cElementalDefinitionStackMap[] catalyst, IAdditionalCheck check){ + EMConstantStackMap[] in, IEMMapRead<? extends IEMStack>[] out, EMConstantStackMap[] catalyst, IAdditionalCheck check){ super(aOptimize,aInputs,aOutputs,aSpecialItems,aChances,aFluidInputs,aFluidOutputs,aDuration,aEUt,aSpecialValue); input=in; output=out; @@ -38,11 +37,11 @@ public class TT_recipe extends GT_Recipe { return EMisRecipeInputEqual(consume,doNotCheckStackSizes,itemStacks,fluidStacks,null,null); } - public boolean EMisRecipeInputEqual(boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, cElementalInstanceStackMap[] in){ + public boolean EMisRecipeInputEqual(boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, EMInstanceStackMap[] in){ return EMisRecipeInputEqual(consume,doNotCheckStackSizes,itemStacks,fluidStacks,in,null); } - public boolean EMisRecipeInputEqual(boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, cElementalInstanceStackMap[] in, cElementalInstanceStackMap[] catalyst) { + public boolean EMisRecipeInputEqual(boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, EMInstanceStackMap[] in, EMInstanceStackMap[] catalyst) { if(additionalCheck !=null && !additionalCheck.check(this,consume,doNotCheckStackSizes,itemStacks,fluidStacks,in,catalyst)) { return false; } @@ -51,7 +50,7 @@ public class TT_recipe extends GT_Recipe { for (int i = 0; i < eCatalyst.length; i++) { if (eCatalyst[i] != null && eCatalyst[i].hasStacks()) { if (catalyst[i] != null && catalyst[i].hasStacks()) { - if (!catalyst[i].removeAllAmounts(true, eCatalyst[i])) { + if (!catalyst[i].containsAllAmounts(eCatalyst[i])) { return false; } } else { @@ -68,8 +67,14 @@ public class TT_recipe extends GT_Recipe { for (int i = 0; i < input.length; i++) { if (input[i] != null && input[i].hasStacks()) { if (in[i] != null && in[i].hasStacks()) { - if (!in[i].removeAllAmounts(consume, input[i])) { - return false; + if(consume){ + if (!in[i].removeAllAmounts(input[i])) { + return false; + } + }else { + if (!in[i].containsAllAmounts(input[i])) { + return false; + } } } else { return false; @@ -83,11 +88,13 @@ public class TT_recipe extends GT_Recipe { return super.isRecipeInputEqual(consume, doNotCheckStackSizes, fluidStacks, itemStacks); } - public boolean EMisRecipeInputEqualConsumeFromOne(boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, cElementalInstanceStackMap in){ + @Deprecated + public boolean EMisRecipeInputEqualConsumeFromOne(boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, EMInstanceStackMap in){ return EMisRecipeInputEqualConsumeFromOne(consume,doNotCheckStackSizes,itemStacks,fluidStacks,in,null); } - public boolean EMisRecipeInputEqualConsumeFromOne(boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, cElementalInstanceStackMap in, cElementalInstanceStackMap[] catalyst) { + @Deprecated + public boolean EMisRecipeInputEqualConsumeFromOne(boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, EMInstanceStackMap in, EMInstanceStackMap[] catalyst) { if(additionalCheck !=null && !additionalCheck.check(this,consume,doNotCheckStackSizes,itemStacks,fluidStacks,in,catalyst)) { return false; } @@ -96,7 +103,7 @@ public class TT_recipe extends GT_Recipe { for (int i = 0; i < eCatalyst.length; i++) { if (eCatalyst[i] != null && eCatalyst[i].hasStacks()) { if (catalyst[i] != null && catalyst[i].hasStacks()) { - if (!catalyst[i].removeAllAmounts(true, eCatalyst[i])) { + if (!catalyst[i].containsAllAmounts(eCatalyst[i])) { return false; } } else { @@ -110,11 +117,17 @@ public class TT_recipe extends GT_Recipe { } if (input != null) { if (in != null) { - for (cElementalDefinitionStackMap anInput : input) { + for (EMConstantStackMap anInput : input) { if (anInput != null && anInput.hasStacks()) { if (in.hasStacks()) { - if (!in.removeAllAmounts(consume, anInput)) { - return false; + if(consume){ + if (!in.removeAllAmounts(anInput)) { + return false; + } + }else { + if (!in.containsAllAmounts(anInput)) { + return false; + } } } else { return false; @@ -129,8 +142,8 @@ public class TT_recipe extends GT_Recipe { } public interface IAdditionalCheck { - boolean check(TT_recipe thisRecipe, boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, cElementalInstanceStackMap[] in, cElementalInstanceStackMap[] e); - boolean check(TT_recipe thisRecipe, boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, cElementalInstanceStackMap in, cElementalInstanceStackMap[] e); + boolean check(TT_recipe thisRecipe, boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, EMInstanceStackMap[] in, EMInstanceStackMap[] e); + boolean check(TT_recipe thisRecipe, boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, EMInstanceStackMap in, EMInstanceStackMap[] e); } public static class TT_Recipe_Map<T extends TT_recipe> { @@ -166,12 +179,20 @@ public class TT_recipe extends GT_Recipe { } public static class GT_Recipe_MapTT extends GT_Recipe.GT_Recipe_Map { - public static GT_Recipe_MapTT sResearchableFakeRecipes =new GT_Recipe_MapTT(new HashSet<>(32), "gt.recipe.researchStation", "Research station", null, "gregtech:textures/gui/multimachines/ResearchFake", 1, 1,1,0,1,"", 1, "", true, false);//nei to false - using custom handler - public static GT_Recipe_MapTT sScannableFakeRecipes = new GT_Recipe_MapTT(new HashSet<>(32),"gt.recipe.em_scanner","EM Scanner Research", null,"gregtech:textures/gui/multimachines/ResearchFake",1,1,1,0,1,"",1,"",true,false); - public static ArrayList<GT_Recipe_AssemblyLine> sAssemblylineRecipes=new ArrayList<>(); + public static GT_Recipe_MapTT sResearchableFakeRecipes = new GT_Recipe_MapTT(new HashSet<>(32), "gt.recipe.researchStation", "Research station", null, "gregtech:textures/gui/multimachines/ResearchFake", 1, 1, 1, 0, 1, "", 1, "", true, false);//nei to false - using custom handler + public static GT_Recipe_MapTT sScannableFakeRecipes = new GT_Recipe_MapTT(new HashSet<>(32), "gt.recipe.em_scanner", "EM Scanner Research", null, "gregtech:textures/gui/multimachines/ResearchFake", 1, 1, 1, 0, 1, "", 1, "", true, false); + public static ArrayList<GT_Recipe_AssemblyLine> sAssemblylineRecipes = new ArrayList<>(); - public GT_Recipe_MapTT(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + public GT_Recipe_MapTT(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, + int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { + super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, + aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, + aShowVoltageAmperageInNEI, aNEIAllowed); } } @@ -181,7 +202,7 @@ public class TT_recipe extends GT_Recipe { public TT_assLineRecipe(boolean aOptimize, ItemStack researchItem, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, FluidStack[] aFluidInputs, int aDuration, int aEUt, int aSpecialValue, - cElementalDefinitionStackMap[] in, cElementalDefinitionStackMap[] out, cElementalDefinitionStackMap[] catalyst, IAdditionalCheck check) { + EMConstantStackMap[] in, EMConstantStackMap[] out, EMConstantStackMap[] catalyst, IAdditionalCheck check) { super(aOptimize, aInputs, aOutputs, aSpecialItems, null, aFluidInputs, null, aDuration, aEUt, aSpecialValue, in, out, catalyst, check); mResearchItem=researchItem; } @@ -189,28 +210,28 @@ public class TT_recipe extends GT_Recipe { public TT_assLineRecipe(boolean aOptimize, ItemStack researchItem, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, FluidStack[] aFluidInputs, int aDuration, int aEUt, int aSpecialValue, - cElementalDefinitionStackMap[] in) { + EMConstantStackMap[] in) { this(aOptimize, researchItem, aInputs, aOutputs, aSpecialItems, aFluidInputs, aDuration, aEUt, aSpecialValue, in, null, null,null); } } public static class TT_EMRecipe extends TT_recipe{ - public final iElementalDefinition mResearchEM; - public final GT_Recipe scannerRecipe; + public final IEMDefinition mResearchEM; + public final GT_Recipe scannerRecipe; - public TT_EMRecipe(boolean aOptimize, GT_Recipe scannerRecipe, iElementalDefinition researchEM, - ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, - FluidStack[] aFluidInputs, int aDuration, int aEUt, int aSpecialValue, - cElementalDefinitionStackMap[] in, cElementalDefinitionStackMap[] out, cElementalDefinitionStackMap[] catalyst, IAdditionalCheck check) { + public TT_EMRecipe(boolean aOptimize, GT_Recipe scannerRecipe, IEMDefinition researchEM, + ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, + FluidStack[] aFluidInputs, int aDuration, int aEUt, int aSpecialValue, + EMConstantStackMap[] in, EMConstantStackMap[] out, EMConstantStackMap[] catalyst, IAdditionalCheck check) { super(aOptimize, aInputs, aOutputs, aSpecialItems, null, aFluidInputs, null, aDuration, aEUt, aSpecialValue, in, out, catalyst, check); mResearchEM=researchEM; this.scannerRecipe=scannerRecipe; } - public TT_EMRecipe(boolean aOptimize, GT_Recipe scannerRecipe, iElementalDefinition researchEM, + public TT_EMRecipe(boolean aOptimize, GT_Recipe scannerRecipe, IEMDefinition researchEM, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, FluidStack[] aFluidInputs, int aDuration, int aEUt, int aSpecialValue, - cElementalDefinitionStackMap[] in) { + EMConstantStackMap[] in) { this(aOptimize, scannerRecipe, researchEM, aInputs, aOutputs, aSpecialItems, aFluidInputs, aDuration, aEUt, aSpecialValue, in, null, null,null); } } @@ -219,8 +240,8 @@ public class TT_recipe extends GT_Recipe { public static TT_Recipe_Map_EM<TT_EMRecipe> sCrafterRecipesEM = new TT_Recipe_Map_EM<>("EM Crafter Recipes","gt.recipe.em_crafter",null); public static TT_Recipe_Map_EM<TT_EMRecipe> sMachineRecipesEM = new TT_Recipe_Map_EM<>("EM Machinert Recipe","gt.recipe.em_machinery",null); - private final HashMap<iElementalDefinition,T> mRecipeMap; - public final String mNEIName,mUnlocalizedName,mNEIGUIPath; + private final HashMap<IEMDefinition,T> mRecipeMap; + public final String mNEIName,mUnlocalizedName,mNEIGUIPath; public TT_Recipe_Map_EM(String mNEIName,String mUnlocalizedName,String mNEIGUIPath){ mRecipeMap =new HashMap<>(16); @@ -229,24 +250,10 @@ public class TT_recipe extends GT_Recipe { this.mNEIGUIPath=mNEIGUIPath; } - public T findRecipe(iElementalDefinition stack){ + public T findRecipe(IEMDefinition stack){ return mRecipeMap.get(stack); } - public T findRecipe(ItemStack dataHandler){ - if(dataHandler==null || dataHandler.stackTagCompound==null) { - return null; - } - try { - return mRecipeMap.get(cElementalDefinition.fromNBT(dataHandler.stackTagCompound.getCompoundTag(E_RECIPE_ID))); - }catch (Exception e){ - if (DEBUG_MODE) { - e.printStackTrace(); - } - return null; - } - } - public void add(T recipe){ mRecipeMap.put(recipe.mResearchEM,recipe); } diff --git a/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java b/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java index 0b3f203899..5e1b808255 100644 --- a/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java +++ b/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java @@ -1,9 +1,9 @@ package com.github.technus.tectech.recipe; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDefinitionStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; import com.github.technus.tectech.thing.CustomItemList; import com.github.technus.tectech.thing.item.ElementalDefinitionContainer_EM; import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_crafting; @@ -150,7 +150,7 @@ public class TT_recipeAdder extends GT_RecipeAdder { public static boolean addResearchableEMmachineRecipe( ItemStack aResearchItem, int totalComputationRequired, int computationRequiredPerSec, int researchEUt, int researchAmperage, - ItemStack[] aInputs, FluidStack[] aFluidInputs, cElementalDefinitionStackMap[] eInputs, + ItemStack[] aInputs, FluidStack[] aFluidInputs, EMConstantStackMap[] eInputs, ItemStack aOutput, int machineDuration, int machineEUt, int machineAmperage) { if(aInputs==null) { aInputs = nullItem; @@ -184,7 +184,7 @@ public class TT_recipeAdder extends GT_RecipeAdder { public static boolean addResearchableEMcrafterRecipe( ItemStack aResearchItem, int totalComputationRequired, int computationRequiredPerSec, int researchEUt, int researchAmperage, - cElementalDefinitionStackMap[] eInputs, cElementalDefinitionStackMap[] catalyst, TT_recipe.IAdditionalCheck check, + EMConstantStackMap[] eInputs, EMConstantStackMap[] catalyst, TT_recipe.IAdditionalCheck check, ItemStack aOutput, int crafterDuration, int crafterEUt, int crafterAmperage) { if (aResearchItem==null || totalComputationRequired<=0 || aOutput == null) { return false; @@ -206,8 +206,8 @@ public class TT_recipeAdder extends GT_RecipeAdder { } public static boolean addScannableEMmachineRecipe( - iElementalDefinition aResearchEM, int totalComputationRequired, int computationRequiredPerSec, int researchEUt, int researchAmperage, - ItemStack[] aInputs, FluidStack[] aFluidInputs, cElementalDefinitionStackMap[] eInputs, + IEMDefinition aResearchEM, int totalComputationRequired, int computationRequiredPerSec, int researchEUt, int researchAmperage, + ItemStack[] aInputs, FluidStack[] aFluidInputs, EMConstantStackMap[] eInputs, ItemStack aOutput, int machineDuration, int machineEUt, int machineAmperage) { if(aInputs==null) { aInputs = nullItem; @@ -234,7 +234,7 @@ public class TT_recipeAdder extends GT_RecipeAdder { computationRequiredPerSec = Short.MAX_VALUE; } ItemStack placeholder=new ItemStack(ElementalDefinitionContainer_EM.INSTANCE); - ElementalDefinitionContainer_EM.setContent(placeholder,new cElementalDefinitionStackMap(new cElementalDefinitionStack(aResearchEM,1))); + ElementalDefinitionContainer_EM.setContent(placeholder,new EMConstantStackMap(new EMDefinitionStack(aResearchEM,1))); GT_Recipe thisRecipe=TT_recipe.GT_Recipe_MapTT.sScannableFakeRecipes.addFakeRecipe(false, new ItemStack[]{placeholder}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Writes Research result for "+ GT_MetaTileEntity_EM_machine.machine)}, null, null, totalComputationRequired, researchEUt, researchAmperage| computationRequiredPerSec<<16); TT_recipe.TT_Recipe_Map_EM.sMachineRecipesEM.add(new TT_recipe.TT_EMRecipe(false,thisRecipe,aResearchEM,aInputs,new ItemStack[]{aOutput},new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Reads Research result")}, aFluidInputs,machineDuration,machineEUt,machineAmperage,eInputs)); @@ -242,8 +242,8 @@ public class TT_recipeAdder extends GT_RecipeAdder { } public static boolean addScannableEMcrafterRecipe( - iElementalDefinition aResearchEM, int totalComputationRequired, int computationRequiredPerSec, int researchEUt, int researchAmperage, - cElementalDefinitionStackMap[] eInputs, cElementalDefinitionStackMap[] catalyst, TT_recipe.IAdditionalCheck check, + IEMDefinition aResearchEM, int totalComputationRequired, int computationRequiredPerSec, int researchEUt, int researchAmperage, + EMConstantStackMap[] eInputs, EMConstantStackMap[] catalyst, TT_recipe.IAdditionalCheck check, ItemStack aOutput, int crafterDuration, int crafterEUt, int crafterAmperage) { if (aResearchEM==null || totalComputationRequired<=0 || aOutput == null) { return false; @@ -259,7 +259,7 @@ public class TT_recipeAdder extends GT_RecipeAdder { computationRequiredPerSec = Short.MAX_VALUE; } ItemStack placeholder=new ItemStack(ElementalDefinitionContainer_EM.INSTANCE); - ElementalDefinitionContainer_EM.setContent(placeholder,new cElementalDefinitionStackMap(new cElementalDefinitionStack(aResearchEM,1))); + ElementalDefinitionContainer_EM.setContent(placeholder,new EMConstantStackMap(new EMDefinitionStack(aResearchEM,1))); GT_Recipe thisRecipe=TT_recipe.GT_Recipe_MapTT.sScannableFakeRecipes.addFakeRecipe(false, new ItemStack[]{placeholder}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Writes Research result for "+ GT_MetaTileEntity_EM_crafting.crafter)}, null, null, totalComputationRequired, researchEUt, researchAmperage| computationRequiredPerSec<<16); TT_recipe.TT_Recipe_Map_EM.sCrafterRecipesEM.add(new TT_recipe.TT_EMRecipe(false,thisRecipe,aResearchEM,null,new ItemStack[]{aOutput},new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Reads Research result")}, null,crafterDuration,crafterEUt,crafterAmperage,eInputs,null,catalyst,check)); diff --git a/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java b/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java index d34d12c754..42fb14f55d 100644 --- a/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java +++ b/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java @@ -13,7 +13,7 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import static com.github.technus.tectech.Reference.MODID; -import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; +import static com.github.technus.tectech.TecTech.creativeTabTecTech; /** * Created by danie_000 on 17.12.2016. diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java index d2c34941ef..62221d5bd4 100644 --- a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java @@ -17,7 +17,6 @@ import net.minecraft.world.IBlockAccess; import java.util.List; -import static com.github.technus.tectech.TecTech.tectechTexturePage1; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; /** diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsNH.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsNH.java index bac2dfb9ac..2a8bb37a0b 100644 --- a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsNH.java +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsNH.java @@ -10,7 +10,7 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; +import static com.github.technus.tectech.TecTech.creativeTabTecTech; import static com.github.technus.tectech.thing.metaTileEntity.Textures.*; /** diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsTT.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsTT.java index eb590ab2e2..de72db417e 100644 --- a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsTT.java +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsTT.java @@ -17,8 +17,8 @@ import net.minecraft.world.IBlockAccess; import java.util.List; +import static com.github.technus.tectech.TecTech.creativeTabTecTech; import static com.github.technus.tectech.TecTech.tectechTexturePage1; -import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; /** * Created by danie_000 on 03.10.2016. diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_HintTT.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_HintTT.java deleted file mode 100644 index c65870eeb7..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_HintTT.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.github.technus.tectech.thing.casing; - -import com.github.technus.tectech.Reference; -import com.github.technus.tectech.thing.CustomItemList; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.util.GT_LanguageManager; -import gregtech.common.blocks.GT_Block_Casings_Abstract; -import gregtech.common.blocks.GT_Material_Casings; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; - -import java.util.List; - -import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; - -/** - * Created by danie_000 on 03.10.2016. - */ -public class GT_Block_HintTT extends GT_Block_Casings_Abstract { - private static IIcon[] hint = new IIcon[16]; - - public GT_Block_HintTT() { - super(GT_Item_HintTT.class, "gt.blockhintTT", GT_Material_Casings.INSTANCE); - setCreativeTab(creativeTabTecTech); - - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Hint 1 dot");//id is -1 - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Hint 2 dots"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Hint 3 dots"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Hint 4 dots"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Hint 5 dots"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Hint 6 dots"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Hint 7 dots"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Hint 8 dots"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Hint 9 dots"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Hint 10 dots"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Hint 11 dots"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Hint 12 dots"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Hint general"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Hint air"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Hint no air"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Hint error"); - - - CustomItemList.hint_0.set(new ItemStack(this, 1, 0)); - CustomItemList.hint_1.set(new ItemStack(this, 1, 1)); - CustomItemList.hint_2.set(new ItemStack(this, 1, 2)); - CustomItemList.hint_3.set(new ItemStack(this, 1, 3)); - CustomItemList.hint_4.set(new ItemStack(this, 1, 4)); - CustomItemList.hint_5.set(new ItemStack(this, 1, 5)); - CustomItemList.hint_6.set(new ItemStack(this, 1, 6)); - CustomItemList.hint_7.set(new ItemStack(this, 1, 7)); - CustomItemList.hint_8.set(new ItemStack(this, 1, 8)); - CustomItemList.hint_9.set(new ItemStack(this, 1, 9)); - CustomItemList.hint_10.set(new ItemStack(this, 1, 10)); - CustomItemList.hint_11.set(new ItemStack(this, 1, 11)); - CustomItemList.hint_general.set(new ItemStack(this, 1, 12)); - CustomItemList.hint_air.set(new ItemStack(this, 1, 13)); - CustomItemList.hint_noAir.set(new ItemStack(this, 1, 14)); - CustomItemList.hint_error.set(new ItemStack(this, 1, 15)); - } - - @Override - public void registerBlockIcons(IIconRegister aIconRegister) { - //super.registerBlockIcons(aIconRegister); - hint[0] = aIconRegister.registerIcon(Reference.MODID+":iconsets/HINT_0"); - hint[1] = aIconRegister.registerIcon(Reference.MODID+":iconsets/HINT_1"); - hint[2] = aIconRegister.registerIcon(Reference.MODID+":iconsets/HINT_2"); - hint[3] = aIconRegister.registerIcon(Reference.MODID+":iconsets/HINT_3"); - hint[4] = aIconRegister.registerIcon(Reference.MODID+":iconsets/HINT_4"); - hint[5] = aIconRegister.registerIcon(Reference.MODID+":iconsets/HINT_5"); - hint[6] = aIconRegister.registerIcon(Reference.MODID+":iconsets/HINT_6"); - hint[7] = aIconRegister.registerIcon(Reference.MODID+":iconsets/HINT_7"); - hint[8] = aIconRegister.registerIcon(Reference.MODID+":iconsets/HINT_8"); - hint[9] = aIconRegister.registerIcon(Reference.MODID+":iconsets/HINT_9"); - hint[10] = aIconRegister.registerIcon(Reference.MODID+":iconsets/HINT_10"); - hint[11] = aIconRegister.registerIcon(Reference.MODID+":iconsets/HINT_11"); - hint[12] = aIconRegister.registerIcon(Reference.MODID+":iconsets/HINT_DEFAULT"); - hint[13] = aIconRegister.registerIcon(Reference.MODID+":iconsets/HINT_AIR"); - hint[14] = aIconRegister.registerIcon(Reference.MODID+":iconsets/HINT_NOAIR"); - hint[15] = aIconRegister.registerIcon(Reference.MODID+":iconsets/HINT_ERROR"); - } - - @Override - public IIcon getIcon(int aSide, int aMeta) { - return hint[aMeta]; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int aSide) { - int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); - return getIcon(aSide, tMeta); - } - - @Override - public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) { - for (int i = 0; i <= 15; i++) { - aList.add(new ItemStack(aItem, 1, i)); - } - } -} diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_HintTT.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_HintTT.java deleted file mode 100644 index 426e7d569b..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_HintTT.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.github.technus.tectech.thing.casing; - -import gregtech.common.blocks.GT_Item_Casings_Abstract; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; - -import java.util.List; - -import static com.github.technus.tectech.util.CommonValues.TEC_MARK_GENERAL; -import static net.minecraft.util.StatCollector.translateToLocal; - -/** - * Created by danie_000 on 03.10.2016. - */ -public class GT_Item_HintTT extends GT_Item_Casings_Abstract { - public GT_Item_HintTT(Block par1) { - super(par1); - } - - @Override - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - aList.add(TEC_MARK_GENERAL); - aList.add(translateToLocal("gt.blockhintTT.desc.0"));//Helps while building - switch (aStack.getItemDamage()) { - case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: - aList.add(EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockhintTT.desc.1"));//Placeholder for a certain group. - break; - case 12: - aList.add(EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockhintTT.desc.2"));//General placeholder. - break; - case 13: - aList.add(EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockhintTT.desc.3"));//Make sure it contains Air material. - break; - case 14: - aList.add(EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockhintTT.desc.4"));//Make sure it does not contain Air material. - break; - case 15: - aList.add(EnumChatFormatting.BLUE.toString() + translateToLocal("gt.blockhintTT.desc.5"));//ERROR, what did u expect? - break; - default://WTF? - aList.add("Damn son where did you get that!?"); - aList.add(EnumChatFormatting.BLUE.toString() + "From outer space... I guess..."); - } - } -} diff --git a/src/main/java/com/github/technus/tectech/thing/casing/TT_Container_Casings.java b/src/main/java/com/github/technus/tectech/thing/casing/TT_Container_Casings.java index 071a4ae28f..40bb20d545 100644 --- a/src/main/java/com/github/technus/tectech/thing/casing/TT_Container_Casings.java +++ b/src/main/java/com/github/technus/tectech/thing/casing/TT_Container_Casings.java @@ -7,7 +7,7 @@ import net.minecraft.block.Block; */ public final class TT_Container_Casings { public static Block sBlockCasingsTT; - public static Block sHintCasingsTT; + public static Block sBlockCasingsBA0; public static Block sBlockCasingsNH; diff --git a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_EnderFluidLink.java b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_EnderFluidLink.java index d6b5e28b18..315c5e5fff 100644 --- a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_EnderFluidLink.java +++ b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_EnderFluidLink.java @@ -3,6 +3,7 @@ package com.github.technus.tectech.thing.cover; import com.github.technus.tectech.loader.NetworkDispatcher; import com.github.technus.tectech.mechanics.enderStorage.EnderLinkCoverMessage; import com.github.technus.tectech.mechanics.enderStorage.EnderLinkTag; +import com.github.technus.tectech.util.TT_Utility; import eu.usrv.yamcore.auxiliary.PlayerChatHelper; import gregtech.api.enums.GT_Values; import gregtech.api.gui.GT_GUICover; @@ -25,7 +26,8 @@ import net.minecraftforge.fluids.IFluidHandler; import java.awt.*; import java.util.UUID; -import static com.github.technus.tectech.mechanics.enderStorage.EnderWorldSavedData.*; +import static com.github.technus.tectech.mechanics.enderStorage.EnderWorldSavedData.getEnderFluidContainer; +import static com.github.technus.tectech.mechanics.enderStorage.EnderWorldSavedData.getEnderLinkTag; public class GT_Cover_TM_EnderFluidLink extends GT_CoverBehavior { private static final int L_PER_TICK = 8000; @@ -325,7 +327,7 @@ public class GT_Cover_TM_EnderFluidLink extends GT_CoverBehavior { @Override public void resetTextBox(GT_GuiIntegerTextBox box) { //Solid White becomes: #FFFFFFFF - box.setText("#" + String.format("%08X", tag.getColorInt())); + box.setText("#" + TT_Utility.formatNumberIntHex(tag.getColorInt())); } public void resetColorField() { diff --git a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java index a573ed740b..33330b521a 100644 --- a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java @@ -6,7 +6,7 @@ import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; -import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.*; +import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.teslaSimpleNodeSetAdd; import static ic2.api.info.Info.DMG_ELECTRIC; public class GT_Cover_TM_TeslaCoil extends GT_CoverBehavior { diff --git a/src/main/java/com/github/technus/tectech/thing/item/AvrProgrammer.java b/src/main/java/com/github/technus/tectech/thing/item/AvrProgrammer.java index 90f3312342..cc071d2326 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/AvrProgrammer.java +++ b/src/main/java/com/github/technus/tectech/thing/item/AvrProgrammer.java @@ -28,7 +28,7 @@ import java.io.OutputStream; import java.util.List; import static com.github.technus.tectech.Reference.MODID; -import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; +import static com.github.technus.tectech.TecTech.creativeTabTecTech; import static net.minecraft.util.StatCollector.translateToLocal; @Optional.InterfaceList( diff --git a/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java b/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java deleted file mode 100644 index 81fec52ebd..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.github.technus.tectech.thing.item; - -import com.github.technus.tectech.mechanics.constructable.ConstructableUtility; -import com.github.technus.tectech.util.CommonValues; -import cpw.mods.fml.common.registry.GameRegistry; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; - -import java.util.List; - -import static com.github.technus.tectech.Reference.MODID; -import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; -import static net.minecraft.util.StatCollector.translateToLocal; - -/** - * Created by Tec on 15.03.2017. - */ -@Deprecated -public final class ConstructableTriggerItem extends Item { - public static ConstructableTriggerItem INSTANCE; - - private ConstructableTriggerItem() { - setUnlocalizedName("em.constructable"); - setTextureName(MODID + ":itemConstructable"); - setCreativeTab(creativeTabTecTech); - } - - @Override - public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { - return ConstructableUtility.handle(aStack, aPlayer, aWorld, aX, aY, aZ, aSide); - } - - @Override - public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { - aList.add(CommonValues.TEC_MARK_GENERAL); - aList.add(translateToLocal("item.em.constructable.desc.0"));//Triggers Constructable Interface - aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.constructable.desc.1"));//Shows multiblock construction details, - aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.constructable.desc.2"));//just Use on a multiblock controller. - aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.constructable.desc.3"));//(Sneak Use in creative to build) - aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.constructable.desc.4"));//Quantity affects tier/mode/type - } - - public static void run() { - INSTANCE = new ConstructableTriggerItem(); - GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); - } -} diff --git a/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java b/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java index 6850b24e0f..c19ec6dda1 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java @@ -1,14 +1,15 @@ package com.github.technus.tectech.thing.item; -import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.font.TecTechFontRender; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.iElementalInstanceContainer; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.tElementalException; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; +import com.github.technus.tectech.mechanics.elementalMatter.core.IEMContainer; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; import com.github.technus.tectech.thing.item.renderElemental.IElementalItem; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -26,13 +27,11 @@ import net.minecraft.world.World; import java.util.Collections; import java.util.List; -import java.util.TreeSet; import static com.github.technus.tectech.Reference.MODID; +import static com.github.technus.tectech.TecTech.creativeTabEM; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT_144; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.*; import static cpw.mods.fml.relauncher.Side.CLIENT; import static net.minecraft.util.StatCollector.translateToLocal; @@ -40,7 +39,6 @@ import static net.minecraft.util.StatCollector.translateToLocal; * Created by Tec on 15.03.2017. */ public final class DebugElementalInstanceContainer_EM extends Item implements IElementalItem { - public static final TreeSet<iElementalDefinition> STACKS_REGISTERED =new TreeSet<>(); public static DebugElementalInstanceContainer_EM INSTANCE; @@ -48,37 +46,35 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE setMaxStackSize(1); setUnlocalizedName("em.debugContainer"); setTextureName(MODID + ":itemDebugContainer"); - setCreativeTab(creativeTabTecTech); + setCreativeTab(creativeTabEM); } @Override public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { - NBTTagCompound tNBT = aStack.getTagCompound(); - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + NBTTagCompound tNBT = aStack.getTagCompound(); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (aPlayer instanceof EntityPlayerMP) { aStack.stackSize = 1; if (tTileEntity instanceof IGregTechTileEntity) { IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); - if (metaTE instanceof iElementalInstanceContainer) { - cElementalInstanceStackMap content = ((iElementalInstanceContainer) metaTE).getContainerHandler(); + if (metaTE instanceof IEMContainer) { + EMInstanceStackMap content = ((IEMContainer) metaTE).getContentHandler(); if (tNBT.hasKey("content")) { try { - content.putUnifyAll(cElementalInstanceStackMap.fromNBT(tNBT.getCompoundTag("content"))); - } catch (tElementalException e) { + content.putUnifyAll(EMInstanceStackMap.fromNBT(TecTech.definitionsRegistry, tNBT.getCompoundTag("content"))); + } catch (EMException e) { if (DEBUG_MODE) { e.printStackTrace(); } return true; } - ((iElementalInstanceContainer) metaTE).purgeOverflow(); + ((IEMContainer) metaTE).purgeOverflow(); tNBT.removeTag("content"); tNBT.removeTag("symbols"); - tNBT.removeTag("info"); } else if (content.hasStacks()) { - ((iElementalInstanceContainer) metaTE).purgeOverflow(); - tNBT.setTag("info", content.getInfoNBT()); - tNBT.setTag("content", content.toNBT()); - tNBT.setTag("symbols", content.getShortSymbolsNBT()); + ((IEMContainer) metaTE).purgeOverflow(); + tNBT.setTag("content", content.toNBT(TecTech.definitionsRegistry)); + tNBT.setTag("symbols", TT_Utility.packStrings(content.getShortSymbolsInfo())); content.clear(); } return true; @@ -88,30 +84,14 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE return aPlayer instanceof EntityPlayerMP; } - public ItemStack setContent(ItemStack aStack,cElementalInstanceStackMap content){ + public ItemStack setContent(ItemStack aStack, EMInstanceStackMap content) { NBTTagCompound tNBT = aStack.getTagCompound(); - if(tNBT==null){ - tNBT=new NBTTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); aStack.setTagCompound(tNBT); } - if (tNBT.hasKey("content")) { - try { - content.putUnifyAll(cElementalInstanceStackMap.fromNBT(tNBT.getCompoundTag("content"))); - } catch (tElementalException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return aStack; - } - tNBT.removeTag("content"); - tNBT.removeTag("info"); - tNBT.removeTag("symbols"); - } else if (content.hasStacks()) { - tNBT.setTag("info", content.getInfoNBT()); - tNBT.setTag("content", content.toNBT()); - tNBT.setTag("symbols", content.getShortSymbolsNBT()); - content.clear(); - } + tNBT.setTag("content", content.toNBT(TecTech.definitionsRegistry)); + tNBT.setTag("symbols", TT_Utility.packStrings(content.getShortSymbolsInfo())); return aStack; } @@ -120,14 +100,18 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE aList.add(CommonValues.TEC_MARK_EM); try { NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT != null && tNBT.hasKey("info")) { + if (tNBT != null && tNBT.hasKey("content")) { aList.add(translateToLocal("item.em.debugContainer.desc.0") + ": ");//Contains - Collections.addAll(aList, Util.infoFromNBT(tNBT.getCompoundTag("info"))); + EMInstanceStackMap content = EMInstanceStackMap.fromNBT(TecTech.definitionsRegistry, tNBT.getCompoundTag("content")); + Collections.addAll(aList, content.getElementalInfo()); } else { aList.add(translateToLocal("item.em.debugContainer.desc.1"));//Container for elemental matter - aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.debugContainer.desc.2"));//Right click on elemental hatches } + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.debugContainer.desc.2"));//Right click on elemental hatches } catch (Exception e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } aList.add(translateToLocal("item.em.debugContainer.desc.3"));//---Unexpected Termination--- } } @@ -142,25 +126,13 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE ItemStack that = new ItemStack(this, 1); that.setTagCompound(new NBTTagCompound()); list.add(that); - for(iElementalDefinition definition: STACKS_REGISTERED){ - list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getName()+" 1 mol"),new cElementalInstanceStackMap(new cElementalInstanceStack(definition, AVOGADRO_CONSTANT)))); - list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getName()+" 144 mol"),new cElementalInstanceStackMap(new cElementalInstanceStack(definition, AVOGADRO_CONSTANT_144)))); - list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getName()+" 1000 mol"),new cElementalInstanceStackMap(new cElementalInstanceStack(definition, AVOGADRO_CONSTANT *1000)))); - } - } - - @Override - public String getSymbol(ItemStack aStack, int index) { - try { - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT != null && tNBT.hasKey("symbols")) { - String[] strings=Util.infoFromNBT(tNBT.getCompoundTag("symbols")); - return strings[index%strings.length]; - } else { - return null; - } - } catch (Exception e) { - return "#!"; + for (IEMDefinition definition : TecTech.definitionsRegistry.getStacksRegisteredForDisplay()) { + list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName() + " " + 1 + " " + translateToLocal("tt.keyword.unit.mbMols")), + new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_MATERIAL_AMOUNT)))); + list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName() + " " + 1 + " " + translateToLocal("tt.keyword.unit.itemMols")), + new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_ITEM)))); + list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName() + " " + 1000 + " " + translateToLocal("tt.keyword.unit.mbMols")), + new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_1k)))); } } diff --git a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java index fa1c25cbf5..85a853e8aa 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java @@ -1,11 +1,13 @@ package com.github.technus.tectech.thing.item; -import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.font.TecTechFontRender; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDefinitionStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.tElementalException; +import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMDefinitionStackMap; import com.github.technus.tectech.thing.item.renderElemental.IElementalItem; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.gui.FontRenderer; @@ -19,8 +21,8 @@ import java.util.Collections; import java.util.List; import static com.github.technus.tectech.Reference.MODID; +import static com.github.technus.tectech.TecTech.creativeTabEM; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; import static cpw.mods.fml.relauncher.Side.CLIENT; import static net.minecraft.util.StatCollector.translateToLocal; @@ -34,36 +36,20 @@ public final class ElementalDefinitionContainer_EM extends Item implements IElem setMaxStackSize(1); setUnlocalizedName("em.definitionContainer"); setTextureName(MODID + ":itemDefinitionContainer"); - setCreativeTab(creativeTabTecTech); + setCreativeTab(creativeTabEM); } - //return previous thing - public static cElementalDefinitionStackMap setContent(ItemStack containerItem, cElementalDefinitionStackMap definitions){ - if(containerItem.getItem() instanceof ElementalDefinitionContainer_EM) { - NBTTagCompound tNBT = containerItem.stackTagCompound; - if (tNBT == null) { - tNBT = containerItem.stackTagCompound = new NBTTagCompound(); - } - - cElementalDefinitionStackMap oldMap=null; - if (tNBT.hasKey("content")) { - try { - oldMap=cElementalDefinitionStackMap.fromNBT(tNBT.getCompoundTag("content")); - } catch (tElementalException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - } - tNBT.setTag("info", definitions.getInfoNBT()); - tNBT.setTag("content", definitions.toNBT()); - tNBT.setTag("symbols",definitions.getShortSymbolsNBT()); - return oldMap; + public static void setContent(ItemStack aStack, EMConstantStackMap definitions){ + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); + aStack.setTagCompound(tNBT); } - return null; + tNBT.setTag("content", definitions.toNBT(TecTech.definitionsRegistry)); + tNBT.setTag("symbols", TT_Utility.packStrings(definitions.getShortSymbolsInfo())); } - public static cElementalDefinitionStackMap getContent(ItemStack containerItem){ + public static EMConstantStackMap getContent(ItemStack containerItem){ if(containerItem.getItem() instanceof ElementalDefinitionContainer_EM){ NBTTagCompound tNBT = containerItem.stackTagCompound; @@ -71,8 +57,8 @@ public final class ElementalDefinitionContainer_EM extends Item implements IElem return null; } try { - return cElementalDefinitionStackMap.fromNBT(tNBT.getCompoundTag("content")); - } catch (tElementalException e) { + return EMConstantStackMap.fromNBT(TecTech.definitionsRegistry,tNBT.getCompoundTag("content")); + } catch (EMException e) { if (DEBUG_MODE) { e.printStackTrace(); } @@ -81,24 +67,23 @@ public final class ElementalDefinitionContainer_EM extends Item implements IElem return null; } - public static cElementalDefinitionStackMap clearContent(ItemStack containerItem){ + public static EMConstantStackMap clearContent(ItemStack containerItem){ if(containerItem.getItem() instanceof ElementalDefinitionContainer_EM){ NBTTagCompound tNBT = containerItem.stackTagCompound; if (tNBT == null) { return null; } - cElementalDefinitionStackMap oldMap=null; + EMConstantStackMap oldMap =null; if (tNBT.hasKey("content")) { try { - oldMap=cElementalDefinitionStackMap.fromNBT(tNBT.getCompoundTag("content")); - } catch (tElementalException e) { + oldMap= EMConstantStackMap.fromNBT(TecTech.definitionsRegistry,tNBT.getCompoundTag("content")); + } catch (EMException e) { if (DEBUG_MODE) { e.printStackTrace(); } } } - tNBT.removeTag("info"); tNBT.removeTag("content"); tNBT.removeTag("symbols"); return oldMap; @@ -111,9 +96,10 @@ public final class ElementalDefinitionContainer_EM extends Item implements IElem aList.add(CommonValues.TEC_MARK_EM); try { NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT != null && tNBT.hasKey("info")) { + if (tNBT != null && tNBT.hasKey("content")) { aList.add(translateToLocal("item.em.definitionContainer.desc.0") + ": ");//Should Contain - Collections.addAll(aList, Util.infoFromNBT(tNBT.getCompoundTag("info"))); + EMDefinitionStackMap content = EMDefinitionStackMap.fromNBT(TecTech.definitionsRegistry, tNBT.getCompoundTag("content")); + Collections.addAll(aList, content.getElementalInfo()); } else { aList.add(translateToLocal("item.em.definitionContainer.desc.1"));//Recipe Hint } @@ -135,21 +121,6 @@ public final class ElementalDefinitionContainer_EM extends Item implements IElem } @Override - public String getSymbol(ItemStack aStack, int index) { - try { - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT != null && tNBT.hasKey("symbols")) { - String[] strings=Util.infoFromNBT(tNBT.getCompoundTag("symbols")); - return strings[index%strings.length]; - } else { - return null; - } - } catch (Exception e) { - return "#!"; - } - } - - @Override @SideOnly(CLIENT) public FontRenderer getFontRenderer(ItemStack stack) { return TecTechFontRender.INSTANCE; diff --git a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java index c951229c92..976b034455 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java @@ -1,13 +1,11 @@ package com.github.technus.tectech.thing.item; -import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.font.TecTechFontRender; import com.github.technus.tectech.loader.gui.ModGuiHandler; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; import com.github.technus.tectech.thing.CustomItemList; -import com.github.technus.tectech.thing.item.renderElemental.IElementalItem; +import com.github.technus.tectech.util.CommonValues; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -22,17 +20,18 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.world.World; +import java.util.ArrayList; import java.util.List; import static com.github.technus.tectech.Reference.MODID; -import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; +import static com.github.technus.tectech.TecTech.creativeTabTecTech; import static cpw.mods.fml.relauncher.Side.CLIENT; import static net.minecraft.util.StatCollector.translateToLocal; /** * Created by Tec on 15.03.2017. */ -public final class ElementalDefinitionScanStorage_EM extends Item implements IElementalItem { +public final class ElementalDefinitionScanStorage_EM extends Item { public static ElementalDefinitionScanStorage_EM INSTANCE; public static IIcon offline, online; @@ -44,14 +43,14 @@ public final class ElementalDefinitionScanStorage_EM extends Item implements IEl } //return previous thing - public static void setContent(ItemStack containerItem, cElementalInstanceStackMap definitions, int[] detailsOnDepthLevels){ - if(containerItem.getItem() instanceof ElementalDefinitionScanStorage_EM) { - if (containerItem.stackTagCompound == null) { - containerItem.stackTagCompound = new NBTTagCompound(); - } - containerItem.stackTagCompound.setTag("elementalInfo", definitions.getScanInfoNBT(detailsOnDepthLevels)); - containerItem.stackTagCompound.setTag("symbols",definitions.getScanShortSymbolsNBT(detailsOnDepthLevels)); + public static void setContent(ItemStack aStack, EMInstanceStackMap instances, int[] detailsOnDepthLevels){ + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); + aStack.setTagCompound(tNBT); } + tNBT.setTag("content", instances.toNBT(TecTech.definitionsRegistry)); + tNBT.setIntArray("scanConfiguration", detailsOnDepthLevels); } public static void clearContent(ItemStack containerItem){ @@ -63,9 +62,10 @@ public final class ElementalDefinitionScanStorage_EM extends Item implements IEl } } - public static String[] getLines(ItemStack containerItem){ - if(containerItem.stackTagCompound!=null && containerItem.stackTagCompound.hasKey("elementalInfo")) { - return Util.infoFromNBT(containerItem.stackTagCompound.getCompoundTag("elementalInfo")); + public static ArrayList<String> getLines(ItemStack containerItem){ + if(containerItem.stackTagCompound!=null && containerItem.stackTagCompound.hasKey("content")) { + EMInstanceStackMap contenet = EMInstanceStackMap.fromNBT(TecTech.definitionsRegistry, containerItem.stackTagCompound.getCompoundTag("contenet")); + return contenet.getScanInfo(containerItem.stackTagCompound.getIntArray("scanConfiguration")); } return null; } @@ -73,19 +73,11 @@ public final class ElementalDefinitionScanStorage_EM extends Item implements IEl @Override public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { aList.add(CommonValues.TEC_MARK_EM); - try { - if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("elementalInfo")) { - aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.definitionScanStorage.desc.0"));//Contains scan result - aList.add(translateToLocal("item.em.definitionScanStorage.desc.1"));//Use to read - //if(DEBUG_MODE) { - // aList.add("DEBUG MODE INFO - U CHEATER"); - // Collections.addAll(aList, Util.infoFromNBT(aStack.stackTagCompound.getCompoundTag("elementalInfo"))); - //} - } else { - aList.add(translateToLocal("item.em.definitionScanStorage.desc.2"));//Storage for matter scan data - } - } catch (Exception e) { - aList.add(translateToLocal("item.em.definitionScanStorage.desc.3"));//---Unexpected Termination--- + if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("content")) { + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.definitionScanStorage.desc.0"));//Contains scan result + aList.add(translateToLocal("item.em.definitionScanStorage.desc.1"));//Use to read + } else { + aList.add(translateToLocal("item.em.definitionScanStorage.desc.2"));//Storage for matter scan data } } @@ -105,19 +97,13 @@ public final class ElementalDefinitionScanStorage_EM extends Item implements IEl @Override public IIcon getIconIndex(ItemStack itemStack) { NBTTagCompound tagCompound=itemStack.stackTagCompound; - if(tagCompound!=null && tagCompound.hasKey("elementalInfo")) { - return online; - } - return offline; + return tagCompound != null && tagCompound.hasKey("content") ? online : offline; } @Override public IIcon getIcon(ItemStack itemStack, int pass) { NBTTagCompound tagCompound=itemStack.stackTagCompound; - if(tagCompound!=null && tagCompound.hasKey("elementalInfo")) { - return online; - } - return offline; + return tagCompound != null && tagCompound.hasKey("content") ? online : offline; } @Override @@ -130,7 +116,7 @@ public final class ElementalDefinitionScanStorage_EM extends Item implements IEl public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { if(world.isRemote){ NBTTagCompound tagCompound=itemStack.stackTagCompound; - if(tagCompound!=null && tagCompound.hasKey("elementalInfo")) { + if(tagCompound!=null && tagCompound.hasKey("content")) { player.openGui(TecTech.instance, ModGuiHandler.SCAN_DISPLAY_SCREEN_ID, world, 0, 0, 0); } } @@ -138,21 +124,6 @@ public final class ElementalDefinitionScanStorage_EM extends Item implements IEl } @Override - public String getSymbol(ItemStack aStack, int index) { - try { - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT != null && tNBT.hasKey("symbols")) { - String[] strings=Util.infoFromNBT(tNBT.getCompoundTag("symbols")); - return strings[index%strings.length]; - } else { - return null; - } - } catch (Exception e) { - return "#!"; - } - } - - @Override @SideOnly(CLIENT) public FontRenderer getFontRenderer(ItemStack stack) { return TecTechFontRender.INSTANCE; diff --git a/src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java b/src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java index f4531a248b..735b2ef0f5 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java +++ b/src/main/java/com/github/technus/tectech/thing/item/EuMeterGT.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.item; -import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.Reference; +import com.github.technus.tectech.util.CommonValues; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.BaseMetaPipeEntity; @@ -22,7 +22,7 @@ import java.util.ArrayList; import java.util.List; import static com.github.technus.tectech.Reference.MODID; -import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; +import static com.github.technus.tectech.TecTech.creativeTabTecTech; import static net.minecraft.util.StatCollector.translateToLocal; import static net.minecraft.util.StatCollector.translateToLocalFormatted; diff --git a/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java b/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java deleted file mode 100644 index 39193fd598..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.github.technus.tectech.thing.item; - -import com.github.technus.tectech.mechanics.alignment.AlignmentUtility; -import com.github.technus.tectech.util.CommonValues; -import cpw.mods.fml.common.registry.GameRegistry; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; - -import java.util.List; - -import static com.github.technus.tectech.Reference.MODID; -import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; -import static net.minecraft.util.StatCollector.translateToLocal; - -/** - * Created by Tec on 15.03.2017. - */ -@Deprecated -public final class FrontRotationTriggerItem extends Item { - public static FrontRotationTriggerItem INSTANCE; - - private FrontRotationTriggerItem() { - setMaxStackSize(1); - setUnlocalizedName("em.frontRotate"); - setTextureName(MODID + ":itemFrontRotate"); - setCreativeTab(creativeTabTecTech); - } - - @Override - public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { - return AlignmentUtility.handle(aPlayer,aWorld,aX,aY,aZ); - } - - @Override - public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { - aList.add(CommonValues.TEC_MARK_GENERAL); - aList.add(translateToLocal("item.em.frontRotate.desc.0"));//Triggers Front Rotation Interface - aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.frontRotate.desc.1"));//Rotates only the front panel, - aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.frontRotate.desc.2"));//which allows structure rotation. - } - - public static void run() { - INSTANCE = new FrontRotationTriggerItem(); - GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); - } -} diff --git a/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java b/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java index 1d1da74a7a..a384d3998a 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java +++ b/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java @@ -1,10 +1,10 @@ package com.github.technus.tectech.thing.item; -import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Param; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_ParamText; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -25,7 +25,7 @@ import net.minecraft.world.World; import java.util.List; import static com.github.technus.tectech.Reference.MODID; -import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; +import static com.github.technus.tectech.TecTech.creativeTabTecTech; import static com.github.technus.tectech.thing.CustomItemList.parametrizerMemory; import static net.minecraft.util.StatCollector.translateToLocal; @@ -33,8 +33,8 @@ import static net.minecraft.util.StatCollector.translateToLocal; * Created by Tec on 15.03.2017. */ public final class ParametrizerMemoryCard extends Item { - public static ParametrizerMemoryCard INSTANCE; - private static IIcon locked, unlocked; + public static ParametrizerMemoryCard INSTANCE; + private static IIcon locked, unlocked; private ParametrizerMemoryCard() { setMaxStackSize(1); @@ -142,20 +142,16 @@ public final class ParametrizerMemoryCard extends Item { aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.parametrizerMemoryCard.desc.3"));//Sneak right click to lock/unlock double temp; - if(tNBT!=null && tNBT.hasKey("param")) { - aList.add("Hatch ID: "+EnumChatFormatting.AQUA + tNBT.getInteger("param")); - temp=tNBT.getInteger("value0D"); - aList.add("Value 0D: "+EnumChatFormatting.AQUA + temp); - aList.add("Value 0B: "+EnumChatFormatting.AQUA + Util.longBitsToShortString(Double.doubleToLongBits(temp))); - if(tNBT.hasKey("value0s")) { - aList.add("Value 0s: " + EnumChatFormatting.AQUA + tNBT.getString("value0s")); - } - temp=tNBT.getInteger("value1D"); - aList.add("Value 1D: "+EnumChatFormatting.AQUA + temp); - aList.add("Value 1B: "+EnumChatFormatting.AQUA + Util.longBitsToShortString(Double.doubleToLongBits(temp))); - if(tNBT.hasKey("value1s")) { - aList.add("Value 1s: " + EnumChatFormatting.AQUA + tNBT.getString("value1s")); - } + if (tNBT != null && tNBT.hasKey("param")) { + aList.add("Hatch ID: " + EnumChatFormatting.AQUA + tNBT.getInteger("param")); + temp = tNBT.getInteger("value0D"); + aList.add("Value 0D: " + EnumChatFormatting.AQUA + temp); + aList.add("Value 0B: " + EnumChatFormatting.AQUA + TT_Utility.longBitsToShortString(Double.doubleToLongBits(temp))); + aList.add("Value 0s: " + EnumChatFormatting.AQUA + tNBT.getString("value0s")); + temp = tNBT.getInteger("value1D"); + aList.add("Value 1D: " + EnumChatFormatting.AQUA + temp); + aList.add("Value 1B: " + EnumChatFormatting.AQUA + TT_Utility.longBitsToShortString(Double.doubleToLongBits(temp))); + aList.add("Value 1s: " + EnumChatFormatting.AQUA + tNBT.getString("value1s")); } } diff --git a/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCapacitor.java b/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCapacitor.java index 86982e7c09..16be66255d 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCapacitor.java +++ b/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCapacitor.java @@ -14,9 +14,9 @@ import net.minecraft.util.IIcon; import java.util.List; -import static com.github.technus.tectech.util.CommonValues.V; import static com.github.technus.tectech.Reference.MODID; import static com.github.technus.tectech.thing.CustomItemList.teslaCapacitor; +import static com.github.technus.tectech.util.CommonValues.V; import static net.minecraft.util.StatCollector.translateToLocal; diff --git a/src/main/java/com/github/technus/tectech/thing/item/TeslaStaff.java b/src/main/java/com/github/technus/tectech/thing/item/TeslaStaff.java index 9d998953e8..ba080f8603 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/TeslaStaff.java +++ b/src/main/java/com/github/technus/tectech/thing/item/TeslaStaff.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.item; -import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.Reference; +import com.github.technus.tectech.util.CommonValues; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.util.GT_Utility; import net.minecraft.entity.Entity; diff --git a/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java b/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java index 20f59b56e2..b4300c763c 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java +++ b/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java @@ -11,6 +11,8 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; +import java.util.Objects; + import static com.github.technus.tectech.Reference.MODID; import static org.lwjgl.opengl.GL11.*; @@ -18,24 +20,26 @@ import static org.lwjgl.opengl.GL11.*; * Created by danie_000 on 17.12.2017. */ public class ScanDisplayScreen extends GuiScreen { - private static final int sizeX=240,sizeY=220, renderedLines =10; - private int baseX,baseY; - private Button up,down,pgUp,pgDown; + private static final int sizeX = 240, sizeY = 220, renderedLines = 10; + private int baseX, baseY; + private Button up, down, pgUp, pgDown; private final String[] lines; - private int firstLine; + private int firstLine; - private static final ResourceLocation[] BACKGROUNDS =new ResourceLocation[]{new ResourceLocation(MODID+":textures/gui/scanDisplayScreen1.png"), - new ResourceLocation(MODID+":textures/gui/scanDisplayScreen2.png"), - new ResourceLocation(MODID+":textures/gui/scanDisplayScreen3.png"), - new ResourceLocation(MODID+":textures/gui/scanDisplayScreen4.png"), - new ResourceLocation(MODID+":textures/gui/scanDisplayScreen5.png"), - new ResourceLocation(MODID+":textures/gui/scanDisplayScreen6.png"), - new ResourceLocation(MODID+":textures/gui/scanDisplayScreen7.png"), - new ResourceLocation(MODID+":textures/gui/scanDisplayScreen8.png")}; - private static final ResourceLocation ITEM =new ResourceLocation(MODID+":textures/gui/scanDisplayItem.png"); + private static final ResourceLocation[] BACKGROUNDS = new ResourceLocation[]{ + new ResourceLocation(MODID + ":textures/gui/scanDisplayScreen1.png"), + new ResourceLocation(MODID + ":textures/gui/scanDisplayScreen2.png"), + new ResourceLocation(MODID + ":textures/gui/scanDisplayScreen3.png"), + new ResourceLocation(MODID + ":textures/gui/scanDisplayScreen4.png"), + new ResourceLocation(MODID + ":textures/gui/scanDisplayScreen5.png"), + new ResourceLocation(MODID + ":textures/gui/scanDisplayScreen6.png"), + new ResourceLocation(MODID + ":textures/gui/scanDisplayScreen7.png"), + new ResourceLocation(MODID + ":textures/gui/scanDisplayScreen8.png")}; + private static final ResourceLocation ITEM = + new ResourceLocation(MODID + ":textures/gui/scanDisplayItem.png"); - public ScanDisplayScreen(EntityPlayer player){ - lines=ElementalDefinitionScanStorage_EM.getLines(player.getHeldItem()); + public ScanDisplayScreen(EntityPlayer player) { + lines = Objects.requireNonNull(ElementalDefinitionScanStorage_EM.getLines(player.getHeldItem())).toArray(new String[0]); } @Override @@ -43,48 +47,48 @@ public class ScanDisplayScreen extends GuiScreen { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); mc.getTextureManager().bindTexture(ITEM); - long tick=System.currentTimeMillis()/150; - int itick=(int)(tick%12); - drawTexturedModalRect(baseX+99,baseY+189,32*(itick/6),32*(itick%6), 32, 32); - mc.getTextureManager().bindTexture(BACKGROUNDS[(int)(tick%8)]); - drawTexturedModalRect(baseX,baseY,0,0, sizeX, sizeY); + long tick = System.currentTimeMillis() / 150; + int itick = (int) (tick % 12); + drawTexturedModalRect(baseX + 99, baseY + 189, 32 * (itick / 6), 32 * (itick % 6), 32, 32); + mc.getTextureManager().bindTexture(BACKGROUNDS[(int) (tick % 8)]); + drawTexturedModalRect(baseX, baseY, 0, 0, sizeX, sizeY); glDisable(GL_BLEND); - super.drawScreen(x,y,partialTicks); + super.drawScreen(x, y, partialTicks); - itick=(TecTech.RANDOM.nextInt(0x66)<<16)+0x77EEFF; - int textBaseX=baseX+20; - int textBaseXX=baseX+95; - int textBaseY=baseY+28; - for(int i=firstLine-1, j=8;i>=0 && j!=0;i--,j/=2){ - int equalPos=lines[i].indexOf('='); - if(equalPos>=0){ - TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(0,equalPos), textBaseX, textBaseY - 8 + j, 200, itick); + itick = (TecTech.RANDOM.nextInt(0x66) << 16) + 0x77EEFF; + int textBaseX = baseX + 20; + int textBaseXX = baseX + 95; + int textBaseY = baseY + 28; + for (int i = firstLine - 1, j = 8; i >= 0 && j != 0; i--, j /= 2) { + int equalPos = lines[i].indexOf('='); + if (equalPos >= 0) { + TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(0, equalPos), textBaseX, textBaseY - 8 + j, 200, itick); TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(equalPos), textBaseXX, textBaseY - 8 + j, 200, itick); - }else { + } else { TecTechFontRender.INSTANCE.drawSplitString(lines[i], textBaseX, textBaseY - 8 + j, 200, itick); } } - for(int i = firstLine, j = 0; i<lines.length && j< renderedLines; i++,j++){ + for (int i = firstLine, j = 0; i < lines.length && j < renderedLines; i++, j++) { textBaseY += 9; - int equalPos=lines[i].indexOf('='); - if(equalPos>=0){ - TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(0,equalPos), textBaseX, textBaseY, 200, itick); + int equalPos = lines[i].indexOf('='); + if (equalPos >= 0) { + TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(0, equalPos), textBaseX, textBaseY, 200, itick); TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(equalPos), textBaseXX, textBaseY, 200, itick); - }else { + } else { TecTechFontRender.INSTANCE.drawSplitString(lines[i], textBaseX, textBaseY, 200, itick); } } - for(int i = firstLine+ renderedLines, j = 8; i<lines.length && j!=0; i++,j/=2){ - int equalPos=lines[i].indexOf('='); - if(equalPos>=0){ - TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(0,equalPos), textBaseX, textBaseY + 17 - j, 200, itick); + for (int i = firstLine + renderedLines, j = 8; i < lines.length && j != 0; i++, j /= 2) { + int equalPos = lines[i].indexOf('='); + if (equalPos >= 0) { + TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(0, equalPos), textBaseX, textBaseY + 17 - j, 200, itick); TecTechFontRender.INSTANCE.drawSplitString(lines[i].substring(equalPos), textBaseXX, textBaseY + 17 - j, 200, itick); - }else { + } else { TecTechFontRender.INSTANCE.drawSplitString(lines[i], textBaseX, textBaseY + 17 - j, 200, itick); } } - TecTechFontRender.INSTANCE.drawSplitString(Integer.toString(firstLine), textBaseX, baseY+146, 200, itick); - TecTechFontRender.INSTANCE.drawSplitString(Integer.toString(lines.length), textBaseX, baseY+157, 200, itick); + TecTechFontRender.INSTANCE.drawSplitString(Integer.toString(firstLine), textBaseX, baseY + 146, 200, itick); + TecTechFontRender.INSTANCE.drawSplitString(Integer.toString(lines.length), textBaseX, baseY + 157, 200, itick); } @Override @@ -94,13 +98,13 @@ public class ScanDisplayScreen extends GuiScreen { @Override public void initGui() { - baseX=(width- sizeX)/2; - baseY=(height- sizeY)/2-12; - int buttonBaseY=baseY+145; - buttonList.add(pgUp= new Button(0, baseX + 77, buttonBaseY, 0, 220)); - buttonList.add(up= new Button(1, baseX + 99, buttonBaseY, 20, 220)); - buttonList.add(down= new Button(2, baseX + 121, buttonBaseY, 40, 220)); - buttonList.add(pgDown= new Button(3, baseX + 143, buttonBaseY, 60, 220)); + baseX = (width - sizeX) / 2; + baseY = (height - sizeY) / 2 - 12; + int buttonBaseY = baseY + 145; + buttonList.add(pgUp = new Button(0, baseX + 77, buttonBaseY, 0, 220)); + buttonList.add(up = new Button(1, baseX + 99, buttonBaseY, 20, 220)); + buttonList.add(down = new Button(2, baseX + 121, buttonBaseY, 40, 220)); + buttonList.add(pgDown = new Button(3, baseX + 143, buttonBaseY, 60, 220)); } @Override @@ -125,19 +129,18 @@ public class ScanDisplayScreen extends GuiScreen { } } - private static class Button extends GuiButton{ - int u,v; - Button(int id,int x,int y,int u,int v){ - super(id,x,y,20,20,""); - this.u=u; - this.v=v; + private static class Button extends GuiButton { + int u, v; + + Button(int id, int x, int y, int u, int v) { + super(id, x, y, 20, 20, ""); + this.u = u; + this.v = v; } @Override - public void drawButton(Minecraft mc, int xPos, int yPos) - { - if (visible) - { + public void drawButton(Minecraft mc, int xPos, int yPos) { + if (visible) { field_146123_n = xPos >= xPosition && yPos >= yPosition && xPos < xPosition + width && yPos < yPosition + height; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -150,9 +153,8 @@ public class ScanDisplayScreen extends GuiScreen { //play cool sound fx @Override - public void func_146113_a(SoundHandler soundHandler) - { - soundHandler.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation(MODID+":fx_click"), 1.0F)); + public void func_146113_a(SoundHandler soundHandler) { + soundHandler.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation(MODID + ":fx_click"), 1.0F)); } } } diff --git a/src/main/java/com/github/technus/tectech/thing/item/renderElemental/IElementalItem.java b/src/main/java/com/github/technus/tectech/thing/item/renderElemental/IElementalItem.java index ab68691eaa..37dce47e5f 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/renderElemental/IElementalItem.java +++ b/src/main/java/com/github/technus/tectech/thing/item/renderElemental/IElementalItem.java @@ -1,7 +1,21 @@ package com.github.technus.tectech.thing.item.renderElemental; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import static com.github.technus.tectech.util.TT_Utility.getSomeString; public interface IElementalItem { - String getSymbol(ItemStack stack,int index); + default String getSymbol(ItemStack stack,int index){ + try { + NBTTagCompound tNBT = stack.getTagCompound(); + if (tNBT != null && tNBT.hasKey("symbols")) { + return getSomeString(tNBT.getCompoundTag("symbols"),index); + } else { + return null; + } + } catch (Exception e) { + return "#!"; + } + } } diff --git a/src/main/java/com/github/technus/tectech/thing/item/renderElemental/RenderElementalName.java b/src/main/java/com/github/technus/tectech/thing/item/renderElemental/RenderElementalName.java index bfb1a188d8..e897f615ad 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/renderElemental/RenderElementalName.java +++ b/src/main/java/com/github/technus/tectech/thing/item/renderElemental/RenderElementalName.java @@ -32,10 +32,10 @@ public class RenderElementalName implements IItemRenderer { for (int i = 0; i < item.getRenderPasses(itemStack.getItemDamage()); i++) { IIcon icon = item.getIcon(itemStack, i); tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(0.0, 0.0, 0.0, (double)icon.getMinU(), (double)icon.getMinV()); - tessellator.addVertexWithUV(0.0, 16, 0.0, (double)icon.getMinU(), (double)icon.getMaxV()); - tessellator.addVertexWithUV(16, 16, 0.0, (double)icon.getMaxU(), (double)icon.getMaxV()); - tessellator.addVertexWithUV(16, 0.0, 0.0, (double)icon.getMaxU(), (double)icon.getMinV()); + tessellator.addVertexWithUV(0.0, 0.0, 0.0, icon.getMinU(), icon.getMinV()); + tessellator.addVertexWithUV(0.0, 16, 0.0, icon.getMinU(), icon.getMaxV()); + tessellator.addVertexWithUV(16, 16, 0.0, icon.getMaxU(), icon.getMaxV()); + tessellator.addVertexWithUV(16, 0.0, 0.0, icon.getMaxU(), icon.getMinV()); tessellator.draw(); //ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625f); } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/Textures.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/Textures.java index 69ff06e9e7..bc853334d2 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/Textures.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/Textures.java @@ -193,7 +193,7 @@ public class Textures { public static ITexture TESLA_TRANSCEIVER_TOP_BA = new GT_RenderedTexture(TESLA_TRANSCEIVER_TOP); - public Textures(){ + public static void run(){ for (byte i = 0; i < MACHINE_CASINGS_TT.length; i++) { for (byte j = 0; j < MACHINE_CASINGS_TT[i].length; j++) { MACHINE_CASINGS_TT[i][j] = new GT_SidedTexture(MACHINECASINGS_BOTTOM_TT[i], MACHINECASINGS_TOP_TT[i], MACHINECASINGS_SIDE_TT[i], Dyes.getModulation(j - 1, MACHINE_METAL.mRGBa)); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java index 4e07622c25..c74691d0a1 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java @@ -1,11 +1,11 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.Reference; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_Container_Capacitor; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_GUIContainer_Capacitor; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -23,9 +23,9 @@ import net.minecraft.util.EnumChatFormatting; import java.util.HashMap; import java.util.Map; -import static com.github.technus.tectech.util.CommonValues.V; -import static com.github.technus.tectech.util.Util.getUniqueIdentifier; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.util.CommonValues.V; +import static com.github.technus.tectech.util.TT_Utility.getUniqueIdentifier; import static net.minecraft.util.StatCollector.translateToLocal; /** @@ -38,7 +38,7 @@ public class GT_MetaTileEntity_Hatch_Capacitor extends GT_MetaTileEntity_Hatch { public GT_MetaTileEntity_Hatch_Capacitor(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 16, ""); - Util.setTier(aTier, this); + TT_Utility.setTier(aTier, this); } public GT_MetaTileEntity_Hatch_Capacitor(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeData.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeData.java index 815f8006c4..9311e34662 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeData.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeData.java @@ -1,10 +1,10 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.mechanics.dataTransport.QuantumDataPacket; -import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data; import com.github.technus.tectech.mechanics.pipe.IConnectsToDataPipe; +import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -22,7 +22,7 @@ import static net.minecraft.util.StatCollector.translateToLocal; public class GT_MetaTileEntity_Hatch_CreativeData extends GT_MetaTileEntity_Hatch_DataConnector<QuantumDataPacket> { public GT_MetaTileEntity_Hatch_CreativeData(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, ""); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } public GT_MetaTileEntity_Hatch_CreativeData(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeMaintenance.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeMaintenance.java index 42817f473e..5279da2b00 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeMaintenance.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeMaintenance.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -22,7 +22,7 @@ public class GT_MetaTileEntity_Hatch_CreativeMaintenance extends GT_MetaTileEnti public GT_MetaTileEntity_Hatch_CreativeMaintenance(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } public GT_MetaTileEntity_Hatch_CreativeMaintenance(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java index 4aa90339cc..9e4f6cba93 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java @@ -1,9 +1,9 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.mechanics.dataTransport.DataPacket; import com.github.technus.tectech.mechanics.pipe.IConnectsToDataPipe; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Dyes; @@ -41,7 +41,7 @@ public abstract class GT_MetaTileEntity_Hatch_DataConnector<T extends DataPacket protected GT_MetaTileEntity_Hatch_DataConnector(int aID, String aName, String aNameRegional, int aTier, String descr) { super(aID, aName, aNameRegional, aTier, 0, descr); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } protected GT_MetaTileEntity_Hatch_DataConnector(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java index bbc11f10fe..406a9ee56f 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -9,8 +9,8 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import static com.github.technus.tectech.util.CommonValues.V; import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_POWER_TT; +import static com.github.technus.tectech.util.CommonValues.V; import static net.minecraft.util.StatCollector.translateToLocal; /** @@ -22,7 +22,7 @@ public class GT_MetaTileEntity_Hatch_DynamoMulti extends GT_MetaTileEntity_Hatch public GT_MetaTileEntity_Hatch_DynamoMulti(int aID, String aName, String aNameRegional, int aTier, int aAmp) { super(aID, aName, aNameRegional, aTier, 0, translateToLocal("gt.blockmachines.hatch.dynamomulti.desc.0"));//Multiple Ampere Energy Extractor for Multiblocks Amperes = aAmp; - Util.setTier(aTier, this); + TT_Utility.setTier(aTier, this); } public GT_MetaTileEntity_Hatch_DynamoMulti(String aName, int aTier, int aAmp, String aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoTunnel.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoTunnel.java index b015d71b60..595f45f8d2 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoTunnel.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoTunnel.java @@ -1,9 +1,9 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; -import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Energy; import com.github.technus.tectech.mechanics.pipe.IConnectsToEnergyTunnel; +import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Energy; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -13,9 +13,9 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_LASER_TT; import static com.github.technus.tectech.util.CommonValues.TRANSFER_AT; import static com.github.technus.tectech.util.CommonValues.V; -import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_LASER_TT; import static net.minecraft.util.StatCollector.translateToLocal; /** @@ -24,7 +24,7 @@ import static net.minecraft.util.StatCollector.translateToLocal; public class GT_MetaTileEntity_Hatch_DynamoTunnel extends GT_MetaTileEntity_Hatch_DynamoMulti implements IConnectsToEnergyTunnel { public GT_MetaTileEntity_Hatch_DynamoTunnel(int aID, String aName, String aNameRegional, int aTier, int aAmp) { super(aID, aName, aNameRegional, aTier, 0, translateToLocal("gt.blockmachines.hatch.dynamotunnel.desc.0"), aAmp);//Energy extracting terminal for Multiblocks - Util.setTier(aTier, this); + TT_Utility.setTier(aTier, this); } public GT_MetaTileEntity_Hatch_DynamoTunnel(String aName, int aTier, int aAmp, String aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java index c8606f68f0..8b8bcaaa1d 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java @@ -1,11 +1,11 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.iElementalInstanceContainer; -import com.github.technus.tectech.mechanics.elementalMatter.core.tElementalException; +import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; +import com.github.technus.tectech.mechanics.elementalMatter.core.IEMContainer; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; import com.github.technus.tectech.mechanics.pipe.IConnectsToElementalPipe; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Dyes; @@ -14,6 +14,7 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -24,7 +25,7 @@ import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.reflect.FieldUtils; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT_144; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED; import static com.github.technus.tectech.util.CommonValues.*; import static gregtech.api.enums.Dyes.MACHINE_METAL; import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity; @@ -34,23 +35,23 @@ import static net.minecraft.util.StatCollector.translateToLocalFormatted; /** * Created by danie_000 on 11.12.2016. */ -public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_MetaTileEntity_Hatch implements iElementalInstanceContainer, IConnectsToElementalPipe { +public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_MetaTileEntity_Hatch implements IEMContainer, IConnectsToElementalPipe { private static Textures.BlockIcons.CustomIcon EM_T_SIDES; private static Textures.BlockIcons.CustomIcon EM_T_ACTIVE; private static Textures.BlockIcons.CustomIcon EM_T_CONN; private String clientLocale = "en_US"; - protected cElementalInstanceStackMap content = new cElementalInstanceStackMap(); + protected EMInstanceStackMap content = new EMInstanceStackMap(); //float lifeTimeMult=1f; - public int postEnergize = 0; + public int postEnergize = 0; public double overflowMatter = 0f; public short id = -1; private byte deathDelay = 2; protected GT_MetaTileEntity_Hatch_ElementalContainer(int aID, String aName, String aNameRegional, int aTier, String descr) { super(aID, aName, aNameRegional, aTier, 0, descr); - Util.setTier(aTier, this); + TT_Utility.setTier(aTier, this); } protected GT_MetaTileEntity_Hatch_ElementalContainer(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { @@ -83,7 +84,7 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta //aNBT.setFloat("lifeTimeMult",lifeTimeMult); aNBT.setDouble("OverflowMatter", overflowMatter); content.cleanUp(); - aNBT.setTag("eM_Stacks", content.toNBT()); + aNBT.setTag("eM_Stacks", content.toNBT(TecTech.definitionsRegistry)); aNBT.setShort("eID", id); } @@ -95,13 +96,13 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta overflowMatter = aNBT.getFloat("overflowMatter")+aNBT.getDouble("OverflowMatter"); id = aNBT.getShort("eID"); try { - content = cElementalInstanceStackMap.fromNBT(aNBT.getCompoundTag("eM_Stacks")); - } catch (tElementalException e) { + content = EMInstanceStackMap.fromNBT(TecTech.definitionsRegistry,aNBT.getCompoundTag("eM_Stacks")); + } catch (EMException e) { if (DEBUG_MODE) { e.printStackTrace(); } if (content == null) { - content = new cElementalInstanceStackMap(); + content = new EMInstanceStackMap(); } } } @@ -112,7 +113,7 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta byte Tick = (byte) (aTick % 20); if (DECAY_AT == Tick) { purgeOverflow(); - content.tickContentByOneSecond(1, postEnergize);//Hatches don't life time mult things + content.tickContent(1, postEnergize,1);//Hatches don't life time mult things purgeOverflow(); } else if (OVERFLOW_AT == Tick) { if (overflowMatter <= 0) { @@ -165,7 +166,7 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta } @Override - public cElementalInstanceStackMap getContainerHandler() { + public EMInstanceStackMap getContentHandler() { return content; } @@ -206,11 +207,11 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta } public int getMaxStacksCount() { - return mTier * 128; + return mTier * mTier >> 4; } public double getMaxStackSize() { - return mTier * (mTier - 7) * 64D * AVOGADRO_CONSTANT_144; + return mTier * (mTier - 7) * 64D * EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED; } @Override @@ -281,8 +282,8 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta return new String[]{ TEC_MARK_EM, mDescription, - translateToLocal("tt.base.emhatch.desc.0") + " " + EnumChatFormatting.AQUA + getMaxStacksCount(),//Max stacks amount: - translateToLocal("tt.base.emhatch.desc.1") + " " + EnumChatFormatting.AQUA + getMaxStackSize(),//Stack capacity: + translateToLocal("tt.base.emhatch.desc.0") + " " + EnumChatFormatting.AQUA + GT_Utility.formatNumbers(getMaxStacksCount()),//Max stacks amount: + translateToLocal("tt.base.emhatch.desc.1") + " " + EnumChatFormatting.AQUA + TT_Utility.formatNumberShortExp(getMaxStackSize()),//Stack capacity: translateToLocal("tt.base.emhatch.desc.2"),//Place Overflow Hatch behind,on top or below translateToLocal("tt.base.emhatch.desc.3"),//to provide overflow protection while this block translateToLocal("tt.base.emhatch.desc.4"),//is not attached to multi block. diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyMulti.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyMulti.java index 0acb9849a7..c637b3bfee 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyMulti.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyMulti.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -11,8 +11,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import static com.github.technus.tectech.util.CommonValues.V; import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_POWER_TT; +import static com.github.technus.tectech.util.CommonValues.V; import static net.minecraft.util.StatCollector.translateToLocal; /** @@ -24,7 +24,7 @@ public class GT_MetaTileEntity_Hatch_EnergyMulti extends GT_MetaTileEntity_Hatch public GT_MetaTileEntity_Hatch_EnergyMulti(int aID, String aName, String aNameRegional, int aTier, int aAmp) { super(aID, aName, aNameRegional, aTier, 0, translateToLocal("gt.blockmachines.hatch.energymulti.desc.0"));//Multiple Ampere Energy Injector for Multiblocks Amperes = aAmp; - Util.setTier(aTier, this); + TT_Utility.setTier(aTier, this); } public GT_MetaTileEntity_Hatch_EnergyMulti(String aName, int aTier, int aAmp, String aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyTunnel.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyTunnel.java index d44119e1ab..d29f9fc14b 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyTunnel.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyTunnel.java @@ -1,8 +1,8 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.mechanics.pipe.IConnectsToEnergyTunnel; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -11,9 +11,9 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_LASER_TT; import static com.github.technus.tectech.util.CommonValues.TRANSFER_AT; import static com.github.technus.tectech.util.CommonValues.V; -import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_LASER_TT; import static net.minecraft.util.StatCollector.translateToLocal; /** @@ -22,7 +22,7 @@ import static net.minecraft.util.StatCollector.translateToLocal; public class GT_MetaTileEntity_Hatch_EnergyTunnel extends GT_MetaTileEntity_Hatch_EnergyMulti implements IConnectsToEnergyTunnel { public GT_MetaTileEntity_Hatch_EnergyTunnel(int aID, String aName, String aNameRegional, int aTier, int aAmp) { super(aID, aName, aNameRegional, aTier, 0, translateToLocal("gt.blockmachines.hatch.energytunnel.desc.0"), aAmp);//Energy injecting terminal for Multiblocks - Util.setTier(aTier, this); + TT_Utility.setTier(aTier, this); } public GT_MetaTileEntity_Hatch_EnergyTunnel(String aName, int aTier, int aAmp, String aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Holder.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Holder.java index 3bbd6b9d54..e9631cfb3e 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Holder.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Holder.java @@ -1,9 +1,9 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_Container_Holder; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_GUIContainer_Holder; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -29,7 +29,7 @@ public class GT_MetaTileEntity_Hatch_Holder extends GT_MetaTileEntity_Hatch { public GT_MetaTileEntity_Hatch_Holder(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 1, ""); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } public GT_MetaTileEntity_Hatch_Holder(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java index 386a08b790..ff5669e0cb 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java @@ -1,9 +1,9 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.mechanics.dataTransport.QuantumDataPacket; import com.github.technus.tectech.mechanics.pipe.IConnectsToDataPipe; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -20,7 +20,7 @@ public class GT_MetaTileEntity_Hatch_InputData extends GT_MetaTileEntity_Hatch_D public GT_MetaTileEntity_Hatch_InputData(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, ""); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } public GT_MetaTileEntity_Hatch_InputData(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputDataItems.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputDataItems.java index f270971f4d..ee619ac5ec 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputDataItems.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputDataItems.java @@ -1,9 +1,9 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.mechanics.dataTransport.InventoryDataPacket; import com.github.technus.tectech.mechanics.pipe.IConnectsToDataPipe; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.enums.Dyes; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -20,9 +20,9 @@ import org.apache.commons.lang3.reflect.FieldUtils; import java.util.ArrayList; -import static com.github.technus.tectech.util.CommonValues.MOVE_AT; import static com.github.technus.tectech.recipe.TT_recipeAdder.nullItem; import static com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DataConnector.*; +import static com.github.technus.tectech.util.CommonValues.MOVE_AT; import static gregtech.api.enums.Dyes.MACHINE_METAL; import static net.minecraft.util.StatCollector.translateToLocal; import static net.minecraft.util.StatCollector.translateToLocalFormatted; @@ -35,7 +35,7 @@ public class GT_MetaTileEntity_Hatch_InputDataItems extends GT_MetaTileEntity_Ha public GT_MetaTileEntity_Hatch_InputDataItems(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } public GT_MetaTileEntity_Hatch_InputDataItems(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputElemental.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputElemental.java index b0f71aab24..92e70e62d5 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputElemental.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputElemental.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -13,7 +13,7 @@ import static net.minecraft.util.StatCollector.translateToLocal; public class GT_MetaTileEntity_Hatch_InputElemental extends GT_MetaTileEntity_Hatch_ElementalContainer { public GT_MetaTileEntity_Hatch_InputElemental(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, translateToLocal("gt.blockmachines.emin.desc"));//Elemental Input for Multiblocks - Util.setTier(aTier, this); + TT_Utility.setTier(aTier, this); } //public GT_MetaTileEntity_Hatch_InputElemental(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java index 87a9c93785..d625911702 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java @@ -1,10 +1,10 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.mechanics.dataTransport.QuantumDataPacket; -import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data; import com.github.technus.tectech.mechanics.pipe.IConnectsToDataPipe; +import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -21,7 +21,7 @@ import static net.minecraft.util.StatCollector.translateToLocal; public class GT_MetaTileEntity_Hatch_OutputData extends GT_MetaTileEntity_Hatch_DataConnector<QuantumDataPacket> { public GT_MetaTileEntity_Hatch_OutputData(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, ""); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } public GT_MetaTileEntity_Hatch_OutputData(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputDataItems.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputDataItems.java index 385de4343c..1c70ccd469 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputDataItems.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputDataItems.java @@ -1,10 +1,10 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.mechanics.dataTransport.InventoryDataPacket; -import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data; import com.github.technus.tectech.mechanics.pipe.IConnectsToDataPipe; +import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -21,7 +21,7 @@ import static net.minecraft.util.StatCollector.translateToLocal; public class GT_MetaTileEntity_Hatch_OutputDataItems extends GT_MetaTileEntity_Hatch_DataConnector<InventoryDataPacket> { public GT_MetaTileEntity_Hatch_OutputDataItems(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, ""); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } public GT_MetaTileEntity_Hatch_OutputDataItems(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java index a1e4f5a8a5..25ed1e6c47 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_EM; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -16,7 +16,7 @@ import static net.minecraft.util.StatCollector.translateToLocal; public class GT_MetaTileEntity_Hatch_OutputElemental extends GT_MetaTileEntity_Hatch_ElementalContainer { public GT_MetaTileEntity_Hatch_OutputElemental(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, translateToLocal("gt.blockmachines.emout.desc"));//Elemental Output for Multiblocks - Util.setTier(aTier, this); + TT_Utility.setTier(aTier, this); } //public GT_MetaTileEntity_Hatch_OutputElemental(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { @@ -62,7 +62,7 @@ public class GT_MetaTileEntity_Hatch_OutputElemental extends GT_MetaTileEntity_H if (aMetaTileEntity != null) { if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputElemental && opposite == tGTTileEntity.getFrontFacing()) { - ((GT_MetaTileEntity_Hatch_InputElemental) aMetaTileEntity).getContainerHandler().putUnifyAll(content); + ((GT_MetaTileEntity_Hatch_InputElemental) aMetaTileEntity).getContentHandler().putUnifyAll(content); ((GT_MetaTileEntity_Hatch_InputElemental) aMetaTileEntity).updateSlots(); content.clear(); return; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java index ff9aca01ee..0d5347a87e 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java @@ -1,8 +1,8 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Dyes; @@ -12,7 +12,6 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Utility; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -27,11 +26,9 @@ import net.minecraft.world.EnumSkyBlock; import net.minecraftforge.common.util.ForgeDirection; import org.apache.commons.lang3.reflect.FieldUtils; -import java.util.Locale; - +import static com.github.technus.tectech.loader.MainLoader.elementalPollution; import static com.github.technus.tectech.util.CommonValues.DISPERSE_AT; import static com.github.technus.tectech.util.CommonValues.V; -import static com.github.technus.tectech.loader.MainLoader.elementalPollution; import static gregtech.api.enums.Dyes.MACHINE_METAL; import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity; import static net.minecraft.util.StatCollector.translateToLocal; @@ -56,7 +53,7 @@ public class GT_MetaTileEntity_Hatch_OverflowElemental extends GT_MetaTileEntity overflowMatter = max / 2; overflowMax = max; overflowDisperse = overflowMax / (float) (30 - aTier); - Util.setTier(aTier, this); + TT_Utility.setTier(aTier, this); } public GT_MetaTileEntity_Hatch_OverflowElemental(String aName, int aTier, double max, String aDescription, ITexture[][][] aTextures) { @@ -91,8 +88,8 @@ public class GT_MetaTileEntity_Hatch_OverflowElemental extends GT_MetaTileEntity return new String[]{ CommonValues.TEC_MARK_EM, mDescription, - translateToLocal("gt.blockmachines.hatch.emmuffler.desc.1") + ": " + EnumChatFormatting.AQUA + GT_Utility.formatNumbers(overflowMax) + " eV/c\u00b2", - translateToLocal("gt.blockmachines.hatch.emmuffler.desc.2") + ": " + EnumChatFormatting.AQUA + GT_Utility.formatNumbers(overflowDisperse) + " (eV/c\u00b2)/s", + translateToLocal("gt.blockmachines.hatch.emmuffler.desc.1") + ": " + EnumChatFormatting.AQUA + TT_Utility.formatNumberShortExp(overflowMax) + " "+translateToLocal("tt.keyword.unit.mass"), + translateToLocal("gt.blockmachines.hatch.emmuffler.desc.2") + ": " + EnumChatFormatting.AQUA + TT_Utility.formatNumberShortExp(overflowDisperse) + " "+translateToLocal("tt.keyword.unit.massFlux"), translateToLocal("gt.blockmachines.hatch.emmuffler.desc.3") }; } @@ -149,10 +146,10 @@ public class GT_MetaTileEntity_Hatch_OverflowElemental extends GT_MetaTileEntity if (aBaseMetaTileEntity.isServerSide() && aTick % 20 == DISPERSE_AT) { if (aBaseMetaTileEntity.isActive()) { if (overflowMatter > overflowDisperse) { - TecTech.anomalyHandler.addAnomaly(aBaseMetaTileEntity, overflowDisperse); + TecTech.anomalyHandler.addAnomaly(aBaseMetaTileEntity, overflowDisperse/(Math.pow(2,mTier))); overflowMatter -= overflowDisperse; } else { - TecTech.anomalyHandler.addAnomaly(aBaseMetaTileEntity, overflowMatter); + TecTech.anomalyHandler.addAnomaly(aBaseMetaTileEntity, overflowMatter/(Math.pow(2,mTier))); overflowMatter = 0; aBaseMetaTileEntity.setActive(false); aBaseMetaTileEntity.setLightValue((byte) 0); @@ -188,6 +185,9 @@ public class GT_MetaTileEntity_Hatch_OverflowElemental extends GT_MetaTileEntity ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.confusion.id, 1, (int) (damagingFactor * 20))); ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.wither.id, 2, (int) (damagingFactor * 15))); ((EntityLivingBase) entity).attackEntityFrom(elementalPollution, damagingFactor); + if(entity instanceof EntityPlayer) { + TecTech.anomalyHandler.addMass((EntityPlayer) entity,overflowDisperse); + } } } @@ -217,17 +217,17 @@ public class GT_MetaTileEntity_Hatch_OverflowElemental extends GT_MetaTileEntity public String[] getInfoData() { return new String[]{ translateToLocalFormatted("tt.keyphrase.Contained_mass", clientLocale) + ":", - EnumChatFormatting.RED + GT_Utility.formatNumbers(overflowMatter) + EnumChatFormatting.RESET + " eV/c\u00b2 /", - EnumChatFormatting.GREEN + GT_Utility.formatNumbers(overflowMax) + EnumChatFormatting.RESET + " eV/c\u00b2", + EnumChatFormatting.RED + TT_Utility.formatNumberExp(overflowMatter) + EnumChatFormatting.RESET + " "+translateToLocal("tt.keyword.unit.mass")+ " / ", + EnumChatFormatting.GREEN + TT_Utility.formatNumberShortExp(overflowMax) + EnumChatFormatting.RESET + " "+translateToLocal("tt.keyword.unit.mass"), translateToLocalFormatted("tt.keyphrase.Mass_Disposal_speed", clientLocale) + ": " + - EnumChatFormatting.BLUE + GT_Utility.formatNumbers(overflowDisperse) + EnumChatFormatting.RESET + " (eV/c\u00b2)/s" + EnumChatFormatting.BLUE + TT_Utility.formatNumberShortExp(overflowDisperse) + EnumChatFormatting.RESET + " "+translateToLocal("tt.keyword.unit.massFlux") }; } @Override public void onRemoval() { if (isValidMetaTileEntity(this) && getBaseMetaTileEntity().isActive()) { - TecTech.anomalyHandler.addAnomaly(getBaseMetaTileEntity(), overflowMatter * 8D); + TecTech.anomalyHandler.addAnomaly(getBaseMetaTileEntity(), overflowMatter); if (TecTech.configTecTech.BOOM_ENABLE) { getBaseMetaTileEntity().doExplosion(V[15]); } else { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java index 7b8a488e57..d53e0683cd 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java @@ -1,11 +1,11 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_Container_Param; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_Container_ParamAdv; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_GUIContainer_Param; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_GUIContainer_ParamAdv; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -44,7 +44,7 @@ public class GT_MetaTileEntity_Hatch_Param extends GT_MetaTileEntity_Hatch { public GT_MetaTileEntity_Hatch_Param(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 0, ""); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } public GT_MetaTileEntity_Hatch_Param(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ParamText.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ParamText.java index bc4562307b..b50475ae59 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ParamText.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ParamText.java @@ -1,9 +1,9 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.loader.NetworkDispatcher; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_Container_ParamText; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_GUIContainer_ParamText; +import com.github.technus.tectech.util.CommonValues; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -113,13 +113,7 @@ public class GT_MetaTileEntity_Hatch_ParamText extends GT_MetaTileEntity_Hatch_P public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); value0s = aNBT.getString("eIeValue0S"); - if (value0s==null){ - value0s=""; - } value1s = aNBT.getString("eIeValue1S"); - if(value1s==null){ - value1s=""; - } } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Rack.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Rack.java index 53fea9ef7c..0ef4a38a3d 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Rack.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Rack.java @@ -1,11 +1,11 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.Reference; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_Container_Rack; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_GUIContainer_Rack; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.common.Loader; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -28,9 +28,9 @@ import org.apache.commons.lang3.reflect.FieldUtils; import java.util.HashMap; import java.util.Map; -import static com.github.technus.tectech.util.CommonValues.MULTI_CHECK_AT; -import static com.github.technus.tectech.util.Util.getUniqueIdentifier; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.util.CommonValues.MULTI_CHECK_AT; +import static com.github.technus.tectech.util.TT_Utility.getUniqueIdentifier; import static net.minecraft.util.StatCollector.translateToLocal; import static net.minecraft.util.StatCollector.translateToLocalFormatted; @@ -48,7 +48,7 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch { public GT_MetaTileEntity_Hatch_Rack(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 4, ""); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } public GT_MetaTileEntity_Hatch_Rack(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Uncertainty.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Uncertainty.java index d723dd908c..9ce5a1c446 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Uncertainty.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Uncertainty.java @@ -1,11 +1,11 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_Container_Uncertainty; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_GUIContainer_Uncertainty; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_GUIContainer_UncertaintyAdv; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -40,7 +40,7 @@ public class GT_MetaTileEntity_Hatch_Uncertainty extends GT_MetaTileEntity_Hatch public GT_MetaTileEntity_Hatch_Uncertainty(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 0, ""); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); regenerate(); } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/TextParametersMessage.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/TextParametersMessage.java index b0b53f6c79..9e4b81cd5b 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/TextParametersMessage.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/TextParametersMessage.java @@ -1,8 +1,8 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_GUIContainer_ParamText; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.MessageContext; @@ -23,8 +23,8 @@ public class TextParametersMessage implements IMessage { int mPosY; int mPosZ; int mPosD; - String mVal0; - String mVal1; + String mVal0=""; + String mVal1=""; public TextParametersMessage() {} @@ -36,13 +36,7 @@ public class TextParametersMessage implements IMessage { mPosZ = tTag.getInteger("posz"); mPosD = tTag.getInteger("posd"); mVal0 = tTag.getString("value0s"); - if(mVal0==null) { - mVal0=""; - } mVal1 = tTag.getString("value1s"); - if(mVal1==null) { - mVal1=""; - } } @Override @@ -149,8 +143,8 @@ public class TextParametersMessage implements IMessage { if(meta instanceof GT_MetaTileEntity_Hatch_ParamText){ ((GT_MetaTileEntity_Hatch_ParamText) meta).value0s =pMessage.mVal0; ((GT_MetaTileEntity_Hatch_ParamText) meta).value1s =pMessage.mVal1; - ((GT_MetaTileEntity_Hatch_ParamText) meta).value0D=Util.getValue(pMessage.mVal0); - ((GT_MetaTileEntity_Hatch_ParamText) meta).value1D=Util.getValue(pMessage.mVal1); + ((GT_MetaTileEntity_Hatch_ParamText) meta).value0D= TT_Utility.getValue(pMessage.mVal0); + ((GT_MetaTileEntity_Hatch_ParamText) meta).value1D= TT_Utility.getValue(pMessage.mVal1); } } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Param.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Param.java index da067078c9..f87e44aefb 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Param.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Param.java @@ -1,8 +1,8 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Param; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.gui.GT_ContainerMetaTile_Machine; @@ -144,11 +144,11 @@ public class GT_Container_Param extends GT_ContainerMetaTile_Machine { for (Object crafter : crafters) { ICrafting var1 = (ICrafting) crafter; - Util.sendInteger(param,this,var1,100); - Util.sendDouble(value0d,this,var1,102); - Util.sendDouble(value1d,this,var1, 106); - Util.sendDouble(input0d,this,var1, 110); - Util.sendDouble(input1d,this,var1, 114); + TT_Utility.sendInteger(param,this,var1,100); + TT_Utility.sendDouble(value0d,this,var1,102); + TT_Utility.sendDouble(value1d,this,var1, 106); + TT_Utility.sendDouble(input0d,this,var1, 110); + TT_Utility.sendDouble(input1d,this,var1, 114); } } @@ -159,31 +159,31 @@ public class GT_Container_Param extends GT_ContainerMetaTile_Machine { switch (par1) { case 100: case 101: - param=Util.receiveInteger(param,100,par1,par2); + param= TT_Utility.receiveInteger(param,100,par1,par2); return; case 102: case 103: case 104: case 105: - value0d =Double.longBitsToDouble(value0l=Util.receiveLong(value0l,102,par1,par2)); + value0d =Double.longBitsToDouble(value0l= TT_Utility.receiveLong(value0l,102,par1,par2)); return; case 106: case 107: case 108: case 109: - value1d =Double.longBitsToDouble(value1l=Util.receiveLong(value1l,106,par1,par2)); + value1d =Double.longBitsToDouble(value1l= TT_Utility.receiveLong(value1l,106,par1,par2)); return; case 110: case 111: case 112: case 113: - input0d =Double.longBitsToDouble(input0l=Util.receiveLong(input0l,110,par1,par2)); + input0d =Double.longBitsToDouble(input0l= TT_Utility.receiveLong(input0l,110,par1,par2)); return; case 114: case 115: case 116: case 117: - input1d =Double.longBitsToDouble(input1l=Util.receiveLong(input1l,114,par1,par2)); + input1d =Double.longBitsToDouble(input1l= TT_Utility.receiveLong(input1l,114,par1,par2)); return; default: } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamAdv.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamAdv.java index c8fa85996a..44608ec204 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamAdv.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamAdv.java @@ -1,8 +1,8 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Param; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.gui.GT_ContainerMetaTile_Machine; @@ -231,12 +231,12 @@ public class GT_Container_ParamAdv extends GT_ContainerMetaTile_Machine { for (Object crafter : crafters) { ICrafting var1 = (ICrafting) crafter; - Util.sendInteger(param,this,var1,100); - Util.sendDouble(value0d,this,var1,102); - Util.sendDouble(value1d,this,var1, 106); - Util.sendDouble(input0d,this,var1, 110); - Util.sendDouble(input1d,this,var1, 114); - Util.sendInteger(pointer,this,var1,118); + TT_Utility.sendInteger(param,this,var1,100); + TT_Utility.sendDouble(value0d,this,var1,102); + TT_Utility.sendDouble(value1d,this,var1, 106); + TT_Utility.sendDouble(input0d,this,var1, 110); + TT_Utility.sendDouble(input1d,this,var1, 114); + TT_Utility.sendInteger(pointer,this,var1,118); } } @@ -247,35 +247,35 @@ public class GT_Container_ParamAdv extends GT_ContainerMetaTile_Machine { switch (par1) { case 100: case 101: - param=Util.receiveInteger(param,100,par1,par2); + param= TT_Utility.receiveInteger(param,100,par1,par2); return; case 102: case 103: case 104: case 105: - value0d =Double.longBitsToDouble(value0l=Util.receiveLong(value0l,102,par1,par2)); + value0d =Double.longBitsToDouble(value0l= TT_Utility.receiveLong(value0l,102,par1,par2)); return; case 106: case 107: case 108: case 109: - value1d =Double.longBitsToDouble(value1l=Util.receiveLong(value1l,106,par1,par2)); + value1d =Double.longBitsToDouble(value1l= TT_Utility.receiveLong(value1l,106,par1,par2)); return; case 110: case 111: case 112: case 113: - input0d =Double.longBitsToDouble(input0l=Util.receiveLong(input0l,110,par1,par2)); + input0d =Double.longBitsToDouble(input0l= TT_Utility.receiveLong(input0l,110,par1,par2)); return; case 114: case 115: case 116: case 117: - input1d =Double.longBitsToDouble(input1l=Util.receiveLong(input1l,114,par1,par2)); + input1d =Double.longBitsToDouble(input1l= TT_Utility.receiveLong(input1l,114,par1,par2)); return; case 118: case 119: - pointer=Util.receiveInteger(pointer,118,par1,par2); + pointer= TT_Utility.receiveInteger(pointer,118,par1,par2); return; default: } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamText.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamText.java index 9c0e08948f..b4c466192f 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamText.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamText.java @@ -1,10 +1,10 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.loader.NetworkDispatcher; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_ParamText; import com.github.technus.tectech.thing.metaTileEntity.hatch.TextParametersMessage; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.gui.GT_ContainerMetaTile_Machine; @@ -95,11 +95,11 @@ public class GT_Container_ParamText extends GT_ContainerMetaTile_Machine { input1d = ((GT_MetaTileEntity_Hatch_ParamText) mTileEntity.getMetaTileEntity()).input1D; for (Object crafter : crafters) { ICrafting var1 = (ICrafting) crafter; - Util.sendInteger(param,this,var1,100); - Util.sendDouble(value0d,this,var1,102); - Util.sendDouble(value1d,this,var1, 106); - Util.sendDouble(input0d,this,var1, 110); - Util.sendDouble(input1d,this,var1, 114); + TT_Utility.sendInteger(param,this,var1,100); + TT_Utility.sendDouble(value0d,this,var1,102); + TT_Utility.sendDouble(value1d,this,var1, 106); + TT_Utility.sendDouble(input0d,this,var1, 110); + TT_Utility.sendDouble(input1d,this,var1, 114); } if(!Objects.equals(value0s,((GT_MetaTileEntity_Hatch_ParamText) mTileEntity.getMetaTileEntity()).value0s) || !Objects.equals(value0s,((GT_MetaTileEntity_Hatch_ParamText) mTileEntity.getMetaTileEntity()).value0s)){ @@ -123,31 +123,31 @@ public class GT_Container_ParamText extends GT_ContainerMetaTile_Machine { switch (par1) { case 100: case 101: - param=Util.receiveInteger(param,100,par1,par2); + param= TT_Utility.receiveInteger(param,100,par1,par2); return; case 102: case 103: case 104: case 105: - value0d =Double.longBitsToDouble(value0l=Util.receiveLong(value0l,102,par1,par2)); + value0d =Double.longBitsToDouble(value0l= TT_Utility.receiveLong(value0l,102,par1,par2)); return; case 106: case 107: case 108: case 109: - value1d =Double.longBitsToDouble(value1l=Util.receiveLong(value1l,106,par1,par2)); + value1d =Double.longBitsToDouble(value1l= TT_Utility.receiveLong(value1l,106,par1,par2)); return; case 110: case 111: case 112: case 113: - input0d =Double.longBitsToDouble(input0l=Util.receiveLong(input0l,110,par1,par2)); + input0d =Double.longBitsToDouble(input0l= TT_Utility.receiveLong(input0l,110,par1,par2)); return; case 114: case 115: case 116: case 117: - input1d =Double.longBitsToDouble(input1l=Util.receiveLong(input1l,114,par1,par2)); + input1d =Double.longBitsToDouble(input1l= TT_Utility.receiveLong(input1l,114,par1,par2)); return; default: } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java index 7eb71651bb..686c2c81ce 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java @@ -1,14 +1,12 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.font.TecTechFontRender; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; import org.lwjgl.opengl.GL11; -import java.util.Locale; - import static gregtech.api.enums.GT_Values.RES_PATH_GUI; public class GT_GUIContainer_Param extends GT_GUIContainerMetaTile_Machine { @@ -20,15 +18,14 @@ public class GT_GUIContainer_Param extends GT_GUIContainerMetaTile_Machine { protected void drawGuiContainerForegroundLayer(int par1, int par2) { if (mContainer != null) { TecTechFontRender.INSTANCE.drawSplitString("Parameters: " + ((GT_Container_Param) mContainer).param, 46, 7, 167, 0xffffff); - Locale locale= Locale.getDefault(); - TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b07" + String.format(locale, "%+.5E", ((GT_Container_Param) mContainer).input0d), 46, 16, 167, 0x22ddff); - TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b07" + String.format(locale, "%+.5E", ((GT_Container_Param) mContainer).input1d), 46, 24, 167, 0x00ffff); - TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b06" + String.format(locale, "%+.5E", ((GT_Container_Param) mContainer).value0d), 46, 33, 167, 0x00bbff); - TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b06" + String.format(locale, "%+.5E", ((GT_Container_Param) mContainer).value1d), 46, 41, 167, 0x0077ff); + TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b07" + TT_Utility.formatNumberExp(((GT_Container_Param) mContainer).input0d), 46, 16, 167, 0x22ddff); + TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b07" + TT_Utility.formatNumberExp(((GT_Container_Param) mContainer).input1d), 46, 24, 167, 0x00ffff); + TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b06" + TT_Utility.formatNumberExp(((GT_Container_Param) mContainer).value0d), 46, 33, 167, 0x00bbff); + TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b06" + TT_Utility.formatNumberExp(((GT_Container_Param) mContainer).value1d), 46, 41, 167, 0x0077ff); GL11.glPushMatrix(); GL11.glScalef(.5f,.5f,.5f); - TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b06" + Util.longBitsToShortString(Double.doubleToLongBits(((GT_Container_Param) mContainer).value0d)), 92, 100, 334, 0x00bbff); - TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b06" + Util.longBitsToShortString(Double.doubleToLongBits(((GT_Container_Param) mContainer).value1d)), 92, 116, 334, 0x0077ff); + TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b06" + TT_Utility.longBitsToShortString(Double.doubleToLongBits(((GT_Container_Param) mContainer).value0d)), 92, 100, 334, 0x00bbff); + TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b06" + TT_Utility.longBitsToShortString(Double.doubleToLongBits(((GT_Container_Param) mContainer).value1d)), 92, 116, 334, 0x0077ff); GL11.glPopMatrix(); } else { TecTechFontRender.INSTANCE.drawSplitString("Parameters", 46, 7, 167, 0xffffff); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java index 4346118619..f7ffa18ffc 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java @@ -1,14 +1,12 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.font.TecTechFontRender; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; import org.lwjgl.opengl.GL11; -import java.util.Locale; - import static gregtech.api.enums.GT_Values.RES_PATH_GUI; public class GT_GUIContainer_ParamAdv extends GT_GUIContainerMetaTile_Machine { @@ -20,15 +18,14 @@ public class GT_GUIContainer_ParamAdv extends GT_GUIContainerMetaTile_Machine { protected void drawGuiContainerForegroundLayer(int par1, int par2) { if (mContainer != null) { TecTechFontRender.INSTANCE.drawSplitString("Parameters X: " + ((GT_Container_ParamAdv) mContainer).param, 46, 7, 167, 0xffffff); - Locale locale = Locale.getDefault(); - TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b07" + String.format(locale, "%+.5E", (((GT_Container_ParamAdv) mContainer).input0d)), 46, 16, 167, 0x22ddff); - TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b07" + String.format(locale, "%+.5E", (((GT_Container_ParamAdv) mContainer).input1d)), 46, 24, 167, 0x00ffff); - TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b06" + String.format(locale, "%+.5E", (((GT_Container_ParamAdv) mContainer).value0d)), 46, 33, 167, 0x00bbff); - TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b06" + String.format(locale, "%+.5E", (((GT_Container_ParamAdv) mContainer).value1d)), 46, 41, 167, 0x0077ff); + TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b07" + TT_Utility.formatNumberExp((((GT_Container_ParamAdv) mContainer).input0d)), 46, 16, 167, 0x22ddff); + TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b07" + TT_Utility.formatNumberExp((((GT_Container_ParamAdv) mContainer).input1d)), 46, 24, 167, 0x00ffff); + TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b06" + TT_Utility.formatNumberExp((((GT_Container_ParamAdv) mContainer).value0d)), 46, 33, 167, 0x00bbff); + TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b06" + TT_Utility.formatNumberExp((((GT_Container_ParamAdv) mContainer).value1d)), 46, 41, 167, 0x0077ff); GL11.glPushMatrix(); GL11.glScalef(.5f,.5f,.5f); - TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b06" + Util.longBitsToShortString(Double.doubleToLongBits(((GT_Container_ParamAdv) mContainer).value0d)), 92, 100, 334, 0x00bbff); - TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b06" + Util.longBitsToShortString(Double.doubleToLongBits(((GT_Container_ParamAdv) mContainer).value1d)), 92, 116, 334, 0x0077ff); + TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b06" + TT_Utility.longBitsToShortString(Double.doubleToLongBits(((GT_Container_ParamAdv) mContainer).value0d)), 92, 100, 334, 0x00bbff); + TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b06" + TT_Utility.longBitsToShortString(Double.doubleToLongBits(((GT_Container_ParamAdv) mContainer).value1d)), 92, 116, 334, 0x0077ff); GL11.glPopMatrix(); TecTechFontRender.INSTANCE.drawSplitString("Pointer " + Integer.toHexString(((GT_Container_ParamAdv) mContainer).pointer | 0x10000).substring(1), 46, 66, 167, 0x0033ff); } else { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamText.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamText.java index 50e608294e..e10f30076d 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamText.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamText.java @@ -1,16 +1,15 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.font.TecTechFontRender; import com.github.technus.tectech.loader.NetworkDispatcher; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_ParamText; import com.github.technus.tectech.thing.metaTileEntity.hatch.TextParametersMessage; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.InventoryPlayer; -import java.util.Locale; import java.util.Objects; import static gregtech.api.enums.GT_Values.RES_PATH_GUI; @@ -77,11 +76,10 @@ public class GT_GUIContainer_ParamText extends GT_GUIContainerMetaTile_Machine { protected void drawGuiContainerForegroundLayer(int par1, int par2) { if (mContainer != null) { TecTechFontRender.INSTANCE.drawSplitString("Parameters tXt: " + ((GT_Container_ParamText) mContainer).param, 46, 7, 167, 0xffffff); - Locale locale = Locale.getDefault(); TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b06", 10, 29, 16, 0x00bbff); TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b06", 10, 44, 16, 0x0077ff); - TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b07" + String.format(locale, "%+.5E", (((GT_Container_ParamText) mContainer).input0d)), 10, 56, 167, 0x22ddff); - TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b07" + String.format(locale, "%+.5E", (((GT_Container_ParamText) mContainer).input1d)), 10, 65, 167, 0x00ffff); + TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b07" + TT_Utility.formatNumberExp((((GT_Container_ParamText) mContainer).input0d)), 10, 56, 167, 0x22ddff); + TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b07" + TT_Utility.formatNumberExp((((GT_Container_ParamText) mContainer).input1d)), 10, 65, 167, 0x00ffff); } else { TecTechFontRender.INSTANCE.drawSplitString("Parameters tXt", 46, 7, 167, 0xffffff); } @@ -107,12 +105,12 @@ public class GT_GUIContainer_ParamText extends GT_GUIContainerMetaTile_Machine { try { if (str.contains("b")) { String[] split = str.split("b"); - val = Util.bitStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_","")); + val = TT_Utility.bitStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_","")); } else if (str.contains("x")) { String[] split = str.split("x"); - val = Util.hexStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_","")); + val = TT_Utility.hexStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_","")); } else { - val = Util.stringToDouble(str); + val = TT_Utility.stringToDouble(str); } if (!Objects.equals(((GT_MetaTileEntity_Hatch_ParamText) ((GT_Container_ParamText) mContainer).mTileEntity.getMetaTileEntity()).value0s, value0tb.getText())) { ((GT_Container_ParamText) mContainer).value0s = value0tb.getText(); @@ -135,12 +133,12 @@ public class GT_GUIContainer_ParamText extends GT_GUIContainerMetaTile_Machine { try { if (str.contains("b")) { String[] split = str.split("b"); - val = Util.bitStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_","")); + val = TT_Utility.bitStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_","")); } else if (str.contains("x")) { String[] split = str.split("x"); - val = Util.hexStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_","")); + val = TT_Utility.hexStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_","")); } else { - val = Util.stringToDouble(str); + val = TT_Utility.stringToDouble(str); } if (!Objects.equals(((GT_MetaTileEntity_Hatch_ParamText) ((GT_Container_ParamText) mContainer).mTileEntity.getMetaTileEntity()).value1s, value1tb.getText())) { ((GT_Container_ParamText) mContainer).value1s = value1tb.getText(); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java index 05829c89e4..8a51494b94 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java @@ -6,7 +6,6 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_Rend import com.github.technus.tectech.util.CommonValues; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -30,9 +29,9 @@ import static net.minecraft.util.StatCollector.translateToLocal; */ public class GT_MetaTileEntity_EM_annihilation extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { //region variables - private static Textures.BlockIcons.CustomIcon ScreenOFF; - private static Textures.BlockIcons.CustomIcon ScreenON; - private static final String[] description = new String[]{ + private static Textures.BlockIcons.CustomIcon ScreenOFF; + private static Textures.BlockIcons.CustomIcon ScreenON; + private static final String[] description = new String[]{ EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", translateToLocal("gt.blockmachines.multimachine.em.annihilation.hint.0"),//1 - Classic Hatches or High Power Casing translateToLocal("gt.blockmachines.multimachine.em.annihilation.hint.1"),//2 - Elemental Hatches or Molecular Casing @@ -40,30 +39,30 @@ public class GT_MetaTileEntity_EM_annihilation extends GT_MetaTileEntity_Multibl //endregion //region structure - private static final IStructureDefinition<GT_MetaTileEntity_EM_annihilation> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_EM_annihilation>builder() - .addShape("main", transpose(new String[][]{ - {" "," AB BA "," AB BA "," BBB "," A A A ","AA F AA"," A A A "," BBB "," AB BA "," AB BA "," "}, - {" "," AB BA "," EECEEECEE "," EGGEEEGGE ","ACGGGEGGGCA","AEGGGDGGGEA","ACGGGEGGGCA"," EGGEEEGGE "," EECEEECEE "," AB BA "," "}, - {" "," B B "," EGGEGEGGE "," G G "," G G "," G G "," G G "," G G "," EGGEGEGGE "," B B "," "}, - {" AAA ","AA BAB AA","ACGGEGEGGCA"," G G "," G G "," G G "," G G "," G G ","ACGGEGEGGCA","AA BAB AA"," AAA "}, - {" AHHHA ","BBBBBBBBBBB","BEEEDEDEEEB","BE EB"," G G "," G G "," G G ","BE EB","BEEEDEDEEEB","BBBBBBBBBBB"," AHHHA "}, - {" AH~HA "," ABBBA "," EGGEEEGGE ","BE EB","AE EA","FD DF","AE EA","BE EB"," EGGEEEGGE "," ABBBA "," AHHHA "}, - {" AHHHA ","BBBBBBBBBBB","BEEEDEDEEEB","BE EB"," G G "," G G "," G G ","BE EB","BEEEDEDEEEB","BBBBBBBBBBB"," AHHHA "}, - {" AAA ","AA BAB AA","ACGGEGEGGCA"," G G "," G G "," G G "," G G "," G G ","ACGGEGEGGCA","AA BAB AA"," AAA "}, - {" "," B B "," EGGEGEGGE "," G G "," G G "," G G "," G G "," G G "," EGGEGEGGE "," B B "," "}, - {" "," AB BA "," EECEEECEE "," EGGEEEGGE ","ACGGGEGGGCA","AEGGGDGGGEA","ACGGGEGGGCA"," EGGEEEGGE "," EECEEECEE "," AB BA "," "}, - {" "," AB BA "," AB BA "," BBB "," A A A ","AA F AA"," A A A "," BBB "," AB BA "," AB BA "," "} - })) - .addElement('A', ofBlock(sBlockCasingsTT, 4)) - .addElement('B', ofBlock(sBlockCasingsTT, 5)) - .addElement('C', ofBlock(sBlockCasingsTT, 6)) - .addElement('D', ofBlock(sBlockCasingsTT, 10)) - .addElement('E', ofBlock(sBlockCasingsTT, 12)) - .addElement('F', ofHatchAdderOptional(GT_MetaTileEntity_EM_annihilation::addElementalToMachineList, textureOffset + 4,2, sBlockCasingsTT, 4)) - .addElement('G', ofBlock(QuantumGlassBlock.INSTANCE, 0)) - .addElement('H', ofHatchAdderOptional(GT_MetaTileEntity_EM_annihilation::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) - .build(); + private static final IStructureDefinition<GT_MetaTileEntity_EM_annihilation> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_EM_annihilation>builder() + .addShape("main", transpose(new String[][]{ + {" ", " AB BA ", " AB BA ", " BBB ", " A A A ", "AA F AA", " A A A ", " BBB ", " AB BA ", " AB BA ", " "}, + {" ", " AB BA ", " EECEEECEE ", " EGGEEEGGE ", "ACGGGEGGGCA", "AEGGGDGGGEA", "ACGGGEGGGCA", " EGGEEEGGE ", " EECEEECEE ", " AB BA ", " "}, + {" ", " B B ", " EGGEGEGGE ", " G G ", " G G ", " G G ", " G G ", " G G ", " EGGEGEGGE ", " B B ", " "}, + {" AAA ", "AA BAB AA", "ACGGEGEGGCA", " G G ", " G G ", " G G ", " G G ", " G G ", "ACGGEGEGGCA", "AA BAB AA", " AAA "}, + {" AHHHA ", "BBBBBBBBBBB", "BEEEDEDEEEB", "BE EB", " G G ", " G G ", " G G ", "BE EB", "BEEEDEDEEEB", "BBBBBBBBBBB", " AHHHA "}, + {" AH~HA ", " ABBBA ", " EGGEEEGGE ", "BE EB", "AE EA", "FD DF", "AE EA", "BE EB", " EGGEEEGGE ", " ABBBA ", " AHHHA "}, + {" AHHHA ", "BBBBBBBBBBB", "BEEEDEDEEEB", "BE EB", " G G ", " G G ", " G G ", "BE EB", "BEEEDEDEEEB", "BBBBBBBBBBB", " AHHHA "}, + {" AAA ", "AA BAB AA", "ACGGEGEGGCA", " G G ", " G G ", " G G ", " G G ", " G G ", "ACGGEGEGGCA", "AA BAB AA", " AAA "}, + {" ", " B B ", " EGGEGEGGE ", " G G ", " G G ", " G G ", " G G ", " G G ", " EGGEGEGGE ", " B B ", " "}, + {" ", " AB BA ", " EECEEECEE ", " EGGEEEGGE ", "ACGGGEGGGCA", "AEGGGDGGGEA", "ACGGGEGGGCA", " EGGEEEGGE ", " EECEEECEE ", " AB BA ", " "}, + {" ", " AB BA ", " AB BA ", " BBB ", " A A A ", "AA F AA", " A A A ", " BBB ", " AB BA ", " AB BA ", " "} + })) + .addElement('A', ofBlock(sBlockCasingsTT, 4)) + .addElement('B', ofBlock(sBlockCasingsTT, 5)) + .addElement('C', ofBlock(sBlockCasingsTT, 6)) + .addElement('D', ofBlock(sBlockCasingsTT, 10)) + .addElement('E', ofBlock(sBlockCasingsTT, 12)) + .addElement('G', ofBlock(QuantumGlassBlock.INSTANCE, 0)) + .addElement('H', ofHatchAdderOptional(GT_MetaTileEntity_EM_annihilation::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) + .addElement('F', ofHatchAdderOptional(GT_MetaTileEntity_EM_annihilation::addElementalToMachineList, textureOffset + 4, 2, sBlockCasingsTT, 4)) + .build(); //endregion public GT_MetaTileEntity_EM_annihilation(int aID, String aName, String aNameRegional) { @@ -111,7 +110,7 @@ public class GT_MetaTileEntity_EM_annihilation extends GT_MetaTileEntity_Multibl @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - structureBuild_EM("main", 5, 5, 0, hintsOnly, stackSize); + structureBuild_EM("main", 5, 5, 0, stackSize, hintsOnly); } @Override @@ -123,4 +122,4 @@ public class GT_MetaTileEntity_EM_annihilation extends GT_MetaTileEntity_Multibl public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java index 448c930351..3d6bb58cb0 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java @@ -6,7 +6,6 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_Rend import com.github.technus.tectech.util.CommonValues; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -36,10 +35,10 @@ public class GT_MetaTileEntity_EM_bhg extends GT_MetaTileEntity_MultiblockBase_E private static Textures.BlockIcons.CustomIcon ScreenON; //todo CHECK VALUES - private static final double NEUTRONIUM_BLOCK_MASS = 4.1E17; - private static final double NEUTRONIUM_BLOCK_ATOM_COUNT = 2.4478671E44; + private static final double NEUTRONIUM_BLOCK_MASS = 4.1E17; + private static final double NEUTRONIUM_BLOCK_ATOM_COUNT = 2.4478671E44; private static final double NEUTRONIUM_BLOCK_TO_EU_INSTANT = URANIUM_MASS_TO_EU_INSTANT * NEUTRONIUM_BLOCK_MASS / (URANIUM_INGOT_MASS_DIFF * 1.78266191e-36);//~ 5.314e40 - private static final double NEUTRON_TO_EU_INSTANT = NEUTRONIUM_BLOCK_TO_EU_INSTANT / NEUTRONIUM_BLOCK_ATOM_COUNT;//~ 0.00021708694 + private static final double NEUTRON_TO_EU_INSTANT = NEUTRONIUM_BLOCK_TO_EU_INSTANT / NEUTRONIUM_BLOCK_ATOM_COUNT;//~ 0.00021708694 public boolean glassDome = false; //endregion @@ -49,86 +48,86 @@ public class GT_MetaTileEntity_EM_bhg extends GT_MetaTileEntity_MultiblockBase_E //per dim disable thingies //region structure actual - private static final IStructureDefinition<GT_MetaTileEntity_EM_bhg> STRUCTURE_DEFINITION= - StructureDefinition.<GT_MetaTileEntity_EM_bhg>builder() + private static final IStructureDefinition<GT_MetaTileEntity_EM_bhg> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_EM_bhg>builder() .addShape("main_t1", transpose(new String[][]{ - {" "," "," "," "," "," "," "," "," "," "," "," "," C C "," C C "," C C "," CCCCCCCCC "," C C "," CCCCCCCCC "," C C "," C C "," C C "," "," "," "," "," "," "," "," "," "," "," "," "}, - {" "," "," "," "," "," "," "," "," "," C C "," C C "," C C "," C C "," DDDDD "," DDCDCDD "," CCCCDCCDCCDCCCC "," DDDDDDD "," CCCCDCCDCCDCCCC "," DDCDCDD "," DDDDD "," C C "," C C "," C C "," C C "," "," "," "," "," "," "," "," "," "}, - {" "," "," "," "," "," "," "," C C "," C C "," C C "," D "," D "," DDDDDDD "," DD DD "," D EEE D "," CCC D EAAAE D CCC "," DDD EAAAE DDD "," CCC D EAAAE D CCC "," D EEE D "," DD DD "," DDDDDDD "," D "," D "," C C "," C C "," C C "," "," "," "," "," "," "," "}, - {" "," "," "," "," "," "," C C "," C C "," D "," D "," "," "," "," "," "," CC CC "," DD DD "," CC CC "," "," "," "," "," "," D "," D "," C C "," C C "," "," "," "," "," "," "}, - {" "," "," "," "," "," C C "," CCCCC "," D "," B "," B "," "," "," "," "," C C "," CC CC "," CDBB BBDC "," CC CC "," C C "," "," "," "," "," B "," B "," D "," CCCCC "," C C "," "," "," "," "," "}, - {" "," "," "," "," C C "," C C "," D "," EEEBEEE "," "," "," "," "," "," E E "," E E "," CC E E CC "," DB BD "," CC E E CC "," E E "," E E "," "," "," "," "," "," EEEBEEE "," D "," C C "," C C "," "," "," "," "}, - {" "," "," "," C C "," CCCCC "," D "," B "," "," "," "," "," "," "," "," C C "," CC CC "," CDB BDC "," CC CC "," C C "," "," "," "," "," "," "," "," B "," D "," CCCCC "," C C "," "," "," "}, - {" "," "," C C "," C C "," D "," EEEBEEE "," "," "," "," "," "," "," "," E E "," E E "," CC E E CC "," DB BD "," CC E E CC "," E E "," E E "," "," "," "," "," "," "," "," EEEBEEE "," D "," C C "," C C "," "," "}, - {" "," "," C C "," D "," B "," "," "," "," "," "," "," "," "," "," "," C C "," DB BD "," C C "," "," "," "," "," "," "," "," "," "," "," B "," D "," C C "," "," "}, - {" "," C C "," C C "," D "," B "," "," "," "," "," "," "," "," "," "," "," CC CC "," DB BD "," CC CC "," "," "," "," "," "," "," "," "," "," "," B "," D "," C C "," C C "," "}, - {" "," C C "," D "," "," "," "," "," "," "," "," "," "," "," "," "," C C "," D D "," C C "," "," "," "," "," "," "," "," "," "," "," "," "," D "," C C "," "}, - {" "," C C "," D "," "," "," "," "," "," "," "," "," "," "," "," "," C C "," D D "," C C "," "," "," "," "," "," "," "," "," "," "," "," "," D "," C C "," "}, - {" CCCCCCC "," C C "," DDDDDDD "," "," "," "," "," "," "," "," "," "," "," D D "," D D ","CCD DCC"," D D ","CCD DCC"," D D "," D D "," "," "," "," "," "," "," "," "," "," "," DDDDDDD "," C C "," C C "}, - {" CCHHHHHCC "," DDDDD "," DD DD "," "," "," E E "," "," E E "," "," "," "," "," D D "," D D "," D D ","CD DC"," D D ","CD DC"," D D "," D D "," D D "," "," "," "," "," E E "," "," E E "," "," "," DD DD "," DDDDD "," C C "}, - {" CHHHHHHHC "," DDCDCDD "," D EEE D "," "," C C "," E E "," C C "," E E "," "," "," "," "," D D "," D D "," D D ","CCE ECC"," DE ED ","CCE ECC"," D D "," D D "," D D "," "," "," "," "," E E "," C C "," E E "," C C "," "," D EEE D "," DDCDCDD "," C C "}, - {" CHHFFFHHC "," CCCCDCCDCCDCCCC "," CCC D EAAAE D CCC "," CC CC "," CC CC "," CC E E CC "," CC CC "," CC E E CC "," C C "," CC CC "," C C "," C C ","CCD DCC","CD DC","CCE ECC","CCA ACC","CDA ADC","CCA ACC","CCE ECC","CD DC","CCD DCC"," C C "," C C "," CC CC "," C C "," CC E E CC "," CC CC "," CC E E CC "," CC CC "," CC CC "," CCC D EAAAE D CCC "," CCCCDCCDCCDCCCC "," CCCCCCCCC "}, - {" CHHF~FHHC "," DDDDDDD "," DDD EAAAE DDD "," DD DD "," CDBB BBDC "," DB BD "," CDB BDC "," DB BD "," DB BD "," DB BD "," D D "," D D "," D D "," D D "," DE ED ","CDA ADC"," DA AD ","CDA ADC"," DE ED "," D D "," D D "," D D "," D D "," DB BD "," DB BD "," DB BD "," CDB BDC "," DB BD "," CDBB BBDC "," DD DD "," DDD EAAAE DDD "," DDDDDDD "," C C "}, - {" CHHFFFHHC "," CCCCDCCDCCDCCCC "," CCC D EAAAE D CCC "," CC CC "," CC CC "," CC E E CC "," CC CC "," CC E E CC "," C C "," CC CC "," C C "," C C ","CCD DCC","CD DC","CCE ECC","CCA ACC","CDA ADC","CCA ACC","CCE ECC","CD DC","CCD DCC"," C C "," C C "," CC CC "," C C "," CC E E CC "," CC CC "," CC E E CC "," CC CC "," CC CC "," CCC D EAAAE D CCC "," CCCCDCCDCCDCCCC "," CCCCCCCCC "}, - {" CHHHHHHHC "," DDCDCDD "," D EEE D "," "," C C "," E E "," C C "," E E "," "," "," "," "," D D "," D D "," D D ","CCE ECC"," DE ED ","CCE ECC"," D D "," D D "," D D "," "," "," "," "," E E "," C C "," E E "," C C "," "," D EEE D "," DDCDCDD "," C C "}, - {" CCHHHHHCC "," DDDDD "," DD DD "," "," "," E E "," "," E E "," "," "," "," "," D D "," D D "," D D ","CD DC"," D D ","CD DC"," D D "," D D "," D D "," "," "," "," "," E E "," "," E E "," "," "," DD DD "," DDDDD "," C C "}, - {" CCCCCCC "," C C "," DDDDDDD "," "," "," "," "," "," "," "," "," "," "," D D "," D D ","CCD DCC"," D D ","CCD DCC"," D D "," D D "," "," "," "," "," "," "," "," "," "," "," DDDDDDD "," C C "," C C "}, - {" "," C C "," D "," "," "," "," "," "," "," "," "," "," "," "," "," C C "," D D "," C C "," "," "," "," "," "," "," "," "," "," "," "," "," D "," C C "," "}, - {" "," C C "," D "," "," "," "," "," "," "," "," "," "," "," "," "," C C "," D D "," C C "," "," "," "," "," "," "," "," "," "," "," "," "," D "," C C "," "}, - {" "," C C "," C C "," D "," B "," "," "," "," "," "," "," "," "," "," "," CC CC "," DB BD "," CC CC "," "," "," "," "," "," "," "," "," "," "," B "," D "," C C "," C C "," "}, - {" "," "," C C "," D "," B "," "," "," "," "," "," "," "," "," "," "," C C "," DB BD "," C C "," "," "," "," "," "," "," "," "," "," "," B "," D "," C C "," "," "}, - {" "," "," C C "," C C "," D "," EEEBEEE "," "," "," "," "," "," "," "," E E "," E E "," CC E E CC "," DB BD "," CC E E CC "," E E "," E E "," "," "," "," "," "," "," "," EEEBEEE "," D "," C C "," C C "," "," "}, - {" "," "," "," C C "," CCCCC "," D "," B "," "," "," "," "," "," "," "," C C "," CC CC "," CDB BDC "," CC CC "," C C "," "," "," "," "," "," "," "," B "," D "," CCCCC "," C C "," "," "," "}, - {" "," "," "," "," C C "," C C "," D "," EEEBEEE "," "," "," "," "," "," E E "," E E "," CC E E CC "," DB BD "," CC E E CC "," E E "," E E "," "," "," "," "," "," EEEBEEE "," D "," C C "," C C "," "," "," "," "}, - {" "," "," "," "," "," C C "," CCCCC "," D "," B "," B "," "," "," "," "," C C "," CC CC "," CDBB BBDC "," CC CC "," C C "," "," "," "," "," B "," B "," D "," CCCCC "," C C "," "," "," "," "," "}, - {" "," "," "," "," "," "," C C "," C C "," D "," D "," "," "," "," "," "," CC CC "," DD DD "," CC CC "," "," "," "," D "," D "," D "," D "," C C "," C C "," "," "," "," "," "," "}, - {" "," "," "," "," "," "," "," C C "," C C "," C C "," D "," D "," DDDDDDD "," DD DD "," D EEE D "," CCC D EAAAE D CCC "," DDD EAAAE DDD "," CCC D EAAAE D CCC "," D EEE D "," DD DD "," DDDDDDD "," D "," D "," C C "," C C "," C C "," "," "," "," "," "," "," "}, - {" "," "," "," "," "," "," "," "," "," C C "," C C "," C C "," C C "," DDDDD "," DDCDCDD "," CCCCDCCDCCDCCCC "," DDDDDDD "," CCCCDCCDCCDCCCC "," DDCDCDD "," DDDDD "," C C "," C C "," C C "," C C "," "," "," "," "," "," "," "," "," "}, - {" "," "," "," "," "," "," "," "," "," "," "," "," C C "," C C "," C C "," CCCCCCCCC "," C C "," CCCCCCCCC "," C C "," C C "," C C "," "," "," "," "," "," "," "," "," "," "," "," "} + {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " C C ", " C C ", " C C ", " CCCCCCCCC ", " C C ", " CCCCCCCCC ", " C C ", " C C ", " C C ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " ", " ", " ", " ", " ", " C C ", " C C ", " C C ", " C C ", " DDDDD ", " DDCDCDD ", " CCCCDCCDCCDCCCC ", " DDDDDDD ", " CCCCDCCDCCDCCCC ", " DDCDCDD ", " DDDDD ", " C C ", " C C ", " C C ", " C C ", " ", " ", " ", " ", " ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " ", " ", " ", " C C ", " C C ", " C C ", " D ", " D ", " DDDDDDD ", " DD DD ", " D EEE D ", " CCC D EAAAE D CCC ", " DDD EAAAE DDD ", " CCC D EAAAE D CCC ", " D EEE D ", " DD DD ", " DDDDDDD ", " D ", " D ", " C C ", " C C ", " C C ", " ", " ", " ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " ", " ", " C C ", " C C ", " D ", " D ", " ", " ", " ", " ", " ", " CC CC ", " DD DD ", " CC CC ", " ", " ", " ", " ", " ", " D ", " D ", " C C ", " C C ", " ", " ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " ", " C C ", " CCCCC ", " D ", " B ", " B ", " ", " ", " ", " ", " C C ", " CC CC ", " CDBB BBDC ", " CC CC ", " C C ", " ", " ", " ", " ", " B ", " B ", " D ", " CCCCC ", " C C ", " ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " C C ", " C C ", " D ", " EEEBEEE ", " ", " ", " ", " ", " ", " E E ", " E E ", " CC E E CC ", " DB BD ", " CC E E CC ", " E E ", " E E ", " ", " ", " ", " ", " ", " EEEBEEE ", " D ", " C C ", " C C ", " ", " ", " ", " "}, + {" ", " ", " ", " C C ", " CCCCC ", " D ", " B ", " ", " ", " ", " ", " ", " ", " ", " C C ", " CC CC ", " CDB BDC ", " CC CC ", " C C ", " ", " ", " ", " ", " ", " ", " ", " B ", " D ", " CCCCC ", " C C ", " ", " ", " "}, + {" ", " ", " C C ", " C C ", " D ", " EEEBEEE ", " ", " ", " ", " ", " ", " ", " ", " E E ", " E E ", " CC E E CC ", " DB BD ", " CC E E CC ", " E E ", " E E ", " ", " ", " ", " ", " ", " ", " ", " EEEBEEE ", " D ", " C C ", " C C ", " ", " "}, + {" ", " ", " C C ", " D ", " B ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " C C ", " DB BD ", " C C ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " B ", " D ", " C C ", " ", " "}, + {" ", " C C ", " C C ", " D ", " B ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " CC CC ", " DB BD ", " CC CC ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " B ", " D ", " C C ", " C C ", " "}, + {" ", " C C ", " D ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " C C ", " D D ", " C C ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " D ", " C C ", " "}, + {" ", " C C ", " D ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " C C ", " D D ", " C C ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " D ", " C C ", " "}, + {" CCCCCCC ", " C C ", " DDDDDDD ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " D D ", " D D ", "CCD DCC", " D D ", "CCD DCC", " D D ", " D D ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " DDDDDDD ", " C C ", " C C "}, + {" CCHHHHHCC ", " DDDDD ", " DD DD ", " ", " ", " E E ", " ", " E E ", " ", " ", " ", " ", " D D ", " D D ", " D D ", "CD DC", " D D ", "CD DC", " D D ", " D D ", " D D ", " ", " ", " ", " ", " E E ", " ", " E E ", " ", " ", " DD DD ", " DDDDD ", " C C "}, + {" CHHHHHHHC ", " DDCDCDD ", " D EEE D ", " ", " C C ", " E E ", " C C ", " E E ", " ", " ", " ", " ", " D D ", " D D ", " D D ", "CCE ECC", " DE ED ", "CCE ECC", " D D ", " D D ", " D D ", " ", " ", " ", " ", " E E ", " C C ", " E E ", " C C ", " ", " D EEE D ", " DDCDCDD ", " C C "}, + {" CHHFFFHHC ", " CCCCDCCDCCDCCCC ", " CCC D EAAAE D CCC ", " CC CC ", " CC CC ", " CC E E CC ", " CC CC ", " CC E E CC ", " C C ", " CC CC ", " C C ", " C C ", "CCD DCC", "CD DC", "CCE ECC", "CCA ACC", "CDA ADC", "CCA ACC", "CCE ECC", "CD DC", "CCD DCC", " C C ", " C C ", " CC CC ", " C C ", " CC E E CC ", " CC CC ", " CC E E CC ", " CC CC ", " CC CC ", " CCC D EAAAE D CCC ", " CCCCDCCDCCDCCCC ", " CCCCCCCCC "}, + {" CHHF~FHHC ", " DDDDDDD ", " DDD EAAAE DDD ", " DD DD ", " CDBB BBDC ", " DB BD ", " CDB BDC ", " DB BD ", " DB BD ", " DB BD ", " D D ", " D D ", " D D ", " D D ", " DE ED ", "CDA ADC", " DA AD ", "CDA ADC", " DE ED ", " D D ", " D D ", " D D ", " D D ", " DB BD ", " DB BD ", " DB BD ", " CDB BDC ", " DB BD ", " CDBB BBDC ", " DD DD ", " DDD EAAAE DDD ", " DDDDDDD ", " C C "}, + {" CHHFFFHHC ", " CCCCDCCDCCDCCCC ", " CCC D EAAAE D CCC ", " CC CC ", " CC CC ", " CC E E CC ", " CC CC ", " CC E E CC ", " C C ", " CC CC ", " C C ", " C C ", "CCD DCC", "CD DC", "CCE ECC", "CCA ACC", "CDA ADC", "CCA ACC", "CCE ECC", "CD DC", "CCD DCC", " C C ", " C C ", " CC CC ", " C C ", " CC E E CC ", " CC CC ", " CC E E CC ", " CC CC ", " CC CC ", " CCC D EAAAE D CCC ", " CCCCDCCDCCDCCCC ", " CCCCCCCCC "}, + {" CHHHHHHHC ", " DDCDCDD ", " D EEE D ", " ", " C C ", " E E ", " C C ", " E E ", " ", " ", " ", " ", " D D ", " D D ", " D D ", "CCE ECC", " DE ED ", "CCE ECC", " D D ", " D D ", " D D ", " ", " ", " ", " ", " E E ", " C C ", " E E ", " C C ", " ", " D EEE D ", " DDCDCDD ", " C C "}, + {" CCHHHHHCC ", " DDDDD ", " DD DD ", " ", " ", " E E ", " ", " E E ", " ", " ", " ", " ", " D D ", " D D ", " D D ", "CD DC", " D D ", "CD DC", " D D ", " D D ", " D D ", " ", " ", " ", " ", " E E ", " ", " E E ", " ", " ", " DD DD ", " DDDDD ", " C C "}, + {" CCCCCCC ", " C C ", " DDDDDDD ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " D D ", " D D ", "CCD DCC", " D D ", "CCD DCC", " D D ", " D D ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " DDDDDDD ", " C C ", " C C "}, + {" ", " C C ", " D ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " C C ", " D D ", " C C ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " D ", " C C ", " "}, + {" ", " C C ", " D ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " C C ", " D D ", " C C ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " D ", " C C ", " "}, + {" ", " C C ", " C C ", " D ", " B ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " CC CC ", " DB BD ", " CC CC ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " B ", " D ", " C C ", " C C ", " "}, + {" ", " ", " C C ", " D ", " B ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " C C ", " DB BD ", " C C ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " B ", " D ", " C C ", " ", " "}, + {" ", " ", " C C ", " C C ", " D ", " EEEBEEE ", " ", " ", " ", " ", " ", " ", " ", " E E ", " E E ", " CC E E CC ", " DB BD ", " CC E E CC ", " E E ", " E E ", " ", " ", " ", " ", " ", " ", " ", " EEEBEEE ", " D ", " C C ", " C C ", " ", " "}, + {" ", " ", " ", " C C ", " CCCCC ", " D ", " B ", " ", " ", " ", " ", " ", " ", " ", " C C ", " CC CC ", " CDB BDC ", " CC CC ", " C C ", " ", " ", " ", " ", " ", " ", " ", " B ", " D ", " CCCCC ", " C C ", " ", " ", " "}, + {" ", " ", " ", " ", " C C ", " C C ", " D ", " EEEBEEE ", " ", " ", " ", " ", " ", " E E ", " E E ", " CC E E CC ", " DB BD ", " CC E E CC ", " E E ", " E E ", " ", " ", " ", " ", " ", " EEEBEEE ", " D ", " C C ", " C C ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " ", " C C ", " CCCCC ", " D ", " B ", " B ", " ", " ", " ", " ", " C C ", " CC CC ", " CDBB BBDC ", " CC CC ", " C C ", " ", " ", " ", " ", " B ", " B ", " D ", " CCCCC ", " C C ", " ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " ", " ", " C C ", " C C ", " D ", " D ", " ", " ", " ", " ", " ", " CC CC ", " DD DD ", " CC CC ", " ", " ", " ", " D ", " D ", " D ", " D ", " C C ", " C C ", " ", " ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " ", " ", " ", " C C ", " C C ", " C C ", " D ", " D ", " DDDDDDD ", " DD DD ", " D EEE D ", " CCC D EAAAE D CCC ", " DDD EAAAE DDD ", " CCC D EAAAE D CCC ", " D EEE D ", " DD DD ", " DDDDDDD ", " D ", " D ", " C C ", " C C ", " C C ", " ", " ", " ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " ", " ", " ", " ", " ", " C C ", " C C ", " C C ", " C C ", " DDDDD ", " DDCDCDD ", " CCCCDCCDCCDCCCC ", " DDDDDDD ", " CCCCDCCDCCDCCCC ", " DDCDCDD ", " DDDDD ", " C C ", " C C ", " C C ", " C C ", " ", " ", " ", " ", " ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " C C ", " C C ", " C C ", " CCCCCCCCC ", " C C ", " CCCCCCCCC ", " C C ", " C C ", " C C ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "} })) .addShape("main_t2", transpose(new String[][]{ - {" "," "," "," "," "," "," "," "," "," "," "," "," C C "," C C "," C C "," CCCCCCCCC "," C C "," CCCCCCCCC "," C C "," C C "," C C "," "," "," "," "," "," "," "," "," "," "," "," "}, - {" "," "," "," "," "," "," "," "," "," C C "," GGC CGG "," GGGC CGGG "," GGGGC CGGGG "," GGGGDDDDDGGGG "," GGGDDCDCDDGGG "," CCCCDCCDCCDCCCC "," DDDDDDD "," CCCCDCCDCCDCCCC "," GGGDDCDCDDGGG "," GGGGDDDDDGGGG "," GGGGC CGGGG "," GGGC CGGG "," GGC CGG "," C C "," "," "," "," "," "," "," "," "," "}, - {" "," "," "," "," "," "," "," C C "," GGC CGG "," GGGGC CGGGG "," GGG D GGG "," GGG D GGG "," GG DDDDDDD GG "," GG DD DD GG "," GG D EEE D GG "," CCC D EAAAE D CCC "," DDD EAAAE DDD "," CCC D EAAAE D CCC "," GG D EEE D GG "," GG DD DD GG "," GG DDDDDDD GG "," GGG D GGG "," GGG D GGG "," GGGGC CGGGG "," GGC CGG "," C C "," "," "," "," "," "," "," "}, - {" "," "," "," "," "," "," C C "," GGGC CGGG "," GGG D GGG "," GG D GG "," GG GG "," G G "," GG GG "," G G "," G G "," CC CC "," DD DD "," CC CC "," G G "," G G "," GG GG "," G G "," GG GG "," GG D GG "," GGG D GGG "," GGGC CGGG "," C C "," "," "," "," "," "," "}, - {" "," "," "," "," "," C C "," GGGCCCCCGGG "," GGG D GGG "," GG B GG "," GG B GG "," G G "," GG GG "," G G "," G G "," C C "," CC CC "," CDBB BBDC "," CC CC "," C C "," G G "," G G "," GG GG "," G G "," GG B GG "," GG B GG "," GGG D GGG "," GGGCCCCCGGG "," C C "," "," "," "," "," "}, - {" "," "," "," "," C C "," GGGGGC CGGGGG "," GGG D GGG "," GG EEEBEEE GG "," GG GG "," G G "," GG GG "," G G "," G G "," G E E G "," G E E G "," CC E E CC "," DB BD "," CC E E CC "," G E E G "," G E E G "," G G "," G G "," GG GG "," G G "," GG GG "," GG EEEBEEE GG "," GGG D GGG "," GGGGGC CGGGGG "," C C "," "," "," "," "}, - {" "," "," "," C C "," GGGCCCCCGGG "," GGG D GGG "," GG B GG "," G G "," GG GG "," G G "," G G "," G G "," G G "," G G "," C C "," CC CC "," CDB BDC "," CC CC "," C C "," G G "," G G "," G G "," G G "," G G "," GG GG "," G G "," GG B GG "," GGG D GGG "," GGGCCCCCGGG "," C C "," "," "," "}, - {" "," "," C C "," GGGC CGGG "," GGG D GGG "," GG EEEBEEE GG "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G E E G "," G E E G "," CC E E CC "," DB BD "," CC E E CC "," G E E G "," G E E G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," GG EEEBEEE GG "," GGG D GGG "," GGGC CGGG "," C C "," "," "}, - {" "," "," GGC CGG "," GGG D GGG "," GG B GG "," GG GG "," GG GG "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," C C "," DB BD "," C C "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," GG GG "," GG GG "," GG B GG "," GGG D GGG "," GGC CGG "," "," "}, - {" "," C C "," GGGGC CGGGG "," GG D GG "," GG B GG "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," CC CC "," DB BD "," CC CC "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," GG B GG "," GG D GG "," GGGGC CGGGG "," C C "," "}, - {" "," GGC CGG "," GGG D GGG "," GG GG "," G G "," GG GG "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," C C "," D D "," C C "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," GG GG "," G G "," GG GG "," GGG D GGG "," GGC CGG "," "}, - {" "," GGGC CGGG "," GGG D GGG "," G G "," GG GG "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," C C "," D D "," C C "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," GG GG "," G G "," GGG D GGG "," GGGC CGGG "," "}, - {" CCCCCCC "," GGGGC CGGGG "," GG DDDDDDD GG "," GG GG "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," GD DG "," GD DG ","CCD DCC"," D D ","CCD DCC"," GD DG "," GD DG "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," GG GG "," GG DDDDDDD GG "," GGGGC CGGGG "," C C "}, - {" CCHHHHHCC "," GGGGDDDDDGGGG "," GG DD DD GG "," G G "," G G "," G E E G "," G G "," G E E G "," G G "," G G "," G G "," G G "," GD DG "," GD DG "," D D ","CD DC"," D D ","CD DC"," D D "," GD DG "," GD DG "," G G "," G G "," G G "," G G "," G E E G "," G G "," G E E G "," G G "," G G "," GG DD DD GG "," GGGGDDDDDGGGG "," C C "}, - {" CHHHHHHHC "," GGGDDCDCDDGGG "," GG D EEE D GG "," G G "," C C "," G E E G "," C C "," G E E G "," G G "," G G "," G G "," G G "," GD DG "," D D "," D D ","CCE ECC"," DE ED ","CCE ECC"," D D "," D D "," GD DG "," G G "," G G "," G G "," G G "," G E E G "," C C "," G E E G "," C C "," G G "," GG D EEE D GG "," GGGDDCDCDDGGG "," C C "}, - {" CHHFFFHHC "," CCCCDCCDCCDCCCC "," CCC D EAAAE D CCC "," CC CC "," CC CC "," CC E E CC "," CC CC "," CC E E CC "," C C "," CC CC "," C C "," C C ","CCD DCC","CD DC","CCE ECC","CCA ACC","CDA ADC","CCA ACC","CCE ECC","CD DC","CCD DCC"," C C "," C C "," CC CC "," C C "," CC E E CC "," CC CC "," CC E E CC "," CC CC "," CC CC "," CCC D EAAAE D CCC "," CCCCDCCDCCDCCCC "," CCCCCCCCC "}, - {" CHHF~FHHC "," DDDDDDD "," DDD EAAAE DDD "," DD DD "," CDBB BBDC "," DB BD "," CDB BDC "," DB BD "," DB BD "," DB BD "," D D "," D D "," D D "," D D "," DE ED ","CDA ADC"," DA AD ","CDA ADC"," DE ED "," D D "," D D "," D D "," D D "," DB BD "," DB BD "," DB BD "," CDB BDC "," DB BD "," CDBB BBDC "," DD DD "," DDD EAAAE DDD "," DDDDDDD "," C C "}, - {" CHHFFFHHC "," CCCCDCCDCCDCCCC "," CCC D EAAAE D CCC "," CC CC "," CC CC "," CC E E CC "," CC CC "," CC E E CC "," C C "," CC CC "," C C "," C C ","CCD DCC","CD DC","CCE ECC","CCA ACC","CDA ADC","CCA ACC","CCE ECC","CD DC","CCD DCC"," C C "," C C "," CC CC "," C C "," CC E E CC "," CC CC "," CC E E CC "," CC CC "," CC CC "," CCC D EAAAE D CCC "," CCCCDCCDCCDCCCC "," CCCCCCCCC "}, - {" CHHHHHHHC "," GGGDDCDCDDGGG "," GG D EEE D GG "," G G "," C C "," G E E G "," C C "," G E E G "," G G "," G G "," G G "," G G "," GD DG "," D D "," D D ","CCE ECC"," DE ED ","CCE ECC"," D D "," D D "," GD DG "," G G "," G G "," G G "," G G "," G E E G "," C C "," G E E G "," C C "," G G "," GG D EEE D GG "," GGGDDCDCDDGGG "," C C "}, - {" CCHHHHHCC "," GGGGDDDDDGGGG "," GG DD DD GG "," G G "," G G "," G E E G "," G G "," G E E G "," G G "," G G "," G G "," G G "," GD DG "," GD DG "," D D ","CD DC"," D D ","CD DC"," D D "," GD DG "," GD DG "," G G "," G G "," G G "," G G "," G E E G "," G G "," G E E G "," G G "," G G "," GG DD DD GG "," GGGGDDDDDGGGG "," C C "}, - {" CCCCCCC "," GGGGC CGGGG "," GG DDDDDDD GG "," GG GG "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," GD DG "," GD DG ","CCD DCC"," D D ","CCD DCC"," GD DG "," GD DG "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," GG GG "," GG DDDDDDD GG "," GGGGC CGGGG "," C C "}, - {" "," GGGC CGGG "," GGG D GGG "," G G "," GG GG "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," C C "," D D "," C C "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," GG GG "," G G "," GGG D GGG "," GGGC CGGG "," "}, - {" "," GGC CGG "," GGG D GGG "," GG GG "," G G "," GG GG "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," C C "," D D "," C C "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," GG GG "," G G "," GG GG "," GGG D GGG "," GGC CGG "," "}, - {" "," C C "," GGGGC CGGGG "," GG D GG "," GG B GG "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," CC CC "," DB BD "," CC CC "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," GG B GG "," GG D GG "," GGGGC CGGGG "," C C "," "}, - {" "," "," GGC CGG "," GGG D GGG "," GG B GG "," GG GG "," GG GG "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," C C "," DB BD "," C C "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," GG GG "," GG GG "," GG B GG "," GGG D GGG "," GGC CGG "," "," "}, - {" "," "," C C "," GGGC CGGG "," GGG D GGG "," GG EEEBEEE GG "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," G E E G "," G E E G "," CC E E CC "," DB BD "," CC E E CC "," G E E G "," G E E G "," G G "," G G "," G G "," G G "," G G "," G G "," G G "," GG EEEBEEE GG "," GGG D GGG "," GGGC CGGG "," C C "," "," "}, - {" "," "," "," C C "," GGGCCCCCGGG "," GGG D GGG "," GG B GG "," G G "," GG GG "," G G "," G G "," G G "," G G "," G G "," C C "," CC CC "," CDB BDC "," CC CC "," C C "," G G "," G G "," G G "," G G "," G G "," GG GG "," G G "," GG B GG "," GGG D GGG "," GGGCCCCCGGG "," C C "," "," "," "}, - {" "," "," "," "," C C "," GGGGGC CGGGGG "," GGG D GGG "," GG EEEBEEE GG "," GG GG "," G G "," GG GG "," G G "," G G "," G E E G "," G E E G "," CC E E CC "," DB BD "," CC E E CC "," G E E G "," G E E G "," G G "," G G "," GG GG "," G G "," GG GG "," GG EEEBEEE GG "," GGG D GGG "," GGGGGC CGGGGG "," C C "," "," "," "," "}, - {" "," "," "," "," "," C C "," GGGCCCCCGGG "," GGG D GGG "," GG B GG "," GG B GG "," G G "," GG GG "," G G "," G G "," C C "," CC CC "," CDBB BBDC "," CC CC "," C C "," G G "," G G "," GG GG "," G G "," GG B GG "," GG B GG "," GGG D GGG "," GGGCCCCCGGG "," C C "," "," "," "," "," "}, - {" "," "," "," "," "," "," C C "," GGGC CGGG "," GGG D GGG "," GG D GG "," GG GG "," G G "," GG GG "," G G "," G G "," CC CC "," DD DD "," CC CC "," G G "," G G "," GG GG "," G D G "," GG D GG "," GG D GG "," GGG D GGG "," GGGC CGGG "," C C "," "," "," "," "," "," "}, - {" "," "," "," "," "," "," "," C C "," GGC CGG "," GGGGC CGGGG "," GGG D GGG "," GGG D GGG "," GG DDDDDDD GG "," GG DD DD GG "," GG D EEE D GG "," CCC D EAAAE D CCC "," DDD EAAAE DDD "," CCC D EAAAE D CCC "," GG D EEE D GG "," GG DD DD GG "," GG DDDDDDD GG "," GGG D GGG "," GGG D GGG "," GGGGC CGGGG "," GGC CGG "," C C "," "," "," "," "," "," "," "}, - {" "," "," "," "," "," "," "," "," "," C C "," GGC CGG "," GGGC CGGG "," GGGGC CGGGG "," GGGGDDDDDGGGG "," GGGDDCDCDDGGG "," CCCCDCCDCCDCCCC "," DDDDDDD "," CCCCDCCDCCDCCCC "," GGGDDCDCDDGGG "," GGGGDDDDDGGGG "," GGGGC CGGGG "," GGGC CGGG "," GGC CGG "," C C "," "," "," "," "," "," "," "," "," "}, - {" "," "," "," "," "," "," "," "," "," "," "," "," C C "," C C "," C C "," CCCCCCCCC "," C C "," CCCCCCCCC "," C C "," C C "," C C "," "," "," "," "," "," "," "," "," "," "," "," "} + {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " C C ", " C C ", " C C ", " CCCCCCCCC ", " C C ", " CCCCCCCCC ", " C C ", " C C ", " C C ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " ", " ", " ", " ", " ", " C C ", " GGC CGG ", " GGGC CGGG ", " GGGGC CGGGG ", " GGGGDDDDDGGGG ", " GGGDDCDCDDGGG ", " CCCCDCCDCCDCCCC ", " DDDDDDD ", " CCCCDCCDCCDCCCC ", " GGGDDCDCDDGGG ", " GGGGDDDDDGGGG ", " GGGGC CGGGG ", " GGGC CGGG ", " GGC CGG ", " C C ", " ", " ", " ", " ", " ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " ", " ", " ", " C C ", " GGC CGG ", " GGGGC CGGGG ", " GGG D GGG ", " GGG D GGG ", " GG DDDDDDD GG ", " GG DD DD GG ", " GG D EEE D GG ", " CCC D EAAAE D CCC ", " DDD EAAAE DDD ", " CCC D EAAAE D CCC ", " GG D EEE D GG ", " GG DD DD GG ", " GG DDDDDDD GG ", " GGG D GGG ", " GGG D GGG ", " GGGGC CGGGG ", " GGC CGG ", " C C ", " ", " ", " ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " ", " ", " C C ", " GGGC CGGG ", " GGG D GGG ", " GG D GG ", " GG GG ", " G G ", " GG GG ", " G G ", " G G ", " CC CC ", " DD DD ", " CC CC ", " G G ", " G G ", " GG GG ", " G G ", " GG GG ", " GG D GG ", " GGG D GGG ", " GGGC CGGG ", " C C ", " ", " ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " ", " C C ", " GGGCCCCCGGG ", " GGG D GGG ", " GG B GG ", " GG B GG ", " G G ", " GG GG ", " G G ", " G G ", " C C ", " CC CC ", " CDBB BBDC ", " CC CC ", " C C ", " G G ", " G G ", " GG GG ", " G G ", " GG B GG ", " GG B GG ", " GGG D GGG ", " GGGCCCCCGGG ", " C C ", " ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " C C ", " GGGGGC CGGGGG ", " GGG D GGG ", " GG EEEBEEE GG ", " GG GG ", " G G ", " GG GG ", " G G ", " G G ", " G E E G ", " G E E G ", " CC E E CC ", " DB BD ", " CC E E CC ", " G E E G ", " G E E G ", " G G ", " G G ", " GG GG ", " G G ", " GG GG ", " GG EEEBEEE GG ", " GGG D GGG ", " GGGGGC CGGGGG ", " C C ", " ", " ", " ", " "}, + {" ", " ", " ", " C C ", " GGGCCCCCGGG ", " GGG D GGG ", " GG B GG ", " G G ", " GG GG ", " G G ", " G G ", " G G ", " G G ", " G G ", " C C ", " CC CC ", " CDB BDC ", " CC CC ", " C C ", " G G ", " G G ", " G G ", " G G ", " G G ", " GG GG ", " G G ", " GG B GG ", " GGG D GGG ", " GGGCCCCCGGG ", " C C ", " ", " ", " "}, + {" ", " ", " C C ", " GGGC CGGG ", " GGG D GGG ", " GG EEEBEEE GG ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G E E G ", " G E E G ", " CC E E CC ", " DB BD ", " CC E E CC ", " G E E G ", " G E E G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " GG EEEBEEE GG ", " GGG D GGG ", " GGGC CGGG ", " C C ", " ", " "}, + {" ", " ", " GGC CGG ", " GGG D GGG ", " GG B GG ", " GG GG ", " GG GG ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " C C ", " DB BD ", " C C ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " GG GG ", " GG GG ", " GG B GG ", " GGG D GGG ", " GGC CGG ", " ", " "}, + {" ", " C C ", " GGGGC CGGGG ", " GG D GG ", " GG B GG ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " CC CC ", " DB BD ", " CC CC ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " GG B GG ", " GG D GG ", " GGGGC CGGGG ", " C C ", " "}, + {" ", " GGC CGG ", " GGG D GGG ", " GG GG ", " G G ", " GG GG ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " C C ", " D D ", " C C ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " GG GG ", " G G ", " GG GG ", " GGG D GGG ", " GGC CGG ", " "}, + {" ", " GGGC CGGG ", " GGG D GGG ", " G G ", " GG GG ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " C C ", " D D ", " C C ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " GG GG ", " G G ", " GGG D GGG ", " GGGC CGGG ", " "}, + {" CCCCCCC ", " GGGGC CGGGG ", " GG DDDDDDD GG ", " GG GG ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " GD DG ", " GD DG ", "CCD DCC", " D D ", "CCD DCC", " GD DG ", " GD DG ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " GG GG ", " GG DDDDDDD GG ", " GGGGC CGGGG ", " C C "}, + {" CCHHHHHCC ", " GGGGDDDDDGGGG ", " GG DD DD GG ", " G G ", " G G ", " G E E G ", " G G ", " G E E G ", " G G ", " G G ", " G G ", " G G ", " GD DG ", " GD DG ", " D D ", "CD DC", " D D ", "CD DC", " D D ", " GD DG ", " GD DG ", " G G ", " G G ", " G G ", " G G ", " G E E G ", " G G ", " G E E G ", " G G ", " G G ", " GG DD DD GG ", " GGGGDDDDDGGGG ", " C C "}, + {" CHHHHHHHC ", " GGGDDCDCDDGGG ", " GG D EEE D GG ", " G G ", " C C ", " G E E G ", " C C ", " G E E G ", " G G ", " G G ", " G G ", " G G ", " GD DG ", " D D ", " D D ", "CCE ECC", " DE ED ", "CCE ECC", " D D ", " D D ", " GD DG ", " G G ", " G G ", " G G ", " G G ", " G E E G ", " C C ", " G E E G ", " C C ", " G G ", " GG D EEE D GG ", " GGGDDCDCDDGGG ", " C C "}, + {" CHHFFFHHC ", " CCCCDCCDCCDCCCC ", " CCC D EAAAE D CCC ", " CC CC ", " CC CC ", " CC E E CC ", " CC CC ", " CC E E CC ", " C C ", " CC CC ", " C C ", " C C ", "CCD DCC", "CD DC", "CCE ECC", "CCA ACC", "CDA ADC", "CCA ACC", "CCE ECC", "CD DC", "CCD DCC", " C C ", " C C ", " CC CC ", " C C ", " CC E E CC ", " CC CC ", " CC E E CC ", " CC CC ", " CC CC ", " CCC D EAAAE D CCC ", " CCCCDCCDCCDCCCC ", " CCCCCCCCC "}, + {" CHHF~FHHC ", " DDDDDDD ", " DDD EAAAE DDD ", " DD DD ", " CDBB BBDC ", " DB BD ", " CDB BDC ", " DB BD ", " DB BD ", " DB BD ", " D D ", " D D ", " D D ", " D D ", " DE ED ", "CDA ADC", " DA AD ", "CDA ADC", " DE ED ", " D D ", " D D ", " D D ", " D D ", " DB BD ", " DB BD ", " DB BD ", " CDB BDC ", " DB BD ", " CDBB BBDC ", " DD DD ", " DDD EAAAE DDD ", " DDDDDDD ", " C C "}, + {" CHHFFFHHC ", " CCCCDCCDCCDCCCC ", " CCC D EAAAE D CCC ", " CC CC ", " CC CC ", " CC E E CC ", " CC CC ", " CC E E CC ", " C C ", " CC CC ", " C C ", " C C ", "CCD DCC", "CD DC", "CCE ECC", "CCA ACC", "CDA ADC", "CCA ACC", "CCE ECC", "CD DC", "CCD DCC", " C C ", " C C ", " CC CC ", " C C ", " CC E E CC ", " CC CC ", " CC E E CC ", " CC CC ", " CC CC ", " CCC D EAAAE D CCC ", " CCCCDCCDCCDCCCC ", " CCCCCCCCC "}, + {" CHHHHHHHC ", " GGGDDCDCDDGGG ", " GG D EEE D GG ", " G G ", " C C ", " G E E G ", " C C ", " G E E G ", " G G ", " G G ", " G G ", " G G ", " GD DG ", " D D ", " D D ", "CCE ECC", " DE ED ", "CCE ECC", " D D ", " D D ", " GD DG ", " G G ", " G G ", " G G ", " G G ", " G E E G ", " C C ", " G E E G ", " C C ", " G G ", " GG D EEE D GG ", " GGGDDCDCDDGGG ", " C C "}, + {" CCHHHHHCC ", " GGGGDDDDDGGGG ", " GG DD DD GG ", " G G ", " G G ", " G E E G ", " G G ", " G E E G ", " G G ", " G G ", " G G ", " G G ", " GD DG ", " GD DG ", " D D ", "CD DC", " D D ", "CD DC", " D D ", " GD DG ", " GD DG ", " G G ", " G G ", " G G ", " G G ", " G E E G ", " G G ", " G E E G ", " G G ", " G G ", " GG DD DD GG ", " GGGGDDDDDGGGG ", " C C "}, + {" CCCCCCC ", " GGGGC CGGGG ", " GG DDDDDDD GG ", " GG GG ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " GD DG ", " GD DG ", "CCD DCC", " D D ", "CCD DCC", " GD DG ", " GD DG ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " GG GG ", " GG DDDDDDD GG ", " GGGGC CGGGG ", " C C "}, + {" ", " GGGC CGGG ", " GGG D GGG ", " G G ", " GG GG ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " C C ", " D D ", " C C ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " GG GG ", " G G ", " GGG D GGG ", " GGGC CGGG ", " "}, + {" ", " GGC CGG ", " GGG D GGG ", " GG GG ", " G G ", " GG GG ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " C C ", " D D ", " C C ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " GG GG ", " G G ", " GG GG ", " GGG D GGG ", " GGC CGG ", " "}, + {" ", " C C ", " GGGGC CGGGG ", " GG D GG ", " GG B GG ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " CC CC ", " DB BD ", " CC CC ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " GG B GG ", " GG D GG ", " GGGGC CGGGG ", " C C ", " "}, + {" ", " ", " GGC CGG ", " GGG D GGG ", " GG B GG ", " GG GG ", " GG GG ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " C C ", " DB BD ", " C C ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " GG GG ", " GG GG ", " GG B GG ", " GGG D GGG ", " GGC CGG ", " ", " "}, + {" ", " ", " C C ", " GGGC CGGG ", " GGG D GGG ", " GG EEEBEEE GG ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G E E G ", " G E E G ", " CC E E CC ", " DB BD ", " CC E E CC ", " G E E G ", " G E E G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " G G ", " GG EEEBEEE GG ", " GGG D GGG ", " GGGC CGGG ", " C C ", " ", " "}, + {" ", " ", " ", " C C ", " GGGCCCCCGGG ", " GGG D GGG ", " GG B GG ", " G G ", " GG GG ", " G G ", " G G ", " G G ", " G G ", " G G ", " C C ", " CC CC ", " CDB BDC ", " CC CC ", " C C ", " G G ", " G G ", " G G ", " G G ", " G G ", " GG GG ", " G G ", " GG B GG ", " GGG D GGG ", " GGGCCCCCGGG ", " C C ", " ", " ", " "}, + {" ", " ", " ", " ", " C C ", " GGGGGC CGGGGG ", " GGG D GGG ", " GG EEEBEEE GG ", " GG GG ", " G G ", " GG GG ", " G G ", " G G ", " G E E G ", " G E E G ", " CC E E CC ", " DB BD ", " CC E E CC ", " G E E G ", " G E E G ", " G G ", " G G ", " GG GG ", " G G ", " GG GG ", " GG EEEBEEE GG ", " GGG D GGG ", " GGGGGC CGGGGG ", " C C ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " ", " C C ", " GGGCCCCCGGG ", " GGG D GGG ", " GG B GG ", " GG B GG ", " G G ", " GG GG ", " G G ", " G G ", " C C ", " CC CC ", " CDBB BBDC ", " CC CC ", " C C ", " G G ", " G G ", " GG GG ", " G G ", " GG B GG ", " GG B GG ", " GGG D GGG ", " GGGCCCCCGGG ", " C C ", " ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " ", " ", " C C ", " GGGC CGGG ", " GGG D GGG ", " GG D GG ", " GG GG ", " G G ", " GG GG ", " G G ", " G G ", " CC CC ", " DD DD ", " CC CC ", " G G ", " G G ", " GG GG ", " G D G ", " GG D GG ", " GG D GG ", " GGG D GGG ", " GGGC CGGG ", " C C ", " ", " ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " ", " ", " ", " C C ", " GGC CGG ", " GGGGC CGGGG ", " GGG D GGG ", " GGG D GGG ", " GG DDDDDDD GG ", " GG DD DD GG ", " GG D EEE D GG ", " CCC D EAAAE D CCC ", " DDD EAAAE DDD ", " CCC D EAAAE D CCC ", " GG D EEE D GG ", " GG DD DD GG ", " GG DDDDDDD GG ", " GGG D GGG ", " GGG D GGG ", " GGGGC CGGGG ", " GGC CGG ", " C C ", " ", " ", " ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " ", " ", " ", " ", " ", " C C ", " GGC CGG ", " GGGC CGGG ", " GGGGC CGGGG ", " GGGGDDDDDGGGG ", " GGGDDCDCDDGGG ", " CCCCDCCDCCDCCCC ", " DDDDDDD ", " CCCCDCCDCCDCCCC ", " GGGDDCDCDDGGG ", " GGGGDDDDDGGGG ", " GGGGC CGGGG ", " GGGC CGGG ", " GGC CGG ", " C C ", " ", " ", " ", " ", " ", " ", " ", " ", " "}, + {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " C C ", " C C ", " C C ", " CCCCCCCCC ", " C C ", " CCCCCCCCC ", " C C ", " C C ", " C C ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "} })) .addElement('A', ofBlock(sBlockCasingsTT, 10)) .addElement('B', ofBlock(sBlockCasingsTT, 11)) .addElement('C', ofBlock(sBlockCasingsTT, 12)) .addElement('D', ofBlock(sBlockCasingsTT, 13)) .addElement('E', ofBlock(sBlockCasingsTT, 14)) - .addElement('F', ofHatchAdderOptional(GT_MetaTileEntity_EM_bhg::addElementalToMachineList, textureOffset + 4, 2, sBlockCasingsTT, 4)) .addElement('G', ofBlock(QuantumGlassBlock.INSTANCE, 0)) .addElement('H', ofHatchAdderOptional(GT_MetaTileEntity_EM_bhg::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) + .addElement('F', ofHatchAdderOptional(GT_MetaTileEntity_EM_bhg::addElementalToMachineList, textureOffset + 4, 2, sBlockCasingsTT, 4)) .build(); @Override @@ -307,9 +306,8 @@ public class GT_MetaTileEntity_EM_bhg extends GT_MetaTileEntity_MultiblockBase_E @Override public void construct(ItemStack stackSize, boolean hintsOnly) { try { - structureBuild_EM((stackSize.stackSize & 1) == 1 ? "main_t1" : "main_t2", 16, 16, 0, hintsOnly, stackSize); - } - catch (Exception e) { + structureBuild_EM((stackSize.stackSize & 1) == 1 ? "main_t1" : "main_t2", 16, 16, 0, stackSize, hintsOnly); + } catch (Exception e) { e.printStackTrace(); } } @@ -318,4 +316,4 @@ public class GT_MetaTileEntity_EM_bhg extends GT_MetaTileEntity_MultiblockBase_E public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java index 31d41fb39e..3f8e9170de 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java @@ -8,10 +8,9 @@ import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_H import com.github.technus.tectech.thing.metaTileEntity.multi.base.*; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.TT_Utility; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import com.gtnewhorizon.structurelib.util.Vec3Impl; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -58,8 +57,8 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB translateToLocal("gt.blockmachines.multimachine.em.computer.hint.1"),//2 - Rack Hatches or Advanced computer casing }; - private static final IStructureDefinition<GT_MetaTileEntity_EM_computer> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_EM_computer>builder() + private static final IStructureDefinition<GT_MetaTileEntity_EM_computer> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_EM_computer>builder() .addShape("front", transpose(new String[][]{ {" AA"}, {" AA"}, @@ -84,10 +83,10 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB {" AA"}, {" AA"} })) - .addElement('A', ofHatchAdderOptional(GT_MetaTileEntity_EM_computer::addToMachineList, textureOffset + 1, 1, sBlockCasingsTT, 1)) .addElement('B', ofBlock(sBlockCasingsTT, 1)) .addElement('C', ofBlock(sBlockCasingsTT, 2)) .addElement('D', ofBlock(sBlockCasingsTT, 3)) + .addElement('A', ofHatchAdderOptional(GT_MetaTileEntity_EM_computer::addToMachineList, textureOffset + 1, 1, sBlockCasingsTT, 1)) .addElement('E', ofHatchAdderOptional(GT_MetaTileEntity_EM_computer::addRackToMachineList, textureOffset + 3, 2, sBlockCasingsTT, 3)) .build(); //endregion @@ -96,17 +95,17 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB protected Parameters.Group.ParameterIn overclock, overvolt; protected Parameters.Group.ParameterOut maxCurrentTemp, availableData; - private static final INameFunction<GT_MetaTileEntity_EM_computer> OC_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.em.computer.cfgi.0");//Overclock ratio - private static final INameFunction<GT_MetaTileEntity_EM_computer> OV_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.em.computer.cfgi.1");//Overvoltage ratio - private static final INameFunction<GT_MetaTileEntity_EM_computer> MAX_TEMP_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.em.computer.cfgo.0");//Current max. heat - private static final INameFunction<GT_MetaTileEntity_EM_computer> COMPUTE_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.em.computer.cfgo.1");//Produced computation - private static final IStatusFunction<GT_MetaTileEntity_EM_computer> OC_STATUS = + private static final INameFunction<GT_MetaTileEntity_EM_computer> OC_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.em.computer.cfgi.0");//Overclock ratio + private static final INameFunction<GT_MetaTileEntity_EM_computer> OV_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.em.computer.cfgi.1");//Overvoltage ratio + private static final INameFunction<GT_MetaTileEntity_EM_computer> MAX_TEMP_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.em.computer.cfgo.0");//Current max. heat + private static final INameFunction<GT_MetaTileEntity_EM_computer> COMPUTE_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.em.computer.cfgo.1");//Produced computation + private static final IStatusFunction<GT_MetaTileEntity_EM_computer> OC_STATUS = (base, p) -> LedStatus.fromLimitsInclusiveOuterBoundary(p.get(), 0, 1, 1, 3); - private static final IStatusFunction<GT_MetaTileEntity_EM_computer> OV_STATUS = + private static final IStatusFunction<GT_MetaTileEntity_EM_computer> OV_STATUS = (base, p) -> LedStatus.fromLimitsInclusiveOuterBoundary(p.get(), .7, .8, 1.2, 2); private static final IStatusFunction<GT_MetaTileEntity_EM_computer> MAX_TEMP_STATUS = (base, p) -> LedStatus.fromLimitsInclusiveOuterBoundary(p.get(), -10000, 0, 0, 5000); - private static final IStatusFunction<GT_MetaTileEntity_EM_computer> COMPUTE_STATUS = (base, p) -> { + private static final IStatusFunction<GT_MetaTileEntity_EM_computer> COMPUTE_STATUS = (base, p) -> { if (base.eAvailableData < 0) { return STATUS_TOO_LOW; } @@ -186,7 +185,7 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); - if(aBaseMetaTileEntity.isServerSide() && mMachine && !aBaseMetaTileEntity.isActive() && aTick % 20 == MULTI_CHECK_AT){ + if (aBaseMetaTileEntity.isServerSide() && mMachine && !aBaseMetaTileEntity.isActive() && aTick % 20 == MULTI_CHECK_AT) { double maxTemp = 0; for (GT_MetaTileEntity_Hatch_Rack rack : eRacks) { if (!GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(rack)) { @@ -204,8 +203,8 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB public boolean checkRecipe_EM(ItemStack itemStack) { parametrization.setToDefaults(false, true); eAvailableData = 0; - double maxTemp = 0; - double overClockRatio = overclock.get(); + double maxTemp = 0; + double overClockRatio = overclock.get(); double overVoltageRatio = overvolt.get(); if (Double.isNaN(overClockRatio) || Double.isNaN(overVoltageRatio)) { return false; @@ -219,7 +218,7 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB return false; } short thingsActive = 0; - int rackComputation; + int rackComputation; for (GT_MetaTileEntity_Hatch_Rack rack : eRacks) { if (!GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(rack)) { @@ -269,8 +268,8 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB public void outputAfterRecipe_EM() { if (!eOutputData.isEmpty()) { Vec3Impl pos = new Vec3Impl(getBaseMetaTileEntity().getXCoord(), - getBaseMetaTileEntity().getYCoord(), - getBaseMetaTileEntity().getZCoord()); + getBaseMetaTileEntity().getYCoord(), + getBaseMetaTileEntity().getZCoord()); QuantumDataPacket pack = new QuantumDataPacket(eAvailableData / eOutputData.size()).unifyTraceWith(pos); if (pack == null) { @@ -296,7 +295,7 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB public String[] getDescription() { return new String[]{ CommonValues.TEC_MARK_EM, - Util.intBitsToString(TecTech.RANDOM.nextInt()), + TT_Utility.intBitsToString(TecTech.RANDOM.nextInt()), EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.em.computer.desc")//You need it to process the number above }; } @@ -384,16 +383,16 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB @Override public void construct(ItemStack stackSize, boolean hintsOnly) { IGregTechTileEntity igt = getBaseMetaTileEntity(); - structureBuild_EM("front", 1, 2, 0, hintsOnly, stackSize); - structureBuild_EM("cap", 1, 2, -1, hintsOnly, stackSize); + structureBuild_EM("front", 1, 2, 0, stackSize, hintsOnly); + structureBuild_EM("cap", 1, 2, -1, stackSize, hintsOnly); byte offset = -2; for (int rackSlices = Math.min(stackSize.stackSize, 12); rackSlices > 0; rackSlices--) { - structureBuild_EM("slice", 1 , 2, offset--, hintsOnly, stackSize); + structureBuild_EM("slice", 1, 2, offset--, stackSize, hintsOnly); } - structureBuild_EM("cap", 1, 2, offset--, hintsOnly, stackSize); - structureBuild_EM("back", 1, 2, offset, hintsOnly, stackSize); + structureBuild_EM("cap", 1, 2, offset--, stackSize, hintsOnly); + structureBuild_EM("back", 1, 2, offset, stackSize, hintsOnly); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java index 9c631c8af6..014e2b3a65 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java @@ -6,7 +6,6 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_Rend import com.github.technus.tectech.util.CommonValues; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -43,23 +42,23 @@ public class GT_MetaTileEntity_EM_crafting extends GT_MetaTileEntity_MultiblockB translateToLocal("gt.blockmachines.multimachine.em.crafter.hint.1"),//2 - Elemental Hatches or Molecular Casing }; - private static final IStructureDefinition<GT_MetaTileEntity_EM_crafting> STRUCTURE_DEFINITION= StructureDefinition + private static final IStructureDefinition<GT_MetaTileEntity_EM_crafting> STRUCTURE_DEFINITION = IStructureDefinition .<GT_MetaTileEntity_EM_crafting>builder() .addShape("main", transpose(new String[][]{ - {" AAA ","AAAAA","A A","BBBBB","BGCGB","BGGGB","BGCGB","BBBBB","A A","AAAAA"," AAA "}, - {"AHHHA","AAAAA"," FFF ","BBBBB","GGGGG","GGGGG","GGGGG","BBBBB"," FFF ","AAAAA","AHHHA"}, - {"AH~HA","AAAAA"," FEF ","BBEBB","CGEGC","GGDGG","CGEGC","BBEBB"," FEF ","AAAAA","AHHHA"}, - {"AHHHA","AAAAA"," FFF ","BBBBB","GGGGG","GGGGG","GGGGG","BBBBB"," FFF ","AAAAA","AHHHA"}, - {" AAA ","AAAAA","A A","BBBBB","BGCGB","BGGGB","BGCGB","BBBBB","A A","AAAAA"," AAA "} + {" AAA ", "AAAAA", "A A", "BBBBB", "BGCGB", "BGGGB", "BGCGB", "BBBBB", "A A", "AAAAA", " AAA "}, + {"AHHHA", "AAAAA", " FFF ", "BBBBB", "GGGGG", "GGGGG", "GGGGG", "BBBBB", " FFF ", "AAAAA", "AHHHA"}, + {"AH~HA", "AAAAA", " FEF ", "BBEBB", "CGEGC", "GGDGG", "CGEGC", "BBEBB", " FEF ", "AAAAA", "AHHHA"}, + {"AHHHA", "AAAAA", " FFF ", "BBBBB", "GGGGG", "GGGGG", "GGGGG", "BBBBB", " FFF ", "AAAAA", "AHHHA"}, + {" AAA ", "AAAAA", "A A", "BBBBB", "BGCGB", "BGGGB", "BGCGB", "BBBBB", "A A", "AAAAA", " AAA "} })) .addElement('A', ofBlock(sBlockCasingsTT, 4)) .addElement('B', ofBlock(sBlockCasingsTT, 5)) .addElement('C', ofBlock(sBlockCasingsTT, 6)) .addElement('D', ofBlock(sBlockCasingsTT, 9)) .addElement('E', ofBlock(sBlockCasingsTT, 10)) - .addElement('F', ofHatchAdderOptional(GT_MetaTileEntity_EM_crafting::addElementalToMachineList, textureOffset + 4, 2, sBlockCasingsTT, 4)) .addElement('G', ofBlock(QuantumGlassBlock.INSTANCE, 0)) .addElement('H', ofHatchAdderOptional(GT_MetaTileEntity_EM_crafting::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) + .addElement('F', ofHatchAdderOptional(GT_MetaTileEntity_EM_crafting::addElementalToMachineList, textureOffset + 4, 2, sBlockCasingsTT, 4)) .build(); //endregion @@ -108,7 +107,7 @@ public class GT_MetaTileEntity_EM_crafting extends GT_MetaTileEntity_MultiblockB @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - structureBuild_EM("main", 2, 2, 0, hintsOnly, stackSize); + structureBuild_EM("main", 2, 2, 0, stackSize, hintsOnly); } @Override @@ -120,4 +119,4 @@ public class GT_MetaTileEntity_EM_crafting extends GT_MetaTileEntity_MultiblockB public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java index bea2b8a0ba..9a9747f012 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java @@ -11,7 +11,6 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_Rend import com.github.technus.tectech.util.CommonValues; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -40,7 +39,7 @@ import static net.minecraft.util.StatCollector.translateToLocal; public class GT_MetaTileEntity_EM_dataBank extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { //region variables private final ArrayList<GT_MetaTileEntity_Hatch_OutputDataItems> eStacksDataOutputs = new ArrayList<>(); - private final ArrayList<GT_MetaTileEntity_Hatch_DataAccess> eDataAccessHatches = new ArrayList<>(); + private final ArrayList<GT_MetaTileEntity_Hatch_DataAccess> eDataAccessHatches = new ArrayList<>(); //endregion //region structure @@ -50,12 +49,12 @@ public class GT_MetaTileEntity_EM_dataBank extends GT_MetaTileEntity_MultiblockB translateToLocal("gt.blockmachines.multimachine.em.databank.hint.1"),//2 - Data Access/Data Bank Master Hatches or computer casing }; - private static final IStructureDefinition<GT_MetaTileEntity_EM_dataBank> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_EM_dataBank>builder() + private static final IStructureDefinition<GT_MetaTileEntity_EM_dataBank> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_EM_dataBank>builder() .addShape("main", transpose(new String[][]{ - {"BCCCB","BDDDB","BDDDB"}, - {"BC~CB","BAAAB","BDDDB"}, - {"BCCCB","BDDDB","BDDDB"} + {"BCCCB", "BDDDB", "BDDDB"}, + {"BC~CB", "BAAAB", "BDDDB"}, + {"BCCCB", "BDDDB", "BDDDB"} })) .addElement('A', ofBlock(sBlockCasingsTT, 1)) .addElement('B', ofBlock(sBlockCasingsTT, 2)) @@ -131,12 +130,12 @@ public class GT_MetaTileEntity_EM_dataBank extends GT_MetaTileEntity_MultiblockB @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity,true, false, true); + return new GT_Container_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, true, false, true); } @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "EMDisplay.png",true, false, true);//todo texture + return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "EMDisplay.png", true, false, true);//todo texture } @Override @@ -175,7 +174,7 @@ public class GT_MetaTileEntity_EM_dataBank extends GT_MetaTileEntity_MultiblockB @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - structureBuild_EM("main", 2, 1, 0, hintsOnly, stackSize); + structureBuild_EM("main", 2, 1, 0, stackSize, hintsOnly); } @Override @@ -187,4 +186,4 @@ public class GT_MetaTileEntity_EM_dataBank extends GT_MetaTileEntity_MultiblockB public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java index 3fdf841b52..18b0047ef4 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputElemental; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; @@ -12,7 +12,6 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_Rend import com.github.technus.tectech.util.CommonValues; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -31,7 +30,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import org.apache.commons.lang3.reflect.FieldUtils; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; @@ -52,8 +51,8 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase private static Textures.BlockIcons.CustomIcon ScreenOFF; private static Textures.BlockIcons.CustomIcon ScreenON; - public static final double URANIUM_INGOT_MASS_DIFF = 1.6114516E10* AVOGADRO_CONSTANT; - private static final double URANIUM_MASS_TO_EU_PARTIAL = ConfigUtil.getFloat(MainConfig.get(), "balance/energy/generator/nuclear") * 3_000_000.0 / URANIUM_INGOT_MASS_DIFF; + public static final double URANIUM_INGOT_MASS_DIFF = 1.6114516E10* EM_COUNT_PER_MATERIAL_AMOUNT; + private static final double URANIUM_MASS_TO_EU_PARTIAL = ConfigUtil.getDouble(MainConfig.get(), "balance/energy/generator/nuclear") * 3_000_000.0 / URANIUM_INGOT_MASS_DIFF; public static final double URANIUM_MASS_TO_EU_INSTANT = URANIUM_MASS_TO_EU_PARTIAL * 20; private String clientLocale = "en_US"; @@ -66,8 +65,8 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase translateToLocal("gt.blockmachines.multimachine.em.decay.hint.1"),//2 - Elemental Hatches or Molecular Casing }; - private static final IStructureDefinition<GT_MetaTileEntity_EM_decay> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_EM_decay>builder() + private static final IStructureDefinition<GT_MetaTileEntity_EM_decay> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_EM_decay>builder() .addShape("main",transpose(new String[][]{ {"A A","AAAAA","A A","ABBBA","ABCBA","ABBBA","A A","AAAAA","A A"}, {" FFF ","AAAAA"," EEE ","BDDDB","BDDDB","BDDDB"," EEE ","AAAAA"," FFF "}, @@ -79,8 +78,8 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase .addElement('B', ofBlock(sBlockCasingsTT, 5)) .addElement('C', ofBlock(sBlockCasingsTT, 6)) .addElement('D', ofBlock(sBlockCasingsTT, 8)) - .addElement('E', ofHatchAdderOptional(GT_MetaTileEntity_EM_decay::addElementalToMachineList, textureOffset + 4, 2, sBlockCasingsTT, 4)) .addElement('F', ofHatchAdderOptional(GT_MetaTileEntity_EM_decay::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) + .addElement('E', ofHatchAdderOptional(GT_MetaTileEntity_EM_decay::addElementalToMachineList, textureOffset + 4, 2, sBlockCasingsTT, 4)) .build(); //endregion @@ -115,30 +114,30 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase @Override public boolean checkRecipe_EM(ItemStack itemStack) { - cElementalInstanceStackMap map = getInputsClone_EM(); + EMInstanceStackMap map = getInputsClone_EM(); if (map != null && map.hasStacks()) { for (GT_MetaTileEntity_Hatch_InputElemental i : eInputHatches) { - i.getContainerHandler().clear(); + i.getContentHandler().clear(); } return startRecipe(map); } return false; } - private boolean startRecipe(cElementalInstanceStackMap input) { + private boolean startRecipe(EMInstanceStackMap input) { mMaxProgresstime = 20; mEfficiencyIncrease = 10000; - outputEM = new cElementalInstanceStackMap[2]; + outputEM = new EMInstanceStackMap[2]; outputEM[0] = input; - outputEM[1] = new cElementalInstanceStackMap(); + outputEM[1] = new EMInstanceStackMap(); - for (cElementalInstanceStack stack : outputEM[0].values()) { - if (stack.getEnergy() == 0 && stack.definition.decayMakesEnergy(1) && + for (EMInstanceStack stack : outputEM[0].valuesToArray()) { + if (stack.getEnergy() == 0 && stack.getDefinition().decayMakesEnergy(1) && getBaseMetaTileEntity().decreaseStoredEnergyUnits( (long) (stack.getEnergySettingCost(1) * URANIUM_MASS_TO_EU_INSTANT), false)) { stack.setEnergy(1); - } else if (!stack.definition.decayMakesEnergy(stack.getEnergy())) { - outputEM[0].remove(stack.definition); + } else if (!stack.getDefinition().decayMakesEnergy(stack.getEnergy())) { + outputEM[0].removeKey(stack.getDefinition()); outputEM[1].putReplace(stack); } } @@ -156,7 +155,7 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase @Override public void outputAfterRecipe_EM() { for (int i = 0; i < 2 && i < eOutputHatches.size(); i++) { - eOutputHatches.get(i).getContainerHandler().putUnifyAll(outputEM[i]); + eOutputHatches.get(i).getContentHandler().putUnifyAll(outputEM[i]); outputEM[i] = null; } } @@ -257,7 +256,7 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - structureBuild_EM("main", 2, 2, 0, hintsOnly, stackSize); + structureBuild_EM("main", 2, 2, 0, stackSize, hintsOnly); } @Override @@ -269,4 +268,4 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java index f0dca07f9c..5a045102ef 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java @@ -1,18 +1,17 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.iHasElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aFluidDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aItemDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aOredictDequantizationInfo; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMDequantizationInfo; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.OreDictionaryStack; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputElemental; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.util.CommonValues; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -25,12 +24,11 @@ import net.minecraftforge.oredict.OreDictionary; import java.util.ArrayList; -import static com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition.STABLE_RAW_LIFE_TIME; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition.refMass; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition.refUnstableMass; +import static com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition.STABLE_RAW_LIFE_TIME; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition.refMass; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition.refUnstableMass; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; -import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sHintCasingsTT; import static com.github.technus.tectech.util.CommonValues.V; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; @@ -45,19 +43,19 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo //region structure //use multi A energy inputs, use less power the longer it runs - private static final IStructureDefinition<GT_MetaTileEntity_EM_dequantizer> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_EM_dequantizer>builder() + private static final IStructureDefinition<GT_MetaTileEntity_EM_dequantizer> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_EM_dequantizer>builder() .addShape("main", transpose(new String[][]{ - {"CCC","ABA","EEE","BDB"}, - {"C~C","BBB","EBE","DFD"}, - {"CCC","ABA","EEE","BDB"} + {"CCC", "ABA", "EEE", "BDB"}, + {"C~C", "BBB", "EBE", "DFD"}, + {"CCC", "ABA", "EEE", "BDB"} })) .addElement('A', ofBlock(sBlockCasingsTT, 0)) .addElement('B', ofBlock(sBlockCasingsTT, 4)) - .addElement('C', ofHatchAdderOptional(GT_MetaTileEntity_EM_dequantizer::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) .addElement('D', ofBlock(QuantumGlassBlock.INSTANCE, 0)) + .addElement('C', ofHatchAdderOptional(GT_MetaTileEntity_EM_dequantizer::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) + .addElement('F', ofHatchAdder(GT_MetaTileEntity_EM_dequantizer::addElementalInputToMachineList, textureOffset + 4, 2)) .addElement('E', ofHatchAdderOptional(GT_MetaTileEntity_EM_dequantizer::addElementalMufflerToMachineList, textureOffset + 4, 3, sBlockCasingsTT, 4)) - .addElement('F', ofHatchAdder(GT_MetaTileEntity_EM_dequantizer::addElementalInputToMachineList, textureOffset + 4, sHintCasingsTT, 1)) .build(); private static final String[] description = new String[]{ @@ -76,10 +74,10 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo super(aName); } - private void startRecipe(iHasElementalDefinition from, long energy) { + private void startRecipe(IEMStack from, long energy) { mMaxProgresstime = 20; mEfficiencyIncrease = 10000; - double mass = from.getMass(); + double mass = from.getMass(); double euMult = Math.abs(mass / refMass); eAmpereFlow = (int) Math.ceil(Math.sqrt(Math.sqrt(euMult))); if (mass > refUnstableMass || from.getDefinition().getRawTimeSpan(energy) < STABLE_RAW_LIFE_TIME) { @@ -102,40 +100,23 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo @Override public boolean checkRecipe_EM(ItemStack itemStack) { for (GT_MetaTileEntity_Hatch_InputElemental in : eInputHatches) { - cElementalInstanceStackMap map = in.getContainerHandler(); - for (cElementalInstanceStack stack : map.values()) { - { - aFluidDequantizationInfo info = stack.getDefinition().someAmountIntoFluidStack(); - if (info != null) { - if (map.removeAllAmounts(false, info.input())) { - mOutputFluids = new FluidStack[]{info.output()}; - startRecipe(info.input(), stack.getEnergy()); - return true; - } - } - } - { - aItemDequantizationInfo info = stack.getDefinition().someAmountIntoItemsStack(); - if (info != null) { - if (map.removeAllAmounts(false, info.input())) { - mOutputItems = new ItemStack[]{info.output()}; - startRecipe(info.input(), stack.getEnergy()); - return true; - } - } - } - { - aOredictDequantizationInfo info = stack.getDefinition().someAmountIntoOredictStack(); - if (info != null) { - if (map.removeAllAmounts(false, info.input())) { - ArrayList<ItemStack> items = OreDictionary.getOres(info.out); - if (items != null && !items.isEmpty()) { - mOutputItems = new ItemStack[]{items.get(0)}; - startRecipe(info.input(), stack.getEnergy()); - return true; - } + EMInstanceStackMap map = in.getContentHandler(); + for (EMInstanceStack stack : map.valuesToArray()) { + EMDequantizationInfo emDequantizationInfo = TecTech.transformationInfo.getInfoMap().get(stack.getDefinition()); + if (emDequantizationInfo != null && emDequantizationInfo.getStack() != null && map.removeAllAmounts(emDequantizationInfo.getInput())) { + Object out = emDequantizationInfo.getStack(); + if (out instanceof ItemStack) { + mOutputItems = new ItemStack[]{emDequantizationInfo.getItem()}; + } else if (out instanceof FluidStack) { + mOutputFluids = new FluidStack[]{emDequantizationInfo.getFluid()}; + } else if (out instanceof OreDictionaryStack) { + ArrayList<ItemStack> items = OreDictionary.getOres(OreDictionary.getOreName(emDequantizationInfo.getOre().getOreId())); + if (items != null && !items.isEmpty()) { + mOutputItems = new ItemStack[]{items.get(0)}; } } + startRecipe(emDequantizationInfo.getInput(), stack.getEnergy()); + return true; } } } @@ -159,7 +140,7 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - structureBuild_EM("main", 1, 1, 0, hintsOnly, stackSize); + structureBuild_EM("main", 1, 1, 0, stackSize, hintsOnly); } @Override @@ -171,4 +152,4 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java index 18416e70f6..f6833d2cb9 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java @@ -9,7 +9,6 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEnt import com.github.technus.tectech.util.CommonValues; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -41,14 +40,14 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa translateToLocal("gt.blockmachines.multimachine.em.infuser.hint"),//1 - Classic Hatches or High Power Casing }; - private static final IStructureDefinition<GT_MetaTileEntity_EM_infuser> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_EM_infuser>builder() + private static final IStructureDefinition<GT_MetaTileEntity_EM_infuser> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_EM_infuser>builder() .addShape("main", transpose(new String[][]{ - {"CCC","CCC","CCC"}, - {"BBB","BAB","BBB"}, - {"A~A","AAA","AAA"}, - {"BBB","BAB","BBB"}, - {"CCC","CCC","CCC"} + {"CCC", "CCC", "CCC"}, + {"BBB", "BAB", "BBB"}, + {"A~A", "AAA", "AAA"}, + {"BBB", "BAB", "BBB"}, + {"CCC", "CCC", "CCC"} })) .addElement('A', ofBlock(sBlockCasingsTT, 4)) .addElement('B', ofBlock(sBlockCasingsTT, 7)) @@ -170,12 +169,12 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity,true, false, true); + return new GT_Container_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, true, false, true); } @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "EMDisplay.png",true, false, true); + return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "EMDisplay.png", true, false, true); } public final static ResourceLocation activitySound = new ResourceLocation(Reference.MODID + ":fx_whooum"); @@ -188,7 +187,7 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - structureBuild_EM("main", 1, 2, 0, hintsOnly, stackSize); + structureBuild_EM("main", 1, 2, 0, stackSize, hintsOnly); } @Override @@ -200,4 +199,4 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java index 53cf072293..23e7267388 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java @@ -9,7 +9,6 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; import com.github.technus.tectech.util.CommonValues; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Utility; @@ -36,8 +35,8 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB translateToLocal("gt.blockmachines.multimachine.em.junction.hint.1"),//2 - Elemental Hatches or Molecular Casing }; - private static final IStructureDefinition<GT_MetaTileEntity_EM_junction> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_EM_junction>builder() + private static final IStructureDefinition<GT_MetaTileEntity_EM_junction> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_EM_junction>builder() .addShape("main", new String[][]{ {"CCC", "C~C", "CCC"}, {"AAA", "AAA", "AAA"}, @@ -45,11 +44,11 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB {"DDD", "DDD", "DDD"} }) .addShape("mainBig", new String[][]{ - {" ", " CCC ", " C~C ", " CCC ", " "}, - {" DDD ", "DAAAD", "DABAD", "DAAAD", " DDD "}, - {"DDDDD", "DAAAD", "DAAAD", "DAAAD", "DDDDD"}, + {" A ", " CCC ", "AC~CA", " CCC ", " A "}, {" DDD ", "DAAAD", "DAAAD", "DAAAD", " DDD "}, - {" DDD ", "DDDDD", "DDDDD", "DDDDD", " DDD "} + {"ADDDA", "DAAAD", "DABAD", "DAAAD", "ADDDA"}, + {" DDD ", "DAAAD", "DAAAD", "DAAAD", " DDD "}, + {" A ", "DDDDD", "ADDDA", "DDDDD", " A "} }) .addElement('A', ofBlock(sBlockCasingsTT, 4)) .addElement('B', ofBlock(sBlockCasingsTT, 5)) @@ -59,7 +58,7 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB //endregion //region parameters - private static final INameFunction<GT_MetaTileEntity_EM_junction> ROUTE_NAME = + private static final INameFunction<GT_MetaTileEntity_EM_junction> ROUTE_NAME = (base, p) -> (p.parameterId() == 0 ? translateToLocal("tt.keyword.Source") + " " : translateToLocal("tt.keyword.Destination") + " ") + p.hatchId(); private static final IStatusFunction<GT_MetaTileEntity_EM_junction> SRC_STATUS = (base, p) -> { @@ -68,7 +67,7 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB v = (int) v; if (v < 0) return STATUS_TOO_LOW; if (v == 0) return STATUS_NEUTRAL; - if (v >= base.eInputHatches.size()) return STATUS_TOO_HIGH; + if (v > base.eOutputHatches.size()) return STATUS_TOO_HIGH; return STATUS_OK; }; private static final IStatusFunction<GT_MetaTileEntity_EM_junction> DST_STATUS = @@ -79,13 +78,13 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB v = (int) v; if (v < 0) return STATUS_TOO_LOW; if (v == 0) return STATUS_LOW; - if (v >= base.eInputHatches.size()) return STATUS_TOO_HIGH; + if (v > base.eInputHatches.size()) return STATUS_TOO_HIGH; return STATUS_OK; } return STATUS_NEUTRAL; }; - protected Parameters.Group.ParameterIn[] src; - protected Parameters.Group.ParameterIn[] dst; + protected Parameters.Group.ParameterIn[] src; + protected Parameters.Group.ParameterIn[] dst; //endregion public GT_MetaTileEntity_EM_junction(int aID, String aName, String aNameRegional) { @@ -103,7 +102,7 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB @Override public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - int meta = iGregTechTileEntity.getMetaIDAtSide(GT_Utility.getOppositeSide(iGregTechTileEntity.getFrontFacing())); + int meta = iGregTechTileEntity.getMetaIDAtSideAndDistance(GT_Utility.getOppositeSide(iGregTechTileEntity.getFrontFacing()),2); if (meta == 4) { return structureCheck_EM("main", 1, 1, 0); } else if (meta == 5) { @@ -115,7 +114,7 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB @Override public boolean checkRecipe_EM(ItemStack itemStack) { for (GT_MetaTileEntity_Hatch_InputElemental in : eInputHatches) { - if (in.getContainerHandler().hasStacks()) { + if (in.getContentHandler().hasStacks()) { mEUt = -(int) V[8]; eAmpereFlow = 1 + (eInputHatches.size() + eOutputHatches.size() >> 1); mMaxProgresstime = 20; @@ -139,8 +138,8 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB if (inIndex < 0 || inIndex >= eInputHatches.size()) { continue; } - int outIndex = (int) dst - 1; - GT_MetaTileEntity_Hatch_InputElemental in = eInputHatches.get(inIndex); + int outIndex = (int) dst - 1; + GT_MetaTileEntity_Hatch_InputElemental in = eInputHatches.get(inIndex); if (outIndex == -1) {//param==0 -> null the content cleanHatchContentEM_EM(in); } else { @@ -148,8 +147,8 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB continue; } GT_MetaTileEntity_Hatch_OutputElemental out = eOutputHatches.get(outIndex); - out.getContainerHandler().putUnifyAll(in.getContainerHandler()); - in.getContainerHandler().clear(); + out.getContentHandler().putUnifyAll(in.getContentHandler()); + in.getContentHandler().clear(); } } } @@ -177,9 +176,9 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB @Override public void construct(ItemStack stackSize, boolean hintsOnly) { if ((stackSize.stackSize & 1) == 1) { - structureBuild_EM("main", 1, 1, 0, hintsOnly, stackSize); + structureBuild_EM("main", 1, 1, 0, stackSize, hintsOnly); } else { - structureBuild_EM("mainBig", 2, 2, 0, hintsOnly, stackSize); + structureBuild_EM("mainBig", 2, 2, 0, stackSize, hintsOnly); } } @@ -192,4 +191,4 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java index 5b6b2c18e7..306d470a8e 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java @@ -2,19 +2,17 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.Reference; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.iHasElementalDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aFluidQuantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aItemQuantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.aOredictQuantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMFluidQuantizationInfo; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMItemQuantizationInfo; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMOredictQuantizationInfo; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.util.CommonValues; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; @@ -29,16 +27,16 @@ import net.minecraftforge.oredict.OreDictionary; import java.util.ArrayList; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition.DEFAULT_ENERGY_LEVEL; -import static com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition.STABLE_RAW_LIFE_TIME; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition.refMass; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition.refUnstableMass; +import static com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition.DEFAULT_ENERGY_LEVEL; +import static com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition.STABLE_RAW_LIFE_TIME; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition.refMass; +import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition.refUnstableMass; import static com.github.technus.tectech.recipe.TT_recipeAdder.nullFluid; import static com.github.technus.tectech.recipe.TT_recipeAdder.nullItem; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; import static com.github.technus.tectech.util.CommonValues.V; -import static com.github.technus.tectech.util.Util.isInputEqual; +import static com.github.technus.tectech.util.TT_Utility.isInputEqual; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; @@ -51,19 +49,19 @@ import static net.minecraft.util.StatCollector.translateToLocal; public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { //region structure //use multi A energy inputs, use less power the longer it runs - private static final IStructureDefinition<GT_MetaTileEntity_EM_quantizer> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_EM_quantizer>builder() + private static final IStructureDefinition<GT_MetaTileEntity_EM_quantizer> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_EM_quantizer>builder() .addShape("main", transpose(new String[][]{ - {"CCC","BAB","EEE","DBD"}, - {"C~C","ABA","EBE","BFB"}, - {"CCC","BAB","EEE","DBD"} + {"CCC", "BAB", "EEE", "DBD"}, + {"C~C", "ABA", "EBE", "BFB"}, + {"CCC", "BAB", "EEE", "DBD"} })) .addElement('A', ofBlock(sBlockCasingsTT, 0)) .addElement('B', ofBlock(sBlockCasingsTT, 4)) - .addElement('C', ofHatchAdderOptional(GT_MetaTileEntity_EM_quantizer::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) .addElement('D', ofBlock(QuantumGlassBlock.INSTANCE, 0)) + .addElement('C', ofHatchAdderOptional(GT_MetaTileEntity_EM_quantizer::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) + .addElement('F', ofHatchAdder(GT_MetaTileEntity_EM_quantizer::addElementalOutputToMachineList, textureOffset + 4, 2)) .addElement('E', ofHatchAdderOptional(GT_MetaTileEntity_EM_quantizer::addElementalMufflerToMachineList, textureOffset + 4, 3, sBlockCasingsTT, 4)) - .addElement('F', ofHatchAdder(GT_MetaTileEntity_EM_quantizer::addElementalOutputToMachineList,textureOffset + 4, 2)) .build(); private static final String[] description = new String[]{ @@ -96,13 +94,13 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock public boolean checkRecipe_EM(ItemStack itemStack) {//TODO implement instance quantization if (GregTech_API.sPostloadFinished) { ArrayList<ItemStack> storedInputs = getStoredInputs(); - ItemStack[] inI = storedInputs.toArray(nullItem); + ItemStack[] inI = storedInputs.toArray(nullItem); if (inI.length > 0) { for (ItemStack is : inI) { //ITEM STACK quantization - aItemQuantizationInfo aIQI = bTransformationInfo.itemQuantization.get(new aItemQuantizationInfo(is, false, null)); + EMItemQuantizationInfo aIQI = TecTech.transformationInfo.getItemQuantization().get(new EMItemQuantizationInfo(is, false, null)); if (aIQI == null) { - aIQI = bTransformationInfo.itemQuantization.get(new aItemQuantizationInfo(is, true, null));//todo check if works? + aIQI = TecTech.transformationInfo.getItemQuantization().get(new EMItemQuantizationInfo(is, true, null));//todo check if works? } if (aIQI == null) { //ORE DICT quantization //todo fix for uranium? @@ -111,12 +109,12 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock if (DEBUG_MODE) { TecTech.LOGGER.info("Quantifier-Ore-recipe " + is.getItem().getUnlocalizedName() + '.' + is.getItemDamage() + ' ' + OreDictionary.getOreName(ID)); } - aOredictQuantizationInfo aOQI = bTransformationInfo.oredictQuantization.get(ID); + EMOredictQuantizationInfo aOQI = TecTech.transformationInfo.getOredictQuantization().get(ID); if (aOQI == null) { continue; } - iHasElementalDefinition into = aOQI.output(); - if (into != null && isInputEqual(true, false, nullFluid, new ItemStack[]{new ItemStack(is.getItem(), aOQI.amount, is.getItemDamage())}, null, inI)) { + IEMStack into = aOQI.getOut(); + if (into != null && isInputEqual(true, false, nullFluid, new ItemStack[]{new ItemStack(is.getItem(), aOQI.getAmount(), is.getItemDamage())}, null, inI)) { startRecipe(into); return true; } @@ -126,7 +124,7 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock if (DEBUG_MODE) { TecTech.LOGGER.info("Quantifier-Item-recipe " + is.getItem().getUnlocalizedName() + '.' + is.getItemDamage()); } - iHasElementalDefinition into = aIQI.output(); + IEMStack into = aIQI.output(); if (into != null && isInputEqual(true, false, nullFluid, new ItemStack[]{new ItemStack(is.getItem(), aIQI.input().stackSize, is.getItemDamage())}, null, inI)) { startRecipe(into); return true; @@ -135,14 +133,14 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock } } ArrayList<FluidStack> storedFluids = getStoredFluids(); - FluidStack[] inF = storedFluids.toArray(nullFluid); + FluidStack[] inF = storedFluids.toArray(nullFluid); if (inF.length > 0) { for (FluidStack fs : inF) { - aFluidQuantizationInfo aFQI = bTransformationInfo.fluidQuantization.get(fs.getFluid().getID()); + EMFluidQuantizationInfo aFQI = TecTech.transformationInfo.getFluidQuantization().get(fs.getFluid().getID()); if (aFQI == null) { continue; } - iHasElementalDefinition into = aFQI.output(); + IEMStack into = aFQI.output(); if (into != null && fs.amount >= aFQI.input().amount && isInputEqual(true, false, new FluidStack[]{aFQI.input()}, nullItem, inF, (ItemStack[]) null)) { startRecipe(into); @@ -154,10 +152,10 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock return false; } - private void startRecipe(iHasElementalDefinition into) { + private void startRecipe(IEMStack into) { mMaxProgresstime = 20; mEfficiencyIncrease = 10000; - double mass = into.getMass(); + double mass = into.getMass(); double euMult = Math.abs(mass / refMass); eAmpereFlow = (int) Math.ceil(Math.sqrt(Math.sqrt(euMult))); if (mass > refUnstableMass || into.getDefinition().getRawTimeSpan(DEFAULT_ENERGY_LEVEL) < STABLE_RAW_LIFE_TIME) { @@ -165,10 +163,10 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock } else { mEUt = (int) -V[6]; } - outputEM = new cElementalInstanceStackMap[]{ - into instanceof cElementalInstanceStack ? - new cElementalInstanceStackMap((cElementalInstanceStack) into) : - new cElementalInstanceStackMap(new cElementalInstanceStack(into.getDefinition(), into.getAmount())) + outputEM = new EMInstanceStackMap[]{ + into instanceof EMInstanceStack ? + new EMInstanceStackMap((EMInstanceStack) into) : + new EMInstanceStackMap(new EMInstanceStack(into.getDefinition(), into.getAmount())) }; } @@ -178,7 +176,7 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock stopMachine(); return; } - eOutputHatches.get(0).getContainerHandler().putUnifyAll(outputEM[0]); + eOutputHatches.get(0).getContentHandler().putUnifyAll(outputEM[0]); outputEM = null; } @@ -201,7 +199,7 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - structureBuild_EM("main", 1, 1, 0, hintsOnly, stackSize); + structureBuild_EM("main", 1, 1, 0, stackSize, hintsOnly); } @Override @@ -213,4 +211,4 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java index f5fc1fa3af..9cd3bf40e7 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java @@ -8,7 +8,6 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_Rend import com.github.technus.tectech.util.CommonValues; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; @@ -54,13 +53,13 @@ import static net.minecraft.util.StatCollector.translateToLocalFormatted; */ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { //region variables - private final ArrayList<GT_MetaTileEntity_Hatch_Holder> eHolders = new ArrayList<>(); - private GT_Recipe.GT_Recipe_AssemblyLine tRecipe; - private TT_recipe.TT_assLineRecipe aRecipe; - private String machineType; - private static final String assembly="Assembly line"; - private ItemStack holdItem; - private long computationRemaining, computationRequired; + private final ArrayList<GT_MetaTileEntity_Hatch_Holder> eHolders = new ArrayList<>(); + private GT_Recipe.GT_Recipe_AssemblyLine tRecipe; + private TT_recipe.TT_assLineRecipe aRecipe; + private String machineType; + private static final String assembly = "Assembly line"; + private ItemStack holdItem; + private long computationRemaining, computationRequired; private static LinkedHashMap<String, String> lServerNames; @@ -74,23 +73,23 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB //endregion //region structure - private static final IStructureDefinition<GT_MetaTileEntity_EM_research> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_EM_research>builder() - .addShape("main", transpose(new String[][]{ - {" ", " A ", " A ", "AAA", "AAA", "AAA", "AAA"}, - {"AAA", "ACA", "ACA", "ACA", "BCB", "BCB", "BBB"}, - {" ", " C ", " ", " ", "ACA", "CCC", "DDD"}, - {" ", " E ", " ", " ", "A~A", "CCC", "DDD"}, - {" ", " C ", " ", " ", "ACA", "CCC", "DDD"}, - {"AAA", "ACA", "ACA", "ACA", "BCB", "BCB", "BBB"}, - {" ", " A ", " A ", "AAA", "AAA", "AAA", "AAA"} - })) - .addElement('A', ofBlock(sBlockCasingsTT, 1)) - .addElement('B', ofBlock(sBlockCasingsTT, 2)) - .addElement('C', ofBlock(sBlockCasingsTT, 3)) - .addElement('D', ofHatchAdderOptional(GT_MetaTileEntity_EM_research::addClassicToMachineList, textureOffset + 1,1, sBlockCasingsTT,1)) - .addElement('E', ofHatchAdder(GT_MetaTileEntity_EM_research::addHolderToMachineList, 3, 2)) - .build(); + private static final IStructureDefinition<GT_MetaTileEntity_EM_research> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_EM_research>builder() + .addShape("main", transpose(new String[][]{ + {" ", " A ", " A ", "AAA", "AAA", "AAA", "AAA"}, + {"AAA", "ACA", "ACA", "ACA", "BCB", "BCB", "BBB"}, + {" ", " C ", " ", " ", "ACA", "CCC", "DDD"}, + {" ", " E ", " ", " ", "A~A", "CCC", "DDD"}, + {" ", " C ", " ", " ", "ACA", "CCC", "DDD"}, + {"AAA", "ACA", "ACA", "ACA", "BCB", "BCB", "BBB"}, + {" ", " A ", " A ", "AAA", "AAA", "AAA", "AAA"} + })) + .addElement('A', ofBlock(sBlockCasingsTT, 1)) + .addElement('B', ofBlock(sBlockCasingsTT, 2)) + .addElement('C', ofBlock(sBlockCasingsTT, 3)) + .addElement('D', ofHatchAdderOptional(GT_MetaTileEntity_EM_research::addClassicToMachineList, textureOffset + 1, 1, sBlockCasingsTT, 1)) + .addElement('E', ofHatchAdder(GT_MetaTileEntity_EM_research::addHolderToMachineList, 3, 2)) + .build(); //endregion public GT_MetaTileEntity_EM_research(int aID, String aName, String aNameRegional) { @@ -144,12 +143,12 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB private void makeStick2() { String s = tRecipe.mOutput.getDisplayName(); if (getBaseMetaTileEntity().isServerSide()) { - if(lServerNames != null) { + if (lServerNames != null) { s = lServerNames.get(tRecipe.mOutput.getDisplayName()); if (s == null) { s = tRecipe.mOutput.getDisplayName(); } - }else{ + } else { s = tRecipe.mOutput.getDisplayName(); } } @@ -188,7 +187,7 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB tNBTList.appendTag(new NBTTagString("Construction plan for " + tRecipe.mOutput.stackSize + " " + s + ". Needed EU/t: " + tRecipe.mEUt + " Production time: " + (tRecipe.mDuration / 20))); for (int i = 0; i < tRecipe.mInputs.length; i++) { if (tRecipe.mOreDictAlt[i] != null) { - int count = 0; + int count = 0; StringBuilder tBuilder = new StringBuilder("Input Bus " + (i + 1) + ": "); for (ItemStack tStack : tRecipe.mOreDictAlt[i]) { if (tStack != null) { @@ -241,7 +240,7 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB mEfficiencyIncrease = 10000; eRequiredData = (short) (ttRecipe.mSpecialValue >>> 16); eAmpereFlow = (short) (ttRecipe.mSpecialValue & 0xFFFF); - mEUt = Math.min(ttRecipe.mEUt,-ttRecipe.mEUt); + mEUt = Math.min(ttRecipe.mEUt, -ttRecipe.mEUt); eHolders.get(0).getBaseMetaTileEntity().setActive(true); return true; } @@ -363,7 +362,7 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB @Override public String[] getInfoData() { long storedEnergy = 0; - long maxEnergy = 0; + long maxEnergy = 0; for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); @@ -570,7 +569,7 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - structureBuild_EM("main", 1, 3, 4, hintsOnly, stackSize); + structureBuild_EM("main", 1, 3, 4, stackSize, hintsOnly); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java index 8c545b50c5..12220dfe14 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java @@ -1,10 +1,11 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.tElementalException; +import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMPrimitiveDefinition; import com.github.technus.tectech.recipe.TT_recipe; import com.github.technus.tectech.thing.CustomItemList; import com.github.technus.tectech.thing.block.QuantumGlassBlock; @@ -15,7 +16,6 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.*; import com.github.technus.tectech.util.CommonValues; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.enums.ItemList; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -35,16 +35,13 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; import org.apache.commons.lang3.reflect.FieldUtils; -import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.cPrimitiveDefinition.nbtE__; import static com.github.technus.tectech.recipe.TT_recipe.E_RECIPE_ID; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_crafting.crafter; import static com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.GT_MetaTileEntity_EM_machine.machine; -import static com.github.technus.tectech.util.CommonValues.V; -import static com.github.technus.tectech.util.CommonValues.VN; -import static com.github.technus.tectech.util.Util.areBitsSet; +import static com.github.technus.tectech.util.CommonValues.*; +import static com.github.technus.tectech.util.TT_Utility.areBitsSet; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; @@ -57,16 +54,29 @@ import static net.minecraft.util.StatCollector.translateToLocalFormatted; */ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { //region variables - public static final int SCAN_DO_NOTHING = 0, - SCAN_GET_NOMENCLATURE = 1, SCAN_GET_DEPTH_LEVEL = 2, SCAN_GET_AMOUNT = 4, SCAN_GET_CHARGE = 8, - SCAN_GET_MASS = 16, SCAN_GET_ENERGY_LEVEL = 32, SCAN_GET_TIMESPAN_INFO = 64, SCAN_GET_ENERGY_STATES = 128, - SCAN_GET_COLOR = 256, SCAN_GET_AGE = 512, SCAN_GET_TIMESPAN_MULT = 1024, SCAN_GET_CLASS_TYPE = 2048; + public static final int + SCAN_DO_NOTHING = 0, + SCAN_GET_NOMENCLATURE = 1<<0, + SCAN_GET_DEPTH_LEVEL = 1<<1, + SCAN_GET_AMOUNT = 1<<2, + SCAN_GET_CHARGE = 1<<3, + SCAN_GET_MASS = 1<<4, + SCAN_GET_ENERGY = 1<<5, + SCAN_GET_ENERGY_LEVEL = 1<<6, + SCAN_GET_TIMESPAN_INFO = 1<<7, + SCAN_GET_ENERGY_STATES = 1<<8, + SCAN_GET_COLORABLE = 1<<9, + SCAN_GET_COLOR_VALUE = 1<<10, + SCAN_GET_AGE = 1<<11, + SCAN_GET_TIMESPAN_MULT = 1<<12, + SCAN_GET_CLASS_TYPE = 1<<13, + SCAN_GET_TOO_BIG = 1<<14;//should be the sum of all flags +1 private TT_recipe.TT_EMRecipe.TT_EMRecipe eRecipe; - private cElementalDefinitionStack objectResearched; - private cElementalInstanceStackMap objectsScanned; - private String machineType; - private long computationRemaining, computationRequired; + private EMDefinitionStack objectResearched; + private EMInstanceStackMap objectsScanned; + private String machineType; + private long computationRemaining, computationRequired; private int[] scanComplexity; private String clientLocale = "en_US"; @@ -81,27 +91,27 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa translateToLocal("gt.blockmachines.multimachine.em.scanner.hint.3"),//4 - Elemental Overflow Hatches or Molecular Casing }; - private static final IStructureDefinition<GT_MetaTileEntity_EM_scanner> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_EM_scanner>builder() + private static final IStructureDefinition<GT_MetaTileEntity_EM_scanner> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_EM_scanner>builder() .addShape("main", transpose(new String[][]{ - {"CCCCC","BBBBB","BBDBB","BDDDB","BDDDB","BDDDB","BBDBB","EEEEE"}, - {"CAAAC","BBBBB","BDDDB","D---D","D---D","D---D","BDDDB","EBBBE"}, - {"CA~AC","BBBBB","DDDDD","D---D","D---D","D---D","DDGDD","EBFBE"}, - {"CAAAC","BBBBB","BDDDB","D---D","D---D","D---D","BDDDB","EBBBE"}, - {"CCCCC","BBBBB","BBDBB","BDDDB","BDDDB","BDDDB","BBDBB","EEEEE"} + {"CCCCC", "BBBBB", "BBDBB", "BDDDB", "BDDDB", "BDDDB", "BBDBB", "EEEEE"}, + {"CAAAC", "BBBBB", "BDDDB", "D---D", "D---D", "D---D", "BDDDB", "EBBBE"}, + {"CA~AC", "BBBBB", "DDDDD", "D---D", "D- -D", "D---D", "DDGDD", "EBFBE"}, + {"CAAAC", "BBBBB", "BDDDB", "D---D", "D---D", "D---D", "BDDDB", "EBBBE"}, + {"CCCCC", "BBBBB", "BBDBB", "BDDDB", "BDDDB", "BDDDB", "BBDBB", "EEEEE"} })) .addElement('A', ofBlock(sBlockCasingsTT, 0)) .addElement('B', ofBlock(sBlockCasingsTT, 4)) - .addElement('C', ofHatchAdderOptional(GT_MetaTileEntity_EM_scanner::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) .addElement('D', ofBlock(QuantumGlassBlock.INSTANCE, 0)) - .addElement('E', ofHatchAdderOptional(GT_MetaTileEntity_EM_scanner::addElementalMufflerToMachineList, textureOffset + 4, 4, sBlockCasingsTT, 4)) + .addElement('C', ofHatchAdderOptional(GT_MetaTileEntity_EM_scanner::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) .addElement('F', ofHatchAdder(GT_MetaTileEntity_EM_scanner::addElementalInputToMachineList, textureOffset + 4, 2)) .addElement('G', ofHatchAdder(GT_MetaTileEntity_EM_scanner::addElementalOutputToMachineList, textureOffset + 4, 3)) + .addElement('E', ofHatchAdderOptional(GT_MetaTileEntity_EM_scanner::addElementalMufflerToMachineList, textureOffset + 4, 4, sBlockCasingsTT, 4)) .build(); //endregion //region parameters - private static final INameFunction<GT_MetaTileEntity_EM_scanner> CONFIG_NAME = + private static final INameFunction<GT_MetaTileEntity_EM_scanner> CONFIG_NAME = (base, p) -> "Config at Depth: " + (p.hatchId() * 2 + p.parameterId()); private static final IStatusFunction<GT_MetaTileEntity_EM_scanner> CONFIG_STATUS = (base, p) -> { @@ -110,15 +120,12 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa return LedStatus.STATUS_WRONG; } v = (int) v; - if (v == 0) - return LedStatus.STATUS_NEUTRAL; - if (v >= SCAN_GET_CLASS_TYPE) - return LedStatus.STATUS_TOO_HIGH; - if (v < 0) - return LedStatus.STATUS_TOO_LOW; + if (v == 0) return LedStatus.STATUS_NEUTRAL; + if (v >= SCAN_GET_TOO_BIG) return LedStatus.STATUS_TOO_HIGH; + if (v < 0) return LedStatus.STATUS_TOO_LOW; return LedStatus.STATUS_OK; }; - protected Parameters.Group.ParameterIn[] scanConfiguration; + protected Parameters.Group.ParameterIn[] scanConfiguration; //endregion public GT_MetaTileEntity_EM_scanner(int aID, String aName, String aNameRegional) { @@ -134,9 +141,9 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa private void quantumStuff(boolean shouldExist) { IGregTechTileEntity base = getBaseMetaTileEntity(); if (base != null && base.getWorld() != null) { - int xDir = ForgeDirection.getOrientation(base.getBackFacing()).offsetX * 4 + base.getXCoord(); - int yDir = ForgeDirection.getOrientation(base.getBackFacing()).offsetY * 4 + base.getYCoord(); - int zDir = ForgeDirection.getOrientation(base.getBackFacing()).offsetZ * 4 + base.getZCoord(); + int xDir = ForgeDirection.getOrientation(base.getBackFacing()).offsetX * 4 + base.getXCoord(); + int yDir = ForgeDirection.getOrientation(base.getBackFacing()).offsetY * 4 + base.getYCoord(); + int zDir = ForgeDirection.getOrientation(base.getBackFacing()).offsetZ * 4 + base.getZCoord(); Block block = base.getWorld().getBlock(xDir, yDir, zDir); if (shouldExist) { if (block != null && block.getMaterial() == Material.air) { @@ -152,58 +159,60 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa private void addComputationRequirements(int depthPlus, int capabilities) { if (areBitsSet(SCAN_GET_NOMENCLATURE, capabilities)) { - computationRequired += depthPlus * 5L; + computationRequired += depthPlus * 3L; eRequiredData += depthPlus; } if (areBitsSet(SCAN_GET_DEPTH_LEVEL, capabilities)) { computationRequired += depthPlus * 10L; eRequiredData += depthPlus; - } if (areBitsSet(SCAN_GET_AMOUNT, capabilities)) { computationRequired += depthPlus * 64L; eRequiredData += depthPlus * 8L; - } if (areBitsSet(SCAN_GET_CHARGE, capabilities)) { computationRequired += depthPlus * 128L; eRequiredData += depthPlus * 4L; - } if (areBitsSet(SCAN_GET_MASS, capabilities)) { computationRequired += depthPlus * 256L; eRequiredData += depthPlus * 4L; - + } + if (areBitsSet(SCAN_GET_ENERGY, capabilities)) { + computationRequired += depthPlus * 256L; + eRequiredData += depthPlus * 16L; } if (areBitsSet(SCAN_GET_ENERGY_LEVEL, capabilities)) { - computationRequired += depthPlus * 512L; + computationRequired += depthPlus * 256L; eRequiredData += depthPlus * 16L; - } if (areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)) { computationRequired += depthPlus * 1024L; eRequiredData += depthPlus * 32L; - } if (areBitsSet(SCAN_GET_ENERGY_STATES, capabilities)) { computationRequired += depthPlus * 2048L; eRequiredData += depthPlus * 32L; - } - if (areBitsSet(SCAN_GET_COLOR, capabilities)) { + if (areBitsSet(SCAN_GET_COLORABLE, capabilities)) { + computationRequired += depthPlus * 512L; + eRequiredData += depthPlus * 48L; + } + if (areBitsSet(SCAN_GET_COLOR_VALUE, capabilities)) { computationRequired += depthPlus * 1024L; eRequiredData += depthPlus * 48L; - } if (areBitsSet(SCAN_GET_AGE, capabilities)) { computationRequired += depthPlus * 2048L; eRequiredData += depthPlus * 64L; - } if (areBitsSet(SCAN_GET_TIMESPAN_MULT, capabilities)) { computationRequired += depthPlus * 2048L; eRequiredData += depthPlus * 64L; - + } + if (areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { + computationRequired += depthPlus * 2L; + eRequiredData += depthPlus; } } @@ -223,32 +232,32 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa @Override public boolean checkRecipe_EM(ItemStack itemStack) { eRecipe = null; - if (!eInputHatches.isEmpty() && eInputHatches.get(0).getContainerHandler().hasStacks() && !eOutputHatches.isEmpty()) { - cElementalInstanceStackMap researchEM = eInputHatches.get(0).getContainerHandler(); + if (!eInputHatches.isEmpty() && eInputHatches.get(0).getContentHandler().hasStacks() && !eOutputHatches.isEmpty()) { + EMInstanceStackMap researchEM = eInputHatches.get(0).getContentHandler(); if (ItemList.Tool_DataOrb.isStackEqual(itemStack, false, true)) { GT_Recipe scannerRecipe = null; - for (cElementalInstanceStack stackEM : researchEM.values()) { + for (EMInstanceStack stackEM : researchEM.valuesToArray()) { objectsScanned = null; - eRecipe = TT_recipe.TT_Recipe_Map_EM.sMachineRecipesEM.findRecipe(stackEM.definition); + eRecipe = TT_recipe.TT_Recipe_Map_EM.sMachineRecipesEM.findRecipe(stackEM.getDefinition()); if (eRecipe != null) { scannerRecipe = eRecipe.scannerRecipe; machineType = machine; - objectResearched = new cElementalDefinitionStack(stackEM.definition, 1); + objectResearched = new EMDefinitionStack(stackEM.getDefinition(), 1); //cleanMassEM_EM(objectResearched.getMass()); - researchEM.remove(objectResearched.definition); + researchEM.removeKey(objectResearched.getDefinition()); break; } - eRecipe = TT_recipe.TT_Recipe_Map_EM.sCrafterRecipesEM.findRecipe(stackEM.definition); + eRecipe = TT_recipe.TT_Recipe_Map_EM.sCrafterRecipesEM.findRecipe(stackEM.getDefinition()); if (eRecipe != null) { scannerRecipe = eRecipe.scannerRecipe; machineType = crafter; - objectResearched = new cElementalDefinitionStack(stackEM.definition, 1); + objectResearched = new EMDefinitionStack(stackEM.getDefinition(), 1); //cleanMassEM_EM(objectResearched.getMass()); - researchEM.remove(objectResearched.definition); + researchEM.removeKey(objectResearched.getDefinition()); break; } cleanStackEM_EM(stackEM); - researchEM.remove(stackEM.definition); + researchEM.removeKey(stackEM.getDefinition()); } if (eRecipe != null && scannerRecipe != null) {//todo make sure it werks computationRequired = computationRemaining = scannerRecipe.mDuration * 20L; @@ -263,7 +272,7 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa } else if (CustomItemList.scanContainer.isStackEqual(itemStack, false, true)) { eRecipe = null; if (researchEM.hasStacks()) { - objectsScanned = researchEM.takeAllToNewMap(); + objectsScanned = researchEM.takeAll(); cleanMassEM_EM(objectsScanned.getMass()); computationRequired = 0; @@ -281,9 +290,6 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa for (int i = 0; i < 20; i++) { if (scanComplexityTemp[i] != SCAN_DO_NOTHING) { maxDepth = i; - if (!DEBUG_MODE) { - scanComplexityTemp[i] &= ~SCAN_GET_CLASS_TYPE; - } addComputationRequirements(i + 1, scanComplexityTemp[i]); } } @@ -314,8 +320,8 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa NBTTagCompound tNBT = mInventory[1].getTagCompound();//code above makes it not null tNBT.setString("eMachineType", machineType); - tNBT.setTag(E_RECIPE_ID, objectResearched.toNBT()); - tNBT.setString("author", EnumChatFormatting.BLUE + "Tec" + EnumChatFormatting.DARK_BLUE + "Tech" + EnumChatFormatting.WHITE + ' ' + machineType + " EM Recipe Generator"); + tNBT.setTag(E_RECIPE_ID, objectResearched.toNBT(TecTech.definitionsRegistry)); + tNBT.setString("author", TEC_MARK_SHORT + EnumChatFormatting.WHITE + ' ' + machineType + " EM Recipe Generator"); } else if (objectsScanned != null && CustomItemList.scanContainer.isStackEqual(mInventory[1], false, true)) { ElementalDefinitionScanStorage_EM.setContent(mInventory[1], objectsScanned, scanComplexity); } @@ -336,7 +342,7 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa @Override public String[] getInfoData() { long storedEnergy = 0; - long maxEnergy = 0; + long maxEnergy = 0; for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); @@ -402,7 +408,7 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa aNBT.setLong("eComputationRemaining", computationRemaining); aNBT.setLong("eComputationRequired", computationRequired); if (objectResearched != null) { - aNBT.setTag("eObject", objectResearched.toNBT()); + aNBT.setTag("eObject", objectResearched.toNBT(TecTech.definitionsRegistry)); } else { aNBT.removeTag("eObject"); } @@ -412,7 +418,7 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa aNBT.removeTag("eScanComplexity"); } if (objectsScanned != null) { - aNBT.setTag("eScanObjects", objectsScanned.toNBT()); + aNBT.setTag("eScanObjects", objectsScanned.toNBT(TecTech.definitionsRegistry)); } else { aNBT.removeTag("eScanObjects"); } @@ -424,8 +430,8 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa computationRemaining = aNBT.getLong("eComputationRemaining"); computationRequired = aNBT.getLong("eComputationRequired"); if (aNBT.hasKey("eObject")) { - objectResearched = cElementalDefinitionStack.fromNBT(aNBT.getCompoundTag("eObject")); - if (objectResearched.definition == nbtE__) { + objectResearched = EMDefinitionStack.fromNBT(TecTech.definitionsRegistry, aNBT.getCompoundTag("eObject")); + if (objectResearched.getDefinition() == EMPrimitiveDefinition.nbtE__) { objectResearched = null; } } else { @@ -438,10 +444,10 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa } try { if (aNBT.hasKey("eScanObjects")) { - objectsScanned = cElementalInstanceStackMap.fromNBT(aNBT.getCompoundTag("eScanObjects")); + objectsScanned = EMInstanceStackMap.fromNBT(TecTech.definitionsRegistry, aNBT.getCompoundTag("eScanObjects")); } - } catch (tElementalException e) { - objectsScanned = new cElementalInstanceStackMap(); + } catch (EMException e) { + objectsScanned = new EMInstanceStackMap(); } } @@ -460,11 +466,11 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa if (computationRemaining > 0 && objectResearched != null) { eRecipe = null; if (ItemList.Tool_DataOrb.isStackEqual(mInventory[1], false, true)) { - eRecipe = TT_recipe.TT_Recipe_Map_EM.sMachineRecipesEM.findRecipe(objectResearched.definition); + eRecipe = TT_recipe.TT_Recipe_Map_EM.sMachineRecipesEM.findRecipe(objectResearched.getDefinition()); if (eRecipe != null) { machineType = machine; } else { - eRecipe = TT_recipe.TT_Recipe_Map_EM.sCrafterRecipesEM.findRecipe(objectResearched.definition); + eRecipe = TT_recipe.TT_Recipe_Map_EM.sCrafterRecipesEM.findRecipe(objectResearched.getDefinition()); if (eRecipe != null) { machineType = crafter; } @@ -530,8 +536,8 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa } @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - structureBuild_EM("main", 2, 2, 0, hintsOnly, stackSize); + public void construct(ItemStack trigger, boolean hintsOnly) { + structureBuild_EM("main", 2, 2, 0, trigger, hintsOnly); } @Override @@ -543,4 +549,4 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java index 0ff238e4c3..7103e6dfff 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java @@ -5,7 +5,6 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEnt import com.github.technus.tectech.util.CommonValues; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.item.ItemStack; @@ -29,21 +28,21 @@ public class GT_MetaTileEntity_EM_stabilizer extends GT_MetaTileEntity_Multibloc translateToLocal("gt.blockmachines.multimachine.em.stabilizer.hint.1"),//2 - Elemental Hatches or Molecular Casing }; - private static final IStructureDefinition<GT_MetaTileEntity_EM_stabilizer> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_EM_stabilizer>builder() + private static final IStructureDefinition<GT_MetaTileEntity_EM_stabilizer> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_EM_stabilizer>builder() .addShape("main", transpose(new String[][]{ - {" AFA ","BCBCB","FBGBF","BCBCB"," AFA "}, - {"AEEEA","CBBBC","BBDBB","CBBBC","AEEEA"}, - {"FE~EF","BBBBB","GDDDG","BBBBB","FEEEF"}, - {"AEEEA","CBBBC","BBDBB","CBBBC","AEEEA"}, - {" AFA ","BCBCB","FBGBF","BCBCB"," AFA "} + {" AFA ", "BCBCB", "FBGBF", "BCBCB", " AFA "}, + {"AEEEA", "CBBBC", "BBDBB", "CBBBC", "AEEEA"}, + {"FE~EF", "BBBBB", "GDDDG", "BBBBB", "FEEEF"}, + {"AEEEA", "CBBBC", "BBDBB", "CBBBC", "AEEEA"}, + {" AFA ", "BCBCB", "FBGBF", "BCBCB", " AFA "} })) .addElement('A', ofBlock(sBlockCasingsTT, 4)) .addElement('B', ofBlock(sBlockCasingsTT, 5)) .addElement('C', ofBlock(sBlockCasingsTT, 6)) .addElement('D', ofBlock(sBlockCasingsTT, 9)) - .addElement('E', ofHatchAdderOptional(GT_MetaTileEntity_EM_stabilizer::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) .addElement('F', ofBlock(QuantumGlassBlock.INSTANCE, 0)) + .addElement('E', ofHatchAdderOptional(GT_MetaTileEntity_EM_stabilizer::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) .addElement('G', ofHatchAdderOptional(GT_MetaTileEntity_EM_stabilizer::addElementalToMachineList, textureOffset + 4, 2, sBlockCasingsTT, 4)) .build(); //endregion @@ -77,7 +76,7 @@ public class GT_MetaTileEntity_EM_stabilizer extends GT_MetaTileEntity_Multibloc @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - structureBuild_EM("main", 2, 2, 0, hintsOnly, stackSize); + structureBuild_EM("main", 2, 2, 0, stackSize, hintsOnly); } @Override @@ -89,4 +88,4 @@ public class GT_MetaTileEntity_EM_stabilizer extends GT_MetaTileEntity_Multibloc public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java index 1ca125977d..bbf33c6ae7 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java @@ -12,7 +12,6 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_Rend import com.github.technus.tectech.util.CommonValues; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import com.gtnewhorizon.structurelib.util.Vec3Impl; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -44,12 +43,12 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas "1 - Classic/Data Hatches or Computer casing",//1 - Classic/Data Hatches or Computer casing }; - private static final IStructureDefinition<GT_MetaTileEntity_EM_switch> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_EM_switch>builder() + private static final IStructureDefinition<GT_MetaTileEntity_EM_switch> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_EM_switch>builder() .addShape("main", transpose(new String[][]{ - {"BBB","BBB","BBB"}, - {"B~B","BAB","BBB"}, - {"BBB","BBB","BBB"} + {"BBB", "BBB", "BBB"}, + {"B~B", "BAB", "BBB"}, + {"BBB", "BBB", "BBB"} })) .addElement('A', ofBlock(sBlockCasingsTT, 3)) .addElement('B', ofHatchAdderOptional(GT_MetaTileEntity_EM_switch::addClassicToMachineList, textureOffset + 1, 1, sBlockCasingsTT, 1)) @@ -57,7 +56,7 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas //endregion //region parameters - private static final INameFunction<GT_MetaTileEntity_EM_switch> ROUTE_NAME = + private static final INameFunction<GT_MetaTileEntity_EM_switch> ROUTE_NAME = (base, p) -> (p.parameterId() == 0 ? translateToLocal("tt.keyword.Destination") + " " : translateToLocal("tt.keyword.Weight") + " ") + p.hatchId(); private static final IStatusFunction<GT_MetaTileEntity_EM_switch> WEI_STATUS = (base, p) -> { @@ -80,8 +79,8 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas } return STATUS_NEUTRAL; }; - protected Parameters.Group.ParameterIn[] dst; - protected Parameters.Group.ParameterIn[] weight; + protected Parameters.Group.ParameterIn[] dst; + protected Parameters.Group.ParameterIn[] weight; //endregion public GT_MetaTileEntity_EM_switch(int aID, String aName, String aNameRegional) { @@ -135,8 +134,8 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas } Vec3Impl pos = new Vec3Impl(getBaseMetaTileEntity().getXCoord(), - getBaseMetaTileEntity().getYCoord(), - getBaseMetaTileEntity().getZCoord()); + getBaseMetaTileEntity().getYCoord(), + getBaseMetaTileEntity().getZCoord()); QuantumDataPacket pack = new QuantumDataPacket(0L).unifyTraceWith(pos); if (pack == null) { @@ -226,7 +225,7 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - structureBuild_EM("main", 1, 1, 0, hintsOnly, stackSize); + structureBuild_EM("main", 1, 1, 0, stackSize, hintsOnly); } @Override @@ -238,4 +237,4 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java index b2f7da7bc3..75eb05bdeb 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java @@ -8,7 +8,6 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_Rend import com.github.technus.tectech.util.CommonValues; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -23,7 +22,6 @@ import net.minecraft.util.ResourceLocation; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; -import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sHintCasingsTT; import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; import static gregtech.api.GregTech_API.sBlockCasings1; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; @@ -34,24 +32,24 @@ import static net.minecraft.util.StatCollector.translateToLocal; */ public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { //region structure - private static final String[] description = new String[]{ + private static final String[] description = new String[]{ EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", translateToLocal("gt.blockmachines.multimachine.em.transformer.hint"),//1 - Energy IO Hatches or High Power Casing }; - private static final IStructureDefinition<GT_MetaTileEntity_EM_transformer> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_EM_transformer>builder() - .addShape("main",new String[][]{ - {"111", "1~1", "111",}, - {"111", "101", "111",}, - {"111", "111", "111",}, - }) - .addElement('0', ofBlock(sBlockCasings1,15)) - .addElement('1', ofChain( - ofHatchAdder(GT_MetaTileEntity_EM_transformer::addEnergyIOToMachineList,textureOffset,sHintCasingsTT,0), - onElementPass(t->t.casingCount++,ofBlock(sBlockCasingsTT,0)) - )) - .build(); - private int casingCount=0; + private static final IStructureDefinition<GT_MetaTileEntity_EM_transformer> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_EM_transformer>builder() + .addShape("main", new String[][]{ + {"111", "1~1", "111",}, + {"111", "101", "111",}, + {"111", "111", "111",}, + }) + .addElement('0', ofBlock(sBlockCasings1, 15)) + .addElement('1', ofChain( + ofHatchAdder(GT_MetaTileEntity_EM_transformer::addEnergyIOToMachineList, textureOffset, 1), + onElementPass(t -> t.casingCount++, ofBlock(sBlockCasingsTT, 0)) + )) + .build(); + private int casingCount = 0; @Override public IStructureDefinition<GT_MetaTileEntity_EM_transformer> getStructure_EM() { @@ -88,8 +86,8 @@ public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_Multiblo @Override public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - casingCount=0; - return structureCheck_EM("main", 1, 1, 0) && casingCount>=5; + casingCount = 0; + return structureCheck_EM("main", 1, 1, 0) && casingCount >= 5; } @Override @@ -118,12 +116,12 @@ public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_Multiblo @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity,true, false, false); + return new GT_Container_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, true, false, false); } @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "EMDisplay.png",true, false, false); + return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "EMDisplay.png", true, false, false); } @Override @@ -161,11 +159,11 @@ public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_Multiblo @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - structureBuild_EM("main", 1, 1, 0, hintsOnly, stackSize); + structureBuild_EM("main", 1, 1, 0, stackSize, hintsOnly); } @Override public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java index 7b85d3406a..83151d71c3 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java @@ -6,7 +6,6 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_Rend import com.github.technus.tectech.util.CommonValues; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -41,25 +40,25 @@ public class GT_MetaTileEntity_EM_wormhole extends GT_MetaTileEntity_MultiblockB translateToLocal("gt.blockmachines.multimachine.em.wormhole.hint.1"),//2 - Elemental Hatches or Molecular Casing }; - private static final IStructureDefinition<GT_MetaTileEntity_EM_wormhole> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_EM_wormhole>builder() + private static final IStructureDefinition<GT_MetaTileEntity_EM_wormhole> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_EM_wormhole>builder() .addShape("main", transpose(new String[][]{ - {" "," "," "," "," "," D "," DDDDD "," DGGGD "," DGGGD "," DGGGD "," DDDDD "}, - {" "," "," "," D "," D "," D "," DDAAADD "," EABBBAE "," EABBBAE "," EABBBAE "," DDAAADD "}, - {" "," D "," D "," D "," "," ","DDA ADD","DABFFFBAD","DABCCCBAD","DABFFFBAD","DDA ADD"}, - {" EEE "," DDD "," F F "," "," "," ","DA AD","GBF FBG","GBC CBG","GBF FBG","DA AD"}, - {" E~E "," DDBDD "," D D "," DD DD "," D D ","DD DD","DA AD","GBF FBG","GBC CBG","GBF FBG","DA AD"}, - {" EEE "," DDD "," F F "," "," "," ","DA AD","GBF FBG","GBC CBG","GBF FBG","DA AD"}, - {" "," D "," D "," D "," "," ","DDA ADD","DABFFFBAD","DABCCCBAD","DABFFFBAD","DDA ADD"}, - {" "," "," "," D "," D "," D "," DDAAADD "," EABBBAE "," EABBBAE "," EABBBAE "," DDAAADD "}, - {" "," "," "," "," "," D "," DDDDD "," DGGGD "," DGGGD "," DGGGD "," DDDDD "} + {" ", " ", " ", " ", " ", " D ", " DDDDD ", " DGGGD ", " DGGGD ", " DGGGD ", " DDDDD "}, + {" ", " ", " ", " D ", " D ", " D ", " DDAAADD ", " EABBBAE ", " EABBBAE ", " EABBBAE ", " DDAAADD "}, + {" ", " D ", " D ", " D ", " ", " ", "DDA ADD", "DABFFFBAD", "DABCCCBAD", "DABFFFBAD", "DDA ADD"}, + {" EEE ", " DDD ", " F F ", " ", " ", " ", "DA AD", "GBF FBG", "GBC CBG", "GBF FBG", "DA AD"}, + {" E~E ", " DDBDD ", " D D ", " DD DD ", " D D ", "DD DD", "DA AD", "GBF FBG", "GBC CBG", "GBF FBG", "DA AD"}, + {" EEE ", " DDD ", " F F ", " ", " ", " ", "DA AD", "GBF FBG", "GBC CBG", "GBF FBG", "DA AD"}, + {" ", " D ", " D ", " D ", " ", " ", "DDA ADD", "DABFFFBAD", "DABCCCBAD", "DABFFFBAD", "DDA ADD"}, + {" ", " ", " ", " D ", " D ", " D ", " DDAAADD ", " EABBBAE ", " EABBBAE ", " EABBBAE ", " DDAAADD "}, + {" ", " ", " ", " ", " ", " D ", " DDDDD ", " DGGGD ", " DGGGD ", " DGGGD ", " DDDDD "} })) .addElement('A', ofBlock(sBlockCasingsTT, 5)) .addElement('B', ofBlock(sBlockCasingsTT, 10)) .addElement('C', ofBlock(sBlockCasingsTT, 11)) .addElement('D', ofBlock(sBlockCasingsTT, 12)) - .addElement('E', ofHatchAdderOptional(GT_MetaTileEntity_EM_wormhole::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) .addElement('F', ofBlock(QuantumGlassBlock.INSTANCE, 0)) + .addElement('E', ofHatchAdderOptional(GT_MetaTileEntity_EM_wormhole::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) .addElement('G', ofHatchAdderOptional(GT_MetaTileEntity_EM_wormhole::addElementalToMachineList, textureOffset + 4, 2, sBlockCasingsTT, 4)) .build(); //endregion @@ -109,7 +108,7 @@ public class GT_MetaTileEntity_EM_wormhole extends GT_MetaTileEntity_MultiblockB @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - structureBuild_EM("main", 4, 4, 0, hintsOnly, stackSize); + structureBuild_EM("main", 4, 4, 0, stackSize, hintsOnly); } @Override @@ -121,4 +120,4 @@ public class GT_MetaTileEntity_EM_wormhole extends GT_MetaTileEntity_MultiblockB public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java index b99ed26f5b..fec070407b 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java @@ -6,7 +6,6 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_Rend import com.github.technus.tectech.util.CommonValues; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import com.gtnewhorizon.structurelib.util.Vec3Impl; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -51,13 +50,13 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock translateToLocal("gt.blockmachines.multimachine.tm.microwave.hint.1"),//Also acts like a hopper so give it an Output Bus }; - private static final IStructureDefinition<GT_MetaTileEntity_TM_microwave> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_TM_microwave>builder() + private static final IStructureDefinition<GT_MetaTileEntity_TM_microwave> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_TM_microwave>builder() .addShape("main", transpose(new String[][]{ - {"AAAAA","A---A","A---A","A---A","AAAAA"}, - {"AAAAA","A---A","A---A","A---A","AAAAA"}, - {"AA~AA","A---A","A---A","A---A","AAAAA"}, - {"ABBBA","BAAAB","BAAAB","BAAAB","ABBBA"} + {"AAAAA", "A---A", "A---A", "A---A", "AAAAA"}, + {"AAAAA", "A---A", "A---A", "A---A", "AAAAA"}, + {"AA~AA", "A---A", "A---A", "A---A", "AAAAA"}, + {"ABBBA", "BAAAB", "BAAAB", "BAAAB", "ABBBA"} })) .addElement('A', ofBlock(sBlockCasings4, 1)) .addElement('B', ofHatchAdderOptional(GT_MetaTileEntity_TM_microwave::addClassicToMachineList, 49, 1, sBlockCasings4, 1)) @@ -70,11 +69,11 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock private static final INameFunction<GT_MetaTileEntity_TM_microwave> POWER_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.microwave.cfgi.0");//Power setting private static final INameFunction<GT_MetaTileEntity_TM_microwave> TIMER_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.microwave.cfgi.1");//Timer setting - private static final INameFunction<GT_MetaTileEntity_TM_microwave> TIMER_VALUE_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.microwave.cfgo.0");//Timer value - private static final INameFunction<GT_MetaTileEntity_TM_microwave> TIMER_REMAINING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.microwave.cfgo.1");//Timer remaining - private static final IStatusFunction<GT_MetaTileEntity_TM_microwave> POWER_STATUS = + private static final INameFunction<GT_MetaTileEntity_TM_microwave> TIMER_VALUE_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.microwave.cfgo.0");//Timer value + private static final INameFunction<GT_MetaTileEntity_TM_microwave> TIMER_REMAINING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.microwave.cfgo.1");//Timer remaining + private static final IStatusFunction<GT_MetaTileEntity_TM_microwave> POWER_STATUS = (base, p) -> LedStatus.fromLimitsInclusiveOuterBoundary(p.get(), 300, 1000, 1000, Double.POSITIVE_INFINITY); - private static final IStatusFunction<GT_MetaTileEntity_TM_microwave> TIMER_STATUS = (base, p) -> { + private static final IStatusFunction<GT_MetaTileEntity_TM_microwave> TIMER_STATUS = (base, p) -> { double value = p.get(); if (Double.isNaN(value)) return STATUS_WRONG; value = (int) value; @@ -99,7 +98,7 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock @Override public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - return structureCheck_EM("main", 2, 2, 0); + return structureCheck_EM("main", 2, 2, 0); } @Override @@ -126,16 +125,16 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock } timerValue.set(timerValue.get() + 1); remainingTime.set(timerSetting.get() - timerValue.get()); - IGregTechTileEntity mte = getBaseMetaTileEntity(); - Vec3Impl xyzOffsets = getExtendedFacing().getWorldOffset(new Vec3Impl(0, -1, 2)); - double xPos = mte.getXCoord() + 0.5f + xyzOffsets.get0(); - double yPos = mte.getYCoord() + 0.5f + xyzOffsets.get1(); - double zPos = mte.getZCoord() + 0.5f + xyzOffsets.get2(); + IGregTechTileEntity mte = getBaseMetaTileEntity(); + Vec3Impl xyzOffsets = getExtendedFacing().getWorldOffset(new Vec3Impl(0, -1, 2)); + double xPos = mte.getXCoord() + 0.5f + xyzOffsets.get0(); + double yPos = mte.getYCoord() + 0.5f + xyzOffsets.get1(); + double zPos = mte.getZCoord() + 0.5f + xyzOffsets.get2(); AxisAlignedBB aabb = getBoundingBox(-2, -2, -2, 2, 2, 2) .offset(xPos, yPos, zPos); xyzOffsets = getExtendedFacing().getWorldOffset(new Vec3Impl(0, -4, 0)); Vec3Impl xyzExpansion = getExtendedFacing().getWorldOffset(new Vec3Impl(1, 0, 1)).abs(); - int power = (int) powerSetting.get(); + int power = (int) powerSetting.get(); int damagingFactor = Math.min(power >> 6, 8) + Math.min(power >> 8, 24) + @@ -143,7 +142,7 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock (power >> 18); ArrayList<ItemStack> itemsToOutput = new ArrayList<>(); - HashSet<Entity> tickedStuff = new HashSet<>(); + HashSet<Entity> tickedStuff = new HashSet<>(); boolean inside = true; do { @@ -171,7 +170,7 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock } } aabb.offset(xyzOffsets.get0(), xyzOffsets.get1(), xyzOffsets.get2()); - aabb = aabb.expand(xyzExpansion.get0()*1.5, xyzExpansion.get1()*1.5, xyzExpansion.get2()*1.5); + aabb = aabb.expand(xyzExpansion.get0() * 1.5, xyzExpansion.get1() * 1.5, xyzExpansion.get2() * 1.5); inside = false; damagingFactor >>= 1; } while (damagingFactor > 0); @@ -196,12 +195,12 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity,true, false, true); + return new GT_Container_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, true, false, true); } @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "EMDisplay.png",true, false, true);//todo texture + return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "EMDisplay.png", true, false, true);//todo texture } @Override @@ -247,7 +246,7 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - structureBuild_EM("main", 2, 2, 0, hintsOnly, stackSize); + structureBuild_EM("main", 2, 2, 0, stackSize, hintsOnly); } @Override @@ -259,4 +258,4 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_proccessingStack.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_proccessingStack.java index 3a1a5a5418..ba0af2d349 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_proccessingStack.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_proccessingStack.java @@ -1,7 +1,8 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.item.ItemStack; @@ -13,6 +14,11 @@ public class GT_MetaTileEntity_TM_proccessingStack extends GT_MetaTileEntity_Mul } @Override + public IStructureDefinition<? extends GT_MetaTileEntity_MultiblockBase_EM> getStructure_EM() { + return null; + } + + @Override public void construct(ItemStack stackSize, boolean hintsOnly) { } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java index cbc20143b3..8d910d9431 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -20,7 +20,6 @@ import com.google.common.collect.Multimap; import com.google.common.collect.MultimapBuilder; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import com.gtnewhorizon.structurelib.util.Vec3Impl; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -46,45 +45,46 @@ import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBloc import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; import static com.github.technus.tectech.util.CommonValues.V; import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; -import static gregtech.api.util.GT_StructureUtility.*; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; import static java.lang.Math.min; import static net.minecraft.util.StatCollector.translateToLocal; public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable, ITeslaConnectable { //Interface fields private final Multimap<Integer, ITeslaConnectableSimple> teslaNodeMap = MultimapBuilder.treeKeys().linkedListValues().build(); - private final HashSet<ThaumSpark> sparkList = new HashSet<>(); - private int sparkCount = 10; + private final HashSet<ThaumSpark> sparkList = new HashSet<>(); + private int sparkCount = 10; //region variables - private static final int transferRadiusTowerFromConfig = TecTech.configTecTech.TESLA_MULTI_RANGE_TOWER;//Default is 32 - private static final int transferRadiusTransceiverFromConfig = TecTech.configTecTech.TESLA_MULTI_RANGE_TRANSCEIVER;//Default is 16 - private static final int transferRadiusCoverUltimateFromConfig = TecTech.configTecTech.TESLA_MULTI_RANGE_COVER;//Default is 16 - private static final int plasmaRangeMultiT1 = TecTech.configTecTech.TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T1;//Default is 2 - private static final int plasmaRangeMultiT2 = TecTech.configTecTech.TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T2;//Default is 4 - private static final int heliumUse = TecTech.configTecTech.TESLA_MULTI_PLASMA_PER_SECOND_T1_HELIUM;//Default is 100 - private static final int nitrogenUse = TecTech.configTecTech.TESLA_MULTI_PLASMA_PER_SECOND_T1_NITROGEN;//Default is 50 - private static final int radonUse = TecTech.configTecTech.TESLA_MULTI_PLASMA_PER_SECOND_T2_RADON;//Default is 50 + private static final int transferRadiusTowerFromConfig = TecTech.configTecTech.TESLA_MULTI_RANGE_TOWER;//Default is 32 + private static final int transferRadiusTransceiverFromConfig = TecTech.configTecTech.TESLA_MULTI_RANGE_TRANSCEIVER;//Default is 16 + private static final int transferRadiusCoverUltimateFromConfig = TecTech.configTecTech.TESLA_MULTI_RANGE_COVER;//Default is 16 + private static final int plasmaRangeMultiT1 = TecTech.configTecTech.TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T1;//Default is 2 + private static final int plasmaRangeMultiT2 = TecTech.configTecTech.TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T2;//Default is 4 + private static final int heliumUse = TecTech.configTecTech.TESLA_MULTI_PLASMA_PER_SECOND_T1_HELIUM;//Default is 100 + private static final int nitrogenUse = TecTech.configTecTech.TESLA_MULTI_PLASMA_PER_SECOND_T1_NITROGEN;//Default is 50 + private static final int radonUse = TecTech.configTecTech.TESLA_MULTI_PLASMA_PER_SECOND_T2_RADON;//Default is 50 //Default is {1, 1, 1} - private static final int[] plasmaTierLoss = new int[]{TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T0, + private static final int[] plasmaTierLoss = new int[]{TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T0, TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T1, TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T2}; - private static final float overDriveLoss = TecTech.configTecTech.TESLA_MULTI_LOSS_FACTOR_OVERDRIVE;//Default is 0.25F; - private static final boolean doFluidOutput = TecTech.configTecTech.TESLA_MULTI_GAS_OUTPUT; //Default is false + private static final float overDriveLoss = TecTech.configTecTech.TESLA_MULTI_LOSS_FACTOR_OVERDRIVE;//Default is 0.25F; + private static final boolean doFluidOutput = TecTech.configTecTech.TESLA_MULTI_GAS_OUTPUT; //Default is false //Face icons private static Textures.BlockIcons.CustomIcon ScreenOFF; private static Textures.BlockIcons.CustomIcon ScreenON; - private int mTier = 0; //Determines max voltage (LV to ZPM) + private int mTier = 0; //Determines max voltage (LV to ZPM) private int plasmaTier = 0; //0 is None, 1 is Helium or Nitrogen, 2 is Radon (Does not match actual plasma tiers) private FluidStack[] mOutputFluidsQueue; //Used to buffer the fluid outputs, so the tesla takes a second to 'cool' any plasma it would output as a gas private final ArrayList<GT_MetaTileEntity_Hatch_Capacitor> eCapacitorHatches = new ArrayList<>(); //Capacitor hatches which determine the max voltage tier and count of amps - private long energyCapacity = 0; //Total energy storage limited by capacitors + private long energyCapacity = 0; //Total energy storage limited by capacitors private long outputVoltageMax = 0; //Tesla voltage output limited by capacitors - private int vTier = -1; //Tesla voltage tier limited by capacitors + private int vTier = -1; //Tesla voltage tier limited by capacitors private long outputCurrentMax = 0; //Tesla current output limited by capacitors //outputVoltage and current after settings @@ -92,45 +92,46 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock private long outputCurrent; //Prevents unnecessary offset calculation, saving on lag - private byte oldRotation = -1; - private byte oldOrientation = -1; + private byte oldRotation = -1; + private byte oldOrientation = -1; //Location of the center of the sphere on top of the tower, used as the Thaumcraft lightning and origin - public Vec3Impl posTop = Vec3Impl.NULL_VECTOR; + public Vec3Impl posTop = Vec3Impl.NULL_VECTOR; //endregion //region structure private static final String[] description = new String[]{ EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.hint.0"),//1 - Classic Hatches, Capacitor Hatches or Tesla Base Casing + translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.hint.1"),//2 - ""Titanium frames"" }; - private static final IStructureDefinition<GT_MetaTileEntity_TM_teslaCoil> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_TM_teslaCoil>builder() + private static final IStructureDefinition<GT_MetaTileEntity_TM_teslaCoil> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_TM_teslaCoil>builder() .addShape("main", transpose(new String[][]{ - {" "," "," BBB "," BBB "," BBB "," "," "}, - {" "," BBB "," BBBBB "," BBBBB "," BBBBB "," BBB "," "}, - {" "," BBB "," BBBBB "," BBBBB "," BBBBB "," BBB "," "}, - {" "," BBB "," BBBBB "," BBBBB "," BBBBB "," BBB "," "}, - {" "," "," BBB "," BCB "," BBB "," "," "}, - {" "," "," "," C "," "," "," "}, - {" "," BBB "," B F B "," BFCFB "," B F B "," BBB "," "}, - {" "," "," "," C "," "," "," "}, - {" "," BBB "," B F B "," BFCFB "," B F B "," BBB "," "}, - {" "," "," "," C "," "," "," "}, - {" "," BBB "," B F B "," BFCFB "," B F B "," BBB "," "}, - {" "," "," "," C "," "," "," "}, - {" "," BBB "," B F B "," BFCFB "," B F B "," BBB "," "}, - {" "," "," "," C "," "," "," "}, - {" "," "," "," C "," "," "," "}, - {" "," DDD "," D D "," D C D "," D D "," DDD "," "}, - {" EE~EE ","EAAAAAE","EADDDAE","EADADAE","EADDDAE"," AAAAAE"," EEEEE "} + {" ", " ", " BBB ", " BBB ", " BBB ", " ", " "}, + {" ", " BBB ", " BBBBB ", " BBBBB ", " BBBBB ", " BBB ", " "}, + {" ", " BBB ", " BBBBB ", " BBBBB ", " BBBBB ", " BBB ", " "}, + {" ", " BBB ", " BBBBB ", " BBBBB ", " BBBBB ", " BBB ", " "}, + {" ", " ", " BBB ", " BCB ", " BBB ", " ", " "}, + {" ", " ", " ", " C ", " ", " ", " "}, + {" ", " BBB ", " B F B ", " BFCFB ", " B F B ", " BBB ", " "}, + {" ", " ", " ", " C ", " ", " ", " "}, + {" ", " BBB ", " B F B ", " BFCFB ", " B F B ", " BBB ", " "}, + {" ", " ", " ", " C ", " ", " ", " "}, + {" ", " BBB ", " B F B ", " BFCFB ", " B F B ", " BBB ", " "}, + {" ", " ", " ", " C ", " ", " ", " "}, + {" ", " BBB ", " B F B ", " BFCFB ", " B F B ", " BBB ", " "}, + {" ", " ", " ", " C ", " ", " ", " "}, + {" ", " ", " ", " C ", " ", " ", " "}, + {" ", " DDD ", " D D ", " D C D ", " D D ", " DDD ", " "}, + {" EE~EE ", "EAAAAAE", "EADDDAE", "EADADAE", "EADDDAE", " AAAAAE", " EEEEE "} })) .addElement('A', ofBlock(sBlockCasingsBA0, 6)) .addElement('B', ofBlock(sBlockCasingsBA0, 7)) .addElement('C', ofBlock(sBlockCasingsBA0, 8)) .addElement('D', defer(t -> ofBlock(sBlockCasingsBA0, t.getCoilWindingMeta()))) .addElement('E', ofHatchAdderOptional(GT_MetaTileEntity_TM_teslaCoil::addCapacitorToMachineList, textureOffset + 16 + 6, 1, sBlockCasingsBA0, 6)) - .addElement('F', ofFrame(Materials.get("Titanium"))) + .addElement('F', ofHatchAdder(GT_MetaTileEntity_TM_teslaCoil::addFrameToMachineList, 0, 2)) .build(); public int getCoilWindingMeta() { @@ -143,28 +144,28 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock protected Parameters.Group.ParameterIn popogaSetting, histLowSetting, histHighSetting, transferRadiusTowerSetting, transferRadiusTransceiverSetting, transferRadiusCoverUltimateSetting, outputVoltageSetting, outputCurrentSetting, sortTimeMinSetting, overDriveSetting; protected Parameters.Group.ParameterOut popogaDisplay, transferRadiusTowerDisplay, transferRadiusTransceiverDisplay, transferRadiusCoverUltimateDisplay, outputVoltageDisplay, outputCurrentDisplay, energyCapacityDisplay, energyStoredDisplay, energyFractionDisplay, sortTimeDisplay; - private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> HYSTERESIS_LOW_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.0");//Hysteresis low setting - private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> HYSTERESIS_HIGH_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.1");//Hysteresis high setting - private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> TRANSFER_RADIUS_TOWER_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.2");//Tesla Towers transfer radius setting - private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> TRANSFER_RADIUS_TRANSCEIVER_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.3");//Tesla Transceiver transfer radius setting + private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> HYSTERESIS_LOW_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.0");//Hysteresis low setting + private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> HYSTERESIS_HIGH_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.1");//Hysteresis high setting + private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> TRANSFER_RADIUS_TOWER_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.2");//Tesla Towers transfer radius setting + private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> TRANSFER_RADIUS_TRANSCEIVER_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.3");//Tesla Transceiver transfer radius setting private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> TRANSFER_RADIUS_COVER_ULTIMATE_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.4");//Tesla Ultimate Cover transfer radius setting - private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> OUTPUT_VOLTAGE_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.5");//Output voltage setting - private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> OUTPUT_CURRENT_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.6");//Output current setting - private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> SCAN_TIME_MIN_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.7");//Scan time Min setting - private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> OVERDRIVE_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.8");//Overdrive setting - private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> POPOGA_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.9");//Unused - - private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> TRANSFER_RADIUS_TOWER_DISPLAY_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.0");//Tesla Towers transfer radius display - private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> TRANSFER_RADIUS_TRANSCEIVER_DISPLAY_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.1");//Tesla Transceiver transfer radius display + private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> OUTPUT_VOLTAGE_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.5");//Output voltage setting + private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> OUTPUT_CURRENT_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.6");//Output current setting + private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> SCAN_TIME_MIN_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.7");//Scan time Min setting + private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> OVERDRIVE_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.8");//Overdrive setting + private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> POPOGA_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.9");//Unused + + private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> TRANSFER_RADIUS_TOWER_DISPLAY_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.0");//Tesla Towers transfer radius display + private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> TRANSFER_RADIUS_TRANSCEIVER_DISPLAY_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.1");//Tesla Transceiver transfer radius display private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> TRANSFER_RADIUS_COVER_ULTIMATE_DISPLAY_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.2");//Tesla Ultimate Cover transfer radius display - private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> OUTPUT_VOLTAGE_DISPLAY_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.3");//Output voltage display - private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> OUTPUT_CURRENT_DISPLAY_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.4");//Output current display - private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> ENERGY_CAPACITY_DISPLAY_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.5");//Energy Capacity display - private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> ENERGY_STORED_DISPLAY_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.6");//Energy Stored display - private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> ENERGY_FRACTION_DISPLAY_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.7");//Energy Fraction display - private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> SCAN_TIME_DISPLAY_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.8");//Scan time display - - private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> HYSTERESIS_LOW_STATUS = (base, p) -> { + private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> OUTPUT_VOLTAGE_DISPLAY_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.3");//Output voltage display + private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> OUTPUT_CURRENT_DISPLAY_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.4");//Output current display + private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> ENERGY_CAPACITY_DISPLAY_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.5");//Energy Capacity display + private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> ENERGY_STORED_DISPLAY_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.6");//Energy Stored display + private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> ENERGY_FRACTION_DISPLAY_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.7");//Energy Fraction display + private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> SCAN_TIME_DISPLAY_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.8");//Scan time display + + private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> HYSTERESIS_LOW_STATUS = (base, p) -> { double value = p.get(); if (Double.isNaN(value)) { return STATUS_WRONG; @@ -173,14 +174,14 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock if (value > base.histHighSetting.get()) return STATUS_TOO_HIGH; return STATUS_OK; }; - private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> HYSTERESIS_HIGH_STATUS = (base, p) -> { + private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> HYSTERESIS_HIGH_STATUS = (base, p) -> { double value = p.get(); if (Double.isNaN(value)) return STATUS_WRONG; if (value <= base.histLowSetting.get()) return STATUS_TOO_LOW; if (value > 0.95) return STATUS_TOO_HIGH; return STATUS_OK; }; - private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> TRANSFER_RADIUS_TOWER_STATUS = (base, p) -> { + private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> TRANSFER_RADIUS_TOWER_STATUS = (base, p) -> { double value = p.get(); if (Double.isNaN(value)) return STATUS_WRONG; value = (int) value; @@ -189,7 +190,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock if (value < transferRadiusTowerFromConfig) return STATUS_LOW; return STATUS_OK; }; - private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> TRANSFER_RADIUS_TRANSCEIVER_STATUS = (base, p) -> { + private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> TRANSFER_RADIUS_TRANSCEIVER_STATUS = (base, p) -> { double value = p.get(); if (Double.isNaN(value)) return STATUS_WRONG; value = (int) value; @@ -207,7 +208,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock if (value < transferRadiusCoverUltimateFromConfig) return STATUS_LOW; return STATUS_OK; }; - private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> OUTPUT_VOLTAGE_OR_CURRENT_STATUS = (base, p) -> { + private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> OUTPUT_VOLTAGE_OR_CURRENT_STATUS = (base, p) -> { double value = p.get(); if (Double.isNaN(value)) return STATUS_WRONG; value = (long) value; @@ -215,7 +216,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock if (value <= 0) return STATUS_TOO_LOW; return STATUS_OK; }; - private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> SCAN_TIME_MIN_STATUS = (base, p) -> { + private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> SCAN_TIME_MIN_STATUS = (base, p) -> { double value = p.get(); if (Double.isNaN(value)) return STATUS_WRONG; value = (int) value; @@ -223,7 +224,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock if (value == 100) return STATUS_OK; return STATUS_HIGH; }; - private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> OVERDRIVE_STATUS = (base, p) -> { + private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> OVERDRIVE_STATUS = (base, p) -> { double value = p.get(); if (Double.isNaN(value)) return STATUS_WRONG; value = (int) value; @@ -231,20 +232,20 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock if (value == 0) return STATUS_LOW; return STATUS_HIGH; }; - private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> POPOGA_STATUS = (base, p) -> { + private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> POPOGA_STATUS = (base, p) -> { if (base.getBaseMetaTileEntity().getWorld().isThundering()) { return STATUS_WTF; } return STATUS_NEUTRAL; }; - private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> SCAN_TIME_STATUS = (base, p) -> { + private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> SCAN_TIME_STATUS = (base, p) -> { double value = p.get(); if (Double.isNaN(value)) return STATUS_WRONG; value = (int) value; if (value == 0) return STATUS_HIGH; return STATUS_LOW; }; - private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> POWER_STATUS = (base, p) -> { + private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> POWER_STATUS = (base, p) -> { double value = p.get(); if (Double.isNaN(value)) return STATUS_WRONG; value = (long) value; @@ -254,7 +255,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock return STATUS_LOW; } }; - private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> ENERGY_STATUS = (base, p) -> { + private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> ENERGY_STATUS = (base, p) -> { double value = p.get(); if (Double.isNaN(value)) return STATUS_WRONG; if (base.energyFractionDisplay.get() > base.histHighSetting.get()) { @@ -369,8 +370,8 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock oldOrientation = iGregTechTileEntity.getFrontFacing(); Vec3Impl posBMTE = new Vec3Impl(getBaseMetaTileEntity().getXCoord(), - getBaseMetaTileEntity().getYCoord(), - getBaseMetaTileEntity().getZCoord()); + getBaseMetaTileEntity().getYCoord(), + getBaseMetaTileEntity().getZCoord()); //Calculate coordinates of the middle bottom posTop = getExtendedFacing().getWorldOffset(new Vec3Impl(0, 0, 2)).add(posBMTE); @@ -612,10 +613,10 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock //TODO Encapsulate the spark sender sparkCount--; - if (sparkCount == 0){ + if (sparkCount == 0) { IGregTechTileEntity mte = getBaseMetaTileEntity(); sparkCount = 10; - if(!sparkList.isEmpty()){ + if (!sparkList.isEmpty()) { NetworkDispatcher.INSTANCE.sendToAllAround(new RendererMessage.RendererData(sparkList), mte.getWorld().provider.dimensionId, mte.getXCoord(), @@ -699,7 +700,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - structureBuild_EM("main", 3, 16, 0, hintsOnly, stackSize); + structureBuild_EM("main", 3, 16, 0, stackSize, hintsOnly); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java index c2d1012910..1691940997 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.base; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.gui.GT_Slot_Holo; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -134,8 +134,8 @@ public class GT_Container_MultiMachineEM extends GT_ContainerMetaTile_Machine { var1.sendProgressBarUpdate(this, 120, eCertainMode | (eCertainStatus << 8)); var1.sendProgressBarUpdate(this, 121, (ePowerPass ? 1 : 0) + (eSafeVoid ? 2 : 0) + (allowedToWork ? 4 : 0) + (ePowerPassButton?8:0)); for(int i=128,k=208,j=0;j<20;j++,i+=4,k+=4) { - Util.sendDouble(eParamsOut[j], this, var1, i); - Util.sendDouble(eParamsIn[j], this, var1, k); + TT_Utility.sendDouble(eParamsOut[j], this, var1, i); + TT_Utility.sendDouble(eParamsIn[j], this, var1, k); } } } @@ -159,10 +159,10 @@ public class GT_Container_MultiMachineEM extends GT_ContainerMetaTile_Machine { ePowerPassCover = (par2 & 8) == 8; } else if(par1>=128 && par1<208){ int pos=(par1-128)>>2; - eParamsOut[pos]=Double.longBitsToDouble(eParamsOutl[pos]=Util.receiveLong(eParamsOutl[pos],par1&0xFFFFFFFC,par1,par2)); + eParamsOut[pos]=Double.longBitsToDouble(eParamsOutl[pos]= TT_Utility.receiveLong(eParamsOutl[pos],par1&0xFFFFFFFC,par1,par2)); }else if(par1>=208 && par1<288){ int pos=(par1-208)>>2; - eParamsIn[pos]=Double.longBitsToDouble(eParamsInl[pos]=Util.receiveLong(eParamsInl[pos],par1&0xFFFFFFFC,par1,par2)); + eParamsIn[pos]=Double.longBitsToDouble(eParamsInl[pos]= TT_Utility.receiveLong(eParamsInl[pos],par1&0xFFFFFFFC,par1,par2)); } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java index a0755b947b..10377e9298 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java @@ -2,8 +2,13 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.base; import com.github.technus.tectech.Reference; import com.github.technus.tectech.TecTech; - -import com.github.technus.tectech.mechanics.structure.Structure; +import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; +import com.github.technus.tectech.thing.metaTileEntity.hatch.*; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; +import com.github.technus.tectech.util.TT_Utility; import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.alignment.IAlignment; import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; @@ -14,14 +19,6 @@ import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.util.Vec3Impl; import cpw.mods.fml.common.network.NetworkRegistry; - -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.tElementalException; -import com.github.technus.tectech.thing.metaTileEntity.hatch.*; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; -import com.github.technus.tectech.util.Util; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -33,9 +30,7 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.*; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gregtech.api.util.IGT_HatchAdder; import gregtech.common.GT_Pollution; -import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.InventoryPlayer; @@ -49,10 +44,11 @@ import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.loader.TecTechConfig.POWERLESS_MODE; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.util.CommonValues.*; import static com.github.technus.tectech.util.DoubleCount.div; -import static com.github.technus.tectech.util.Util.getTier; +import static com.github.technus.tectech.util.TT_Utility.getTier; import static java.lang.Math.min; /** @@ -69,7 +65,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt //Sound resource - same as with screen but override getActivitySound public final static ResourceLocation activitySound = new ResourceLocation(Reference.MODID + ":fx_lo_freq"); @SideOnly(Side.CLIENT) - private SoundLoop activitySoundLoop; + private SoundLoop activitySoundLoop; //endregion //region HATCHES ARRAYS - they hold info about found hatches, add hatches to them... (auto structure magic does it tho) @@ -77,19 +73,19 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt //HATCHES!!!, should be added and removed in check machine //EM in/out - protected ArrayList<GT_MetaTileEntity_Hatch_InputElemental> eInputHatches = new ArrayList<>(); - protected ArrayList<GT_MetaTileEntity_Hatch_OutputElemental> eOutputHatches = new ArrayList<>(); + protected ArrayList<GT_MetaTileEntity_Hatch_InputElemental> eInputHatches = new ArrayList<>(); + protected ArrayList<GT_MetaTileEntity_Hatch_OutputElemental> eOutputHatches = new ArrayList<>(); //EM overflow output - protected ArrayList<GT_MetaTileEntity_Hatch_OverflowElemental> eMufflerHatches = new ArrayList<>(); + protected ArrayList<GT_MetaTileEntity_Hatch_OverflowElemental> eMufflerHatches = new ArrayList<>(); //extra hatches - protected ArrayList<GT_MetaTileEntity_Hatch_Param> eParamHatches = new ArrayList<>(); - protected ArrayList<GT_MetaTileEntity_Hatch_Uncertainty> eUncertainHatches = new ArrayList<>(); + protected ArrayList<GT_MetaTileEntity_Hatch_Param> eParamHatches = new ArrayList<>(); + protected ArrayList<GT_MetaTileEntity_Hatch_Uncertainty> eUncertainHatches = new ArrayList<>(); //multi amp hatches in/out - protected ArrayList<GT_MetaTileEntity_Hatch_EnergyMulti> eEnergyMulti = new ArrayList<>(); - protected ArrayList<GT_MetaTileEntity_Hatch_DynamoMulti> eDynamoMulti = new ArrayList<>(); + protected ArrayList<GT_MetaTileEntity_Hatch_EnergyMulti> eEnergyMulti = new ArrayList<>(); + protected ArrayList<GT_MetaTileEntity_Hatch_DynamoMulti> eDynamoMulti = new ArrayList<>(); //data hatches - protected ArrayList<GT_MetaTileEntity_Hatch_InputData> eInputData = new ArrayList<>(); - protected ArrayList<GT_MetaTileEntity_Hatch_OutputData> eOutputData = new ArrayList<>(); + protected ArrayList<GT_MetaTileEntity_Hatch_InputData> eInputData = new ArrayList<>(); + protected ArrayList<GT_MetaTileEntity_Hatch_OutputData> eOutputData = new ArrayList<>(); //endregion @@ -111,7 +107,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt //storage for output EM that will be auto handled in case of failure to finish recipe //if you succed to use a recipe - be sure to output EM from outputEM to hatches in the output method - protected cElementalInstanceStackMap[] outputEM; + protected EMInstanceStackMap[] outputEM; //are parameters correct - change in check recipe/output/update params etc. (maintenance status boolean) protected boolean eParameters = true; @@ -147,7 +143,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt //front rotation val private IAlignmentLimits alignmentLimits = IAlignmentLimits.UNLIMITED; - private ExtendedFacing extendedFacing = ExtendedFacing.DEFAULT; + private ExtendedFacing extendedFacing = ExtendedFacing.DEFAULT; //endregion protected GT_MetaTileEntity_MultiblockBase_EM(int aID, String aName, String aNameRegional) { @@ -166,14 +162,19 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt //region SUPER STRUCT @Override + public IAlignmentLimits getAlignmentLimits() { + return alignmentLimits; + } + + @Override public ExtendedFacing getExtendedFacing() { return extendedFacing; } @Override public void setExtendedFacing(ExtendedFacing newExtendedFacing) { - if(extendedFacing!=newExtendedFacing){ - extendedFacing=newExtendedFacing; + if (extendedFacing != newExtendedFacing) { + extendedFacing = newExtendedFacing; IGregTechTileEntity base = getBaseMetaTileEntity(); mMachine = false; if (getBaseMetaTileEntity().isServerSide()) { @@ -183,18 +184,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt StructureLibAPI.sendAlignment((IAlignmentProvider) base, new NetworkRegistry.TargetPoint(base.getWorld().provider.dimensionId, base.getXCoord(), base.getYCoord(), base.getZCoord(), 512)); - }else{ + } else { base.issueTextureUpdate(); } } } @Override - public IAlignmentLimits getAlignmentLimits() { - return alignmentLimits; - } - - @Override public boolean isFacingValid(byte aFacing) { return canSetToDirectionAny(ForgeDirection.getOrientation(aFacing)); } @@ -206,46 +202,29 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt /** * Gets structure + * * @return STATIC INSTANCE OF STRUCTURE */ - public IStructureDefinition<? extends GT_MetaTileEntity_MultiblockBase_EM> getStructure_EM(){ - throw new NoSuchMethodError("Implement it as STATIC INSTANCE"); - } + public abstract IStructureDefinition<? extends GT_MetaTileEntity_MultiblockBase_EM> getStructure_EM(); @SuppressWarnings("unchecked") - private IStructureDefinition<GT_MetaTileEntity_MultiblockBase_EM> getStructure_EM_Internal(){ - return (IStructureDefinition<GT_MetaTileEntity_MultiblockBase_EM>)getStructure_EM(); + private IStructureDefinition<GT_MetaTileEntity_MultiblockBase_EM> getStructure_EM_Internal() { + return (IStructureDefinition<GT_MetaTileEntity_MultiblockBase_EM>) getStructure_EM(); } - public final boolean structureCheck_EM(String piece,int horizontalOffset, int verticalOffset, int depthOffset) { + public final boolean structureCheck_EM(String piece, int horizontalOffset, int verticalOffset, int depthOffset) { IGregTechTileEntity baseMetaTileEntity = getBaseMetaTileEntity(); - return getStructure_EM_Internal().check(this,piece, baseMetaTileEntity.getWorld(),getExtendedFacing(), - baseMetaTileEntity.getXCoord(),baseMetaTileEntity.getYCoord(),baseMetaTileEntity.getZCoord(), - horizontalOffset,verticalOffset,depthOffset,!mMachine); + return getStructure_EM_Internal().check(this, piece, baseMetaTileEntity.getWorld(), getExtendedFacing(), + baseMetaTileEntity.getXCoord(), baseMetaTileEntity.getYCoord(), baseMetaTileEntity.getZCoord(), + horizontalOffset, verticalOffset, depthOffset, !mMachine); } - public final boolean structureBuild_EM(String piece,int horizontalOffset, int verticalOffset, int depthOffset,boolean hintsOnly,ItemStack trigger) { + public final boolean structureBuild_EM(String piece, int horizontalOffset, int verticalOffset, int depthOffset, ItemStack trigger, boolean hintsOnly) { IGregTechTileEntity baseMetaTileEntity = getBaseMetaTileEntity(); return getStructure_EM_Internal().buildOrHints(this, trigger, piece, baseMetaTileEntity.getWorld(), getExtendedFacing(), baseMetaTileEntity.getXCoord(), baseMetaTileEntity.getYCoord(), baseMetaTileEntity.getZCoord(), horizontalOffset, verticalOffset, depthOffset, hintsOnly); } - - @Deprecated - @SuppressWarnings("unchecked") - public final <T extends GT_MetaTileEntity_MultiblockBase_EM> boolean structureCheck_EM( - String[][] structure,//0-9 casing, +- air no air, a-z ignore - Block[] blockType,//use numbers 0-9 for casing types - byte[] blockMeta,//use numbers 0-9 for casing types - IGT_HatchAdder<T>[] addingMethods, - short[] casingTextures, - Block[] blockTypeFallback,//use numbers 0-9 for casing types - byte[] blockMetaFallback,//use numbers 0-9 for casing types - int horizontalOffset, int verticalOffset, int depthOffset) { - return Structure.checker(structure, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, - horizontalOffset, verticalOffset, depthOffset, (T)this, getExtendedFacing(), !mMachine); - } - //endregion //region METHODS TO OVERRIDE - general functionality, recipe check, output @@ -318,7 +297,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt EnumChatFormatting.YELLOW + ":" + EnumChatFormatting.AQUA + "I " + parametrization.getStatusIn(hatchNo, paramID).name.get()); list.add(EnumChatFormatting.WHITE + "Value: " + - EnumChatFormatting.AQUA + Util.doubleToString(parametrization.getIn(hatchNo, paramID))); + EnumChatFormatting.AQUA + TT_Utility.doubleToString(parametrization.getIn(hatchNo, paramID))); try { list.add(parametrization.groups[hatchNo].parameterIn[paramID].getBrief()); } catch (NullPointerException | IndexOutOfBoundsException e) { @@ -341,7 +320,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt EnumChatFormatting.YELLOW + ":" + EnumChatFormatting.AQUA + "O " + parametrization.getStatusOut(hatchNo, paramID).name.get()); list.add(EnumChatFormatting.WHITE + "Value: " + - EnumChatFormatting.AQUA + Util.doubleToString(parametrization.getOut(hatchNo, paramID))); + EnumChatFormatting.AQUA + TT_Utility.doubleToString(parametrization.getOut(hatchNo, paramID))); try { list.add(parametrization.groups[hatchNo].parameterOut[paramID].getBrief()); } catch (NullPointerException | IndexOutOfBoundsException e) { @@ -371,7 +350,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Override public String[] getInfoData() {//TODO Do it long storedEnergy = 0; - long maxEnergy = 0; + long maxEnergy = 0; for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); @@ -649,10 +628,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt * @return available data */ protected long getAvailableData_EM() { - long result = 0; - Vec3Impl pos = new Vec3Impl(getBaseMetaTileEntity().getXCoord(), - getBaseMetaTileEntity().getYCoord(), - getBaseMetaTileEntity().getZCoord()); + long result = 0; + IGregTechTileEntity baseMetaTileEntity = getBaseMetaTileEntity(); + Vec3Impl pos = new Vec3Impl(baseMetaTileEntity.getXCoord(), baseMetaTileEntity.getYCoord(), baseMetaTileEntity.getZCoord()); for (GT_MetaTileEntity_Hatch_InputData in : eInputData) { if (in.q != null) { Long value = in.q.contentIfNotInTrace(pos); @@ -724,8 +702,8 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt aNBT.setByte("eCertainM", eCertainMode); aNBT.setByte("eCertainS", eCertainStatus); aNBT.setByte("eMinRepair", minRepairStatus); - aNBT.setByte("eRotation", (byte)extendedFacing.getRotation().getIndex()); - aNBT.setByte("eFlip", (byte)extendedFacing.getFlip().getIndex()); + aNBT.setByte("eRotation", (byte) extendedFacing.getRotation().getIndex()); + aNBT.setByte("eFlip", (byte) extendedFacing.getFlip().getIndex()); aNBT.setBoolean("eParam", eParameters); aNBT.setBoolean("ePass", ePowerPass); aNBT.setBoolean("ePowerPassCover", ePowerPassCover); @@ -761,7 +739,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt NBTTagCompound output = new NBTTagCompound(); for (int i = 0; i < outputEM.length; i++) { if (outputEM[i] != null) { - output.setTag(Integer.toString(i), outputEM[i].toNBT()); + output.setTag(Integer.toString(i), outputEM[i].toNBT(TecTech.definitionsRegistry)); } } aNBT.setTag("outputEM", output); @@ -808,14 +786,14 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt eMaxAmpereGen = aNBT.getLong("eGenRating"); maxEUinputMin = aNBT.getLong("eMaxEUmin"); maxEUinputMax = aNBT.getLong("eMaxEUmax"); - eAmpereFlow = aNBT.hasKey("eRating")?aNBT.getLong("eRating"):1; + eAmpereFlow = aNBT.hasKey("eRating") ? aNBT.getLong("eRating") : 1; eMaxAmpereFlow = aNBT.getLong("eMaxA"); eRequiredData = aNBT.getLong("eDataR"); eAvailableData = aNBT.getLong("eDataA"); eCertainMode = aNBT.getByte("eCertainM"); eCertainStatus = aNBT.getByte("eCertainS"); - minRepairStatus = aNBT.hasKey("eMinRepair")?aNBT.getByte("eMinRepair"):3; - extendedFacing=ExtendedFacing.of( + minRepairStatus = aNBT.hasKey("eMinRepair") ? aNBT.getByte("eMinRepair") : 3; + extendedFacing = ExtendedFacing.of( ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()), Rotation.byIndex(aNBT.getByte("eRotation")), Flip.byIndex(aNBT.getByte("eFlip"))); @@ -846,13 +824,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt int outputLen = aNBT.getInteger("eOutputStackCount"); if (outputLen > 0) { - outputEM = new cElementalInstanceStackMap[outputLen]; + outputEM = new EMInstanceStackMap[outputLen]; NBTTagCompound compound = aNBT.getCompoundTag("outputEM"); for (int i = 0; i < outputEM.length; i++) { if (compound.hasKey(Integer.toString(i))) { try { - outputEM[i] = cElementalInstanceStackMap.fromNBT(compound.getCompoundTag(Integer.toString(i))); - } catch (tElementalException e) { + outputEM[i] = EMInstanceStackMap.fromNBT(TecTech.definitionsRegistry, compound.getCompoundTag(Integer.toString(i))); + } catch (EMException e) { if (DEBUG_MODE) { e.printStackTrace(); } @@ -970,7 +948,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt private void cleanOrExplode() { if (outputEM != null) { float mass = 0; - for (cElementalInstanceStackMap tree : outputEM) { + for (EMInstanceStackMap tree : outputEM) { if (tree != null) { mass += tree.getMass(); } @@ -1159,7 +1137,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt explodeMultiblock(); } if (outputEM != null) { - for (cElementalInstanceStackMap tree : outputEM) { + for (EMInstanceStackMap tree : outputEM) { if (tree != null && tree.hasStacks()) { explodeMultiblock(); } @@ -1226,7 +1204,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt mProgresstime = 0; mMaxProgresstime = 0; mEfficiencyIncrease = 0; - + if (aBaseMetaTileEntity.isAllowedToWork()) { if (checkRecipe(mInventory[1])) { mEfficiency = Math.max(0, min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - (getIdealStatus() - getRepairStatus()) * 1000)); @@ -1301,26 +1279,26 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } double remaining = voider.overflowMax - voider.getOverflowMatter(); for (GT_MetaTileEntity_Hatch_InputElemental in : eInputHatches) { - for (cElementalInstanceStack instance : in.getContainerHandler().values()) { - double qty = div(remaining,instance.definition.getMass()); + for (EMInstanceStack instance : in.getContentHandler().valuesToArray()) { + double qty = div(remaining, instance.getDefinition().getMass()); if (qty > 0) { - qty = min(qty, instance.amount); - if (voider.addOverflowMatter(instance.definition.getMass() * qty)) { + qty = min(qty, instance.getAmount()); + if (voider.addOverflowMatter(instance.getDefinition().getMass() * qty)) { voider.setOverflowMatter(voider.overflowMax); } - in.getContainerHandler().removeAmount(false, new cElementalDefinitionStack(instance.definition, qty)); + in.getContentHandler().removeAmount(new EMDefinitionStack(instance.getDefinition(), qty)); } } } for (GT_MetaTileEntity_Hatch_OutputElemental out : eOutputHatches) { - for (cElementalInstanceStack instance : out.getContainerHandler().values()) { - double qty = div(remaining,instance.definition.getMass()); + for (EMInstanceStack instance : out.getContentHandler().valuesToArray()) { + double qty = div(remaining, instance.getDefinition().getMass()); if (qty > 0) { - qty = min(qty, instance.amount); - if (voider.addOverflowMatter(instance.definition.getMass() * qty)) { + qty = min(qty, instance.getAmount()); + if (voider.addOverflowMatter(instance.getDefinition().getMass() * qty)) { voider.setOverflowMatter(voider.overflowMax); } - out.getContainerHandler().removeAmount(false, new cElementalDefinitionStack(instance.definition, qty)); + out.getContentHandler().removeAmount(new EMDefinitionStack(instance.getDefinition(), qty)); } } } @@ -1328,16 +1306,16 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } protected void maintenance_EM() { - for (GT_MetaTileEntity_Hatch_Maintenance tHatch : mMaintenanceHatches) { - if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - if (GT_MetaTileEntity_MultiBlockBase.disableMaintenance) { - mWrench = true; - mScrewdriver = true; - mSoftHammer = true; - mHardHammer = true; - mSolderingTool = true; - mCrowbar = true; - } else { + if (GT_MetaTileEntity_MultiBlockBase.disableMaintenance) { + mWrench = true; + mScrewdriver = true; + mSoftHammer = true; + mHardHammer = true; + mSolderingTool = true; + mCrowbar = true; + } else { + for (GT_MetaTileEntity_Hatch_Maintenance tHatch : mMaintenanceHatches) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { if (tHatch.mAuto && !(mWrench && mScrewdriver && mSoftHammer && mHardHammer && mSolderingTool && mCrowbar)) { tHatch.autoMaintainance(); } @@ -1544,7 +1522,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } protected void dischargeController_EM(IGregTechTileEntity aBaseMetaTileEntity) { - if(ePowerPass && getEUVar() > getMinimumStoredEU()){ + if (ePowerPass && getEUVar() > getMinimumStoredEU()) { powerPass(aBaseMetaTileEntity); } } @@ -1604,7 +1582,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt break; } if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - euVar = Math.min(tHatch.maxEUInput() * tHatch.maxAmperesIn(),tHatch.getEUVar()); + euVar = Math.min(tHatch.maxEUInput() * tHatch.maxAmperesIn(), tHatch.getEUVar()); if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euVar, false)) { setEUVar(getEUVar() + euVar); } @@ -1615,7 +1593,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt break; } if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - euVar = Math.min(tHatch.maxEUInput() * tHatch.maxAmperesIn(),tHatch.getEUVar()); + euVar = Math.min(tHatch.maxEUInput() * tHatch.maxAmperesIn(), tHatch.getEUVar()); if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euVar, false)) { setEUVar(getEUVar() + euVar); } @@ -1678,6 +1656,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt if (allowProduction && euFlow > 0) { addEnergyOutput_EM((long) mEUt * (long) mEfficiency / getMaxEfficiency(aStack), eAmpereFlow); } else if (euFlow < 0) { + if (POWERLESS_MODE) { + return true; + } if (!drainEnergyInput_EM(mEUt, (long) mEUt * getMaxEfficiency(aStack) / Math.max(1000L, mEfficiency), eAmpereFlow)) { criticalStopMachine(); return false; @@ -1691,6 +1672,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt if (allowProduction && euFlow > 0) { addEnergyOutput_EM((long) mEUt * (long) mEfficiency / getMaxEfficiency(aStack), eAmpereFlow); } else if (euFlow < 0) { + if (POWERLESS_MODE) { + return true; + } if (!drainEnergyInput((long) mEUt * getMaxEfficiency(aStack) / Math.max(1000L, mEfficiency), eAmpereFlow)) { criticalStopMachine(); return false; @@ -1735,7 +1719,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Deprecated @Override public final boolean addEnergyOutput(long eu) { - return addEnergyOutput_EM(eu,1); + return addEnergyOutput_EM(eu, 1); } public boolean addEnergyOutput_EM(long EU, long Amperes) { @@ -1788,24 +1772,24 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Deprecated @Override public final boolean drainEnergyInput(long eu) { - return drainEnergyInput_EM(0,eu,1); + return drainEnergyInput_EM(0, eu, 1); } public boolean drainEnergyInput_EM(long EUtTierVoltage, long EUtEffective, long Amperes) { long EUuse = EUtEffective * Amperes; - if(EUuse==0){ + if (EUuse == 0) { return true; } - if(maxEUinputMin==0){ + if (maxEUinputMin == 0) { return false; } if (EUuse < 0) { EUuse = -EUuse; } if (EUuse > getEUVar() || //not enough power - (EUtTierVoltage==0? EUuse> getMaxInputEnergy(): + (EUtTierVoltage == 0 ? EUuse > getMaxInputEnergy() : (EUtTierVoltage > maxEUinputMax) || //TIER IS BASED ON BEST HATCH! not total EUtEffective input - (EUtTierVoltage * Amperes - 1) / maxEUinputMin + 1 > eMaxAmpereFlow)) {// EUuse==0? --> (EUuse - 1) / maxEUinputMin + 1 = 1! //if not too much A + (EUtTierVoltage * Amperes - 1) / maxEUinputMin + 1 > eMaxAmpereFlow)) {// EUuse==0? --> (EUuse - 1) / maxEUinputMin + 1 = 1! //if not too much A if (DEBUG_MODE) { TecTech.LOGGER.debug("L1 " + EUuse + ' ' + getEUVar() + ' ' + (EUuse > getEUVar())); TecTech.LOGGER.debug("L2 " + EUtEffective + ' ' + maxEUinputMax + ' ' + (EUtEffective > maxEUinputMax)); @@ -1821,10 +1805,10 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt public boolean drainEnergyInput(long EUtEffective, long Amperes) { long EUuse = EUtEffective * Amperes; - if(EUuse==0){ + if (EUuse == 0) { return true; } - if(maxEUinputMin==0){ + if (maxEUinputMin == 0) { return false; } if (EUuse < 0) { @@ -1846,7 +1830,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt mMaxProgresstime = time; return true; } - long tempEUt = Math.max(EU, V[1]); + long tempEUt = Math.max(EU, V[1]); long tempTier = maxEUinputMax >> 2; while (tempEUt < tempTier) { tempEUt <<= 2; @@ -1889,12 +1873,12 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt long energy = 0; for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - energy += tHatch.maxEUInput()*tHatch.maxAmperesIn(); + energy += tHatch.maxEUInput() * tHatch.maxAmperesIn(); } } for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) { if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - energy += tHatch.maxEUInput()*tHatch.maxAmperesIn(); + energy += tHatch.maxEUInput() * tHatch.maxAmperesIn(); } } return energy; @@ -1909,7 +1893,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) { if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - energy += tHatch.maxEUInput()*tHatch.Amperes; + energy += tHatch.maxEUInput() * tHatch.Amperes; } } return energy; @@ -1933,19 +1917,19 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt //region convenience copies input and output EM //new Method - public final cElementalInstanceStackMap getInputsClone_EM() { - cElementalInstanceStackMap in = new cElementalInstanceStackMap(); + public final EMInstanceStackMap getInputsClone_EM() { + EMInstanceStackMap in = new EMInstanceStackMap(); for (GT_MetaTileEntity_Hatch_ElementalContainer hatch : eInputHatches) { - in.putUnifyAll(hatch.getContainerHandler()); + in.putUnifyAll(hatch.getContentHandler()); } return in.hasStacks() ? in : null; } //new Method - public final cElementalInstanceStackMap getOutputsClone_EM() { - cElementalInstanceStackMap out = new cElementalInstanceStackMap(); + public final EMInstanceStackMap getOutputsClone_EM() { + EMInstanceStackMap out = new EMInstanceStackMap(); for (GT_MetaTileEntity_Hatch_ElementalContainer hatch : eOutputHatches) { - out.putUnifyAll(hatch.getContainerHandler()); + out.putUnifyAll(hatch.getContentHandler()); } return out.hasStacks() ? out : null; } @@ -1975,10 +1959,10 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt if (target == null) { return; } - cleanMassEM_EM(target.getContainerHandler().getMass()); + cleanMassEM_EM(target.getContentHandler().getMass()); } - public void cleanStackEM_EM(cElementalInstanceStack target) { + public void cleanStackEM_EM(EMInstanceStack target) { if (target == null) { return; } @@ -2010,7 +1994,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt return; } float mass = 0; - for (cElementalInstanceStackMap map : outputEM) { + for (EMInstanceStackMap map : outputEM) { if (map != null) { mass += map.getMass(); } @@ -2098,13 +2082,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Override public void doExplosion(long aExplosionPower) { - explodeMultiblock(); if (!TecTech.configTecTech.BOOM_ENABLE) { TecTech.proxy.broadcast("Multi DoExplosion BOOM! " + getBaseMetaTileEntity().getXCoord() + ' ' + getBaseMetaTileEntity().getYCoord() + ' ' + getBaseMetaTileEntity().getZCoord()); StackTraceElement[] ste = Thread.currentThread().getStackTrace(); TecTech.proxy.broadcast("Multi DoExplosion BOOM! " + ste[2].toString()); return; } + explodeMultiblock(); super.doExplosion(aExplosionPower); }//Redirecting to explodemultiblock //endregion diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/render/TT_RenderedExtendedFacingTexture.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/render/TT_RenderedExtendedFacingTexture.java index 5ed53634de..9795b42827 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/render/TT_RenderedExtendedFacingTexture.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/render/TT_RenderedExtendedFacingTexture.java @@ -1,39 +1,16 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.base.render; -import com.github.technus.tectech.util.LightingHelper; -import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider; -import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; import gregtech.api.enums.Dyes; -import gregtech.api.interfaces.IColorModulationContainer; import gregtech.api.interfaces.IIconContainer; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; +import gregtech.common.render.GT_RenderedTexture; -public class TT_RenderedExtendedFacingTexture implements ITexture,IColorModulationContainer { - private final IIconContainer mIconContainer; - private final boolean mAllowAlpha; - /** - * DO NOT MANIPULATE THE VALUES INSIDE THIS ARRAY!!! - * <p/> - * Just set this variable to another different Array instead. - * Otherwise some colored things will get Problems. - */ - public short[] mRGBa; +public class TT_RenderedExtendedFacingTexture extends GT_RenderedTexture { + public TT_RenderedExtendedFacingTexture(IIconContainer aIcon, short[] aRGBa, boolean allowAlpha, boolean glow, boolean stdOrient, boolean extFacing) { + super(aIcon, aRGBa, allowAlpha, glow, stdOrient, extFacing); + } public TT_RenderedExtendedFacingTexture(IIconContainer aIcon, short[] aRGBa, boolean aAllowAlpha) { - if (aRGBa.length != 4) throw new IllegalArgumentException("RGBa doesn't have 4 Values @ TT_RenderedTexture"); - mIconContainer = aIcon; - mAllowAlpha = aAllowAlpha; - mRGBa = aRGBa; + this(aIcon,aRGBa,aAllowAlpha,false,false,true); } public TT_RenderedExtendedFacingTexture(IIconContainer aIcon, short[] aRGBa) { @@ -43,863 +20,4 @@ public class TT_RenderedExtendedFacingTexture implements ITexture,IColorModulati public TT_RenderedExtendedFacingTexture(IIconContainer aIcon) { this(aIcon, Dyes._NULL.mRGBa); } - - @Override - public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - aRenderer.field_152631_f = true; - LightingHelper lighting = new LightingHelper(aRenderer); - lighting.setupLightingXPos(aBlock, aX, aY, aZ).setupColor(ForgeDirection.EAST.ordinal(), mRGBa); - ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); - renderFaceXPos(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); - if (mIconContainer.getOverlayIcon() != null) { - lighting.setupColor(ForgeDirection.EAST.ordinal(), 0xffffff); - renderFaceXPos(aRenderer, aX, aY, aZ, mIconContainer.getOverlayIcon(), rotation); - } - aRenderer.field_152631_f = false; - } - - @Override - public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - LightingHelper lighting = new LightingHelper(aRenderer); - lighting.setupLightingXNeg(aBlock, aX, aY, aZ).setupColor(ForgeDirection.WEST.ordinal(), mRGBa); - ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); - renderFaceXNeg(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); - if (mIconContainer.getOverlayIcon() != null) { - lighting.setupColor(ForgeDirection.WEST.ordinal(), 0xffffff); - renderFaceXNeg(aRenderer, aX, aY, aZ, mIconContainer.getOverlayIcon(), rotation); - } - } - - @Override - public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - LightingHelper lighting = new LightingHelper(aRenderer); - lighting.setupLightingYPos(aBlock, aX, aY, aZ).setupColor(ForgeDirection.UP.ordinal(), mRGBa); - ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); - renderFaceYPos(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); - if (mIconContainer.getOverlayIcon() != null) { - lighting.setupColor(ForgeDirection.UP.ordinal(), 0xffffff); - renderFaceYPos(aRenderer, aX, aY, aZ, mIconContainer.getOverlayIcon(), rotation); - } - } - - @Override - public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - LightingHelper lighting = new LightingHelper(aRenderer); - lighting.setupLightingYNeg(aBlock, aX, aY, aZ).setupColor(ForgeDirection.DOWN.ordinal(), mRGBa); - ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); - renderFaceYNeg(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); - if (mIconContainer.getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(255, 255, 255, 255); - renderFaceYNeg(aRenderer, aX, aY, aZ, mIconContainer.getOverlayIcon(), rotation); - } - } - - @Override - public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - LightingHelper lighting = new LightingHelper(aRenderer); - lighting.setupLightingZPos(aBlock, aX, aY, aZ).setupColor(ForgeDirection.SOUTH.ordinal(), mRGBa); - ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); - renderFaceZPos(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); - if (mIconContainer.getOverlayIcon() != null) { - lighting.setupColor(ForgeDirection.SOUTH.ordinal(), 0xffffff); - renderFaceZPos(aRenderer, aX, aY, aZ, mIconContainer.getOverlayIcon(), rotation); - } - } - - @Override - public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - aRenderer.field_152631_f = true; - LightingHelper lighting = new LightingHelper(aRenderer); - lighting.setupLightingZNeg(aBlock, aX, aY, aZ).setupColor(ForgeDirection.NORTH.ordinal(), mRGBa); - ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); - renderFaceZNeg(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); - if (mIconContainer.getOverlayIcon() != null) { - lighting.setupColor(ForgeDirection.NORTH.ordinal(), 0xffffff); - renderFaceZNeg(aRenderer, aX, aY, aZ, mIconContainer.getOverlayIcon(), rotation); - } - aRenderer.field_152631_f = false; - } - - /** - * Renders the given texture to the bottom face of the block. Args: block, x, y, z, texture - */ - public void renderFaceYNeg(RenderBlocks aRenderer, double x, double y, double z, IIcon icon, ExtendedFacing rotation) { - Tessellator tessellator = Tessellator.instance; - - if (aRenderer.hasOverrideBlockTexture()) { - icon = aRenderer.overrideBlockTexture; - } - - double d3 = icon.getInterpolatedU(aRenderer.renderMaxX * 16.0D); - double d4 = icon.getInterpolatedU(aRenderer.renderMinX * 16.0D); - double d5 = icon.getInterpolatedV(aRenderer.renderMinZ * 16.0D); - double d6 = icon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D); - - if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { - d3 = icon.getMaxU(); - d4 = icon.getMinU(); - } - - if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) { - d5 = icon.getMinV(); - d6 = icon.getMaxV(); - } - - { - double temp; - switch (rotation.getFlip().ordinal()){ - case 1: - temp=d3; - d3=d4; - d4=temp; - break; - case 2: - temp=d5; - d5=d6; - d6=temp; - case 3: - temp=d3; - d3=d4; - d4=temp; - break; - } - } - - double d7 = d4; - double d8 = d3; - double d9 = d5; - double d10 = d6; - - switch (rotation.getRotation().ordinal()) { - case 3: - d3 = icon.getInterpolatedU(aRenderer.renderMaxZ * 16.0D); - d5 = icon.getInterpolatedV(16.0D - aRenderer.renderMaxX * 16.0D); - d4 = icon.getInterpolatedU(aRenderer.renderMinZ * 16.0D); - d6 = icon.getInterpolatedV(16.0D - aRenderer.renderMinX * 16.0D); - d9 = d5; - d10 = d6; - d7 = d3; - d8 = d4; - d5 = d6; - d6 = d9; - break; - case 1: - d3 = icon.getInterpolatedU(16.0D - aRenderer.renderMinZ * 16.0D); - d5 = icon.getInterpolatedV(aRenderer.renderMinX * 16.0D); - d4 = icon.getInterpolatedU(16.0D - aRenderer.renderMaxZ * 16.0D); - d6 = icon.getInterpolatedV(aRenderer.renderMaxX * 16.0D); - d7 = d4; - d8 = d3; - d3 = d4; - d4 = d8; - d9 = d6; - d10 = d5; - break; - case 2: - d3 = icon.getInterpolatedU(16.0D - aRenderer.renderMaxX * 16.0D); - d4 = icon.getInterpolatedU(16.0D - aRenderer.renderMinX * 16.0D); - d5 = icon.getInterpolatedV(16.0D - aRenderer.renderMinZ * 16.0D); - d6 = icon.getInterpolatedV(16.0D - aRenderer.renderMaxZ * 16.0D); - d7 = d4; - d8 = d3; - d9 = d5; - d10 = d6; - break; - } - - double d11 = x + aRenderer.renderMinX; - double d12 = x + aRenderer.renderMaxX; - double d13 = y + aRenderer.renderMinY; - double d14 = z + aRenderer.renderMinZ; - double d15 = z + aRenderer.renderMaxZ; - - if (aRenderer.renderFromInside) { - d11 = x + aRenderer.renderMaxX; - d12 = x + aRenderer.renderMinX; - } - - if (aRenderer.enableAO) { - tessellator.setColorOpaque_F(aRenderer.colorRedTopLeft, aRenderer.colorGreenTopLeft, aRenderer.colorBlueTopLeft); - tessellator.setBrightness(aRenderer.brightnessTopLeft); - tessellator.addVertexWithUV(d11, d13, d15, d8, d10); - tessellator.setColorOpaque_F(aRenderer.colorRedBottomLeft, aRenderer.colorGreenBottomLeft, aRenderer.colorBlueBottomLeft); - tessellator.setBrightness(aRenderer.brightnessBottomLeft); - tessellator.addVertexWithUV(d11, d13, d14, d3, d5); - tessellator.setColorOpaque_F(aRenderer.colorRedBottomRight, aRenderer.colorGreenBottomRight, aRenderer.colorBlueBottomRight); - tessellator.setBrightness(aRenderer.brightnessBottomRight); - tessellator.addVertexWithUV(d12, d13, d14, d7, d9); - tessellator.setColorOpaque_F(aRenderer.colorRedTopRight, aRenderer.colorGreenTopRight, aRenderer.colorBlueTopRight); - tessellator.setBrightness(aRenderer.brightnessTopRight); - tessellator.addVertexWithUV(d12, d13, d15, d4, d6); - } else { - tessellator.addVertexWithUV(d11, d13, d15, d8, d10); - tessellator.addVertexWithUV(d11, d13, d14, d3, d5); - tessellator.addVertexWithUV(d12, d13, d14, d7, d9); - tessellator.addVertexWithUV(d12, d13, d15, d4, d6); - } - } - - /** - * Renders the given texture to the top face of the block. Args: block, x, y, z, texture - */ - public void renderFaceYPos(RenderBlocks aRenderer, double x, double y, double z, IIcon icon, ExtendedFacing rotation) { - Tessellator tessellator = Tessellator.instance; - - if (aRenderer.hasOverrideBlockTexture()) { - icon = aRenderer.overrideBlockTexture; - } - - double d3 = icon.getInterpolatedU(aRenderer.renderMinX * 16.0D); - double d4 = icon.getInterpolatedU(aRenderer.renderMaxX * 16.0D); - double d5 = icon.getInterpolatedV(aRenderer.renderMinZ * 16.0D); - double d6 = icon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D); - - if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { - d3 = icon.getMinU(); - d4 = icon.getMaxU(); - } - - if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) { - d5 = icon.getMinV(); - d6 = icon.getMaxV(); - } - - { - double temp; - switch (rotation.getFlip().ordinal()){ - case 1: - temp=d3; - d3=d4; - d4=temp; - break; - case 2: - temp=d5; - d5=d6; - d6=temp; - case 3: - temp=d3; - d3=d4; - d4=temp; - break; - } - } - - double d7 = d4; - double d8 = d3; - double d9 = d5; - double d10 = d6; - - switch (rotation.getRotation().ordinal()) { - case 1: - d3 = icon.getInterpolatedU(aRenderer.renderMinZ * 16.0D); - d5 = icon.getInterpolatedV(16.0D - aRenderer.renderMaxX * 16.0D); - d4 = icon.getInterpolatedU(aRenderer.renderMaxZ * 16.0D); - d6 = icon.getInterpolatedV(16.0D - aRenderer.renderMinX * 16.0D); - d9 = d5; - d10 = d6; - d7 = d3; - d8 = d4; - d5 = d6; - d6 = d9; - break; - case 3: - d3 = icon.getInterpolatedU(16.0D - aRenderer.renderMaxZ * 16.0D); - d5 = icon.getInterpolatedV(aRenderer.renderMinX * 16.0D); - d4 = icon.getInterpolatedU(16.0D - aRenderer.renderMinZ * 16.0D); - d6 = icon.getInterpolatedV(aRenderer.renderMaxX * 16.0D); - d7 = d4; - d8 = d3; - d3 = d4; - d4 = d8; - d9 = d6; - d10 = d5; - break; - case 2: - d3 = icon.getInterpolatedU(16.0D - aRenderer.renderMinX * 16.0D); - d4 = icon.getInterpolatedU(16.0D - aRenderer.renderMaxX * 16.0D); - d5 = icon.getInterpolatedV(16.0D - aRenderer.renderMinZ * 16.0D); - d6 = icon.getInterpolatedV(16.0D - aRenderer.renderMaxZ * 16.0D); - d7 = d4; - d8 = d3; - d9 = d5; - d10 = d6; - break; - } - - double d11 = x + aRenderer.renderMinX; - double d12 = x + aRenderer.renderMaxX; - double d13 = y + aRenderer.renderMaxY; - double d14 = z + aRenderer.renderMinZ; - double d15 = z + aRenderer.renderMaxZ; - - if (aRenderer.renderFromInside) { - d11 = x + aRenderer.renderMaxX; - d12 = x + aRenderer.renderMinX; - } - - if (aRenderer.enableAO) { - tessellator.setColorOpaque_F(aRenderer.colorRedTopLeft, aRenderer.colorGreenTopLeft, aRenderer.colorBlueTopLeft); - tessellator.setBrightness(aRenderer.brightnessTopLeft); - tessellator.addVertexWithUV(d12, d13, d15, d4, d6); - tessellator.setColorOpaque_F(aRenderer.colorRedBottomLeft, aRenderer.colorGreenBottomLeft, aRenderer.colorBlueBottomLeft); - tessellator.setBrightness(aRenderer.brightnessBottomLeft); - tessellator.addVertexWithUV(d12, d13, d14, d7, d9); - tessellator.setColorOpaque_F(aRenderer.colorRedBottomRight, aRenderer.colorGreenBottomRight, aRenderer.colorBlueBottomRight); - tessellator.setBrightness(aRenderer.brightnessBottomRight); - tessellator.addVertexWithUV(d11, d13, d14, d3, d5); - tessellator.setColorOpaque_F(aRenderer.colorRedTopRight, aRenderer.colorGreenTopRight, aRenderer.colorBlueTopRight); - tessellator.setBrightness(aRenderer.brightnessTopRight); - tessellator.addVertexWithUV(d11, d13, d15, d8, d10); - } else { - tessellator.addVertexWithUV(d12, d13, d15, d4, d6); - tessellator.addVertexWithUV(d12, d13, d14, d7, d9); - tessellator.addVertexWithUV(d11, d13, d14, d3, d5); - tessellator.addVertexWithUV(d11, d13, d15, d8, d10); - } - } - - /** - * Renders the given texture to the north (z-negative) face of the block. Args: block, x, y, z, texture - */ - public void renderFaceZNeg(RenderBlocks aRenderer, double x, double y, double z, IIcon icon, ExtendedFacing rotation) { - Tessellator tessellator = Tessellator.instance; - - if (aRenderer.hasOverrideBlockTexture()) { - icon = aRenderer.overrideBlockTexture; - } - - double d3 = icon.getInterpolatedU(aRenderer.renderMinX * 16.0D); - double d4 = icon.getInterpolatedU(aRenderer.renderMaxX * 16.0D); - - if (aRenderer.field_152631_f) { - d4 = icon.getInterpolatedU((1.0D - aRenderer.renderMinX) * 16.0D); - d3 = icon.getInterpolatedU((1.0D - aRenderer.renderMaxX) * 16.0D); - } - - double d5 = icon.getInterpolatedV(16.0D - aRenderer.renderMaxY * 16.0D); - double d6 = icon.getInterpolatedV(16.0D - aRenderer.renderMinY * 16.0D); - - double d7; - - if (aRenderer.flipTexture) { - d7 = d3; - d3 = d4; - d4 = d7; - } - - if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { - d3 = icon.getMinU(); - d4 = icon.getMaxU(); - } - - if (aRenderer.renderMinY < 0.0D || aRenderer.renderMaxY > 1.0D) { - d5 = icon.getMinV(); - d6 = icon.getMaxV(); - } - - { - double temp; - switch (rotation.getFlip().ordinal()){ - case 1: - temp=d3; - d3=d4; - d4=temp; - break; - case 2: - temp=d5; - d5=d6; - d6=temp; - case 3: - temp=d3; - d3=d4; - d4=temp; - break; - } - } - - d7 = d4; - double d8 = d3; - double d9 = d5; - double d10 = d6; - - switch (rotation.getRotation().ordinal()) { - case 3: - d3 = icon.getInterpolatedU(aRenderer.renderMaxY * 16.0D); - d4 = icon.getInterpolatedU(aRenderer.renderMinY * 16.0D); - d5 = icon.getInterpolatedV(16.0D - aRenderer.renderMinX * 16.0D); - d6 = icon.getInterpolatedV(16.0D - aRenderer.renderMaxX * 16.0D); - d9 = d5; - d10 = d6; - d7 = d3; - d8 = d4; - d5 = d6; - d6 = d9; - break; - case 1: - d3 = icon.getInterpolatedU(16.0D - aRenderer.renderMinY * 16.0D); - d4 = icon.getInterpolatedU(16.0D - aRenderer.renderMaxY * 16.0D); - d5 = icon.getInterpolatedV(aRenderer.renderMaxX * 16.0D); - d6 = icon.getInterpolatedV(aRenderer.renderMinX * 16.0D); - d7 = d4; - d8 = d3; - d3 = d4; - d4 = d8; - d9 = d6; - d10 = d5; - break; - case 2: - d3 = icon.getInterpolatedU(16.0D - aRenderer.renderMinX * 16.0D); - d4 = icon.getInterpolatedU(16.0D - aRenderer.renderMaxX * 16.0D); - d5 = icon.getInterpolatedV(aRenderer.renderMaxY * 16.0D); - d6 = icon.getInterpolatedV(aRenderer.renderMinY * 16.0D); - d7 = d4; - d8 = d3; - d9 = d5; - d10 = d6; - break; - } - - double d11 = x + aRenderer.renderMinX; - double d12 = x + aRenderer.renderMaxX; - double d13 = y + aRenderer.renderMinY; - double d14 = y + aRenderer.renderMaxY; - double d15 = z + aRenderer.renderMinZ; - - if (aRenderer.renderFromInside) { - d11 = x + aRenderer.renderMaxX; - d12 = x + aRenderer.renderMinX; - } - - if (aRenderer.enableAO) { - tessellator.setColorOpaque_F(aRenderer.colorRedTopLeft, aRenderer.colorGreenTopLeft, aRenderer.colorBlueTopLeft); - tessellator.setBrightness(aRenderer.brightnessTopLeft); - tessellator.addVertexWithUV(d11, d14, d15, d7, d9); - tessellator.setColorOpaque_F(aRenderer.colorRedBottomLeft, aRenderer.colorGreenBottomLeft, aRenderer.colorBlueBottomLeft); - tessellator.setBrightness(aRenderer.brightnessBottomLeft); - tessellator.addVertexWithUV(d12, d14, d15, d3, d5); - tessellator.setColorOpaque_F(aRenderer.colorRedBottomRight, aRenderer.colorGreenBottomRight, aRenderer.colorBlueBottomRight); - tessellator.setBrightness(aRenderer.brightnessBottomRight); - tessellator.addVertexWithUV(d12, d13, d15, d8, d10); - tessellator.setColorOpaque_F(aRenderer.colorRedTopRight, aRenderer.colorGreenTopRight, aRenderer.colorBlueTopRight); - tessellator.setBrightness(aRenderer.brightnessTopRight); - tessellator.addVertexWithUV(d11, d13, d15, d4, d6); - } else { - tessellator.addVertexWithUV(d11, d14, d15, d7, d9); - tessellator.addVertexWithUV(d12, d14, d15, d3, d5); - tessellator.addVertexWithUV(d12, d13, d15, d8, d10); - tessellator.addVertexWithUV(d11, d13, d15, d4, d6); - } - } - - /** - * Renders the given texture to the south (z-positive) face of the block. Args: block, x, y, z, texture - */ - public void renderFaceZPos(RenderBlocks aRenderer, double x, double y, double z, IIcon icon, ExtendedFacing rotation) { - Tessellator tessellator = Tessellator.instance; - - if (aRenderer.hasOverrideBlockTexture()) { - icon = aRenderer.overrideBlockTexture; - } - - double d3 = icon.getInterpolatedU(aRenderer.renderMinX * 16.0D); - double d4 = icon.getInterpolatedU(aRenderer.renderMaxX * 16.0D); - double d5 = icon.getInterpolatedV(16.0D - aRenderer.renderMaxY * 16.0D); - double d6 = icon.getInterpolatedV(16.0D - aRenderer.renderMinY * 16.0D); - double d7; - - if (aRenderer.flipTexture) { - d7 = d3; - d3 = d4; - d4 = d7; - } - - if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { - d3 = icon.getMinU(); - d4 = icon.getMaxU(); - } - - if (aRenderer.renderMinY < 0.0D || aRenderer.renderMaxY > 1.0D) { - d5 = icon.getMinV(); - d6 = icon.getMaxV(); - } - - { - double temp; - switch (rotation.getFlip().ordinal()){ - case 1: - temp=d3; - d3=d4; - d4=temp; - break; - case 2: - temp=d5; - d5=d6; - d6=temp; - case 3: - temp=d3; - d3=d4; - d4=temp; - break; - } - } - - d7 = d4; - double d8 = d3; - double d9 = d5; - double d10 = d6; - - switch (rotation.getRotation().ordinal()) { - case 1: - d3 = icon.getInterpolatedU(aRenderer.renderMinY * 16.0D); - d6 = icon.getInterpolatedV(16.0D - aRenderer.renderMinX * 16.0D); - d4 = icon.getInterpolatedU(aRenderer.renderMaxY * 16.0D); - d5 = icon.getInterpolatedV(16.0D - aRenderer.renderMaxX * 16.0D); - d9 = d5; - d10 = d6; - d7 = d3; - d8 = d4; - d5 = d6; - d6 = d9; - break; - case 3: - d3 = icon.getInterpolatedU(16.0D - aRenderer.renderMaxY * 16.0D); - d5 = icon.getInterpolatedV(aRenderer.renderMinX * 16.0D); - d4 = icon.getInterpolatedU(16.0D - aRenderer.renderMinY * 16.0D); - d6 = icon.getInterpolatedV(aRenderer.renderMaxX * 16.0D); - d7 = d4; - d8 = d3; - d3 = d4; - d4 = d8; - d9 = d6; - d10 = d5; - break; - case 2: - d3 = icon.getInterpolatedU(16.0D - aRenderer.renderMinX * 16.0D); - d4 = icon.getInterpolatedU(16.0D - aRenderer.renderMaxX * 16.0D); - d5 = icon.getInterpolatedV(aRenderer.renderMaxY * 16.0D); - d6 = icon.getInterpolatedV(aRenderer.renderMinY * 16.0D); - d7 = d4; - d8 = d3; - d9 = d5; - d10 = d6; - break; - } - - double d11 = x + aRenderer.renderMinX; - double d12 = x + aRenderer.renderMaxX; - double d13 = y + aRenderer.renderMinY; - double d14 = y + aRenderer.renderMaxY; - double d15 = z + aRenderer.renderMaxZ; - - if (aRenderer.renderFromInside) { - d11 = x + aRenderer.renderMaxX; - d12 = x + aRenderer.renderMinX; - } - - if (aRenderer.enableAO) { - tessellator.setColorOpaque_F(aRenderer.colorRedTopLeft, aRenderer.colorGreenTopLeft, aRenderer.colorBlueTopLeft); - tessellator.setBrightness(aRenderer.brightnessTopLeft); - tessellator.addVertexWithUV(d11, d14, d15, d3, d5); - tessellator.setColorOpaque_F(aRenderer.colorRedBottomLeft, aRenderer.colorGreenBottomLeft, aRenderer.colorBlueBottomLeft); - tessellator.setBrightness(aRenderer.brightnessBottomLeft); - tessellator.addVertexWithUV(d11, d13, d15, d8, d10); - tessellator.setColorOpaque_F(aRenderer.colorRedBottomRight, aRenderer.colorGreenBottomRight, aRenderer.colorBlueBottomRight); - tessellator.setBrightness(aRenderer.brightnessBottomRight); - tessellator.addVertexWithUV(d12, d13, d15, d4, d6); - tessellator.setColorOpaque_F(aRenderer.colorRedTopRight, aRenderer.colorGreenTopRight, aRenderer.colorBlueTopRight); - tessellator.setBrightness(aRenderer.brightnessTopRight); - tessellator.addVertexWithUV(d12, d14, d15, d7, d9); - } else { - tessellator.addVertexWithUV(d11, d14, d15, d3, d5); - tessellator.addVertexWithUV(d11, d13, d15, d8, d10); - tessellator.addVertexWithUV(d12, d13, d15, d4, d6); - tessellator.addVertexWithUV(d12, d14, d15, d7, d9); - } - } - - /** - * Renders the given texture to the west (x-negative) face of the block. Args: block, x, y, z, texture - */ - public void renderFaceXNeg(RenderBlocks aRenderer, double x, double y, double z, IIcon icon, ExtendedFacing rotation) { - Tessellator tessellator = Tessellator.instance; - - if (aRenderer.hasOverrideBlockTexture()) { - icon = aRenderer.overrideBlockTexture; - } - - double d3 = icon.getInterpolatedU(aRenderer.renderMinZ * 16.0D); - double d4 = icon.getInterpolatedU(aRenderer.renderMaxZ * 16.0D); - double d5 = icon.getInterpolatedV(16.0D - aRenderer.renderMaxY * 16.0D); - double d6 = icon.getInterpolatedV(16.0D - aRenderer.renderMinY * 16.0D); - double d7; - - if (aRenderer.flipTexture) { - d7 = d3; - d3 = d4; - d4 = d7; - } - - if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) { - d3 = icon.getMinU(); - d4 = icon.getMaxU(); - } - - if (aRenderer.renderMinY < 0.0D || aRenderer.renderMaxY > 1.0D) { - d5 = icon.getMinV(); - d6 = icon.getMaxV(); - } - - { - double temp; - switch (rotation.getFlip().ordinal()){ - case 1: - temp=d3; - d3=d4; - d4=temp; - break; - case 2: - temp=d5; - d5=d6; - d6=temp; - case 3: - temp=d3; - d3=d4; - d4=temp; - break; - } - } - - d7 = d4; - double d8 = d3; - double d9 = d5; - double d10 = d6; - - switch (rotation.getRotation().ordinal()) { - case 1: - d3 = icon.getInterpolatedU(aRenderer.renderMinY * 16.0D); - d5 = icon.getInterpolatedV(16.0D - aRenderer.renderMaxZ * 16.0D); - d4 = icon.getInterpolatedU(aRenderer.renderMaxY * 16.0D); - d6 = icon.getInterpolatedV(16.0D - aRenderer.renderMinZ * 16.0D); - d9 = d5; - d10 = d6; - d7 = d3; - d8 = d4; - d5 = d6; - d6 = d9; - break; - case 3: - d3 = icon.getInterpolatedU(16.0D - aRenderer.renderMaxY * 16.0D); - d5 = icon.getInterpolatedV(aRenderer.renderMinZ * 16.0D); - d4 = icon.getInterpolatedU(16.0D - aRenderer.renderMinY * 16.0D); - d6 = icon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D); - d7 = d4; - d8 = d3; - d3 = d4; - d4 = d8; - d9 = d6; - d10 = d5; - break; - case 2: - d3 = icon.getInterpolatedU(16.0D - aRenderer.renderMinZ * 16.0D); - d4 = icon.getInterpolatedU(16.0D - aRenderer.renderMaxZ * 16.0D); - d5 = icon.getInterpolatedV(aRenderer.renderMaxY * 16.0D); - d6 = icon.getInterpolatedV(aRenderer.renderMinY * 16.0D); - d7 = d4; - d8 = d3; - d9 = d5; - d10 = d6; - break; - } - - double d11 = x + aRenderer.renderMinX; - double d12 = y + aRenderer.renderMinY; - double d13 = y + aRenderer.renderMaxY; - double d14 = z + aRenderer.renderMinZ; - double d15 = z + aRenderer.renderMaxZ; - - if (aRenderer.renderFromInside) { - d14 = z + aRenderer.renderMaxZ; - d15 = z + aRenderer.renderMinZ; - } - - if (aRenderer.enableAO) { - tessellator.setColorOpaque_F(aRenderer.colorRedTopLeft, aRenderer.colorGreenTopLeft, aRenderer.colorBlueTopLeft); - tessellator.setBrightness(aRenderer.brightnessTopLeft); - tessellator.addVertexWithUV(d11, d13, d15, d7, d9); - tessellator.setColorOpaque_F(aRenderer.colorRedBottomLeft, aRenderer.colorGreenBottomLeft, aRenderer.colorBlueBottomLeft); - tessellator.setBrightness(aRenderer.brightnessBottomLeft); - tessellator.addVertexWithUV(d11, d13, d14, d3, d5); - tessellator.setColorOpaque_F(aRenderer.colorRedBottomRight, aRenderer.colorGreenBottomRight, aRenderer.colorBlueBottomRight); - tessellator.setBrightness(aRenderer.brightnessBottomRight); - tessellator.addVertexWithUV(d11, d12, d14, d8, d10); - tessellator.setColorOpaque_F(aRenderer.colorRedTopRight, aRenderer.colorGreenTopRight, aRenderer.colorBlueTopRight); - tessellator.setBrightness(aRenderer.brightnessTopRight); - tessellator.addVertexWithUV(d11, d12, d15, d4, d6); - } else { - tessellator.addVertexWithUV(d11, d13, d15, d7, d9); - tessellator.addVertexWithUV(d11, d13, d14, d3, d5); - tessellator.addVertexWithUV(d11, d12, d14, d8, d10); - tessellator.addVertexWithUV(d11, d12, d15, d4, d6); - } - } - - /** - * Renders the given texture to the east (x-positive) face of the block. Args: block, x, y, z, texture - */ - public void renderFaceXPos(RenderBlocks aRenderer, double x, double y, double z, IIcon icon, ExtendedFacing rotation) { - Tessellator tessellator = Tessellator.instance; - - if (aRenderer.hasOverrideBlockTexture()) { - icon = aRenderer.overrideBlockTexture; - } - - double d3 = icon.getInterpolatedU(aRenderer.renderMinZ * 16.0D); - double d4 = icon.getInterpolatedU(aRenderer.renderMaxZ * 16.0D); - - if (aRenderer.field_152631_f) { - d4 = icon.getInterpolatedU((1.0D - aRenderer.renderMinZ) * 16.0D); - d3 = icon.getInterpolatedU((1.0D - aRenderer.renderMaxZ) * 16.0D); - } - - double d5 = icon.getInterpolatedV(16.0D - aRenderer.renderMaxY * 16.0D); - double d6 = icon.getInterpolatedV(16.0D - aRenderer.renderMinY * 16.0D); - double d7; - - if (aRenderer.flipTexture) { - d7 = d3; - d3 = d4; - d4 = d7; - } - - if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) { - d3 = icon.getMinU(); - d4 = icon.getMaxU(); - } - - if (aRenderer.renderMinY < 0.0D || aRenderer.renderMaxY > 1.0D) { - d5 = icon.getMinV(); - d6 = icon.getMaxV(); - } - - { - double temp; - switch (rotation.getFlip().ordinal()){ - case 1: - temp=d3; - d3=d4; - d4=temp; - break; - case 2: - temp=d5; - d5=d6; - d6=temp; - case 3: - temp=d3; - d3=d4; - d4=temp; - break; - } - } - - d7 = d4; - double d8 = d3; - double d9 = d5; - double d10 = d6; - - switch (rotation.getRotation().ordinal()) { - case 3: - d3 = icon.getInterpolatedU(aRenderer.renderMaxY * 16.0D); - d5 = icon.getInterpolatedV(16.0D - aRenderer.renderMinZ * 16.0D); - d4 = icon.getInterpolatedU(aRenderer.renderMinY * 16.0D); - d6 = icon.getInterpolatedV(16.0D - aRenderer.renderMaxZ * 16.0D); - d9 = d5; - d10 = d6; - d7 = d3; - d8 = d4; - d5 = d6; - d6 = d9; - break; - case 1: - d3 = icon.getInterpolatedU(16.0D - aRenderer.renderMinY * 16.0D); - d5 = icon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D); - d4 = icon.getInterpolatedU(16.0D - aRenderer.renderMaxY * 16.0D); - d6 = icon.getInterpolatedV(aRenderer.renderMinZ * 16.0D); - d7 = d4; - d8 = d3; - d3 = d4; - d4 = d8; - d9 = d6; - d10 = d5; - break; - case 2: - d3 = icon.getInterpolatedU(16.0D - aRenderer.renderMinZ * 16.0D); - d4 = icon.getInterpolatedU(16.0D - aRenderer.renderMaxZ * 16.0D); - d5 = icon.getInterpolatedV(aRenderer.renderMaxY * 16.0D); - d6 = icon.getInterpolatedV(aRenderer.renderMinY * 16.0D); - d7 = d4; - d8 = d3; - d9 = d5; - d10 = d6; - break; - } - - double d11 = x + aRenderer.renderMaxX; - double d12 = y + aRenderer.renderMinY; - double d13 = y + aRenderer.renderMaxY; - double d14 = z + aRenderer.renderMinZ; - double d15 = z + aRenderer.renderMaxZ; - - if (aRenderer.renderFromInside) { - d14 = z + aRenderer.renderMaxZ; - d15 = z + aRenderer.renderMinZ; - } - - if (aRenderer.enableAO) { - tessellator.setColorOpaque_F(aRenderer.colorRedTopLeft, aRenderer.colorGreenTopLeft, aRenderer.colorBlueTopLeft); - tessellator.setBrightness(aRenderer.brightnessTopLeft); - tessellator.addVertexWithUV(d11, d12, d15, d8, d10); - tessellator.setColorOpaque_F(aRenderer.colorRedBottomLeft, aRenderer.colorGreenBottomLeft, aRenderer.colorBlueBottomLeft); - tessellator.setBrightness(aRenderer.brightnessBottomLeft); - tessellator.addVertexWithUV(d11, d12, d14, d4, d6); - tessellator.setColorOpaque_F(aRenderer.colorRedBottomRight, aRenderer.colorGreenBottomRight, aRenderer.colorBlueBottomRight); - tessellator.setBrightness(aRenderer.brightnessBottomRight); - tessellator.addVertexWithUV(d11, d13, d14, d7, d9); - tessellator.setColorOpaque_F(aRenderer.colorRedTopRight, aRenderer.colorGreenTopRight, aRenderer.colorBlueTopRight); - tessellator.setBrightness(aRenderer.brightnessTopRight); - tessellator.addVertexWithUV(d11, d13, d15, d3, d5); - } else { - tessellator.addVertexWithUV(d11, d12, d15, d8, d10); - tessellator.addVertexWithUV(d11, d12, d14, d4, d6); - tessellator.addVertexWithUV(d11, d13, d14, d7, d9); - tessellator.addVertexWithUV(d11, d13, d15, d3, d5); - } - } - - @Override - public short[] getRGBA() { - return mRGBa; - } - - @Override - public boolean isValidTexture() { - return mIconContainer != null; - } - - private static ExtendedFacing getExtendedFacing(int x, int y, int z) { - World w = Minecraft.getMinecraft().theWorld; - if (w != null) { - TileEntity te = w.getTileEntity(x, y, z); - if (te instanceof IGregTechTileEntity) { - IMetaTileEntity meta = ((IGregTechTileEntity) te).getMetaTileEntity(); - if (meta instanceof IAlignmentProvider) { - return ((IAlignmentProvider) meta).getAlignment().getExtendedFacing(); - }else{ - return ExtendedFacing.of(ForgeDirection.getOrientation(meta.getBaseMetaTileEntity().getFrontFacing())); - } - } else if (te instanceof IAlignmentProvider) { - return ((IAlignmentProvider) te).getAlignment().getExtendedFacing(); - } - } - return ExtendedFacing.DEFAULT; - } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_collider/GT_MetaTileEntity_EM_collider.java index 49c43d6b4e..34fdba402b 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_collider/GT_MetaTileEntity_EM_collider.java @@ -1,18 +1,17 @@ -package com.github.technus.tectech.thing.metaTileEntity.multi; +package com.github.technus.tectech.thing.metaTileEntity.multi.em_collider; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.dComplexAspectDefinition; -import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.ePrimalAspectDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecayResult; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalMutableDefinitionStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.templates.cElementalPrimitive; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dHadronDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eQuarkDefinition; +import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.EMComplexAspectDefinition; +import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.EMPrimalAspectDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecayResult; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMDefinitionStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMHadronDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMQuarkDefinition; import com.github.technus.tectech.thing.block.QuantumGlassBlock; -import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputElemental; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.INameFunction; @@ -20,9 +19,9 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunctio import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; import com.github.technus.tectech.util.CommonValues; +import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -38,13 +37,14 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.HashMap; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; import static com.github.technus.tectech.util.DoubleCount.add; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; import static net.minecraft.util.StatCollector.translateToLocal; @@ -60,45 +60,37 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB protected static final byte FUSE_MODE = 0, COLLIDE_MODE = 1; private static double MASS_TO_EU_INSTANT; - private static int STARTUP_COST, KEEPUP_COST; + private static int STARTUP_COST, KEEPUP_COST; - protected byte eTier = 0; - protected cElementalInstanceStack stack; - private long plasmaEnergy; + protected byte eTier = 0; + protected EMInstanceStack stack; + private long plasmaEnergy; protected boolean started = false; //endregion //region collision handlers - public static final HashMap<Integer, IColliderHandler> FUSE_HANDLERS = new HashMap<>(); + public static final HashMap<Long, IColliderHandler> FUSE_HANDLERS = new HashMap<>(); public static final HashMap<String, IPrimitiveColliderHandler> PRIMITIVE_FUSE_HANDLERS = new HashMap<>(); - public interface IPrimitiveColliderHandler { - void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out); - } - - public interface IColliderHandler extends IPrimitiveColliderHandler { - byte getRequiredTier(); - } - static { - FUSE_HANDLERS.put((dAtomDefinition.getClassTypeStatic() << 16) | dAtomDefinition.getClassTypeStatic(), new IColliderHandler() { + FUSE_HANDLERS.put(((long) EMAtomDefinition.getClassTypeStatic() << 16) | EMAtomDefinition.getClassTypeStatic(), new IColliderHandler() { @Override - public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { + public void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { try { - cElementalMutableDefinitionStackMap defs = new cElementalMutableDefinitionStackMap(); - defs.putUnifyAll(in1.definition.getSubParticles()); - defs.putUnifyAll(in2.definition.getSubParticles()); - dAtomDefinition atom = new dAtomDefinition(defs.toImmutable_optimized_unsafeLeavesExposedElementalTree()); - out.putUnify(new cElementalInstanceStack(atom, Math.min(in1.amount, in2.amount))); + EMDefinitionStackMap defs = new EMDefinitionStackMap(); + defs.putUnifyAllExact(in1.getDefinition().getSubParticles()); + defs.putUnifyAllExact(in2.getDefinition().getSubParticles()); + EMAtomDefinition atom = new EMAtomDefinition(defs.toImmutable_optimized_unsafe_LeavesExposedElementalTree()); + out.putUnify(new EMInstanceStack(atom, Math.min(in1.getAmount(), in2.getAmount()))); } catch (Exception e) { out.putUnifyAll(in1, in2); return; } - if (in1.amount > in2.amount) { - out.putUnify(new cElementalInstanceStack(in1.definition, in1.amount - in2.amount)); - } else if (in2.amount > in1.amount) { - out.putUnify(new cElementalInstanceStack(in2.definition, in2.amount - in1.amount)); + if (in1.getAmount() > in2.getAmount()) { + out.putUnify(new EMInstanceStack(in1.getDefinition(), in1.getAmount() - in2.getAmount())); + } else if (in2.getAmount() > in1.getAmount()) { + out.putUnify(new EMInstanceStack(in2.getDefinition(), in2.getAmount() - in1.getAmount())); } } @@ -107,27 +99,27 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB return 1; } }); - registerSimpleAtomFuse(dHadronDefinition.getClassTypeStatic()); - registerSimpleAtomFuse(dComplexAspectDefinition.getClassTypeStatic()); - registerSimpleAtomFuse(cElementalPrimitive.getClassTypeStatic()); + registerSimpleAtomFuse(EMHadronDefinition.getClassTypeStatic()); + registerSimpleAtomFuse(EMComplexAspectDefinition.getClassTypeStatic()); + registerSimpleAtomFuse(EMPrimitiveTemplate.getClassTypeStatic()); - FUSE_HANDLERS.put((dHadronDefinition.getClassTypeStatic() << 16) | dHadronDefinition.getClassTypeStatic(), new IColliderHandler() { + FUSE_HANDLERS.put(((long) EMHadronDefinition.getClassTypeStatic() << 16) | EMHadronDefinition.getClassTypeStatic(), new IColliderHandler() { @Override - public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { + public void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { try { - cElementalMutableDefinitionStackMap defs = new cElementalMutableDefinitionStackMap(); - defs.putUnifyAll(in1.definition.getSubParticles()); - defs.putUnifyAll(in2.definition.getSubParticles()); - dHadronDefinition hadron = new dHadronDefinition(defs.toImmutable_optimized_unsafeLeavesExposedElementalTree()); - out.putUnify(new cElementalInstanceStack(hadron, Math.min(in1.amount, in2.amount))); + EMDefinitionStackMap defs = new EMDefinitionStackMap(); + defs.putUnifyAllExact(in1.getDefinition().getSubParticles()); + defs.putUnifyAllExact(in2.getDefinition().getSubParticles()); + EMHadronDefinition hadron = new EMHadronDefinition(defs.toImmutable_optimized_unsafe_LeavesExposedElementalTree()); + out.putUnify(new EMInstanceStack(hadron, Math.min(in1.getAmount(), in2.getAmount()))); } catch (Exception e) { out.putUnifyAll(in1, in2); return; } - if (in1.amount > in2.amount) { - out.putUnify(new cElementalInstanceStack(in1.definition, in1.amount - in2.amount)); - } else if (in2.amount > in1.amount) { - out.putUnify(new cElementalInstanceStack(in2.definition, in2.amount - in1.amount)); + if (in1.getAmount() > in2.getAmount()) { + out.putUnify(new EMInstanceStack(in1.getDefinition(), in1.getAmount() - in2.getAmount())); + } else if (in2.getAmount() > in1.getAmount()) { + out.putUnify(new EMInstanceStack(in2.getDefinition(), in2.getAmount() - in1.getAmount())); } } @@ -136,23 +128,23 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB return 2; } }); - FUSE_HANDLERS.put((dHadronDefinition.getClassTypeStatic() << 16) | cElementalPrimitive.getClassTypeStatic(), new IColliderHandler() { + FUSE_HANDLERS.put(((long) EMHadronDefinition.getClassTypeStatic() << 16) | EMPrimitiveTemplate.getClassTypeStatic(), new IColliderHandler() { @Override - public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { + public void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { try { - cElementalMutableDefinitionStackMap defs = new cElementalMutableDefinitionStackMap(); - defs.putUnifyAll(in1.definition.getSubParticles()); - defs.putUnify(in2.definition.getStackForm(1)); - dHadronDefinition hadron = new dHadronDefinition(defs.toImmutable_optimized_unsafeLeavesExposedElementalTree()); - out.putUnify(new cElementalInstanceStack(hadron, Math.min(in1.amount, in2.amount))); + EMDefinitionStackMap defs = new EMDefinitionStackMap(); + defs.putUnifyAllExact(in1.getDefinition().getSubParticles()); + defs.putUnifyExact(in2.getDefinition().getStackForm(1)); + EMHadronDefinition hadron = new EMHadronDefinition(defs.toImmutable_optimized_unsafe_LeavesExposedElementalTree()); + out.putUnify(new EMInstanceStack(hadron, Math.min(in1.getAmount(), in2.getAmount()))); } catch (Exception e) { out.putUnifyAll(in1, in2); return; } - if (in1.amount > in2.amount) { - out.putUnify(new cElementalInstanceStack(in1.definition, in1.amount - in2.amount)); - } else if (in2.amount > in1.amount) { - out.putUnify(new cElementalInstanceStack(in2.definition, in2.amount - in1.amount)); + if (in1.getAmount() > in2.getAmount()) { + out.putUnify(new EMInstanceStack(in1.getDefinition(), in1.getAmount() - in2.getAmount())); + } else if (in2.getAmount() > in1.getAmount()) { + out.putUnify(new EMInstanceStack(in2.getDefinition(), in2.getAmount() - in1.getAmount())); } } @@ -162,13 +154,13 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB } }); - registerSimpleAspectFuse(dComplexAspectDefinition.getClassTypeStatic()); - registerSimpleAspectFuse(cElementalPrimitive.getClassTypeStatic()); + registerSimpleAspectFuse(EMComplexAspectDefinition.getClassTypeStatic()); + registerSimpleAspectFuse(EMPrimitiveTemplate.getClassTypeStatic()); - FUSE_HANDLERS.put((cElementalPrimitive.getClassTypeStatic() << 16) | cElementalPrimitive.getClassTypeStatic(), new IColliderHandler() { + FUSE_HANDLERS.put(((long) EMPrimitiveTemplate.getClassTypeStatic() << 16) | EMPrimitiveTemplate.getClassTypeStatic(), new IColliderHandler() { @Override - public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { - IPrimitiveColliderHandler collisionHandler = PRIMITIVE_FUSE_HANDLERS.get(in1.definition.getClass().getName() + '\0' + in2.definition.getClass().getName()); + public void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { + IPrimitiveColliderHandler collisionHandler = PRIMITIVE_FUSE_HANDLERS.get(in1.getDefinition().getClass().getName() + '\0' + in2.getDefinition().getClass().getName()); if (collisionHandler != null) { collisionHandler.collide(in2, in1, out); } else { @@ -182,40 +174,40 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB } }); - PRIMITIVE_FUSE_HANDLERS.put(eQuarkDefinition.class.getName() + '\0' + eQuarkDefinition.class.getName(), (in1, in2, out) -> { + PRIMITIVE_FUSE_HANDLERS.put(EMQuarkDefinition.class.getName() + '\0' + EMQuarkDefinition.class.getName(), (in1, in2, out) -> { try { - cElementalMutableDefinitionStackMap defs = new cElementalMutableDefinitionStackMap(); - defs.putUnify(in1.definition.getStackForm(1)); - defs.putUnify(in2.definition.getStackForm(1)); - dHadronDefinition hadron = new dHadronDefinition(defs.toImmutable_optimized_unsafeLeavesExposedElementalTree()); - out.putUnify(new cElementalInstanceStack(hadron, Math.min(in1.amount, in2.amount))); + EMDefinitionStackMap defs = new EMDefinitionStackMap(); + defs.putUnifyExact(in1.getDefinition().getStackForm(1)); + defs.putUnifyExact(in2.getDefinition().getStackForm(1)); + EMHadronDefinition hadron = new EMHadronDefinition(defs.toImmutable_optimized_unsafe_LeavesExposedElementalTree()); + out.putUnify(new EMInstanceStack(hadron, Math.min(in1.getAmount(), in2.getAmount()))); } catch (Exception e) { out.putUnifyAll(in1, in2); return; } - if (in1.amount > in2.amount) { - out.putUnify(new cElementalInstanceStack(in1.definition, in1.amount - in2.amount)); - } else if (in2.amount > in1.amount) { - out.putUnify(new cElementalInstanceStack(in2.definition, in2.amount - in1.amount)); + if (in1.getAmount() > in2.getAmount()) { + out.putUnify(new EMInstanceStack(in1.getDefinition(), in1.getAmount() - in2.getAmount())); + } else if (in2.getAmount() > in1.getAmount()) { + out.putUnify(new EMInstanceStack(in2.getDefinition(), in2.getAmount() - in1.getAmount())); } }); - PRIMITIVE_FUSE_HANDLERS.put(ePrimalAspectDefinition.class.getName() + '\0' + ePrimalAspectDefinition.class.getName(), (in1, in2, out) -> { + PRIMITIVE_FUSE_HANDLERS.put(EMPrimalAspectDefinition.class.getName() + '\0' + EMPrimalAspectDefinition.class.getName(), (in1, in2, out) -> { if (fuseAspects(in1, in2, out)) return; - if (in1.amount > in2.amount) { - out.putUnify(new cElementalInstanceStack(in1.definition, in1.amount - in2.amount)); - } else if (in2.amount > in1.amount) { - out.putUnify(new cElementalInstanceStack(in2.definition, in2.amount - in1.amount)); + if (in1.getAmount() > in2.getAmount()) { + out.putUnify(new EMInstanceStack(in1.getDefinition(), in1.getAmount() - in2.getAmount())); + } else if (in2.getAmount() > in1.getAmount()) { + out.putUnify(new EMInstanceStack(in2.getDefinition(), in2.getAmount() - in1.getAmount())); } }); } - private static boolean fuseAspects(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { + private static boolean fuseAspects(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { try { - cElementalMutableDefinitionStackMap defs = new cElementalMutableDefinitionStackMap(); - defs.putUnify(in1.definition.getStackForm(1)); - defs.putUnify(in2.definition.getStackForm(1)); - dComplexAspectDefinition aspect = new dComplexAspectDefinition(defs.toImmutable_optimized_unsafeLeavesExposedElementalTree()); - out.putUnify(new cElementalInstanceStack(aspect, Math.min(in1.amount, in2.amount))); + EMDefinitionStackMap defs = new EMDefinitionStackMap(); + defs.putUnifyExact(in1.getDefinition().getStackForm(1)); + defs.putUnifyExact(in2.getDefinition().getStackForm(1)); + EMComplexAspectDefinition aspect = new EMComplexAspectDefinition(defs.toImmutable_optimized_unsafe_LeavesExposedElementalTree()); + out.putUnify(new EMInstanceStack(aspect, Math.min(in1.getAmount(), in2.getAmount()))); } catch (Exception e) { out.putUnifyAll(in1, in2); return true; @@ -223,15 +215,15 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB return false; } - private static void registerSimpleAspectFuse(byte classTypeStatic) { - FUSE_HANDLERS.put((dComplexAspectDefinition.getClassTypeStatic() << 16) | classTypeStatic, new IColliderHandler() { + private static void registerSimpleAspectFuse(int classTypeStatic) { + FUSE_HANDLERS.put(((long) EMComplexAspectDefinition.getClassTypeStatic() << 16) | classTypeStatic, new IColliderHandler() { @Override - public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { + public void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { if (fuseAspects(in1, in2, out)) return; - if (in1.amount > in2.amount) { - out.putUnify(new cElementalInstanceStack(in1.definition, in1.amount - in2.amount)); - } else if (in2.amount > in1.amount) { - out.putUnify(new cElementalInstanceStack(in2.definition, in2.amount - in1.amount)); + if (in1.getAmount() > in2.getAmount()) { + out.putUnify(new EMInstanceStack(in1.getDefinition(), in1.getAmount() - in2.getAmount())); + } else if (in2.getAmount() > in1.getAmount()) { + out.putUnify(new EMInstanceStack(in2.getDefinition(), in2.getAmount() - in1.getAmount())); } } @@ -242,24 +234,24 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB }); } - private static void registerSimpleAtomFuse(byte classTypeStatic) { - FUSE_HANDLERS.put((dAtomDefinition.getClassTypeStatic() << 16) | classTypeStatic, new IColliderHandler() { + private static void registerSimpleAtomFuse(int classTypeStatic) { + FUSE_HANDLERS.put(((long) EMAtomDefinition.getClassTypeStatic() << 16) | classTypeStatic, new IColliderHandler() { @Override - public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { + public void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { try { - cElementalMutableDefinitionStackMap defs = new cElementalMutableDefinitionStackMap(); - defs.putUnifyAll(in1.definition.getSubParticles()); - defs.putUnify(in2.definition.getStackForm(1)); - dAtomDefinition atom = new dAtomDefinition(defs.toImmutable_optimized_unsafeLeavesExposedElementalTree()); - out.putUnify(new cElementalInstanceStack(atom, Math.min(in1.amount, in2.amount))); + EMDefinitionStackMap defs = new EMDefinitionStackMap(); + defs.putUnifyAllExact(in1.getDefinition().getSubParticles()); + defs.putUnifyExact(in2.getDefinition().getStackForm(1)); + EMAtomDefinition atom = new EMAtomDefinition(defs.toImmutable_optimized_unsafe_LeavesExposedElementalTree()); + out.putUnify(new EMInstanceStack(atom, Math.min(in1.getAmount(), in2.getAmount()))); } catch (Exception e) { out.putUnifyAll(in1, in2); return; } - if (in1.amount > in2.amount) { - out.putUnify(new cElementalInstanceStack(in1.definition, in1.amount - in2.amount)); - } else if (in2.amount > in1.amount) { - out.putUnify(new cElementalInstanceStack(in2.definition, in2.amount - in1.amount)); + if (in1.getAmount() > in2.getAmount()) { + out.putUnify(new EMInstanceStack(in1.getDefinition(), in1.getAmount() - in2.getAmount())); + } else if (in2.getAmount() > in1.getAmount()) { + out.putUnify(new EMInstanceStack(in2.getDefinition(), in2.getAmount() - in1.getAmount())); } } @@ -272,7 +264,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB //endregion //region parameters - protected Parameters.Group.ParameterIn mode; + protected Parameters.Group.ParameterIn mode; private static final IStatusFunction<GT_MetaTileEntity_EM_collider> MODE_STATUS = (base_EM, p) -> { if (base_EM.isMaster()) { double mode = p.get(); @@ -287,7 +279,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB } return STATUS_OK; }; - private static final INameFunction<GT_MetaTileEntity_EM_collider> MODE_NAME = (base_EM, p) -> { + private static final INameFunction<GT_MetaTileEntity_EM_collider> MODE_NAME = (base_EM, p) -> { if (base_EM.isMaster()) { double mode = p.get(); if (mode == FUSE_MODE) { @@ -312,23 +304,31 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB translateToLocal("gt.blockmachines.multimachine.em.collider.hint.4"),//General - Another Controller facing opposite direction }; - private static final IStructureDefinition<GT_MetaTileEntity_EM_collider> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_EM_collider>builder() - .addShape("main", transpose(new String[][]{ - {" A A A "," AAAAAAA "," BBBBIIIBBBB "," BAAAAAAAAAAAB "," BAAAA AAAAB "," BAAA AAAB "," BAAA AAAB "," BAA AAB "," ABAA AABA ","AABA ABAA"," AIA AIA ","AAIA AIAA"," AIA AIA ","AABA ABAA"," ABAA AABA "," BAA AAB "," BAAA AAAB "," BAAA AAAB "," BAAAABJJJBAAAAB "," BAHHBBBBBHHAB "," BBBBGFGBBBB "}, - {" AAAAA "," AADDDDDAA "," CDDEEEEEDDC "," CDEEDDDDDEEDC "," CDEDD DDEDC "," CDED DEDC "," CDED DEDC "," ADED DEDA "," ADED DEDA ","ADED DEDA","ADED DEDA","ADED DEDA","ADED DEDA","ADED DEDA"," ADED DEDA "," ADED DEDA "," CDED DEDC "," CDED DEDC "," CDEDDBJ~JBDDEDC "," CDEEDDDDDEEDC "," CDDEEEEEDDC "}, - {" A A A "," AAAAAAA "," BBBBIIIBBBB "," BAAAAAAAAAAAB "," BAAAA AAAAB "," BAAA AAAB "," BAAA AAAB "," BAA AAB "," ABAA AABA ","AABA ABAA"," AIA AIA ","AAIA AIAA"," AIA AIA ","AABA ABAA"," ABAA AABA "," BAA AAB "," BAAA AAAB "," BAAA AAAB "," BAAAABJJJBAAAAB "," BAHHBBBBBHHAB "," BBBBGFGBBBB "} + private static final IStructureDefinition<GT_MetaTileEntity_EM_collider> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_EM_collider>builder() + .addShape("tier1", transpose(new String[][]{ + {" A A A ", " AAAAAAA ", " bbbbIIIbbbb ", " bAAAAAAAAAAAb ", " bAAAA AAAAb ", " bAAA AAAb ", " bAAA AAAb ", " bAA AAb ", " AbAA AAbA ", "AAbA AbAA", " AIA AIA ", "AAIA AIAA", " AIA AIA ", "AAbA AbAA", " AbAA AAbA ", " bAA AAb ", " bAAA AAAb ", " bAAA AAAb ", " bAAAAbJJJbAAAAb ", " bAHHbbbbbHHAb ", " bbbbGFGbbbb "}, + {" AAAAA ", " AADDDDDAA ", " cDDeeeeeDDc ", " cDeeDDDDDeeDc ", " cDeDD DDeDc ", " cDeD DeDc ", " cDeD DeDc ", " ADeD DeDA ", " ADeD DeDA ", "ADeD DeDA", "ADeD DeDA", "ADeD DeDA", "ADeD DeDA", "ADeD DeDA", " ADeD DeDA ", " ADeD DeDA ", " cDeD DeDc ", " cDeD DeDc ", " cDeDDbJ~JbDDeDc ", " cDeeDDDDDeeDc ", " cDDeeeeeDDc "}, + {" A A A ", " AAAAAAA ", " bbbbIIIbbbb ", " bAAAAAAAAAAAb ", " bAAAA AAAAb ", " bAAA AAAb ", " bAAA AAAb ", " bAA AAb ", " AbAA AAbA ", "AAbA AbAA", " AIA AIA ", "AAIA AIAA", " AIA AIA ", "AAbA AbAA", " AbAA AAbA ", " bAA AAb ", " bAAA AAAb ", " bAAA AAAb ", " bAAAAbJJJbAAAAb ", " bAHHbbbbbHHAb ", " bbbbGFGbbbb "} + })) + .addShape("tier2", transpose(new String[][]{ + {" A A A ", " AAAAAAA ", " BBBBIIIBBBB ", " BAAAAAAAAAAAB ", " BAAAA AAAAB ", " BAAA AAAB ", " BAAA AAAB ", " BAA AAB ", " ABAA AABA ", "AABA ABAA", " AIA AIA ", "AAIA AIAA", " AIA AIA ", "AABA ABAA", " ABAA AABA ", " BAA AAB ", " BAAA AAAB ", " BAAA AAAB ", " BAAAABJJJBAAAAB ", " BAHHBBBBBHHAB ", " BBBBGFGBBBB "}, + {" AAAAA ", " AADDDDDAA ", " CDDEEEEEDDC ", " CDEEDDDDDEEDC ", " CDEDD DDEDC ", " CDED DEDC ", " CDED DEDC ", " ADED DEDA ", " ADED DEDA ", "ADED DEDA", "ADED DEDA", "ADED DEDA", "ADED DEDA", "ADED DEDA", " ADED DEDA ", " ADED DEDA ", " CDED DEDC ", " CDED DEDC ", " CDEDDBJ~JBDDEDC ", " CDEEDDDDDEEDC ", " CDDEEEEEDDC "}, + {" A A A ", " AAAAAAA ", " BBBBIIIBBBB ", " BAAAAAAAAAAAB ", " BAAAA AAAAB ", " BAAA AAAB ", " BAAA AAAB ", " BAA AAB ", " ABAA AABA ", "AABA ABAA", " AIA AIA ", "AAIA AIAA", " AIA AIA ", "AABA ABAA", " ABAA AABA ", " BAA AAB ", " BAAA AAAB ", " BAAA AAAB ", " BAAAABJJJBAAAAB ", " BAHHBBBBBHHAB ", " BBBBGFGBBBB "} })) .addElement('A', ofBlock(sBlockCasingsTT, 4)) - .addElement('B', defer(t -> (int) t.eTier, (t, item) -> 2 - (item.stackSize & 1), error(), ofBlock(sBlockCasingsTT, 4), ofBlock(sBlockCasingsTT, 5))) - .addElement('C', defer(t -> (int) t.eTier, (t, item) -> 2 - (item.stackSize & 1), error(), ofBlock(sBlockCasingsTT, 4), ofBlock(sBlockCasingsTT, 6))) + .addElement('b', ofBlock(sBlockCasingsTT, 4)) + .addElement('B', ofBlock(sBlockCasingsTT, 5)) + .addElement('c', ofBlock(sBlockCasingsTT, 4)) + .addElement('C', ofBlock(sBlockCasingsTT, 6)) .addElement('D', ofBlock(sBlockCasingsTT, 7)) - .addElement('E', defer(t -> (int) t.eTier, (t, item) -> 2 - (item.stackSize & 1), error(), ofBlock(sBlockCasingsTT, 8), ofBlock(sBlockCasingsTT, 9))) - .addElement('F', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addElementalOutputToMachineList, textureOffset + 4, 3, sBlockCasingsTT, 4)) - .addElement('G', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addElementalMufflerToMachineList, textureOffset + 4, 4, sBlockCasingsTT, 4)) - .addElement('H', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addElementalInputToMachineList, textureOffset + 4, 2, sBlockCasingsTT, 4)) + .addElement('e', ofBlock(sBlockCasingsTT, 8)) + .addElement('E', ofBlock(sBlockCasingsTT, 9)) .addElement('I', ofBlock(QuantumGlassBlock.INSTANCE, 0)) .addElement('J', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) + .addElement('H', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addElementalInputToMachineList, textureOffset + 4, 2, sBlockCasingsTT, 4)) + .addElement('F', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addElementalOutputToMachineList, textureOffset + 4, 3, sBlockCasingsTT, 4)) + .addElement('G', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addElementalMufflerToMachineList, textureOffset + 4, 4, sBlockCasingsTT, 4)) .build(); @Override @@ -347,7 +347,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB } public static void setValues(int heliumPlasmaValue) { - double MASS_TO_EU_PARTIAL = heliumPlasmaValue / (1.75893000478707E07* AVOGADRO_CONSTANT);//mass diff + double MASS_TO_EU_PARTIAL = heliumPlasmaValue / (1.75893000478707E07 * EM_COUNT_PER_MATERIAL_AMOUNT);//mass diff MASS_TO_EU_INSTANT = MASS_TO_EU_PARTIAL * 20; STARTUP_COST = -heliumPlasmaValue * 10000; KEEPUP_COST = -heliumPlasmaValue; @@ -355,27 +355,27 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB protected double fuse(GT_MetaTileEntity_EM_collider partner) {///CAN MAKE EU if (partner.stack != null && stack != null) {//todo add single event mode as an option - boolean check = stack.definition.fusionMakesEnergy(stack.getEnergy()) && - partner.stack.definition.fusionMakesEnergy(partner.stack.getEnergy()); + boolean check = stack.getDefinition().fusionMakesEnergy(stack.getEnergy()) && + partner.stack.getDefinition().fusionMakesEnergy(partner.stack.getEnergy()); - cElementalInstanceStack stack2 = partner.stack; - double preMass = add(stack2.getMass(),stack.getMass()); + EMInstanceStack stack2 = partner.stack; + double preMass = add(stack2.getMass(), stack.getMass()); //System.out.println("preMass = " + preMass); - cElementalInstanceStackMap map = new cElementalInstanceStackMap(); - IColliderHandler colliderHandler; - if (stack2.definition.getClassType() > stack.definition.getClassType()) {//always bigger first - colliderHandler = FUSE_HANDLERS.get((stack2.definition.getClassType() << 16) | stack.definition.getClassType()); + EMInstanceStackMap map = new EMInstanceStackMap(); + IColliderHandler colliderHandler; + if (stack2.getDefinition().getMatterMassType() > stack.getDefinition().getMatterMassType()) {//always bigger first + colliderHandler = FUSE_HANDLERS.get((stack2.getDefinition().getMatterMassType() << 16) | stack.getDefinition().getMatterMassType()); if (handleRecipe(stack2, map, colliderHandler)) return 0; } else { - colliderHandler = FUSE_HANDLERS.get((stack.definition.getClassType() << 16) | stack2.definition.getClassType()); + colliderHandler = FUSE_HANDLERS.get((stack.getDefinition().getMatterMassType() << 16) | stack2.getDefinition().getMatterMassType()); if (handleRecipe(stack2, map, colliderHandler)) return 0; } - for (cElementalInstanceStack newStack : map.values()) { - check &= newStack.definition.fusionMakesEnergy(newStack.getEnergy()); + for (EMInstanceStack newStack : map.valuesToArray()) { + check &= newStack.getDefinition().fusionMakesEnergy(newStack.getEnergy()); } //System.out.println("outputEM[0].getMass() = " + outputEM[0].getMass()); - outputEM = new cElementalInstanceStackMap[]{map}; + outputEM = new EMInstanceStackMap[]{map}; partner.stack = stack = null; //System.out.println("check = " + check); @@ -387,21 +387,21 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB protected double collide(GT_MetaTileEntity_EM_collider partner) {//DOES NOT MAKE EU! if (partner.stack != null && stack != null) {//todo add single event mode as an option - cElementalInstanceStack stack2 = partner.stack; - double preMass = stack2.getMass() + stack.getMass(); + EMInstanceStack stack2 = partner.stack; + double preMass = stack2.getMass() + stack.getMass(); //System.out.println("preMass = " + preMass); - cElementalInstanceStackMap map = new cElementalInstanceStackMap(); - IColliderHandler colliderHandler; - if (stack2.definition.getClassType() > stack.definition.getClassType()) {//always bigger first - colliderHandler = FUSE_HANDLERS.get((stack2.definition.getClassType() << 16) | stack.definition.getClassType()); + EMInstanceStackMap map = new EMInstanceStackMap(); + IColliderHandler colliderHandler; + if (stack2.getDefinition().getMatterMassType() > stack.getDefinition().getMatterMassType()) {//always bigger first + colliderHandler = FUSE_HANDLERS.get((stack2.getDefinition().getMatterMassType() << 16) | stack.getDefinition().getMatterMassType()); if (handleRecipe(stack2, map, colliderHandler)) return 0; } else { - colliderHandler = FUSE_HANDLERS.get((stack.definition.getClassType() << 16) | stack2.definition.getClassType()); + colliderHandler = FUSE_HANDLERS.get((stack.getDefinition().getMatterMassType() << 16) | stack2.getDefinition().getMatterMassType()); if (handleRecipe(stack2, map, colliderHandler)) return 0; } //System.out.println("outputEM[0].getMass() = " + outputEM[0].getMass()); - outputEM = new cElementalInstanceStackMap[]{map}; + outputEM = new EMInstanceStackMap[]{map}; partner.stack = stack = null; //System.out.println("check = " + check); @@ -411,22 +411,22 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB return 0; } - private boolean handleRecipe(cElementalInstanceStack stack2, cElementalInstanceStackMap map, IColliderHandler colliderHandler) { + private boolean handleRecipe(EMInstanceStack stack2, EMInstanceStackMap map, IColliderHandler colliderHandler) { if (colliderHandler != null && eTier >= colliderHandler.getRequiredTier()) { colliderHandler.collide(stack2, stack, map); } else { map.putUnifyAll(stack, stack2); - outputEM = new cElementalInstanceStackMap[]{map}; + outputEM = new EMInstanceStackMap[]{map}; return true; } return false; } protected GT_MetaTileEntity_EM_collider getPartner() { - IGregTechTileEntity iGregTechTileEntity = getBaseMetaTileEntity(); - int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX * 4; - int yDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetY * 4; - int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ * 4; + IGregTechTileEntity iGregTechTileEntity = getBaseMetaTileEntity(); + int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX * 4; + int yDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetY * 4; + int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ * 4; IGregTechTileEntity gregTechBaseTileEntity = iGregTechTileEntity.getIGregTechTileEntityOffset(xDir, yDir, zDir); if (gregTechBaseTileEntity != null) { IMetaTileEntity gregTechMetaTileEntity = gregTechBaseTileEntity.getMetaTileEntity(); @@ -449,16 +449,17 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB } } - private cElementalInstanceStackMap tickStack() { + private EMInstanceStackMap tickStack() { if (stack == null) { return null; } - cElementalDecayResult newInstances = stack.decay(1, stack.age += 1, 0); + stack.setAge(stack.getAge() + 1); + EMDecayResult newInstances = stack.decay(1, stack.getAge(), 0); if (newInstances == null) { stack.nextColor(); return null; } else { - stack = newInstances.getOutput().remove(newInstances.getOutput().getLast().definition); + stack = newInstances.getOutput().removeKey(newInstances.getOutput().getLast().getDefinition()); return newInstances.getOutput(); } } @@ -485,7 +486,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB eTier = 0; return false; } - if (structureCheck_EM("main", 11, 1, 18)) { + if (structureCheck_EM("tier"+eTier, 11, 1, 18)) { return true; } eTier = 0; @@ -502,12 +503,12 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB if (started) { if (stack == null) { for (GT_MetaTileEntity_Hatch_InputElemental inputElemental : eInputHatches) { - cElementalInstanceStackMap container = inputElemental.getContainerHandler(); + EMInstanceStackMap container = inputElemental.getContentHandler(); if (container.isEmpty()) { continue; } - stack = container.remove(container.getFirst().definition); - long eut = KEEPUP_COST + (long) (KEEPUP_COST * Math.abs(stack.getMass() / dAtomDefinition.getSomethingHeavy().getMass())) / 2; + stack = container.removeKey(container.getFirst().getDefinition()); + long eut = KEEPUP_COST + (long) (KEEPUP_COST * Math.abs(stack.getMass() / EMAtomDefinition.getSomethingHeavy().getMass())) / 2; if (eut < Integer.MIN_VALUE + 7) { return false; } @@ -552,12 +553,12 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB collide(partner);//todo break; default: { - outputEM = new cElementalInstanceStackMap[2]; + outputEM = new EMInstanceStackMap[2]; outputEM[1] = tickStack(); if (outputEM[1] == null) { outputEM[1] = partner.tickStack(); } else { - cElementalInstanceStackMap map = partner.tickStack(); + EMInstanceStackMap map = partner.tickStack(); if (map != null) { outputEM[1].putUnifyAll(map); } @@ -567,7 +568,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB if (outputEM != null) { for (int i = 0, lim = Math.min(outputEM.length, eOutputHatches.size()); i < lim; i++) { if (outputEM[i] != null) { - eOutputHatches.get(i).getContainerHandler().putUnifyAll(outputEM[i]); + eOutputHatches.get(i).getContentHandler().putUnifyAll(outputEM[i]); outputEM[i] = null; } } @@ -625,7 +626,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB aNBT.setByte("eTier", eTier);//collider tier aNBT.setBoolean("eStarted", started); if (stack != null) { - aNBT.setTag("eStack", stack.toNBT()); + aNBT.setTag("eStack", stack.toNBT(TecTech.definitionsRegistry)); } aNBT.setLong("ePlasmaEnergy", plasmaEnergy); } @@ -636,7 +637,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB eTier = aNBT.getByte("eTier");//collider tier started = aNBT.getBoolean("eStarted"); if (aNBT.hasKey("eStack")) { - stack = cElementalInstanceStack.fromNBT(aNBT.getCompoundTag("eStack")); + stack = EMInstanceStack.fromNBT(TecTech.definitionsRegistry, aNBT.getCompoundTag("eStack")); } plasmaEnergy = aNBT.getLong("ePlasmaEnergy"); } @@ -671,23 +672,23 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB } @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { + public void construct(ItemStack trigger, boolean hintsOnly) { IGregTechTileEntity iGregTechTileEntity = getBaseMetaTileEntity(); - int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX * 4; - int yDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetY * 4; - int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ * 4; + int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX * 4; + int yDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetY * 4; + int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ * 4; if (hintsOnly) { - TecTech.proxy.hint_particle(iGregTechTileEntity.getWorld(), + StructureLibAPI.hintParticle(iGregTechTileEntity.getWorld(), iGregTechTileEntity.getXCoord() + xDir, iGregTechTileEntity.getYCoord() + yDir, iGregTechTileEntity.getZCoord() + zDir, - TT_Container_Casings.sHintCasingsTT, 12); + StructureLibAPI.getBlockHint(), 12); } - structureBuild_EM("main", 11, 1, 18, hintsOnly, stackSize); + structureBuild_EM("tier"+(((trigger.stackSize-1)%2)+1), 11, 1, 18, trigger, hintsOnly); } @Override public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_collider/IColliderHandler.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_collider/IColliderHandler.java new file mode 100644 index 0000000000..0114ac847b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_collider/IColliderHandler.java @@ -0,0 +1,5 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.em_collider; + +public interface IColliderHandler extends IPrimitiveColliderHandler { + byte getRequiredTier(); +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_collider/IPrimitiveColliderHandler.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_collider/IPrimitiveColliderHandler.java new file mode 100644 index 0000000000..3c4438b5e1 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_collider/IPrimitiveColliderHandler.java @@ -0,0 +1,8 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.em_collider; + +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; + +public interface IPrimitiveColliderHandler { + void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out); +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java index 1ed1278bce..e6e618a31c 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java @@ -1,9 +1,9 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition; import com.github.technus.tectech.thing.metaTileEntity.multi.base.INameFunction; import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunction; import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; @@ -12,7 +12,7 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; import java.util.Arrays; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT_144; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED; import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; import static com.github.technus.tectech.util.CommonValues.V; import static com.github.technus.tectech.util.DoubleCount.*; @@ -74,21 +74,21 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehav radius = 0.5D - (12D - tier) / 64D; maxRCF = Math.pow(Math.E, tier) * 12D; maxRPM = Math.sqrt(maxRCF / (0.001118D * radius)); - double maxSafeMass = dAtomDefinition.getSomethingHeavy().getMass() * (1 << tier); + double maxSafeMass = EMAtomDefinition.getSomethingHeavy().getMass() * (1 << tier); maxForce = maxSafeMass * maxRCF;// (eV/c^2 * m/s) / g - maxCapacity = maxSafeMass * AVOGADRO_CONSTANT_144 * radius;// eV/c^2 + maxCapacity = maxSafeMass * EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED * radius;// eV/c^2 } private double getRCF(double RPM) { return RPM * RPM * radius * 0.001118; } - private void addRandomly(cElementalInstanceStack me, cElementalInstanceStackMap[] toThis, int fractionCount) { - double amountPerFraction = div(me.amount,fractionCount); - cElementalInstanceStack[] stacks = new cElementalInstanceStack[fractionCount]; + private void addRandomly(EMInstanceStack me, EMInstanceStackMap[] toThis, int fractionCount) { + double amountPerFraction = div(me.getAmount(),fractionCount); + EMInstanceStack[] stacks = new EMInstanceStack[fractionCount]; for (int i = 0; i < fractionCount; i++) { stacks[i] = me.clone(); - stacks[i].amount = amountPerFraction; + stacks[i].setAmount(amountPerFraction); toThis[i].putReplace(stacks[i]); } //int remainingAmount = (int) (me.amount % fractionCount); @@ -112,24 +112,24 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehav } @Override - public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { - cElementalInstanceStackMap input = inputs[0]; + public MultiblockControl<EMInstanceStackMap[]> process(EMInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { + EMInstanceStackMap input = inputs[0]; if (input == null || input.isEmpty()) return null;//nothing in only valid input - cElementalInstanceStack[] stacks = input.values(); + EMInstanceStack[] stacks = input.valuesToArray(); double inputMass = 0; - for (cElementalInstanceStack stack : stacks) { + for (EMInstanceStack stack : stacks) { inputMass += Math.abs(stack.getMass()); } double excessMass = 0; while (inputMass > maxCapacity) { - cElementalInstanceStack randomStack = stacks[TecTech.RANDOM.nextInt(stacks.length)]; - double amountToRemove = TecTech.RANDOM.nextDouble()/10D * randomStack.getAmount(); - randomStack.amount= sub(randomStack.amount,amountToRemove);//mutates the parent InstanceStackMap - if (randomStack.amount <= 0) { - input.remove(randomStack.definition); - stacks = input.values(); + EMInstanceStack randomStack = stacks[TecTech.RANDOM.nextInt(stacks.length)]; + double amountToRemove = TecTech.RANDOM.nextDouble()/10D * randomStack.getAmount(); + randomStack.setAmount(sub(randomStack.getAmount(),amountToRemove));//mutates the parent InstanceStackMap + if (randomStack.isInvalidAmount()) { + input.removeKey(randomStack.getDefinition()); + stacks = input.valuesToArray(); } double mass = Math.abs(randomStack.getDefinition().getMass()) * amountToRemove; excessMass += mass; @@ -142,10 +142,10 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehav if (inputMass * RCF > maxForce) return new MultiblockControl<>(excessMass);//AND THEN IT EXPLODES // how many output hatches to use - int fractionCount = (int) settingFraction.get(); - cElementalInstanceStackMap[] outputs = new cElementalInstanceStackMap[fractionCount]; + int fractionCount = (int) settingFraction.get(); + EMInstanceStackMap[] outputs = new EMInstanceStackMap[fractionCount]; for (int i = 0; i < fractionCount; i++) { - outputs[i] = new cElementalInstanceStackMap(); + outputs[i] = new EMInstanceStackMap(); } //mixing factor... @@ -162,24 +162,24 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehav //take all from hatch handler and put into new map - this takes from hatch to inner data storage - stacks = input.takeAllToNewMap().values();//cleanup stacks + stacks = input.takeAll().valuesToArray();//cleanup stacks if (stacks.length > 1) { Arrays.sort(stacks, (o1, o2) -> { - double m1 = o1.definition.getMass(); - double m2 = o2.definition.getMass(); + double m1 = o1.getDefinition().getMass(); + double m2 = o2.getDefinition().getMass(); if (m1 < m2) return -1; if (m1 > m2) return 1; return o1.compareTo(o2); }); double absMassPerOutput = 0;//"volume" - for (cElementalInstanceStack stack : stacks) { + for (EMInstanceStack stack : stacks) { double tempMass=Math.abs(stack.getMass()); if(tempMass!=0) { - double amount = stack.amount; - stack.amount = mul(stack.amount,mixingFactor); + double amount = stack.getAmount(); + stack.setAmount(mul(stack.getAmount(),mixingFactor)); addRandomly(stack, outputs, fractionCount); - stack.amount = sub(amount,stack.amount); + stack.setAmount(sub(amount, stack.getAmount())); absMassPerOutput += tempMass; } } @@ -197,7 +197,7 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehav for (int stackNo = 0; stackNo < stacks.length; stackNo++) { if (stacks[stackNo] != null) { double stackMass = Math.abs(stacks[stackNo].getMass()); - double amount = div(remaining,Math.abs(stacks[stackNo].definition.getMass())); + double amount = div(remaining,Math.abs(stacks[stackNo].getDefinition().getMass())); //if(DEBUG_MODE){ // TecTech.LOGGER.info("stackMass "+stackMass); // TecTech.LOGGER.info("defMass "+stacks[stackNo].definition.getMass()); @@ -207,16 +207,16 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehav if (stackMass == 0) { addRandomly(stacks[stackNo], outputs, fractionCount); stacks[stackNo] = null; - } else if (amount >= stacks[stackNo].amount) { + } else if (amount >= stacks[stackNo].getAmount()) { remaining= sub(remaining,stackMass); outputs[fraction].putUnify(stacks[stackNo]); stacks[stackNo] = null; } else if (amount > 0) { - remaining= sub(remaining, mul(amount,stacks[stackNo].definition.getMass())); - cElementalInstanceStack clone = stacks[stackNo].clone(); - clone.amount = amount; + remaining= sub(remaining, mul(amount, stacks[stackNo].getDefinition().getMass())); + EMInstanceStack clone = stacks[stackNo].clone(); + clone.setAmount(amount); outputs[fraction].putUnify(clone); - stacks[stackNo].amount= sub(stacks[stackNo].amount,amount); + stacks[stackNo].setAmount(sub(stacks[stackNo].getAmount(),amount)); //if(DEBUG_MODE){ // TecTech.LOGGER.info("remainingAfter "+remaining); // TecTech.LOGGER.info("amountCloneAfter "+clone.amount+"/"+stacks[stackNo].amount); @@ -228,7 +228,7 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehav } } //add remaining - for (cElementalInstanceStack stack : stacks) { + for (EMInstanceStack stack : stacks) { if (stack != null) { outputs[fractionCount - 1].putUnify(stack); } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Electrolyzer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Electrolyzer.java index df21feb9f2..4c95c2acd7 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Electrolyzer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Electrolyzer.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; @@ -24,7 +24,7 @@ public class Behaviour_Electrolyzer implements GT_MetaTileEntity_EM_machine.IBeh } @Override - public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { + public MultiblockControl<EMInstanceStackMap[]> process(EMInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { return null; } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java index 40e2942bab..3d1259f808 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java @@ -1,17 +1,17 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dAtomDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition; import com.github.technus.tectech.thing.metaTileEntity.multi.base.INameFunction; import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunction; import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT_144; -import static com.github.technus.tectech.util.CommonValues.V; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED; import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; +import static com.github.technus.tectech.util.CommonValues.V; import static com.github.technus.tectech.util.DoubleCount.mul; import static com.github.technus.tectech.util.DoubleCount.sub; @@ -88,7 +88,7 @@ public class Behaviour_ElectromagneticSeparator implements GT_MetaTileEntity_EM_ public Behaviour_ElectromagneticSeparator(int desiredTier){ tier=(byte) desiredTier; ticks =Math.max(20,(1<<(12-desiredTier))*20); - maxCapacity= dAtomDefinition.getSomethingHeavy().getMass()*(2<<tier)* AVOGADRO_CONSTANT_144; + maxCapacity= EMAtomDefinition.getSomethingHeavy().getMass()*(2<<tier)* EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED; maxCharge=144D*(1<<(tier-5)); switch (tier){ case 12: @@ -143,23 +143,23 @@ public class Behaviour_ElectromagneticSeparator implements GT_MetaTileEntity_EM_ } @Override - public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { - cElementalInstanceStackMap input = inputs[0]; + public MultiblockControl<EMInstanceStackMap[]> process(EMInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { + EMInstanceStackMap input = inputs[0]; if (input == null || input.isEmpty()) return null;//nothing in only valid input - cElementalInstanceStack[] stacks = input.values(); + EMInstanceStack[] stacks = input.valuesToArray(); double inputMass = 0; - for (cElementalInstanceStack stack : stacks) { + for (EMInstanceStack stack : stacks) { inputMass += Math.abs(stack.getMass()); } float excessMass = 0; while (inputMass > maxCapacity) { - cElementalInstanceStack randomStack = stacks[TecTech.RANDOM.nextInt(stacks.length)]; - double amountToRemove = TecTech.RANDOM.nextDouble()/10D * randomStack.getAmount(); - randomStack.amount= sub(randomStack.amount,amountToRemove);//mutates the parent InstanceStackMap - if (randomStack.amount <= 0) { - input.remove(randomStack.definition); + EMInstanceStack randomStack = stacks[TecTech.RANDOM.nextInt(stacks.length)]; + double amountToRemove = TecTech.RANDOM.nextDouble()/10D * randomStack.getAmount(); + randomStack.setAmount(sub(randomStack.getAmount(),amountToRemove));//mutates the parent InstanceStackMap + if (randomStack.isInvalidAmount()) { + input.removeKey(randomStack.getDefinition()); } double mass = Math.abs(randomStack.getDefinition().getMass()) * amountToRemove; excessMass += mass; @@ -174,9 +174,9 @@ public class Behaviour_ElectromagneticSeparator implements GT_MetaTileEntity_EM_ int mTicks=(int)(ticks*(inputMass/maxCapacity)); mTicks=Math.max(mTicks,20); - cElementalInstanceStackMap[] outputs = new cElementalInstanceStackMap[3]; + EMInstanceStackMap[] outputs = new EMInstanceStackMap[3]; for (int i = 0; i < 3; i++) { - outputs[i] = new cElementalInstanceStackMap(); + outputs[i] = new EMInstanceStackMap(); } double offsetIn=offsetSetting.get(); @@ -185,9 +185,9 @@ public class Behaviour_ElectromagneticSeparator implements GT_MetaTileEntity_EM_ double levelsCountPlus1=precisionFullIn-precisionMinimalIn+1; //take all from hatch handler and put into new map - this takes from hatch to inner data storage - stacks = input.takeAllToNewMap().values();//cleanup stacks - for(cElementalInstanceStack stack:stacks){ - double charge=stack.definition.getCharge()-offsetIn; + stacks = input.takeAll().valuesToArray();//cleanup stacks + for(EMInstanceStack stack:stacks){ + double charge= stack.getDefinition().getCharge()-offsetIn; if(charge<precisionMinimalIn && charge>-precisionMinimalIn){ outputs[1].putReplace(stack); }else if(charge>=precisionFullIn){ @@ -195,13 +195,13 @@ public class Behaviour_ElectromagneticSeparator implements GT_MetaTileEntity_EM_ }else if(charge<=-precisionFullIn){ outputs[0].putReplace(stack); }else{ - double amount=mul(stack.amount,(Math.abs(charge)-precisionMinimalIn+1D)/levelsCountPlus1);//todo check - if (amount < stack.amount) { - cElementalInstanceStack clone = stack.clone(); - clone.amount = sub(clone.amount, amount); + double amount=mul(stack.getAmount(),(Math.abs(charge)-precisionMinimalIn+1D)/levelsCountPlus1);//todo check + if (amount < stack.getAmount()) { + EMInstanceStack clone = stack.clone(); + clone.setAmount(sub(clone.getAmount(), amount)); outputs[1].putReplace(clone); - stack.amount = amount; + stack.setAmount(amount); } if(charge>0){ outputs[2].putReplace(stack); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_PrecisionLaser.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_PrecisionLaser.java index cd6f637d61..7d472de847 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_PrecisionLaser.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_PrecisionLaser.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; @@ -24,7 +24,7 @@ public class Behaviour_PrecisionLaser implements GT_MetaTileEntity_EM_machine.IB } @Override - public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { + public MultiblockControl<EMInstanceStackMap[]> process(EMInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { return null; } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java index c86c06b2a0..05050a3c66 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; @@ -26,9 +26,9 @@ public class Behaviour_Recycler implements GT_MetaTileEntity_EM_machine.IBehavio } @Override - public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { + public MultiblockControl<EMInstanceStackMap[]> process(EMInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { double mass=0; - for (cElementalInstanceStackMap input : inputs) { + for (EMInstanceStackMap input : inputs) { if (input != null) { mass += input.getMass(); } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Scanner.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Scanner.java index 95bb8dce40..fa517c73d4 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Scanner.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Scanner.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; @@ -24,7 +24,7 @@ public class Behaviour_Scanner implements GT_MetaTileEntity_EM_machine.IBehaviou } @Override - public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { + public MultiblockControl<EMInstanceStackMap[]> process(EMInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { return null; } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java index a43bf2b128..1f791963e0 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java @@ -1,15 +1,14 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.constructable.IConstructable; -import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.block.QuantumStuffBlock; import com.github.technus.tectech.thing.metaTileEntity.multi.base.*; import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.TT_Utility; +import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; @@ -27,6 +26,7 @@ import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texture import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; import static net.minecraft.util.StatCollector.translateToLocal; @@ -37,7 +37,7 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa //region variables public static final String machine = "EM Machinery"; - private ItemStack loadedMachine; + private ItemStack loadedMachine; private IBehaviour currentBehaviour; //endregion @@ -48,27 +48,27 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa translateToLocal("gt.blockmachines.multimachine.em.processing.hint.1"),//2 - Elemental Hatches or Molecular Casing }; - private static final IStructureDefinition<GT_MetaTileEntity_EM_machine> STRUCTURE_DEFINITION = - StructureDefinition.<GT_MetaTileEntity_EM_machine>builder() - .addShape("main", new String[][]{ - {" A "," AAA "," EBE "," ECE "," EBE "," AAA "," A "}, - {" DDD ","AAAAA","E---E","E---E","E---E","AAAAA"," FFF "}, - {"AD-DA","AA~AA","B---B","C---C","B---B","AA-AA","AFFFA"}, - {" DDD ","AAAAA","E---E","E---E","E---E","AAAAA"," FFF "}, - {" A "," AAA "," EBE "," ECE "," EBE "," AAA "," A "} - }) + private static final IStructureDefinition<GT_MetaTileEntity_EM_machine> STRUCTURE_DEFINITION = IStructureDefinition + .<GT_MetaTileEntity_EM_machine>builder() + .addShape("main", transpose(new String[][]{ + {" A ", " AAA ", " EBE ", " ECE ", " EBE ", " AAA ", " A "}, + {" DDD ", "AAAAA", "E---E", "E---E", "E---E", "AAAAA", " FFF "}, + {"AD-DA", "AA~AA", "B---B", "C- -C", "B---B", "AA-AA", "AFFFA"}, + {" DDD ", "AAAAA", "E---E", "E---E", "E---E", "AAAAA", " FFF "}, + {" A ", " AAA ", " EBE ", " ECE ", " EBE ", " AAA ", " A "} + })) .addElement('A', ofBlock(sBlockCasingsTT, 4)) .addElement('B', ofBlock(sBlockCasingsTT, 5)) .addElement('C', ofBlock(sBlockCasingsTT, 6)) - .addElement('D', ofHatchAdderOptional(GT_MetaTileEntity_EM_machine::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) .addElement('E', ofBlock(QuantumGlassBlock.INSTANCE, 0)) + .addElement('D', ofHatchAdderOptional(GT_MetaTileEntity_EM_machine::addClassicToMachineList, textureOffset, 1, sBlockCasingsTT, 0)) .addElement('F', ofHatchAdderOptional(GT_MetaTileEntity_EM_machine::addElementalToMachineList, textureOffset + 4, 2, sBlockCasingsTT, 4)) .build(); //endregion //region parameters - protected Parameters.Group.ParameterIn[] inputMux; - protected Parameters.Group.ParameterIn[] outputMux; + protected Parameters.Group.ParameterIn[] inputMux; + protected Parameters.Group.ParameterIn[] outputMux; private static final IStatusFunction<GT_MetaTileEntity_EM_machine> SRC_STATUS = (base, p) -> { double v = p.get(); @@ -92,7 +92,7 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa } return STATUS_NEUTRAL; }; - private static final INameFunction<GT_MetaTileEntity_EM_machine> ROUTE_NAME = + private static final INameFunction<GT_MetaTileEntity_EM_machine> ROUTE_NAME = (base, p) -> (p.parameterId() == 0 ? translateToLocal("tt.keyword.Source") + " " : translateToLocal("tt.keyword.Destination") + " ") + p.hatchId(); //endregion @@ -110,7 +110,7 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa return false; } loadedMachine = newMachine; - Supplier<IBehaviour> behaviourSupplier = GT_MetaTileEntity_EM_machine.BEHAVIOUR_MAP.get(new Util.ItemStack_NoNBT(newMachine)); + Supplier<IBehaviour> behaviourSupplier = GT_MetaTileEntity_EM_machine.BEHAVIOUR_MAP.get(new TT_Utility.ItemStack_NoNBT(newMachine)); if (currentBehaviour == null && behaviourSupplier == null) { return false; } @@ -132,11 +132,11 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa return true; } - private static final HashMap<Util.ItemStack_NoNBT, Supplier<IBehaviour>> BEHAVIOUR_MAP = new HashMap<>(); + private static final HashMap<TT_Utility.ItemStack_NoNBT, Supplier<IBehaviour>> BEHAVIOUR_MAP = new HashMap<>(); public static void registerBehaviour(Supplier<IBehaviour> behaviour, ItemStack is) { - BEHAVIOUR_MAP.put(new Util.ItemStack_NoNBT(is), behaviour); - TecTech.LOGGER.info("Registered EM machine behaviour " + behaviour.get().getClass().getSimpleName() + ' ' + new Util.ItemStack_NoNBT(is).toString()); + BEHAVIOUR_MAP.put(new TT_Utility.ItemStack_NoNBT(is), behaviour); + TecTech.LOGGER.info("Registered EM machine behaviour " + behaviour.get().getClass().getSimpleName() + ' ' + new TT_Utility.ItemStack_NoNBT(is).toString()); } public interface IBehaviour { @@ -164,15 +164,15 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa * @param parameters array passed from previous method! * @return null if recipe should not start, control object to set machine state and start recipe */ - MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters); + MultiblockControl<EMInstanceStackMap[]> process(EMInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters); } private void quantumStuff(boolean shouldIExist) { IGregTechTileEntity base = getBaseMetaTileEntity(); if (base != null && base.getWorld() != null) { - int xDir = ForgeDirection.getOrientation(base.getBackFacing()).offsetX * 2 + base.getXCoord(); - int yDir = ForgeDirection.getOrientation(base.getBackFacing()).offsetY * 2 + base.getYCoord(); - int zDir = ForgeDirection.getOrientation(base.getBackFacing()).offsetZ * 2 + base.getZCoord(); + int xDir = ForgeDirection.getOrientation(base.getBackFacing()).offsetX * 2 + base.getXCoord(); + int yDir = ForgeDirection.getOrientation(base.getBackFacing()).offsetY * 2 + base.getYCoord(); + int zDir = ForgeDirection.getOrientation(base.getBackFacing()).offsetZ * 2 + base.getZCoord(); Block block = base.getWorld().getBlock(xDir, yDir, zDir); if (shouldIExist) { if (block != null && block.getMaterial() == Material.air) { @@ -257,11 +257,11 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa return false; } - cElementalInstanceStackMap[] handles = new cElementalInstanceStackMap[6]; + EMInstanceStackMap[] handles = new EMInstanceStackMap[6]; for (int i = 0; i < 6; i++) { int pointer = (int) inputMux[i].get(); if (pointer >= 0 && pointer < eInputHatches.size()) { - handles[i] = eInputHatches.get(pointer).getContainerHandler(); + handles[i] = eInputHatches.get(pointer).getContentHandler(); } } @@ -275,7 +275,7 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa } } - MultiblockControl<cElementalInstanceStackMap[]> control = currentBehaviour.process(handles, this, parametrization); + MultiblockControl<EMInstanceStackMap[]> control = currentBehaviour.process(handles, this, parametrization); if (control == null) { return false; } @@ -314,11 +314,11 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa return; } - cElementalInstanceStackMap[] handles = new cElementalInstanceStackMap[6]; + EMInstanceStackMap[] handles = new EMInstanceStackMap[6]; for (int i = 0; i < 6; i++) { int pointer = (int) outputMux[i].get(); if (pointer >= 0 && pointer < eOutputHatches.size()) { - handles[i] = eOutputHatches.get(pointer).getContainerHandler(); + handles[i] = eOutputHatches.get(pointer).getContentHandler(); } } //output @@ -357,7 +357,7 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - structureBuild_EM("main", 2, 2, 1, hintsOnly, stackSize); + structureBuild_EM("main", 2, 2, 1, stackSize, hintsOnly); } @Override @@ -369,4 +369,4 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/other todo b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/other todo index 7059fdf6fd..a195157a17 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/other todo +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/other todo @@ -23,16 +23,16 @@ BlockFakeLight.java for turrets: floodlightb +mega - projects + fix eu/t checks if needs maintenance!!! make microwave grinder cap autosmelting based on power - iterative halflife formula: =prev qty* 2^(-t diff / t half) - actual ion cannons diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java index ee6f469d59..1cc3123528 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java @@ -1,11 +1,11 @@ package com.github.technus.tectech.thing.metaTileEntity.pipe; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.loader.NetworkDispatcher; import com.github.technus.tectech.mechanics.pipe.IActivePipe; import com.github.technus.tectech.mechanics.pipe.IConnectsToDataPipe; import com.github.technus.tectech.mechanics.pipe.PipeActivityMessage; import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.loader.NetworkDispatcher; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.GT_Mod; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java index 55a7f23b6a..d19fec6f05 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java @@ -1,11 +1,11 @@ package com.github.technus.tectech.thing.metaTileEntity.pipe; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.loader.NetworkDispatcher; import com.github.technus.tectech.mechanics.pipe.IActivePipe; import com.github.technus.tectech.mechanics.pipe.IConnectsToElementalPipe; import com.github.technus.tectech.mechanics.pipe.PipeActivityMessage; import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.loader.NetworkDispatcher; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.GT_Mod; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Energy.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Energy.java index ef767dacdd..1f4fd71a39 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Energy.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Energy.java @@ -1,11 +1,11 @@ package com.github.technus.tectech.thing.metaTileEntity.pipe; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.loader.NetworkDispatcher; import com.github.technus.tectech.mechanics.pipe.IActivePipe; import com.github.technus.tectech.mechanics.pipe.IConnectsToEnergyTunnel; import com.github.technus.tectech.mechanics.pipe.PipeActivityMessage; import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.loader.NetworkDispatcher; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.GT_Mod; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_BuckConverter.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_BuckConverter.java index 737046729f..20b690a3e8 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_BuckConverter.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_BuckConverter.java @@ -1,9 +1,9 @@ package com.github.technus.tectech.thing.metaTileEntity.single; -import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_Container_BuckConverter; import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_GUIContainer_BuckConverter; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -29,12 +29,12 @@ public class GT_MetaTileEntity_BuckConverter extends GT_MetaTileEntity_TieredMac public GT_MetaTileEntity_BuckConverter(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 0, ""); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } public GT_MetaTileEntity_BuckConverter(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 0, aDescription, aTextures); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DataReader.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DataReader.java index 748b680faa..9b177dd1ce 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DataReader.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DataReader.java @@ -1,9 +1,9 @@ package com.github.technus.tectech.thing.metaTileEntity.single; -import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_Container_DataReader; import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_GUIContainer_DataReader; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -38,17 +38,17 @@ import static net.minecraft.util.StatCollector.translateToLocal; * Created by Tec on 23.03.2017. */ public class GT_MetaTileEntity_DataReader extends GT_MetaTileEntity_BasicMachine { - private static final HashMap<Util.ItemStack_NoNBT,ArrayList<IDataRender>> RENDER_REGISTRY =new HashMap<>(); - public static GT_RenderedTexture READER_ONLINE, READER_OFFLINE; + private static final HashMap<TT_Utility.ItemStack_NoNBT,ArrayList<IDataRender>> RENDER_REGISTRY =new HashMap<>(); + public static GT_RenderedTexture READER_ONLINE, READER_OFFLINE; public GT_MetaTileEntity_DataReader(int aID, String aName, String aNameRegional, int aTier) { super(aID,aName,aNameRegional,aTier,1,"",1,1,"dataReader.png",""); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } public GT_MetaTileEntity_DataReader(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName,aTier,1,aDescription,aTextures,1,1,"dataReader.png",""); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } @Override @@ -91,7 +91,7 @@ public class GT_MetaTileEntity_DataReader extends GT_MetaTileEntity_BasicMachine return DID_NOT_FIND_RECIPE; } ItemStack input=getInputAt(0); - for(IDataRender render:getRenders(new Util.ItemStack_NoNBT(input))){ + for(IDataRender render:getRenders(new TT_Utility.ItemStack_NoNBT(input))){ if(render.canRender(input,mTier)){ mOutputItems[0]=input.copy(); input.stackSize-=1; @@ -175,7 +175,7 @@ public class GT_MetaTileEntity_DataReader extends GT_MetaTileEntity_BasicMachine return maxEUInput()*4L; } - public static void addDataRender(Util.ItemStack_NoNBT stack, IDataRender render){ + public static void addDataRender(TT_Utility.ItemStack_NoNBT stack, IDataRender render){ ArrayList<IDataRender> renders = RENDER_REGISTRY.computeIfAbsent(stack, k -> new ArrayList<>()); if(FMLCommonHandler.instance().getEffectiveSide().isClient()) { render.loadResources(); @@ -183,7 +183,7 @@ public class GT_MetaTileEntity_DataReader extends GT_MetaTileEntity_BasicMachine renders.add(render); } - public static List<IDataRender> getRenders(Util.ItemStack_NoNBT stack){ + public static List<IDataRender> getRenders(TT_Utility.ItemStack_NoNBT stack){ ArrayList<IDataRender> iDataRenders = RENDER_REGISTRY.get(stack); return iDataRenders==null?Collections.emptyList():iDataRenders; } @@ -205,7 +205,7 @@ public class GT_MetaTileEntity_DataReader extends GT_MetaTileEntity_BasicMachine } public static void run(){ - addDataRender(new Util.ItemStack_NoNBT(ItemList.Tool_DataStick.get(1)),new IDataRender() { + addDataRender(new TT_Utility.ItemStack_NoNBT(ItemList.Tool_DataStick.get(1)),new IDataRender() { @SideOnly(Side.CLIENT) private ResourceLocation bg; @SideOnly(Side.CLIENT) @@ -271,8 +271,8 @@ public class GT_MetaTileEntity_DataReader extends GT_MetaTileEntity_BasicMachine public void renderForeground(ItemStack itemStack, int mouseX, int mouseY, GT_GUIContainer_DataReader gui, FontRenderer font) { int time=itemStack.stackTagCompound.getInteger("time"); int EUt=itemStack.stackTagCompound.getInteger("eu"); - font.drawString("Assembly Line Recipe", 7, 8, 0x80a0ff); - font.drawString(GT_Utility.trans("152","Total: ") + GT_Utility.formatNumbers((long)time * EUt) + " EU",7,93, 0x80a0ff); + font.drawString(translateToLocal("tt.keyphrase.Ass_line_recipe"), 7, 8, 0x80a0ff); + font.drawString(GT_Utility.trans("152","Total: ") + GT_Utility.formatNumbers((long) time * EUt) + " EU",7,93, 0x80a0ff); font.drawString(GT_Utility.trans("153","Usage: ") + GT_Utility.formatNumbers(EUt) + " EU/t",7,103, 0x80a0ff); font.drawString(GT_Utility.trans("154","Voltage: ") + GT_Utility.formatNumbers(EUt) + " EU",7,113, 0x80a0ff); font.drawString(GT_Utility.trans("155","Amperage: ") + 1 ,7,123, 0x80a0ff); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPollutor.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPollutor.java index 0d5a59a5c1..c68b9fc395 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPollutor.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPollutor.java @@ -1,11 +1,11 @@ package com.github.technus.tectech.thing.metaTileEntity.single; -import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OverflowElemental; import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_Container_DebugPollutor; import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_GUIContainer_DebugPollutor; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -35,12 +35,12 @@ public class GT_MetaTileEntity_DebugPollutor extends GT_MetaTileEntity_TieredMac public GT_MetaTileEntity_DebugPollutor(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 0, ""); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } public GT_MetaTileEntity_DebugPollutor(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 0, aDescription, aTextures); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPowerGenerator.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPowerGenerator.java index 931da27e6c..1be2173bfc 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPowerGenerator.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPowerGenerator.java @@ -1,9 +1,9 @@ package com.github.technus.tectech.thing.metaTileEntity.single; -import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_Container_DebugPowerGenerator; import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_GUIContainer_DebugPowerGenerator; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -32,12 +32,12 @@ public class GT_MetaTileEntity_DebugPowerGenerator extends GT_MetaTileEntity_Tie public GT_MetaTileEntity_DebugPowerGenerator(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 0, ""); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } public GT_MetaTileEntity_DebugPowerGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 0, aDescription, aTextures); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java index 01d5e2321e..46b3d5e927 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java @@ -4,7 +4,7 @@ import com.github.technus.tectech.TecTech; import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_Container_DebugStructureWriter; import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_GUIContainer_DebugStructureWriter; import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.TT_Utility; import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; import com.gtnewhorizon.structurelib.structure.StructureUtility; import cpw.mods.fml.relauncher.Side; @@ -20,13 +20,9 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; -import java.util.Comparator; -import java.util.function.Function; - import static com.github.technus.tectech.thing.metaTileEntity.Textures.MACHINE_CASINGS_TT; import static net.minecraft.util.StatCollector.translateToLocal; @@ -41,12 +37,12 @@ public class GT_MetaTileEntity_DebugStructureWriter extends GT_MetaTileEntity_Ti public GT_MetaTileEntity_DebugStructureWriter(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 0, ""); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } public GT_MetaTileEntity_DebugStructureWriter(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 0, aDescription, aTextures); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_MicroController.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_MicroController.java index 9bac9df2f3..4c4e035d44 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_MicroController.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_MicroController.java @@ -10,8 +10,8 @@ import com.github.technus.avrClone.memory.EepromMemory; import com.github.technus.avrClone.memory.RemovableMemory; import com.github.technus.avrClone.memory.program.ProgramMemory; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.mechanics.avr.SidedRedstone; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -41,12 +41,12 @@ public class GT_MetaTileEntity_MicroController extends GT_MetaTileEntity_TieredM public GT_MetaTileEntity_MicroController(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 0, "AVR Micro-controller"); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } public GT_MetaTileEntity_MicroController(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 0, aDescription, aTextures); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); core=new AvrCore(); core.setUsingImmersiveOperands(false); core.setInstructionRegistry(InstructionRegistry.INSTRUCTION_REGISTRY_OP); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_OwnerDetector.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_OwnerDetector.java index 03ec9efd89..57009c2e35 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_OwnerDetector.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_OwnerDetector.java @@ -1,8 +1,8 @@ package com.github.technus.tectech.thing.metaTileEntity.single; -import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -21,8 +21,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import org.apache.commons.lang3.reflect.FieldUtils; -import static com.github.technus.tectech.util.CommonValues.RECIPE_AT; import static com.github.technus.tectech.thing.metaTileEntity.Textures.MACHINE_CASINGS_TT; +import static com.github.technus.tectech.util.CommonValues.RECIPE_AT; import static net.minecraft.util.StatCollector.translateToLocal; import static net.minecraft.util.StatCollector.translateToLocalFormatted; @@ -36,12 +36,12 @@ public class GT_MetaTileEntity_OwnerDetector extends GT_MetaTileEntity_TieredMac public GT_MetaTileEntity_OwnerDetector(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 0, ""); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } public GT_MetaTileEntity_OwnerDetector(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 0, aDescription, aTextures); - Util.setTier(aTier,this); + TT_Utility.setTier(aTier,this); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TT_Transformer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TT_Transformer.java index 61f2259c5c..c5391537a6 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TT_Transformer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TT_Transformer.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.single; import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -13,12 +13,12 @@ import static net.minecraft.util.StatCollector.translateToLocal; public class GT_MetaTileEntity_TT_Transformer extends GT_MetaTileEntity_Transformer { public GT_MetaTileEntity_TT_Transformer(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, ""); - Util.setTier(aTier, this); + TT_Utility.setTier(aTier, this); } public GT_MetaTileEntity_TT_Transformer(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); - Util.setTier(aTier, this); + TT_Utility.setTier(aTier, this); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java index 3b240e4c56..8ca4844043 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java @@ -1,14 +1,13 @@ package com.github.technus.tectech.thing.metaTileEntity.single;
-import com.github.technus.tectech.mechanics.tesla.ITeslaConnectable;
-import com.github.technus.tectech.mechanics.tesla.ITeslaConnectableSimple;
-import com.github.technus.tectech.util.CommonValues;
import com.github.technus.tectech.TecTech;
import com.github.technus.tectech.loader.NetworkDispatcher;
import com.github.technus.tectech.mechanics.spark.RendererMessage;
import com.github.technus.tectech.mechanics.spark.ThaumSpark;
-import com.github.technus.tectech.util.Util;
-import com.google.common.collect.ArrayListMultimap;
+import com.github.technus.tectech.mechanics.tesla.ITeslaConnectable;
+import com.github.technus.tectech.mechanics.tesla.ITeslaConnectableSimple;
+import com.github.technus.tectech.util.CommonValues;
+import com.github.technus.tectech.util.TT_Utility;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.gtnewhorizon.structurelib.util.Vec3Impl;
@@ -28,8 +27,8 @@ import java.util.Arrays; import java.util.HashSet;
import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.*;
-import static com.github.technus.tectech.util.CommonValues.V;
import static com.github.technus.tectech.thing.metaTileEntity.Textures.*;
+import static com.github.technus.tectech.util.CommonValues.V;
import static java.lang.Math.round;
import static net.minecraft.util.StatCollector.translateToLocal;
import static net.minecraft.util.StatCollector.translateToLocalFormatted;
@@ -62,7 +61,7 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB public GT_MetaTileEntity_TeslaCoil(int aID, String aName, String aNameRegional, int aTier, int aSlotCount) {
super(aID, aName, aNameRegional, aTier, "", aSlotCount);
- Util.setTier(aTier, this);
+ TT_Utility.setTier(aTier, this);
}
public GT_MetaTileEntity_TeslaCoil(String aName, int aTier, String aDescription, ITexture[][][] aTextures, int aSlotCount) {
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugPollutor.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugPollutor.java index b40a9126b7..e74c51ab90 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugPollutor.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugPollutor.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.single.gui; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_DebugPollutor; +import com.github.technus.tectech.util.TT_Utility; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.gui.GT_ContainerMetaTile_Machine; @@ -129,8 +129,8 @@ public class GT_Container_DebugPollutor for (Object crafter : crafters) { ICrafting var1 = (ICrafting) crafter; - Util.sendInteger(pollution,this,var1,100); - Util.sendFloat(anomaly,this,var1,102); + TT_Utility.sendInteger(pollution,this,var1,100); + TT_Utility.sendFloat(anomaly,this,var1,102); } } @@ -141,11 +141,11 @@ public class GT_Container_DebugPollutor switch (par1) { case 100: case 101: - pollution = Util.receiveInteger(pollution,100,par1,par2); + pollution = TT_Utility.receiveInteger(pollution,100,par1,par2); break; case 102: case 103: - anomaly = Float.intBitsToFloat(anomalyInt=Util.receiveInteger(anomalyInt,102,par1,par2)); + anomaly = Float.intBitsToFloat(anomalyInt= TT_Utility.receiveInteger(anomalyInt,102,par1,par2)); break; } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_BuckConverter.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_BuckConverter.java index 6b6b778d40..1cff7e6c30 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_BuckConverter.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_BuckConverter.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.single.gui; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; @@ -19,7 +19,7 @@ public class GT_GUIContainer_BuckConverter extends GT_GUIContainerMetaTile_Machi if (mContainer != null) { GT_Container_BuckConverter buck = (GT_Container_BuckConverter) mContainer; fontRendererObj.drawString("EUT: " + buck.EUT, 46, 24, 16448255); - fontRendererObj.drawString("TIER: " + VN[Util.getTier(buck.EUT<0?-buck.EUT:buck.EUT)], 46, 32, 16448255); + fontRendererObj.drawString("TIER: " + VN[TT_Utility.getTier(buck.EUT<0?-buck.EUT:buck.EUT)], 46, 32, 16448255); fontRendererObj.drawString("AMP: " + buck.AMP, 46, 40, 16448255); fontRendererObj.drawString("SUM: " + (long)buck.AMP*buck.EUT, 46, 48, 16448255); } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DataReader.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DataReader.java index bde5b90048..738587941e 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DataReader.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DataReader.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.single.gui; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_DataReader; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.gui.GT_Slot_Holo; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -15,7 +15,6 @@ import net.minecraft.util.IIcon; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import java.util.ArrayList; import java.util.List; public class GT_GUIContainer_DataReader extends GT_GUIContainerMetaTile_Machine { @@ -116,7 +115,7 @@ public class GT_GUIContainer_DataReader extends GT_GUIContainerMetaTile_Machine private void renderDataBG(ItemStack thing, int mouseX, int mouseY, int x, int y, byte mTier) { if (thing != null) { for (GT_MetaTileEntity_DataReader.IDataRender render : - GT_MetaTileEntity_DataReader.getRenders(new Util.ItemStack_NoNBT(thing))) { + GT_MetaTileEntity_DataReader.getRenders(new TT_Utility.ItemStack_NoNBT(thing))) { if (render.canRender(thing, mTier)) { if (!GT_Utility.areStacksEqual(stack, thing, false)) { render.initRender(thing); @@ -134,7 +133,7 @@ public class GT_GUIContainer_DataReader extends GT_GUIContainerMetaTile_Machine return false; } for (GT_MetaTileEntity_DataReader.IDataRender render : - GT_MetaTileEntity_DataReader.getRenders(new Util.ItemStack_NoNBT(stack))) { + GT_MetaTileEntity_DataReader.getRenders(new TT_Utility.ItemStack_NoNBT(stack))) { if (render.canRender(stack, mTier)) { render.renderForeground(stack, mouseX, mouseY, this, fontRendererObj); return true; @@ -148,7 +147,7 @@ public class GT_GUIContainer_DataReader extends GT_GUIContainerMetaTile_Machine return false; } for (GT_MetaTileEntity_DataReader.IDataRender render : - GT_MetaTileEntity_DataReader.getRenders(new Util.ItemStack_NoNBT(stack))) { + GT_MetaTileEntity_DataReader.getRenders(new TT_Utility.ItemStack_NoNBT(stack))) { if (render.canRender(stack, mTier)) { render.renderTooltips(stack, mouseX, mouseY, this); return true; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugPowerGenerator.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugPowerGenerator.java index ee6e952040..f1f5050d9d 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugPowerGenerator.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugPowerGenerator.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.single.gui; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; @@ -19,7 +19,7 @@ public class GT_GUIContainer_DebugPowerGenerator extends GT_GUIContainerMetaTile if (mContainer != null) { GT_Container_DebugPowerGenerator dpg = (GT_Container_DebugPowerGenerator) mContainer; fontRendererObj.drawString("EUT: " + dpg.EUT, 46, 24, 16448255); - fontRendererObj.drawString("TIER: " + VN[Util.getTier(dpg.EUT<0?-dpg.EUT:dpg.EUT)], 46, 32, 16448255); + fontRendererObj.drawString("TIER: " + VN[TT_Utility.getTier(dpg.EUT<0?-dpg.EUT:dpg.EUT)], 46, 32, 16448255); fontRendererObj.drawString("AMP: " + dpg.AMP, 46, 40, 16448255); fontRendererObj.drawString("SUM: " + (long)dpg.AMP*dpg.EUT, 46, 48, 16448255); } diff --git a/src/main/java/com/github/technus/tectech/thing/tileEntity/ReactorSimTileEntity.java b/src/main/java/com/github/technus/tectech/thing/tileEntity/ReactorSimTileEntity.java index 4d66b28ca6..55fa327364 100644 --- a/src/main/java/com/github/technus/tectech/thing/tileEntity/ReactorSimTileEntity.java +++ b/src/main/java/com/github/technus/tectech/thing/tileEntity/ReactorSimTileEntity.java @@ -89,7 +89,7 @@ public class ReactorSimTileEntity extends TileEntityNuclearReactorElectric { @Override public double getReactorEUEnergyOutput() { - return (double)(getReactorEnergyOutput() * 5.0F * ConfigUtil.getFloat(MainConfig.get(), "balance/energy/generator/nuclear")); + return getReactorEnergyOutput() * 5.0F * ConfigUtil.getDouble(MainConfig.get(), "balance/energy/generator/nuclear"); } //public List<TileEntity> getSubTiles() { diff --git a/src/main/java/com/github/technus/tectech/util/CommonValues.java b/src/main/java/com/github/technus/tectech/util/CommonValues.java index f5d5ce6900..603644bcde 100644 --- a/src/main/java/com/github/technus/tectech/util/CommonValues.java +++ b/src/main/java/com/github/technus/tectech/util/CommonValues.java @@ -6,38 +6,33 @@ import net.minecraft.util.EnumChatFormatting; * Created by danie_000 on 11.01.2017. */ public final class CommonValues { - public static final String TEC_MARK_GENERAL = - EnumChatFormatting.BLUE + "Tec" + - EnumChatFormatting.DARK_BLUE + "Tech" + - EnumChatFormatting.BLUE + ": Interdimensional"; - public static final String TEC_MARK_EM = - EnumChatFormatting.BLUE + "Tec" + - EnumChatFormatting.DARK_BLUE + "Tech" + - EnumChatFormatting.BLUE + ": Elemental Matter"; - public static final String BASS_MARK = - EnumChatFormatting.BLUE + "Tec" + - EnumChatFormatting.DARK_BLUE + "Tech" + - EnumChatFormatting.BLUE + ": Theta Movement"; - public static final String COSMIC_MARK = - EnumChatFormatting.BLUE + "Tec" + - EnumChatFormatting.DARK_BLUE + "Tech" + - EnumChatFormatting.BLUE + ": Cosmic";//TODO get a better name than cosmic for *UNDEFINED* thing + public static final String TEC_MARK_SHORT = + EnumChatFormatting.BLUE + "Tec" + EnumChatFormatting.DARK_BLUE + "Tech"; + public static final String TEC_MARK_GENERAL = TEC_MARK_SHORT + + EnumChatFormatting.BLUE + ": Interdimensional"; + public static final String TEC_MARK_EM = TEC_MARK_SHORT + + EnumChatFormatting.BLUE + ": Elemental Matter"; + public static final String BASS_MARK = TEC_MARK_SHORT + + EnumChatFormatting.BLUE + ": Theta Movement"; + public static final String COSMIC_MARK = TEC_MARK_SHORT + + EnumChatFormatting.BLUE + ": Cosmic";//TODO get a better name than cosmic for *UNDEFINED* thing - public static final byte DECAY_AT = 0;// hatches compute decays + public static final byte DECAY_AT = 0;// hatches compute decays public static final byte MULTI_PURGE_1_AT = 2;// multiblocks clean their hatches 1 - public static final byte MOVE_AT = 4;// move stuff around - public static final byte RECIPE_AT = 6;// move stuff around + public static final byte MOVE_AT = 4;// move stuff around + public static final byte RECIPE_AT = 6;// move stuff around public static final byte MULTI_PURGE_2_AT = 8;// multiblocks clean their hatches 2 - public static final byte OVERFLOW_AT = 10;// then hatches clean themselves + public static final byte OVERFLOW_AT = 10;// then hatches clean themselves // - in case some hatches are not in multiblock structure - public static final byte MULTI_CHECK_AT = 12;// multiblock checks it's state - public static final byte DISPERSE_AT = 14;// overflow hatches perform disperse - public static final byte TRANSFER_AT = 16; + public static final byte MULTI_CHECK_AT = 12;// multiblock checks it's state + public static final byte DISPERSE_AT = 14;// overflow hatches perform disperse + public static final byte TRANSFER_AT = 16; - public static final long[] AatV = new long[]{268435455,67108863,16777215,4194303,1048575,262143,65535,16383,4095,1023,255,63,15,3,1,1}; + public static final long[] AatV = new long[]{268435455, 67108863, 16777215, 4194303, 1048575, 262143, 65535, 16383, 4095, 1023, 255, 63, 15, 3, 1, 1}; public static final String[] VOLTAGE_NAMES = new String[]{"Ultra Low Voltage", "Low Voltage", "Medium Voltage", "High Voltage", "Extreme Voltage", "Insane Voltage", "Ludicrous Voltage", "ZPM Voltage", "Ultimate Voltage", "Ultimate High Voltage", "Ultimate Extreme Voltage", "Ultimate Insane Voltage", "Ultimate Mega Voltage", "Ultimate Extended Mega Voltage", "Overpowered Voltage", "Maximum Voltage"}; - public static final String[] VN = new String[]{"ULV", "LV", "MV", "HV", "EV", "IV", "LuV", "ZPM", "UV", "UHV", "UEV", "UIV", "UMV", "UXV", "OpV", "MAX"}; - public static final long[] V = new long[]{8L, 32L, 128L, 512L, 2048L, 8192L, 32768L, 131072L, 524288L, 2097152L, 8388608L, 33554432L, 134217728L, 536870912L, 1073741824L, Integer.MAX_VALUE - 7}; + public static final String[] VN = new String[]{"ULV", "LV", "MV", "HV", "EV", "IV", "LuV", "ZPM", "UV", "UHV", "UEV", "UIV", "UMV", "UXV", "OpV", "MAX"}; + public static final long[] V = new long[]{8L, 32L, 128L, 512L, 2048L, 8192L, 32768L, 131072L, 524288L, 2097152L, 8388608L, 33554432L, 134217728L, 536870912L, 1073741824L, Integer.MAX_VALUE - 7}; - private CommonValues() {} + private CommonValues() { + } } diff --git a/src/main/java/com/github/technus/tectech/util/DoubleCount.java b/src/main/java/com/github/technus/tectech/util/DoubleCount.java index b37c0987ae..cd86480be9 100644 --- a/src/main/java/com/github/technus/tectech/util/DoubleCount.java +++ b/src/main/java/com/github/technus/tectech/util/DoubleCount.java @@ -2,27 +2,42 @@ package com.github.technus.tectech.util; import java.util.Arrays; -import static java.lang.Math.*; -import static java.lang.Math.max; +import static java.lang.Math.abs; import static java.lang.Math.ulp; public class DoubleCount { - public static double[] distribute(double count,double... probabilities) throws ArithmeticException { - if (probabilities == null) { + /** + * Distributes count across probabilities + * + * @param count the count to divide + * @param probabilities probability ratios to divide by, descending + * @return divided count + * @throws ArithmeticException + */ + public static double[] distribute(double count, double... probabilities) throws ArithmeticException { + if (probabilities == null || Double.isNaN(count)) { return null; } else if (count == 0) { return new double[probabilities.length]; + } else if (Double.isInfinite(count)) { + double[] doubles = new double[probabilities.length]; + Arrays.fill(doubles, count); + return doubles; } else { switch (probabilities.length) { default: { - int size = probabilities.length; + int size = probabilities.length; double[] output = new double[size]; size--; - double remaining = count, previous = probabilities[size], probability, out, sum = 0; + double remaining = count, previous = probabilities[size], probability, out; for (int i = size - 1; i >= 0; i--) { probability = probabilities[i]; - remaining -= out = count * probability - ulp(probability); - sum += output[i] = out; + out = count * probability; + out -= ulpSigned(out); + + remaining -= out; + output[i] = out; + if (previous < probability) { throw new ArithmeticException("Malformed probability order: " + Arrays.toString(probabilities)); } @@ -31,14 +46,10 @@ public class DoubleCount { break; } } - if (remaining * count < 0) { + if (remaining * count < 0) {//overshoot finishIt(size, output, remaining); } else { - sum += output[size] = remaining - ulp(remaining) * size; - if (sum > count) { - remaining = sum - count; - finishIt(size, output, remaining); - } + output[size] = remaining; } return output; } @@ -50,84 +61,64 @@ public class DoubleCount { } } + public static double ulpSigned(double number) { + if (number == 0) { + return 0; + } + return number > 0 ? ulp(number) : -ulp(number); + } + private static void finishIt(int size, double[] output, double remaining) { for (int i = size - 1; i >= 0; i--) { if (abs(output[i]) >= abs(remaining)) { output[i] -= remaining; break; } else { - remaining+=output[i]; - output[i]=0; + remaining += output[i]; + output[i] = 0; } } } - public static double div(double count,double divisor){ - if (divisor == 0) { - throw new ArithmeticException("Divide by 0"); - }else if(count==0 || divisor==1){ - return count; - }else if(divisor==-1){ - return -count; + public static double div(double count, double divisor) { + if (count == 0 || abs(divisor) == 1 || abs(count)==abs(divisor)) { + return count/divisor; } else { double result = count / divisor; - if(result*count<0){ - return 0; - } - return result-ulp(result); + return result - ulpSigned(result); } } - public static double mul(double count,double multiplier){ - if(count==0 || multiplier==1){ - return count; - }else if(multiplier==-1){ - return -count; + public static double mul(double count, double multiplier) { + if (count == 0 || multiplier == 0 || abs(multiplier)==1 || abs(count)==1) { + return count*multiplier; } else { double result = count * multiplier; - if(result*count<0){ - return 0; - } - return result-ulp(result); + return result - ulpSigned(result); } } - public static double sub(double count,double value){ - if(value==0){ - return count; - } - if(count==0){ - return -value; - } - if(value==count){ - return 0; - } - return value < 0 ? addInternal(count, -value) : subInternal(count, value); - } - - public static double add(double count,double value){ - if(value==0){ - return count; - } - if(count==0){ - return value; - } - return value < 0 ? subInternal(count, -value) : addInternal(count, value); - } - - private static double subInternal(double count,double value){ - double result = count - max(value,ulp(count)); - if (result+value>count || value>count-result){ - result-=ulp(result); + public static double sub(double count, double value) { + if (count == 0 || value == 0 || count == value) { + return count - value; + } else { + double result = count - value; + if(result==count||result==value){ + return result; + } + return result - ulpSigned(result); } - return result; } - private static double addInternal(double count,double value){ - double result = count + value; - if (result-value>count || result-count>value){ - result-=ulp(result); + public static double add(double count, double value) { + if (count == 0 || value == 0 || count == -value) { + return count + value; + } else { + double result = count + value; + if(result==count||result==value){ + return result; + } + return result - ulpSigned(result); } - return result; } } diff --git a/src/main/java/com/github/technus/tectech/util/Util.java b/src/main/java/com/github/technus/tectech/util/TT_Utility.java index 1843770e3a..2b67f72ff0 100644 --- a/src/main/java/com/github/technus/tectech/util/Util.java +++ b/src/main/java/com/github/technus/tectech/util/TT_Utility.java @@ -29,15 +29,37 @@ import org.apache.commons.lang3.StringUtils; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.lang.reflect.Array; import java.lang.reflect.Field; import java.nio.charset.StandardCharsets; import java.util.*; +import java.util.function.Function; /** * Created by Tec on 21.03.2017. */ -public final class Util { - private Util() { +public final class TT_Utility { + private TT_Utility() { + } + + private static final StringBuilder STRING_BUILDER = new StringBuilder(); + private static final Map<Locale, Formatter> FORMATTER_MAP = new HashMap<>(); + + private static Formatter getFormatter() { + STRING_BUILDER.setLength(0); + return FORMATTER_MAP.computeIfAbsent(Locale.getDefault(Locale.Category.FORMAT), locale -> new Formatter(STRING_BUILDER, locale)); + } + + public static String formatNumberShortExp(double value) { + return getFormatter().format("%.3E", value).toString(); + } + + public static String formatNumberExp(double value) { + return getFormatter().format("%+.5E", value).toString(); + } + + public static String formatNumberIntHex(int value) { + return getFormatter().format("%08X", value).toString(); } @SuppressWarnings("ComparatorMethodParameterNotUsed") @@ -52,45 +74,75 @@ public final class Util { return sortedEntries; } - public static int bitStringToInt(String bits){ - if(bits==null){ + public static int bitStringToInt(String bits) { + if (bits == null) { return 0; } - if(bits.length() > 32){ + if (bits.length() > 32) { throw new NumberFormatException("Too long!"); } - return Integer.parseInt(bits,2); + return Integer.parseInt(bits, 2); } - public static int hexStringToInt(String hex){ - if(hex==null){ + public static int hexStringToInt(String hex) { + if (hex == null) { return 0; } - if(hex.length()>8){ + if (hex.length() > 8) { throw new NumberFormatException("Too long!"); } - return Integer.parseInt(hex,16); + return Integer.parseInt(hex, 16); } - public static double stringToDouble(String str){ - if(str==null){ + public static double stringToDouble(String str) { + if (str == null) { return 0; } return Double.parseDouble(str); } + private static final String SUPER_SCRIPT = "\u207D\u207E*\u207A,\u207B./\u2070\u00B9\u00B2\u00B3\u2074\u2075\u2076\u2077\u2078\u2079:;<\u207C"; + private static final String SUB_SCRIPT = "\u208D\u208E*\u208A,\u208B./\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089:;<\u208C"; + + public static String toSubscript(String s) { + STRING_BUILDER.setLength(0); + for (int i = 0; i <s.length(); i++) { + char c=s.charAt(i); + if(c>='('&&c<='='){ + STRING_BUILDER.append(SUB_SCRIPT.charAt(c-'(')); + }else { + STRING_BUILDER.append(c); + } + } + return STRING_BUILDER.toString(); + } + + public static String toSuperscript(String s) { + STRING_BUILDER.setLength(0); + for (int i = 0; i <s.length(); i++) { + char c=s.charAt(i); + if(c>='('&&c<='='){ + STRING_BUILDER.append(SUPER_SCRIPT.charAt(c-'(')); + }else { + STRING_BUILDER.append(c); + } + } + return STRING_BUILDER.toString(); + } + + public static double getValue(String in1) { String str = in1.toLowerCase(); double val; try { if (str.contains("b")) { String[] split = str.split("b"); - val = Util.bitStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); + val = TT_Utility.bitStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); } else if (str.contains("x")) { String[] split = str.split("x"); - val = Util.hexStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); + val = TT_Utility.hexStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); } else { - val = Util.stringToDouble(str); + val = TT_Utility.stringToDouble(str); } return val; } catch (Exception e) { @@ -278,7 +330,7 @@ public final class Util { public static String[] splitButDifferent(String string, String delimiter) { String[] strings = new String[StringUtils.countMatches(string, delimiter) + 1]; - int lastEnd = 0; + int lastEnd = 0; for (int i = 0; i < strings.length - 1; i++) { int nextEnd = string.indexOf(delimiter, lastEnd); strings[i] = string.substring(lastEnd, nextEnd); @@ -288,7 +340,7 @@ public final class Util { return strings; } - public static String[] infoFromNBT(NBTTagCompound nbt) { + public static String[] unpackStrings(NBTTagCompound nbt) { String[] strings = new String[nbt.getInteger("i")]; for (int i = 0; i < strings.length; i++) { strings[i] = nbt.getString(Integer.toString(i)); @@ -296,14 +348,45 @@ public final class Util { return strings; } + public static String getSomeString(NBTTagCompound nbt, int index) { + return nbt.getString(Integer.toString(index % nbt.getInteger("i"))); + } + + public static NBTTagCompound packStrings(String... info) { + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setInteger("i", info.length); + for (int i = 0; i < info.length; i++) { + nbt.setString(Integer.toString(i), info[i]); + } + return nbt; + } + + @SuppressWarnings("unchecked") + public static <T> T[] unpackNBT(Class<T> tClass, Function<NBTTagCompound, T> converter, NBTTagCompound nbt) { + T[] objects = (T[]) Array.newInstance(tClass, nbt.getInteger("i")); + for (int i = 0; i < objects.length; i++) { + objects[i] = converter.apply(nbt.getCompoundTag(Integer.toString(i))); + } + return objects; + } + + public static <T> NBTTagCompound packNBT(Function<T, NBTTagCompound> converter, T... info) { + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setInteger("i", info.length); + for (int i = 0; i < info.length; i++) { + nbt.setTag(Integer.toString(i), converter.apply(info[i])); + } + return nbt; + } + public static boolean areBitsSet(int setBits, int testedValue) { return (testedValue & setBits) == setBits; } public static class ItemStack_NoNBT implements Comparable<ItemStack_NoNBT> { public final Item mItem; - public final int mStackSize; - public final int mMetaData; + public final int mStackSize; + public final int mMetaData; public ItemStack_NoNBT(Item aItem, long aStackSize, long aMetaData) { this.mItem = aItem; @@ -355,210 +438,241 @@ public final class Util { } } - public static void setTier(int tier,Object me){ - try{ - Field field=GT_MetaTileEntity_TieredMachineBlock.class.getField("mTier"); + public static void setTier(int tier, Object me) { + try { + Field field = GT_MetaTileEntity_TieredMachineBlock.class.getField("mTier"); field.setAccessible(true); - field.set(me,(byte)tier); - }catch (Exception e){ + field.set(me, (byte) tier); + } catch (Exception e) { //e.printStackTrace(); } } - public static StringBuilder receiveString(StringBuilder previousValue, int startIndex, int index, int value){ - int sizeReq=index-startIndex; - if(value==0){ - previousValue.setLength(Math.min(previousValue.length(),sizeReq)); - }else { - previousValue.setLength(Math.max(previousValue.length(),sizeReq)); - previousValue.setCharAt(sizeReq,(char)value); + public static StringBuilder receiveString(StringBuilder previousValue, int startIndex, int index, int value) { + int sizeReq = index - startIndex; + if (value == 0) { + previousValue.setLength(Math.min(previousValue.length(), sizeReq)); + } else { + previousValue.setLength(Math.max(previousValue.length(), sizeReq)); + previousValue.setCharAt(sizeReq, (char) value); } return previousValue; } @Deprecated - public static double receiveDouble(double previousValue, int startIndex, int index, int value){ - return Double.longBitsToDouble(receiveLong(Double.doubleToLongBits(previousValue),startIndex,index,value)); + public static double receiveDouble(double previousValue, int startIndex, int index, int value) { + return Double.longBitsToDouble(receiveLong(Double.doubleToLongBits(previousValue), startIndex, index, value)); } - public static long receiveLong(long previousValue, int startIndex, int index, int value){ - value &=0xFFFF; - switch (index-startIndex){ + public static long receiveLong(long previousValue, int startIndex, int index, int value) { + value &= 0xFFFF; + switch (index - startIndex) { case 0: - previousValue&= 0xFFFF_FFFF_FFFF_0000L; - previousValue|=value; + previousValue &= 0xFFFF_FFFF_FFFF_0000L; + previousValue |= value; break; case 1: - previousValue&=0xFFFF_FFFF_0000_FFFFL; - previousValue|=value<<16; + previousValue &= 0xFFFF_FFFF_0000_FFFFL; + previousValue |= (long) value << 16; break; case 2: - previousValue&=0xFFFF_0000_FFFF_FFFFL; - previousValue|=(long)value<<32; + previousValue &= 0xFFFF_0000_FFFF_FFFFL; + previousValue |= (long) value << 32; break; case 3: - previousValue&=0x0000_FFFF_FFFF_FFFFL; - previousValue|=(long)value<<48; + previousValue &= 0x0000_FFFF_FFFF_FFFFL; + previousValue |= (long) value << 48; break; } return previousValue; } - public static void sendString(StringBuilder string,Container container, ICrafting crafter,int startIndex){ + public static void sendString(StringBuilder string, Container container, ICrafting crafter, int startIndex) { for (int i = 0; i < string.length(); i++) { - crafter.sendProgressBarUpdate(container,startIndex++,string.charAt(i)); + crafter.sendProgressBarUpdate(container, startIndex++, string.charAt(i)); } - crafter.sendProgressBarUpdate(container,startIndex,0); + crafter.sendProgressBarUpdate(container, startIndex, 0); } - public static void sendDouble(double value,Container container, ICrafting crafter,int startIndex){ - sendLong(Double.doubleToLongBits(value),container,crafter,startIndex); + public static void sendDouble(double value, Container container, ICrafting crafter, int startIndex) { + sendLong(Double.doubleToLongBits(value), container, crafter, startIndex); } - public static void sendLong(long value,Container container, ICrafting crafter,int startIndex){ - crafter.sendProgressBarUpdate(container, startIndex++, (int)(value & 0xFFFFL)); - crafter.sendProgressBarUpdate(container, startIndex++, (int)((value & 0xFFFF0000L)>>>16)); - crafter.sendProgressBarUpdate(container, startIndex++, (int)((value & 0xFFFF00000000L)>>>32)); - crafter.sendProgressBarUpdate(container, startIndex, (int)((value & 0xFFFF000000000000L)>>>48)); + public static void sendLong(long value, Container container, ICrafting crafter, int startIndex) { + crafter.sendProgressBarUpdate(container, startIndex++, (int) (value & 0xFFFFL)); + crafter.sendProgressBarUpdate(container, startIndex++, (int) ((value & 0xFFFF0000L) >>> 16)); + crafter.sendProgressBarUpdate(container, startIndex++, (int) ((value & 0xFFFF00000000L) >>> 32)); + crafter.sendProgressBarUpdate(container, startIndex, (int) ((value & 0xFFFF000000000000L) >>> 48)); } @Deprecated - public static float receiveFloat(float previousValue, int startIndex, int index, int value){ - return Float.intBitsToFloat(receiveInteger(Float.floatToIntBits(previousValue),startIndex,index,value)); + public static float receiveFloat(float previousValue, int startIndex, int index, int value) { + return Float.intBitsToFloat(receiveInteger(Float.floatToIntBits(previousValue), startIndex, index, value)); } - public static int receiveInteger(int previousValue, int startIndex, int index, int value){ - value &=0xFFFF; - switch (index-startIndex){ + public static int receiveInteger(int previousValue, int startIndex, int index, int value) { + value &= 0xFFFF; + switch (index - startIndex) { case 0: - previousValue&= 0xFFFF_0000; - previousValue|=value; + previousValue &= 0xFFFF_0000; + previousValue |= value; break; case 1: - previousValue&=0x0000_FFFF; - previousValue|=value<<16; + previousValue &= 0x0000_FFFF; + previousValue |= value << 16; break; } return previousValue; } - public static void sendFloat(float value,Container container, ICrafting crafter,int startIndex){ - sendInteger(Float.floatToIntBits(value),container,crafter,startIndex); + public static void sendFloat(float value, Container container, ICrafting crafter, int startIndex) { + sendInteger(Float.floatToIntBits(value), container, crafter, startIndex); } - public static void sendInteger(int value,Container container, ICrafting crafter,int startIndex){ - crafter.sendProgressBarUpdate(container, startIndex++, (int)(value & 0xFFFFL)); - crafter.sendProgressBarUpdate(container, startIndex, (value & 0xFFFF0000)>>>16); + public static void sendInteger(int value, Container container, ICrafting crafter, int startIndex) { + crafter.sendProgressBarUpdate(container, startIndex++, (int) (value & 0xFFFFL)); + crafter.sendProgressBarUpdate(container, startIndex, (value & 0xFFFF0000) >>> 16); } - public static String doubleToString(double value){ - if(value==(long)value){ - return Long.toString((long)value); + public static String doubleToString(double value) { + if (value == (long) value) { + return Long.toString((long) value); } return Double.toString(value); } - public static boolean checkChunkExist(World world, ChunkCoordIntPair chunk){ - int x=chunk.getCenterXPos(); - int z=chunk.getCenterZPosition(); + public static boolean checkChunkExist(World world, ChunkCoordIntPair chunk) { + int x = chunk.getCenterXPos(); + int z = chunk.getCenterZPosition(); return world.checkChunksExist(x, 0, z, x, 0, z); } - public static NBTTagCompound getPlayerData(UUID uuid1,UUID uuid2,String extension) { + public static NBTTagCompound getPlayerData(UUID uuid1, UUID uuid2, String extension) { try { if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { - if (uuid1 != null && uuid2!=null) { + if (uuid1 != null && uuid2 != null) { IPlayerFileData playerNBTManagerObj = MinecraftServer.getServer().worldServerForDimension(0).getSaveHandler().getSaveHandler(); - SaveHandler sh = (SaveHandler)playerNBTManagerObj; - File dir = ObfuscationReflectionHelper.getPrivateValue(SaveHandler.class, sh, new String[]{"playersDirectory", "field_75771_c"}); - String id1=uuid1.toString(); - NBTTagCompound tagCompound=read(new File(dir, id1 + "."+extension)); - if(tagCompound!=null){ + SaveHandler sh = (SaveHandler) playerNBTManagerObj; + File dir = ObfuscationReflectionHelper.getPrivateValue(SaveHandler.class, sh, new String[]{"playersDirectory", "field_75771_c"}); + String id1 = uuid1.toString(); + NBTTagCompound tagCompound = read(new File(dir, id1 + "." + extension)); + if (tagCompound != null) { return tagCompound; } - tagCompound=readBackup(new File(dir, id1 + "."+extension+"_bak")); - if(tagCompound!=null){ + tagCompound = readBackup(new File(dir, id1 + "." + extension + "_bak")); + if (tagCompound != null) { return tagCompound; } - String id2=uuid2.toString(); - tagCompound=read(new File(dir, id2 + "."+extension)); - if(tagCompound!=null){ + String id2 = uuid2.toString(); + tagCompound = read(new File(dir, id2 + "." + extension)); + if (tagCompound != null) { return tagCompound; } - tagCompound=readBackup(new File(dir, id2 + "."+extension+"_bak")); - if(tagCompound!=null){ + tagCompound = readBackup(new File(dir, id2 + "." + extension + "_bak")); + if (tagCompound != null) { return tagCompound; } } } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } return new NBTTagCompound(); } - public static void savePlayerFile(EntityPlayer player,String extension, NBTTagCompound data) { + public static void savePlayerFile(EntityPlayer player, String extension, NBTTagCompound data) { try { if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { if (player != null) { IPlayerFileData playerNBTManagerObj = MinecraftServer.getServer().worldServerForDimension(0).getSaveHandler().getSaveHandler(); - SaveHandler sh = (SaveHandler)playerNBTManagerObj; - File dir = ObfuscationReflectionHelper.getPrivateValue(SaveHandler.class, sh, new String[]{"playersDirectory", "field_75771_c"}); - String id1=player.getUniqueID().toString(); - write(new File(dir, id1 + "."+extension),data); - write(new File(dir, id1 + "."+extension+"_bak"),data); - String id2=UUID.nameUUIDFromBytes(player.getCommandSenderName().getBytes(StandardCharsets.UTF_8)).toString(); - write(new File(dir, id2 + "."+extension),data); - write(new File(dir, id2 + "."+extension+"_bak"),data); + SaveHandler sh = (SaveHandler) playerNBTManagerObj; + File dir = ObfuscationReflectionHelper.getPrivateValue(SaveHandler.class, sh, new String[]{"playersDirectory", "field_75771_c"}); + String id1 = player.getUniqueID().toString(); + write(new File(dir, id1 + "." + extension), data); + write(new File(dir, id1 + "." + extension + "_bak"), data); + String id2 = UUID.nameUUIDFromBytes(player.getCommandSenderName().getBytes(StandardCharsets.UTF_8)).toString(); + write(new File(dir, id2 + "." + extension), data); + write(new File(dir, id2 + "." + extension + "_bak"), data); } } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } - private static NBTTagCompound read(File file){ + private static NBTTagCompound read(File file) { if (file != null && file.exists()) { - try(FileInputStream fileInputStream= new FileInputStream(file)) { + try (FileInputStream fileInputStream = new FileInputStream(file)) { return CompressedStreamTools.readCompressed(fileInputStream); } catch (Exception var9) { - TecTech.LOGGER.error("Cannot read NBT File: "+file.getAbsolutePath()); + TecTech.LOGGER.error("Cannot read NBT File: " + file.getAbsolutePath()); } } return null; } - private static NBTTagCompound readBackup(File file){ + private static NBTTagCompound readBackup(File file) { if (file != null && file.exists()) { - try(FileInputStream fileInputStream= new FileInputStream(file)) { + try (FileInputStream fileInputStream = new FileInputStream(file)) { return CompressedStreamTools.readCompressed(fileInputStream); } catch (Exception var9) { - TecTech.LOGGER.error("Cannot read NBT File: "+file.getAbsolutePath()); + TecTech.LOGGER.error("Cannot read NBT File: " + file.getAbsolutePath()); return new NBTTagCompound(); } } return null; } - private static void write(File file,NBTTagCompound tagCompound){ + private static void write(File file, NBTTagCompound tagCompound) { if (file != null) { - if(tagCompound==null){ - if(file.exists()) file.delete(); - }else { - try(FileOutputStream fileOutputStream= new FileOutputStream(file)) { - CompressedStreamTools.writeCompressed(tagCompound,fileOutputStream); + if (tagCompound == null) { + if (file.exists()) file.delete(); + } else { + try (FileOutputStream fileOutputStream = new FileOutputStream(file)) { + CompressedStreamTools.writeCompressed(tagCompound, fileOutputStream); } catch (Exception var9) { - TecTech.LOGGER.error("Cannot write NBT File: "+file.getAbsolutePath()); + TecTech.LOGGER.error("Cannot write NBT File: " + file.getAbsolutePath()); } } } } - public static AxisAlignedBB fromChunkCoordIntPair(ChunkCoordIntPair chunkCoordIntPair){ - int x=chunkCoordIntPair.chunkXPos<<4; - int z=chunkCoordIntPair.chunkZPos<<4; - return AxisAlignedBB.getBoundingBox(x,-128,z,x+16,512,z+16); + public static AxisAlignedBB fromChunkCoordIntPair(ChunkCoordIntPair chunkCoordIntPair) { + int x = chunkCoordIntPair.chunkXPos << 4; + int z = chunkCoordIntPair.chunkZPos << 4; + return AxisAlignedBB.getBoundingBox(x, -128, z, x + 16, 512, z + 16); + } + + public static AxisAlignedBB fromChunk(Chunk chunk) { + int x = chunk.xPosition << 4; + int z = chunk.zPosition << 4; + return AxisAlignedBB.getBoundingBox(x, -128, z, x + 16, 512, z + 16); + } + + public static String getConcated(String[] strings, String separator) { + StringBuilder stringBuilder = new StringBuilder(); + for (String string : strings) { + stringBuilder.append(string).append(separator); + } + int length = stringBuilder.length(); + if (length >= separator.length()) { + stringBuilder.setLength(length - separator.length()); + } + return stringBuilder.toString(); + } + + public static double getMagnitude3D(double[] in) { + return Math.sqrt(in[0] * in[0] + in[1] * in[1] + in[2] * in[2]); + } + + public static void normalize3D(double[] in, double[] out) { + double mag = getMagnitude3D(in); + out[0] = in[0] / mag; + out[1] = in[1] / mag; + out[2] = in[2] / mag; } - public static AxisAlignedBB fromChunk(Chunk chunk){ - int x=chunk.xPosition<<4; - int z=chunk.zPosition<<4; - return AxisAlignedBB.getBoundingBox(x,-128,z,x+16,512,z+16); + public static void crossProduct3D(double[] inA, double[] inB, double[] out) { + out[0] = inA[1] * inB[2] - inA[2] * inB[1]; + out[1] = inA[2] * inB[0] - inA[0] * inB[2]; + out[2] = inA[0] * inB[1] - inA[1] * inB[0]; } } diff --git a/src/main/java/com/github/technus/tectech/util/Vec3Impl.java b/src/main/java/com/github/technus/tectech/util/Vec3Impl.java deleted file mode 100644 index 56a9176767..0000000000 --- a/src/main/java/com/github/technus/tectech/util/Vec3Impl.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.github.technus.tectech.util; - -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.dispenser.IPosition; -import net.minecraftforge.common.util.ForgeDirection; - -@Deprecated -public class Vec3Impl implements Comparable<Vec3Impl> { - public static final Vec3Impl NULL_VECTOR = new Vec3Impl(0, 0, 0); - private final int val0; - private final int val1; - private final int val2; - - public Vec3Impl(int in0, int in1, int in2) { - this.val0 = in0; - this.val1 = in1; - this.val2 = in2; - } - - public Vec3Impl(IGregTechTileEntity baseMetaTileEntity) { - this(baseMetaTileEntity.getXCoord(),baseMetaTileEntity.getYCoord(),baseMetaTileEntity.getZCoord()); - } - - public int compareTo(Vec3Impl o) { - return val1 == o.val1 ? val2 == o.val2 ? val0 - o.val0 : val2 - o.val2 : val1 - o.val1; - } - - /** - * Gets the coordinate. - */ - public int get(int index) { - switch (index){ - case 0: return val0; - case 1: return val1; - case 2: return val2; - default: return 0; - } - } - - /** - * Gets the X coordinate. - */ - public int get0() { - return this.val0; - } - - /** - * Gets the Y coordinate. - */ - public int get1() { - return this.val1; - } - - /** - * Gets the Z coordinate. - */ - public int get2() { - return this.val2; - } - - public Vec3Impl offset(ForgeDirection facing, int n) { - return n == 0 ? this : new Vec3Impl(val0 + facing.offsetX * n, val1 + facing.offsetY * n, val2 + facing.offsetZ * n); - } - - public Vec3Impl add(IGregTechTileEntity tileEntity) { - return new Vec3Impl(val0 + tileEntity.getXCoord(), val1 + tileEntity.getYCoord(), val2 + tileEntity.getZCoord()); - } - - public Vec3Impl sub(IGregTechTileEntity tileEntity) { - return new Vec3Impl(val0 - tileEntity.getXCoord(), val1 - tileEntity.getYCoord(), val2 - tileEntity.getZCoord()); - } - - public Vec3Impl add(Vec3Impl pos) { - return new Vec3Impl(val0 + pos.val0, val1 + pos.val1, val2 + pos.val2); - } - - public Vec3Impl sub(Vec3Impl pos) { - return new Vec3Impl(val0 - pos.val0, val1 - pos.val1, val2 - pos.val2); - } - - public Vec3Impl add(int pos0,int pos1,int pos2) { - return new Vec3Impl(val0 + pos0, val1 + pos1, val2 + pos2); - } - - public Vec3Impl sub(int pos0,int pos1,int pos2) { - return new Vec3Impl(val0 - pos0, val1 - pos1, val2 - pos2); - } - - public Vec3Impl crossProduct(Vec3Impl vec) { - return new Vec3Impl(val1 * vec.val2 - val2 * vec.val1, val2 * vec.val0 - val0 * vec.val2, - val0 * vec.val1 - val1 * vec.val0); - } - - public boolean withinDistance(Vec3Impl to, double distance) { - return this.distanceSq(to.val0, to.val1, to.val2, false) < distance * distance; - } - - public boolean withinDistance(IPosition to, double distance) { - return this.distanceSq(to.getX(), to.getY(), to.getZ(), true) < distance * distance; - } - - public double distanceSq(Vec3Impl to) { - return this.distanceSq(to.val0, to.val1, to.val2, true); - } - - public double distanceSq(IPosition to, boolean useCenter) { - return this.distanceSq(to.getX(), to.getY(), to.getZ(), useCenter); - } - - public double distanceSq(double x, double y, double z, boolean useCenter) { - double d0 = useCenter ? 0.5D : 0.0D; - double d1 = (double)val0 + d0 - x; - double d2 = (double)val1 + d0 - y; - double d3 = (double)val2 + d0 - z; - return d1 * d1 + d2 * d2 + d3 * d3; - } - - public int manhattanDistance(Vec3Impl to) { - float f = (float)Math.abs(to.val0 - val0); - float f1 = (float)Math.abs(to.val1 - val1); - float f2 = (float)Math.abs(to.val2 - val2); - return (int)(f + f1 + f2); - } - - @Override - public String toString() { - return "Vec3[" + val0 + ", " + val1 + ", " + val2 + "]"; - } - - public Vec3Impl abs() { - return new Vec3Impl(Math.abs(val0),Math.abs(val1),Math.abs(val2)); - } - - public boolean equals(Object o) { - if (this == o) { - return true; - } else if (o instanceof Vec3Impl) { - Vec3Impl vec3i = (Vec3Impl)o; - return val0 == vec3i.val0 && val1 == vec3i.val1 && val2 == vec3i.val2; - } - return false; - } - - public int hashCode() { - return (val1 + val2 * 31) * 31 + val0; - } -}
\ No newline at end of file diff --git a/src/main/resources/META-INF/tectech_at.cfg b/src/main/resources/META-INF/tectech_at.cfg index e09e575a7d..fa76d13c1f 100644 --- a/src/main/resources/META-INF/tectech_at.cfg +++ b/src/main/resources/META-INF/tectech_at.cfg @@ -1,2 +1,17 @@ public net.minecraft.block.Block field_149781_w #blockResistance -public net.minecraft.block.Block field_149782_v #blockHardness
\ No newline at end of file +public net.minecraft.block.Block field_149782_v #blockHardness +protected net.minecraft.client.gui.FontRenderer field_111274_c #unicodePageLocations +protected net.minecraft.client.gui.FontRenderer field_78285_g #colorCode +protected net.minecraft.client.gui.FontRenderer field_78298_i #renderEngine +protected net.minecraft.client.gui.FontRenderer field_78293_l #unicodeFlag +protected net.minecraft.client.gui.FontRenderer field_78294_m #bidiFlag +protected net.minecraft.client.gui.FontRenderer field_78291_n #red +protected net.minecraft.client.gui.FontRenderer field_78292_o #blue +protected net.minecraft.client.gui.FontRenderer field_78306_p #green +protected net.minecraft.client.gui.FontRenderer field_78305_q #alpha +protected net.minecraft.client.gui.FontRenderer field_78304_r #textColor +protected net.minecraft.client.gui.FontRenderer field_78303_s #randomStyle +protected net.minecraft.client.gui.FontRenderer field_78302_t #boldStyle +protected net.minecraft.client.gui.FontRenderer field_78301_u #italicStyle +protected net.minecraft.client.gui.FontRenderer field_78300_v #underlineStyle +protected net.minecraft.client.gui.FontRenderer field_78299_w #strikethroughStyle diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index adec911faa..471b0f1062 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -1,5 +1,6 @@ #Creative Tab Name itemGroup.TecTech=TecTech Interdimensional +itemGroup.EM=TecTech Elemental Matter #Blocks tile.quantumStuff.name=Quantum Stuff @@ -798,20 +799,10 @@ gt.blockmachines.debug.tt.writer.desc.2=ABC axises aligned to machine front tt.keyword.ID=ID #Example: 32EU at 1A tt.keyword.at=at -#These are Thaumcraft aspects -tt.keyword.Air=Air -tt.keyword.Earth=Earth -tt.keyword.Fire=Fire -tt.keyword.Water=Water -tt.keyword.Order=Order -tt.keyword.Entropy=Entropy -tt.keyword.Primal=Primal -tt.keyword.Aspect=Aspect -tt.keyword.CLASS=CLASS -tt.keyword.NAME=NAME -tt.keyword.CHARGE=CHARGE -tt.keyword.COLORLESS=COLORLESS -tt.keyword.MASS=MASS + +tt.keyphrase.Hint_Details=Hint Details + +#debug boom tt.keyword.BOOM=BOOM! tt.keyword.Destination=Destination tt.keyword.Weight=Weight @@ -834,10 +825,6 @@ tt.keyword.Status=Status tt.keyword.Content=Content tt.keyword.PacketHistory=PacketHistory -tt.keyphrase.LIFE_TIME=LIFE TIME -tt.keyphrase.CARRIES_COLOR=CARRIES COLOR -tt.keyphrase.Hint_Details=Hint Details -tt.keyphrase.At_current_energy_level=At current energy level #Used when 0 Elemental Matter Stacks tt.keyphrase.No_Stacks=No Stacks tt.keyphrase.Contains_EM=Contains EM @@ -871,7 +858,389 @@ tt.keyphrase.Average_IO_(max)=Voltage I/O (max) tt.keyphrase.Average_IO_max=Voltage I/O max tt.keyphrase.Amperage_IO_(max)=Amperage I/O (max) tt.keyphrase.Side_capabilities=Side capabilities +tt.keyphrase.Ass_line_recipe=Assembly Line Recipe #OpenTurrets compatibility tile.turretHeadEM.name=Elemental Matter Turret tile.turretBaseEM.name=Elemental Turret Base + +#EM scan result +tt.keyword.scan.depth=Depth +tt.keyword.scan.class=Class +tt.keyword.scan.name=Name +tt.keyword.scan.symbol=Symbol + +tt.keyword.scan.mass=Mass +tt.keyword.scan.count=Count +tt.keyword.scan.amount=Amount +tt.keyword.scan.energy=Energy +tt.keyword.scan.energyLevel=Energy Level +tt.keyword.scan.charge=Charge +tt.keyword.scan.life_mult=Life multiplier +tt.keyword.scan.half_life=Half life +tt.keyword.scan.life_time=Life time +tt.keyword.scan.age=Age +tt.keyphrase.scan.at_current_energy_level=At current energy level +tt.keyword.scan.color=Colorless +tt.keyword.scan.colorless=Colorless +tt.keyword.scan.colored=Colored + +tt.keyword.short.mass=M +tt.keyword.short.count=Qty +tt.keyword.short.amount=Qty +tt.keyword.short.energy=E +tt.keyword.short.energyLevel=EL +tt.keyword.short.charge=C +tt.keyword.short.time=T + +tt.keyword.unit.mass=eV/c² +tt.keyword.unit.massFlux=eV/c²s +tt.keyword.unit.count= +tt.keyword.unit.mol=mol +tt.keyword.unit.itemMols=item(s) +tt.keyword.unit.mbMols=mb +tt.keyword.unit.energy=eV +tt.keyword.unit.charge=e +tt.keyword.unit.time=s +tt.keyword.unit.tick=t +#that the thing wont decay +tt.keyword.stable=STABLE + +#EM types +tt.keyword.Primitive=Primitive +tt.keyword.Element=Element +tt.keyword.Atom=Atom +tt.keyword.Isotope=Isotope +tt.keyword.Boson=Boson +tt.keyword.Fermion=Fermion +tt.keyword.GaugeBoson=Gauge boson +tt.keyword.Meson=Meson +tt.keyword.Baryon=Baryon +tt.keyword.Tetraquark=Tetraquark +tt.keyword.Pentaquark=Pentaquark +tt.keyword.Hexaquark=Hexaquark +tt.keyword.Hadron=Hadron +tt.keyword.Neutrino=Neutrino +tt.keyword.Quark=Quark +tt.keyword.ScalarBoson=Scalar boson +#em definitions +tt.keyword.PrimitiveNBTERROR=NBT ERROR +tt.keyword.PrimitiveNULLPOINTER=NULL POINTER +tt.keyword.PrimitiveSpace=Space +tt.keyword.PrimitivePresence=Presence +tt.keyword.PrimitiveMass=Mass +tt.keyword.PrimitiveDarkMass=DarkMass +tt.keyword.PrimitiveEnergy=Energy +tt.keyword.PrimitiveDarkEnergy=DarkEnergy +tt.keyword.PrimitiveMagic=Magic +tt.keyword.PrimitiveAntimagic=Antimagic +tt.keyword.Gluon=Gluon +tt.keyword.Photon=Photon +tt.keyword.Weak0=Weak +tt.keyword.WeakPlus=Weak+ +tt.keyword.WeakMinus=Weak- +tt.keyword.Proton=Proton +tt.keyword.AntiProton=Antiproton +tt.keyword.Neutron=Neutron +tt.keyword.AntiNeutron=Antineutron +tt.keyword.Lepton=Lepton +tt.keyword.Electron=Electron +tt.keyword.Muon=Muon +tt.keyword.Tauon=Tauon +tt.keyword.Positron=Positron +tt.keyword.Antimuon=Antimuon +tt.keyword.Antitauon=Antitauon +tt.keyword.ElectronNeutrino=Electron neutrino +tt.keyword.MuonNeutrino=Muon neutrino +tt.keyword.TauonNeutrino=Tauon neutrino +tt.keyword.PositronNeutrino=Positron neutrino +tt.keyword.AntimuonNeutrino=Antimuon neutrino +tt.keyword.AntitauonNeutrino=Antitauon neutrino +tt.keyword.QuarkUp=Up +tt.keyword.QuarkCharm=Charm +tt.keyword.QuarkTop=Top +tt.keyword.QuarkDown=Down +tt.keyword.QuarkStrange=Strange +tt.keyword.QuarkBottom=Bottom +tt.keyword.QuarkAntiUp=Antiup +tt.keyword.QuarkAntiCharm=Anticharm +tt.keyword.QuarkAntiTop=Antitop +tt.keyword.QuarkAntiDown=Antidown +tt.keyword.QuarkAntiStrange=Antistrange +tt.keyword.QuarkAntiBottom=Antibottom +tt.keyword.Higgs=Higgs +#These are Thaumcraft aspects +tt.keyword.Air=Air +tt.keyword.Earth=Earth +tt.keyword.Fire=Fire +tt.keyword.Water=Water +tt.keyword.Order=Order +tt.keyword.Entropy=Entropy +tt.keyword.Chaos=Chaos + +tt.keyword.Primal=Primal +tt.keyword.Aspect=Aspect + +tt.element.Neutronium=Neutronium +tt.element.Hydrogen=Hydrogen +tt.element.Helium=Helium +tt.element.Lithium=Lithium +tt.element.Beryllium=Beryllium +tt.element.Boron=Boron +tt.element.Carbon=Carbon +tt.element.Nitrogen=Nitrogen +tt.element.Oxygen=Oxygen +tt.element.Fluorine=Fluorine +tt.element.Neon=Neon +tt.element.Sodium=Sodium +tt.element.Magnesium=Magnesium +tt.element.Aluminium=Aluminium +tt.element.Silicon=Silicon +tt.element.Phosphorus=Phosphorus +tt.element.Sulfur=Sulfur +tt.element.Chlorine=Chlorine +tt.element.Argon=Argon +tt.element.Potassium=Potassium +tt.element.Calcium=Calcium +tt.element.Scandium=Scandium +tt.element.Titanium=Titanium +tt.element.Vanadium=Vanadium +tt.element.Chromium=Chromium +tt.element.Manganese=Manganese +tt.element.Iron=Iron +tt.element.Cobalt=Cobalt +tt.element.Nickel=Nickel +tt.element.Copper=Copper +tt.element.Zinc=Zinc +tt.element.Gallium=Gallium +tt.element.Germanium=Germanium +tt.element.Arsenic=Arsenic +tt.element.Selenium=Selenium +tt.element.Bromine=Bromine +tt.element.Krypton=Krypton +tt.element.Rubidium=Rubidium +tt.element.Strontium=Strontium +tt.element.Yttrium=Yttrium +tt.element.Zirconium=Zirconium +tt.element.Niobium=Niobium +tt.element.Molybdenum=Molybdenum +tt.element.Technetium=Technetium +tt.element.Ruthenium=Ruthenium +tt.element.Rhodium=Rhodium +tt.element.Palladium=Palladium +tt.element.Silver=Silver +tt.element.Cadmium=Cadmium +tt.element.Indium=Indium +tt.element.Tin=Tin +tt.element.Antimony=Antimony +tt.element.Tellurium=Tellurium +tt.element.Iodine=Iodine +tt.element.Xenon=Xenon +tt.element.Caesium=Caesium +tt.element.Barium=Barium +tt.element.Lanthanum=Lanthanum +tt.element.Cerium=Cerium +tt.element.Praseodymium=Praseodymium +tt.element.Neodymium=Neodymium +tt.element.Promethium=Promethium +tt.element.Samarium=Samarium +tt.element.Europium=Europium +tt.element.Gadolinium=Gadolinium +tt.element.Terbium=Terbium +tt.element.Dysprosium=Dysprosium +tt.element.Holmium=Holmium +tt.element.Erbium=Erbium +tt.element.Thulium=Thulium +tt.element.Ytterbium=Ytterbium +tt.element.Lutetium=Lutetium +tt.element.Hafnium=Hafnium +tt.element.Tantalum=Tantalum +tt.element.Tungsten=Tungsten +tt.element.Rhenium=Rhenium +tt.element.Osmium=Osmium +tt.element.Iridium=Iridium +tt.element.Platinum=Platinum +tt.element.Gold=Gold +tt.element.Mercury=Mercury +tt.element.Thallium=Thallium +tt.element.Lead=Lead +tt.element.Bismuth=Bismuth +tt.element.Polonium=Polonium +tt.element.Astatine=Astatine +tt.element.Radon=Radon +tt.element.Francium=Francium +tt.element.Radium=Radium +tt.element.Actinium=Actinium +tt.element.Thorium=Thorium +tt.element.Protactinium=Protactinium +tt.element.Uranium=Uranium +tt.element.Neptunium=Neptunium +tt.element.Plutonium=Plutonium +tt.element.Americium=Americium +tt.element.Curium=Curium +tt.element.Berkelium=Berkelium +tt.element.Californium=Californium +tt.element.Einsteinium=Einsteinium +tt.element.Fermium=Fermium +tt.element.Mendelevium=Mendelevium +tt.element.Nobelium=Nobelium +tt.element.Lawrencium=Lawrencium +tt.element.Rutherfordium=Rutherfordium +tt.element.Dubnium=Dubnium +tt.element.Seaborgium=Seaborgium +tt.element.Bohrium=Bohrium +tt.element.Hassium=Hassium +tt.element.Meitnerium=Meitnerium +tt.element.Darmstadtium=Darmstadtium +tt.element.Roentgenium=Roentgenium +tt.element.Copernicium=Copernicium +tt.element.Nihonium=Nihonium +tt.element.Flerovium=Flerovium +tt.element.Moscovium=Moscovium +tt.element.Livermorium=Livermorium +tt.element.Tennessine=Tennessine +tt.element.Oganesson=Oganesson + +tt.element.AntiNeutronium=Antineutronium +tt.element.AntiHydrogen=Antihydrogen +tt.element.AntiHelium=Antihelium +tt.element.AntiLithium=Antilithium +tt.element.AntiBeryllium=Antiberyllium +tt.element.AntiBoron=Antiboron +tt.element.AntiCarbon=Anticarbon +tt.element.AntiNitrogen=Antinitrogen +tt.element.AntiOxygen=Antioxygen +tt.element.AntiFluorine=Antifluorine +tt.element.AntiNeon=Antineon +tt.element.AntiSodium=Antisodium +tt.element.AntiMagnesium=Antimagnesium +tt.element.AntiAluminium=Antialuminium +tt.element.AntiSilicon=Antisilicon +tt.element.AntiPhosphorus=Antiphosphorus +tt.element.AntiSulfur=Antisulfur +tt.element.AntiChlorine=Antichlorine +tt.element.AntiArgon=Antiargon +tt.element.AntiPotassium=Antipotassium +tt.element.AntiCalcium=Anticalcium +tt.element.AntiScandium=Antiscandium +tt.element.AntiTitanium=Antititanium +tt.element.AntiVanadium=Antivanadium +tt.element.AntiChromium=Antichromium +tt.element.AntiManganese=Antimanganese +tt.element.AntiIron=Antiiron +tt.element.AntiCobalt=Anticobalt +tt.element.AntiNickel=Antinickel +tt.element.AntiCopper=Anticopper +tt.element.AntiZinc=Antizinc +tt.element.AntiGallium=Antigallium +tt.element.AntiGermanium=Antigermanium +tt.element.AntiArsenic=Antiarsenic +tt.element.AntiSelenium=Antiselenium +tt.element.AntiBromine=Antibromine +tt.element.AntiKrypton=Antikrypton +tt.element.AntiRubidium=Antirubidium +tt.element.AntiStrontium=Antistrontium +tt.element.AntiYttrium=Antiyttrium +tt.element.AntiZirconium=Antizirconium +tt.element.AntiNiobium=Antiniobium +tt.element.AntiMolybdenum=Antimolybdenum +tt.element.AntiTechnetium=Antitechnetium +tt.element.AntiRuthenium=Antiruthenium +tt.element.AntiRhodium=Antirhodium +tt.element.AntiPalladium=Antipalladium +tt.element.AntiSilver=Antisilver +tt.element.AntiCadmium=Anticadmium +tt.element.AntiIndium=Antiindium +tt.element.AntiTin=Antitin +tt.element.AntiAntimony=Antiantimony +tt.element.AntiTellurium=Antitellurium +tt.element.AntiIodine=Antiiodine +tt.element.AntiXenon=Antixenon +tt.element.AntiCaesium=Anticaesium +tt.element.AntiBarium=Antibarium +tt.element.AntiLanthanum=Antilanthanum +tt.element.AntiCerium=Anticerium +tt.element.AntiPraseodymium=Antipraseodymium +tt.element.AntiNeodymium=Antineodymium +tt.element.AntiPromethium=Antipromethium +tt.element.AntiSamarium=Antisamarium +tt.element.AntiEuropium=Antieuropium +tt.element.AntiGadolinium=Antigadolinium +tt.element.AntiTerbium=Antiterbium +tt.element.AntiDysprosium=Antidysprosium +tt.element.AntiHolmium=Antiholmium +tt.element.AntiErbium=Antierbium +tt.element.AntiThulium=Antithulium +tt.element.AntiYtterbium=Antiytterbium +tt.element.AntiLutetium=Antilutetium +tt.element.AntiHafnium=Antihafnium +tt.element.AntiTantalum=Antitantalum +tt.element.AntiTungsten=Antitungsten +tt.element.AntiRhenium=Antirhenium +tt.element.AntiOsmium=Antiosmium +tt.element.AntiIridium=Antiiridium +tt.element.AntiPlatinum=Antiplatinum +tt.element.AntiGold=Antigold +tt.element.AntiMercury=Antimercury +tt.element.AntiThallium=Antithallium +tt.element.AntiLead=Antilead +tt.element.AntiBismuth=Antibismuth +tt.element.AntiPolonium=Antipolonium +tt.element.AntiAstatine=Antiastatine +tt.element.AntiRadon=Antiradon +tt.element.AntiFrancium=Antifrancium +tt.element.AntiRadium=Antiradium +tt.element.AntiActinium=Antiactinium +tt.element.AntiThorium=Antithorium +tt.element.AntiProtactinium=Antiprotactinium +tt.element.AntiUranium=Antiuranium +tt.element.AntiNeptunium=Antineptunium +tt.element.AntiPlutonium=Antiplutonium +tt.element.AntiAmericium=Antiamericium +tt.element.AntiCurium=Anticurium +tt.element.AntiBerkelium=Antiberkelium +tt.element.AntiCalifornium=Antibalifornium +tt.element.AntiEinsteinium=Antieinsteinium +tt.element.AntiFermium=Antifermium +tt.element.AntiMendelevium=Antimendelevium +tt.element.AntiNobelium=Antinobelium +tt.element.AntiLawrencium=Antilawrencium +tt.element.AntiRutherfordium=Antirutherfordium +tt.element.AntiDubnium=Antidubnium +tt.element.AntiSeaborgium=Antiseaborgium +tt.element.AntiBohrium=Antibohrium +tt.element.AntiHassium=Antihassium +tt.element.AntiMeitnerium=Antimeitnerium +tt.element.AntiDarmstadtium=Antidarmstadtium +tt.element.AntiRoentgenium=Antiroentgenium +tt.element.AntiCopernicium=Anticopernicium +tt.element.AntiNihonium=Antinihonium +tt.element.AntiFlerovium=Antiflerovium +tt.element.AntiMoscovium=Antimoscovium +tt.element.AntiLivermorium=Antilivermorium +tt.element.AntiTennessine=Antitennessine +tt.element.AntiOganesson=Antioganesson + +tt.IUPAC.n=nil +tt.IUPAC.u=un +tt.IUPAC.b=bi +tt.IUPAC.t=tri +tt.IUPAC.q=quad +tt.IUPAC.p=pent +tt.IUPAC.h=hex +tt.IUPAC.s=sept +tt.IUPAC.o=oct +tt.IUPAC.e=enn +tt.IUPAC.N=Nil +tt.IUPAC.U=Un +tt.IUPAC.B=Bi +tt.IUPAC.T=Tri +tt.IUPAC.Q=Quad +tt.IUPAC.P=Pent +tt.IUPAC.H=Hex +tt.IUPAC.S=Sept +tt.IUPAC.O=Oct +tt.IUPAC.E=Enn +tt.IUPAC.ium=ium +tt.IUPAC.Anti=Anti +tt.keyword.Weird=*
\ No newline at end of file |