aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlease <4586901+Glease@users.noreply.github.com>2022-02-23 13:03:46 +0800
committerGitHub <noreply@github.com>2022-02-23 06:03:46 +0100
commitd246612148b9b6dfaa4dfabd399f077ea0544096 (patch)
treea96dab0db8900faf6e344c1a1c7b58549c3cead3
parent7252f84377957aadcbb3b64b1b369209f1846e95 (diff)
downloadGT5-Unofficial-d246612148b9b6dfaa4dfabd399f077ea0544096.tar.gz
GT5-Unofficial-d246612148b9b6dfaa4dfabd399f077ea0544096.tar.bz2
GT5-Unofficial-d246612148b9b6dfaa4dfabd399f077ea0544096.zip
Consolidate boro glass stuff into a real API (#95)
* Consolidate boro glass stuff into a real API * pull in changes from ExampleMod * Fix underflow * attempt to fix build Former-commit-id: 2413c93bc2bb5ab32a0e8078dbcf01a4b23b1f7d
-rw-r--r--.editorconfig19
-rw-r--r--.github/scripts/test-no-crash-reports.sh9
-rwxr-xr-x.github/scripts/test_no_error_reports51
-rw-r--r--.github/workflows/build-and-test.yml20
-rw-r--r--build.gradle159
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/API/BorosilicateGlass.java152
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreTransformer.java3
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java7
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java20
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java66
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java70
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java26
12 files changed, 368 insertions, 234 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000000..6effbc91a8
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,19 @@
+# This is the universal Text Editor Configuration
+# for all GTNewHorizons projects
+# See: https://editorconfig.org/
+
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+indent_size = 4
+indent_style = space
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.{bat,ini}]
+end_of_line = crlf
+
+[*.{dtd,json,info,mcmeta,md,sh,svg,xml,xsd,xsl,yaml,yml}]
+indent_size = 2
diff --git a/.github/scripts/test-no-crash-reports.sh b/.github/scripts/test-no-crash-reports.sh
deleted file mode 100644
index c67e342c06..0000000000
--- a/.github/scripts/test-no-crash-reports.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-directory="run/crash-reports"
-if [ -d $directory ]; then
- echo "Crash reports detected:"
- cat $directory/*
- exit 1
-else
- echo "No crash reports detected"
- exit 0
-fi
diff --git a/.github/scripts/test_no_error_reports b/.github/scripts/test_no_error_reports
new file mode 100755
index 0000000000..1fcc7396c6
--- /dev/null
+++ b/.github/scripts/test_no_error_reports
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+
+# bashsupport disable=BP5006 # Global environment variables
+RUNDIR="run" \
+ CRASH="crash-reports" \
+ SERVERLOG="server.log"
+
+# enable nullglob to get 0 results when no match rather than the pattern
+shopt -s nullglob
+
+# store matches in array
+crash_reports=("$RUNDIR/$CRASH/crash"*.txt)
+
+# if array not empty there are crash_reports
+if [ "${#crash_reports[@]}" -gt 0 ]; then
+ # get the latest crash_report from array
+ latest_crash_report="${crash_reports[-1]}"
+ {
+ printf 'Latest crash report detected %s:\n' "${latest_crash_report##*/}"
+ cat "$latest_crash_report"
+ } >&2
+ exit 1
+fi
+
+if grep --quiet --fixed-strings 'Fatal errors were detected' "$SERVERLOG"; then
+ {
+ printf 'Fatal errors detected:\n'
+ cat server.log
+ } >&2
+ exit 1
+fi
+
+if grep --quiet --fixed-strings 'The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED' \
+ "$SERVERLOG"; then
+ {
+ printf 'Server force stopped:'
+ cat server.log
+ } >&2
+ exit 1
+fi
+
+if ! grep --quiet --perl-regexp --only-matching '.+Done \(.+\)\! For help, type "help" or "\?"' "$SERVERLOG"; then
+ {
+ printf 'Server did not finish startup:'
+ cat server.log
+ } >&2
+ exit 1
+fi
+
+printf 'No crash reports detected'
+exit 0
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
index a60a2b6468..56a1ad52cc 100644
--- a/.github/workflows/build-and-test.yml
+++ b/.github/workflows/build-and-test.yml
@@ -14,32 +14,32 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- with:
+ with:
fetch-depth: 0
-
+
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: gradle
-
+
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup the workspace
run: ./gradlew setupCIWorkspace
-
+
- name: Build the mod
run: ./gradlew build
- - name: Run server for 1 minute
+ - name: Run server for 1.5 minutes
run: |
mkdir run
- echo "eula=true" > run/eula.txt
- timeout 60 ./gradlew runServer || true
+ echo "eula=true" > run/eula.txt
+ timeout 90 ./gradlew runServer 2>&1 | tee -a server.log || true
- - name: Test no crashes happend
+ - name: Test no errors reported during server run
run: |
- chmod +x .github/scripts/test-no-crash-reports.sh
- .github/scripts/test-no-crash-reports.sh
+ chmod +x .github/scripts/test_no_error_reports
+ .github/scripts/test_no_error_reports
diff --git a/build.gradle b/build.gradle
index 4f54c87f65..5906f8fc98 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,11 +1,14 @@
-//version: 1643844119
+//version: 1644894948
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates.
- */
+*/
+import org.gradle.internal.logging.text.StyledTextOutput
+import org.gradle.internal.logging.text.StyledTextOutputFactory
+import org.gradle.internal.logging.text.StyledTextOutput.Style
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
@@ -15,20 +18,20 @@ import java.util.concurrent.TimeUnit
buildscript {
repositories {
maven {
- name = "forge"
- url = "https://maven.minecraftforge.net"
+ name 'forge'
+ url 'https://maven.minecraftforge.net'
}
maven {
- name = "sonatype"
- url = "https://oss.sonatype.org/content/repositories/snapshots/"
+ name 'sonatype'
+ url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven {
- name = "Scala CI dependencies"
- url = "https://repo1.maven.org/maven2/"
+ name 'Scala CI dependencies'
+ url 'https://repo1.maven.org/maven2/'
}
maven {
- name = "jitpack"
- url = "https://jitpack.io"
+ name 'jitpack'
+ url 'https://jitpack.io'
}
}
dependencies {
@@ -37,21 +40,26 @@ buildscript {
}
plugins {
+ id 'java-library'
id 'idea'
id 'eclipse'
id 'scala'
- id('org.jetbrains.kotlin.jvm') version ('1.6.10') apply false
- id('org.ajoberstar.grgit') version('4.1.1')
- id('com.github.johnrengelman.shadow') version('4.0.4')
- id('com.palantir.git-version') version('0.13.0') apply false
- id('de.undercouch.download') version('5.0.1')
- id('maven-publish')
+ id 'maven-publish'
+ id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false
+ id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false
+ id 'org.ajoberstar.grgit' version '4.1.1'
+ id 'com.github.johnrengelman.shadow' version '4.0.4'
+ id 'com.palantir.git-version' version '0.13.0' apply false
+ id 'de.undercouch.download' version '5.0.1'
+ id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false
}
if (project.file('.git/HEAD').isFile()) {
apply plugin: 'com.palantir.git-version'
}
+def out = services.get(StyledTextOutputFactory).create('an-output')
+
apply plugin: 'forge'
def projectJavaVersion = JavaLanguageVersion.of(8)
@@ -167,8 +175,8 @@ configurations.all {
try {
'git config core.fileMode false'.execute()
}
-catch (Exception e) {
- logger.error("\u001B[31mgit isn't installed at all\u001B[0m")
+catch (Exception ignored) {
+ out.style(Style.Failure).println("git isn't installed at all")
}
// Pulls version first from the VERSION env and then git tag
@@ -177,19 +185,22 @@ String versionOverride = System.getenv("VERSION") ?: null
try {
identifiedVersion = versionOverride == null ? gitVersion() : versionOverride
}
-catch (Exception e) {
- logger.error("\n\u001B[1;31mThis mod must be version controlled by Git AND the repository must provide at least one tag,\n" +
- "or the VERSION override must be set! \u001B[32m(Don't download from GitHub using the ZIP option, instead\n" +
- "clone the repository, see\u001B[33m https://gtnh.miraheze.org/wiki/Development \u001B[32mfor details.)\u001B[0m\n");
+catch (Exception ignored) {
+ out.style(Style.Failure).text(
+ 'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' +
+ 'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' +
+ 'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)'
+ )
versionOverride = 'NO-GIT-TAG-SET'
identifiedVersion = versionOverride
}
version = minecraftVersion + '-' + identifiedVersion
-String modVersion = identifiedVersion
+ext {
+ modVersion = identifiedVersion
+}
-if( identifiedVersion.equals(versionOverride) ) {
- logger.error('\u001B[31m\u001B[7mWe hope you know what you\'re doing using\u001B[0m\u001B[1;34m ' + modVersion + '\u001B[0m\n');
- logger.error('\7\u001B[31mGoing to blindly try to use\u001B[1;34m ' + modVersion + '\u001B[0m\u001B[31m, this probably won\'t work the way you expect!!\u001B[0m\n');
+if(identifiedVersion == versionOverride) {
+ out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7')
}
group = modGroup
@@ -200,7 +211,6 @@ else {
archivesBaseName = modId
}
-
def arguments = []
def jvmArguments = []
@@ -214,8 +224,8 @@ if(usesMixins.toBoolean()) {
}
minecraft {
- version = minecraftVersion + "-" + forgeVersion + "-" + minecraftVersion
- runDir = "run"
+ version = minecraftVersion + '-' + forgeVersion + '-' + minecraftVersion
+ runDir = 'run'
if (replaceGradleTokenInFile) {
replaceIn replaceGradleTokenInFile
@@ -248,8 +258,8 @@ minecraft {
}
}
-if(file("addon.gradle").exists()) {
- apply from: "addon.gradle"
+if(file('addon.gradle').exists()) {
+ apply from: 'addon.gradle'
}
apply from: 'repositories.gradle'
@@ -262,42 +272,42 @@ configurations {
repositories {
maven {
- name = "Overmind forge repo mirror"
- url = "https://gregtech.overminddl1.com/"
+ name 'Overmind forge repo mirror'
+ url 'https://gregtech.overminddl1.com/'
}
if(usesMixins.toBoolean()) {
maven {
- name = "sponge"
- url = "https://repo.spongepowered.org/repository/maven-public"
+ name 'sponge'
+ url 'https://repo.spongepowered.org/repository/maven-public'
}
maven {
- url = "https://jitpack.io"
+ url 'https://jitpack.io'
}
}
}
dependencies {
if(usesMixins.toBoolean()) {
- annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3")
- annotationProcessor("com.google.guava:guava:24.1.1-jre")
- annotationProcessor("com.google.code.gson:gson:2.8.6")
- annotationProcessor("org.spongepowered:mixin:0.8-SNAPSHOT")
+ annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3')
+ annotationProcessor('com.google.guava:guava:24.1.1-jre')
+ annotationProcessor('com.google.code.gson:gson:2.8.6')
+ annotationProcessor('org.spongepowered:mixin:0.8-SNAPSHOT')
// using 0.8 to workaround a issue in 0.7 which fails mixin application
- compile("com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH") {
+ compile('com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH') {
// Mixin includes a lot of dependencies that are too up-to-date
- exclude module: "launchwrapper"
- exclude module: "guava"
- exclude module: "gson"
- exclude module: "commons-io"
- exclude module: "log4j-core"
+ exclude module: 'launchwrapper'
+ exclude module: 'guava'
+ exclude module: 'gson'
+ exclude module: 'commons-io'
+ exclude module: 'log4j-core'
}
- compile("com.github.GTNewHorizons:SpongeMixins:1.5.0")
+ compile('com.github.GTNewHorizons:SpongeMixins:1.5.0')
}
}
apply from: 'dependencies.gradle'
-def mixingConfigRefMap = "mixins." + modId + ".refmap.json"
+def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json'
def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfigRefMap
def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg"
@@ -401,17 +411,16 @@ tasks.withType(JavaExec).configureEach {
)
}
-processResources
-{
+processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
-
+
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
- // replace version and mcversion
+ // replace modVersion and minecraftVersion
expand "minecraftVersion": project.minecraft.version,
"modVersion": modVersion,
"modId": modId,
@@ -422,7 +431,7 @@ processResources
from refMap
}
- // copy everything else, thats not the mcmod.info
+ // copy everything else that's not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
@@ -430,7 +439,7 @@ processResources
def getManifestAttributes() {
def manifestAttributes = [:]
- if(containsMixinsAndOrCoreModOnly.toBoolean() == false && (usesMixins.toBoolean() || coreModClass)) {
+ if(!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) {
manifestAttributes += ["FMLCorePluginContainsFMLMod": true]
}
@@ -446,14 +455,14 @@ def getManifestAttributes() {
manifestAttributes += [
"TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
"MixinConfigs" : "mixins." + modId + ".json",
- "ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false
+ "ForceLoadAsMod" : !containsMixinsAndOrCoreModOnly.toBoolean()
]
}
return manifestAttributes
}
task sourcesJar(type: Jar) {
- from (sourceSets.main.allJava)
+ from (sourceSets.main.allSource)
from (file("$projectDir/LICENSE"))
getArchiveClassifier().set('sources')
}
@@ -508,7 +517,7 @@ task devJar(type: Jar) {
}
task apiJar(type: Jar) {
- from (sourceSets.main.allJava) {
+ from (sourceSets.main.allSource) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
}
@@ -533,14 +542,15 @@ artifacts {
}
}
-// The gradle metadata includes all of the additional deps that we disabled from POM generation (including forgeBin with no groupID),
+// The gradle metadata includes all of the additional deps that we disabled from POM generation (including forgeBin with no groupID),
// and isn't strictly needed with the POM so just disable it.
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
+// workaround variable hiding in pom processing
+def projectConfigs = project.configurations
-// publishing
publishing {
publications {
maven(MavenPublication) {
@@ -560,14 +570,21 @@ publishing {
artifactId = System.getenv("ARTIFACT_ID") ?: project.name
// Using the identified version, not project.version as it has the prepended 1.7.10
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
-
- // Remove all non GTNH deps here.
- // Original intention was to remove an invalid forgeBin being generated without a groupId (mandatory), but
- // it also removes all of the MC deps
+
+ // remove extra garbage from minecraft and minecraftDeps configuration
pom.withXml {
+ def badArtifacts = [:].withDefault {[] as Set<String>}
+ for (configuration in [projectConfigs.minecraft, projectConfigs.minecraftDeps]) {
+ for (dependency in configuration.allDependencies) {
+ badArtifacts[dependency.group == null ? "" : dependency.group] += dependency.name
+ }
+ }
+ // example for specifying extra stuff to ignore
+ // badArtifacts["org.example.group"] += "artifactName"
+
Node pomNode = asNode()
pomNode.dependencies.'*'.findAll() {
- it.groupId.text() != 'com.github.GTNewHorizons'
+ badArtifacts[it.groupId.text()].contains(it.artifactId.text())
}.each() {
it.parent().remove(it)
}
@@ -599,7 +616,7 @@ if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
if (autoUpdateBuildScript.toBoolean()) {
performBuildScriptUpdate(projectDir.toString())
} else {
- println("Build script update available! Run 'gradle updateBuildScript'")
+ out.style(Style.SuccessHeader).println("Build script update available! Run 'gradle updateBuildScript'")
}
}
@@ -611,7 +628,7 @@ boolean performBuildScriptUpdate(String projectDir) {
if (isNewBuildScriptVersionAvailable(projectDir)) {
def buildscriptFile = getFile("build.gradle")
availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } }
- print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
+ out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
return true
}
return false
@@ -673,26 +690,26 @@ def deobf(String sourceURL) {
}
}
-// The method above is to be prefered. Use this method if the filename is not at the end of the URL.
+// The method above is to be preferred. Use this method if the filename is not at the end of the URL.
def deobf(String sourceURL, String fileName) {
String cacheDir = System.getProperty("user.home") + "/.gradle/caches/"
String bon2Dir = cacheDir + "forge_gradle/deobf"
String bon2File = bon2Dir + "/BON2-2.5.0.jar"
String obfFile = cacheDir + "modules-2/files-2.1/" + fileName + ".jar"
String deobfFile = cacheDir + "modules-2/files-2.1/" + fileName + "-deobf.jar"
-
+
if(file(deobfFile).exists()) {
return files(deobfFile)
}
- download {
+ download.run {
src 'https://github.com/GTNewHorizons/BON2/releases/download/2.5.0/BON2-2.5.0.CUSTOM-all.jar'
dest bon2File
quiet true
overwrite false
}
- download {
+ download.run {
src sourceURL
dest obfFile
quiet true
@@ -711,7 +728,7 @@ def deobf(String sourceURL, String fileName) {
// Helper methods
def checkPropertyExists(String propertyName) {
- if (project.hasProperty(propertyName) == false) {
+ if (!project.hasProperty(propertyName)) {
throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/gradle.properties")
}
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BorosilicateGlass.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BorosilicateGlass.java
new file mode 100644
index 0000000000..e4714d059d
--- /dev/null
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BorosilicateGlass.java
@@ -0,0 +1,152 @@
+package com.github.bartimaeusnek.bartworks.API;
+
+import com.gtnewhorizon.structurelib.structure.IStructureElement;
+import cpw.mods.fml.common.registry.GameRegistry;
+import net.minecraft.block.Block;
+import org.apache.commons.lang3.tuple.Pair;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAdder;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAnyMeta;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered;
+
+/**
+ * API for bartworks borosilicate glass.
+ * <p>
+ * You might have noticed this API does not expose any Block instance, but only IStructureElements. This is in case we
+ * add more glass blocks later, and we run out of meta id for only one block.
+ * <p>
+ * IStructureElements returned from this class should not have its methods called before the game start.
+ */
+public class BorosilicateGlass {
+
+ private static Block block;
+ private static List<Pair<Block, Integer>> representatives;
+
+ private static Block getGlassBlock() {
+ if (block == null)
+ block = GameRegistry.findBlock("bartworks", "BW_GlasBlocks");
+ return block;
+ }
+
+ private static List<Pair<Block, Integer>> getRepresentatives() {
+ if (representatives == null) {
+ ArrayList<Pair<Block, Integer>> ret = new ArrayList<>();
+ Block block = getGlassBlock();
+ ret.add(Pair.of(block, 0));
+ ret.add(Pair.of(block, 1));
+ ret.add(Pair.of(block, 2));
+ ret.add(Pair.of(block, 3));
+ ret.add(Pair.of(block, 4));
+ ret.add(Pair.of(block, 5));
+ ret.add(Pair.of(block, 13));
+ ret.add(Pair.of(block, 14));
+ representatives = ret;
+ }
+ return representatives;
+ }
+
+ private static byte checkWithinBound(byte val, byte lo, byte hi) {
+ return val > hi || val < lo ? -1 : val;
+ }
+
+ /**
+ * Check if there is at least one type of boroglass in that tier.
+ */
+ public static boolean hasGlassInTier(int tier) {
+ return tier >= 3 && tier <= 10;
+ }
+
+ /**
+ * Get a structure element for a certain tier of <b>borosilicate</b> glass. DOES NOT accept other glass like reinforced glass, magic mirror, vanilla glass, etc.
+ * <p>
+ * Use this if you just want boroglass here and doesn't care what tier it is.
+ */
+ public static <T> IStructureElement<T> ofBoroGlass(int tier) {
+ if (!hasGlassInTier(tier)) throw new IllegalArgumentException();
+ return lazy(t -> {
+ Pair<Block, Integer> pair = getRepresentatives().get(tier - 3);
+ return ofBlockAdder((t1, block1, meta) -> getTier(block1, meta) == tier, pair.getKey(), pair.getValue());
+ });
+ }
+
+ /**
+ * Get a structure element for any kind of <b>borosilicate</b> glass. DOES NOT accept other glass like reinforced glass, magic mirror, vanilla glass, etc.
+ * <p>
+ * Use this if you just want boroglass here and doesn't care what tier it is.
+ */
+ public static <T> IStructureElement<T> ofBoroGlassAnyTier() {
+ return lazy(t -> ofBlockAnyMeta(getGlassBlock()));
+ }
+
+ /**
+ * Get a structure element for <b>borosilicate</b> glass. DOES NOT accept other glass like reinforced glass, magic mirror, vanilla glass, etc.
+ * <p>
+ * This assumes you want all glass used to be of the same tier.
+ * <p>
+ * NOTE: This will accept the basic boron glass (HV tier) as well. You might not want this. Use the other overload to filter this out.
+ *
+ * @param initialValue the value set before structure check started
+ */
+ public static <T> IStructureElement<T> ofBoroGlass(byte initialValue, BiConsumer<T, Byte> setter, Function<T, Byte> getter) {
+ return lazy(t -> ofBlocksTiered(BorosilicateGlass::getTier, getRepresentatives(), initialValue, setter, getter));
+ }
+
+ /**
+ * Get a structure element for <b>borosilicate</b> glass. DOES NOT accept other glass like reinforced glass, magic mirror, vanilla glass, etc.
+ *
+ * @param initialValue the value set before structure check started
+ * @param minTier minimal accepted tier. inclusive. must be greater than 0.
+ * @param maxTier maximal accepted tier. inclusive.
+ */
+ public static <T> IStructureElement<T> ofBoroGlass(byte initialValue, byte minTier, byte maxTier, BiConsumer<T, Byte> setter, Function<T, Byte> getter) {
+ if (minTier > maxTier || minTier < 0) throw new IllegalArgumentException();
+ return lazy(t -> ofBlocksTiered(
+ (block1, meta) -> checkWithinBound(getTier(block1, meta), minTier, maxTier),
+ getRepresentatives().stream().skip(Math.max(minTier - 3, 0)).limit(maxTier - minTier + 1).collect(Collectors.toList()),
+ initialValue,
+ setter,
+ getter
+ ));
+ }
+
+ /**
+ * Get the tier of this <b>borosilicate</b> glass. DOES NOT consider other glass like reinforced glass, magic mirror, vanilla glass, etc.
+ */
+ public static byte getTier(Block block, int meta) {
+ byte ret;
+ switch (meta) {
+ case 1:
+ ret = 4;
+ break;
+ case 2:
+ case 12:
+ ret = 5;
+ break;
+ case 3:
+ ret = 6;
+ break;
+ case 4:
+ ret = 7;
+ break;
+ case 5:
+ ret = 8;
+ break;
+ case 13:
+ ret = 9;
+ break;
+ case 14:
+ ret = 10;
+ break;
+ default:
+ ret = 3;
+ }
+ return block == getGlassBlock() ? ret : -1;
+ }
+}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreTransformer.java b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreTransformer.java
index 4ea3582bd1..223a067ce6 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreTransformer.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreTransformer.java
@@ -296,6 +296,9 @@ public class BWCoreTransformer implements IClassTransformer {
toPatch.instructions.add(new VarInsnNode(ALOAD,2));
toPatch.instructions.add(new MethodInsnNode(INVOKESTATIC,"com/github/bartimaeusnek/bartworks/ASM/BWCoreStaticReplacementMethodes","findCachedMatchingRecipe","(Lnet/minecraft/inventory/InventoryCrafting;Lnet/minecraft/world/World;)Lnet/minecraft/item/ItemStack;",false));
toPatch.instructions.add(new InsnNode(ARETURN));
+ toPatch.localVariables.clear();
+ toPatch.maxStack = 2;
+ toPatch.maxLocals = 3;
break scase;
}
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java
index e0c172f1cd..a136cfd34b 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java
@@ -22,6 +22,7 @@
package com.github.bartimaeusnek.bartworks.common.items;
+import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass;
import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation;
import com.github.bartimaeusnek.bartworks.MainMod;
import com.github.bartimaeusnek.bartworks.common.blocks.BW_GlasBlocks;
@@ -69,8 +70,10 @@ public class BW_ItemBlocks extends ItemBlock {
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) {
- if (this.field_150939_a instanceof BW_GlasBlocks)
- aList.add(StatCollector.translateToLocal("tooltip.glas.0.name") + " " + BW_ColorUtil.getColorForTier(BW_Util.getTierFromGlasMeta(aStack.getItemDamage())) + GT_Values.VN[BW_Util.getTierFromGlasMeta(aStack.getItemDamage())]);
+ byte tier = BorosilicateGlass.getTier(this.field_150939_a, aStack.getItemDamage());
+ if (tier >= 0) {
+ aList.add(StatCollector.translateToLocal("tooltip.glas.0.name") + " " + BW_ColorUtil.getColorForTier(tier) + GT_Values.VN[tier]);
+ }
if (this.field_150939_a instanceof ITileAddsInformation) {
aList.addAll(Arrays.asList(((ITileAddsInformation) this.field_150939_a).getInfoData()));
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java
index f9263f140a..b204f30502 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java
@@ -22,6 +22,7 @@
package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega;
+import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass;
import com.github.bartimaeusnek.bartworks.API.LoaderReference;
import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler;
import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry;
@@ -77,7 +78,7 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl
.addElement('t', ofHatchAdderOptional(GT_TileEntity_MegaBlastFurnace::addOutputHatchToTopList, CASING_INDEX, 1, GregTech_API.sBlockCasings1, CASING_INDEX))
.addElement('m', ofHatchAdder(GT_TileEntity_MegaBlastFurnace::addMufflerToMachineList, CASING_INDEX, 2))
.addElement('C', ofCoil(GT_TileEntity_MegaBlastFurnace::setCoilLevel, GT_MetaTileEntity_ElectricBlastFurnace::getCoilLevel))
- .addElement('g', ofBlockAdder(GT_TileEntity_MegaBlastFurnace::addGlas, ItemRegistry.bw_glasses[0], 1))
+ .addElement('g', BorosilicateGlass.ofBoroGlass((byte) 0, (byte) 1, Byte.MAX_VALUE, (te, t) -> te.glasTier = t, te -> te.glasTier))
.addElement('b', ofHatchAdderOptional(GT_TileEntity_MegaBlastFurnace::addBottomHatch, CASING_INDEX, 3, GregTech_API.sBlockCasings1, CASING_INDEX))
.build();
@@ -163,9 +164,7 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl
return tt;
}
- @SuppressWarnings("rawtypes")
public ArrayList<Object> TTTunnels = new ArrayList<>();
- @SuppressWarnings("rawtypes")
public ArrayList<Object> TTMultiAmp = new ArrayList<>();
@Override
@@ -455,17 +454,6 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl
buildPiece("main", stackSize, hintsOnly, 7, 17, 0);
}
- private boolean addGlas(Block block, int meta) {
- if (block != ItemRegistry.bw_glasses[0])
- return false;
- byte tier = BW_Util.getTierFromGlasMeta(meta);
- if (tier >= 8) tier = 8;
- if (glasTier > 0)
- return tier == glasTier;
- glasTier = tier;
- return true;
- }
-
@Override
public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) {
if (LoaderReference.tectech) {
@@ -489,11 +477,11 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl
if (mMaintenanceHatches.size() != 1)
return false;
- if (LoaderReference.tectech && this.glasTier != 8)
+ if (LoaderReference.tectech && this.glasTier < 8)
if (!areLazorsLowPowa() || areThingsNotProperlyTiered(this.getTecTechEnergyTunnels()) || areThingsNotProperlyTiered(this.getTecTechEnergyMultis()))
return false;
- if (this.glasTier != 8 && !this.mEnergyHatches.isEmpty())
+ if (this.glasTier < 8 && !this.mEnergyHatches.isEmpty())
for (GT_MetaTileEntity_Hatch_Energy hatchEnergy : this.mEnergyHatches)
if (this.glasTier < hatchEnergy.mTier)
return false;
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java
index 3aaeab8c30..e2383c8fa1 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java
@@ -22,9 +22,9 @@
package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega;
+import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass;
import com.github.bartimaeusnek.bartworks.API.LoaderReference;
import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler;
-import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry;
import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference;
import com.github.bartimaeusnek.bartworks.util.BW_Util;
import com.github.bartimaeusnek.bartworks.util.MegaUtils;
@@ -33,20 +33,15 @@ import com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti;
import com.github.bartimaeusnek.crossmod.tectech.helper.TecTe