From 8b81ea9fd4b9446bea8f95fbcb04e550ebf23c83 Mon Sep 17 00:00:00 2001 From: "[Kiwi233]" <[huaxia0611@qq.com]> Date: Mon, 2 Aug 2021 20:57:25 +0800 Subject: Update zh_CN.lang --- src/main/resources/assets/tectech/lang/zh_CN.lang | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/main/resources') diff --git a/src/main/resources/assets/tectech/lang/zh_CN.lang b/src/main/resources/assets/tectech/lang/zh_CN.lang index c01c8f2757..56cecd80c2 100644 --- a/src/main/resources/assets/tectech/lang/zh_CN.lang +++ b/src/main/resources/assets/tectech/lang/zh_CN.lang @@ -87,6 +87,16 @@ item.tm.teslaCover.desc.4=到底谁在用电缆? item.tm.teslaStaff.name=特斯拉权杖 item.tm.teslaStaff.desc=狂妄之人窃取了众神的权柄! +item.tm.enderfluidlinkcover.name=末影流体覆盖板 +item.tm.enderfluidlinkcover.desc.0=在机器间无线传输流体! +item.tm.enderfluidlinkcover.desc.1=可贴在储罐/机器/管道的任意面以将其与末影相连 +item.tm.enderfluidlinkcover.desc.2=末影储罐太逊了! -来自Chads-of-NH的Bot + +item.tm.powerpassupgradecover.name=导能升级覆盖板 +item.tm.powerpassupgradecover.desc.0=为TecTech多方块机器添加导能功能 +item.tm.powerpassupgradecover.desc.1=罐中的有源变压器?? +item.tm.powerpassupgradecover.desc.2=将它们像圣诞彩灯一样串起来! + #Death Messages death.attack.microwaving=%1$s被辐射脱水。 death.attack.microwaving.player=%1$s在与%2$s的战斗中被辐射脱水。 @@ -771,7 +781,7 @@ gt.blockmachines.debug.tt.data.desc.0=量子数据输出 gt.blockmachines.debug.tt.data.desc.1=高速光纤接口 gt.blockmachines.debug.tt.data.desc.2=启用前必须涂色 gt.blockmachines.debug.tt.maintenance.name=Debug维护仓 -gt.blockmachines.debug.tt.maintenance.desc.0=用于维护多方块 +gt.blockmachines.debug.tt.maintenance.desc.0=自动维护多方块机器 gt.blockmachines.debug.tt.maintenance.desc.1=它能修好一切,除了自己. gt.blockmachines.debug.tt.maintenance.desc.2=为人民服务! gt.blockmachines.debug.tt.genny.name=Debug发电机 -- cgit From 062fb04b02b9291741fdc4e79441e07cedee8796 Mon Sep 17 00:00:00 2001 From: Bass Date: Fri, 24 Dec 2021 18:49:07 +0000 Subject: Merge pull request #19 from GTNewHorizons/unified-build-script GTNewHorizons/TecTech/pull/19 Update buildscript Unify build script --- .github/scripts/test-no-error-reports.sh | 27 + .github/workflows/build-and-test.yml | 45 ++ .github/workflows/release-tags.yml | 61 +++ .gitignore | 62 +-- .gitmodules | 3 - build.gradle | 562 +++++++++++++++++++++ build.gradle.kts | 292 ----------- dependencies.gradle | 43 ++ .../OpenModularTurrets-1.7.10-2.2.10-237-deobf.jar | Bin 0 -> 988221 bytes draw_io_graph.png | Bin 0 -> 113460 bytes gradle.properties | 70 ++- gradle/wrapper/gradle-wrapper.jar | Bin 54417 -> 55616 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 22 +- gradlew.bat | 18 +- jitpack.yml | 2 + libs/CoFHCore-[1.7.10]3.1.4-329-dev.jar | Bin 1213993 -> 0 bytes libs/GT-PlusPlus-1.7.0-prerelease-8-final.jar | Bin 4458558 -> 0 bytes .../OpenModularTurrets-1.7.10-2.2.10-237-deobf.jar | Bin 988221 -> 0 bytes real.gradle.properties | 20 - repositories.gradle | 26 + src/main/resources/mcmod.info | 8 +- 22 files changed, 894 insertions(+), 369 deletions(-) create mode 100644 .github/scripts/test-no-error-reports.sh create mode 100644 .github/workflows/build-and-test.yml create mode 100644 .github/workflows/release-tags.yml delete mode 100644 .gitmodules create mode 100644 build.gradle delete mode 100644 build.gradle.kts create mode 100644 dependencies.gradle create mode 100644 dependencies/OpenModularTurrets-1.7.10-2.2.10-237-deobf.jar create mode 100644 draw_io_graph.png create mode 100644 jitpack.yml delete mode 100644 libs/CoFHCore-[1.7.10]3.1.4-329-dev.jar delete mode 100644 libs/GT-PlusPlus-1.7.0-prerelease-8-final.jar delete mode 100644 libs/OpenModularTurrets-1.7.10-2.2.10-237-deobf.jar delete mode 100644 real.gradle.properties create mode 100644 repositories.gradle (limited to 'src/main/resources') diff --git a/.github/scripts/test-no-error-reports.sh b/.github/scripts/test-no-error-reports.sh new file mode 100644 index 0000000000..e3876606d5 --- /dev/null +++ b/.github/scripts/test-no-error-reports.sh @@ -0,0 +1,27 @@ +if [[ -d "run/crash-reports" ]]; then + echo "Crash reports detected:" + cat $directory/* + exit 1 +fi + +if grep --quiet "Fatal errors were detected" server.log; then + echo "Fatal errors detected:" + cat server.log + exit 1 +fi + +if grep --quiet "The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED" server.log; then + echo "Server force stopped:" + cat server.log + exit 1 +fi + +if grep --quiet 'Done .+ For help, type "help" or "?"' server.log; then + echo "Server didn't finish startup:" + cat server.log + exit 1 +fi + +echo "No crash reports detected" +exit 0 + diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000000..08df9fe89f --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,45 @@ +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Build and test + +on: + pull_request: + branches: [ master, main ] + push: + branches: [ master, main ] + +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up JDK 8 + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Setup the workspace + run: ./gradlew setupCIWorkspace + + - name: Build the mod + run: ./gradlew build + + - name: Run server for 1.5 minutes + run: | + mkdir run + echo "eula=true" > run/eula.txt + timeout 90 ./gradlew runServer | tee --append server.log || true + + - name: Test no errors reported during server run + run: | + chmod +x .github/scripts/test-no-error-reports.sh + .github/scripts/test-no-error-reports.sh diff --git a/.github/workflows/release-tags.yml b/.github/workflows/release-tags.yml new file mode 100644 index 0000000000..96d37f7d9a --- /dev/null +++ b/.github/workflows/release-tags.yml @@ -0,0 +1,61 @@ +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Release tagged build + +on: + push: + tags: + - '*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set release version + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Set up JDK 8 + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Setup the workspace + run: ./gradlew setupCIWorkspace + + - name: Build the mod + run: ./gradlew build + + - name: Release under current tag + uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: "${{ env.RELEASE_VERSION }}" + prerelease: false + title: "${{ env.RELEASE_VERSION }}" + files: build/libs/*.jar + + - name: Set repository owner and name + run: | + echo "REPOSITORY_OWNER=${GITHUB_REPOSITORY%/*}" >> $GITHUB_ENV + echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV + + - name: Publish package + run: ./gradlew publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ARTIFACT_GROUP_ID: com.github.${{ env.REPOSITORY_OWNER }} + ARTIFACT_ID: "${{ env.REPOSITORY_NAME }}" + ARTIFACT_VERSION: "${{ env.RELEASE_VERSION }}" + REPOSITORY_NAME: "${{ env.REPOSITORY_NAME }}" + REPOSITORY_OWNER: "${{ env.REPOSITORY_OWNER }}" + diff --git a/.gitignore b/.gitignore index 3d66b81105..558ad12d27 100644 --- a/.gitignore +++ b/.gitignore @@ -1,44 +1,28 @@ -.gradle/ -run/ -.settings/ +.gradle +.settings +/.idea/ +/run/ +/build/ +/eclipse/ .classpath .project -bin/ -out/ -libs/gregtech* -CREDITS-fml.txt -LICENSE-fml.txt -MinecraftForge-Credits.txt -MinecraftForge-License.txt -CoreMod.iml -CoreMod.ipr -CoreMod.iws -Idea.bat -SetupDevWorkspaces.bat +/bin/ +/config/ +/crash-reports/ +/logs/ +options.txt +/saves/ +usernamecache.json +banned-ips.json +banned-players.json +eula.txt +ops.json +server.properties +servers.dat +usercache.json +whitelist.json +/out/ *.iml *.ipr *.iws -*.bat -.idea/workspace.xml -*.db -*.log -.idea/ -\.directory -asm/ -config/ -saves/ -usernamecache.json -PlayerCache.dat -GregTech.cfg -options.txt -GregTech.lang -mods/ -classes/ -logs/ -libs/AsieLib-1.7.10-0.4.9-deobf.jar -libs/Computronics-1.7.10-1.6.6-deobf.jar -libs/Galacticraft-API-1.7-3.0.12.504.jar -libs/GTNewHorizonsCoreMod-1.7.10-1.6.10.jar -libs/MicdoodleCore-1.7-3.0.12.504.jar -libs/worldedit-forge-mc1.7.10-6.1.1-dist.jar -eclipse/ +src/main/resources/mixins.*.json diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 58eebb4aa5..0000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "AVRcore"] - path = AVRcore - url = https://github.com/Technus/AVRcore diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000000..2ec9a2ebac --- /dev/null +++ b/build.gradle @@ -0,0 +1,562 @@ +//version: be36e1399d5622c152db7c530c48e17cde0ce1bb +/* +DO NOT CHANGE THIS FILE! + +Also, you may replace this file at any time if there is an update available. +Please check https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/build.gradle for updates. + */ + + +import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +import java.util.concurrent.TimeUnit + +buildscript { + repositories { + maven { + name = "forge" + url = "https://maven.minecraftforge.net" + } + maven { + name = "sonatype" + url = "https://oss.sonatype.org/content/repositories/snapshots/" + } + maven { + name = "Scala CI dependencies" + url = "https://repo1.maven.org/maven2/" + } + maven { + name = "jitpack" + url = "https://jitpack.io" + } + } + dependencies { + classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.4' + } +} + +plugins { + id 'idea' + id 'scala' + id("org.ajoberstar.grgit") version("3.1.1") + id("com.github.johnrengelman.shadow") version("4.0.4") + id("com.palantir.git-version") version("0.12.3") + id("maven-publish") +} + +apply plugin: 'forge' + +def projectJavaVersion = JavaLanguageVersion.of(8) + +java { + toolchain { + languageVersion.set(projectJavaVersion) + } +} + +idea { + module { + inheritOutputDirs = true + downloadJavadoc = true + downloadSources = true + } +} + +if(JavaVersion.current() != JavaVersion.VERSION_1_8) { + throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current()) +} + +checkPropertyExists("modName") +checkPropertyExists("modId") +checkPropertyExists("modGroup") +checkPropertyExists("autoUpdateBuildScript") +checkPropertyExists("minecraftVersion") +checkPropertyExists("forgeVersion") +checkPropertyExists("replaceGradleTokenInFile") +checkPropertyExists("gradleTokenModId") +checkPropertyExists("gradleTokenModName") +checkPropertyExists("gradleTokenVersion") +checkPropertyExists("gradleTokenGroupName") +checkPropertyExists("apiPackage") +checkPropertyExists("accessTransformersFile") +checkPropertyExists("usesMixins") +checkPropertyExists("mixinPlugin") +checkPropertyExists("mixinsPackage") +checkPropertyExists("coreModClass") +checkPropertyExists("containsMixinsAndOrCoreModOnly") +checkPropertyExists("usesShadowedDependencies") +checkPropertyExists("developmentEnvironmentUserName") + + +String javaSourceDir = "src/main/java/" +String scalaSourceDir = "src/main/scala/" + +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) +} + +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) + } +} + +if(accessTransformersFile) { + String targetFile = "src/main/resources/META-INF/" + accessTransformersFile + if(getFile(targetFile).exists() == false) { + throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile) + } +} + +if(usesMixins.toBoolean()) { + if(mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) { + throw new GradleException("\"mixinPlugin\" requires \"mixinsPackage\" and \"mixinPlugin\" to be set!") + } + + 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) + } + + 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) + } +} + +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) + } +} + +configurations.all { + resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS) + + // Make sure GregTech build won't time out + System.setProperty("org.gradle.internal.http.connectionTimeout", 120000 as String) + System.setProperty("org.gradle.internal.http.socketTimeout", 120000 as String) +} + +// Fix Jenkins' Git: chmod a file should not be detected as a change and append a '.dirty' to the version +'git config core.fileMode false'.execute() +// Pulls version from git tag +try { + version = minecraftVersion + "-" + gitVersion() +} +catch (Exception e) { + throw new IllegalStateException("This mod must be version controlled by Git AND the repository must provide at least one tag!"); +} + +group = modGroup +if(project.hasProperty("customArchiveBaseName") && customArchiveBaseName) { + archivesBaseName = customArchiveBaseName +} +else { + archivesBaseName = modId +} + +minecraft { + version = minecraftVersion + "-" + forgeVersion + "-" + minecraftVersion + runDir = "run" + + if (replaceGradleTokenInFile) { + replaceIn replaceGradleTokenInFile + if(gradleTokenModId) { + replace gradleTokenModId, modId + } + if(gradleTokenModName) { + replace gradleTokenModName, modName + } + if(gradleTokenVersion) { + replace gradleTokenVersion, versionDetails().lastTag + } + if(gradleTokenGroupName) { + replace gradleTokenGroupName, modGroup + } + } +} + +if(file("addon.gradle").exists()) { + apply from: "addon.gradle" +} + +apply from: 'repositories.gradle' + +configurations { + implementation.extendsFrom(shadowImplementation) +} + +repositories { + maven { + name = "Overmind forge repo mirror" + url = "https://gregtech.overminddl1.com/" + } + if(usesMixins.toBoolean()) { + maven { + name = "sponge" + url = "https://repo.spongepowered.org/repository/maven-public" + } + maven { + url = "https://jitpack.io" + } + } +} + +dependencies { + if(usesMixins.toBoolean()) { + annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3") + annotationProcessor("com.google.guava:guava:24.1.1-jre") + annotationProcessor("com.google.code.gson:gson:2.8.6") + annotationProcessor("org.spongepowered:mixin:0.8-SNAPSHOT") + // using 0.8 to workaround a issue in 0.7 which fails mixin application + compile("org.spongepowered:mixin:0.7.11-SNAPSHOT") { + // Mixin includes a lot of dependencies that are too up-to-date + exclude module: "launchwrapper" + exclude module: "guava" + exclude module: "gson" + exclude module: "commons-io" + exclude module: "log4j-core" + } + compile("com.github.GTNewHorizons:SpongeMixins:1.3.3:dev") + } +} + +apply from: 'dependencies.gradle' + +def mixingConfigRefMap = "mixins." + modId + ".refmap.json" +def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfigRefMap +def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg" + +task generateAssets { + if(usesMixins.toBoolean()) { + getFile("/src/main/resources/mixins." + modId + ".json").text = """{ + "required": true, + "minVersion": "0.7.11", + "package": "${modGroup}.${mixinsPackage}", + "plugin": "${modGroup}.${mixinPlugin}", + "refmap": "${mixingConfigRefMap}", + "target": "@env(DEFAULT)", + "compatibilityLevel": "JAVA_8" +} + +""" + } +} + +task relocateShadowJar(type: ConfigureShadowRelocation) { + target = tasks.shadowJar + prefix = modGroup + ".shadow" +} + +shadowJar { + manifest { + attributes(getManifestAttributes()) + } + + minimize() // This will only allow shading for actually used classes + configurations = [project.configurations.shadowImplementation] + dependsOn(relocateShadowJar) +} + +jar { + manifest { + attributes(getManifestAttributes()) + } + + if(usesShadowedDependencies.toBoolean()) { + dependsOn(shadowJar) + enabled = false + } +} + +reobf { + if(usesMixins.toBoolean()) { + addExtraSrgFile mixinSrg + } +} + +afterEvaluate { + if(usesMixins.toBoolean()) { + tasks.compileJava { + options.compilerArgs += [ + "-AreobfSrgFile=${tasks.reobf.srg}", + "-AoutSrgFile=${mixinSrg}", + "-AoutRefMapFile=${refMap}", + // Elan: from what I understand they are just some linter configs so you get some warning on how to properly code + "-XDenableSunApiLintControl", + "-XDignore.symbol.file" + ] + } + } +} + +runClient { + def arguments = [] + + if(usesMixins.toBoolean()) { + arguments += [ + "--mods=../build/libs/$modId-${version}.jar", + "--tweakClass org.spongepowered.asm.launch.MixinTweaker" + ] + } + + if(developmentEnvironmentUserName) { + arguments += [ + "--username", + developmentEnvironmentUserName + ] + } + + args(arguments) +} + +runServer { + def arguments = [] + + if (usesMixins.toBoolean()) { + arguments += [ + "--mods=../build/libs/$modId-${version}.jar", + "--tweakClass org.spongepowered.asm.launch.MixinTweaker" + ] + } + + args(arguments) +} + +tasks.withType(JavaExec).configureEach { + javaLauncher.set( + javaToolchains.launcherFor { + languageVersion = projectJavaVersion + } + ) +} + +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 + expand "minecraftVersion": project.minecraft.version, + "modVersion": versionDetails().lastTag, + "modId": modId, + "modName": modName + } + + if(usesMixins.toBoolean()) { + from refMap + } + + // copy everything else, thats not the mcmod.info + from(sourceSets.main.resources.srcDirs) { + exclude 'mcmod.info' + } + } + +def getManifestAttributes() { + def manifestAttributes = [:] + if(containsMixinsAndOrCoreModOnly.toBoolean() == false && (usesMixins.toBoolean() || coreModClass)) { + manifestAttributes += ["FMLCorePluginContainsFMLMod": true] + } + + if(accessTransformersFile) { + manifestAttributes += ["FMLAT" : accessTransformersFile.toString()] + } + + if(coreModClass) { + manifestAttributes += ["FMLCorePlugin": modGroup + "." + coreModClass] + } + + if(usesMixins.toBoolean()) { + manifestAttributes += [ + "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", + "MixinConfigs" : "mixins." + modId + ".json", + "ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false + ] + } + return manifestAttributes +} + +task sourcesJar(type: Jar) { + from (sourceSets.main.allJava) + from (file("$projectDir/LICENSE")) + getArchiveClassifier().set('sources') +} + +task shadowDevJar(type: ShadowJar) { + from sourceSets.main.output + getArchiveClassifier().set("dev") + + manifest { + attributes(getManifestAttributes()) + } + + minimize() // This will only allow shading for actually used classes + configurations = [project.configurations.shadowImplementation] +} + +task relocateShadowDevJar(type: ConfigureShadowRelocation) { + target = tasks.shadowDevJar + prefix = modGroup + ".shadow" +} + +task circularResolverJar(type: Jar) { + dependsOn(relocateShadowDevJar) + dependsOn(shadowDevJar) + enabled = false +} + +task devJar(type: Jar) { + from sourceSets.main.output + getArchiveClassifier().set("dev") + + manifest { + attributes(getManifestAttributes()) + } + + if(usesShadowedDependencies.toBoolean()) { + dependsOn(circularResolverJar) + enabled = false + } +} + +task apiJar(type: Jar) { + from (sourceSets.main.allJava) { + include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**' + } + + from (sourceSets.main.output) { + include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**' + } + + from (sourceSets.main.resources.srcDirs) { + include("LICENSE") + } + + getArchiveClassifier().set('api') +} + +artifacts { + archives sourcesJar + archives devJar + if(apiPackage) { + archives apiJar + } +} + +// publishing +publishing { + publications { + maven(MavenPublication) { + artifact source: jar + artifact source: sourcesJar, classifier: "src" + artifact source: devJar, classifier: "dev" + if (apiPackage) { + archives source: apiJar, classifier: "api" + } + + groupId = System.getenv("ARTIFACT_GROUP_ID") ?: group + artifactId = System.getenv("ARTIFACT_ID") ?: project.name + version = System.getenv("ARTIFACT_VERSION") ?: project.version + } + } + + repositories { + maven { + String owner = System.getenv("REPOSITORY_OWNER") ?: "Unknown" + String repositoryName = System.getenv("REPOSITORY_NAME") ?: "Unknown" + String githubRepositoryUrl = "https://maven.pkg.github.com/$owner/$repositoryName" + name = "GitHubPackages" + url = githubRepositoryUrl + credentials { + username = System.getenv("GITHUB_ACTOR") ?: "NONE" + password = System.getenv("GITHUB_TOKEN") ?: "NONE" + } + } + } +} + +// Updating +task updateBuildScript { + doLast { + if (performBuildScriptUpdate(projectDir.toString())) return + + print("Build script already up-to-date!") + } +} + +if (isNewBuildScriptVersionAvailable(projectDir.toString())) { + if (autoUpdateBuildScript.toBoolean()) { + performBuildScriptUpdate(projectDir.toString()) + } else { + println("Build script update available! Run 'gradle updateBuildScript'") + } +} + +static URL availableBuildScriptUrl() { + new URL("https://raw.githubusercontent.com/SinTh0r4s/ExampleMod1.7.10/main/build.gradle") +} + +boolean performBuildScriptUpdate(String projectDir) { + if (isNewBuildScriptVersionAvailable(projectDir)) { + def buildscriptFile = getFile("build.gradle") + availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } } + print("Build script updated. Please REIMPORT the project or RESTART your IDE!") + return true + } + return false +} + +boolean isNewBuildScriptVersionAvailable(String projectDir) { + Map parameters = ["connectTimeout": 2000, "readTimeout": 2000] + + String currentBuildScript = getFile("build.gradle").getText() + String currentBuildScriptHash = getVersionHash(currentBuildScript) + String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText() + String availableBuildScriptHash = getVersionHash(availableBuildScript) + + boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash + return !isUpToDate +} + +static String getVersionHash(String buildScriptContent) { + String versionLine = buildScriptContent.find("^//version: [a-z0-9]*") + if(versionLine != null) { + return versionLine.split(": ").last() + } + return "" +} + +configure(updateBuildScript) { + group = 'forgegradle' + description = 'Updates the build script to the latest version' +} + +// Helper methods + +def checkPropertyExists(String propertyName) { + if (project.hasProperty(propertyName) == false) { + throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/gradle.properties") + } +} + +def getFile(String relativePath) { + return new File(projectDir, relativePath) +} diff --git a/build.gradle.kts b/build.gradle.kts deleted file mode 100644 index 29a4f8b6de..0000000000 --- a/build.gradle.kts +++ /dev/null @@ -1,292 +0,0 @@ -import net.minecraftforge.gradle.user.UserExtension -import java.io.FileInputStream -import java.util.* -import java.io.* - -buildscript { - repositories { - mavenCentral() - maven("https://gregtech.overminddl1.com/") - maven("https://jitpack.io") - - } - dependencies { - classpath("com.github.GTNH2:ForgeGradle:FG_1.2-SNAPSHOT"){ - isChanging = true - } - } -} - -plugins { - idea - java - signing -} - -apply(plugin = "forge") - -//Downloads Javadocs and sources by default -idea { - module { - this.isDownloadJavadoc = true - this.isDownloadSources = true - } -} - -//Set Java to version 1.8 -java { - this.sourceCompatibility = JavaVersion.VERSION_1_8 - this.targetCompatibility = JavaVersion.VERSION_1_8 -} - -//Set standard encoding -tasks.withType { - options.encoding = "UTF-8" -} - -//Add extra sources here -sourceSets.getByName("main") { - java.srcDir("src/main/java") - java.srcDir("AVRcore/src") -} - -//Load Minecraft Version -val Project.minecraft: UserExtension - get() = extensions.getByName("minecraft") - -//TODO Delete this! This exists to load the configs from the real properties file, which is needed for Jenkins to build -//Gradle will load gradle.properties from it's home, it's install, and the project folder. Clearly whoever setup the -//Jenkins jar signing needs to be reminded of this! -val prop = Properties() -prop.load(FileInputStream("real.gradle.properties")) -val propSign = Properties() -propSign.load(FileInputStream("gradle.properties")) - -//TODO Delete -val projectVersion: String = prop.getProperty("projectVersion") -//TODO Uncomment -//val projectVersion: String by project - -//Generates a hash for each new commit to differentiate versions -var commitHash = Runtime - .getRuntime() - .exec("git rev-parse --short HEAD") - .let { process -> - process.waitFor() - val output = process.inputStream.use { - it.bufferedReader().use(BufferedReader::readText) - } - process.destroy() - output.trim() - } - -minecraft.version = "1.7.10-10.13.4.1614-1.7.10" -version = "$projectVersion-$commitHash" -group = "com.github.technus" - -//Minecraft Block -configure { - //Replaces version inside the mod - this.includes.addAll( - arrayOf( - "Reference.java" - ) - ) - this.replacements.putAll( - mapOf( - Pair("GRADLETOKEN_VERSION", project.version) - ) - ) - - //This is sometimes called 'eclipse' instead - this.runDir = "run" -} - -repositories { - mavenLocal() - maven("https://gregtech.overminddl1.com/") { this.name = "GT6Maven" } - maven("http://maven.ic2.player.to/") { this.name = "ic2" } - maven("http://jenkins.usrv.eu:8081/nexus/content/repositories/releases/") { this.name = "UsrvDE/GTNH" } - ivy { - this.name = "gtnh_download_source_underscores" - this.artifactPattern("http://downloads.gtnewhorizons.com/Mods_for_Jenkins/[module]_[revision].[ext]") - } - ivy { - this.name = "gtnh_download_source" - this.artifactPattern("http://downloads.gtnewhorizons.com/Mods_for_Jenkins/[module]-[revision].[ext]") - } - ivy { - this.name = "BuildCraft" - this.artifactPattern("http://www.mod-buildcraft.com/releases/BuildCraft/[revision]/[module]-[revision](-[classifier]).[ext]") - } - maven("http://maven.cil.li/") { this.name = "OpenComputers" } - maven("http://default.mobiusstrip.eu/maven") { this.name = "Jabba" } - maven("http://chickenbones.net/maven/") { this.name = "CodeChicken" } - maven("http://www.ryanliptak.com/maven/") { this.name = "appleCore" } - maven("https://jitpack.io") -} - -dependencies { - //Local Libraries - compile(fileTree("libs") { this.include("*.jar") }) - - //TODO Uncomment - //Versions from properties - //val ic2Version: String by project - //val gt5uVersion: String by project - //val yamcoreVersion: String by project - //val opencomputersVersion: String by project - //val computercraftVersion: String by project - //val baublesVersion: String by project - //val thaumcraftVersion: String by project - //val codechickenlibVersion: String by project - //val codechickencoreVersion: String by project - //val neiVersion: String by project - //val wailaVersion: String by project - //val galacticraftVersion: String by project - //val galacticGregVersion: String by project - //val buildcraftVersion: String by project - //val forestryVersion: String by project - //val enderioVersion: String by project - //val enderCoreVersion: String by project - - //TODO Delete - val ic2Version: String = prop.getProperty("ic2Version") - val gt5uVersion: String = prop.getProperty("gt5uVersion") - val yamcoreVersion: String = prop.getProperty("yamcoreVersion") - val opencomputersVersion: String = prop.getProperty("opencomputersVersion") - val computercraftVersion: String = prop.getProperty("computercraftVersion") - val baublesVersion: String = prop.getProperty("baublesVersion") - val thaumcraftVersion: String = prop.getProperty("thaumcraftVersion") - val codechickenlibVersion: String = prop.getProperty("codechickenlibVersion") - val codechickencoreVersion: String = prop.getProperty("codechickencoreVersion") - val neiVersion: String = prop.getProperty("neiVersion") - val wailaVersion: String = prop.getProperty("wailaVersion") - val galacticraftVersion: String = prop.getProperty("galacticraftVersion") - val galacticGregVersion: String = prop.getProperty("galacticGregVersion") - val buildcraftVersion: String = prop.getProperty("buildcraftVersion") - val forestryVersion: String = prop.getProperty("forestryVersion") - val enderioVersion: String = prop.getProperty("enderioVersion") - val enderCoreVersion: String = prop.getProperty("enderCoreVersion") - - //Hard Dependencies - compile("net.industrial-craft:industrialcraft-2:$ic2Version:dev") - compile("com.github.GTNewHorizons:StructureLib:1.0.9:deobf") - compile("com.github.GTNewHorizons:GT5-Unofficial:$gt5uVersion:dev"){ - exclude("net.industrial-craft", "industrialcraft-2") - isChanging = true - } - compile("eu.usrv:YAMCore:$yamcoreVersion:deobf") - - //Compile Dependencies - compileOnly("li.cil.oc:OpenComputers:$opencomputersVersion:dev") - compileOnly("dan200.computercraft:ComputerCraft:$computercraftVersion") - compile("com.azanor.baubles:Baubles:$baublesVersion:deobf") - compile("thaumcraft:Thaumcraft:$thaumcraftVersion:dev") - compile("codechicken:CodeChickenLib:$codechickenlibVersion:dev") - compile("codechicken:CodeChickenCore:$codechickencoreVersion:dev") - compile("codechicken:NotEnoughItems:$neiVersion:dev") - - //Optional Libraries for Testing - runtimeOnly("mcp.mobius.waila:Waila:$wailaVersion") - - //runtimeOnly("micdoodle8.mods:MicdoodleCore:$galacticraftVersion:Dev") - //runtimeOnly("micdoodle8.mods:GalacticraftCore:$galacticraftVersion:Dev") - //runtimeOnly("micdoodle8.mods:Galacticraft-Planets:$galacticraftVersion:Dev") - //runtimeOnly("com.github.GTNewHorizons:GalacticGregGT5:$galacticGregVersion") - //runtimeOnly("com.mod-buildcraft:buildcraft:$buildcraftVersion:dev") - //runtimeOnly("net.sengir.forestry:forestry_1.7.10:$forestryVersion:dev") - //runtimeOnly("com.enderio.core:EnderCore:$enderCoreVersion:dev") - //runtimeOnly("com.enderio:EnderIO:$enderioVersion:dev"){ - // exclude("com.enderio.core", "EnderCore") - // exclude("mcp.mobius.waila", "Waila") - //} - - configurations.all { - resolutionStrategy.cacheDynamicVersionsFor(30, "seconds") - } -} - - - - -tasks.withType { - //Mark as outdated if versions change - this.inputs.properties += "version" to project.version - this.inputs.properties += "mcversion" to project.minecraft.version - this.archiveBaseName.set("TecTech-${project.minecraft.version}") - - //Replace versions in mcmod.info - this.filesMatching("/mcmod.info") { - this.expand( - mapOf( - "version" to project.version, - "mcversion" to project.minecraft.version - ) - ) - } -} - -//Load AVRcore -val submodulesUpdate by tasks.creating(Exec::class) { - this.description = "Updates (and inits) git submodules" - this.group = "Build Setup" - this.commandLine("git", "submodule", "update", "--init", "--recursive", "--remote") -} -tasks.named("setupCIWorkspace") { - dependsOn(":submodulesUpdate") -} -tasks.named("setupDevWorkspace") { - dependsOn(":submodulesUpdate") -} -tasks.named("setupDecompWorkspace") { - dependsOn(":submodulesUpdate") -} -tasks.named("compileJava") { - dependsOn(":submodulesUpdate") -} -tasks.named("sourceMainJava") { - dependsOn(":submodulesUpdate") -} - -tasks.jar { - //Needed for access transformer which allows nerfing hardness of blocks - this.manifest.attributes( - mapOf( - Pair("FMLAT", "tectech_at.cfg") - ) - ) -} - -val sourcesJar by tasks.creating(Jar::class) { - this.from(sourceSets.main.get().allSource) - this.archiveClassifier.set("sources") -} - -val devJar by tasks.creating(Jar::class) { - this.from(sourceSets.main.get().output) - this.archiveClassifier.set("dev") -} - -artifacts { - this.archives(sourcesJar) - this.archives(devJar) -} - -tasks.register("signJar") { - dependsOn("reobf") -} - -//TODO Fix, but technically it was never fully implemented -//signing { -// sign(tasks["jar"]) -//} -// -//tasks.named("signJar") { -// allprojects { -// extra["signing.keyId"] = propSign.getProperty("keyStoreAlias") -// extra["signing.secretKeyRingFile"] = propSign.getProperty("keyStore") -// extra["signing.password"] = propSign.getProperty("keyStorePass") -// } -// dependsOn(":reobf") -//} diff --git a/dependencies.gradle b/dependencies.gradle new file mode 100644 index 0000000000..6d229574c1 --- /dev/null +++ b/dependencies.gradle @@ -0,0 +1,43 @@ +// Add your dependencies here + +dependencies { + shadowImplementation("com.github.GTNewHorizons:AVRcore:add-build-script-SNAPSHOT") + + compile("com.github.GTNewHorizons:GT5-Unofficial:master-SNAPSHOT:dev") + compile("com.github.GTNewHorizons:Yamcl:master-SNAPSHOT:dev") + + /*compile("com.github.GTNewHorizons:NotEnoughItems:master-SNAPSHOT:dev") { // Transitive by GT5-Unofficial + transitive = false + } + compile("com.github.GTNewHorizons:CodeChickenLib:master-SNAPSHOT:dev") { // Transitive by GT5-Unofficial + transitive = false + } + compile("com.github.GTNewHorizons:StructureLib:master-SNAPSHOT:dev") { // Transitive by GT5-Unofficial + transitive = false + } + compile("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev") { // Transitive by GT5-Unofficial + transitive = false + }*/ + + compileOnly("com.github.GTNewHorizons:GTplusplus:master-SNAPSHOT:dev") { + transitive = false + } + compileOnly("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:master-SNAPSHOT: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") +} 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 new file mode 100644 index 0000000000..e854bf7df9 Binary files /dev/null and b/dependencies/OpenModularTurrets-1.7.10-2.2.10-237-deobf.jar differ diff --git a/draw_io_graph.png b/draw_io_graph.png new file mode 100644 index 0000000000..241c41d604 Binary files /dev/null and b/draw_io_graph.png differ diff --git a/gradle.properties b/gradle.properties index 7fc32d532c..3d49d30e98 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,64 @@ -#Dummy File, replaced in Jenkins -systemProp.org.gradle.internal.http.connectionTimeout=120000 -systemProp.org.gradle.internal.http.socketTimeout=120000 -keyStoreAlias=w -keyStore=w -keyStorePass=w +modName = TecTech - Tec Technology! + +# This is a case-sensitive string to identify your mod. Convention is to use lower case. +modId = tectech + +modGroup = com.github.technus.tectech + +# WHY is there no version field? +# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the +# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/ + +# Will update your build.gradle automatically whenever an update is available +autoUpdateBuildScript = false + +minecraftVersion = 1.7.10 +forgeVersion = 10.13.4.1614 + +# Select a username for testing your mod with breakpoints. You may leave this empty for a random user name each time you +# restart Minecraft in development. Choose this dependent on your mod: +# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name +# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty +developmentEnvironmentUserName = "Developer" + +# Define a source file of your project with: +# public static final String VERSION = "GRADLETOKEN_VERSION"; +# The string's content will be replaced with your mods version when compiled. You should use this to specify your mod's +# version in @Mod([...], version = VERSION, [...]) +# Leave these properties empty to skip individual token replacements +replaceGradleTokenInFile = Reference.java +gradleTokenModId = +gradleTokenModName = +gradleTokenVersion = GRADLETOKEN_VERSION +gradleTokenGroupName = + +# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise you can +# leave this property empty. +# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api +apiPackage = + +# Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/ +# Example value: mymodid_at.cfg +accessTransformersFile = tectech_at.cfg + +# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled! +usesMixins = false +# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise. +mixinPlugin = +# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail! +mixinsPackage = +# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin! +# This parameter is for legacy compatability only +# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin +coreModClass = +# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class +# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false! +containsMixinsAndOrCoreModOnly = false + +# If enabled, you may use 'shadowImplementation' for dependencies. They will be integrated in your jar. It is your +# responsibility check the licence and request permission for distribution, if required. +usesShadowedDependencies = true + +# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older +# projects. New projects should not use this parameter. +customArchiveBaseName = TecTech diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 758de960ec..5c2d1cf016 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5028f28f8e..3ab0b725ef 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index cccdd3d517..83f2acfdc3 100644 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -109,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` diff --git a/gradlew.bat b/gradlew.bat index f9553162f1..9618d8d960 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 0000000000..09bbb514fc --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,2 @@ +before_install: + - ./gradlew setupCIWorkspace \ No newline at end of file diff --git a/libs/CoFHCore-[1.7.10]3.1.4-329-dev.jar b/libs/CoFHCore-[1.7.10]3.1.4-329-dev.jar deleted file mode 100644 index 7a53464d53..0000000000 Binary files a/libs/CoFHCore-[1.7.10]3.1.4-329-dev.jar and /dev/null differ diff --git a/libs/GT-PlusPlus-1.7.0-prerelease-8-final.jar b/libs/GT-PlusPlus-1.7.0-prerelease-8-final.jar deleted file mode 100644 index 181475fc38..0000000000 Binary files a/libs/GT-PlusPlus-1.7.0-prerelease-8-final.jar and /dev/null differ diff --git a/libs/OpenModularTurrets-1.7.10-2.2.10-237-deobf.jar b/libs/OpenModularTurrets-1.7.10-2.2.10-237-deobf.jar deleted file mode 100644 index e854bf7df9..0000000000 Binary files a/libs/OpenModularTurrets-1.7.10-2.2.10-237-deobf.jar and /dev/null differ diff --git a/real.gradle.properties b/real.gradle.properties deleted file mode 100644 index 5cf1722acc..0000000000 --- a/real.gradle.properties +++ /dev/null @@ -1,20 +0,0 @@ -systemProp.org.gradle.internal.http.connectionTimeout=120000 -systemProp.org.gradle.internal.http.socketTimeout=120000 -projectVersion=4.10.8 -ic2Version=2.2.828-experimental -gt5uVersion=experimental-SNAPSHOT -yamcoreVersion=1.7.10-0.5.79 -opencomputersVersion=MC1.7.10-1.7.5.1291 -computercraftVersion=1.75 -baublesVersion=1.7.10-1.0.1.10 -thaumcraftVersion=1.7.10-4.2.3.5 -codechickenlibVersion=1.7.10-1.1.3.140 -codechickencoreVersion=1.7.10-1.0.7.47 -neiVersion=1.7.10-1.0.5.120 -wailaVersion=1.5.10_1.7.10 -galacticraftVersion=1.7-3.0.12.504 -galacticGregVersion=master-SNAPSHOT -buildcraftVersion=7.1.23 -forestryVersion=4.4.0.0 -enderioVersion=1.7.10-2.3.0.429_beta -enderCoreVersion=1.7.10-0.2.0.39_beta diff --git a/repositories.gradle b/repositories.gradle new file mode 100644 index 0000000000..130197c8aa --- /dev/null +++ b/repositories.gradle @@ -0,0 +1,26 @@ +// Add any additional repositories for your dependencies here + +repositories { + maven { + name "OpenComputers Repo" + url = "http://maven.cil.li/" + } + maven { + name = "sponge" + url = "https://repo.spongepowered.org/repository/maven-public" + } + maven { + name = "ic2" + url = "http://maven.ic2.player.to/" + metadataSources { + mavenPom() + artifact() + } + } + maven { + url "https://cursemaven.com" + } + maven { + url = "https://jitpack.io" + } +} diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index f7fc68f278..21ecee23f8 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,10 +1,10 @@ [ { - "modid": "tectech", - "name": "TecTech", + "modid": "${modId}", + "name": "${modName}", "description": "TecTech - Tec Technology Interdimensional! Replace UUMatter with something overly complicated and annoying! (GT5u Addon)", - "version": "${version}", - "mcversion": "${mcversion}", + "version": "${modVersion}", + "mcversion": "${minecraftVersion}", "url": "", "updateUrl": "", "authorList": ["_Technus_"], -- cgit From b5399199a88d7c6c19a2ed494aa9c66b81bf2249 Mon Sep 17 00:00:00 2001 From: Tec Date: Sat, 22 Jan 2022 23:33:56 +0100 Subject: Rework API, add locale --- .../java/com/github/technus/tectech/TecTech.java | 19 +- .../dreamcraft/DreamCraftRecipeLoader.java | 8 +- .../tectech/compatibility/gtpp/GtppAtomLoader.java | 68 +- .../blocks/turretbases/TurretBaseEM.java | 2 +- .../blocks/turretheads/TurretHeadEM.java | 2 +- .../entity/projectiles/projectileEM.java | 4 +- .../tileentity/turret/TileTurretHeadEM.java | 6 +- .../spartakcore/SpartakCoreRecipeLoader.java | 9 +- .../definitions/EMComplexAspectDefinition.java | 78 +- .../definitions/EMPrimalAspectDefinition.java | 41 +- .../transformations/AspectDefinitionCompat.java | 7 +- .../AspectDefinitionCompatEnabled.java | 11 +- .../GT_MetaTileEntity_EM_essentiaDequantizer.java | 8 +- .../GT_MetaTileEntity_EM_essentiaQuantizer.java | 4 +- .../technus/tectech/loader/ElementalLoader.java | 29 +- .../github/technus/tectech/loader/MainLoader.java | 26 +- .../tectech/loader/gui/CreativeTabTecTech.java | 2 - .../tectech/loader/recipe/BaseRecipeLoader.java | 125 +++ .../tectech/loader/recipe/BloodyRecipeLoader.java | 6 +- .../tectech/loader/recipe/RecipeLoader.java | 121 -- .../tectech/loader/thing/MachineLoader.java | 15 +- .../tectech/mechanics/anomaly/AnomalyHandler.java | 14 +- .../elementalMatter/core/EMException.java | 3 - .../elementalMatter/core/commands/EMGive.java | 118 +- .../elementalMatter/core/commands/EMList.java | 56 +- .../core/definitions/EMComplexTemplate.java | 20 +- .../core/definitions/EMDefinitionsRegistry.java | 110 -- .../core/definitions/EMPrimitiveTemplate.java | 67 +- .../core/definitions/IEMDefinition.java | 32 +- .../registry/EMDefinitionsRegistry.java | 189 ++++ .../core/definitions/registry/EMIndirectType.java | 37 + .../core/definitions/registry/EMType.java | 63 ++ .../core/maps/EMConstantStackMap.java | 5 +- .../core/maps/EMDefinitionStackMap.java | 5 +- .../core/maps/EMInstanceStackMap.java | 32 +- .../elementalMatter/core/maps/IEMMapRead.java | 20 +- .../elementalMatter/core/maps/IEMMapWrite.java | 12 +- .../core/maps/IEMMapWriteExact.java | 6 +- .../core/stacks/EMDefinitionStack.java | 10 +- .../core/stacks/EMInstanceStack.java | 61 +- .../elementalMatter/core/stacks/IEMStack.java | 33 +- .../core/transformations/EMDequantizationInfo.java | 56 + .../transformations/EMFluidDequantizationInfo.java | 43 - .../transformations/EMFluidQuantizationInfo.java | 4 +- .../transformations/EMItemDequantizationInfo.java | 45 - .../transformations/EMItemQuantizationInfo.java | 4 +- .../EMOredictDequantizationInfo.java | 60 - .../transformations/EMOredictQuantizationInfo.java | 41 +- .../core/transformations/EMTransformationInfo.java | 165 --- .../transformations/EMTransformationRegistry.java | 134 +++ .../core/transformations/IEMExchangeInfo.java | 11 - .../core/transformations/OreDictionaryStack.java | 19 + .../definitions/complex/EMAtomDefinition.java | 1187 ++++++++++---------- .../definitions/complex/EMHadronDefinition.java | 229 ++-- .../definitions/primitive/EMBosonDefinition.java | 38 +- .../definitions/primitive/EMFermionDefinition.java | 16 + .../primitive/EMGaugeBosonDefinition.java | 83 ++ .../definitions/primitive/EMLeptonDefinition.java | 43 +- .../primitive/EMNeutrinoDefinition.java | 41 +- .../primitive/EMPrimitiveDefinition.java | 50 +- .../definitions/primitive/EMQuarkDefinition.java | 87 +- .../primitive/EMScalarBosonDefinition.java | 46 + .../github/technus/tectech/recipe/TT_recipe.java | 19 +- .../tectech/thing/block/QuantumGlassBlock.java | 2 +- .../tectech/thing/casing/GT_Block_CasingsNH.java | 2 +- .../tectech/thing/casing/GT_Block_CasingsTT.java | 2 +- .../tectech/thing/casing/GT_Block_HintTT.java | 2 +- .../technus/tectech/thing/item/AvrProgrammer.java | 2 +- .../thing/item/ConstructableTriggerItem.java | 2 +- .../item/DebugElementalInstanceContainer_EM.java | 32 +- .../item/ElementalDefinitionContainer_EM.java | 11 +- .../item/ElementalDefinitionScanStorage_EM.java | 2 +- .../technus/tectech/thing/item/EuMeterGT.java | 2 +- .../thing/item/FrontRotationTriggerItem.java | 2 +- .../tectech/thing/item/ParametrizerMemoryCard.java | 2 +- .../tectech/thing/metaTileEntity/Textures.java | 2 +- ...GT_MetaTileEntity_Hatch_ElementalContainer.java | 8 +- .../multi/GT_MetaTileEntity_EM_collider.java | 717 ------------ .../multi/GT_MetaTileEntity_EM_decay.java | 4 +- .../multi/GT_MetaTileEntity_EM_dequantizer.java | 49 +- .../multi/GT_MetaTileEntity_EM_quantizer.java | 11 +- .../multi/GT_MetaTileEntity_EM_scanner.java | 10 +- .../base/GT_MetaTileEntity_MultiblockBase_EM.java | 4 +- .../em_collider/GT_MetaTileEntity_EM_collider.java | 709 ++++++++++++ .../multi/em_collider/IColliderHandler.java | 5 + .../em_collider/IPrimitiveColliderHandler.java | 8 + .../multi/em_machine/Behaviour_Centrifuge.java | 7 +- .../Behaviour_ElectromagneticSeparator.java | 9 +- .../github/technus/tectech/util/DoubleCount.java | 6 + .../java/com/github/technus/tectech/util/Util.java | 12 + src/main/resources/assets/tectech/lang/en_US.lang | 103 +- 91 files changed, 2929 insertions(+), 2703 deletions(-) create mode 100644 src/main/java/com/github/technus/tectech/loader/recipe/BaseRecipeLoader.java delete mode 100644 src/main/java/com/github/technus/tectech/loader/recipe/RecipeLoader.java delete mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMDefinitionsRegistry.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/registry/EMDefinitionsRegistry.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/registry/EMIndirectType.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/registry/EMType.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMDequantizationInfo.java delete mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMFluidDequantizationInfo.java delete mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMItemDequantizationInfo.java delete mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMOredictDequantizationInfo.java delete mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMTransformationInfo.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMTransformationRegistry.java delete mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/IEMExchangeInfo.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/OreDictionaryStack.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMFermionDefinition.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMGaugeBosonDefinition.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMScalarBosonDefinition.java delete mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_collider/GT_MetaTileEntity_EM_collider.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_collider/IColliderHandler.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_collider/IPrimitiveColliderHandler.java (limited to 'src/main/resources') diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index ef5e146bfa..d730d64a65 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -2,6 +2,7 @@ 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.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; @@ -11,6 +12,8 @@ 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.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; @@ -41,7 +44,8 @@ public class TecTech { public static TecTech instance; public static final XSTR RANDOM = XSTR.XSTR_INSTANCE; - public static final LogHelper LOGGER = new LogHelper(Reference.MODID); + public static final LogHelper LOGGER = new LogHelper(Reference.MODID); + public static CreativeTabTecTech creativeTabTecTech; private static IngameErrorLog moduleAdminErrorLogs; public static TecTechConfig configTecTech; @@ -50,6 +54,9 @@ public class TecTech { 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 */ @@ -106,7 +113,7 @@ public class TecTech { Field field= GT_Proxy.class.getDeclaredField("mEvents"); field.setAccessible(true); modifiersField.setInt( field, field.getModifiers() & ~Modifier.FINAL ); - field.set(GT_Mod.gregtechproxy, new Collection() { + field.set(GT_Mod.gregtechproxy, new Collection() { @Override public int size() { return 0; @@ -123,8 +130,8 @@ public class TecTech { } @Override - public Iterator iterator() { - return new Iterator() { + public Iterator iterator() { + return new Iterator() { @Override public boolean hasNext() { return false; @@ -188,13 +195,13 @@ 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()); } 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 00b31915c2..4ebe84147f 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/gtpp/GtppAtomLoader.java b/src/main/java/com/github/technus/tectech/compatibility/gtpp/GtppAtomLoader.java index ee7d293e08..67a363fc6c 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,18 +1,19 @@ package com.github.technus.tectech.compatibility.gtpp; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo; +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.EMTransformationInfo.AVOGADRO_CONSTANT_144; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.EMAtomDefinition.*; +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; @@ -41,14 +42,13 @@ public class GtppAtomLoader implements Runnable{ } //endregion - @Override - public void run() { + public void setTransformations(EMTransformationRegistry transformationInfo) { //region reflect a bit try{ ELEMENT=Class.forName("gtPlusPlus.core.material.ELEMENT"); ELEMENT_INSTANCE=ELEMENT.getMethod("getInstance").invoke(null); - Class clazz=Class.forName("gtPlusPlus.core.material.Material"); + Class clazz=Class.forName("gtPlusPlus.core.material.Material"); getUnlocalizedName=clazz.getMethod("getUnlocalizedName"); getFluid=clazz.getMethod("getFluid", int.class); @@ -59,34 +59,34 @@ public class GtppAtomLoader implements Runnable{ } //endregion - EMTransformationInfo.TRANSFORMATION_INFO.addFluid(new EMDefinitionStack(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); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(32), AVOGADRO_CONSTANT_144), OrePrefixes.dust, getUnlocalizedName("GERMANIUM"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(34), AVOGADRO_CONSTANT_144), OrePrefixes.dust, getUnlocalizedName("SELENIUM"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addFluid(new EMDefinitionStack(getFirstStableIsotope(35), AVOGADRO_CONSTANT_144), getFluid("BROMINE",144)); - EMTransformationInfo.TRANSFORMATION_INFO.addFluid(new EMDefinitionStack(getFirstStableIsotope(36), AVOGADRO_CONSTANT_144), getFluid("KRYPTON",144)); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(40), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("ZIRCONIUM"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(43), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("TECHNETIUM"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(44), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("RUTHENIUM"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(45), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("RHODIUM"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(53), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("IODINE"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addFluid(new EMDefinitionStack(getFirstStableIsotope(54), AVOGADRO_CONSTANT_144),getFluid("XENON",144)); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(72), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("HAFNIUM"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(75), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("RHENIUM"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(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); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getBestUnstableIsotope(84), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("POLONIUM"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getBestUnstableIsotope(85), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("ASTATINE"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getBestUnstableIsotope(87), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("FRANCIUM"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getBestUnstableIsotope(88), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("RADIUM"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getBestUnstableIsotope(89), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("ACTINIUM"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getBestUnstableIsotope(91), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("PROTACTINIUM"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(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); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getBestUnstableIsotope(96), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("CURIUM"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getBestUnstableIsotope(97), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("BERKELIUM"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getBestUnstableIsotope(98), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("CALIFORNIUM"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getBestUnstableIsotope(99), AVOGADRO_CONSTANT_144),OrePrefixes.dust, getUnlocalizedName("EINSTEINIUM"),1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(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/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/entity/projectiles/projectileEM.java b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/entity/projectiles/projectileEM.java index 785b59f093..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 @@ -52,10 +52,10 @@ public class projectileEM extends LaserProjectile { charge=projectileContent.getCharge(); massFactor =(float) (projectileContent.getDefinition().getMass()/ EMHadronDefinition.hadron_n_.getMass()); - if(projectileContent.getDefinition().getMatterType()>1 || projectileContent.getDefinition().getMatterType()<-1) { + if(projectileContent.getDefinition().getGeneration()>1 || projectileContent.getDefinition().getGeneration()<-1) { strange = true; } - if(projectileContent.getDefinition().getMatterType()<0) { + if(projectileContent.getDefinition().getGeneration()<0) { antiMatter = true; } 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 6dc5c4f60a..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 @@ -14,7 +14,7 @@ import openmodularturrets.handler.ConfigHandler; import openmodularturrets.tileentity.turrets.TurretHead; import openmodularturrets.util.TurretHeadUtil; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo.AVOGADRO_CONSTANT; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT; /** * Created by Bass on 27/07/2017. @@ -71,8 +71,8 @@ public class TileTurretHeadEM extends TurretHead{ return new projectileEM(world, TurretHeadUtil.getTurretBase(worldObj, xCoord, yCoord, zCoord), null); } EMInstanceStack stack = hatchContentPointer.getRandom(); - double amount = Math.min(AVOGADRO_CONSTANT, stack.getAmount()); - hatchContentPointer.removeAmount(stack.getDefinition(),AVOGADRO_CONSTANT); + 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); 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/EMComplexAspectDefinition.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMComplexAspectDefinition.java index a062fa0dab..40419604e4 100644 --- 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 @@ -2,24 +2,21 @@ package com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.defi import com.github.technus.tectech.TecTech; import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.transformations.AspectDefinitionCompat; -import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMDefinitionsRegistry; -import com.github.technus.tectech.util.Util; -import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay; -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.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.transformations.EMFluidDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMItemDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMOredictDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMBosonDefinition; -import net.minecraft.nbt.NBTTagCompound; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMIndirectType; +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.Util; import java.util.ArrayList; 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 com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; import static net.minecraft.util.StatCollector.translateToLocal; @@ -30,7 +27,7 @@ public final class EMComplexAspectDefinition extends EMComplexTemplate { private final int hash; private final double mass; - private static final byte nbtType = (byte) 'c'; + private static final String nbtType = "`"; private final EMConstantStackMap aspectStacks; @@ -76,7 +73,7 @@ public final class EMComplexAspectDefinition extends EMComplexTemplate { @Override public String getLocalizedName() { - String name = AspectDefinitionCompat.aspectDefinitionCompat.getAspectTag(this); + String name = AspectDefinitionCompat.aspectDefinitionCompat.getAspectLocalizedName(this); if (name != null) { name = name.substring(0, 1).toUpperCase() + name.substring(1); } else { @@ -124,25 +121,10 @@ public final class EMComplexAspectDefinition extends EMComplexTemplate { } @Override - protected int getIndirectTagValue() { + protected String getIndirectTagValue() { return nbtType; } - public static EMComplexAspectDefinition fromNBT(NBTTagCompound nbt) { - EMDefinitionStack[] stacks = new EMDefinitionStack[nbt.getInteger("i")]; - for (int i = 0; i < stacks.length; i++) { - stacks[i] = EMDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); - } - try { - return new EMComplexAspectDefinition(stacks); - } catch (EMException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return null; - } - } - @Override public double getRawTimeSpan(long currentEnergy) { return -1; @@ -159,12 +141,12 @@ public final class EMComplexAspectDefinition extends EMComplexTemplate { } @Override - public byte getMatterType() { + public int getGeneration() { return 0; } @Override - public byte getColor() { + public int getMaxColors() { return -1; } @@ -175,7 +157,7 @@ public final class EMComplexAspectDefinition extends EMComplexTemplate { @Override public EMDecay[] getEnergyInducedDecay(long energyLevel) { - return new EMDecay[]{new EMDecay(0.75F, aspectStacks), EMBosonDefinition.deadEnd}; + return new EMDecay[]{new EMDecay(0.75F, aspectStacks), deadEnd}; } @Override @@ -218,45 +200,25 @@ public final class EMComplexAspectDefinition extends EMComplexTemplate { return mass; } - @Override - public EMFluidDequantizationInfo someAmountIntoFluidStack() { - return null; - } - - @Override - public EMItemDequantizationInfo someAmountIntoItemsStack() { - return null; - } - - @Override - public EMOredictDequantizationInfo someAmountIntoOredictStack() { - return null; - } - @Override public IEMDefinition getAnti() { return null; } - public static void run() { - try { - EMDefinitionsRegistry.registerDefinitionClass(nbtType, EMComplexAspectDefinition::fromNBT,EMComplexAspectDefinition.class, getClassTypeStatic()); - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } + 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 byte getClassType() { + public int getMatterMassType() { return getClassTypeStatic(); } - public static byte getClassTypeStatic() { + public static int getClassTypeStatic() { return -96; } @@ -275,7 +237,7 @@ public final class EMComplexAspectDefinition extends EMComplexTemplate { @Override public void addScanResults(ArrayList lines, int capabilities, long energyLevel) { if (Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { - lines.add(translateToLocal("tt.keyword.CLASS") + " = " + nbtType + ' ' + getClassType()); + lines.add(translateToLocal("tt.keyword.CLASS") + " = " + nbtType + ' ' + getMatterMassType()); } if (Util.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS, capabilities)) { lines.add(translateToLocal("tt.keyword.NAME") + " = " + getLocalizedName()); @@ -285,7 +247,7 @@ public final class EMComplexAspectDefinition extends EMComplexTemplate { 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")); + lines.add(hasColor() ? 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"); 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 index e62c2e5278..885a71ef28 100644 --- 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 @@ -1,6 +1,9 @@ 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; @@ -10,29 +13,35 @@ import static net.minecraft.util.StatCollector.translateToLocal; */ public final class EMPrimalAspectDefinition extends EMPrimitiveTemplate { public static final EMPrimalAspectDefinition - magic_air = new EMPrimalAspectDefinition(translateToLocal("tt.keyword.Air"), "a`", 1e1D, 35), - magic_earth = new EMPrimalAspectDefinition(translateToLocal("tt.keyword.Earth"), "e`", 1e9D, 34), - magic_fire = new EMPrimalAspectDefinition(translateToLocal("tt.keyword.Fire"), "f`", 1e3D, 33), - magic_water = new EMPrimalAspectDefinition(translateToLocal("tt.keyword.Water"), "w`", 1e7D, 32), - magic_order = new EMPrimalAspectDefinition(translateToLocal("tt.keyword.Order"), "o`", 1e5D, 30), - magic_entropy = new EMPrimalAspectDefinition(translateToLocal("tt.keyword.Entropy"), "e`", 1e5D, 31); + magic_air = new EMPrimalAspectDefinition(translateToLocal("tt.keyword.Air"), "a`", 1e1D, 45,"a`"), + magic_earth = new EMPrimalAspectDefinition(translateToLocal("tt.keyword.Earth"), "e`", 1e9D, 44,"e`"), + magic_fire = new EMPrimalAspectDefinition(translateToLocal("tt.keyword.Fire"), "f`", 1e3D, 43,"f`"), + magic_water = new EMPrimalAspectDefinition(translateToLocal("tt.keyword.Water"), "w`", 1e7D, 42,"w`"), + magic_order = new EMPrimalAspectDefinition(translateToLocal("tt.keyword.Order"), "o`", 1e5D, 40,"o`"), + magic_entropy = new EMPrimalAspectDefinition(translateToLocal("tt.keyword.Chaos"), "c`", 1e5D, 41,"c`"); - private EMPrimalAspectDefinition(String name, String symbol, double mass, int ID) { - super(name, symbol, 0, mass, 0, -1, ID); + 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() { - magic_air.init(null, -1F, -1, -1, NO_DECAY); - magic_earth.init(null, -1F, -1, -1, NO_DECAY); - magic_fire.init(null, -1F, -1, -1, NO_DECAY); - magic_water.init(null, -1F, -1, -1, NO_DECAY); - magic_order.init(null, -1F, -1, -1, NO_DECAY); - magic_entropy.init(null, -1F, -1, -1, NO_DECAY); + 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 getLocalizedName() { - return translateToLocal("tt.keyword.Primal") + ": " + getName(); + String name = AspectDefinitionCompat.aspectDefinitionCompat.getAspectLocalizedName(this); + if (name != null) { + return translateToLocal("tt.keyword.Primal") + ": " + getUnlocalizedName()+" ("+name+")"; + } else { + return translateToLocal("tt.keyword.Primal") + ": " + getUnlocalizedName(); + } } @Override 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 index a4328d2e03..c1c6c6dcb2 100644 --- 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 @@ -2,6 +2,7 @@ package com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.tran 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; @@ -13,12 +14,16 @@ public class AspectDefinitionCompat { private final HashMap defToAspect = new HashMap<>(); private final HashMap aspectToDef = new HashMap<>(); - public void run(){} + 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; } 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 index ead8a5fdef..ccccff7c3d 100644 --- 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 @@ -2,20 +2,20 @@ package com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.tran 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.registry.EMDefinitionsRegistry; import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; import thaumcraft.api.aspects.Aspect; import java.util.ArrayList; import static com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.EMPrimalAspectDefinition.*; -import static com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMDefinitionsRegistry.STACKS_REGISTERED; /** * Created by Tec on 21.05.2017. */ public final class AspectDefinitionCompatEnabled extends AspectDefinitionCompat { @Override - public void run(){ + public void run(EMDefinitionsRegistry registry){ getDefToAspect().put(magic_air,"aer"); getDefToAspect().put(magic_earth,"terra"); getDefToAspect().put(magic_fire,"ignis"); @@ -51,6 +51,7 @@ public final class AspectDefinitionCompatEnabled extends AspectDefinitionCompat } getAspectToDef().put(aspect.getTag(),newAspect); getDefToAspect().put(newAspect,aspect.getTag()); + registry.registerForDisplay(newAspect); }catch (EMException e) { /**/ }finally { @@ -60,7 +61,6 @@ public final class AspectDefinitionCompatEnabled extends AspectDefinitionCompat } } } - STACKS_REGISTERED.addAll(getDefToAspect().keySet()); } @Override @@ -68,6 +68,11 @@ public final class AspectDefinitionCompatEnabled extends AspectDefinitionCompat 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/GT_MetaTileEntity_EM_essentiaDequantizer.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java index dbcbe7d86b..267af79784 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 @@ -26,8 +26,8 @@ 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.EMTransformationInfo.AVOGADRO_CONSTANT; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo.AVOGADRO_CONSTANT_DIMINISHED; +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_ITEM_DIMINISHED; import static com.github.technus.tectech.mechanics.structure.Structure.adders; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; @@ -100,7 +100,7 @@ public class GT_MetaTileEntity_EM_essentiaDequantizer extends GT_MetaTileEntity_ } EMInstanceStack stack = inputHatchContainer.getRandom(); - if (stack.getAmount() < AVOGADRO_CONSTANT_DIMINISHED) { + if (stack.getAmount() < EM_COUNT_PER_ITEM_DIMINISHED) { cleanStackEM_EM(inputHatchContainer.removeKey(stack.getDefinition())); mEUt = (int) -V[6]; } else { @@ -111,7 +111,7 @@ public class GT_MetaTileEntity_EM_essentiaDequantizer extends GT_MetaTileEntity_ cleanStackEM_EM(inputHatchContainer.removeKey(stack.getDefinition())); mEUt = (int) -V[7]; } else { - inputHatchContainer.removeAmount(stack.getDefinition().getStackForm(AVOGADRO_CONSTANT)); + inputHatchContainer.removeAmount(stack.getDefinition().getStackForm(EM_COUNT_PER_MATERIAL_AMOUNT)); if (aspect.isPrimal()) { mEUt = (int) -V[8]; } else { 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 5fe8c973fe..a381a37f89 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 @@ -25,7 +25,7 @@ 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.EMTransformationInfo.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.structure.Structure.adders; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; @@ -90,7 +90,7 @@ public class GT_MetaTileEntity_EM_essentiaQuantizer extends GT_MetaTileEntity_Mu mEfficiencyIncrease = 10000; eAmpereFlow = 1; outputEM = new EMInstanceStackMap[]{ - new EMInstanceStackMap(new EMInstanceStack(definition,AVOGADRO_CONSTANT)) + new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_MATERIAL_AMOUNT)) }; if (definition instanceof EMPrimalAspectDefinition) { mEUt = (int) -V[8]; 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 61989e7b13..773361bd0f 100644 --- a/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java @@ -2,36 +2,33 @@ package com.github.technus.tectech.loader; 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.complex.EMNuclideIAEA; 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 // =================================================================================================== - EMPrimitiveDefinition.run(); + EMPrimitiveDefinition.run(registry); - EMQuarkDefinition.run(); - EMLeptonDefinition.run(); - EMNeutrinoDefinition.run(); - EMBosonDefinition.run(); + EMQuarkDefinition.run(registry); + EMLeptonDefinition.run(registry); + EMNeutrinoDefinition.run(registry); + EMGaugeBosonDefinition.run(registry); + EMScalarBosonDefinition.run(registry); - EMHadronDefinition.run(); + EMHadronDefinition.run(registry); - EMNuclideIAEA.run(); + EMAtomDefinition.run(registry); - EMAtomDefinition.run(); - - EMPrimalAspectDefinition.run(); - - EMComplexAspectDefinition.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 b3c8d24a7c..e2f1e2882f 100644 --- a/src/main/java/com/github/technus/tectech/loader/MainLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/MainLoader.java @@ -8,14 +8,16 @@ import com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity. import com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi.EssentiaCompatEnabled; 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; @@ -43,7 +45,7 @@ import static com.github.technus.tectech.TecTech.*; 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.TecTech.creativeTabTecTech; import static gregtech.api.enums.GT_Values.W; public final class MainLoader { @@ -65,17 +67,17 @@ public final class MainLoader { //set expanded texture arrays for tiers try { - new Textures(); + Textures.run(); }catch (Throwable t){ LOGGER.error("Loading textures...",t); } } - public static void load() { + public static void load(EMDefinitionsRegistry registry) { ProgressManager.ProgressBar progressBarLoad = ProgressManager.push("TecTech Loader", 9); progressBarLoad.step("Elemental Things"); - new ElementalLoader().run(); + new ElementalLoader().run(registry); LOGGER.info("Elemental Init Done"); progressBarLoad.step("Thaumcraft Compatibility"); @@ -120,7 +122,7 @@ public final class MainLoader { ProgressManager.pop(progressBarLoad); } - public static void postLoad() { + public static void postLoad(EMDefinitionsRegistry registry, EMTransformationRegistry transformationInfo) { ProgressManager.ProgressBar progressBarPostLoad = ProgressManager.push("TecTech Post Loader", 6); progressBarPostLoad.step("Dreamcraft Compatibility"); @@ -138,15 +140,11 @@ public final class MainLoader { } progressBarPostLoad.step("Thaumcraft Compatibility"); - if (Loader.isModLoaded(Reference.THAUMCRAFT)) { - aspectDefinitionCompat = new AspectDefinitionCompatEnabled(); - aspectDefinitionCompat.run(); - } else { - aspectDefinitionCompat = new AspectDefinitionCompat(); - } + aspectDefinitionCompat = Loader.isModLoaded(Reference.THAUMCRAFT) ? new AspectDefinitionCompatEnabled() : new AspectDefinitionCompat(); + aspectDefinitionCompat.run(registry); progressBarPostLoad.step("Recipes"); - new RecipeLoader().run(); + new BaseRecipeLoader().run(transformationInfo); TecTech.LOGGER.info("Recipe Init Done"); progressBarPostLoad.step("Register Extra Hazmat Suits"); 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/BaseRecipeLoader.java b/src/main/java/com/github/technus/tectech/loader/recipe/BaseRecipeLoader.java new file mode 100644 index 0000000000..d91d0e5900 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/recipe/BaseRecipeLoader.java @@ -0,0 +1,125 @@ +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.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 cpw.mods.fml.common.Loader; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import static gregtech.api.enums.GT_Values.RA; + +/** + * Created by danie_000 on 16.11.2016. + */ +public class BaseRecipeLoader { + public static Materials getOrDefault(String name,Materials def){ + Materials mat=Materials.get(name); + return mat == Materials._NULL || mat == null ? def : mat; + } + + 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); + } + + //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),}); + + //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 EU reader + GT_ModHandler.addCraftingRecipe(new ItemStack(EuMeterGT.INSTANCE,1), + GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[]{"PGW", "SCW", "BRN", + 'P', OrePrefixes.plateDouble.get(Materials.Steel), + 'G', OrePrefixes.plate.get(Materials.Glass), + 'W', OrePrefixes.cableGt01.get(Materials.Copper), + 'S', OrePrefixes.stick.get(Materials.Brass), + 'C', ItemList.Casing_Coil_Cupronickel.get(1), + 'B', Dyes.dyeBlue, + 'R', Dyes.dyeRed, + 'N', Dyes.dyeBlack,}); + + //Owner detector + GT_ModHandler.addCraftingRecipe(CustomItemList.Machine_OwnerDetector.get(1), + GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[]{"PPP","GEG","PPP", + 'P', OrePrefixes.plate.get(Materials.IronMagnetic), + 'G', OrePrefixes.plate.get(Materials.Glass), + 'E', OrePrefixes.gem.get(Materials.EnderPearl)}); + + //Data reader + GT_ModHandler.addCraftingRecipe(CustomItemList.Machine_DataReader.get(1), + GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[]{"BdB","GES","PwP", + 'B', OrePrefixes.screw.get(Materials.Iridium), + 'P', OrePrefixes.plate.get(Materials.Iridium), + 'G', ItemList.Cover_Screen, + 'S', OrePrefixes.circuit.get(Materials.Elite), + 'E', ItemList.Hull_IV}); + + //Data Bank + RA.addAssemblylineRecipe(ItemList.Hatch_DataAccess_EV.get(1), 20000, new ItemStack[]{ + CustomItemList.Machine_Multi_Switch.get(1), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Master, 2), + ItemList.Tool_DataOrb.get(1), + ItemList.Cover_Screen.get(1), + }, new FluidStack[]{ + new FluidStack(FluidRegistry.getFluid("ic2coolant"), 2000), + Materials.Hydrogen.getGas(1000), + }, CustomItemList.Machine_Multi_DataBank.get(1), 12000, 14000); + //CustomItemList.Machine_Multi_DataBank + + //Bucks + //RA.addAssemblerRecipe(CustomItemList.) + + //recipe for ass line data hatches + RA.addAssemblerRecipe(ItemList.Hatch_DataAccess_EV.get(1), CustomItemList.dataIn_Hatch.get(1), CustomItemList.dataInAss_Hatch.get(1), 2048, 12000); + 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(transformationInfo);//init recipes for GTNH version + } else if (Loader.isModLoaded(Reference.SPARTAKCORE)) { + new SpartakCoreRecipeLoader().run(transformationInfo);//init recipes for SpartakCore version + } else { + 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/recipe/RecipeLoader.java b/src/main/java/com/github/technus/tectech/loader/recipe/RecipeLoader.java deleted file mode 100644 index b5333c8e0d..0000000000 --- a/src/main/java/com/github/technus/tectech/loader/recipe/RecipeLoader.java +++ /dev/null @@ -1,121 +0,0 @@ -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.spartakcore.SpartakCoreRecipeLoader; -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 cpw.mods.fml.common.Loader; -import gregtech.api.enums.Dyes; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - -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); - return mat == Materials._NULL || mat == null ? def : mat; - } - - @Override - public void run() { - EMAtomDefinition.setTransformations(); - EMHadronDefinition.setTransformations(); - - // =================================================================================================== - // 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); - } - - //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),}); - - //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 EU reader - GT_ModHandler.addCraftingRecipe(new ItemStack(EuMeterGT.INSTANCE,1), - GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, - new Object[]{"PGW", "SCW", "BRN", - 'P', OrePrefixes.plateDouble.get(Materials.Steel), - 'G', OrePrefixes.plate.get(Materials.Glass), - 'W', OrePrefixes.cableGt01.get(Materials.Copper), - 'S', OrePrefixes.stick.get(Materials.Brass), - 'C', ItemList.Casing_Coil_Cupronickel.get(1), - 'B', Dyes.dyeBlue, - 'R', Dyes.dyeRed, - 'N', Dyes.dyeBlack,}); - - //Owner detector - GT_ModHandler.addCraftingRecipe(CustomItemList.Machine_OwnerDetector.get(1), - GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, - new Object[]{"PPP","GEG","PPP", - 'P', OrePrefixes.plate.get(Materials.IronMagnetic), - 'G', OrePrefixes.plate.get(Materials.Glass), - 'E', OrePrefixes.gem.get(Materials.EnderPearl)}); - - //Data reader - GT_ModHandler.addCraftingRecipe(CustomItemList.Machine_DataReader.get(1), - GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, - new Object[]{"BdB","GES","PwP", - 'B', OrePrefixes.screw.get(Materials.Iridium), - 'P', OrePrefixes.plate.get(Materials.Iridium), - 'G', ItemList.Cover_Screen, - 'S', OrePrefixes.circuit.get(Materials.Elite), - 'E', ItemList.Hull_IV}); - - //Data Bank - RA.addAssemblylineRecipe(ItemList.Hatch_DataAccess_EV.get(1), 20000, new ItemStack[]{ - CustomItemList.Machine_Multi_Switch.get(1), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Master, 2), - ItemList.Tool_DataOrb.get(1), - ItemList.Cover_Screen.get(1), - }, new FluidStack[]{ - new FluidStack(FluidRegistry.getFluid("ic2coolant"), 2000), - Materials.Hydrogen.getGas(1000), - }, CustomItemList.Machine_Multi_DataBank.get(1), 12000, 14000); - //CustomItemList.Machine_Multi_DataBank - - //Bucks - //RA.addAssemblerRecipe(CustomItemList.) - - //recipe for ass line data hatches - RA.addAssemblerRecipe(ItemList.Hatch_DataAccess_EV.get(1), CustomItemList.dataIn_Hatch.get(1), CustomItemList.dataInAss_Hatch.get(1), 2048, 12000); - 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 - } else if (Loader.isModLoaded(Reference.SPARTAKCORE)) { - new SpartakCoreRecipeLoader().run();//init recipes for SpartakCore version - } else { - new BloodyRecipeLoader().run();//init recipes for NON-GTNH version - } - } -} - 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 b3df7483f5..4dd9d3422d 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,7 +16,7 @@ import cpw.mods.fml.common.Loader; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo.AVOGADRO_CONSTANT; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT; import static com.github.technus.tectech.util.CommonValues.V; import static com.github.technus.tectech.thing.CustomItemList.*; @@ -74,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*AVOGADRO_CONSTANT).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*AVOGADRO_CONSTANT).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*AVOGADRO_CONSTANT).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*AVOGADRO_CONSTANT).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*AVOGADRO_CONSTANT).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*AVOGADRO_CONSTANT).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/mechanics/anomaly/AnomalyHandler.java b/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java index c6ac34b66d..84f8a5e9d6 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 @@ -31,18 +31,18 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo.AVOGADRO_CONSTANT; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo.AVOGADRO_CONSTANT_144; +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; public class AnomalyHandler implements IChunkMetaDataHandler { - private static final double SWAP_THRESHOLD = EMAtomDefinition.getSomethingHeavy().getMass() * 1000D * AVOGADRO_CONSTANT_144;//can be const as it is computed later... + 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"; private static final int MEAN_DELAY =50; - private static final double CANCER_EFFECTIVENESS = 1/AVOGADRO_CONSTANT; - private static final double CHARGE_EFFECTIVENESS = 10/AVOGADRO_CONSTANT; - private static final double CHARGE_EXPLOSIVENESS = 5/AVOGADRO_CONSTANT; + private static final double CANCER_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 ArrayList playersWithCharge = new ArrayList<>(); @@ -133,7 +133,7 @@ public class AnomalyHandler implements IChunkMetaDataHandler { } private void swapSomething(Chunk a,Chunk b,double mass) { - float explosionPower=(float) Math.log(mass/AVOGADRO_CONSTANT); + 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()); 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 index e00e72446d..d607dfad73 100644 --- 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 @@ -19,7 +19,4 @@ public final class EMException extends RuntimeException { public EMException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); } - - public EMException() { - } } 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 index af4caf854b..18f2f76498 100644 --- 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 @@ -1,36 +1,31 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.commands; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +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.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate; import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; 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.EMPrimitiveDefinition.nbtE__; /** * Created by danie_000 on 30.12.2017. */ public class EMGive implements ICommand { - ArrayList aliases=new ArrayList<>(); + ArrayList aliases = new ArrayList<>(); - public EMGive(){ + public EMGive() { aliases.add("em_give"); aliases.add("give_em"); aliases.add("gib_em"); @@ -39,27 +34,24 @@ public class EMGive implements ICommand { @Override public void processCommand(ICommandSender sender, String[] args) { if (sender instanceof EntityPlayerMP && !sender.getEntityWorld().isRemote) { - if(args.length < 3) { + if (args.length < 3) { sender.addChatMessage(new ChatComponentText(getCommandUsage(sender))); - }else{ - TecTech.LOGGER.info("Spawninig EM for "+((EntityPlayerMP) sender).getDisplayName()+" - "+Arrays.toString(args)); + } else { + TecTech.LOGGER.info("Spawninig EM for " + ((EntityPlayerMP) sender).getDisplayName() + " - " + Arrays.toString(args)); - ArrayList list = new ArrayList<>(Arrays.asList(args)); - String energy=list.remove(0); + ArrayList list = new ArrayList<>(Arrays.asList(args)); + String energy = list.remove(0); - EMDefinitionStack def = getDefinitionStack(list); - if(def!=null) { - EMInstanceStack instanceStack = new EMInstanceStack(def, 1D, 0D, Long.parseLong(energy)); + 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); - NBTTagCompound contents = new NBTTagCompound(); - contents.setTag("info", instanceMap.getInfoNBT()); - contents.setTag("content", instanceMap.toNBT()); - itemStack.setTagCompound(contents); + DebugElementalInstanceContainer_EM.INSTANCE.setContent(itemStack, instanceMap); ((EntityPlayerMP) sender).inventory.addItemStackToInventory(itemStack); } @@ -67,40 +59,45 @@ public class EMGive implements ICommand { } } - private EMDefinitionStack getDefinitionStack(ArrayList args){ - if(args.get(0).equals("<")){ - args.remove(0); + private EMDefinitionStack getDefinitionStack(EMDefinitionsRegistry registry, ArrayList args) { + double amount; + if (args.size() == 0) { return null; } - double amount=Double.parseDouble(args.remove(0)); - try{ - int id=Integer.parseInt(args.get(0)); - args.remove(0); - IEMDefinition primitive = IEMDefinition.getBindsPrimitive().get(id); - return new EMDefinitionStack(primitive,amount); - }catch (NumberFormatException e){ - byte clazz = (byte) args.remove(0).charAt(0); - Method constructor = IEMDefinition.getBindsComplex().get(clazz); - - EMDefinitionStackMap stacks =new EMDefinitionStackMap(); - while(args.size()>0){ - EMDefinitionStack tempStack =getDefinitionStack(args); - if(tempStack==null) { - break; - }else { - stacks.putUnifyExact(tempStack); - } + String defTag = args.remove(0); + if ("<".equals(defTag)) { + return null; + } + try { + amount = Double.parseDouble(defTag); + if (args.size() == 0) { + return null; } - - try { - return ((IEMDefinition) constructor.invoke(null, stacks.toNBT())).getStackForm(amount); - } catch (Exception e1) { - if (DEBUG_MODE) { - e.printStackTrace(); + 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 nbtE__.getStackForm(amount); } + return emIndirectType.create(registry, stacks.toNBT(registry)).getStackForm(amount); } + return null; } @Override @@ -120,33 +117,20 @@ public class EMGive implements ICommand { @Override public List addTabCompletionOptions(ICommandSender sender, String[] args) { - if(args.length==2){ - return completionsForClassOrID(); + if (args.length > 1 && args.length % 2 == 0) { + return new ArrayList<>(TecTech.definitionsRegistry.getBinds().keySet()); } return null; } - private List completionsForClassOrID(){ - ArrayList strings=new ArrayList<>(8); - Map binds= IEMDefinition.getBindsComplex(); - for (Map.Entry e:binds.entrySet()) { - strings.add(String.valueOf((char)e.getKey().byteValue())); - } - Map bindsBO = IEMDefinition.getBindsPrimitive(); - for (Map.Entry 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 ... <)"; + return "em_give Energy Count ClassOrId ( (Count ClassOrId ... <) ...<)"; } @Override public int compareTo(Object o) { - if(o instanceof ICommand){ + if (o instanceof ICommand) { return getCommandName().compareTo(((ICommand) o).getCommandName()); } return 0; 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 index 13531dbf85..90eddf1e23 100644 --- 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 @@ -1,15 +1,15 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.commands; -import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate; -import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMType; +import com.github.technus.tectech.util.Util; 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; +import java.util.stream.Collectors; /** * Created by danie_000 on 30.12.2017. @@ -26,27 +26,32 @@ public class EMList implements ICommand { public void processCommand(ICommandSender sender, String[] args) { if (!sender.getEntityWorld().isRemote) { if(args.length == 0) { - sender.addChatMessage(new ChatComponentText(" Available Classes: tag - name")); - Map binds= IEMDefinition.getBindsComplex(); - for (Map.Entry 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) EMPrimitiveTemplate.nbtType))){ - Map bindsBO = IEMDefinition.getBindsPrimitive(); - for (Map.Entry e:bindsBO.entrySet()) { - sender.addChatMessage(new ChatComponentText(e.getKey() + " - "+e.getValue().getLocalizedName())); - } - }else{ - sender.addChatMessage(new ChatComponentText("Complex definition - needs contents")); - } - }else{ - sender.addChatMessage(new ChatComponentText(getCommandUsage(sender))); + listClasses(sender); + }else { + listDefinitions(sender, Util.getConcated(args," ")); } } } + private void listDefinitions(ICommandSender sender, String arg) { + sender.addChatMessage(new ChatComponentText(" Available Direct: tag - name symbol")); + for (EMType directType : TecTech.definitionsRegistry.getDirectTypes().values()) { + if ("*".equals(arg) || arg.equalsIgnoreCase(directType.getLocalizedName())) { + 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 name 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; @@ -65,19 +70,14 @@ public class EMList implements ICommand { @Override public List addTabCompletionOptions(ICommandSender sender, String[] args) { if(args.length==0){ - Map binds= IEMDefinition.getBindsComplex(); - ArrayList strings=new ArrayList<>(binds.size()); - for (Map.Entry e:binds.entrySet()) { - strings.add(String.valueOf((char)e.getKey().byteValue())+' '+e.getValue().getReturnType().getSimpleName()); - } - return strings; + return TecTech.definitionsRegistry.getDirectTypes().values().stream().map(EMType::getLocalizedName).collect(Collectors.toList()); } return null; } @Override public String getCommandUsage(ICommandSender p_71518_1_) { - return "em_list (optional class tag)"; + return "em_list (optional Direct Name or *)"; } @Override 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 index 94a50ce322..13838cf443 100644 --- 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 @@ -1,5 +1,6 @@ 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; @@ -29,11 +30,6 @@ public abstract class EMComplexTemplate implements IEMDefinition { return getSubParticles().compareWithAmountsInternal(o.getSubParticles()); } - @Override - public final EMDefinitionStack getStackForm(double amount) { - return new EMDefinitionStack(this, amount); - } - @Override public final boolean equals(Object obj) { if(this==obj) { @@ -50,24 +46,22 @@ public abstract class EMComplexTemplate implements IEMDefinition { @Override public int hashCode() {//Internal amounts should be also hashed - int hash = -(getSubParticles().size() << 4); + int hash = -(getSubParticles().size() << 16); for (EMDefinitionStack stack : getSubParticles().valuesToArray()) { int amount=(int) stack.getAmount(); - hash += ((amount & 0x1) == 0 ? -amount : amount) + stack.getDefinition().hashCode(); + hash += ((amount & 0x1) == 0 ? -amount : amount) * (stack.getDefinition().hashCode()<<4); } return hash; } @Override public String toString() { - return getLocalizedName()+ '\n' + getSymbol(); + return getLocalizedName()+ " " + getSymbol(); } - public NBTTagCompound toNBT() { - NBTTagCompound nbtTagCompound = getSubParticles().toNBT(); - nbtTagCompound.setInteger(EMDefinitionsRegistry.getIndirectTagName(), getIndirectTagValue()); - return nbtTagCompound; + public NBTTagCompound toNBT(EMDefinitionsRegistry registry) { + return registry.indirectToNBT(getIndirectTagValue(),getSubParticles()); } - protected abstract int getIndirectTagValue(); + protected abstract String getIndirectTagValue(); } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMDefinitionsRegistry.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMDefinitionsRegistry.java deleted file mode 100644 index c0f9df32f2..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/definitions/EMDefinitionsRegistry.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core.definitions; - -import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.*; -import java.util.function.Function; - -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 NavigableSet STACKS_REGISTERED = new TreeSet<>(); - private static final Map DIRECT_BINDS = new HashMap<>(); - private static final Map> CLASS_BINDS = new HashMap<>();//creator methods in subclasses - private static final Map> CLASSES = new HashMap<>(); - private static final Map, Integer> CLASS_TYPES = new HashMap<>(); - private static final String INDIRECT_TAG = "t"; - private static final String DIRECT_TAG = "c"; - - private EMDefinitionsRegistry() { - } - - static { - CLASS_BINDS.put(0, EMDefinitionsRegistry::getDefinitionDirect); - CLASS_BINDS.put((int) 'p', EMDefinitionsRegistry::getDefinitionDirect); - } - - private static IEMDefinition getDefinitionDirect(NBTTagCompound nbt) { - return DIRECT_BINDS.get(nbt.getInteger(getDirectTagName())); - } - - public static IEMDefinition fromNBT(NBTTagCompound nbt) { - IEMDefinition apply; - try { - apply = CLASS_BINDS.get(nbt.getInteger(getIndirectTagName())).apply(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 (apply == nbtE__) { - throw new EMException("Deserialized to NBT ERROR!"); - } else if (apply == null__ || apply == null) { - throw new EMException("Deserialized to NULL POINTER!"); - } - } - if (apply == null) { - return null__; - } - return apply; - } - - public static void registerDefinitionClass(int shortcutNBT, Function creator, Class clazz, int classID) { - if (CLASS_BINDS.put(shortcutNBT, creator) != null) { - EMException e = new EMException("Duplicate NBT shortcut! " + shortcutNBT + " used for NBT based creation"); - if (DEBUG_MODE) { - e.printStackTrace(); - } else { - throw e; - } - } - if (CLASSES.put(classID, clazz) != null) { - EMException e = new EMException("Duplicate Class ID! " + classID + " used for class comparison"); - if (DEBUG_MODE) { - e.printStackTrace(); - } else { - throw e; - } - } - CLASS_TYPES.put(clazz, classID); - } - - public static void registerDirectDefinition(IEMDefinition definition, int id) { - IEMDefinition old = DIRECT_BINDS.put(id, definition); - if (old != null) { - EMException e = new EMException("Duplicate primitive EM ID: " + id + - " for " + definition.getLocalizedName() + - " and " + old.getLocalizedName()); - if (DEBUG_MODE) { - e.printStackTrace(); - } else { - throw e; - } - } - } - - public static NavigableSet getStacksRegisteredForDisplay() { - return STACKS_REGISTERED; - } - - public static void registerForDisplay(IEMDefinition definition){ - STACKS_REGISTERED.add(definition); - STACKS_REGISTERED.add(definition.getAnti()); - } - - public static String getIndirectTagName() { - return INDIRECT_TAG; - } - - public static String getDirectTagName() { - return DIRECT_TAG; - } -} 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 index b529b79cc0..0f25d73704 100644 --- 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 @@ -2,10 +2,8 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.definitions; 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.registry.EMDefinitionsRegistry; import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMFluidDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMItemDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMOredictDequantizationInfo; import net.minecraft.nbt.NBTTagCompound; import java.util.ArrayList; @@ -25,41 +23,43 @@ public abstract class EMPrimitiveTemplate extends EMComplexTemplate { //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 byte color; + private final int color; //-1/-2/-3 anti matter generations, +1/+2/+3 matter generations, 0 self anti - private final byte type; + private final int generation; - private EMPrimitiveTemplate anti;//IMMUTABLE + 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 type, double mass, int charge, int color, int ID) { + 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.type = (byte) type; + this.generation = generation; this.mass = mass; this.charge = charge; - this.color = (byte) color; + this.color = color; this.ID = ID; - EMDefinitionsRegistry.registerDirectDefinition(this,ID); + this.bind=bind; } // - protected void init(EMPrimitiveTemplate antiParticle, double rawLifeTime, int naturalInstant, int energeticInstant, EMDecay... elementalDecaysArray) { + 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; - EMDefinitionsRegistry.registerForDisplay(this); + registry.registerForDisplay(this); + registry.registerDirectDefinition(bind,this); } @Override @@ -83,7 +83,7 @@ public abstract class EMPrimitiveTemplate extends EMComplexTemplate { } @Override - public byte getColor() { + public int getMaxColors() { return color; } @@ -153,44 +153,27 @@ public abstract class EMPrimitiveTemplate extends EMComplexTemplate { } @Override - public EMFluidDequantizationInfo someAmountIntoFluidStack() { - return null; - } - - @Override - public EMItemDequantizationInfo someAmountIntoItemsStack() { - return null; - } - - @Override - public EMOredictDequantizationInfo someAmountIntoOredictStack() { - return null; - } - - @Override - public byte getMatterType() { - return type; + public int getGeneration() { + return generation; } @Override - public final NBTTagCompound toNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setInteger(EMDefinitionsRegistry.getDirectTagName(), ID); - return nbt; + public final NBTTagCompound toNBT(EMDefinitionsRegistry registry) { + return registry.directToNBT(bind); } @Override - protected final int getIndirectTagValue() { + protected final String getIndirectTagValue() { throw new EMException("This class should only be used directly!"); } @Override - public final byte getClassType() { + public final int getMatterMassType() { return getClassTypeStatic(); } - public static byte getClassTypeStatic(){ - return -128; + public static int getClassTypeStatic(){ + return Short.MIN_VALUE; } @Override @@ -203,7 +186,7 @@ public abstract class EMPrimitiveTemplate extends EMComplexTemplate { @Override public void addScanResults(ArrayList lines, int capabilities, long energyLevel) { if(areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { - lines.add("CLASS = " + EMDefinitionsRegistry.getDirectTagName() + ' ' + getClassType()); + lines.add("DIRECT = " + bind + ' ' + getMatterMassType()); } if(areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { lines.add("NAME = "+ getLocalizedName()); @@ -213,7 +196,7 @@ public abstract class EMPrimitiveTemplate extends EMComplexTemplate { lines.add("CHARGE = " + getCharge() / 3D + " e"); } if(areBitsSet(SCAN_GET_COLOR,capabilities)) { - lines.add(getColor() < 0 ? "COLORLESS" : "CARRIES COLOR"); + lines.add(hasColor() ? "COLORLESS" : "CARRIES COLOR"); } if(areBitsSet(SCAN_GET_MASS,capabilities)) { lines.add("MASS = " + getMass() + " eV/c\u00b2"); @@ -226,7 +209,7 @@ public abstract class EMPrimitiveTemplate extends EMComplexTemplate { @Override public final int compareTo(IEMDefinition o) { - if (getClassType() == o.getClassType()) { + if (getMatterMassType() == o.getMatterMassType()) { int oID = ((EMPrimitiveTemplate) o).ID; return Integer.compare(ID, oID); } @@ -238,7 +221,7 @@ public abstract class EMPrimitiveTemplate extends EMComplexTemplate { return ID; } - public String getName() { + 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 index 06bfc61737..8125812dc6 100644 --- 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 @@ -1,11 +1,9 @@ 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.mechanics.elementalMatter.core.transformations.EMFluidDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMItemDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMOredictDequantizationInfo; import net.minecraft.nbt.NBTTagCompound; import java.util.ArrayList; @@ -31,9 +29,9 @@ public interface IEMDefinition extends Comparable,Cloneable {//IM void addScanResults(ArrayList lines, int capabilities, long energyLevel); - byte getMatterType(); + int getMatterMassType();//bigger number means bigger things usually, but it is just used to differentiate between classes of iED - byte getClassType();//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 @@ -59,7 +57,11 @@ public interface IEMDefinition extends Comparable,Cloneable {//IM int getCharge();//charge 1/3 electron charge //dynamically changing stuff - byte getColor();//-1 nope cannot 0 it can but undefined + int getMaxColors(); + + default boolean hasColor(){ + return getMaxColors()>0; + } double getRawTimeSpan(long currentEnergy);//defined in static fields or generated @@ -67,19 +69,17 @@ public interface IEMDefinition extends Comparable,Cloneable {//IM EMConstantStackMap getSubParticles();//contents... null if none - EMFluidDequantizationInfo someAmountIntoFluidStack(); - - EMItemDequantizationInfo someAmountIntoItemsStack(); - - EMOredictDequantizationInfo someAmountIntoOredictStack(); + NBTTagCompound toNBT(EMDefinitionsRegistry registry); - NBTTagCompound toNBT(); - - EMDefinitionStack getStackForm(double amount); + default EMDefinitionStack getStackForm(double amount){ + return new EMDefinitionStack(this,amount); + } - IEMDefinition clone(); + default IEMDefinition clone(){ + return this; + } default int compareClassID(IEMDefinition obj) { - return (int) getClassType() - obj.getClassType(); + 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 stacksRegistered = new TreeSet<>(); + + private final Map hashMap = new HashMap<>(); + private final Map hashMapR = Collections.unmodifiableMap(hashMap); + + private final Map, EMType> types = new HashMap<>(); + private final Map, EMType> typesR = Collections.unmodifiableMap(types); + private final Map, EMType> directTypes = new HashMap<>(); + private final Map, EMType> directTypesR = Collections.unmodifiableMap(directTypes); + private final Map, EMIndirectType> indirectTypes = new HashMap<>(); + private final Map, EMIndirectType> indirectTypesR = Collections.unmodifiableMap(indirectTypes); + + private final Map binds = new HashMap<>(); + private final Map bindsR = Collections.unmodifiableMap(binds); + private final Map directBinds = new HashMap<>(); + private final Map directBindsR = Collections.unmodifiableMap(directBinds); + private final Map indirectBinds = new HashMap<>(); + private final Map 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 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 getHashMapping() { + return hashMapR; + } + + public NavigableSet getStacksRegisteredForDisplay() { + return stacksRegistered; + } + + public Map getBinds() { + return bindsR; + } + + public Map getDirectBinds() { + return directBindsR; + } + + public Map getIndirectBinds() { + return indirectBindsR; + } + + public Map, EMType> getTypes() { + return typesR; + } + + public Map, EMType> getDirectTypes() { + return directTypesR; + } + + public Map, 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 creator; + + public EMIndirectType(BiFunction creator, Class clazz, String unlocalizedName) { + super(clazz, unlocalizedName); + this.creator = creator; + } + + protected BiFunction 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 definitions = new HashMap<>(); + private final Map definitionsR = Collections.unmodifiableMap(definitions); + private final Class clazz; + private final String unlocalizedName; + + public EMType(Class clazz, String unlocalizedName) { + this.clazz = clazz; + this.unlocalizedName = unlocalizedName; + } + + public Class 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 getDefinitions() { + return definitionsR; + } +} 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 index e6cfa7d03e..f6bef9910e 100644 --- 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 @@ -1,5 +1,6 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.maps; +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.EMException; import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; @@ -45,10 +46,10 @@ public final class EMConstantStackMap/*IMMUTABLE*/ extends EMStackMap(getBackingMap())); } - public static EMConstantStackMap fromNBT(NBTTagCompound nbt) throws EMException { + public static EMConstantStackMap fromNBT(EMDefinitionsRegistry registry, NBTTagCompound nbt) throws EMException { EMDefinitionStack[] defStacks = new EMDefinitionStack[nbt.getInteger("i")]; for (int i = 0; i < defStacks.length; i++) { - defStacks[i] = EMDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); + defStacks[i] = EMDefinitionStack.fromNBT(registry,nbt.getCompoundTag(Integer.toString(i))); if (defStacks[i].getDefinition().equals(nbtE__)) { throw new EMException("Something went Wrong"); } 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 index 78bb8d740a..57b8f7bf1c 100644 --- 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 @@ -1,5 +1,6 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.maps; +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.EMException; import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; @@ -43,10 +44,10 @@ public final class EMDefinitionStackMap extends EMStackMap im return new EMConstantStackMap(getBackingMap()); } - public static EMDefinitionStackMap fromNBT(NBTTagCompound nbt) throws EMException { + public static EMDefinitionStackMap fromNBT(EMDefinitionsRegistry registry, NBTTagCompound nbt) throws EMException { EMDefinitionStack[] defStacks = new EMDefinitionStack[nbt.getInteger("i")]; for (int i = 0; i < defStacks.length; i++) { - defStacks[i] = EMDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); + defStacks[i] = EMDefinitionStack.fromNBT(registry,nbt.getCompoundTag(Integer.toString(i))); if (defStacks[i].getDefinition().equals(nbtE__)) { throw new EMException("Something went Wrong"); } 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 index 69dc53f83d..64ff7063e8 100644 --- 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 @@ -1,10 +1,12 @@ 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.EMException; -import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; @@ -13,9 +15,10 @@ import java.util.Map; import java.util.NavigableMap; import java.util.TreeMap; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo.AVOGADRO_CONSTANT; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.AVOGADRO_CONSTANT; import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMPrimitiveDefinition.nbtE__; import static com.github.technus.tectech.util.DoubleCount.add; +import static net.minecraft.util.StatCollector.translateToLocal; /** * Created by danie_000 on 22.01.2017. @@ -91,7 +94,7 @@ public final class EMInstanceStackMap extends EMStackMap implem for (EMInstanceStack instance : getBackingMap().values()) { info[i++] = EnumChatFormatting.BLUE + instance.getDefinition().getLocalizedName()+ " "+ EnumChatFormatting.AQUA + instance.getDefinition().getSymbol()+ EnumChatFormatting.RESET+ - " #: " + EnumChatFormatting.GREEN + String.format("%.3E", instance.getAmount() / AVOGADRO_CONSTANT) +" mol"+ EnumChatFormatting.RESET+ + " #: " + EnumChatFormatting.GREEN + String.format("%.3E", instance.getAmount() /AVOGADRO_CONSTANT) +" "+translateToLocal("tt.keyword.mol")+ EnumChatFormatting.RESET+ " E: " + EnumChatFormatting.GREEN + instance.getEnergy() + EnumChatFormatting.RESET+ " T: " + EnumChatFormatting.GREEN + (instance.getLifeTime()<0?"STABLE":String.format("%.3E",instance.getLifeTime())); } @@ -120,16 +123,15 @@ public final class EMInstanceStackMap extends EMStackMap implem } public double tickContent(double lifeTimeMult, int postEnergize, double seconds){ - cleanUp(); + //cleanUp(); double diff=0; - for (EMInstanceStack instance : valuesToArray()) { + for (EMInstanceStack instance : takeAllToArray()) { instance.setAge(instance.getAge() + seconds); EMDecayResult newInstances = instance.decay(lifeTimeMult, instance.getAge(), postEnergize); if (newInstances == null) { - instance.nextColor(); + putUnify(instance); } else { diff=add(diff,newInstances.getMassDiff()); - removeAmount(instance);//todo check maybe this should be removeKey putUnifyAll(newInstances.getOutput()); } } @@ -157,10 +159,10 @@ public final class EMInstanceStackMap extends EMStackMap implem return nbt; } - public static EMInstanceStackMap fromNBT(NBTTagCompound nbt) throws EMException { + public static EMInstanceStackMap fromNBT(EMDefinitionsRegistry registry, NBTTagCompound nbt) throws EMException { EMInstanceStack[] instances = new EMInstanceStack[nbt.getInteger("i")]; for (int i = 0; i < instances.length; i++) { - instances[i] = EMInstanceStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); + instances[i] = EMInstanceStack.fromNBT(registry,nbt.getCompoundTag(Integer.toString(i))); if (instances[i].getDefinition().equals(nbtE__)) { throw new EMException("Something went Wrong"); } @@ -188,6 +190,12 @@ public final class EMInstanceStackMap extends EMStackMap implem return build.toString(); } + public EMInstanceStack[] takeAllToArray(){ + EMInstanceStack[] newStack = valuesToArray();//just in case to uncouple The map + this.getBackingMap().clear(); + return newStack; + } + public EMInstanceStackMap takeAll(){ EMInstanceStackMap newStack =new EMInstanceStackMap(false,new TreeMap<>(this.getBackingMap()));//just in case to uncouple The map this.getBackingMap().clear(); @@ -212,7 +220,7 @@ public final class EMInstanceStackMap extends EMStackMap implem return stack; } double newAmount = add(target.getAmount(), stack.getAmount()); - if (IEMMapRead.isValidAmount(newAmount)) { + if (IEMStack.isValidAmount(newAmount)) { stack=target.unifyIntoThis(stack); putReplace(stack); return stack; @@ -230,7 +238,7 @@ public final class EMInstanceStackMap extends EMStackMap implem return stack; } double newAmount = target.getAmount()+stack.getAmount(); - if (IEMMapRead.isValidAmount(newAmount)) { + if (IEMStack.isValidAmount(newAmount)) { stack=target.unifyIntoThis(stack); putReplace(stack); return stack; 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 index 1322566914..c0420fa2b2 100644 --- 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 @@ -1,6 +1,7 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.maps; import com.github.technus.tectech.TecTech; +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.mechanics.elementalMatter.core.definitions.IEMDefinition; import net.minecraft.nbt.NBTTagCompound; @@ -9,18 +10,11 @@ import net.minecraft.util.EnumChatFormatting; import java.lang.reflect.Array; import java.util.*; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo.*; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry.*; import static com.github.technus.tectech.util.DoubleCount.ulpSigned; +import static net.minecraft.util.StatCollector.translateToLocal; public interface IEMMapRead extends Comparable>, Cloneable { - static boolean isValidAmount(double amount){ - return amount>=AVOGADRO_CONSTANT_UNCERTAINTY; - } - - static boolean isInvalidAmount(double amount){ - return amount getBackingMap(); IEMMapRead clone(); @@ -105,7 +99,7 @@ public interface IEMMapRead extends Comparable for (T defStack : values()) { info[i] = EnumChatFormatting.BLUE + defStack.getDefinition().getLocalizedName(); info[i + 1] = EnumChatFormatting.AQUA + defStack.getDefinition().getSymbol(); - info[i + 2] = "Amount " + EnumChatFormatting.GREEN + defStack.getAmount()/AVOGADRO_CONSTANT; + info[i + 2] = "Amount " + EnumChatFormatting.GREEN + defStack.getAmount()/AVOGADRO_CONSTANT+" "+translateToLocal("tt.keyword.mol"); i += 3; } return info; @@ -132,12 +126,12 @@ public interface IEMMapRead extends Comparable return nbt; } - default NBTTagCompound toNBT() { + default NBTTagCompound toNBT(EMDefinitionsRegistry registry) { NBTTagCompound nbt = new NBTTagCompound(); nbt.setInteger("i", size()); int i = 0; for (Map.Entry entry : entrySet()) { - nbt.setTag(Integer.toString(i++), entry.getValue().toNBT()); + nbt.setTag(Integer.toString(i++), entry.getValue().toNBT(registry)); } return nbt; } @@ -265,7 +259,7 @@ public interface IEMMapRead extends Comparable } default boolean containsAmount(IEMDefinition def, double amountToConsume) { - double amountRequired=amountToConsume-AVOGADRO_CONSTANT_EPSILON; + double amountRequired=amountToConsume- EM_COUNT_EPSILON; if(amountRequired==amountToConsume){ amountRequired-=ulpSigned(amountRequired); } 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 index f13e82fb26..15815f2ee0 100644 --- 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 @@ -2,11 +2,11 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.maps; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo; +import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationRegistry; import java.util.Map; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo.AVOGADRO_CONSTANT_EPSILON; +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 extends IEMMapWriteExact { @@ -15,11 +15,11 @@ public interface IEMMapWrite extends IEMMapWriteExact { /** * Consumes amount from map * @param def def to consume - * @param amountToConsume should be comparable to {@link EMTransformationInfo#AVOGADRO_CONSTANT} + * @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-AVOGADRO_CONSTANT_EPSILON; + double amountRequired=amountToConsume- EM_COUNT_EPSILON; if(amountRequired==amountToConsume){ amountRequired-=ulpSigned(amountRequired); } @@ -31,7 +31,7 @@ public interface IEMMapWrite extends IEMMapWriteExact { if(current!=null){ if(current.getAmount()>=amountRequired){ double newAmount=sub(current.getAmount(),amountToConsume); - if(IEMMapRead.isValidAmount(current.getAmount())){ + if(IEMStack.isValidAmount(newAmount)){ current=(T)current.mutateAmount(newAmount); getBackingMap().put(current.getDefinition(),current); }else { @@ -88,7 +88,7 @@ public interface IEMMapWrite extends IEMMapWriteExact { return stack; } double newAmount = add(target.getAmount(), stack.getAmount()); - if (IEMMapRead.isValidAmount(newAmount)) { + if (IEMStack.isValidAmount(newAmount)) { stack=(T) target.mutateAmount(newAmount); putReplace(stack); return stack; 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 index 167ec8451d..9da971944c 100644 --- 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 @@ -7,7 +7,7 @@ import java.util.Map; public interface IEMMapWriteExact extends IEMMapRead { default void cleanUp(){ - entrySet().removeIf(entry -> IEMMapRead.isInvalidAmount(entry.getValue().getAmount())); + entrySet().removeIf(entry -> entry.getValue().isInvalidAmount()); } default void clear() { @@ -95,7 +95,7 @@ public interface IEMMapWriteExact extends IEMMapRead { if(current!=null){ double newAmount=current.getAmount()-amountToConsume; if(newAmount>=0){ - if(IEMMapRead.isValidAmount(current.getAmount())){ + if(current.isValidAmount()){ current=(T)current.mutateAmount(newAmount); getBackingMap().put(current.getDefinition(),current); } else { @@ -142,7 +142,7 @@ public interface IEMMapWriteExact extends IEMMapRead { return stack; } double newAmount = target.getAmount()+stack.getAmount(); - if (IEMMapRead.isValidAmount(newAmount)) { + if (IEMStack.isValidAmount(newAmount)) { stack=(T) target.mutateAmount(newAmount); putReplace(stack); return stack; 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 index f868dbe0ad..c1e6a729f8 100644 --- 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 @@ -1,6 +1,6 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.stacks; -import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMDefinitionsRegistry; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry; import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; import net.minecraft.nbt.NBTTagCompound; @@ -41,16 +41,16 @@ public final class EMDefinitionStack implements IEMStack { return amount; } - public NBTTagCompound toNBT() { + public NBTTagCompound toNBT(EMDefinitionsRegistry registry) { NBTTagCompound nbt = new NBTTagCompound(); - nbt.setTag("d", getDefinition().toNBT()); + nbt.setTag("d", getDefinition().toNBT(registry)); nbt.setDouble("Q", getAmount()); return nbt; } - public static EMDefinitionStack fromNBT(NBTTagCompound nbt) { + public static EMDefinitionStack fromNBT(EMDefinitionsRegistry registry,NBTTagCompound nbt) { return new EMDefinitionStack( - EMDefinitionsRegistry.fromNBT(nbt.getCompoundTag("d")), + registry.fromNBT(nbt.getCompoundTag("d")), nbt.getLong("q")+nbt.getDouble("Q")); } 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 index 6347cd2144..b67d2ce121 100644 --- 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 @@ -1,12 +1,12 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.stacks; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMDefinitionsRegistry; 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.mechanics.elementalMatter.core.definitions.IEMDefinition; import com.github.technus.tectech.util.Util; import net.minecraft.client.Minecraft; import net.minecraft.crash.CrashReport; @@ -14,19 +14,22 @@ import net.minecraft.nbt.NBTTagCompound; import java.util.ArrayList; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo.AVOGADRO_CONSTANT; +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.mechanics.elementalMatter.definitions.primitive.EMBosonDefinition.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.*; +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 = AVOGADRO_CONSTANT;//todo + public static double DECAY_CALL_PER = EM_COUNT_PER_MATERIAL_AMOUNT;//todo private final IEMDefinition definition; private double amount; @@ -35,7 +38,7 @@ public final class EMInstanceStack implements IEMStack { //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; + private int color; private double lifeTime; private double lifeTimeMult; @@ -53,11 +56,10 @@ public final class EMInstanceStack implements IEMStack { public EMInstanceStack(IEMDefinition defSafe, double amount, double lifeTimeMult, double age, long energy) { definition = defSafe == null ? null__ : defSafe; - byte bColor = getDefinition().getColor(); - if (bColor < 0 || bColor > 2) {//transforms colorable??? into proper color - this.color = bColor; - } else { - this.color = (byte) TecTech.RANDOM.nextInt(3); + 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; @@ -119,11 +121,11 @@ public final class EMInstanceStack implements IEMStack { return definition; } - public byte getColor() { + public int getColor() { return color; } - public void setColor(byte color) {//does not allow changing magic element + public void setColor(int color) {//does not allow changing magic element if (this.color < 0 || this.color > 2 || color < 0 || color >= 3) { return; } @@ -131,10 +133,9 @@ public final class EMInstanceStack implements IEMStack { } public void nextColor() {//does not allow changing magic element - if (color < 0 || color > 2) { - return; + if (definition.hasColor()) { + color = (byte) TecTech.RANDOM.nextInt(definition.getMaxColors()); } - color = (byte) TecTech.RANDOM.nextInt(3); } public double getLifeTime() { @@ -524,7 +525,7 @@ public final class EMInstanceStack implements IEMStack { lines.add("ENERGY = " + energy); } if (Util.areBitsSet(SCAN_GET_AMOUNT, capabilities)) { - lines.add("AMOUNT = " + getAmount() / AVOGADRO_CONSTANT + " mol"); + lines.add("AMOUNT = " + getAmount() /AVOGADRO_CONSTANT + " "+translateToLocal("tt.keyword.mol")); } scanContents(lines, getDefinition().getSubParticles(), 1, detailsOnDepthLevels); } @@ -546,25 +547,25 @@ public final class EMInstanceStack implements IEMStack { } } - public NBTTagCompound toNBT() { + public NBTTagCompound toNBT(EMDefinitionsRegistry registry) { NBTTagCompound nbt = new NBTTagCompound(); - nbt.setTag("d", getDefinition().toNBT()); + nbt.setTag("d", getDefinition().toNBT(registry)); nbt.setDouble("Q", getAmount()); - nbt.setLong("e", energy); - nbt.setByte("c", color); - nbt.setDouble("A", getAge()); nbt.setDouble("M", lifeTimeMult); + nbt.setDouble("A", getAge()); + nbt.setLong("e", energy); + nbt.setInteger("c", color); return nbt; } - public static EMInstanceStack fromNBT(NBTTagCompound nbt) { + public static EMInstanceStack fromNBT(EMDefinitionsRegistry registry, NBTTagCompound nbt) { EMInstanceStack instance = new EMInstanceStack( - EMDefinitionsRegistry.fromNBT(nbt.getCompoundTag("d")), - nbt.getLong("q") + nbt.getDouble("Q"), - nbt.getFloat("m") + nbt.getDouble("M"), - nbt.getLong("a") + nbt.getDouble("A"), + registry.fromNBT(nbt.getCompoundTag("d")), + nbt.getDouble("Q"), + nbt.getDouble("M"), + nbt.getDouble("A"), nbt.getLong("e")); - instance.setColor(nbt.getByte("c")); + instance.setColor(nbt.getInteger("c")); return instance; } @@ -587,7 +588,7 @@ public final class EMInstanceStack implements IEMStack { @Override public String toString() { - return getDefinition().toString() + '\n' + getAmount() / AVOGADRO_CONSTANT + " mol\n" + getMass(); + return getDefinition().toString() + ' ' + getAmount() /AVOGADRO_CONSTANT + " "+translateToLocal("tt.keyword.mol")+" " + getMass()+" eV/c^2"; } public void setAmount(double amount) { 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 index 5672b31c04..e5cfab9752 100644 --- 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 @@ -1,37 +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,Cloneable { +public interface IEMStack extends Comparable, 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 getCharge() { + return getDefinition().getCharge() * getAmount(); } - default double getMass(){ - return getDefinition().getMass()*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(); + NBTTagCompound toNBT(EMDefinitionsRegistry registry); @Override - default int compareTo(IEMStack o){ + default int compareTo(IEMStack o) { return getDefinition().compareTo(o.getDefinition()); } } 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/EMFluidDequantizationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMFluidDequantizationInfo.java deleted file mode 100644 index d74c36170e..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMFluidDequantizationInfo.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.IEMStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; - -/** - * Created by Tec on 23.05.2017. - */ -public class EMFluidDequantizationInfo implements IEMExchangeInfo { - private final IEMStack in; - private final FluidStack out; - - public EMFluidDequantizationInfo(IEMStack emIn, FluidStack fluidStackOut){ - in=emIn; - out=fluidStackOut; - } - - public EMFluidDequantizationInfo(IEMStack emIn, Fluid fluid, int fluidAmount){ - in=emIn; - out=new FluidStack(fluid,fluidAmount); - } - - @Override - public IEMStack 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 EMFluidDequantizationInfo && hashCode() == obj.hashCode(); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMFluidQuantizationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMFluidQuantizationInfo.java index 43fb5550aa..cf0cc6218c 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMFluidQuantizationInfo.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMFluidQuantizationInfo.java @@ -7,7 +7,7 @@ import net.minecraftforge.fluids.FluidStack; /** * Created by Tec on 23.05.2017. */ -public class EMFluidQuantizationInfo implements IEMExchangeInfo { +public class EMFluidQuantizationInfo { private final FluidStack in; private final IEMStack out; @@ -21,12 +21,10 @@ public class EMFluidQuantizationInfo implements IEMExchangeInfo { - private final IEMStack in; - private final ItemStack out; - - public EMItemDequantizationInfo(IEMStack emIn, ItemStack itemStackOut){ - in=emIn; - out=itemStackOut; - } - - public EMItemDequantizationInfo(IEMStack emIn, OrePrefixes prefix, Materials material, int amount) { - in = emIn; - out = GT_OreDictUnificator.get(prefix, material, amount); - } - - @Override - public IEMStack 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 EMItemDequantizationInfo && hashCode() == obj.hashCode(); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMItemQuantizationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMItemQuantizationInfo.java index 553e806d38..c5db63b3ad 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMItemQuantizationInfo.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/EMItemQuantizationInfo.java @@ -11,7 +11,7 @@ import net.minecraftforge.oredict.OreDictionary; /** * Created by Tec on 23.05.2017. */ -public class EMItemQuantizationInfo implements IEMExchangeInfo { +public class EMItemQuantizationInfo { private final ItemStack in; private final boolean skipNBT; private final IEMStack out; @@ -28,12 +28,10 @@ public class EMItemQuantizationInfo implements IEMExchangeInfo { - private final IEMStack in; - private final String out; - private final int amount; - - public EMOredictDequantizationInfo(IEMStack emIn, String name, int qty) { - in = emIn; - out =name; - amount = qty; - } - - public EMOredictDequantizationInfo(IEMStack emIn, OrePrefixes prefix, Materials material, int qty) { - in = emIn; - out = prefix.name() + material.mName; - amount = qty; - } - - public EMOredictDequantizationInfo(IEMStack emIn, OrePrefixes prefix, String materialName, int qty) { - in = emIn; - out = prefix.name() + materialName; - amount = qty; - } - - @Override - public IEMStack input() { - return in.clone();//MEH! - } - - @Override - public String output() { - return getOut(); - } - - @Override - public int hashCode() { - return in.getDefinition().hashCode(); - } - - @Override - public boolean equals(Object obj) { - return obj instanceof EMOredictDequantizationInfo && hashCode() == obj.hashCode(); - } - - public String getOut() { - return out; - } - - public int getAmount() { - return amount; - } -} 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 index 0ca0415b0d..3c54dd86ac 100644 --- 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 @@ -3,46 +3,41 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.transformation 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 implements IEMExchangeInfo { - private final String in; +public class EMOredictQuantizationInfo { + private final int id; private final int amount; private final IEMStack out; - public EMOredictQuantizationInfo(String name, int qty, IEMStack emOut){ - in=name; - amount=qty; - out=emOut; + public EMOredictQuantizationInfo(int id, int amount, IEMStack out) { + this.id = id; + this.amount = amount; + this.out = out; } - public EMOredictQuantizationInfo(OrePrefixes prefix, Materials material, int qty, IEMStack emOut){ - in=prefix.name() + material.mName; - amount=qty; - out=emOut; + public EMOredictQuantizationInfo(String name, int qty, IEMStack emOut) { + this(OreDictionary.getOreID(name),qty,emOut); } - public EMOredictQuantizationInfo(OrePrefixes prefix, String materialName, int qty, IEMStack emOut){ - in=prefix.name() + materialName; - amount=qty; - out=emOut; + public EMOredictQuantizationInfo(OrePrefixes prefix, Materials material, int qty, IEMStack emOut) { + this(prefix, material.mName, qty,emOut); } - @Override - public String input() { - return getIn(); + public EMOredictQuantizationInfo(OrePrefixes prefix, String materialName, int qty, IEMStack emOut) { + this(OreDictionary.getOreID(prefix.name() + materialName),qty,emOut); } - @Override - public IEMStack output() { - return out.clone(); + public IEMStack getOut() { + return out; } @Override public int hashCode() { - return getIn().hashCode(); + return getId(); } @Override @@ -50,8 +45,8 @@ public class EMOredictQuantizationInfo implements IEMExchangeInfo fluidQuantization; - private Map itemQuantization; - private Map oredictQuantization; - - private Map fluidDequantization; - private Map itemDequantization; - private Map oredictDequantization; - - private EMTransformationInfo() { - this( - new HashMap<>(16), new HashMap<>(16), new HashMap<>(64), - new HashMap<>(16), new HashMap<>(16), new HashMap<>(64) - ); - } - - public EMTransformationInfo( - Map fluidQuantization, - Map itemQuantization, - Map oredictQuantization, - Map fluidDequantization, - Map itemDequantization, - Map oredictDequantization) { - this.setFluidQuantization(fluidQuantization); - this.setItemQuantization(itemQuantization); - this.setOredictQuantization(oredictQuantization); - this.setFluidDequantization(fluidDequantization); - this.setItemDequantization(itemDequantization); - this.setOredictDequantization(oredictDequantization); - } - - public void addFluid(IEMStack em, FluidStack fluidStack){ - getFluidQuantization().put(fluidStack.getFluidID(),new EMFluidQuantizationInfo(fluidStack,em)); - getFluidDequantization().put(em.getDefinition(),new EMFluidDequantizationInfo(em,fluidStack)); - EMDefinitionsRegistry.registerForDisplay(em.getDefinition()); - } - - public void addFluid(IEMStack em, Fluid fluid, int fluidAmount){ - getFluidQuantization().put(fluid.getID(),new EMFluidQuantizationInfo(fluid,fluidAmount,em)); - getFluidDequantization().put(em.getDefinition(),new EMFluidDequantizationInfo(em,fluid,fluidAmount)); - EMDefinitionsRegistry.registerForDisplay(em.getDefinition()); - } - - private void addItemQuantization(EMItemQuantizationInfo aIQI){ - getItemQuantization().put(aIQI,aIQI); - } - - public void addItem(IEMStack em, ItemStack itemStack, boolean skipNBT){ - addItemQuantization(new EMItemQuantizationInfo(itemStack,skipNBT,em)); - getItemDequantization().put(em.getDefinition(),new EMItemDequantizationInfo(em,itemStack)); - EMDefinitionsRegistry.registerForDisplay(em.getDefinition()); - } - - public void addItem(IEMStack em, OrePrefixes prefix, Materials material, int amount, boolean skipNBT){ - addItemQuantization(new EMItemQuantizationInfo(prefix,material,amount,skipNBT,em)); - getItemDequantization().put(em.getDefinition(),new EMItemDequantizationInfo(em,prefix,material,amount)); - EMDefinitionsRegistry.registerForDisplay(em.getDefinition()); - } - - public void addOredict(IEMStack em, String name, int qty){ - getOredictQuantization().put(OreDictionary.getOreID(name),new EMOredictQuantizationInfo(name,qty,em)); - getOredictDequantization().put(em.getDefinition(),new EMOredictDequantizationInfo(em,name,qty)); - EMDefinitionsRegistry.registerForDisplay(em.getDefinition()); - } - - public void addOredict(IEMStack em, OrePrefixes prefix, Materials material, int qty){ - getOredictQuantization().put(OreDictionary.getOreID(prefix.name() + material.mName),new EMOredictQuantizationInfo(prefix,material,qty,em)); - getOredictDequantization().put(em.getDefinition(),new EMOredictDequantizationInfo(em,prefix,material,qty)); - EMDefinitionsRegistry.registerForDisplay(em.getDefinition()); - } - - public void addOredict(IEMStack em, OrePrefixes prefix, String materialName, int qty){ - getOredictQuantization().put(OreDictionary.getOreID(prefix.name() + materialName),new EMOredictQuantizationInfo(prefix,materialName,qty,em)); - getOredictDequantization().put(em.getDefinition(),new EMOredictDequantizationInfo(em,prefix,materialName,qty)); - EMDefinitionsRegistry.registerForDisplay(em.getDefinition()); - } - - public Map getFluidQuantization() { - return fluidQuantization; - } - - public void setFluidQuantization(Map fluidQuantization) { - this.fluidQuantization = fluidQuantization; - } - - public Map getItemQuantization() { - return itemQuantization; - } - - public void setItemQuantization(Map itemQuantization) { - this.itemQuantization = itemQuantization; - } - - public Map getOredictQuantization() { - return oredictQuantization; - } - - public void setOredictQuantization(Map oredictQuantization) { - this.oredictQuantization = oredictQuantization; - } - - public Map getFluidDequantization() { - return fluidDequantization; - } - - public void setFluidDequantization(Map fluidDequantization) { - this.fluidDequantization = fluidDequantization; - } - - public Map getItemDequantization() { - return itemDequantization; - } - - public void setItemDequantization(Map itemDequantization) { - this.itemDequantization = itemDequantization; - } - - public Map getOredictDequantization() { - return oredictDequantization; - } - - public void setOredictDequantization(Map oredictDequantization) { - this.oredictDequantization = oredictDequantization; - } -} 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 fluidQuantization; + private final Map itemQuantization; + private final Map oredictQuantization; + + private final Map infoMap; + private final Function creator; + + public EMTransformationRegistry() { + this(EMDequantizationInfo::new); + } + + public EMTransformationRegistry(Function creator) { + this(creator, + new HashMap<>(16), new HashMap<>(16), new HashMap<>(64), + new HashMap<>(256) + ); + } + + public EMTransformationRegistry(Function creator, + Map fluidQuantization, + Map itemQuantization, + Map oredictQuantization, + Map 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 getFluidQuantization() { + return fluidQuantization; + } + + public Map getItemQuantization() { + return itemQuantization; + } + + public Map getOredictQuantization() { + return oredictQuantization; + } + + public Map getInfoMap() { + return infoMap; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/IEMExchangeInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/IEMExchangeInfo.java deleted file mode 100644 index e20b0af3b5..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/IEMExchangeInfo.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 IEMExchangeInfo { - 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/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/definitions/complex/EMAtomDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMAtomDefinition.java index 37ecb861f8..76f4457e94 100644 --- 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 @@ -1,69 +1,65 @@ 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.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.EMDefinitionsRegistry; import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMIndirectType; +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.EMDefinitionStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMFluidDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMItemDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMOredictDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMBosonDefinition; +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.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.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo.AVOGADRO_CONSTANT_144; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMBosonDefinition.boson_Y__; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMBosonDefinition.deadEnd; +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.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; 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 net.minecraft.util.StatCollector.translateToLocal; /** * Created by danie_000 on 18.11.2016. */ -public final class EMAtomDefinition extends EMComplexTemplate { - public static final long ATOM_COMPLEXITY_LIMIT=65536L; - private static final byte BYTE_OFFSET=32; +public class EMAtomDefinition extends EMComplexTemplate { + public static final long ATOM_COMPLEXITY_LIMIT = 65536L; + private static final byte BYTE_OFFSET = 32; - private final int hash; + private final int hash; public static double refMass, refUnstableMass; - private static final byte nbtType = (byte) 'a'; + private static final String nbtType = "a"; private static final Random xstr = new XSTR();//NEEDS SEPARATE! private static Map> stableIsotopes = new HashMap<>(); private static final Map stableAtoms = new HashMap<>(); private static Map> mostStableUnstableIsotopes = new HashMap<>(); private static final Map unstableAtoms = new HashMap<>(); - private static EMDefinitionStack alpha,deuterium,tritium,helium_3,beryllium_8,carbon_14,neon_24,silicon_34; - private static final HashMap lifetimeOverrides = 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 lifetimeOverrides = new HashMap<>(); private final EMNuclideIAEA iaea; private static EMAtomDefinition somethingHeavy; + public static EMAtomDefinition getSomethingHeavy() { return somethingHeavy; } private static final ArrayList overrides = new ArrayList<>(); - public static void addOverride(EMAtomDefinition atom, double rawLifeTime){ - lifetimeOverrides.put(atom,rawLifeTime); + + public static void addOverride(EMAtomDefinition atom, double rawLifeTime) { + lifetimeOverrides.put(atom, rawLifeTime); } //float-mass in eV/c^2 @@ -106,23 +102,23 @@ public final class EMAtomDefinition extends EMComplexTemplate { } elementalStacks = things; - double mass = 0; - int cLeptons = 0; - int cNucleus = 0; - int neutralCount = 0, element = 0; - int type = 0; + 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()){ + if ((int) stack.getAmount() != stack.getAmount()) { throw new ArithmeticException("Amount cannot be safely converted to int!"); } mass += stack.getMass(); - if (def.getMatterType() < 0) { + if (def.getGeneration() < 0) { containsAnti = true; } - type = Math.max(type, Math.abs(def.getMatterType())); + type = Math.max(type, Math.abs(def.getGeneration())); if (def instanceof EMLeptonDefinition) { cLeptons += stack.getCharge(); @@ -148,57 +144,57 @@ public final class EMAtomDefinition extends EMComplexTemplate { //stability curve int StableIsotope = stableIzoCurve(element); - int izoDiff = neutralCount - StableIsotope; - int izoDiffAbs = Math.abs(izoDiff); + int izoDiff = neutralCount - StableIsotope; + int izoDiffAbs = Math.abs(izoDiff); xstr.setSeed((element + 1L) * (neutralCount + 100L)); - iaea = EMNuclideIAEA.get(element,neutralCount); - if(getIaea() !=null){ - if(Double.isNaN(getIaea().getMass())) { + 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); + if (Double.isNaN(getIaea().getHalfTime())) { + Double overriddenLifeTime = lifetimeOverrides.get(this); double rawLifeTimeTemp; - if(overriddenLifeTime!=null) { + if (overriddenLifeTime != null) { rawLifeTimeTemp = overriddenLifeTime; } else { rawLifeTimeTemp = calculateLifeTime(izoDiff, izoDiffAbs, element, neutralCount, containsAnti); } rawLifeTime = Math.min(rawLifeTimeTemp, STABLE_RAW_LIFE_TIME); - }else { + } else { rawLifeTime = containsAnti ? getIaea().getHalfTime() * 1.5514433E-21d * (1d + xstr.nextDouble() * 9d) : getIaea().getHalfTime(); } - iaeaDefinitionExistsAndHasEnergyLevels = getIaea().getEnergeticStatesArray().length>1; - }else{ - this.mass=mass; + iaeaDefinitionExistsAndHasEnergyLevels = getIaea().getEnergeticStatesArray().length > 1; + } else { + this.mass = mass; - Double overriddenLifeTime= lifetimeOverrides.get(this); + Double overriddenLifeTime = lifetimeOverrides.get(this); double rawLifeTimeTemp; - if(overriddenLifeTime!=null) { + if (overriddenLifeTime != null) { rawLifeTimeTemp = overriddenLifeTime; } else { rawLifeTimeTemp = calculateLifeTime(izoDiff, izoDiffAbs, element, neutralCount, containsAnti); } rawLifeTime = Math.min(rawLifeTimeTemp, STABLE_RAW_LIFE_TIME); - iaeaDefinitionExistsAndHasEnergyLevels =false; + iaeaDefinitionExistsAndHasEnergyLevels = false; } - if(getIaea() ==null || getIaea().getEnergeticStatesArray()[0].energy!=0) { + 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); + } 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(); + hash = super.hashCode(); } private static int stableIzoCurve(int element) { @@ -267,7 +263,7 @@ public final class EMAtomDefinition extends EMComplexTemplate { private static boolean canTheyBeTogether(EMConstantStackMap stacks) { boolean nuclei = false; - long qty=0; + long qty = 0; for (EMDefinitionStack stack : stacks.valuesToArray()) { if (stack.getDefinition() instanceof EMHadronDefinition) { if (((EMHadronDefinition) stack.getDefinition()).getAmount() != 3) { @@ -277,12 +273,12 @@ public final class EMAtomDefinition extends EMComplexTemplate { } else if (!(stack.getDefinition() instanceof EMLeptonDefinition)) { return false; } - if((int) stack.getAmount() != stack.getAmount()){ + if ((int) stack.getAmount() != stack.getAmount()) { throw new ArithmeticException("Amount cannot be safely converted to int!"); } - qty+= stack.getAmount(); + qty += stack.getAmount(); } - return nuclei && qty= getIaea().getEnergeticStatesArray().length){ - return getIaea().getEnergeticStatesArray()[getIaea().getEnergeticStatesArray().length-1].Thalf/(currentEnergy- getIaea().getEnergeticStatesArray().length+1); + 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 getIaea().getEnergeticStatesArray()[(int) currentEnergy].Thalf; } - return rawLifeTime/(currentEnergy+1); + return rawLifeTime / (currentEnergy + 1); } @Override @@ -332,16 +328,16 @@ public final class EMAtomDefinition extends EMComplexTemplate { } @Override - public byte getColor() { + public int getMaxColors() { return -10; } @Override public String getLocalizedName() { - int element = Math.abs(this.getElement()); + int element = Math.abs(this.getElement()); boolean negative = this.getElement() < 0; try { - if (Math.abs(getMatterType()) != 1) { + if (Math.abs(getGeneration()) != 1) { return (negative ? "~? " : "? ") + Nomenclature.NAME[element]; } return negative ? '~' + Nomenclature.NAME[element] : Nomenclature.NAME[element]; @@ -349,35 +345,35 @@ public final class EMAtomDefinition extends EMComplexTemplate { if (DEBUG_MODE) { e.printStackTrace(); } - return translateToLocal("tt.keyword.Element")+(negative ? ": ~" : ": ") + element; + return translateToLocal("tt.keyword.Element") + (negative ? ": ~" : ": ") + element; } } @Override public String getSymbol() { - int element = Math.abs(this.getElement()); + int element = Math.abs(this.getElement()); boolean negative = this.getElement() < 0; try { - return (negative ? "~" : "") + Nomenclature.SYMBOL[element] + " N:" + getNeutralCount() + " I:" + (getNeutralCount() +element) + " C:" + getCharge(); + return (negative ? "~" : "") + Nomenclature.SYMBOL[element] + " N:" + getNeutralCount() + " I:" + (getNeutralCount() + 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:" + getNeutralCount() + " I:" + (getNeutralCount() +element) + " C:" + getCharge(); + return (negative ? "~" : "") + Nomenclature.SYMBOL_IUPAC[10 + s100] + Nomenclature.SYMBOL_IUPAC[s10] + Nomenclature.SYMBOL_IUPAC[s1] + " N:" + getNeutralCount() + " I:" + (getNeutralCount() + element) + " C:" + getCharge(); } catch (Exception E) { if (DEBUG_MODE) { e.printStackTrace(); } - return (negative ? "~" : "") + "? N:" + getNeutralCount() + " I:" + (getNeutralCount() +element) + " C:" + getCharge(); + return (negative ? "~" : "") + "? N:" + getNeutralCount() + " I:" + (getNeutralCount() + element) + " C:" + getCharge(); } } } @Override public String getShortSymbol() { - int element = Math.abs(this.getElement()); + int element = Math.abs(this.getElement()); boolean negative = this.getElement() < 0; try { return (negative ? "~" : "") + Nomenclature.SYMBOL[element]; @@ -404,69 +400,69 @@ public final class EMAtomDefinition extends EMComplexTemplate { @Override public EMDecay[] getDecayArray() { - ArrayList decaysList =new ArrayList<>(4); - return getDecayArray(decaysList, getDecayMode(),true); + ArrayList decaysList = new ArrayList<>(4); + return getDecayArray(decaysList, getDecayMode(), true); } private EMDecay[] getDecayArray(ArrayList decaysList, int decayMode, boolean tryAnti) {//todo? - if (getMatterType() == 1) { + if (getGeneration() == 1) { switch (decayMode) { case -2: - if(TecTech.RANDOM.nextBoolean() && ElectronCapture(decaysList)) { + if (TecTech.RANDOM.nextBoolean() && ElectronCapture(decaysList)) { return decaysList.toArray(EMDecay.NO_PRODUCT); - } else if(PbetaDecay(decaysList)) { + } else if (PbetaDecay(decaysList)) { return decaysList.toArray(EMDecay.NO_PRODUCT); } break; case -1: - if(Emmision(decaysList, EMHadronDefinition.hadron_p1)) { + if (Emmision(decaysList, EMHadronDefinition.hadron_p1)) { return decaysList.toArray(EMDecay.NO_PRODUCT); } break; case 0: - if(alphaDecay(decaysList)) { + if (alphaDecay(decaysList)) { return decaysList.toArray(EMDecay.NO_PRODUCT); } break; case 1: - if(Emmision(decaysList, EMHadronDefinition.hadron_n1)) { + if (Emmision(decaysList, EMHadronDefinition.hadron_n1)) { return decaysList.toArray(EMDecay.NO_PRODUCT); } break; case 2: - if(MbetaDecay(decaysList)) { + if (MbetaDecay(decaysList)) { return decaysList.toArray(EMDecay.NO_PRODUCT); } break; default: - if(decayMode>8){ - if(iaeaDecay(decaysList,0)) { + if (decayMode > 8) { + if (iaeaDecay(decaysList, 0)) { return decaysList.toArray(EMDecay.NO_PRODUCT); } - return getDecayArray(decaysList,decayMode- BYTE_OFFSET,false); + return getDecayArray(decaysList, decayMode - BYTE_OFFSET, false); } } return EMDecay.NO_DECAY; - }else if(getMatterType() ==-1){ - EMAtomDefinition anti =getAnti(); - if(anti!=null) { + } else if (getGeneration() == -1) { + EMAtomDefinition anti = getAnti(); + if (anti != null) { return anti.getDecayArray(decaysList, decayMode, false); } } return getNaturalDecayInstant(); } - private boolean iaeaDecay(ArrayList decaysList, long energy){ + private boolean iaeaDecay(ArrayList decaysList, long energy) { EMNuclideIAEA.energeticState state; - if(energy> getIaea().getEnergeticStatesArray().length) { + if (energy > getIaea().getEnergeticStatesArray().length) { state = getIaea().getEnergeticStatesArray()[getIaea().getEnergeticStatesArray().length - 1]; - } else if(energy<=0) { + } else if (energy <= 0) { state = getIaea().getEnergeticStatesArray()[0]; } else { state = getIaea().getEnergeticStatesArray()[(int) energy]; } - for (int i=0;i decaysList, EMNuclideIAEA.iaeaDecay decay, long energy){ - EMDefinitionStackMap withThis =elementalStacks.toMutable(), newStuff =new EMDefinitionStackMap(); - switch (decay.decayName){ + private boolean getDecayFromIaea(ArrayList decaysList, EMNuclideIAEA.iaeaDecay decay, long energy) { + EMDefinitionStackMap withThis = elementalStacks.toMutable(), newStuff = new EMDefinitionStackMap(); + switch (decay.decayName) { case "D": { - if (withThis.removeAllAmountsExact(deuterium.getDefinition().getSubParticles())){ + if (withThis.removeAllAmountsExact(deuterium.getDefinition().getSubParticles())) { withThis.putReplace(deuterium); - decaysList.add(new EMDecay(decay.chance,withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; } - } break; + } + break; case "3H": { - if (withThis.removeAllAmountsExact(tritium.getDefinition().getSubParticles())){ + if (withThis.removeAllAmountsExact(tritium.getDefinition().getSubParticles())) { withThis.putReplace(tritium); - decaysList.add(new EMDecay(decay.chance,withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; } - } break; + } + break; case "3HE": { - if (withThis.removeAllAmountsExact(helium_3.getDefinition().getSubParticles())){ + if (withThis.removeAllAmountsExact(helium_3.getDefinition().getSubParticles())) { withThis.putReplace(helium_3); - decaysList.add(new EMDecay(decay.chance,withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; } - } break; + } + break; case "8BE": { - if (withThis.removeAllAmountsExact(beryllium_8.getDefinition().getSubParticles())){ + if (withThis.removeAllAmountsExact(beryllium_8.getDefinition().getSubParticles())) { withThis.putReplace(beryllium_8); - decaysList.add(new EMDecay(decay.chance,withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; } - } break; + } + break; case "14C": { - if (withThis.removeAllAmountsExact(carbon_14.getDefinition().getSubParticles())){ + if (withThis.removeAllAmountsExact(carbon_14.getDefinition().getSubParticles())) { newStuff.putReplace(carbon_14); - try{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "24NE": { - if (withThis.removeAllAmountsExact(neon_24.getDefinition().getSubParticles())){ + if (withThis.removeAllAmountsExact(neon_24.getDefinition().getSubParticles())) { newStuff.putReplace(neon_24); - try{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "34SI": { - if (withThis.removeAllAmountsExact(silicon_34.getDefinition().getSubParticles())){ + if (withThis.removeAllAmountsExact(silicon_34.getDefinition().getSubParticles())) { newStuff.putReplace(silicon_34); - try{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; - case "A": case "A?": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n2, EMHadronDefinition.hadron_p2)){ + } + break; + case "A": + case "A?": { + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n2, EMHadronDefinition.hadron_p2)) { newStuff.putReplace(alpha); - try{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "B+": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p1)){ + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p1)) { withThis.putUnifyExact(EMHadronDefinition.hadron_n1); newStuff.putReplace(EMLeptonDefinition.lepton_e_1); newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve1); - try{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "2B+": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p2)){ + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p2)) { withThis.putUnifyExact(EMHadronDefinition.hadron_n2); newStuff.putReplace(EMLeptonDefinition.lepton_e_2); newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve2); - try{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "B-": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n1)){ + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n1)) { withThis.putUnifyExact(EMHadronDefinition.hadron_p1); newStuff.putReplace(EMLeptonDefinition.lepton_e1); newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve_1); - try{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "2B-": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n2)){ + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n2)) { withThis.putUnifyExact(EMHadronDefinition.hadron_p2); newStuff.putReplace(EMLeptonDefinition.lepton_e2); newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve_2); - try{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "EC": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p1, EMLeptonDefinition.lepton_e1)){ + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p1, EMLeptonDefinition.lepton_e1)) { withThis.putUnifyExact(EMHadronDefinition.hadron_n1); newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve1); - try{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "2EC": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p2, EMLeptonDefinition.lepton_e2)){ + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p2, EMLeptonDefinition.lepton_e2)) { withThis.putUnifyExact(EMHadronDefinition.hadron_n2); newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve2); - try{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; - case "B++EC": case "EC+B+": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p2, EMLeptonDefinition.lepton_e1)){ + } + 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{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "B+A": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p3, EMHadronDefinition.hadron_n1)){ + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p3, EMHadronDefinition.hadron_n1)) { newStuff.putReplace(EMLeptonDefinition.lepton_e_1); newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve1); newStuff.putReplace(alpha); - try{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "B+P": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p2)){ + 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{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "B+2P": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p3)){ + 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{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "B-A": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n3, EMHadronDefinition.hadron_p1)){ + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n3, EMHadronDefinition.hadron_p1)) { newStuff.putReplace(EMLeptonDefinition.lepton_e1); newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve_1); newStuff.putReplace(alpha); - try{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "B-N": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n2)){ + 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{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "B-2N": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n3)){ + 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{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "B-P": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n1)){ + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n1)) { newStuff.putReplace(EMLeptonDefinition.lepton_e1); newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve_1); newStuff.putReplace(EMHadronDefinition.hadron_p1); - try{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "ECA": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n1, EMLeptonDefinition.lepton_e1, EMHadronDefinition.hadron_p3)){ + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n1, EMLeptonDefinition.lepton_e1, EMHadronDefinition.hadron_p3)) { newStuff.putReplace(EMNeutrinoDefinition.lepton_Ve1); newStuff.putReplace(alpha); - try{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "ECP": { - if (withThis.removeAllAmountsExact(EMLeptonDefinition.lepton_e1, EMHadronDefinition.hadron_p2)){ + 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{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "EC2P": { - if (withThis.removeAllAmountsExact(EMLeptonDefinition.lepton_e1, EMHadronDefinition.hadron_p3)){ + 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{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "ECP+EC2P": {//todo look at branching ratios - if (withThis.removeAllAmountsExact(EMLeptonDefinition.lepton_e2, EMHadronDefinition.hadron_p5)){ + 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{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "N": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n1)){ + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n1)) { newStuff.putReplace(EMHadronDefinition.hadron_n1); - try{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "2N": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n2)){ + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n2)) { newStuff.putReplace(EMHadronDefinition.hadron_n2); - try{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "P": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p1)){ + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p1)) { newStuff.putReplace(EMHadronDefinition.hadron_p1); - try{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "2P": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p2)){ + if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p2)) { newStuff.putReplace(EMHadronDefinition.hadron_p2); - try{ + try { newStuff.putReplace(new EMAtomDefinition(withThis.toImmutable_optimized_unsafe_LeavesExposedElementalTree()).getStackForm(1)); - decaysList.add(new EMDecay(decay.chance,newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "SF": { if (Fission(decaysList, withThis, newStuff, decay.chance, false)) { return true; } - } break; + } + break; case "B-F": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_n1)){ + 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)) { + try { + if (Fission(decaysList, withThis, newStuff, decay.chance, false)) { return true; } - }catch (Exception e){ - if(DEBUG_MODE) { + } 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)){ + } + 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)) { + try { + if (Fission(decaysList, withThis, newStuff, decay.chance, false)) { return true; } - }catch (Exception e){ - if(DEBUG_MODE) { + } 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)){ + } + 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)) { + try { + if (Fission(decaysList, withThis, newStuff, decay.chance, false)) { return true; } - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "SF+EC+B-": { - if (withThis.removeAllAmountsExact(EMLeptonDefinition.lepton_e1)){ + 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)) { + try { + if (Fission(decaysList, withThis, newStuff, decay.chance, false)) { return true; } - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; - case "IT": case "IT?": case "G": { - if(energy>0){ + } + break; + case "IT": + case "IT?": + case "G": { + if (energy > 0) { decaysList.add(new EMDecay(decay.chance, this, boson_Y__)); - }else{ - if(DEBUG_MODE) { + } else { + if (DEBUG_MODE) { TecTech.LOGGER.info("Tried to emit Gamma from ground state"); } decaysList.add(new EMDecay(decay.chance, this)); @@ -986,28 +1024,30 @@ public final class EMAtomDefinition extends EMComplexTemplate { return true; } //break; case "IT+EC+B+": { - if (withThis.removeAllAmountsExact(EMHadronDefinition.hadron_p2, EMLeptonDefinition.lepton_e1)){ + 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(EMBosonDefinition.boson_Y__1); - try{ + 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())); + decaysList.add(new EMDecay(decay.chance, newStuff.toImmutable_optimized_unsafe_LeavesExposedElementalTree())); return true; - }catch (Exception e){ - if(DEBUG_MODE) { + } catch (Exception e) { + if (DEBUG_MODE) { e.printStackTrace(); } } } - } break; + } + break; case "DEAD_END": decaysList.add(deadEnd); return true; - default: throw new Error("Unsupported decay mode: " + decay.decayName + ' ' + getNeutralCount() + ' ' + getElement()); + default: + throw new Error("Unsupported decay mode: " + decay.decayName + ' ' + getNeutralCount() + ' ' + getElement()); } - if(DEBUG_MODE) { + if (DEBUG_MODE) { TecTech.LOGGER.info("Failed to decay " + getElement() + ' ' + getNeutralCount() + ' ' + decay.decayName); } return false; @@ -1093,48 +1133,48 @@ public final class EMAtomDefinition extends EMComplexTemplate { private boolean Fission(ArrayList decaysList, EMDefinitionStackMap fissile, EMDefinitionStackMap particles, double probability, boolean spontaneousCheck) { EMDefinitionStackMap heavy = new EMDefinitionStackMap(); - double[] liquidDrop = liquidDropFunction(Math.abs(getElement())<=97); + double[] liquidDrop = liquidDropFunction(Math.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)) { + 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.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)); + 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) { + } 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); + 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)); + 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) { + if (DEBUG_MODE) { e.printStackTrace(); } } @@ -1181,51 +1221,51 @@ public final class EMAtomDefinition extends EMComplexTemplate { @Override public EMDecay[] getEnergyInducedDecay(long energyLevel) { if (iaeaDefinitionExistsAndHasEnergyLevels) { - ArrayList decays =new ArrayList<>(4); - if(iaeaDecay(decays,energyLevel)){ + ArrayList decays = new ArrayList<>(4); + if (iaeaDecay(decays, energyLevel)) { return decays.toArray(EMDecay.NO_PRODUCT); } } - if(energyLevel< Math.abs(getCharge())/3+ getNeutralCount()) { + if (energyLevel < Math.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= getIaea().getEnergeticStatesArray().length){ - if(currentEnergyLevel>= getIaea().getEnergeticStatesArray().length) { + 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()[getIaea().getEnergeticStatesArray().length - 1].energy; + } else { result += getIaea().getEnergeticStatesArray()[(int) newEnergyLevel].energy; } - return backwards?-result:result; + return backwards ? -result : result; } - return IEMDefinition.DEFAULT_ENERGY_REQUIREMENT *(newEnergyLevel-currentEnergyLevel); + return IEMDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - currentEnergyLevel); } @Override @@ -1235,17 +1275,17 @@ public final class EMAtomDefinition extends EMComplexTemplate { @Override public boolean usesMultipleDecayCalls(long energyLevel) { - if(!iaeaDefinitionExistsAndHasEnergyLevels) return false; + if (!iaeaDefinitionExistsAndHasEnergyLevels) return false; EMNuclideIAEA.energeticState state; - if(energyLevel> getIaea().getEnergeticStatesArray().length) { + if (energyLevel > getIaea().getEnergeticStatesArray().length) { state = getIaea().getEnergeticStatesArray()[getIaea().getEnergeticStatesArray().length - 1]; - } else if(energyLevel<=0) { + } 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 + for (EMNuclideIAEA.iaeaDecay decay : state.decaymodes) { + if (decay.decayName.contains("F")) return true;//if is fissile } return false; } @@ -1257,7 +1297,7 @@ public final class EMAtomDefinition extends EMComplexTemplate { @Override public boolean fusionMakesEnergy(long energyLevel) { - return getIaea() !=null || iaeaDefinitionExistsAndHasEnergyLevels; + return getIaea() != null || iaeaDefinitionExistsAndHasEnergyLevels; } @Override @@ -1265,7 +1305,7 @@ public final class EMAtomDefinition extends EMComplexTemplate { //disembody ArrayList decaysInto = new ArrayList<>(); for (EMDefinitionStack elementalStack : elementalStacks.valuesToArray()) { - if (elementalStack.getDefinition().getMatterType() == 1 || elementalStack.getDefinition().getMatterType() == -1) { + if (elementalStack.getDefinition().getGeneration() == 1 || elementalStack.getDefinition().getGeneration() == -1) { //covers both quarks and antiquarks decaysInto.add(elementalStack); } else { @@ -1278,10 +1318,10 @@ public final class EMAtomDefinition extends EMComplexTemplate { //@Override //public iElementalDefinition getAnti() { - // cElementalDefinitionStack[] stacks = this.elementalStacks.values(); - // cElementalDefinitionStack[] antiElements = new cElementalDefinitionStack[stacks.length]; + // EMDefinitionStack[] stacks = this.elementalStacks.values(); + // EMDefinitionStack[] antiElements = new EMDefinitionStack[stacks.length]; // for (int i = 0; i < antiElements.length; i++) { - // antiElements[i] = new cElementalDefinitionStack(stacks[i].definition.getAnti(), stacks[i].amount); + // antiElements[i] = new EMDefinitionStack(stacks[i].definition.getAnti(), stacks[i].amount); // } // try { // return new dAtomDefinition(false, antiElements); @@ -1307,21 +1347,6 @@ public final class EMAtomDefinition extends EMComplexTemplate { } } - @Override - public EMFluidDequantizationInfo someAmountIntoFluidStack() { - return EMTransformationInfo.TRANSFORMATION_INFO.getFluidDequantization().get(this); - } - - @Override - public EMItemDequantizationInfo someAmountIntoItemsStack() { - return EMTransformationInfo.TRANSFORMATION_INFO.getItemDequantization().get(this); - } - - @Override - public EMOredictDequantizationInfo someAmountIntoOredictStack() { - return EMTransformationInfo.TRANSFORMATION_INFO.getOredictDequantization().get(this); - } - public EMNuclideIAEA getIaea() { return iaea; } @@ -1339,55 +1364,43 @@ public final class EMAtomDefinition extends EMComplexTemplate { } 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 = 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 - protected int getIndirectTagValue() { + protected String getIndirectTagValue() { return nbtType; } - public static EMAtomDefinition fromNBT(NBTTagCompound nbt) { - EMDefinitionStack[] stacks = new EMDefinitionStack[nbt.getInteger("i")]; - for (int i = 0; i < stacks.length; i++) { - stacks[i] = EMDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); - } - try { - return new EMAtomDefinition(stacks); - } catch (EMException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return null; - } - } + 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(); - public static void run() { for (Runnable r : overrides) { r.run(); } - for(Map.Entry entry:lifetimeOverrides.entrySet()){ + for (Map.Entry entry : lifetimeOverrides.entrySet()) { try { lifetimeOverrides.put(new EMAtomDefinition(entry.getKey().elementalStacks), entry.getValue()); - }catch (EMException e){ + } catch (EMException e) { e.printStackTrace(); //Impossible } } //populate stable isotopes - for (int element = 1; element < 83; element++)//Up to Bismuth exclusive - { + 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); - EMNuclideIAEA nuclide = EMNuclideIAEA.get(element, isotope); + int StableIsotope = stableIzoCurve(element); + int izoDiff = isotope - StableIsotope; + int izoDiffAbs = Math.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 isotopes = stableIsotopes.computeIfAbsent(element, k -> new TreeSet<>()); isotopes.add(isotope); @@ -1396,16 +1409,16 @@ public final class EMAtomDefinition extends EMComplexTemplate { } //populate unstable isotopes - for (int element = 83; element < 150; element++) { + 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 = Math.abs(izoDiff); - double rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); - TreeMap isotopes = mostStableUnstableIsotopes.computeIfAbsent(element, k -> new TreeMap<>()); - isotopes.put(rawLifeTime, isotope); + int Isotope = stableIzoCurve(element); + int izoDiff = isotope - Isotope; + int izoDiffAbs = Math.abs(izoDiff); + double rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); + TreeMap isotopes = mostStableUnstableIsotopes.computeIfAbsent(element, k -> new TreeMap<>()); + isotopes.put(rawLifeTime, isotope);//todo dont add stable ones } } @@ -1428,213 +1441,221 @@ public final class EMAtomDefinition extends EMComplexTemplate { TecTech.LOGGER.info("Added Unstable Atom:" + integerTreeMapEntry.getKey() + ' ' + integerTreeMapEntry.getValue().lastEntry().getValue() + ' ' + unstableAtoms.get(integerTreeMapEntry.getKey()).getMass()); } } - deuterium=new EMAtomDefinition( + + deuterium = new EMAtomDefinition( EMHadronDefinition.hadron_p1, EMHadronDefinition.hadron_n1, EMLeptonDefinition.lepton_e1).getStackForm(1); - tritium=new EMAtomDefinition( + registry.registerForDisplay(deuterium.getDefinition()); + + tritium = new EMAtomDefinition( EMHadronDefinition.hadron_p1, EMHadronDefinition.hadron_n2, EMLeptonDefinition.lepton_e1).getStackForm(1); - helium_3=new EMAtomDefinition( + 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); - beryllium_8=new EMAtomDefinition( + 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); - carbon_14=new EMAtomDefinition( + 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); - neon_24=new EMAtomDefinition( + 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); - silicon_34=new EMAtomDefinition( + 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); - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - - try { - EMDefinitionsRegistry.registerDefinitionClass(nbtType, EMAtomDefinition::fromNBT,EMAtomDefinition.class,getClassTypeStatic()); - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - if(DEBUG_MODE) { - TecTech.LOGGER.info("Registered Elemental Matter Class: Atom " + nbtType + ' ' + getClassTypeStatic()); - } - } - - public static void setTransformations(){ - /*----STABLE ATOMS----**/ - refMass = getFirstStableIsotope(1).getMass() * AVOGADRO_CONSTANT_144; - - EMTransformationInfo.TRANSFORMATION_INFO.addFluid(new EMDefinitionStack(getFirstStableIsotope(1), AVOGADRO_CONSTANT_144),Materials.Hydrogen.mGas,144); - EMTransformationInfo.TRANSFORMATION_INFO.addFluid(new EMDefinitionStack(getFirstStableIsotope(2), AVOGADRO_CONSTANT_144),Materials.Helium.mGas, 144); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(3), AVOGADRO_CONSTANT_144), dust, Materials.Lithium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(4), AVOGADRO_CONSTANT_144), dust, Materials.Beryllium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(5), AVOGADRO_CONSTANT_144), dust, Materials.Boron,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(6), AVOGADRO_CONSTANT_144), dust, Materials.Carbon,1); - EMTransformationInfo.TRANSFORMATION_INFO.addFluid(new EMDefinitionStack(getFirstStableIsotope(7), AVOGADRO_CONSTANT_144),Materials.Nitrogen.mGas, 144); - EMTransformationInfo.TRANSFORMATION_INFO.addFluid(new EMDefinitionStack(getFirstStableIsotope(8), AVOGADRO_CONSTANT_144),Materials.Oxygen.mGas, 144); - EMTransformationInfo.TRANSFORMATION_INFO.addFluid(new EMDefinitionStack(getFirstStableIsotope(9), AVOGADRO_CONSTANT_144),Materials.Fluorine.mGas, 144); - //transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(10), AVOGADRO_CONSTANT_144),Materials.Neon.mGas.getID(), 144); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(11), AVOGADRO_CONSTANT_144), dust, Materials.Sodium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(12), AVOGADRO_CONSTANT_144), dust, Materials.Magnesium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(13), AVOGADRO_CONSTANT_144), dust, Materials.Aluminium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(14), AVOGADRO_CONSTANT_144), dust, Materials.Silicon,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(15), AVOGADRO_CONSTANT_144), dust, Materials.Phosphorus,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(16), AVOGADRO_CONSTANT_144), dust, Materials.Sulfur,1); - EMTransformationInfo.TRANSFORMATION_INFO.addFluid(new EMDefinitionStack(getFirstStableIsotope(17), AVOGADRO_CONSTANT_144),Materials.Argon.mGas, 144); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(19), AVOGADRO_CONSTANT_144), dust, Materials.Potassium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(20), AVOGADRO_CONSTANT_144), dust, Materials.Calcium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(21), AVOGADRO_CONSTANT_144), dust, Materials.Scandium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(22), AVOGADRO_CONSTANT_144), dust, Materials.Titanium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(23), AVOGADRO_CONSTANT_144), dust, Materials.Vanadium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(24), AVOGADRO_CONSTANT_144), dust, Materials.Chrome,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(25), AVOGADRO_CONSTANT_144), dust, Materials.Manganese,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(26), AVOGADRO_CONSTANT_144), dust, Materials.Iron,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(27), AVOGADRO_CONSTANT_144), dust, Materials.Cobalt,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(28), AVOGADRO_CONSTANT_144), dust, Materials.Nickel,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(29), AVOGADRO_CONSTANT_144), dust, Materials.Copper,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(30), AVOGADRO_CONSTANT_144), dust, Materials.Zinc,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(31), AVOGADRO_CONSTANT_144), dust, Materials.Gallium,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(32), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Germanium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(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); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(37), AVOGADRO_CONSTANT_144), dust, Materials.Rubidium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(38), AVOGADRO_CONSTANT_144), dust, Materials.Strontium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(39), AVOGADRO_CONSTANT_144), dust, Materials.Yttrium,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(40), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Zirconium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(41), AVOGADRO_CONSTANT_144), dust, Materials.Niobium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(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); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(46), AVOGADRO_CONSTANT_144), dust, Materials.Palladium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(47), AVOGADRO_CONSTANT_144), dust, Materials.Silver,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(48), AVOGADRO_CONSTANT_144), dust, Materials.Cadmium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(49), AVOGADRO_CONSTANT_144), dust, Materials.Indium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(50), AVOGADRO_CONSTANT_144), dust, Materials.Tin,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(51), AVOGADRO_CONSTANT_144), dust, Materials.Antimony,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(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); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(55), AVOGADRO_CONSTANT_144), dust, Materials.Caesium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(56), AVOGADRO_CONSTANT_144), dust, Materials.Barium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(57), AVOGADRO_CONSTANT_144), dust, Materials.Lanthanum,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(58), AVOGADRO_CONSTANT_144), dust, Materials.Cerium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(59), AVOGADRO_CONSTANT_144), dust, Materials.Praseodymium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(60), AVOGADRO_CONSTANT_144), dust, Materials.Neodymium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(61), AVOGADRO_CONSTANT_144), dust, Materials.Promethium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(62), AVOGADRO_CONSTANT_144), dust, Materials.Samarium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(63), AVOGADRO_CONSTANT_144), dust, Materials.Europium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(64), AVOGADRO_CONSTANT_144), dust, Materials.Gadolinium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(65), AVOGADRO_CONSTANT_144), dust, Materials.Terbium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(66), AVOGADRO_CONSTANT_144), dust, Materials.Dysprosium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(67), AVOGADRO_CONSTANT_144), dust, Materials.Holmium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(68), AVOGADRO_CONSTANT_144), dust, Materials.Erbium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(69), AVOGADRO_CONSTANT_144), dust, Materials.Thulium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(70), AVOGADRO_CONSTANT_144), dust, Materials.Ytterbium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(71), AVOGADRO_CONSTANT_144), dust, Materials.Lutetium,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(72), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Hafnum,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(73), AVOGADRO_CONSTANT_144), dust, Materials.Tantalum,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(74), AVOGADRO_CONSTANT_144), dust, Materials.Tungsten,1); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(75), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Rhenium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(76), AVOGADRO_CONSTANT_144), dust, Materials.Osmium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(77), AVOGADRO_CONSTANT_144), dust, Materials.Iridium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(78), AVOGADRO_CONSTANT_144), dust, Materials.Platinum,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(79), AVOGADRO_CONSTANT_144), dust, Materials.Gold,1); - EMTransformationInfo.TRANSFORMATION_INFO.addFluid(new EMDefinitionStack(getFirstStableIsotope(80), AVOGADRO_CONSTANT_144),Materials.Mercury.mFluid, 144); - //transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(81), AVOGADRO_CONSTANT_144),OrePrefixes.dust, Materials.Thallium,1); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getFirstStableIsotope(82), AVOGADRO_CONSTANT_144), dust, Materials.Lead,1); - - /*----UNSTABLE ATOMS----**/ - refUnstableMass = getFirstStableIsotope(82).getMass() * AVOGADRO_CONSTANT_144; - - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(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); - EMTransformationInfo.TRANSFORMATION_INFO.addFluid(new EMDefinitionStack(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); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(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); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(getBestUnstableIsotope(95), AVOGADRO_CONSTANT_144), dust, Materials.Americium,1); - - try { - EMAtomDefinition temp; - EMTransformationInfo.TRANSFORMATION_INFO.addFluid(new EMDefinitionStack(deuterium.getDefinition(), AVOGADRO_CONSTANT_144),Materials.Deuterium.mGas, 144); - - EMTransformationInfo.TRANSFORMATION_INFO.addFluid(new EMDefinitionStack(tritium.getDefinition(), AVOGADRO_CONSTANT_144),Materials.Tritium.mGas, 144); + registry.registerForDisplay(silicon_34.getDefinition()); - EMTransformationInfo.TRANSFORMATION_INFO.addFluid(new EMDefinitionStack(helium_3.getDefinition(), AVOGADRO_CONSTANT_144),Materials.Helium_3.mGas, 144); - - temp=new EMAtomDefinition( + uranium_238 = new EMAtomDefinition( new EMDefinitionStack(EMLeptonDefinition.lepton_e, 92), new EMDefinitionStack(EMHadronDefinition.hadron_p, 92), - new EMDefinitionStack(EMHadronDefinition.hadron_n, 146) - ); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(temp, AVOGADRO_CONSTANT_144), dust, Materials.Uranium/*238*/,1); - - double tempMass=temp.getMass(); + new EMDefinitionStack(EMHadronDefinition.hadron_n, 146)).getStackForm(1); + registry.registerForDisplay(uranium_238.getDefinition()); - temp=new EMAtomDefinition( + uranium_235 = new EMAtomDefinition( new EMDefinitionStack(EMLeptonDefinition.lepton_e, 92), new EMDefinitionStack(EMHadronDefinition.hadron_p, 92), - new EMDefinitionStack(EMHadronDefinition.hadron_n, 143) - ); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(temp, AVOGADRO_CONSTANT_144), dust, Materials.Uranium235,1); + new EMDefinitionStack(EMHadronDefinition.hadron_n, 143)).getStackForm(1); + registry.registerForDisplay(uranium_235.getDefinition()); - TecTech.LOGGER.info("Diff Mass U : "+(tempMass-temp.getMass())); + TecTech.LOGGER.info("Diff Mass U : " + (uranium_238.getDefinition().getMass() - uranium_235.getDefinition().getMass())); - temp=new EMAtomDefinition( + plutonium_239 = new EMAtomDefinition( new EMDefinitionStack(EMLeptonDefinition.lepton_e, 94), new EMDefinitionStack(EMHadronDefinition.hadron_p, 94), - new EMDefinitionStack(EMHadronDefinition.hadron_n, 145) - ); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(temp, AVOGADRO_CONSTANT_144), dust, Materials.Plutonium/*239*/,1); + new EMDefinitionStack(EMHadronDefinition.hadron_n, 145)).getStackForm(1); + registry.registerForDisplay(plutonium_239.getDefinition()); - somethingHeavy=new EMAtomDefinition( + plutonium_241 = new EMAtomDefinition( new EMDefinitionStack(EMLeptonDefinition.lepton_e, 94), new EMDefinitionStack(EMHadronDefinition.hadron_p, 94), - new EMDefinitionStack(EMHadronDefinition.hadron_n, 147) - ); - EMTransformationInfo.TRANSFORMATION_INFO.addOredict(new EMDefinitionStack(somethingHeavy, AVOGADRO_CONSTANT_144), dust, Materials.Plutonium241,1); + new EMDefinitionStack(EMHadronDefinition.hadron_n, 147)).getStackForm(1); + registry.registerForDisplay(plutonium_241.getDefinition()); - TecTech.LOGGER.info("Diff Mass Pu: "+(somethingHeavy.getMass()-temp.getMass())); + TecTech.LOGGER.info("Diff Mass Pu: " + (plutonium_241.getDefinition().getMass() - plutonium_239.getDefinition().getMass())); - TecTech.LOGGER.info("Neutron Mass: "+ EMHadronDefinition.hadron_n.getMass()); + somethingHeavy=(EMAtomDefinition) plutonium_241.getDefinition(); - } catch (EMException e) { + } catch (Exception e) { if (DEBUG_MODE) { e.printStackTrace(); } } - if(Loader.isModLoaded(Reference.GTPLUSPLUS)) { - new GtppAtomLoader().run(); + 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); } @@ -1644,11 +1665,11 @@ public final class EMAtomDefinition extends EMComplexTemplate { } @Override - public byte getClassType() { + public int getMatterMassType() { return getClassTypeStatic(); } - public static byte getClassTypeStatic(){ + public static int getClassTypeStatic() { return 64; } @@ -1659,36 +1680,36 @@ public final class EMAtomDefinition extends EMComplexTemplate { @Override public void addScanShortSymbols(ArrayList lines, int capabilities, long energyLevel) { - if(Util.areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { + 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 lines, int capabilities, long energyLevel) { - if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { - lines.add("CLASS = " + getIndirectTagValue() + ' ' + getClassType()); + if (Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { + lines.add("CLASS = " + getIndirectTagValue() + ' ' + getMatterMassType()); } - if(Util.areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add("NAME = "+ getLocalizedName()); - lines.add("SYMBOL = "+getSymbol()); + if (Util.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS | SCAN_GET_TIMESPAN_INFO, capabilities)) { + lines.add("NAME = " + getLocalizedName()); + lines.add("SYMBOL = " + getSymbol()); } - if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) { + 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_COLOR, capabilities)) { + lines.add(hasColor() ? "COLORLESS" : "CARRIES COLOR"); } - if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) { + 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< getIaea().getEnergeticStatesArray().length; i++){ - lines.add("E LEVEL "+i+" = "+ getIaea().getEnergeticStatesArray()[i].energy+" eV"); + if (iaeaDefinitionExistsAndHasEnergyLevels && Util.areBitsSet(SCAN_GET_ENERGY_STATES, capabilities)) { + for (int i = 1; i < getIaea().getEnergeticStatesArray().length; i++) { + lines.add("E LEVEL " + i + " = " + getIaea().getEnergeticStatesArray()[i].energy + " eV"); } } - if(Util.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)){ - lines.add("HALF LIFE = "+getRawTimeSpan(energyLevel)+ " s"); + 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/EMHadronDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMHadronDefinition.java index c1db8e4460..aedb11ac05 100644 --- 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 @@ -4,21 +4,20 @@ 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.EMDefinitionsRegistry; 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.EMFluidDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMItemDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMOredictDequantizationInfo; +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.definitions.primitive.EMBosonDefinition; +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 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; @@ -26,29 +25,28 @@ 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.EMTransformationInfo.AVOGADRO_CONSTANT_144; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo.TRANSFORMATION_INFO; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMBosonDefinition.boson_Y__; +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.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; -import static gregtech.api.enums.OrePrefixes.dust; import static net.minecraft.util.StatCollector.translateToLocal; /** * Created by danie_000 on 17.11.2016. */ -public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize map i/o +public class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize map i/o private final int hash; - private static final byte nbtType = (byte) 'h'; + private static final String nbtType = "h"; //Helpers - public static final Map SYMBOL_MAP =new HashMap<>(); - public static final Map NAME_MAP =new HashMap<>(); - public static EMHadronDefinition hadron_p, hadron_n, hadron_p_, hadron_n_; + public static final Map SYMBOL_MAP = new HashMap<>(); + public static final Map 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; + 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; @@ -81,20 +79,20 @@ public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize } quarkStacks = quarks; - int amount = 0; - int charge = 0; - int type = 0; + int amount = 0; + int charge = 0; + int type = 0; boolean containsAnti = false; - double mass = 0; + double mass = 0; for (EMDefinitionStack quarkStack : quarkStacks.valuesToArray()) { amount += quarkStack.getAmount(); - if((int) quarkStack.getAmount() != 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().getMatterType()), type); - if (quarkStack.getDefinition().getMatterType() < 0) { + type = Math.max(Math.abs(quarkStack.getDefinition().getGeneration()), type); + if (quarkStack.getDefinition().getGeneration() < 0) { containsAnti = true; } } @@ -106,10 +104,10 @@ public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize if (mass == protonMass && this.getAmount() == 3) { rawLifeTime = IEMDefinition.STABLE_RAW_LIFE_TIME; - mass=actualProtonMass; + mass = actualProtonMass; } else if (mass == neutronMass && this.getAmount() == 3) { rawLifeTime = 882D; - mass=actualNeutronMass; + mass = actualNeutronMass; } else { if (this.getAmount() == 3) { rawLifeTime = 1.34D / mass * Math.pow(9.81, charge); @@ -119,8 +117,8 @@ public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize rawLifeTime = 1.21D / mass / Math.pow(9.80, charge); } } - this.mass=mass; - hash=super.hashCode(); + this.mass = mass; + hash = super.hashCode(); } //public but u can just try{}catch(){} the constructor it still calls this method @@ -130,7 +128,7 @@ public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize if (!(quarks.getDefinition() instanceof EMQuarkDefinition)) { return false; } - if((int) quarks.getAmount() != quarks.getAmount()){ + if ((int) quarks.getAmount() != quarks.getAmount()) { throw new ArithmeticException("Amount cannot be safely converted to int!"); } amount += quarks.getAmount(); @@ -140,12 +138,12 @@ public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize @Override public String getLocalizedName() { - StringBuilder name= new StringBuilder(getSimpleName()); + StringBuilder name = new StringBuilder(getSimpleName()); name.append(':'); - String sym= translateToLocal(NAME_MAP.get(this)); - if(sym!=null){ + String sym = translateToLocal(UNLOCALIZED_NAME_MAP.get(this)); + if (sym != null) { name.append(' ').append(sym); - }else { + } else { for (EMDefinitionStack quark : quarkStacks.valuesToArray()) { name.append(' ').append(quark.getDefinition().getSymbol()).append((int) quark.getAmount()); } @@ -172,10 +170,10 @@ public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize @Override public String getSymbol() { - String sym=SYMBOL_MAP.get(this); - if(sym!=null){ + String sym = SYMBOL_MAP.get(this); + if (sym != null) { return sym; - }else { + } else { StringBuilder symbol = new StringBuilder(8); for (EMDefinitionStack quark : quarkStacks.valuesToArray()) { for (int i = 0; i < quark.getAmount(); i++) { @@ -188,10 +186,10 @@ public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize @Override public String getShortSymbol() { - String sym=SYMBOL_MAP.get(this); - if(sym!=null){ + String sym = SYMBOL_MAP.get(this); + if (sym != null) { return sym; - }else { + } else { StringBuilder symbol = new StringBuilder(8); for (EMDefinitionStack quark : quarkStacks.valuesToArray()) { for (int i = 0; i < quark.getAmount(); i++) { @@ -203,7 +201,7 @@ public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize } @Override - public byte getColor() { + public int getMaxColors() { return -7; } @@ -215,12 +213,12 @@ public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize @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().getMatterType() == -quarkStacks[1].getDefinition().getMatterType()) { + 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 decaysInto = new ArrayList<>(); for (EMDefinitionStack quarks : quarkStacks) { - if (quarks.getDefinition().getMatterType() == 1 || quarks.getDefinition().getMatterType() == -1) { + if (quarks.getDefinition().getGeneration() == 1 || quarks.getDefinition().getGeneration() == -1) { //covers both quarks and antiquarks decaysInto.add(quarks); } else { @@ -230,22 +228,22 @@ public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize } return new EMDecay[]{ new EMDecay(0.75D, decaysInto.toArray(new EMDefinitionStack[0])), - EMBosonDefinition.deadEnd + 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().getMatterType() == -quarkStacks[1].getDefinition().getMatterType()) { + 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), EMBosonDefinition.deadEnd}; //decay into quarks + 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); + return IEMDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - currentEnergyLevel); } @Override @@ -273,10 +271,10 @@ public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize EMDefinitionStack[] quarkStacks = this.quarkStacks.valuesToArray(); if (getAmount() == 2 && quarkStacks.length == 2 && quarkStacks[0].getDefinition().getMass() == quarkStacks[1].getDefinition().getMass() && - quarkStacks[0].getDefinition().getMatterType() == -quarkStacks[1].getDefinition().getMatterType()) { + quarkStacks[0].getDefinition().getGeneration() == -quarkStacks[1].getDefinition().getGeneration()) { return EMDecay.NO_PRODUCT; } else if (getAmount() != 3) { - return new EMDecay[]{new EMDecay(0.95D, quarkStacks), EMBosonDefinition.deadEnd}; //decay into quarks + return new EMDecay[]{new EMDecay(0.95D, quarkStacks), deadEnd}; //decay into quarks } else { ArrayList newBaryon = new ArrayList<>(); IEMDefinition[] Particles = new IEMDefinition[2]; @@ -289,7 +287,7 @@ public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize EMQuarkDefinition lastQuark = newBaryon.remove(2); EMDefinitionStack[] decay; - if (Math.abs(lastQuark.getMatterType()) > 1) { + if (Math.abs(lastQuark.getGeneration()) > 1) { decay = lastQuark.getDecayArray()[1].getOutputStacks().valuesToArray(); } else { decay = lastQuark.getDecayArray()[2].getOutputStacks().valuesToArray(); @@ -299,19 +297,19 @@ public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize Particles[1] = decay[2].getDefinition(); EMDefinitionStack[] contentOfBaryon = newBaryon.stream() - .map(eQuarkDefinition -> new EMDefinitionStack(eQuarkDefinition,1)) + .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]), - EMBosonDefinition.deadEnd}; + deadEnd}; } catch (EMException e) { if (DEBUG_MODE) { e.printStackTrace(); } - return new EMDecay[]{EMBosonDefinition.deadEnd}; + return new EMDecay[]{deadEnd}; } } } @@ -337,7 +335,7 @@ public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize } @Override - public byte getMatterType() { + public int getGeneration() { return type; } @@ -373,64 +371,48 @@ public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize } @Override - public EMFluidDequantizationInfo someAmountIntoFluidStack() { - return null; - } - - @Override - public EMItemDequantizationInfo someAmountIntoItemsStack() { - return null; - } - - @Override - public EMOredictDequantizationInfo someAmountIntoOredictStack() { - return null; - } - - @Override - protected int getIndirectTagValue() { + protected String getIndirectTagValue() { return nbtType; } - public static EMHadronDefinition fromNBT(NBTTagCompound nbt) { - EMDefinitionStack[] stacks = new EMDefinitionStack[nbt.getInteger("i")]; - for (int i = 0; i < stacks.length; i++) { - stacks[i] = EMDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); - } - try { - return new EMHadronDefinition(stacks); - } catch (EMException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return null; - } - } - - public static void run() { + 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"); - NAME_MAP.put(hadron_p,translateToLocal("tt.keyword.Proton")); - EMDefinitionsRegistry.getStacksRegisteredForDisplay().add(hadron_p); + 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"); - NAME_MAP.put(hadron_p_,translateToLocal("tt.keyword.AntiProton")); - EMDefinitionsRegistry.getStacksRegisteredForDisplay().add(hadron_p_); + 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"); - NAME_MAP.put(hadron_n,translateToLocal("tt.keyword.Neutron")); - EMDefinitionsRegistry.getStacksRegisteredForDisplay().add(hadron_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"); - NAME_MAP.put(hadron_n_,translateToLocal("tt.keyword.AntiNeutron")); - EMDefinitionsRegistry.getStacksRegisteredForDisplay().add(hadron_n_); + 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(); @@ -446,34 +428,29 @@ public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize hadron_n3 = new EMDefinitionStack(hadron_n, 3D); hadron_p5 = new EMDefinitionStack(hadron_p, 5D); - try { - EMDefinitionsRegistry.registerDefinitionClass(nbtType, EMHadronDefinition::fromNBT,EMHadronDefinition.class,getClassTypeStatic()); - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - if(DEBUG_MODE) { + if (DEBUG_MODE) { TecTech.LOGGER.info("Registered Elemental Matter Class: Hadron " + nbtType + ' ' + getClassTypeStatic()); } } - public static void setTransformations(){ + 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* AVOGADRO_CONSTANT_144); - TRANSFORMATION_INFO.getOredictDequantization().put(neutrons.getDefinition(),new EMOredictDequantizationInfo(neutrons, dust, Materials.Neutronium,1)); - TRANSFORMATION_INFO.getOredictQuantization().put( - OreDictionary.getOreID(OrePrefixes.ingotHot.name()+Materials.Neutronium.mName), - new EMOredictQuantizationInfo(OrePrefixes.ingotHot,Materials.Neutronium,1 ,neutrons) + 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 byte getClassType() { + public int getMatterMassType() { return getClassTypeStatic(); } - public static byte getClassTypeStatic(){ + public static int getClassTypeStatic() { return -64; } @@ -484,32 +461,32 @@ public final class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize @Override public void addScanShortSymbols(ArrayList lines, int capabilities, long energyLevel) { - if(Util.areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { + 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 lines, int capabilities, long energyLevel) { - if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { - lines.add("CLASS = " + getIndirectTagValue() + ' ' + getClassType()); + if (Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { + lines.add("CLASS = " + getIndirectTagValue() + ' ' + getMatterMassType()); } - if(Util.areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { - lines.add("NAME = "+getSimpleName()); + 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)) { + 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_COLOR, capabilities)) { + lines.add(hasColor() ? "COLORLESS" : "CARRIES COLOR"); } - if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) { + 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"); + 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 index f20f872a6e..9b77a6cab8 100644 --- 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 @@ -1,46 +1,16 @@ 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.stacks.EMDefinitionStack; import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate; -import static com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay.*; -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 final class EMBosonDefinition extends EMPrimitiveTemplate { - public static final EMBosonDefinition - boson_Y__ = new EMBosonDefinition("Photon", "\u03b3", 1e-18D, -1, 27), - boson_H__ = new EMBosonDefinition("Higgs", "\u0397", 126.09e9D, -2, 28); - //deadEnd - public static final EMDecay deadEnd = new EMDecay(boson_Y__, boson_Y__); - public static final EMDecay deadEndHalf = new EMDecay(boson_Y__); - public static final EMDefinitionStack boson_Y__1 =new EMDefinitionStack(boson_Y__,1); - - private EMBosonDefinition(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, NO_DECAY); - boson_H__.init(null, 1.56e-22D, 2, 2, - new EMDecay(0.01D, quark_b, quark_b_), - new EMDecay(0.02D, lepton_t, lepton_t_), - new EMDecay(0.96D, new EMDefinitionStack(boson_Y__, 4)), - deadEnd); +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 getLocalizedName() { - return translateToLocal("tt.keyword.Boson")+": " + getName(); - } - - @Override - public boolean isTimeSpanHalfLife() { - return this==boson_H__; + return translateToLocal("tt.keyword.Boson")+": " + translateToLocal(getUnlocalizedName()); } } 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..f8f05b80ee --- /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 getLocalizedName() { + return translateToLocal("tt.keyword.Fermion")+": " + translateToLocal(getUnlocalizedName()); + } +} 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..fb8128c3a5 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMGaugeBosonDefinition.java @@ -0,0 +1,83 @@ +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.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, 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 getLocalizedName() { + return translateToLocal("tt.keyword.GaugeBoson") + ": " + translateToLocal(getUnlocalizedName()); + } + + @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 index 38e537ec59..c665bf23b4 100644 --- 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 @@ -1,57 +1,60 @@ 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.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMBosonDefinition.*; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMBosonDefinition.boson_Y__; +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 final class EMLeptonDefinition extends EMPrimitiveTemplate { +public class EMLeptonDefinition extends EMFermionDefinition { public static final EMLeptonDefinition - lepton_e = new EMLeptonDefinition("Electron", "\u03b2-", 1, 0.511e6D, -3, 15), - lepton_m = new EMLeptonDefinition("Muon", "\u03bc-", 2, 105.658e6D, -3, 17), - lepton_t = new EMLeptonDefinition("Tauon", "\u03c4-", 3, 1776.83e6D, -3, 19), - lepton_e_ = new EMLeptonDefinition("Positron", "\u03b2+", -1, 0.511e6D, 3, 16), - lepton_m_ = new EMLeptonDefinition("Antimuon", "\u03bc+", -2, 105.658e6D, 3, 18), - lepton_t_ = new EMLeptonDefinition("Antitauon", "\u03c4+", -3, 1776.83e6D, 3, 20); + 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); - private EMLeptonDefinition(String name, String symbol, int type, double mass, int charge, int ID) { - super(name, symbol, type, mass, charge, -1, ID); + protected EMLeptonDefinition(String name, String symbol, int type, double mass, int charge, int ID,String bind) { + super(name, symbol, type, mass, charge, -1, ID,bind); //this.itemThing=null; //this.fluidThing=null; } - public static void run() { - lepton_e.init(lepton_e_, STABLE_RAW_LIFE_TIME, 0, 1, + 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(lepton_m_, 2.197019e-6D, 0, 1, + 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(lepton_t_, 2.906e-13D, 1, 3, + 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(lepton_e, STABLE_RAW_LIFE_TIME, 0, 1, + lepton_e_.init(registry,lepton_e, STABLE_RAW_LIFE_TIME, 0, 1, deadEnd, new EMDecay(lepton_e,boson_Y__)); - lepton_m_.init(lepton_m, 2.197019e-6F, 0, 1, + 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(lepton_t, 2.906e-13F, 1, 3, + 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__), @@ -60,7 +63,7 @@ public final class EMLeptonDefinition extends EMPrimitiveTemplate { @Override public String getLocalizedName() { - return translateToLocal("tt.keyword.Lepton")+": " + getName(); + return translateToLocal("tt.keyword.Lepton")+": " + translateToLocal(getUnlocalizedName()); } @Override 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 index 9af7b97cb4..9ef04e8c7e 100644 --- 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 @@ -1,56 +1,59 @@ 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.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate; -import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMBosonDefinition.*; +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 final class EMNeutrinoDefinition extends EMPrimitiveTemplate { +public class EMNeutrinoDefinition extends EMLeptonDefinition { public static final EMNeutrinoDefinition - lepton_Ve = new EMNeutrinoDefinition("Electron neutrino", "\u03bd\u03b2", 1, 2e0D, 21), - lepton_Vm = new EMNeutrinoDefinition("Muon neutrino", "\u03bd\u03bc", 2, 0.15e6D, 23), - lepton_Vt = new EMNeutrinoDefinition("Tauon neutrino", "\u03bd\u03c4", 3, 15e6D, 25), - lepton_Ve_ = new EMNeutrinoDefinition("Positron neutrino", "~\u03bd\u03b2", -1, 2e0D, 22), - lepton_Vm_ = new EMNeutrinoDefinition("Antimuon neutrino", "~\u03bd\u03bc", -2, 0.15e6D, 24), - lepton_Vt_ = new EMNeutrinoDefinition("Antitauon neutrino", "~\u03bd\u03c4", -3, 15e6D, 26); + 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); - private EMNeutrinoDefinition(String name, String symbol, int type, double mass, int ID) { - super(name, symbol, type, mass, 0, -1, ID); + 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() { - lepton_Ve.init(lepton_Ve_, 1D, -1, -1, + 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(lepton_Vm_, 1D, 1, 0, + lepton_Vm.init(registry,lepton_Vm_, 1D, 1, 0, new EMDecay(0.825D, nothing), deadEndHalf); - lepton_Vt.init(lepton_Vt_, 1, 1, 0, + lepton_Vt.init(registry,lepton_Vt_, 1, 1, 0, new EMDecay(0.75F, nothing), deadEnd); - lepton_Ve_.init(lepton_Ve, 1, -1, -1, + lepton_Ve_.init(registry,lepton_Ve, 1, -1, -1, EMDecay.NO_PRODUCT); - lepton_Vm_.init(lepton_Vm, 1, 1, 0, + lepton_Vm_.init(registry,lepton_Vm, 1, 1, 0, new EMDecay(0.825F, nothing), deadEndHalf); - lepton_Vt_.init(lepton_Vt, 1, 1, 0, + lepton_Vt_.init(registry,lepton_Vt, 1, 1, 0, new EMDecay(0.75F, nothing), deadEnd); } @Override public String getLocalizedName() { - return translateToLocal("tt.keyword.Neutrino")+": " + getName(); + return translateToLocal("tt.keyword.Neutrino")+": " + translateToLocal(getUnlocalizedName()); } @Override 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 index 41da06567d..60f87ac83b 100644 --- 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 @@ -1,6 +1,8 @@ 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; @@ -8,29 +10,45 @@ import static net.minecraft.util.StatCollector.translateToLocal; /** * Created by danie_000 on 22.10.2016. */ -public final class EMPrimitiveDefinition extends EMPrimitiveTemplate { +public class EMPrimitiveDefinition extends EMPrimitiveTemplate { public static final EMPrimitiveDefinition - nbtE__ = new EMPrimitiveDefinition("NBT ERROR", "!", 0, 0D, Integer.MIN_VALUE, 0), - null__ = new EMPrimitiveDefinition("NULL POINTER", ".", 0, 0D, -3, Integer.MIN_VALUE), - space__ = new EMPrimitiveDefinition("Space", "_", 0, 0D, -4, Integer.MIN_VALUE+1), - magic = new EMPrimitiveDefinition("Magic", "Ma", 4, 1e5D, 0, 1), - magic_ = new EMPrimitiveDefinition("Antimagic", "~Ma", -4, 1e5D, 0, 2); - - private EMPrimitiveDefinition(String name, String symbol, int type, double mass, int color, int ID) { - super(name, symbol, type, mass, 0, color, ID); + 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() { - nbtE__.init(null__, NO_DECAY_RAW_LIFE_TIME, -1, -1, NO_DECAY); - null__.init(null__, NO_DECAY_RAW_LIFE_TIME, -1, -1, NO_DECAY); - space__.init(space__, NO_DECAY_RAW_LIFE_TIME, -1, -1, NO_DECAY); - magic.init(magic_, NO_DECAY_RAW_LIFE_TIME, -1, -1, NO_DECAY); - magic_.init(magic, NO_DECAY_RAW_LIFE_TIME, -1, -1, NO_DECAY); + 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 getLocalizedName() { - return translateToLocal("tt.keyword.Primitive")+": " + getName(); + return translateToLocal("tt.keyword.Primitive") + ": " + translateToLocal(getUnlocalizedName()); } @Override 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 index 3f19205aeb..19162bf90d 100644 --- 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 @@ -1,8 +1,10 @@ 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.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.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; @@ -10,94 +12,95 @@ import static net.minecraft.util.StatCollector.translateToLocal; /** * Created by danie_000 on 22.10.2016. */ -public final class EMQuarkDefinition extends EMPrimitiveTemplate { +public class EMQuarkDefinition extends EMFermionDefinition { public static final EMQuarkDefinition - quark_u = new EMQuarkDefinition("Up", "u", 1, 2.3e6D, 2, 3), - quark_c = new EMQuarkDefinition("Charm", "c", 2, 1.29e9D, 2, 9), - quark_t = new EMQuarkDefinition("Top", "t", 3, 172.44e9D, 2, 13), - quark_d = new EMQuarkDefinition("Down", "d", 1, 4.8e6D, -1, 5), - quark_s = new EMQuarkDefinition("Strange", "s", 2, 95e6D, -1, 7), - quark_b = new EMQuarkDefinition("Bottom", "b", 3, 4.65e9D, -1, 11), - quark_u_ = new EMQuarkDefinition("AntiUp", "~u", -1, 2.3e6D, -2, 4), - quark_c_ = new EMQuarkDefinition("AntiCharm", "~c", -2, 1.29e9D, -2, 10), - quark_t_ = new EMQuarkDefinition("AntiTop", "~t", -3, 172.44e9D, -2, 14), - quark_d_ = new EMQuarkDefinition("AntiDown", "~d", -1, 4.8e6D, 1, 6), - quark_s_ = new EMQuarkDefinition("AntiStrange", "~s", -2, 95e6D, 1, 8), - quark_b_ = new EMQuarkDefinition("AntiBottom", "~b", -3, 4.65e9D, 1, 12); + 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"); - private EMQuarkDefinition(String name, String symbol, int type, double mass, int charge, int ID) { - super(name, symbol, type, mass, charge, 0, ID); + 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() { - quark_u.init(quark_u_, STABLE_RAW_LIFE_TIME, 3, -1, + 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), - EMBosonDefinition.deadEnd);//makes photons and don't care - quark_c.init(quark_c_, 0.5e-13D, 1, -1, + 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), - EMBosonDefinition.deadEnd);//makes photons and don't care - quark_t.init(quark_t_, 2.5e-26D, 0, -1, + 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), - EMBosonDefinition.deadEnd);//makes photons and don't care + deadEnd);//makes photons and don't care - quark_d.init(quark_d_, STABLE_RAW_LIFE_TIME, 3, -1, + 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_), - EMBosonDefinition.deadEnd);//makes photons and don't care - quark_s.init(quark_s_, 0.6e-9D, 1, -1, + 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_), - EMBosonDefinition.deadEnd);//makes photons and don't care - quark_b.init(quark_b_, 0.7e-13D, 0, -1, + 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_), - EMBosonDefinition.deadEnd);//makes photons and don't care + deadEnd);//makes photons and don't care - quark_u_.init(quark_u, STABLE_RAW_LIFE_TIME, 3, -1, + 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_), - EMBosonDefinition.deadEnd);//makes photons and don't care - quark_c_.init(quark_c, 0.5e-13D, 1, -1, + 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_), - EMBosonDefinition.deadEnd);//makes photons and don't care - quark_t_.init(quark_t, 2.5e-26F, 0, -1, + 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_), - EMBosonDefinition.deadEnd);//makes photons and don't care + deadEnd);//makes photons and don't care - quark_d_.init(quark_d, STABLE_RAW_LIFE_TIME, 3, -1, + 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), - EMBosonDefinition.deadEnd);//makes photons and don't care - quark_s_.init(quark_s, 0.6e-9F, 1, -1, + 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), - EMBosonDefinition.deadEnd);//makes photons and don't care - quark_b_.init(quark_b, 0.7e-13F, 0, -1, + 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), - EMBosonDefinition.deadEnd);//makes photons and don't care + deadEnd);//makes photons and don't care } @Override public String getLocalizedName() { - return translateToLocal("tt.keyword.Quark")+": " + getName(); + return translateToLocal("tt.keyword.Quark")+": " + translateToLocal(getUnlocalizedName()); } @Override 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..5070954847 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMScalarBosonDefinition.java @@ -0,0 +1,46 @@ +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.*; +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, 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 getLocalizedName() { + return translateToLocal("tt.keyword.ScalarBoson")+": " + translateToLocal(getUnlocalizedName()); + } + + @Override + public boolean isTimeSpanHalfLife() { + return true; + } +} 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 b7310485a2..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,11 +1,10 @@ package com.github.technus.tectech.recipe; -import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMDefinitionsRegistry; +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 com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.util.GT_Recipe; import net.minecraft.item.ItemStack; @@ -16,8 +15,6 @@ 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 EMConstantStackMap[] input; @@ -257,20 +254,6 @@ public class TT_recipe extends GT_Recipe { return mRecipeMap.get(stack); } - public T findRecipe(ItemStack dataHandler){ - if(dataHandler==null || dataHandler.stackTagCompound==null) { - return null; - } - try { - return mRecipeMap.get(EMDefinitionsRegistry.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/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_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..f3574007f2 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 @@ -18,7 +18,7 @@ import net.minecraft.world.IBlockAccess; import java.util.List; import static com.github.technus.tectech.TecTech.tectechTexturePage1; -import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; +import static com.github.technus.tectech.TecTech.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 index c65870eeb7..9648e41d8d 100644 --- 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 @@ -16,7 +16,7 @@ import net.minecraft.world.IBlockAccess; import java.util.List; -import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; +import static com.github.technus.tectech.TecTech.creativeTabTecTech; /** * Created by danie_000 on 03.10.2016. 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 index 752f2d1bcc..3d00fcdf35 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java +++ b/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java @@ -12,7 +12,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 net.minecraft.util.StatCollector.translateToLocal; /** 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 2062173cfd..d909054196 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,15 +1,15 @@ package com.github.technus.tectech.thing.item; -import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMDefinitionsRegistry; -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.maps.EMInstanceStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.IEMContainer; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; 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.Util; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -30,8 +30,8 @@ import java.util.List; import static com.github.technus.tectech.Reference.MODID; 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.EMTransformationInfo.*; +import static com.github.technus.tectech.TecTech.creativeTabTecTech; +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; @@ -61,7 +61,7 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE EMInstanceStackMap content = ((IEMContainer) metaTE).getContentHandler(); if (tNBT.hasKey("content")) { try { - content.putUnifyAll(EMInstanceStackMap.fromNBT(tNBT.getCompoundTag("content"))); + content.putUnifyAll(EMInstanceStackMap.fromNBT(TecTech.definitionsRegistry,tNBT.getCompoundTag("content"))); } catch (EMException e) { if (DEBUG_MODE) { e.printStackTrace(); @@ -75,7 +75,7 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE } else if (content.hasStacks()) { ((IEMContainer) metaTE).purgeOverflow(); tNBT.setTag("info", content.getInfoNBT()); - tNBT.setTag("content", content.toNBT()); + tNBT.setTag("content", content.toNBT(TecTech.definitionsRegistry)); tNBT.setTag("symbols", content.getShortSymbolsNBT()); content.clear(); } @@ -94,7 +94,7 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE } if (tNBT.hasKey("content")) { try { - content.putUnifyAll(EMInstanceStackMap.fromNBT(tNBT.getCompoundTag("content"))); + content.putUnifyAll(EMInstanceStackMap.fromNBT(TecTech.definitionsRegistry,tNBT.getCompoundTag("content"))); } catch (EMException e) { if (DEBUG_MODE) { e.printStackTrace(); @@ -106,7 +106,7 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE tNBT.removeTag("symbols"); } else if (content.hasStacks()) { tNBT.setTag("info", content.getInfoNBT()); - tNBT.setTag("content", content.toNBT()); + tNBT.setTag("content", content.toNBT(TecTech.definitionsRegistry)); tNBT.setTag("symbols", content.getShortSymbolsNBT()); content.clear(); } @@ -140,10 +140,10 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE ItemStack that = new ItemStack(this, 1); that.setTagCompound(new NBTTagCompound()); list.add(that); - for(IEMDefinition definition: EMDefinitionsRegistry.getStacksRegisteredForDisplay()){ - list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" 1 mol"),new EMInstanceStackMap(new EMInstanceStack(definition, AVOGADRO_CONSTANT)))); - list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" 144 mol"),new EMInstanceStackMap(new EMInstanceStack(definition, AVOGADRO_CONSTANT_144)))); - list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" 1000 mol"),new EMInstanceStackMap(new EMInstanceStack(definition, AVOGADRO_CONSTANT_1000)))); + for(IEMDefinition definition: TecTech.definitionsRegistry.getStacksRegisteredForDisplay()){ + list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" "+1+" "+translateToLocal("tt.keyword.mbMols")),new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_MATERIAL_AMOUNT)))); + list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" "+1+" "+translateToLocal("tt.keyword.itemMols")),new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_ITEM)))); + list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" "+1000+" "+translateToLocal("tt.keyword.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 2cca6474f4..f0f59e0e86 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,5 +1,6 @@ package com.github.technus.tectech.thing.item; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.util.Util; import com.github.technus.tectech.font.TecTechFontRender; @@ -20,7 +21,7 @@ import java.util.List; import static com.github.technus.tectech.Reference.MODID; 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.TecTech.creativeTabTecTech; import static cpw.mods.fml.relauncher.Side.CLIENT; import static net.minecraft.util.StatCollector.translateToLocal; @@ -48,7 +49,7 @@ public final class ElementalDefinitionContainer_EM extends Item implements IElem EMConstantStackMap oldMap =null; if (tNBT.hasKey("content")) { try { - oldMap= EMConstantStackMap.fromNBT(tNBT.getCompoundTag("content")); + oldMap= EMConstantStackMap.fromNBT(TecTech.definitionsRegistry,tNBT.getCompoundTag("content")); } catch (EMException e) { if (DEBUG_MODE) { e.printStackTrace(); @@ -56,7 +57,7 @@ public final class ElementalDefinitionContainer_EM extends Item implements IElem } } tNBT.setTag("info", definitions.getInfoNBT()); - tNBT.setTag("content", definitions.toNBT()); + tNBT.setTag("content", definitions.toNBT(TecTech.definitionsRegistry)); tNBT.setTag("symbols",definitions.getShortSymbolsNBT()); return oldMap; } @@ -71,7 +72,7 @@ public final class ElementalDefinitionContainer_EM extends Item implements IElem return null; } try { - return EMConstantStackMap.fromNBT(tNBT.getCompoundTag("content")); + return EMConstantStackMap.fromNBT(TecTech.definitionsRegistry,tNBT.getCompoundTag("content")); } catch (EMException e) { if (DEBUG_MODE) { e.printStackTrace(); @@ -91,7 +92,7 @@ public final class ElementalDefinitionContainer_EM extends Item implements IElem EMConstantStackMap oldMap =null; if (tNBT.hasKey("content")) { try { - oldMap= EMConstantStackMap.fromNBT(tNBT.getCompoundTag("content")); + oldMap= EMConstantStackMap.fromNBT(TecTech.definitionsRegistry,tNBT.getCompoundTag("content")); } catch (EMException e) { if (DEBUG_MODE) { e.printStackTrace(); 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 e517fe5f2a..8b8133a1e2 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 @@ -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 cpw.mods.fml.relauncher.Side.CLIENT; import static net.minecraft.util.StatCollector.translateToLocal; 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..4fca682268 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 @@ -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 index d71abb34b7..b74f40f336 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java +++ b/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java @@ -12,7 +12,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 net.minecraft.util.StatCollector.translateToLocal; /** 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..7f9e0f0a4a 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 @@ -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; 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_ElementalContainer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java index 0950a173ab..84f18ad2bf 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 @@ -24,7 +24,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.EMTransformationInfo.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; @@ -83,7 +83,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,7 +95,7 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta overflowMatter = aNBT.getFloat("overflowMatter")+aNBT.getDouble("OverflowMatter"); id = aNBT.getShort("eID"); try { - content = EMInstanceStackMap.fromNBT(aNBT.getCompoundTag("eM_Stacks")); + content = EMInstanceStackMap.fromNBT(TecTech.definitionsRegistry,aNBT.getCompoundTag("eM_Stacks")); } catch (EMException e) { if (DEBUG_MODE) { e.printStackTrace(); @@ -210,7 +210,7 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta } public double getMaxStackSize() { - return mTier * (mTier - 7) * 64D * AVOGADRO_CONSTANT_144; + return mTier * (mTier - 7) * 64D * EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED; } @Override 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/GT_MetaTileEntity_EM_collider.java deleted file mode 100644 index 3015d024c7..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java +++ /dev/null @@ -1,717 +0,0 @@ -package com.github.technus.tectech.thing.metaTileEntity.multi; - -import com.github.technus.tectech.TecTech; -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.constructable.IConstructable; -import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecayResult; -import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMDefinitionStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate; -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.mechanics.structure.IStructureDefinition; -import com.github.technus.tectech.mechanics.structure.StructureDefinition; -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; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunction; -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 cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; -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.EMTransformationInfo.AVOGADRO_CONSTANT; -import static com.github.technus.tectech.mechanics.structure.StructureUtility.*; -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 net.minecraft.util.StatCollector.translateToLocal; - -/** - * Created by danie_000 on 17.12.2016. - */ -public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { - //region variables - private static Textures.BlockIcons.CustomIcon ScreenOFF; - private static Textures.BlockIcons.CustomIcon ScreenON; - private static Textures.BlockIcons.CustomIcon ScreenON_Slave; - private static Textures.BlockIcons.CustomIcon ScreenOFF_Slave; - - protected static final byte FUSE_MODE = 0, COLLIDE_MODE = 1; - private static double MASS_TO_EU_INSTANT; - private static int STARTUP_COST, KEEPUP_COST; - - protected byte eTier = 0; - protected EMInstanceStack stack; - private long plasmaEnergy; - - protected boolean started = false; - //endregion - - //region collision handlers - public static final HashMap FUSE_HANDLERS = new HashMap<>(); - public static final HashMap PRIMITIVE_FUSE_HANDLERS = new HashMap<>(); - - public interface IPrimitiveColliderHandler { - void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out); - } - - public interface IColliderHandler extends IPrimitiveColliderHandler { - byte getRequiredTier(); - } - - static { - FUSE_HANDLERS.put((EMAtomDefinition.getClassTypeStatic() << 16) | EMAtomDefinition.getClassTypeStatic(), new IColliderHandler() { - @Override - public void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { - try { - 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.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())); - } - } - - @Override - public byte getRequiredTier() { - return 1; - } - }); - registerSimpleAtomFuse(EMHadronDefinition.getClassTypeStatic()); - registerSimpleAtomFuse(EMComplexAspectDefinition.getClassTypeStatic()); - registerSimpleAtomFuse(EMPrimitiveTemplate.getClassTypeStatic()); - - FUSE_HANDLERS.put((EMHadronDefinition.getClassTypeStatic() << 16) | EMHadronDefinition.getClassTypeStatic(), new IColliderHandler() { - @Override - public void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { - try { - 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.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())); - } - } - - @Override - public byte getRequiredTier() { - return 2; - } - }); - FUSE_HANDLERS.put((EMHadronDefinition.getClassTypeStatic() << 16) | EMPrimitiveTemplate.getClassTypeStatic(), new IColliderHandler() { - @Override - public void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { - try { - 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.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())); - } - } - - @Override - public byte getRequiredTier() { - return 2; - } - }); - - registerSimpleAspectFuse(EMComplexAspectDefinition.getClassTypeStatic()); - registerSimpleAspectFuse(EMPrimitiveTemplate.getClassTypeStatic()); - - FUSE_HANDLERS.put((EMPrimitiveTemplate.getClassTypeStatic() << 16) | EMPrimitiveTemplate.getClassTypeStatic(), new IColliderHandler() { - @Override - 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 { - out.putUnifyAll(in1, in2); - } - } - - @Override - public byte getRequiredTier() { - return 2; - } - }); - - PRIMITIVE_FUSE_HANDLERS.put(EMQuarkDefinition.class.getName() + '\0' + EMQuarkDefinition.class.getName(), (in1, in2, out) -> { - try { - 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.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(EMPrimalAspectDefinition.class.getName() + '\0' + EMPrimalAspectDefinition.class.getName(), (in1, in2, out) -> { - if (fuseAspects(in1, in2, out)) return; - 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(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { - try { - 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; - } - return false; - } - - private static void registerSimpleAspectFuse(byte classTypeStatic) { - FUSE_HANDLERS.put((EMComplexAspectDefinition.getClassTypeStatic() << 16) | classTypeStatic, new IColliderHandler() { - @Override - public void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { - if (fuseAspects(in1, in2, out)) return; - 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())); - } - } - - @Override - public byte getRequiredTier() { - return 1; - } - }); - } - - private static void registerSimpleAtomFuse(byte classTypeStatic) { - FUSE_HANDLERS.put((EMAtomDefinition.getClassTypeStatic() << 16) | classTypeStatic, new IColliderHandler() { - @Override - public void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { - try { - 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.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())); - } - } - - @Override - public byte getRequiredTier() { - return 1; - } - }); - } - //endregion - - //region parameters - protected Parameters.Group.ParameterIn mode; - private static final IStatusFunction MODE_STATUS = (base_EM, p) -> { - if (base_EM.isMaster()) { - double mode = p.get(); - if (mode == FUSE_MODE || mode == COLLIDE_MODE) { - return STATUS_OK; - } else if (mode > 1) { - return STATUS_TOO_HIGH; - } else if (mode < 0) { - return STATUS_TOO_LOW; - } - return STATUS_WRONG; - } - return STATUS_OK; - }; - private static final INameFunction MODE_NAME = (base_EM, p) -> { - if (base_EM.isMaster()) { - double mode = p.get(); - if (mode == FUSE_MODE) { - return translateToLocal("gt.blockmachines.multimachine.em.collider.mode.0");//Mode: Fuse - } else if (mode == COLLIDE_MODE) { - return translateToLocal("gt.blockmachines.multimachine.em.collider.mode.1");//Mode: Collide - } - return translateToLocal("gt.blockmachines.multimachine.em.collider.mode.2");//Mode: Undefined - } - return translateToLocal("gt.blockmachines.multimachine.em.collider.mode.3");//Currently Slaves... - }; - //endregion - - //region structure - //use multi A energy inputs, use less power the longer it runs - private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition - .builder() - .addShapeOldApi("main", new String[][]{ - {"I0A0A0", "I00000", "I0A0A0",}, - {"H0000000", "G001111100", "H0000000",}, - {"F22223332222", "F41155555114", "F22223332222",}, - {"E2000000000002", "E4155111115514", "E2000000000002",}, - {"D20000E00002", "D41511E11514", "D20000E00002",}, - {"C2000I0002", "C4151I1514", "C2000I0002",}, - {"B2000K0002", "B4151K1514", "B2000K0002",}, - {"B200M002", "A0151M1510", "B200M002",}, - {"A0200M0020", "A0151M1510", "A0200M0020",}, - {"0020O0200", "0151O1510", "0020O0200",}, - {"A030O030", "0151O1510", "A030O030",}, - {"0030O0300", "0151O1510", "0030O0300",}, - {"A030O030", "0151O1510", "A030O030",}, - {"0020O0200", "0151O1510", "0020O0200",}, - {"A0200M0020", "A0151M1510", "A0200M0020",}, - {"B200M002", "A0151M1510", "B200M002",}, - {"B2000K0002", "B4151K1514", "B2000K0002",}, - {"C2000I0002", "C4151I1514", "C2000I0002",}, - {"D200002&&&200002", "D415112&.&211514", "D200002&&&200002",}, - {"E20!!22222!!02", "E4155111115514", "E20!!22222!!02",}, - {"F2222#$#2222", "F41155555114", "F2222#$#2222",}, - }) - .addElement('0', ofBlock(sBlockCasingsTT, 4)) - .addElement('1', ofBlock(sBlockCasingsTT, 7)) - .addElement('2', defer(t -> (int) t.eTier, (t, item) -> 2 - (item.stackSize & 1), - error(), ofBlock(sBlockCasingsTT, 4), ofBlock(sBlockCasingsTT, 5))) - .addElement('3', ofBlock(QuantumGlassBlock.INSTANCE, 0)) - .addElement('4', defer(t -> (int) t.eTier, (t, item) -> 2 - (item.stackSize & 1), - error(), ofBlock(sBlockCasingsTT, 4), ofBlock(sBlockCasingsTT, 6))) - .addElement('5', defer(t -> (int) t.eTier, (t, item) -> 2 - (item.stackSize & 1), - error(), ofBlock(sBlockCasingsTT, 8), ofBlock(sBlockCasingsTT, 9))) - .addElement('&', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addClassicToMachineList, - textureOffset, 1, sBlockCasingsTT, 0)) - .addElement('!', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addElementalInputToMachineList, - textureOffset + 4, 2, sBlockCasingsTT, 4)) - .addElement('$', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addElementalOutputToMachineList, - textureOffset + 4, 3, sBlockCasingsTT, 4)) - .addElement('#', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addElementalMufflerToMachineList, - textureOffset + 4, 4, sBlockCasingsTT, 4)) - .build(); - private static final String[] description = new String[]{ - EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", - translateToLocal("gt.blockmachines.multimachine.em.collider.hint.0"),//1 - Classic Hatches or High Power Casing - translateToLocal("gt.blockmachines.multimachine.em.collider.hint.1"),//2 - Elemental Input Hatches or Molecular Casing - translateToLocal("gt.blockmachines.multimachine.em.collider.hint.2"),//3 - Elemental Output Hatches or Molecular Casing - translateToLocal("gt.blockmachines.multimachine.em.collider.hint.3"),//4 - Elemental Overflow Hatches or Molecular Casing - translateToLocal("gt.blockmachines.multimachine.em.collider.hint.4"),//General - Another Controller facing opposite direction - }; - - @Override - public IStructureDefinition getStructure_EM() { - return STRUCTURE_DEFINITION; - } - - //endregion - - public GT_MetaTileEntity_EM_collider(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GT_MetaTileEntity_EM_collider(String aName) { - super(aName); - } - - public static void setValues(int heliumPlasmaValue) { - double MASS_TO_EU_PARTIAL = heliumPlasmaValue / (1.75893000478707E07* AVOGADRO_CONSTANT);//mass diff - MASS_TO_EU_INSTANT = MASS_TO_EU_PARTIAL * 20; - STARTUP_COST = -heliumPlasmaValue * 10000; - KEEPUP_COST = -heliumPlasmaValue; - } - - 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.getDefinition().fusionMakesEnergy(stack.getEnergy()) && - partner.stack.getDefinition().fusionMakesEnergy(partner.stack.getEnergy()); - - EMInstanceStack stack2 = partner.stack; - double preMass = add(stack2.getMass(),stack.getMass()); - //System.out.println("preMass = " + preMass); - - EMInstanceStackMap map = new EMInstanceStackMap(); - IColliderHandler colliderHandler; - if (stack2.getDefinition().getClassType() > stack.getDefinition().getClassType()) {//always bigger first - colliderHandler = FUSE_HANDLERS.get((stack2.getDefinition().getClassType() << 16) | stack.getDefinition().getClassType()); - if (handleRecipe(stack2, map, colliderHandler)) return 0; - } else { - colliderHandler = FUSE_HANDLERS.get((stack.getDefinition().getClassType() << 16) | stack2.getDefinition().getClassType()); - if (handleRecipe(stack2, map, colliderHandler)) return 0; - } - for (EMInstanceStack newStack : map.valuesToArray()) { - check &= newStack.getDefinition().fusionMakesEnergy(newStack.getEnergy()); - } - //System.out.println("outputEM[0].getMass() = " + outputEM[0].getMass()); - outputEM = new EMInstanceStackMap[]{map}; - - partner.stack = stack = null; - //System.out.println("check = " + check); - //System.out.println("preMass-map.getMass() = " + (preMass - map.getMass())); - return check ? preMass - map.getMass() : Math.min(preMass - map.getMass(), 0); - } - return 0; - } - - 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 - EMInstanceStack stack2 = partner.stack; - double preMass = stack2.getMass() + stack.getMass(); - //System.out.println("preMass = " + preMass); - - EMInstanceStackMap map = new EMInstanceStackMap(); - IColliderHandler colliderHandler; - if (stack2.getDefinition().getClassType() > stack.getDefinition().getClassType()) {//always bigger first - colliderHandler = FUSE_HANDLERS.get((stack2.getDefinition().getClassType() << 16) | stack.getDefinition().getClassType()); - if (handleRecipe(stack2, map, colliderHandler)) return 0; - } else { - colliderHandler = FUSE_HANDLERS.get((stack.getDefinition().getClassType() << 16) | stack2.getDefinition().getClassType()); - if (handleRecipe(stack2, map, colliderHandler)) return 0; - } - //System.out.println("outputEM[0].getMass() = " + outputEM[0].getMass()); - outputEM = new EMInstanceStackMap[]{map}; - - partner.stack = stack = null; - //System.out.println("check = " + check); - //System.out.println("preMass-map.getMass() = " + (preMass - map.getMass())); - return Math.min(preMass - map.getMass(), 0); - } - return 0; - } - - 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 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 gregTechBaseTileEntity = iGregTechTileEntity.getIGregTechTileEntityOffset(xDir, yDir, zDir); - if (gregTechBaseTileEntity != null) { - IMetaTileEntity gregTechMetaTileEntity = gregTechBaseTileEntity.getMetaTileEntity(); - return gregTechMetaTileEntity instanceof GT_MetaTileEntity_EM_collider && - ((GT_MetaTileEntity_EM_collider) gregTechMetaTileEntity).mMachine && - gregTechBaseTileEntity.getBackFacing() == iGregTechTileEntity.getFrontFacing() ? - (GT_MetaTileEntity_EM_collider) gregTechMetaTileEntity : null; - } - return null; - } - - protected final boolean isMaster() { - return getBaseMetaTileEntity().getFrontFacing() % 2 == 0; - } - - private void makeEU(double massDiff) { - plasmaEnergy += massDiff * MASS_TO_EU_INSTANT; - if (DEBUG_MODE) { - System.out.println("plasmaEnergy = " + plasmaEnergy); - } - } - - private EMInstanceStackMap tickStack() { - if (stack == null) { - return null; - } - stack.setAge(stack.getAge() + 1); - EMDecayResult newInstances = stack.decay(1, stack.getAge(), 0); - if (newInstances == null) { - stack.nextColor(); - return null; - } else { - stack = newInstances.getOutput().removeKey(newInstances.getOutput().getLast().getDefinition()); - return newInstances.getOutput(); - } - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_collider(mName); - } - - @Override - public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX * 2; - int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ * 2; - if (iGregTechTileEntity.getBlockOffset(xDir, 0, zDir) != sBlockCasingsTT) { - eTier = 0; - return false; - } - - if (iGregTechTileEntity.getMetaIDOffset(xDir, 0, zDir) == 8) { - eTier = 1; - } else if (iGregTechTileEntity.getMetaIDOffset(xDir, 0, zDir) == 9) { - eTier = 2; - } else { - eTier = 0; - return false; - } - if (structureCheck_EM("main", 11, 1, 18)) { - return true; - } - eTier = 0; - return false; - } - - @Override - public boolean checkRecipe_EM(ItemStack itemStack) { - GT_MetaTileEntity_EM_collider partner = getPartner(); - if (partner == null) { - return false; - } - mEfficiencyIncrease = 10000; - if (started) { - if (stack == null) { - for (GT_MetaTileEntity_Hatch_InputElemental inputElemental : eInputHatches) { - EMInstanceStackMap container = inputElemental.getContentHandler(); - if (container.isEmpty()) { - continue; - } - 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; - } - mMaxProgresstime = 20; - mEUt = (int) eut; - eAmpereFlow = 5; - return true; - } - mMaxProgresstime = 20; - mEUt = KEEPUP_COST; - eAmpereFlow = 1; - return true; - } - mMaxProgresstime = 20; - mEUt = KEEPUP_COST; - eAmpereFlow = 2; - } else { - started = true; - mMaxProgresstime = 20; - mEUt = STARTUP_COST; - eAmpereFlow = 10; - } - return true; - } - - @Override - public void outputAfterRecipe_EM() { - GT_MetaTileEntity_EM_collider partner = getPartner(); - if (partner == null) { - if (stack != null) { - cleanMassEM_EM(stack.getMass()); - stack = null; - } - return; - } - if (isMaster()) { - switch ((int) mode.get()) { - case FUSE_MODE: - makeEU(fuse(partner)); - break; - case COLLIDE_MODE: - collide(partner);//todo - break; - default: { - outputEM = new EMInstanceStackMap[2]; - outputEM[1] = tickStack(); - if (outputEM[1] == null) { - outputEM[1] = partner.tickStack(); - } else { - EMInstanceStackMap map = partner.tickStack(); - if (map != null) { - outputEM[1].putUnifyAll(map); - } - } - } - } - if (outputEM != null) { - for (int i = 0, lim = Math.min(outputEM.length, eOutputHatches.size()); i < lim; i++) { - if (outputEM[i] != null) { - eOutputHatches.get(i).getContentHandler().putUnifyAll(outputEM[i]); - outputEM[i] = null; - } - } - } - } - } - - @Override - public String[] getDescription() { - return new String[]{ - CommonValues.TEC_MARK_EM, - translateToLocal("gt.blockmachines.multimachine.em.collider.desc.0"),//Collide matter at extreme velocities. - EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.em.collider.desc.1")//Faster than light*!!! - }; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister aBlockIconRegister) { - ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/EM_COLLIDER"); - ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/EM_COLLIDER_ACTIVE"); - ScreenOFF_Slave = new Textures.BlockIcons.CustomIcon("iconsets/EM_COLLIDER_SLAVE"); - ScreenON_Slave = new Textures.BlockIcons.CustomIcon("iconsets/EM_COLLIDER_ACTIVE_SLAVE"); - super.registerIcons(aBlockIconRegister); - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - if (aFacing % 2 == 0) { - return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4], new TT_RenderedExtendedFacingTexture(aActive ? ScreenON : ScreenOFF)}; - } else { - return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4], new TT_RenderedExtendedFacingTexture(aActive ? ScreenON_Slave : ScreenOFF_Slave)}; - } - } - return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4]}; - } - - @Override - protected void parametersInstantiation_EM() { - Parameters.Group hatch_0 = parametrization.getGroup(0); - mode = hatch_0.makeInParameter(0, FUSE_MODE, MODE_NAME, MODE_STATUS); - } - - @Override - public void parametersStatusesWrite_EM(boolean machineBusy) { - if (isMaster()) { - super.parametersStatusesWrite_EM(machineBusy); - } - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setByte("eTier", eTier);//collider tier - aNBT.setBoolean("eStarted", started); - if (stack != null) { - aNBT.setTag("eStack", stack.toNBT()); - } - aNBT.setLong("ePlasmaEnergy", plasmaEnergy); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - eTier = aNBT.getByte("eTier");//collider tier - started = aNBT.getBoolean("eStarted"); - if (aNBT.hasKey("eStack")) { - stack = EMInstanceStack.fromNBT(aNBT.getCompoundTag("eStack")); - } - plasmaEnergy = aNBT.getLong("ePlasmaEnergy"); - } - - @Override - public void stopMachine() { - started = false; - if (stack != null) { - cleanMassEM_EM(stack.getMass()); - stack = null; - } - super.stopMachine(); - } - - @Override - protected void afterRecipeCheckFailed() { - started = false; - if (stack != null) { - cleanMassEM_EM(stack.getMass()); - stack = null; - } - getBaseMetaTileEntity().disableWorking(); - super.afterRecipeCheckFailed(); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (!aBaseMetaTileEntity.isAllowedToWork()) { - started = false; - } - super.onPreTick(aBaseMetaTileEntity, aTick); - } - - @Override - public void construct(ItemStack stackSize, 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; - if (hintsOnly) { - TecTech.proxy.hint_particle(iGregTechTileEntity.getWorld(), - iGregTechTileEntity.getXCoord() + xDir, - iGregTechTileEntity.getYCoord() + yDir, - iGregTechTileEntity.getZCoord() + zDir, - TT_Container_Casings.sHintCasingsTT, 12); - } - structureBuild_EM("main", 11, 1, 18, hintsOnly, stackSize); - } - - @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_decay.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java index 84dafb8db2..1978d2acfc 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 @@ -31,7 +31,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.EMTransformationInfo.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.structure.Structure.adders; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; @@ -50,7 +50,7 @@ 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; + 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; 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 e769d3e480..7d5961f219 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,12 +1,12 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.mechanics.constructable.IConstructable; 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.EMFluidDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMItemDequantizationInfo; -import com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMOredictDequantizationInfo; +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.mechanics.structure.Structure; import com.github.technus.tectech.mechanics.structure.adders.IHatchAdder; import com.github.technus.tectech.thing.block.QuantumGlassBlock; @@ -100,38 +100,21 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo for (GT_MetaTileEntity_Hatch_InputElemental in : eInputHatches) { EMInstanceStackMap map = in.getContentHandler(); for (EMInstanceStack stack : map.valuesToArray()) { - { - EMFluidDequantizationInfo info = stack.getDefinition().someAmountIntoFluidStack(); - if (info != null) { - if (map.removeAllAmounts(info.input())) { - mOutputFluids = new FluidStack[]{info.output()}; - startRecipe(info.input(), stack.getEnergy()); - return true; - } - } - } - { - EMItemDequantizationInfo info = stack.getDefinition().someAmountIntoItemsStack(); - if (info != null) { - if (map.removeAllAmounts(info.input())) { - mOutputItems = new ItemStack[]{info.output()}; - startRecipe(info.input(), stack.getEnergy()); - return true; - } - } - } - { - EMOredictDequantizationInfo info = stack.getDefinition().someAmountIntoOredictStack(); - if (info != null) { - if (map.removeAllAmounts(info.input())) { - ArrayList items = OreDictionary.getOres(info.getOut()); - if (items != null && !items.isEmpty()) { - mOutputItems = new ItemStack[]{items.get(0)}; - startRecipe(info.input(), stack.getEnergy()); - return true; - } + 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 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; } } } 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 64949fe402..be036050be 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 @@ -31,7 +31,6 @@ import java.util.ArrayList; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; 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.core.transformations.EMTransformationInfo.TRANSFORMATION_INFO; 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.mechanics.structure.Structure.adders; @@ -98,9 +97,9 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock if (inI.length > 0) { for (ItemStack is : inI) { //ITEM STACK quantization - EMItemQuantizationInfo aIQI = TRANSFORMATION_INFO.getItemQuantization().get(new EMItemQuantizationInfo(is, false, null)); + EMItemQuantizationInfo aIQI = TecTech.transformationInfo.getItemQuantization().get(new EMItemQuantizationInfo(is, false, null)); if (aIQI == null) { - aIQI = TRANSFORMATION_INFO.getItemQuantization().get(new EMItemQuantizationInfo(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? @@ -109,11 +108,11 @@ 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)); } - EMOredictQuantizationInfo aOQI = TRANSFORMATION_INFO.getOredictQuantization().get(ID); + EMOredictQuantizationInfo aOQI = TecTech.transformationInfo.getOredictQuantization().get(ID); if (aOQI == null) { continue; } - IEMStack into = aOQI.output(); + 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; @@ -136,7 +135,7 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock FluidStack[] inF = storedFluids.toArray(nullFluid); if (inF.length > 0) { for (FluidStack fs : inF) { - EMFluidQuantizationInfo aFQI = TRANSFORMATION_INFO.getFluidQuantization().get(fs.getFluid().getID()); + EMFluidQuantizationInfo aFQI = TecTech.transformationInfo.getFluidQuantization().get(fs.getFluid().getID()); if (aFQI == null) { continue; } 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 74bb817142..89255b331a 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 @@ -309,7 +309,7 @@ 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.setTag(E_RECIPE_ID, objectResearched.toNBT(TecTech.definitionsRegistry)); tNBT.setString("author", EnumChatFormatting.BLUE + "Tec" + EnumChatFormatting.DARK_BLUE + "Tech" + EnumChatFormatting.WHITE + ' ' + machineType + " EM Recipe Generator"); } else if (objectsScanned != null && CustomItemList.scanContainer.isStackEqual(mInventory[1], false, true)) { ElementalDefinitionScanStorage_EM.setContent(mInventory[1], objectsScanned, scanComplexity); @@ -387,7 +387,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"); } @@ -397,7 +397,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"); } @@ -409,7 +409,7 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa computationRemaining = aNBT.getLong("eComputationRemaining"); computationRequired = aNBT.getLong("eComputationRequired"); if (aNBT.hasKey("eObject")) { - objectResearched = EMDefinitionStack.fromNBT(aNBT.getCompoundTag("eObject")); + objectResearched = EMDefinitionStack.fromNBT(TecTech.definitionsRegistry,aNBT.getCompoundTag("eObject")); if (objectResearched.getDefinition() == nbtE__) { objectResearched = null; } @@ -423,7 +423,7 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa } try { if (aNBT.hasKey("eScanObjects")) { - objectsScanned = EMInstanceStackMap.fromNBT(aNBT.getCompoundTag("eScanObjects")); + objectsScanned = EMInstanceStackMap.fromNBT(TecTech.definitionsRegistry,aNBT.getCompoundTag("eScanObjects")); } } catch (EMException e) { objectsScanned = new EMInstanceStackMap(); 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 9a6f99bed8..2fe43cb8e1 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 @@ -757,7 +757,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); @@ -847,7 +847,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt for (int i = 0; i < outputEM.length; i++) { if (compound.hasKey(Integer.toString(i))) { try { - outputEM[i] = EMInstanceStackMap.fromNBT(compound.getCompoundTag(Integer.toString(i))); + outputEM[i] = EMInstanceStackMap.fromNBT(TecTech.definitionsRegistry,compound.getCompoundTag(Integer.toString(i))); } catch (EMException e) { if (DEBUG_MODE) { e.printStackTrace(); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_collider/GT_MetaTileEntity_EM_collider.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_collider/GT_MetaTileEntity_EM_collider.java new file mode 100644 index 0000000000..cf8f26ff02 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_collider/GT_MetaTileEntity_EM_collider.java @@ -0,0 +1,709 @@ +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.EMComplexAspectDefinition; +import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.EMPrimalAspectDefinition; +import com.github.technus.tectech.mechanics.constructable.IConstructable; +import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecayResult; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMDefinitionStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMInstanceStack; +import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.EMPrimitiveTemplate; +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.mechanics.structure.IStructureDefinition; +import com.github.technus.tectech.mechanics.structure.StructureDefinition; +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; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunction; +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 cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +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.EMTransformationRegistry.EM_COUNT_PER_MATERIAL_AMOUNT; +import static com.github.technus.tectech.mechanics.structure.StructureUtility.*; +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 net.minecraft.util.StatCollector.translateToLocal; + +/** + * Created by danie_000 on 17.12.2016. + */ +public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { + //region variables + private static Textures.BlockIcons.CustomIcon ScreenOFF; + private static Textures.BlockIcons.CustomIcon ScreenON; + private static Textures.BlockIcons.CustomIcon ScreenON_Slave; + private static Textures.BlockIcons.CustomIcon ScreenOFF_Slave; + + protected static final byte FUSE_MODE = 0, COLLIDE_MODE = 1; + private static double MASS_TO_EU_INSTANT; + private static int STARTUP_COST, KEEPUP_COST; + + protected byte eTier = 0; + protected EMInstanceStack stack; + private long plasmaEnergy; + + protected boolean started = false; + //endregion + + //region collision handlers + public static final HashMap FUSE_HANDLERS = new HashMap<>(); + public static final HashMap PRIMITIVE_FUSE_HANDLERS = new HashMap<>(); + + static { + FUSE_HANDLERS.put(((long) EMAtomDefinition.getClassTypeStatic() << 16) | EMAtomDefinition.getClassTypeStatic(), new IColliderHandler() { + @Override + public void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { + try { + 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.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())); + } + } + + @Override + public byte getRequiredTier() { + return 1; + } + }); + registerSimpleAtomFuse(EMHadronDefinition.getClassTypeStatic()); + registerSimpleAtomFuse(EMComplexAspectDefinition.getClassTypeStatic()); + registerSimpleAtomFuse(EMPrimitiveTemplate.getClassTypeStatic()); + + FUSE_HANDLERS.put(((long) EMHadronDefinition.getClassTypeStatic() << 16) | EMHadronDefinition.getClassTypeStatic(), new IColliderHandler() { + @Override + public void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { + try { + 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.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())); + } + } + + @Override + public byte getRequiredTier() { + return 2; + } + }); + FUSE_HANDLERS.put(((long) EMHadronDefinition.getClassTypeStatic() << 16) | EMPrimitiveTemplate.getClassTypeStatic(), new IColliderHandler() { + @Override + public void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { + try { + 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.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())); + } + } + + @Override + public byte getRequiredTier() { + return 2; + } + }); + + registerSimpleAspectFuse(EMComplexAspectDefinition.getClassTypeStatic()); + registerSimpleAspectFuse(EMPrimitiveTemplate.getClassTypeStatic()); + + FUSE_HANDLERS.put(((long) EMPrimitiveTemplate.getClassTypeStatic() << 16) | EMPrimitiveTemplate.getClassTypeStatic(), new IColliderHandler() { + @Override + 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 { + out.putUnifyAll(in1, in2); + } + } + + @Override + public byte getRequiredTier() { + return 2; + } + }); + + PRIMITIVE_FUSE_HANDLERS.put(EMQuarkDefinition.class.getName() + '\0' + EMQuarkDefinition.class.getName(), (in1, in2, out) -> { + try { + 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.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(EMPrimalAspectDefinition.class.getName() + '\0' + EMPrimalAspectDefinition.class.getName(), (in1, in2, out) -> { + if (fuseAspects(in1, in2, out)) return; + 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(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { + try { + 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; + } + return false; + } + + private static void registerSimpleAspectFuse(int classTypeStatic) { + FUSE_HANDLERS.put(((long) EMComplexAspectDefinition.getClassTypeStatic() << 16) | classTypeStatic, new IColliderHandler() { + @Override + public void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { + if (fuseAspects(in1, in2, out)) return; + 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())); + } + } + + @Override + public byte getRequiredTier() { + return 1; + } + }); + } + + private static void registerSimpleAtomFuse(int classTypeStatic) { + FUSE_HANDLERS.put(((long) EMAtomDefinition.getClassTypeStatic() << 16) | classTypeStatic, new IColliderHandler() { + @Override + public void collide(EMInstanceStack in1, EMInstanceStack in2, EMInstanceStackMap out) { + try { + 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.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())); + } + } + + @Override + public byte getRequiredTier() { + return 1; + } + }); + } + //endregion + + //region parameters + protected Parameters.Group.ParameterIn mode; + private static final IStatusFunction MODE_STATUS = (base_EM, p) -> { + if (base_EM.isMaster()) { + double mode = p.get(); + if (mode == FUSE_MODE || mode == COLLIDE_MODE) { + return STATUS_OK; + } else if (mode > 1) { + return STATUS_TOO_HIGH; + } else if (mode < 0) { + return STATUS_TOO_LOW; + } + return STATUS_WRONG; + } + return STATUS_OK; + }; + private static final INameFunction MODE_NAME = (base_EM, p) -> { + if (base_EM.isMaster()) { + double mode = p.get(); + if (mode == FUSE_MODE) { + return translateToLocal("gt.blockmachines.multimachine.em.collider.mode.0");//Mode: Fuse + } else if (mode == COLLIDE_MODE) { + return translateToLocal("gt.blockmachines.multimachine.em.collider.mode.1");//Mode: Collide + } + return translateToLocal("gt.blockmachines.multimachine.em.collider.mode.2");//Mode: Undefined + } + return translateToLocal("gt.blockmachines.multimachine.em.collider.mode.3");//Currently Slaves... + }; + //endregion + + //region structure + //use multi A energy inputs, use less power the longer it runs + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition + .builder() + .addShapeOldApi("main", new String[][]{ + {"I0A0A0", "I00000", "I0A0A0",}, + {"H0000000", "G001111100", "H0000000",}, + {"F22223332222", "F41155555114", "F22223332222",}, + {"E2000000000002", "E4155111115514", "E2000000000002",}, + {"D20000E00002", "D41511E11514", "D20000E00002",}, + {"C2000I0002", "C4151I1514", "C2000I0002",}, + {"B2000K0002", "B4151K1514", "B2000K0002",}, + {"B200M002", "A0151M1510", "B200M002",}, + {"A0200M0020", "A0151M1510", "A0200M0020",}, + {"0020O0200", "0151O1510", "0020O0200",}, + {"A030O030", "0151O1510", "A030O030",}, + {"0030O0300", "0151O1510", "0030O0300",}, + {"A030O030", "0151O1510", "A030O030",}, + {"0020O0200", "0151O1510", "0020O0200",}, + {"A0200M0020", "A0151M1510", "A0200M0020",}, + {"B200M002", "A0151M1510", "B200M002",}, + {"B2000K0002", "B4151K1514", "B2000K0002",}, + {"C2000I0002", "C4151I1514", "C2000I0002",}, + {"D200002&&&200002", "D415112&.&211514", "D200002&&&200002",}, + {"E20!!22222!!02", "E4155111115514", "E20!!22222!!02",}, + {"F2222#$#2222", "F41155555114", "F2222#$#2222",}, + }) + .addElement('0', ofBlock(sBlockCasingsTT, 4)) + .addElement('1', ofBlock(sBlockCasingsTT, 7)) + .addElement('2', defer(t -> (int) t.eTier, (t, item) -> 2 - (item.stackSize & 1), + error(), ofBlock(sBlockCasingsTT, 4), ofBlock(sBlockCasingsTT, 5))) + .addElement('3', ofBlock(QuantumGlassBlock.INSTANCE, 0)) + .addElement('4', defer(t -> (int) t.eTier, (t, item) -> 2 - (item.stackSize & 1), + error(), ofBlock(sBlockCasingsTT, 4), ofBlock(sBlockCasingsTT, 6))) + .addElement('5', defer(t -> (int) t.eTier, (t, item) -> 2 - (item.stackSize & 1), + error(), ofBlock(sBlockCasingsTT, 8), ofBlock(sBlockCasingsTT, 9))) + .addElement('&', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addClassicToMachineList, + textureOffset, 1, sBlockCasingsTT, 0)) + .addElement('!', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addElementalInputToMachineList, + textureOffset + 4, 2, sBlockCasingsTT, 4)) + .addElement('$', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addElementalOutputToMachineList, + textureOffset + 4, 3, sBlockCasingsTT, 4)) + .addElement('#', ofHatchAdderOptional(GT_MetaTileEntity_EM_collider::addElementalMufflerToMachineList, + textureOffset + 4, 4, sBlockCasingsTT, 4)) + .build(); + private static final String[] description = new String[]{ + EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", + translateToLocal("gt.blockmachines.multimachine.em.collider.hint.0"),//1 - Classic Hatches or High Power Casing + translateToLocal("gt.blockmachines.multimachine.em.collider.hint.1"),//2 - Elemental Input Hatches or Molecular Casing + translateToLocal("gt.blockmachines.multimachine.em.collider.hint.2"),//3 - Elemental Output Hatches or Molecular Casing + translateToLocal("gt.blockmachines.multimachine.em.collider.hint.3"),//4 - Elemental Overflow Hatches or Molecular Casing + translateToLocal("gt.blockmachines.multimachine.em.collider.hint.4"),//General - Another Controller facing opposite direction + }; + + @Override + public IStructureDefinition getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + //endregion + + public GT_MetaTileEntity_EM_collider(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_EM_collider(String aName) { + super(aName); + } + + public static void setValues(int heliumPlasmaValue) { + 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; + } + + 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.getDefinition().fusionMakesEnergy(stack.getEnergy()) && + partner.stack.getDefinition().fusionMakesEnergy(partner.stack.getEnergy()); + + EMInstanceStack stack2 = partner.stack; + double preMass = add(stack2.getMass(),stack.getMass()); + //System.out.println("preMass = " + preMass); + + 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.getDefinition().getMatterMassType() << 16) | stack2.getDefinition().getMatterMassType()); + if (handleRecipe(stack2, map, colliderHandler)) return 0; + } + for (EMInstanceStack newStack : map.valuesToArray()) { + check &= newStack.getDefinition().fusionMakesEnergy(newStack.getEnergy()); + } + //System.out.println("outputEM[0].getMass() = " + outputEM[0].getMass()); + outputEM = new EMInstanceStackMap[]{map}; + + partner.stack = stack = null; + //System.out.println("check = " + check); + //System.out.println("preMass-map.getMass() = " + (preMass - map.getMass())); + return check ? preMass - map.getMass() : Math.min(preMass - map.getMass(), 0); + } + return 0; + } + + 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 + EMInstanceStack stack2 = partner.stack; + double preMass = stack2.getMass() + stack.getMass(); + //System.out.println("preMass = " + preMass); + + 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.getDefinition().getMatterMassType() << 16) | stack2.getDefinition().getMatterMassType()); + if (handleRecipe(stack2, map, colliderHandler)) return 0; + } + //System.out.println("outputEM[0].getMass() = " + outputEM[0].getMass()); + outputEM = new EMInstanceStackMap[]{map}; + + partner.stack = stack = null; + //System.out.println("check = " + check); + //System.out.println("preMass-map.getMass() = " + (preMass - map.getMass())); + return Math.min(preMass - map.getMass(), 0); + } + return 0; + } + + 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 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 gregTechBaseTileEntity = iGregTechTileEntity.getIGregTechTileEntityOffset(xDir, yDir, zDir); + if (gregTechBaseTileEntity != null) { + IMetaTileEntity gregTechMetaTileEntity = gregTechBaseTileEntity.getMetaTileEntity(); + return gregTechMetaTileEntity instanceof GT_MetaTileEntity_EM_collider && + ((GT_MetaTileEntity_EM_collider) gregTechMetaTileEntity).mMachine && + gregTechBaseTileEntity.getBackFacing() == iGregTechTileEntity.getFrontFacing() ? + (GT_MetaTileEntity_EM_collider) gregTechMetaTileEntity : null; + } + return null; + } + + protected final boolean isMaster() { + return getBaseMetaTileEntity().getFrontFacing() % 2 == 0; + } + + private void makeEU(double massDiff) { + plasmaEnergy += massDiff * MASS_TO_EU_INSTANT; + if (DEBUG_MODE) { + System.out.println("plasmaEnergy = " + plasmaEnergy); + } + } + + private EMInstanceStackMap tickStack() { + if (stack == null) { + return null; + } + stack.setAge(stack.getAge() + 1); + EMDecayResult newInstances = stack.decay(1, stack.getAge(), 0); + if (newInstances == null) { + stack.nextColor(); + return null; + } else { + stack = newInstances.getOutput().removeKey(newInstances.getOutput().getLast().getDefinition()); + return newInstances.getOutput(); + } + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EM_collider(mName); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX * 2; + int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ * 2; + if (iGregTechTileEntity.getBlockOffset(xDir, 0, zDir) != sBlockCasingsTT) { + eTier = 0; + return false; + } + + if (iGregTechTileEntity.getMetaIDOffset(xDir, 0, zDir) == 8) { + eTier = 1; + } else if (iGregTechTileEntity.getMetaIDOffset(xDir, 0, zDir) == 9) { + eTier = 2; + } else { + eTier = 0; + return false; + } + if (structureCheck_EM("main", 11, 1, 18)) { + return true; + } + eTier = 0; + return false; + } + + @Override + public boolean checkRecipe_EM(ItemStack itemStack) { + GT_MetaTileEntity_EM_collider partner = getPartner(); + if (partner == null) { + return false; + } + mEfficiencyIncrease = 10000; + if (started) { + if (stack == null) { + for (GT_MetaTileEntity_Hatch_InputElemental inputElemental : eInputHatches) { + EMInstanceStackMap container = inputElemental.getContentHandler(); + if (container.isEmpty()) { + continue; + } + 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; + } + mMaxProgresstime = 20; + mEUt = (int) eut; + eAmpereFlow = 5; + return true; + } + mMaxProgresstime = 20; + mEUt = KEEPUP_COST; + eAmpereFlow = 1; + return true; + } + mMaxProgresstime = 20; + mEUt = KEEPUP_COST; + eAmpereFlow = 2; + } else { + started = true; + mMaxProgresstime = 20; + mEUt = STARTUP_COST; + eAmpereFlow = 10; + } + return true; + } + + @Override + public void outputAfterRecipe_EM() { + GT_MetaTileEntity_EM_collider partner = getPartner(); + if (partner == null) { + if (stack != null) { + cleanMassEM_EM(stack.getMass()); + stack = null; + } + return; + } + if (isMaster()) { + switch ((int) mode.get()) { + case FUSE_MODE: + makeEU(fuse(partner)); + break; + case COLLIDE_MODE: + collide(partner);//todo + break; + default: { + outputEM = new EMInstanceStackMap[2]; + outputEM[1] = tickStack(); + if (outputEM[1] == null) { + outputEM[1] = partner.tickStack(); + } else { + EMInstanceStackMap map = partner.tickStack(); + if (map != null) { + outputEM[1].putUnifyAll(map); + } + } + } + } + if (outputEM != null) { + for (int i = 0, lim = Math.min(outputEM.length, eOutputHatches.size()); i < lim; i++) { + if (outputEM[i] != null) { + eOutputHatches.get(i).getContentHandler().putUnifyAll(outputEM[i]); + outputEM[i] = null; + } + } + } + } + } + + @Override + public String[] getDescription() { + return new String[]{ + CommonValues.TEC_MARK_EM, + translateToLocal("gt.blockmachines.multimachine.em.collider.desc.0"),//Collide matter at extreme velocities. + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.em.collider.desc.1")//Faster than light*!!! + }; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/EM_COLLIDER"); + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/EM_COLLIDER_ACTIVE"); + ScreenOFF_Slave = new Textures.BlockIcons.CustomIcon("iconsets/EM_COLLIDER_SLAVE"); + ScreenON_Slave = new Textures.BlockIcons.CustomIcon("iconsets/EM_COLLIDER_ACTIVE_SLAVE"); + super.registerIcons(aBlockIconRegister); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + if (aFacing % 2 == 0) { + return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4], new TT_RenderedExtendedFacingTexture(aActive ? ScreenON : ScreenOFF)}; + } else { + return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4], new TT_RenderedExtendedFacingTexture(aActive ? ScreenON_Slave : ScreenOFF_Slave)}; + } + } + return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4]}; + } + + @Override + protected void parametersInstantiation_EM() { + Parameters.Group hatch_0 = parametrization.getGroup(0); + mode = hatch_0.makeInParameter(0, FUSE_MODE, MODE_NAME, MODE_STATUS); + } + + @Override + public void parametersStatusesWrite_EM(boolean machineBusy) { + if (isMaster()) { + super.parametersStatusesWrite_EM(machineBusy); + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setByte("eTier", eTier);//collider tier + aNBT.setBoolean("eStarted", started); + if (stack != null) { + aNBT.setTag("eStack", stack.toNBT(TecTech.definitionsRegistry)); + } + aNBT.setLong("ePlasmaEnergy", plasmaEnergy); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + eTier = aNBT.getByte("eTier");//collider tier + started = aNBT.getBoolean("eStarted"); + if (aNBT.hasKey("eStack")) { + stack = EMInstanceStack.fromNBT(TecTech.definitionsRegistry,aNBT.getCompoundTag("eStack")); + } + plasmaEnergy = aNBT.getLong("ePlasmaEnergy"); + } + + @Override + public void stopMachine() { + started = false; + if (stack != null) { + cleanMassEM_EM(stack.getMass()); + stack = null; + } + super.stopMachine(); + } + + @Override + protected void afterRecipeCheckFailed() { + started = false; + if (stack != null) { + cleanMassEM_EM(stack.getMass()); + stack = null; + } + getBaseMetaTileEntity().disableWorking(); + super.afterRecipeCheckFailed(); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (!aBaseMetaTileEntity.isAllowedToWork()) { + started = false; + } + super.onPreTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void construct(ItemStack stackSize, 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; + if (hintsOnly) { + TecTech.proxy.hint_particle(iGregTechTileEntity.getWorld(), + iGregTechTileEntity.getXCoord() + xDir, + iGregTechTileEntity.getYCoord() + yDir, + iGregTechTileEntity.getZCoord() + zDir, + TT_Container_Casings.sHintCasingsTT, 12); + } + structureBuild_EM("main", 11, 1, 18, hintsOnly, stackSize); + } + + @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 d1eafa22fc..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 @@ -12,8 +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.EMTransformationInfo.AVOGADRO_CONSTANT_144; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo.AVOGADRO_CONSTANT_UNCERTAINTY; +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.*; @@ -77,7 +76,7 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehav maxRPM = Math.sqrt(maxRCF / (0.001118D * radius)); 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) { @@ -128,7 +127,7 @@ public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehav 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.getAmount() < AVOGADRO_CONSTANT_UNCERTAINTY) { + if (randomStack.isInvalidAmount()) { input.removeKey(randomStack.getDefinition()); stacks = input.valuesToArray(); } 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 70d93b36ed..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 @@ -9,10 +9,9 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunctio 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.EMTransformationInfo.AVOGADRO_CONSTANT_144; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.EMTransformationInfo.AVOGADRO_CONSTANT_UNCERTAINTY; -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; @@ -89,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= EMAtomDefinition.getSomethingHeavy().getMass()*(2<=separator.length()){ + stringBuilder.setLength(length -separator.length()); + } + return stringBuilder.toString(); + } } diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index 89d2b517a2..a5b5051827 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -798,20 +798,17 @@ 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 +#EM scan result tt.keyword.CLASS=CLASS tt.keyword.NAME=NAME tt.keyword.CHARGE=CHARGE tt.keyword.COLORLESS=COLORLESS tt.keyword.MASS=MASS +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 +#debug boom tt.keyword.BOOM=BOOM! tt.keyword.Destination=Destination tt.keyword.Weight=Weight @@ -834,10 +831,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 @@ -875,3 +868,87 @@ tt.keyphrase.Side_capabilities=Side capabilities #OpenTurrets compatibility tile.turretHeadEM.name=Elemental Matter Turret tile.turretBaseEM.name=Elemental Turret Base + +tt.keyword.mol=mol +tt.keyword.itemMols=items +tt.keyword.mbMols=mb +#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 + + + + + + -- cgit From caff4351909ce59637348c6be94271cf1d1c0a9c Mon Sep 17 00:00:00 2001 From: Tec Date: Sun, 23 Jan 2022 14:47:42 +0100 Subject: Separate EM to new tab --- src/main/java/com/github/technus/tectech/TecTech.java | 4 +++- .../com/github/technus/tectech/loader/MainLoader.java | 2 ++ .../technus/tectech/loader/gui/CreativeTabEM.java | 19 +++++++++++++++++++ .../technus/tectech/mechanics/elementalMatter/README | 5 ++++- .../elementalMatter/core/maps/EMInstanceStackMap.java | 5 ----- .../item/DebugElementalInstanceContainer_EM.java | 4 ++-- .../thing/item/ElementalDefinitionContainer_EM.java | 10 +++++----- .../thing/item/ElementalDefinitionScanStorage_EM.java | 4 ++-- .../GT_MetaTileEntity_Hatch_ElementalContainer.java | 4 ++-- src/main/resources/assets/tectech/lang/en_US.lang | 1 + 10 files changed, 40 insertions(+), 18 deletions(-) create mode 100644 src/main/java/com/github/technus/tectech/loader/gui/CreativeTabEM.java (limited to 'src/main/resources') diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index d730d64a65..10b8f69b1a 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -3,6 +3,7 @@ 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.CreativeTabTecTech; +import com.github.technus.tectech.loader.gui.CreativeTabEM; import com.github.technus.tectech.mechanics.anomaly.AnomalyHandler; import com.github.technus.tectech.mechanics.anomaly.CancerCommand; import com.github.technus.tectech.mechanics.anomaly.ChargeCommand; @@ -45,7 +46,8 @@ public class TecTech { public static final XSTR RANDOM = XSTR.XSTR_INSTANCE; public static final LogHelper LOGGER = new LogHelper(Reference.MODID); - public static CreativeTabTecTech creativeTabTecTech; + public static CreativeTabTecTech creativeTabTecTech; + public static CreativeTabEM creativeTabEM; private static IngameErrorLog moduleAdminErrorLogs; public static TecTechConfig configTecTech; 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 e2f1e2882f..b9d737f98a 100644 --- a/src/main/java/com/github/technus/tectech/loader/MainLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/MainLoader.java @@ -7,6 +7,7 @@ import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.trans 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.CreativeTabTecTech; +import com.github.technus.tectech.loader.gui.CreativeTabEM; import com.github.technus.tectech.loader.gui.ModGuiHandler; import com.github.technus.tectech.loader.recipe.BaseRecipeLoader; import com.github.technus.tectech.loader.thing.ComponentLoader; @@ -64,6 +65,7 @@ public final class MainLoader { public static void preLoad(){ creativeTabTecTech =new CreativeTabTecTech("TecTech"); + creativeTabEM =new CreativeTabEM("EM"); //set expanded texture arrays for tiers try { 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/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/maps/EMInstanceStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/maps/EMInstanceStackMap.java index 64ff7063e8..265d219168 100644 --- 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 @@ -117,11 +117,6 @@ public final class EMInstanceStackMap extends EMStackMap implem return list; } - //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; 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 d909054196..ecebc6afcd 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 @@ -29,8 +29,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.TecTech.creativeTabTecTech; 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; @@ -46,7 +46,7 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE setMaxStackSize(1); setUnlocalizedName("em.debugContainer"); setTextureName(MODID + ":itemDebugContainer"); - setCreativeTab(creativeTabTecTech); + setCreativeTab(creativeTabEM); } @Override 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 f0f59e0e86..0de8bb007a 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,12 +1,12 @@ package com.github.technus.tectech.thing.item; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.font.TecTechFontRender; -import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; +import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; import com.github.technus.tectech.thing.item.renderElemental.IElementalItem; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.Util; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.gui.FontRenderer; @@ -20,8 +20,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.TecTech.creativeTabTecTech; import static cpw.mods.fml.relauncher.Side.CLIENT; import static net.minecraft.util.StatCollector.translateToLocal; @@ -35,7 +35,7 @@ public final class ElementalDefinitionContainer_EM extends Item implements IElem setMaxStackSize(1); setUnlocalizedName("em.definitionContainer"); setTextureName(MODID + ":itemDefinitionContainer"); - setCreativeTab(creativeTabTecTech); + setCreativeTab(creativeTabEM); } //return previous thing 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 8b8133a1e2..1cb6de1df6 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,13 @@ 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.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 com.github.technus.tectech.util.Util; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; 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 84f18ad2bf..6cb83f5d46 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 @@ -112,7 +112,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) { @@ -206,7 +206,7 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta } public int getMaxStacksCount() { - return mTier * 128; + return mTier * mTier >> 4; } public double getMaxStackSize() { diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index a5b5051827..f69f250e78 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 -- cgit From 7adcaf6d9b4a8628711a01ce2467f13582cea7d5 Mon Sep 17 00:00:00 2001 From: Tec Date: Thu, 27 Jan 2022 22:09:30 +0100 Subject: Cleanup Atoms Localization, and FontRenderer --- .../technus/tectech/font/TecTechFontRender.java | 240 ++++++++++++------ .../definitions/complex/EMAtomDefinition.java | 113 ++++----- .../item/DebugElementalInstanceContainer_EM.java | 9 +- src/main/resources/META-INF/tectech_at.cfg | 17 +- src/main/resources/assets/tectech/lang/en_US.lang | 268 ++++++++++++++++++++- 5 files changed, 498 insertions(+), 149 deletions(-) (limited to 'src/main/resources') 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..fbbc12fe36 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,182 @@ 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.util.ResourceLocation; import org.lwjgl.opengl.GL11; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - @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 float DISTANCE_L = .125F; + private static float DISTANCE_L2 = DISTANCE_L * 2F; - private static float DISTANCE_M = 0.06F; - private static float DISTANCE_M2 = DISTANCE_M *2F; + private static float DISTANCE_M = 0.06F; + private static float DISTANCE_M2 = DISTANCE_M * 2F; - private static float DISTANCE_A = 0.06F; - private static float DISTANCE_A2 = DISTANCE_A *2F; + private static float DISTANCE_A = 0.06F; + private static 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); - } - } - resetMethod.setAccessible(true); - renderMethod.setAccessible(true); - reset=resetMethod; - render=renderMethod; + private void resetStyles() { + this.randomStyle = false; + this.boldStyle = false; + this.italicStyle = false; + this.underlineStyle = false; + this.strikethroughStyle = false; } - private TecTechFontRender() { - super(Minecraft.getMinecraft().gameSettings, new ResourceLocation("textures/font/ascii.png"), Minecraft.getMinecraft().renderEngine, false); - gameSettings = Minecraft.getMinecraft().gameSettings; + 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; + } } - private void resetStyles2(){ + private String bidiReorder(String p_147647_1_) { try { - reset.invoke(this); - } catch (IllegalAccessException | InvocationTargetException e) { - throw new RuntimeException("Cannot run method resetStyles!",e); + 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 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); + 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 = "ÀÁÂÈÊËÍÓÔÕÚßãõğİıŒœŞşŴŵžȇ\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃áíóúñѪº¿®¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αβΓπΣσμτΦΘΩδ∞∅∈∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■\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 float renderCharAtPos(int p_78278_1_, char p_78278_2_, boolean p_78278_3_) { + return p_78278_2_ == ' ' ? 4.0F : ("ÀÁÂÈÊËÍÓÔÕÚßãõğİıŒœŞşŴŵžȇ\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃áíóúñѪº¿®¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αβΓπΣσμτΦΘΩδ∞∅∈∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■\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 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 +203,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 +228,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 +254,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--; @@ -213,50 +308,40 @@ public class TecTechFontRender extends FontRenderer { 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 +350,7 @@ public class TecTechFontRender extends FontRenderer { i += k; - if (flag && k > 0) - { + if (flag && k > 0) { ++i; } } @@ -274,4 +358,6 @@ public class TecTechFontRender extends FontRenderer { return i; } } + + } 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 index 76f4457e94..49fd8b5b54 100644 --- 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 @@ -5,8 +5,8 @@ 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.EMIndirectType; 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; @@ -27,12 +27,17 @@ import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileE 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; @@ -118,7 +123,7 @@ public class EMAtomDefinition extends EMComplexTemplate { if (def.getGeneration() < 0) { containsAnti = true; } - type = Math.max(type, Math.abs(def.getGeneration())); + type = Math.max(type, abs(def.getGeneration())); if (def instanceof EMLeptonDefinition) { cLeptons += stack.getCharge(); @@ -140,12 +145,12 @@ public class EMAtomDefinition extends EMComplexTemplate { this.neutralCount = neutralCount; this.element = element; - element = Math.abs(element); + element = abs(element); //stability curve int StableIsotope = stableIzoCurve(element); int izoDiff = neutralCount - StableIsotope; - int izoDiffAbs = Math.abs(izoDiff); + int izoDiffAbs = abs(izoDiff); xstr.setSeed((element + 1L) * (neutralCount + 100L)); iaea = EMNuclideIAEA.get(element, neutralCount); @@ -215,7 +220,7 @@ public class EMAtomDefinition extends EMComplexTemplate { if (element == 0) { return 1e-35D; } else if (element == 1) { - unstabilityEXP = 1.743D - Math.abs(izoDiff - 1) * 9.743D; + unstabilityEXP = 1.743D - abs(izoDiff - 1) * 9.743D; } else if (element == 2) { switch (isotope) { case 4: @@ -234,9 +239,9 @@ public class EMAtomDefinition extends EMComplexTemplate { } 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); + 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) - Math.abs(izoDiff) * (3D - element / 13D + element * element / 1600D); + 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; } @@ -334,63 +339,51 @@ public class EMAtomDefinition extends EMComplexTemplate { @Override public String getLocalizedName() { - int element = Math.abs(this.getElement()); - boolean negative = this.getElement() < 0; - try { - if (Math.abs(getGeneration()) != 1) { - return (negative ? "~? " : "? ") + Nomenclature.NAME[element]; - } - return negative ? '~' + Nomenclature.NAME[element] : Nomenclature.NAME[element]; - } catch (Exception e) { - if (DEBUG_MODE) { - e.printStackTrace(); + int element = abs(this.getElement()); + boolean anti = this.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])); } - return translateToLocal("tt.keyword.Element") + (negative ? ": ~" : ": ") + element; + s.append(weird?translateToLocal("tt.keyword.Weird"):""); + return s.toString(); } + return translateToLocal("tt.element."+(anti?"Anti":"")+NAME[element])+(weird?translateToLocal("tt.keyword.Weird"):""); } @Override public String getSymbol() { - int element = Math.abs(this.getElement()); - boolean negative = this.getElement() < 0; - try { - return (negative ? "~" : "") + Nomenclature.SYMBOL[element] + " N:" + getNeutralCount() + " I:" + (getNeutralCount() + 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:" + getNeutralCount() + " I:" + (getNeutralCount() + element) + " C:" + getCharge(); - } catch (Exception E) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - return (negative ? "~" : "") + "? N:" + getNeutralCount() + " I:" + (getNeutralCount() + element) + " C:" + getCharge(); - } - } + return getShortSymbol() + " N:" + getNeutralCount() + " I:" + (getNeutralCount() + element) + " C:" + getCharge(); } @Override public String getShortSymbol() { - int element = Math.abs(this.getElement()); - boolean negative = this.getElement() < 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 ? "~" : "") + "?"; - } + int element = abs(this.getElement()); + boolean anti = this.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]); + s.append(weird?translateToLocal("tt.keyword.Weird"):""); + return s.toString(); } + return (anti?"~":"")+SYMBOL[element]+(weird?translateToLocal("tt.keyword.Weird"):""); } @Override @@ -1133,7 +1126,7 @@ public class EMAtomDefinition extends EMComplexTemplate { private boolean Fission(ArrayList decaysList, EMDefinitionStackMap fissile, EMDefinitionStackMap particles, double probability, boolean spontaneousCheck) { EMDefinitionStackMap heavy = new EMDefinitionStackMap(); - double[] liquidDrop = liquidDropFunction(Math.abs(getElement()) <= 97); + double[] liquidDrop = liquidDropFunction(abs(getElement()) <= 97); for (EMDefinitionStack stack : fissile.valuesToArray()) { if (spontaneousCheck && stack.getDefinition() instanceof EMHadronDefinition && @@ -1226,7 +1219,7 @@ public class EMAtomDefinition extends EMComplexTemplate { return decays.toArray(EMDecay.NO_PRODUCT); } } - if (energyLevel < Math.abs(getCharge()) / 3 + getNeutralCount()) { + if (energyLevel < abs(getCharge()) / 3 + getNeutralCount()) { return new EMDecay[]{new EMDecay(1, this, boson_Y__)}; } return getNaturalDecayInstant(); @@ -1363,12 +1356,6 @@ public class EMAtomDefinition extends EMComplexTemplate { return element; } - 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 protected String getIndirectTagValue() { return nbtType; @@ -1398,7 +1385,7 @@ public class EMAtomDefinition extends EMComplexTemplate { //stability curve int StableIsotope = stableIzoCurve(element); int izoDiff = isotope - StableIsotope; - int izoDiffAbs = Math.abs(izoDiff); + 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) { @@ -1415,7 +1402,7 @@ public class EMAtomDefinition extends EMComplexTemplate { //stability curve int Isotope = stableIzoCurve(element); int izoDiff = isotope - Isotope; - int izoDiffAbs = Math.abs(izoDiff); + int izoDiffAbs = abs(izoDiff); double rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); TreeMap isotopes = mostStableUnstableIsotopes.computeIfAbsent(element, k -> new TreeMap<>()); isotopes.put(rawLifeTime, isotope);//todo dont add stable ones 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 ecebc6afcd..b8ce40b180 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 @@ -141,9 +141,12 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE that.setTagCompound(new NBTTagCompound()); list.add(that); for(IEMDefinition definition: TecTech.definitionsRegistry.getStacksRegisteredForDisplay()){ - list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" "+1+" "+translateToLocal("tt.keyword.mbMols")),new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_MATERIAL_AMOUNT)))); - list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" "+1+" "+translateToLocal("tt.keyword.itemMols")),new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_ITEM)))); - list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" "+1000+" "+translateToLocal("tt.keyword.mbMols")),new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_1k)))); + list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" "+1+" "+translateToLocal("tt.keyword.mbMols")), + new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_MATERIAL_AMOUNT)))); + list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" "+1+" "+translateToLocal("tt.keyword.itemMols")), + new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_ITEM)))); + list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getLocalizedName()+" "+1000+" "+translateToLocal("tt.keyword.mbMols")), + new EMInstanceStackMap(new EMInstanceStack(definition, EM_COUNT_PER_1k)))); } } 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 f69f250e78..7924545051 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -948,8 +948,266 @@ 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 -- cgit From 9c10b4c63b9c4ea551719c8a059d36ea01c5b89e Mon Sep 17 00:00:00 2001 From: Tec Date: Sun, 6 Feb 2022 11:08:29 +0100 Subject: Update TT_Utility --- .../dreamcraft/NoDreamCraftMachineLoader.java | 34 +- .../definitions/EMComplexAspectDefinition.java | 16 +- .../tectech/mechanics/anomaly/AnomalyHandler.java | 10 +- .../tectech/mechanics/commands/ConvertFloat.java | 4 +- .../tectech/mechanics/commands/ConvertInteger.java | 4 +- .../tectech/mechanics/data/ChunkDataMessage.java | 4 +- .../tectech/mechanics/data/PlayerPersistence.java | 6 +- .../elementalMatter/core/commands/EMList.java | 4 +- .../core/definitions/EMPrimitiveTemplate.java | 2 +- .../core/maps/EMInstanceStackMap.java | 20 +- .../elementalMatter/core/maps/EMStackMap.java | 13 +- .../elementalMatter/core/maps/IEMMapRead.java | 2 +- .../core/stacks/EMInstanceStack.java | 20 +- .../definitions/complex/EMAtomDefinition.java | 18 +- .../definitions/complex/EMHadronDefinition.java | 16 +- .../definitions/complex/EMNuclideIAEA.java | 2 +- .../tectech/nei/TT_NEI_ResearchHandler.java | 4 +- .../technus/tectech/nei/TT_NEI_ScannerHandler.java | 4 +- .../thing/cover/GT_Cover_TM_EnderFluidLink.java | 3 +- .../item/DebugElementalInstanceContainer_EM.java | 6 +- .../item/ElementalDefinitionContainer_EM.java | 6 +- .../item/ElementalDefinitionScanStorage_EM.java | 6 +- .../tectech/thing/item/ParametrizerMemoryCard.java | 6 +- .../hatch/GT_MetaTileEntity_Hatch_Capacitor.java | 6 +- .../GT_MetaTileEntity_Hatch_CreativeData.java | 4 +- ...T_MetaTileEntity_Hatch_CreativeMaintenance.java | 4 +- .../GT_MetaTileEntity_Hatch_DataConnector.java | 4 +- .../hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java | 4 +- .../GT_MetaTileEntity_Hatch_DynamoTunnel.java | 4 +- ...GT_MetaTileEntity_Hatch_ElementalContainer.java | 9 +- .../hatch/GT_MetaTileEntity_Hatch_EnergyMulti.java | 6 +- .../GT_MetaTileEntity_Hatch_EnergyTunnel.java | 8 +- .../hatch/GT_MetaTileEntity_Hatch_Holder.java | 4 +- .../hatch/GT_MetaTileEntity_Hatch_InputData.java | 4 +- .../GT_MetaTileEntity_Hatch_InputDataItems.java | 4 +- .../GT_MetaTileEntity_Hatch_InputElemental.java | 4 +- .../hatch/GT_MetaTileEntity_Hatch_OutputData.java | 4 +- .../GT_MetaTileEntity_Hatch_OutputDataItems.java | 4 +- .../GT_MetaTileEntity_Hatch_OutputElemental.java | 4 +- .../GT_MetaTileEntity_Hatch_OverflowElemental.java | 15 +- .../hatch/GT_MetaTileEntity_Hatch_Param.java | 4 +- .../hatch/GT_MetaTileEntity_Hatch_Rack.java | 6 +- .../hatch/GT_MetaTileEntity_Hatch_Uncertainty.java | 4 +- .../hatch/TextParametersMessage.java | 6 +- .../hatch/gui/GT_Container_Param.java | 22 +- .../hatch/gui/GT_Container_ParamAdv.java | 26 +- .../hatch/gui/GT_Container_ParamText.java | 22 +- .../hatch/gui/GT_GUIContainer_Param.java | 17 +- .../hatch/gui/GT_GUIContainer_ParamAdv.java | 17 +- .../hatch/gui/GT_GUIContainer_ParamText.java | 20 +- .../multi/GT_MetaTileEntity_EM_computer.java | 4 +- .../multi/GT_MetaTileEntity_EM_quantizer.java | 2 +- .../multi/GT_MetaTileEntity_EM_scanner.java | 2 +- .../multi/base/GT_Container_MultiMachineEM.java | 10 +- .../base/GT_MetaTileEntity_MultiblockBase_EM.java | 8 +- .../em_machine/GT_MetaTileEntity_EM_machine.java | 10 +- .../single/GT_MetaTileEntity_BuckConverter.java | 6 +- .../single/GT_MetaTileEntity_DataReader.java | 22 +- .../single/GT_MetaTileEntity_DebugPollutor.java | 6 +- .../GT_MetaTileEntity_DebugPowerGenerator.java | 6 +- .../GT_MetaTileEntity_DebugStructureWriter.java | 10 +- .../single/GT_MetaTileEntity_MicroController.java | 6 +- .../single/GT_MetaTileEntity_OwnerDetector.java | 6 +- .../single/GT_MetaTileEntity_TT_Transformer.java | 6 +- .../single/GT_MetaTileEntity_TeslaCoil.java | 5 +- .../single/gui/GT_Container_DebugPollutor.java | 10 +- .../single/gui/GT_GUIContainer_BuckConverter.java | 4 +- .../single/gui/GT_GUIContainer_DataReader.java | 9 +- .../gui/GT_GUIContainer_DebugPowerGenerator.java | 4 +- .../github/technus/tectech/util/TT_Utility.java | 613 +++++++++++++++++++++ .../java/com/github/technus/tectech/util/Util.java | 596 -------------------- src/main/resources/assets/tectech/lang/en_US.lang | 3 + 72 files changed, 899 insertions(+), 895 deletions(-) create mode 100644 src/main/java/com/github/technus/tectech/util/TT_Utility.java delete mode 100644 src/main/java/com/github/technus/tectech/util/Util.java (limited to 'src/main/resources') 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..c8eda64bea 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,7 +2,7 @@ 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.util.TT_Utility; 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; @@ -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/thaumcraft/elementalMatter/definitions/EMComplexAspectDefinition.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/EMComplexAspectDefinition.java index 8c90dc939c..be1ed9bd51 100644 --- 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 @@ -10,7 +10,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.reg 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.Util; +import com.github.technus.tectech.util.TT_Utility; import java.util.ArrayList; @@ -233,30 +233,30 @@ public final class EMComplexAspectDefinition extends EMComplexTemplate { @Override public void addScanShortSymbols(ArrayList lines, int capabilities, long energyLevel) { - if (Util.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS, capabilities)) { lines.add(getShortSymbol()); } } @Override public void addScanResults(ArrayList lines, int capabilities, long energyLevel) { - if (Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { lines.add(translateToLocal("tt.keyword.CLASS") + " = " + nbtType + ' ' + getMatterMassType()); } - if (Util.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS, capabilities)) { lines.add(translateToLocal("tt.keyword.NAME") + " = " + getLocalizedName()); //lines.add("SYMBOL = "+getSymbol()); } - if (Util.areBitsSet(SCAN_GET_CHARGE, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_CHARGE, capabilities)) { lines.add(translateToLocal("tt.keyword.CHARGE") + " = " + getCharge() / 3f + " e"); } - if (Util.areBitsSet(SCAN_GET_COLOR, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_COLOR, capabilities)) { lines.add(hasColor() ? translateToLocal("tt.keyword.COLORLESS") : translateToLocal("tt.keyphrase.CARRIES_COLOR")); } - if (Util.areBitsSet(SCAN_GET_MASS, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_MASS, capabilities)) { lines.add(translateToLocal("tt.keyword.MASS") + " = " + getMass() + " eV/c\u00b2"); } - if (Util.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)) { + if (TT_Utility.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/mechanics/anomaly/AnomalyHandler.java b/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java index a61490b162..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 @@ -8,7 +8,7 @@ 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.EMAtomDefinition; -import com.github.technus.tectech.util.Util; +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; @@ -33,8 +33,8 @@ 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.Util.crossProduct3D; -import static com.github.technus.tectech.util.Util.normalize3D; +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 { private static final double SWAP_THRESHOLD = EMAtomDefinition.getSomethingHeavy().getMass() * 1000D * EM_COUNT_PER_MATERIAL_AMOUNT_DIMINISHED;//can be const as it is computed later... @@ -171,8 +171,8 @@ public class AnomalyHandler implements IChunkMetaDataHandler { } int x = (b.xPosition - a.xPosition) << 4; int z = (b.xPosition - a.xPosition) << 4; - List aE = a.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, Util.fromChunk(a)); - List bE = b.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, Util.fromChunk(b)); + List aE = a.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, TT_Utility.fromChunk(a)); + List bE = b.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, TT_Utility.fromChunk(b)); for (EntityLivingBase entityLivingBase : aE) { if (TecTech.RANDOM.nextBoolean()) { if (entityLivingBase instanceof EntityPlayer) { 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/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 { @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..beda03fe0a 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,6 +1,6 @@ package com.github.technus.tectech.mechanics.data; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.TT_Utility; import com.github.technus.tectech.loader.NetworkDispatcher; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent; @@ -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/core/commands/EMList.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/EMList.java index fe542abbde..0f71a24d82 100644 --- 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 @@ -2,7 +2,7 @@ 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.Util; +import com.github.technus.tectech.util.TT_Utility; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.util.ChatComponentText; @@ -28,7 +28,7 @@ public class EMList implements ICommand { if(args.length == 0) { listClasses(sender); }else { - String concated = Util.getConcated(args, " "); + String concated = TT_Utility.getConcated(args, " "); listDefinitions(sender,concated, concated.replaceAll(" ","_"),concated.replaceAll("_"," ")); } } 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 index a1f606c3c2..edf1827a07 100644 --- 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 @@ -9,7 +9,7 @@ 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.Util.areBitsSet; +import static com.github.technus.tectech.util.TT_Utility.areBitsSet; import static net.minecraft.util.StatCollector.translateToLocal; /** 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 index 265d219168..bfaad77c33 100644 --- 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 @@ -7,6 +7,8 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.reg 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; @@ -94,9 +96,9 @@ public final class EMInstanceStackMap extends EMStackMap implem for (EMInstanceStack instance : getBackingMap().values()) { info[i++] = EnumChatFormatting.BLUE + instance.getDefinition().getLocalizedName()+ " "+ EnumChatFormatting.AQUA + instance.getDefinition().getSymbol()+ EnumChatFormatting.RESET+ - " #: " + EnumChatFormatting.GREEN + String.format("%.3E", instance.getAmount() /AVOGADRO_CONSTANT) +" "+translateToLocal("tt.keyword.mol")+ EnumChatFormatting.RESET+ - " E: " + EnumChatFormatting.GREEN + instance.getEnergy() + EnumChatFormatting.RESET+ - " T: " + EnumChatFormatting.GREEN + (instance.getLifeTime()<0?"STABLE":String.format("%.3E",instance.getLifeTime())); + " #: " + EnumChatFormatting.GREEN + TT_Utility.formatNumberExp(instance.getAmount() /AVOGADRO_CONSTANT) +" "+translateToLocal("tt.keyword.mol")+ EnumChatFormatting.RESET+ + " E: " + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(instance.getEnergy()) + EnumChatFormatting.RESET+ + " T: " + EnumChatFormatting.GREEN + (instance.getLifeTime()<0?translateToLocal("tt.keyword.stable"):TT_Utility.formatNumberShortExp(instance.getLifeTime())); } return info; } @@ -165,17 +167,6 @@ public final class EMInstanceStackMap extends EMStackMap implem return new EMInstanceStackMap(false, instances); } - @Override - public boolean equals(Object obj) { - if (obj instanceof EMInstanceStackMap) { - return compareTo((EMInstanceStackMap) obj) == 0; - } - if (obj instanceof EMStackMap) { - return toDefinitionMapForComparison().compareTo((EMStackMap) obj) == 0; - } - return false; - } - @Override public String toString() { StringBuilder build=new StringBuilder("Instance Stack Map\n"); @@ -197,6 +188,7 @@ public final class EMInstanceStackMap extends EMStackMap implem return newStack; } + @Deprecated public EMDefinitionStackMap toDefinitionMapForComparison() { EMDefinitionStack[] list = new EMDefinitionStack[size()]; int i = 0; 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 index 795ac3d3bf..3765fe6098 100644 --- 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 @@ -30,11 +30,11 @@ abstract class EMStackMap implements IEMMapRead { @Override public boolean equals(Object obj) { - if (obj instanceof EMInstanceStackMap) { - return compareTo(((EMInstanceStackMap) obj).toDefinitionMapForComparison()) == 0; + if(this == obj){ + return true; } - if (obj instanceof EMStackMap) { - return compareTo((EMStackMap) obj) == 0; + if (obj instanceof IEMMapRead) { + return compareTo((IEMMapRead) obj) == 0; } return false; } @@ -47,4 +47,9 @@ abstract class EMStackMap implements IEMMapRead { } return hash; } + + @Override + public int compareTo(IEMMapRead 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 index c0420fa2b2..86ca6de8a8 100644 --- 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 @@ -14,7 +14,7 @@ import static com.github.technus.tectech.mechanics.elementalMatter.core.transfor import static com.github.technus.tectech.util.DoubleCount.ulpSigned; import static net.minecraft.util.StatCollector.translateToLocal; -public interface IEMMapRead extends Comparable>, Cloneable { +public interface IEMMapRead extends Comparable>, Cloneable { NavigableMap getBackingMap(); IEMMapRead clone(); 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 index b67d2ce121..d37a8bd099 100644 --- 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 @@ -7,7 +7,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEM 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.Util; +import com.github.technus.tectech.util.TT_Utility; import net.minecraft.client.Minecraft; import net.minecraft.crash.CrashReport; import net.minecraft.nbt.NBTTagCompound; @@ -505,26 +505,26 @@ public final class EMInstanceStack implements IEMStack { public void addScanResults(ArrayList lines, int[] detailsOnDepthLevels) { int capabilities = detailsOnDepthLevels[0]; - if (Util.areBitsSet(SCAN_GET_DEPTH_LEVEL, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_DEPTH_LEVEL, capabilities)) { lines.add("DEPTH = " + 0); } getDefinition().addScanResults(lines, capabilities, energy); - if (Util.areBitsSet(SCAN_GET_TIMESPAN_MULT, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_TIMESPAN_MULT, capabilities)) { lines.add("TIME MULT = " + lifeTimeMult); - if (Util.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)) { lines.add("TIME SPAN = " + lifeTime + " s"); } } - if (Util.areBitsSet(SCAN_GET_AGE, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_AGE, capabilities)) { lines.add("AGE = " + getAge() + " s"); } - if (Util.areBitsSet(SCAN_GET_COLOR, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_COLOR, capabilities)) { lines.add("COLOR = " + color + " RGB or CMY"); } - if (Util.areBitsSet(SCAN_GET_ENERGY_LEVEL, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_ENERGY_LEVEL, capabilities)) { lines.add("ENERGY = " + energy); } - if (Util.areBitsSet(SCAN_GET_AMOUNT, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_AMOUNT, capabilities)) { lines.add("AMOUNT = " + getAmount() /AVOGADRO_CONSTANT + " "+translateToLocal("tt.keyword.mol")); } scanContents(lines, getDefinition().getSubParticles(), 1, detailsOnDepthLevels); @@ -535,11 +535,11 @@ public final class EMInstanceStack implements IEMStack { int deeper = depth + 1; for (EMDefinitionStack definitionStack : definitions.valuesToArray()) { lines.add("");//def separator - if (Util.areBitsSet(SCAN_GET_DEPTH_LEVEL, detailsOnDepthLevels[depth])) { + if (TT_Utility.areBitsSet(SCAN_GET_DEPTH_LEVEL, detailsOnDepthLevels[depth])) { lines.add("DEPTH = " + depth); } getDefinition().addScanResults(lines, detailsOnDepthLevels[depth], energy); - if (Util.areBitsSet(SCAN_GET_AMOUNT, detailsOnDepthLevels[depth])) { + if (TT_Utility.areBitsSet(SCAN_GET_AMOUNT, detailsOnDepthLevels[depth])) { lines.add("AMOUNT = " + definitionStack.getAmount()); } scanContents(lines, definitionStack.getDefinition().getSubParticles(), deeper, detailsOnDepthLevels); 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 index 0eced7bd3c..20e58216c1 100644 --- 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 @@ -14,7 +14,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.transformations 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.Util; +import com.github.technus.tectech.util.TT_Utility; import com.github.technus.tectech.util.XSTR; import java.util.*; @@ -1676,35 +1676,35 @@ public class EMAtomDefinition extends EMComplexTemplate { @Override public void addScanShortSymbols(ArrayList lines, int capabilities, long energyLevel) { - if (Util.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS | SCAN_GET_TIMESPAN_INFO, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS | SCAN_GET_TIMESPAN_INFO, capabilities)) { lines.add(getShortSymbol()); } } @Override public void addScanResults(ArrayList lines, int capabilities, long energyLevel) { - if (Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { lines.add("CLASS = " + getIndirectTagValue() + ' ' + getMatterMassType()); } - if (Util.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS | SCAN_GET_TIMESPAN_INFO, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS | SCAN_GET_TIMESPAN_INFO, capabilities)) { lines.add("NAME = " + getLocalizedName()); lines.add("SYMBOL = " + getSymbol()); } - if (Util.areBitsSet(SCAN_GET_CHARGE, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_CHARGE, capabilities)) { lines.add("CHARGE = " + getCharge() / 3D + " e"); } - if (Util.areBitsSet(SCAN_GET_COLOR, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_COLOR, capabilities)) { lines.add(hasColor() ? "COLORLESS" : "CARRIES COLOR"); } - if (Util.areBitsSet(SCAN_GET_MASS, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_MASS, capabilities)) { lines.add("MASS = " + getMass() + " eV/c\u00b2"); } - if (iaeaDefinitionExistsAndHasEnergyLevels && Util.areBitsSet(SCAN_GET_ENERGY_STATES, capabilities)) { + if (iaeaDefinitionExistsAndHasEnergyLevels && TT_Utility.areBitsSet(SCAN_GET_ENERGY_STATES, capabilities)) { for (int i = 1; i < getIaea().getEnergeticStatesArray().length; i++) { lines.add("E LEVEL " + i + " = " + getIaea().getEnergeticStatesArray()[i].energy + " eV"); } } - if (Util.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)) { + if (TT_Utility.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/EMHadronDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMHadronDefinition.java index 19208fbf4a..85cb07ea33 100644 --- 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 @@ -15,7 +15,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.transformations 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 com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.TT_Utility; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import net.minecraftforge.oredict.OreDictionary; @@ -461,30 +461,30 @@ public class EMHadronDefinition extends EMComplexTemplate {//TODO Optimize map i @Override public void addScanShortSymbols(ArrayList lines, int capabilities, long energyLevel) { - if (Util.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS | SCAN_GET_TIMESPAN_INFO, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS | SCAN_GET_TIMESPAN_INFO, capabilities)) { lines.add(getShortSymbol()); } } @Override public void addScanResults(ArrayList lines, int capabilities, long energyLevel) { - if (Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { lines.add("CLASS = " + getIndirectTagValue() + ' ' + getMatterMassType()); } - if (Util.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS | SCAN_GET_TIMESPAN_INFO, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_NOMENCLATURE | SCAN_GET_CHARGE | SCAN_GET_MASS | SCAN_GET_TIMESPAN_INFO, capabilities)) { lines.add("NAME = " + getLocalizedTypeName()); //lines.add("SYMBOL = "+getSymbol()); } - if (Util.areBitsSet(SCAN_GET_CHARGE, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_CHARGE, capabilities)) { lines.add("CHARGE = " + getCharge() / 3D + " e"); } - if (Util.areBitsSet(SCAN_GET_COLOR, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_COLOR, capabilities)) { lines.add(hasColor() ? "COLORLESS" : "CARRIES COLOR"); } - if (Util.areBitsSet(SCAN_GET_MASS, capabilities)) { + if (TT_Utility.areBitsSet(SCAN_GET_MASS, capabilities)) { lines.add("MASS = " + getMass() + " eV/c\u00b2"); } - if (Util.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)) { + if (TT_Utility.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/EMNuclideIAEA.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMNuclideIAEA.java index bd34733cb6..e5fab5e6bf 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMNuclideIAEA.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMNuclideIAEA.java @@ -8,7 +8,7 @@ import java.util.HashSet; import java.util.TreeMap; import static com.github.technus.tectech.mechanics.elementalMatter.core.definitions.IEMDefinition.STABLE_RAW_LIFE_TIME; -import static com.github.technus.tectech.util.Util.splitButDifferent; +import static com.github.technus.tectech.util.TT_Utility.splitButDifferent; 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; 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 114dc7399f..85e9fa26ec 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 @@ -215,8 +215,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 2dc4604fd5..50035be554 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 @@ -215,8 +215,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/thing/cover/GT_Cover_TM_EnderFluidLink.java b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_EnderFluidLink.java index d6b5e28b18..7266611b20 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; @@ -325,7 +326,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/item/DebugElementalInstanceContainer_EM.java b/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java index b8ce40b180..7d7880adca 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 @@ -9,7 +9,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstance 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.Util; +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; @@ -120,7 +120,7 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE NBTTagCompound tNBT = aStack.getTagCompound(); if (tNBT != null && tNBT.hasKey("info")) { aList.add(translateToLocal("item.em.debugContainer.desc.0") + ": ");//Contains - Collections.addAll(aList, Util.infoFromNBT(tNBT.getCompoundTag("info"))); + Collections.addAll(aList, TT_Utility.infoFromNBT(tNBT.getCompoundTag("info"))); } 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 @@ -155,7 +155,7 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE try { NBTTagCompound tNBT = aStack.getTagCompound(); if (tNBT != null && tNBT.hasKey("symbols")) { - String[] strings=Util.infoFromNBT(tNBT.getCompoundTag("symbols")); + String[] strings= TT_Utility.infoFromNBT(tNBT.getCompoundTag("symbols")); return strings[index%strings.length]; } else { return null; 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 0de8bb007a..dede2e36ce 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 @@ -6,7 +6,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.EMException; import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; import com.github.technus.tectech.thing.item.renderElemental.IElementalItem; 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.common.registry.GameRegistry; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.gui.FontRenderer; @@ -114,7 +114,7 @@ public final class ElementalDefinitionContainer_EM extends Item implements IElem NBTTagCompound tNBT = aStack.getTagCompound(); if (tNBT != null && tNBT.hasKey("info")) { aList.add(translateToLocal("item.em.definitionContainer.desc.0") + ": ");//Should Contain - Collections.addAll(aList, Util.infoFromNBT(tNBT.getCompoundTag("info"))); + Collections.addAll(aList, TT_Utility.infoFromNBT(tNBT.getCompoundTag("info"))); } else { aList.add(translateToLocal("item.em.definitionContainer.desc.1"));//Recipe Hint } @@ -140,7 +140,7 @@ public final class ElementalDefinitionContainer_EM extends Item implements IElem try { NBTTagCompound tNBT = aStack.getTagCompound(); if (tNBT != null && tNBT.hasKey("symbols")) { - String[] strings=Util.infoFromNBT(tNBT.getCompoundTag("symbols")); + String[] strings= TT_Utility.infoFromNBT(tNBT.getCompoundTag("symbols")); return strings[index%strings.length]; } else { return null; 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 1cb6de1df6..22fc6e65a9 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 @@ -7,7 +7,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMInstance import com.github.technus.tectech.thing.CustomItemList; import com.github.technus.tectech.thing.item.renderElemental.IElementalItem; 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.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -65,7 +65,7 @@ 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")); + return TT_Utility.infoFromNBT(containerItem.stackTagCompound.getCompoundTag("elementalInfo")); } return null; } @@ -142,7 +142,7 @@ public final class ElementalDefinitionScanStorage_EM extends Item implements IEl try { NBTTagCompound tNBT = aStack.getTagCompound(); if (tNBT != null && tNBT.hasKey("symbols")) { - String[] strings=Util.infoFromNBT(tNBT.getCompoundTag("symbols")); + String[] strings= TT_Utility.infoFromNBT(tNBT.getCompoundTag("symbols")); return strings[index%strings.length]; } else { return null; 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 7f9e0f0a4a..aff84c9b4b 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,7 +1,7 @@ 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.util.TT_Utility; 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; @@ -146,13 +146,13 @@ public final class ParametrizerMemoryCard extends Item { 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))); + aList.add("Value 0B: "+EnumChatFormatting.AQUA + TT_Utility.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))); + aList.add("Value 1B: "+EnumChatFormatting.AQUA + TT_Utility.longBitsToShortString(Double.doubleToLongBits(temp))); if(tNBT.hasKey("value1s")) { aList.add("Value 1s: " + EnumChatFormatting.AQUA + tNBT.getString("value1s")); } 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..1e90535224 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 @@ -3,7 +3,7 @@ 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.util.TT_Utility; 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 cpw.mods.fml.relauncher.Side; @@ -24,7 +24,7 @@ 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.util.TT_Utility.getUniqueIdentifier; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; 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..eb9ce2af30 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,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 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; @@ -22,7 +22,7 @@ import static net.minecraft.util.StatCollector.translateToLocal; public class GT_MetaTileEntity_Hatch_CreativeData extends GT_MetaTileEntity_Hatch_DataConnector { 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..3385447861 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,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 com.github.technus.tectech.mechanics.dataTransport.DataPacket; import com.github.technus.tectech.mechanics.pipe.IConnectsToDataPipe; import cpw.mods.fml.relauncher.Side; @@ -41,7 +41,7 @@ public abstract class GT_MetaTileEntity_Hatch_DataConnector { 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..5fe3fd3170 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,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 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; @@ -21,7 +21,7 @@ import static net.minecraft.util.StatCollector.translateToLocal; public class GT_MetaTileEntity_Hatch_OutputDataItems extends GT_MetaTileEntity_Hatch_DataConnector { 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 1426e8a702..4b62965dba 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,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 com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_EM; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -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) { 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 8b55c16831..5223ca5b5b 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 @@ -2,7 +2,7 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; import com.github.technus.tectech.TecTech; 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.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; @@ -54,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) { @@ -89,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) + " eV/c\u00b2", + translateToLocal("gt.blockmachines.hatch.emmuffler.desc.2") + ": " + EnumChatFormatting.AQUA + TT_Utility.formatNumberShortExp(overflowDisperse) + " (eV/c\u00b2)/s", translateToLocal("gt.blockmachines.hatch.emmuffler.desc.3") }; } @@ -218,10 +217,10 @@ 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 + " eV/c\u00b2 /", + EnumChatFormatting.GREEN + TT_Utility.formatNumberShortExp(overflowMax) + EnumChatFormatting.RESET + " eV/c\u00b2", 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 + " (eV/c\u00b2)/s" }; } 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..10e6ca71d9 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,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 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; @@ -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_Rack.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Rack.java index 53fea9ef7c..975d6b516b 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 @@ -3,7 +3,7 @@ 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.util.TT_Utility; 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 cpw.mods.fml.common.Loader; @@ -29,7 +29,7 @@ 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.util.TT_Utility.getUniqueIdentifier; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; 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..00c1d002b6 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 @@ -2,7 +2,7 @@ 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.TT_Utility; 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; @@ -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..96b54273db 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,7 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.TT_Utility; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_GUIContainer_ParamText; import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.common.network.simpleimpl.IMessage; @@ -149,8 +149,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..cf3a164f8f 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,7 +1,7 @@ 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.util.TT_Utility; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Param; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -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..75abd6d4c2 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,7 +1,7 @@ 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.util.TT_Utility; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Param; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -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..1d2df027f3 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,7 +1,7 @@ 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.util.TT_Utility; 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; @@ -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_computer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java index 6ad3282d9d..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,7 +8,7 @@ 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.util.Vec3Impl; @@ -295,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 }; } 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 dc218da530..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 @@ -36,7 +36,7 @@ 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; 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 8583f03193..474dbdab2c 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 @@ -43,7 +43,7 @@ import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileE 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.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; 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 3a019de78c..d4fe7b6e49 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 @@ -8,7 +8,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefini 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.Util; +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; @@ -47,7 +47,7 @@ import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_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; /** @@ -295,7 +295,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) { @@ -318,7 +318,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) { 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 2c4217aaba..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 @@ -6,7 +6,7 @@ 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 gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -110,7 +110,7 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa return false; } loadedMachine = newMachine; - Supplier behaviourSupplier = GT_MetaTileEntity_EM_machine.BEHAVIOUR_MAP.get(new Util.ItemStack_NoNBT(newMachine)); + Supplier 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> BEHAVIOUR_MAP = new HashMap<>(); + private static final HashMap> BEHAVIOUR_MAP = new HashMap<>(); public static void registerBehaviour(Supplier 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 { 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..8d9c245d98 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,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 com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_Container_BuckConverter; import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_GUIContainer_BuckConverter; import cpw.mods.fml.relauncher.Side; @@ -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..fe300f7ed2 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,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 com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_Container_DataReader; import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_GUIContainer_DataReader; import cpw.mods.fml.common.FMLCommonHandler; @@ -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> RENDER_REGISTRY =new HashMap<>(); - public static GT_RenderedTexture READER_ONLINE, READER_OFFLINE; + private static final HashMap> 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 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 getRenders(Util.ItemStack_NoNBT stack){ + public static List getRenders(TT_Utility.ItemStack_NoNBT stack){ ArrayList 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..82f8c77536 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 @@ -2,7 +2,7 @@ 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.TT_Utility; 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; @@ -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..327f66ecf6 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,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 com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_Container_DebugPowerGenerator; import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_GUIContainer_DebugPowerGenerator; import cpw.mods.fml.relauncher.Side; @@ -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..0ab08c356e 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,7 +10,7 @@ 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.util.TT_Utility; import com.github.technus.tectech.mechanics.avr.SidedRedstone; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -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..3ba7bcf885 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 @@ -2,7 +2,7 @@ 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.TT_Utility; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -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..475e8ac10a 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 @@ -7,8 +7,7 @@ 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.util.TT_Utility; import com.google.common.collect.Multimap; import com.google.common.collect.MultimapBuilder; import com.gtnewhorizon.structurelib.util.Vec3Impl; @@ -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..4e4a235ca4 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,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 com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_DebugPollutor; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -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..4731374c31 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,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 com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_DataReader; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.gui.GT_Slot_Holo; @@ -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/util/TT_Utility.java b/src/main/java/com/github/technus/tectech/util/TT_Utility.java new file mode 100644 index 0000000000..c989fe1e1f --- /dev/null +++ b/src/main/java/com/github/technus/tectech/util/TT_Utility.java @@ -0,0 +1,613 @@ +package com.github.technus.tectech.util; + +import com.github.technus.tectech.TecTech; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.ObfuscationReflectionHelper; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.GregTech_API; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.storage.IPlayerFileData; +import net.minecraft.world.storage.SaveHandler; +import net.minecraftforge.fluids.FluidStack; +import org.apache.commons.lang3.StringUtils; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.lang.reflect.Field; +import java.nio.charset.StandardCharsets; +import java.util.*; + +/** + * Created by Tec on 21.03.2017. + */ +public final class TT_Utility { + private TT_Utility() { + } + private static final Map formaters=new HashMap<>(); + + private static Formatter getFormatter(){ + return formaters.computeIfAbsent(Locale.getDefault(Locale.Category.FORMAT), Formatter::new); + } + + 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") + public static > SortedSet> entriesSortedByValues(Map map) { + SortedSet> sortedEntries = new TreeSet<>( + (e1, e2) -> { + int res = e1.getValue().compareTo(e2.getValue()); + return res != 0 ? res : 1; // Special fix to preserve items with equal values + } + ); + sortedEntries.addAll(map.entrySet()); + return sortedEntries; + } + + public static int bitStringToInt(String bits){ + if(bits==null){ + return 0; + } + if(bits.length() > 32){ + throw new NumberFormatException("Too long!"); + } + return Integer.parseInt(bits,2); + } + + public static int hexStringToInt(String hex){ + if(hex==null){ + return 0; + } + if(hex.length()>8){ + throw new NumberFormatException("Too long!"); + } + return Integer.parseInt(hex,16); + } + + public static double stringToDouble(String str){ + if(str==null){ + return 0; + } + return Double.parseDouble(str); + } + + public static double getValue(String in1) { + String str = in1.toLowerCase(); + double val; + try { + if (str.contains("b")) { + String[] split = str.split("b"); + val = TT_Utility.bitStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); + } else if (str.contains("x")) { + String[] split = str.split("x"); + val = TT_Utility.hexStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); + } else { + val = TT_Utility.stringToDouble(str); + } + return val; + } catch (Exception e) { + return 0; + } + } + + + public static String intBitsToString(int number) { + StringBuilder result = new StringBuilder(16); + + for (int i = 31; i >= 0; i--) { + int mask = 1 << i; + result.append((number & mask) != 0 ? "1" : "0"); + + if (i % 8 == 0) { + result.append(' '); + } + } + result.replace(result.length() - 1, result.length(), ""); + + return result.toString(); + } + + public static String intBitsToShortString(int number) { + StringBuilder result = new StringBuilder(35); + + for (int i = 31; i >= 0; i--) { + int mask = 1 << i; + result.append((number & mask) != 0 ? ":" : "."); + + if (i % 8 == 0) { + result.append('|'); + } + } + result.replace(result.length() - 1, result.length(), ""); + + return result.toString(); + } + + public static String longBitsToShortString(long number) { + StringBuilder result = new StringBuilder(71); + + for (int i = 63; i >= 0; i--) { + long mask = 1L << i; + result.append((number & mask) != 0 ? ":" : "."); + + if (i % 8 == 0) { + result.append('|'); + } + } + result.replace(result.length() - 1, result.length(), ""); + + return result.toString(); + } + + public static float map(float x, float in_min, float in_max, float out_min, float out_max) { + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; + } + + public static boolean isInputEqual(boolean aDecreaseStacksizeBySuccess, boolean aDontCheckStackSizes, FluidStack[] requiredFluidInputs, ItemStack[] requiredInputs, FluidStack[] givenFluidInputs, ItemStack... givenInputs) { + if (!GregTech_API.sPostloadFinished) { + return false; + } + if (requiredFluidInputs.length > 0 && givenFluidInputs == null) { + return false; + } + int amt; + for (FluidStack tFluid : requiredFluidInputs) { + if (tFluid != null) { + boolean temp = true; + amt = tFluid.amount; + for (FluidStack aFluid : givenFluidInputs) { + if (aFluid != null && aFluid.isFluidEqual(tFluid)) { + if (aDontCheckStackSizes) { + temp = false; + break; + } + amt -= aFluid.amount; + if (amt < 1) { + temp = false; + break; + } + } + } + if (temp) { + return false; + } + } + } + + if (requiredInputs.length > 0 && givenInputs == null) { + return false; + } + for (ItemStack tStack : requiredInputs) { + if (tStack != null) { + amt = tStack.stackSize; + boolean temp = true; + for (ItemStack aStack : givenInputs) { + if (GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true)) { + if (aDontCheckStackSizes) { + temp = false; + break; + } + amt -= aStack.stackSize; + if (amt < 1) { + temp = false; + break; + } + } + } + if (temp) { + return false; + } + } + } + + if (aDecreaseStacksizeBySuccess) { + if (givenFluidInputs != null) { + for (FluidStack tFluid : requiredFluidInputs) { + if (tFluid != null) { + amt = tFluid.amount; + for (FluidStack aFluid : givenFluidInputs) { + if (aFluid != null && aFluid.isFluidEqual(tFluid)) { + if (aDontCheckStackSizes) { + aFluid.amount -= amt; + break; + } + if (aFluid.amount < amt) { + amt -= aFluid.amount; + aFluid.amount = 0; + } else { + aFluid.amount -= amt; + break; + } + } + } + } + } + } + + if (givenInputs != null) { + for (ItemStack tStack : requiredInputs) { + if (tStack != null) { + amt = tStack.stackSize; + for (ItemStack aStack : givenInputs) { + if (GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true)) { + if (aDontCheckStackSizes) { + aStack.stackSize -= amt; + break; + } + if (aStack.stackSize < amt) { + amt -= aStack.stackSize; + aStack.stackSize = 0; + } else { + aStack.stackSize -= amt; + break; + } + } + } + } + } + } + } + + return true; + } + + public static String getUniqueIdentifier(ItemStack is) { + return GameRegistry.findUniqueIdentifierFor(is.getItem()).modId + ':' + is.getUnlocalizedName(); + } + + public static byte getTier(long l) { + byte b = -1; + + do { + ++b; + if (b >= CommonValues.V.length) { + return b; + } + } while (l > CommonValues.V[b]); + + return b; + } + + public static String[] splitButDifferent(String string, String delimiter) { + String[] strings = new String[StringUtils.countMatches(string, delimiter) + 1]; + int lastEnd = 0; + for (int i = 0; i < strings.length - 1; i++) { + int nextEnd = string.indexOf(delimiter, lastEnd); + strings[i] = string.substring(lastEnd, nextEnd); + lastEnd = nextEnd + delimiter.length(); + } + strings[strings.length - 1] = string.substring(lastEnd); + return strings; + } + + public static String[] infoFromNBT(NBTTagCompound nbt) { + String[] strings = new String[nbt.getInteger("i")]; + for (int i = 0; i < strings.length; i++) { + strings[i] = nbt.getString(Integer.toString(i)); + } + return strings; + } + + public static boolean areBitsSet(int setBits, int testedValue) { + return (testedValue & setBits) == setBits; + } + + public static class ItemStack_NoNBT implements Comparable { + public final Item mItem; + public final int mStackSize; + public final int mMetaData; + + public ItemStack_NoNBT(Item aItem, long aStackSize, long aMetaData) { + this.mItem = aItem; + this.mStackSize = (byte) ((int) aStackSize); + this.mMetaData = (short) ((int) aMetaData); + } + + public ItemStack_NoNBT(ItemStack aStack) { + if (aStack == null) { + mItem = null; + mStackSize = mMetaData = 0; + } else { + mItem = aStack.getItem(); + mStackSize = aStack.stackSize; + mMetaData = Items.feather.getDamage(aStack); + } + } + + @Override + public int compareTo(ItemStack_NoNBT o) { + if (mMetaData > o.mMetaData) return 1; + if (mMetaData < o.mMetaData) return -1; + if (mStackSize > o.mStackSize) return 1; + if (mStackSize < o.mStackSize) return -1; + if (mItem != null && o.mItem != null) + return mItem.getUnlocalizedName().compareTo(o.mItem.getUnlocalizedName()); + if (mItem == null && o.mItem == null) return 0; + if (mItem != null) return 1; + return -1; + } + + @Override + public boolean equals(Object aStack) { + return aStack == this || + (aStack instanceof ItemStack_NoNBT && + ((mItem == ((ItemStack_NoNBT) aStack).mItem) || ((ItemStack_NoNBT) aStack).mItem.getUnlocalizedName().equals(this.mItem.getUnlocalizedName())) && + ((ItemStack_NoNBT) aStack).mStackSize == this.mStackSize && + ((ItemStack_NoNBT) aStack).mMetaData == this.mMetaData); + } + + @Override + public int hashCode() { + return (mItem != null ? mItem.getUnlocalizedName().hashCode() : 0) ^ (mMetaData << 16) ^ (mStackSize << 24); + } + + @Override + public String toString() { + return Integer.toString(hashCode()) + ' ' + (mItem == null ? "null" : mItem.getUnlocalizedName()) + ' ' + mMetaData + ' ' + mStackSize; + } + } + + 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){ + //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); + } + 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 long receiveLong(long previousValue, int startIndex, int index, int value){ + value &=0xFFFF; + switch (index-startIndex){ + case 0: + previousValue&= 0xFFFF_FFFF_FFFF_0000L; + previousValue|=value; + break; + case 1: + previousValue&=0xFFFF_FFFF_0000_FFFFL; + previousValue|=(long)value<<16; + break; + case 2: + previousValue&=0xFFFF_0000_FFFF_FFFFL; + previousValue|=(long)value<<32; + break; + case 3: + previousValue&=0x0000_FFFF_FFFF_FFFFL; + previousValue|=(long)value<<48; + break; + } + return previousValue; + } + + 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,0); + } + + 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)); + } + + @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 int receiveInteger(int previousValue, int startIndex, int index, int value){ + value &=0xFFFF; + switch (index-startIndex){ + case 0: + previousValue&= 0xFFFF_0000; + previousValue|=value; + break; + case 1: + 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 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); + } + return Double.toString(value); + } + + 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) { + try { + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + 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){ + return tagCompound; + } + 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){ + return tagCompound; + } + tagCompound=readBackup(new File(dir, id2 + "."+extension+"_bak")); + if(tagCompound!=null){ + return tagCompound; + } + } + } + } catch (Exception ignored) {} + return new NBTTagCompound(); + } + + 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); + } + } + } catch (Exception ignored) {} + } + + private static NBTTagCompound read(File file){ + if (file != null && file.exists()) { + try(FileInputStream fileInputStream= new FileInputStream(file)) { + return CompressedStreamTools.readCompressed(fileInputStream); + } catch (Exception var9) { + TecTech.LOGGER.error("Cannot read NBT File: "+file.getAbsolutePath()); + } + } + return null; + } + + private static NBTTagCompound readBackup(File file){ + if (file != null && file.exists()) { + try(FileInputStream fileInputStream= new FileInputStream(file)) { + return CompressedStreamTools.readCompressed(fileInputStream); + } catch (Exception var9) { + TecTech.LOGGER.error("Cannot read NBT File: "+file.getAbsolutePath()); + return new NBTTagCompound(); + } + } + return null; + } + + 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); + } catch (Exception var9) { + 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 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 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/Util.java b/src/main/java/com/github/technus/tectech/util/Util.java deleted file mode 100644 index 489246e061..0000000000 --- a/src/main/java/com/github/technus/tectech/util/Util.java +++ /dev/null @@ -1,596 +0,0 @@ -package com.github.technus.tectech.util; - -import com.github.technus.tectech.TecTech; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.ObfuscationReflectionHelper; -import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.GregTech_API; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.server.MinecraftServer; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.ChunkCoordIntPair; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.storage.IPlayerFileData; -import net.minecraft.world.storage.SaveHandler; -import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.StringUtils; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.lang.reflect.Field; -import java.nio.charset.StandardCharsets; -import java.util.*; - -/** - * Created by Tec on 21.03.2017. - */ -public final class Util { - private Util() { - } - - @SuppressWarnings("ComparatorMethodParameterNotUsed") - public static > SortedSet> entriesSortedByValues(Map map) { - SortedSet> sortedEntries = new TreeSet<>( - (e1, e2) -> { - int res = e1.getValue().compareTo(e2.getValue()); - return res != 0 ? res : 1; // Special fix to preserve items with equal values - } - ); - sortedEntries.addAll(map.entrySet()); - return sortedEntries; - } - - public static int bitStringToInt(String bits){ - if(bits==null){ - return 0; - } - if(bits.length() > 32){ - throw new NumberFormatException("Too long!"); - } - return Integer.parseInt(bits,2); - } - - public static int hexStringToInt(String hex){ - if(hex==null){ - return 0; - } - if(hex.length()>8){ - throw new NumberFormatException("Too long!"); - } - return Integer.parseInt(hex,16); - } - - public static double stringToDouble(String str){ - if(str==null){ - return 0; - } - return Double.parseDouble(str); - } - - 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("_", "")); - } else if (str.contains("x")) { - String[] split = str.split("x"); - val = Util.hexStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); - } else { - val = Util.stringToDouble(str); - } - return val; - } catch (Exception e) { - return 0; - } - } - - - public static String intBitsToString(int number) { - StringBuilder result = new StringBuilder(16); - - for (int i = 31; i >= 0; i--) { - int mask = 1 << i; - result.append((number & mask) != 0 ? "1" : "0"); - - if (i % 8 == 0) { - result.append(' '); - } - } - result.replace(result.length() - 1, result.length(), ""); - - return result.toString(); - } - - public static String intBitsToShortString(int number) { - StringBuilder result = new StringBuilder(35); - - for (int i = 31; i >= 0; i--) { - int mask = 1 << i; - result.append((number & mask) != 0 ? ":" : "."); - - if (i % 8 == 0) { - result.append('|'); - } - } - result.replace(result.length() - 1, result.length(), ""); - - return result.toString(); - } - - public static String longBitsToShortString(long number) { - StringBuilder result = new StringBuilder(71); - - for (int i = 63; i >= 0; i--) { - long mask = 1L << i; - result.append((number & mask) != 0 ? ":" : "."); - - if (i % 8 == 0) { - result.append('|'); - } - } - result.replace(result.length() - 1, result.length(), ""); - - return result.toString(); - } - - public static float map(float x, float in_min, float in_max, float out_min, float out_max) { - return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; - } - - public static boolean isInputEqual(boolean aDecreaseStacksizeBySuccess, boolean aDontCheckStackSizes, FluidStack[] requiredFluidInputs, ItemStack[] requiredInputs, FluidStack[] givenFluidInputs, ItemStack... givenInputs) { - if (!GregTech_API.sPostloadFinished) { - return false; - } - if (requiredFluidInputs.length > 0 && givenFluidInputs == null) { - return false; - } - int amt; - for (FluidStack tFluid : requiredFluidInputs) { - if (tFluid != null) { - boolean temp = true; - amt = tFluid.amount; - for (FluidStack aFluid : givenFluidInputs) { - if (aFluid != null && aFluid.isFluidEqual(tFluid)) { - if (aDontCheckStackSizes) { - temp = false; - break; - } - amt -= aFluid.amount; - if (amt < 1) { - temp = false; - break; - } - } - } - if (temp) { - return false; - } - } - } - - if (requiredInputs.length > 0 && givenInputs == null) { - return false; - } - for (ItemStack tStack : requiredInputs) { - if (tStack != null) { - amt = tStack.stackSize; - boolean temp = true; - for (ItemStack aStack : givenInputs) { - if (GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true)) { - if (aDontCheckStackSizes) { - temp = false; - break; - } - amt -= aStack.stackSize; - if (amt < 1) { - temp = false; - break; - } - } - } - if (temp) { - return false; - } - } - } - - if (aDecreaseStacksizeBySuccess) { - if (givenFluidInputs != null) { - for (FluidStack tFluid : requiredFluidInputs) { - if (tFluid != null) { - amt = tFluid.amount; - for (FluidStack aFluid : givenFluidInputs) { - if (aFluid != null && aFluid.isFluidEqual(tFluid)) { - if (aDontCheckStackSizes) { - aFluid.amount -= amt; - break; - } - if (aFluid.amount < amt) { - amt -= aFluid.amount; - aFluid.amount = 0; - } else { - aFluid.amount -= amt; - break; - } - } - } - } - } - } - - if (givenInputs != null) { - for (ItemStack tStack : requiredInputs) { - if (tStack != null) { - amt = tStack.stackSize; - for (ItemStack aStack : givenInputs) { - if (GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true)) { - if (aDontCheckStackSizes) { - aStack.stackSize -= amt; - break; - } - if (aStack.stackSize < amt) { - amt -= aStack.stackSize; - aStack.stackSize = 0; - } else { - aStack.stackSize -= amt; - break; - } - } - } - } - } - } - } - - return true; - } - - public static String getUniqueIdentifier(ItemStack is) { - return GameRegistry.findUniqueIdentifierFor(is.getItem()).modId + ':' + is.getUnlocalizedName(); - } - - public static byte getTier(long l) { - byte b = -1; - - do { - ++b; - if (b >= CommonValues.V.length) { - return b; - } - } while (l > CommonValues.V[b]); - - return b; - } - - public static String[] splitButDifferent(String string, String delimiter) { - String[] strings = new String[StringUtils.countMatches(string, delimiter) + 1]; - int lastEnd = 0; - for (int i = 0; i < strings.length - 1; i++) { - int nextEnd = string.indexOf(delimiter, lastEnd); - strings[i] = string.substring(lastEnd, nextEnd); - lastEnd = nextEnd + delimiter.length(); - } - strings[strings.length - 1] = string.substring(lastEnd); - return strings; - } - - public static String[] infoFromNBT(NBTTagCompound nbt) { - String[] strings = new String[nbt.getInteger("i")]; - for (int i = 0; i < strings.length; i++) { - strings[i] = nbt.getString(Integer.toString(i)); - } - return strings; - } - - public static boolean areBitsSet(int setBits, int testedValue) { - return (testedValue & setBits) == setBits; - } - - public static class ItemStack_NoNBT implements Comparable { - public final Item mItem; - public final int mStackSize; - public final int mMetaData; - - public ItemStack_NoNBT(Item aItem, long aStackSize, long aMetaData) { - this.mItem = aItem; - this.mStackSize = (byte) ((int) aStackSize); - this.mMetaData = (short) ((int) aMetaData); - } - - public ItemStack_NoNBT(ItemStack aStack) { - if (aStack == null) { - mItem = null; - mStackSize = mMetaData = 0; - } else { - mItem = aStack.getItem(); - mStackSize = aStack.stackSize; - mMetaData = Items.feather.getDamage(aStack); - } - } - - @Override - public int compareTo(ItemStack_NoNBT o) { - if (mMetaData > o.mMetaData) return 1; - if (mMetaData < o.mMetaData) return -1; - if (mStackSize > o.mStackSize) return 1; - if (mStackSize < o.mStackSize) return -1; - if (mItem != null && o.mItem != null) - return mItem.getUnlocalizedName().compareTo(o.mItem.getUnlocalizedName()); - if (mItem == null && o.mItem == null) return 0; - if (mItem != null) return 1; - return -1; - } - - @Override - public boolean equals(Object aStack) { - return aStack == this || - (aStack instanceof ItemStack_NoNBT && - ((mItem == ((ItemStack_NoNBT) aStack).mItem) || ((ItemStack_NoNBT) aStack).mItem.getUnlocalizedName().equals(this.mItem.getUnlocalizedName())) && - ((ItemStack_NoNBT) aStack).mStackSize == this.mStackSize && - ((ItemStack_NoNBT) aStack).mMetaData == this.mMetaData); - } - - @Override - public int hashCode() { - return (mItem != null ? mItem.getUnlocalizedName().hashCode() : 0) ^ (mMetaData << 16) ^ (mStackSize << 24); - } - - @Override - public String toString() { - return Integer.toString(hashCode()) + ' ' + (mItem == null ? "null" : mItem.getUnlocalizedName()) + ' ' + mMetaData + ' ' + mStackSize; - } - } - - 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){ - //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); - } - 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 long receiveLong(long previousValue, int startIndex, int index, int value){ - value &=0xFFFF; - switch (index-startIndex){ - case 0: - previousValue&= 0xFFFF_FFFF_FFFF_0000L; - previousValue|=value; - break; - case 1: - previousValue&=0xFFFF_FFFF_0000_FFFFL; - previousValue|=value<<16; - break; - case 2: - previousValue&=0xFFFF_0000_FFFF_FFFFL; - previousValue|=(long)value<<32; - break; - case 3: - previousValue&=0x0000_FFFF_FFFF_FFFFL; - previousValue|=(long)value<<48; - break; - } - return previousValue; - } - - 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,0); - } - - 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)); - } - - @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 int receiveInteger(int previousValue, int startIndex, int index, int value){ - value &=0xFFFF; - switch (index-startIndex){ - case 0: - previousValue&= 0xFFFF_0000; - previousValue|=value; - break; - case 1: - 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 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); - } - return Double.toString(value); - } - - 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) { - try { - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { - 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){ - return tagCompound; - } - 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){ - return tagCompound; - } - tagCompound=readBackup(new File(dir, id2 + "."+extension+"_bak")); - if(tagCompound!=null){ - return tagCompound; - } - } - } - } catch (Exception ignored) {} - return new NBTTagCompound(); - } - - 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); - } - } - } catch (Exception ignored) {} - } - - private static NBTTagCompound read(File file){ - if (file != null && file.exists()) { - try(FileInputStream fileInputStream= new FileInputStream(file)) { - return CompressedStreamTools.readCompressed(fileInputStream); - } catch (Exception var9) { - TecTech.LOGGER.error("Cannot read NBT File: "+file.getAbsolutePath()); - } - } - return null; - } - - private static NBTTagCompound readBackup(File file){ - if (file != null && file.exists()) { - try(FileInputStream fileInputStream= new FileInputStream(file)) { - return CompressedStreamTools.readCompressed(fileInputStream); - } catch (Exception var9) { - TecTech.LOGGER.error("Cannot read NBT File: "+file.getAbsolutePath()); - return new NBTTagCompound(); - } - } - return null; - } - - 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); - } catch (Exception var9) { - 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 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 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/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index 79c46b07a2..f9ab756696 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -865,6 +865,7 @@ 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 @@ -873,6 +874,8 @@ tile.turretBaseEM.name=Elemental Turret Base tt.keyword.mol=mol tt.keyword.itemMols=items tt.keyword.mbMols=mb +#that the thing wont decay +tt.keyword.stable=STABLE #EM types tt.keyword.Primitive=Primitive tt.keyword.Element=Element -- cgit