Skip to content

Commit

Permalink
Migrate to new RecipeMap (#29)
Browse files Browse the repository at this point in the history
* Migrate to new RecipeMap

* update gradle+bs+deps

* bump version

---------

Co-authored-by: Martin Robertz <[email protected]>
  • Loading branch information
miozune and Dream-Master authored Dec 3, 2023
1 parent caaeb2a commit 6cf9b9e
Show file tree
Hide file tree
Showing 15 changed files with 170 additions and 176 deletions.
27 changes: 0 additions & 27 deletions .github/scripts/test-no-error-reports.sh

This file was deleted.

10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.gradle
.settings
/.idea/
/.vscode/
/run/
/build/
/eclipse/
Expand All @@ -25,8 +26,13 @@ whitelist.json
*.iml
*.ipr
*.iws
src/main/resources/mixins.*.json
src/main/resources/mixins.*([!.]).json
*.bat
*.DS_Store
!gradlew.bat
/src/main/generated
.factorypath
addon.local.gradle
addon.local.gradle.kts
addon.late.local.gradle
addon.late.local.gradle.kts
layout.json
97 changes: 57 additions & 40 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 1692122114
//version: 1701530445
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Expand Down Expand Up @@ -28,27 +28,12 @@ import java.util.concurrent.TimeUnit

buildscript {
repositories {
mavenCentral()

maven {
name 'forge'
url 'https://maven.minecraftforge.net'
}
maven {
// GTNH RetroFuturaGradle and ASM Fork
name "GTNH Maven"
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
allowInsecureProtocol = true
}
maven {
name 'sonatype'
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven {
name 'Scala CI dependencies'
url 'https://repo1.maven.org/maven2/'
}

mavenLocal()
}
}
Expand Down Expand Up @@ -89,6 +74,23 @@ def out = services.get(StyledTextOutputFactory).create('an-output')
def projectJavaVersion = JavaLanguageVersion.of(8)

boolean disableSpotless = project.hasProperty("disableSpotless") ? project.disableSpotless.toBoolean() : false
boolean disableCheckstyle = project.hasProperty("disableCheckstyle") ? project.disableCheckstyle.toBoolean() : false

final String CHECKSTYLE_CONFIG = """
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<!-- Use CHECKSTYLE:OFF and CHECKSTYLE:ON comments to suppress checkstyle lints in a block -->
<module name="SuppressionCommentFilter"/>
<module name="AvoidStarImport">
<!-- Allow static wildcard imports for cases like Opcodes and LWJGL classes, these don't get created accidentally by the IDE -->
<property name="allowStaticMemberImports" value="true"/>
</module>
</module>
</module>
"""

checkPropertyExists("modName")
checkPropertyExists("modId")
Expand Down Expand Up @@ -140,6 +142,17 @@ if (!disableSpotless) {
apply from: Blowdryer.file('spotless.gradle')
}

if (!disableCheckstyle) {
apply plugin: 'checkstyle'
tasks.named("checkstylePatchedMc") { enabled = false }
tasks.named("checkstyleMcLauncher") { enabled = false }
tasks.named("checkstyleIdeVirtualMain") { enabled = false }
tasks.named("checkstyleInjectedTags") { enabled = false }
checkstyle {
config = resources.text.fromString(CHECKSTYLE_CONFIG)
}
}

String javaSourceDir = "src/main/java/"
String scalaSourceDir = "src/main/scala/"
String kotlinSourceDir = "src/main/kotlin/"
Expand Down Expand Up @@ -274,7 +287,7 @@ if (apiPackage) {
}

if (accessTransformersFile) {
for (atFile in accessTransformersFile.split(",")) {
for (atFile in accessTransformersFile.split(" ")) {
String targetFile = "src/main/resources/META-INF/" + atFile.trim()
if (!getFile(targetFile).exists()) {
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
Expand Down Expand Up @@ -600,15 +613,10 @@ repositories {
}
maven {
name = "ic2"
url = "https://maven.ic2.player.to/"
metadataSources {
mavenPom()
artifact()
url = getURL("https://maven.ic2.player.to/", "https://maven2.ic2.player.to/")
content {
includeGroup "net.industrial-craft"
}
}
maven {
name = "ic2-mirror"
url = "https://maven2.ic2.player.to/"
metadataSources {
mavenPom()
artifact()
Expand All @@ -623,7 +631,7 @@ repositories {

def mixinProviderGroup = "io.github.legacymoddingmc"
def mixinProviderModule = "unimixins"
def mixinProviderVersion = "0.1.7.1"
def mixinProviderVersion = "0.1.13"
def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule}:${mixinProviderVersion}"
def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev"
ext.mixinProviderSpec = mixinProviderSpec
Expand Down Expand Up @@ -770,23 +778,14 @@ ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies"
}

dependencies {
def lwjgl3ifyVersion = '1.4.0'
def asmVersion = '9.4'
def lwjgl3ifyVersion = '1.5.7'
if (modId != 'lwjgl3ify') {
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
}
if (modId != 'hodgepodge') {
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.26')
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.35')
}

java17PatchDependencies('net.minecraft:launchwrapper:1.17.2') {transitive = false}
java17PatchDependencies("org.ow2.asm:asm:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-commons:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-tree:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-analysis:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-util:${asmVersion}")
java17PatchDependencies('org.ow2.asm:asm-deprecated:7.1')
java17PatchDependencies("org.apache.commons:commons-lang3:3.12.0")
java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false}
}

Expand Down Expand Up @@ -1173,9 +1172,8 @@ publishing {
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
}
}

repositories {
if (usesMavenPublishing.toBoolean()) {
if (usesMavenPublishing.toBoolean() && System.getenv("MAVEN_USER") != null) {
maven {
url = mavenPublishUrl
allowInsecureProtocol = mavenPublishUrl.startsWith("http://") // Mostly for the GTNH maven
Expand Down Expand Up @@ -1297,7 +1295,7 @@ def addCurseForgeRelation(String type, String name) {

// Updating

def buildscriptGradleVersion = "8.2.1"
def buildscriptGradleVersion = "8.5"

tasks.named('wrapper', Wrapper).configure {
gradleVersion = buildscriptGradleVersion
Expand Down Expand Up @@ -1576,6 +1574,25 @@ def getSecondaryArtifacts() {
return secondaryArtifacts
}

def getURL(String main, String fallback) {
return pingURL(main, 10000) ? main : fallback
}

// credit: https://stackoverflow.com/a/3584332
def pingURL(String url, int timeout) {
url = url.replaceFirst("^https", "http") // Otherwise an exception may be thrown on invalid SSL certificates.
try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection()
connection.setConnectTimeout(timeout)
connection.setReadTimeout(timeout)
connection.setRequestMethod("HEAD")
int responseCode = connection.getResponseCode()
return 200 <= responseCode && responseCode <= 399
} catch (IOException ignored) {
return false
}
}

// For easier scripting of things that require variables defined earlier in the buildscript
if (file('addon.late.gradle.kts').exists()) {
apply from: 'addon.late.gradle.kts'
Expand Down
10 changes: 5 additions & 5 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ dependencies {
compileOnly('com.google.auto.value:auto-value-annotations:1.8.2')
annotationProcessor('com.google.auto.value:auto-value:1.8.2')

api('com.github.GTNewHorizons:NotEnoughItems:2.3.82-GTNH:dev')
api('com.github.GTNewHorizons:NotEnoughItems:2.4.13-GTNH:dev')

api('com.github.GTNewHorizons:DetravScannerMod:1.7.2:dev') {transitive=false}
api('com.github.GTNewHorizons:EnderStorage:1.4.12:dev') {transitive=false}
api('com.github.GTNewHorizons:GT5-Unofficial:5.09.43.171:dev')
api('com.github.GTNewHorizons:GTplusplus:1.9.76:dev')
api('com.github.GTNewHorizons:NewHorizonsCoreMod:2.1.99:dev')
api('com.github.GTNewHorizons:bartworks:0.7.38:dev')
api('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.96:dev')
api('com.github.GTNewHorizons:GTplusplus:1.10.37:dev')
api('com.github.GTNewHorizons:NewHorizonsCoreMod:2.2.44:dev')
api('com.github.GTNewHorizons:bartworks:0.8.19:dev')
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
16 changes: 10 additions & 6 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

Expand Down Expand Up @@ -133,26 +130,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,6 +197,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder;

import gregtech.api.recipe.RecipeMaps;
import gregtech.api.util.GT_Recipe;

class RecipeHandler {
Expand All @@ -40,17 +41,17 @@ void initialize() {
.filter(recipe -> recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() != null)
.forEach(recipe -> craftingTableOutputs.add(ItemComponent.create(recipe.getRecipeOutput())));

assemblingMachineOutputs = GT_Recipe.GT_Recipe_Map.sAssemblerRecipes.mRecipeList.stream()
assemblingMachineOutputs = RecipeMaps.assemblerRecipes.getAllRecipes().stream()
.flatMap(recipe -> GregTechRecipeUtil.buildComponentsFromItemOutputs(recipe).stream())
.map(DisplayComponent::component).map(ItemComponent.class::cast).collect(Collectors.toSet());

assemblingLineOutputs = GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.mRecipeList.stream()
assemblingLineOutputs = RecipeMaps.assemblylineVisualRecipes.getAllRecipes().stream()
.flatMap(recipe -> GregTechRecipeUtil.buildComponentsFromItemOutputs(recipe).stream())
.map(DisplayComponent::component).map(ItemComponent.class::cast).collect(Collectors.toSet());

Set<ItemComponent> allCircuits = circuitLineHandler.allCircuits();
ListMultimap<ItemComponent, GT_Recipe> circuitRecipes = MultimapBuilder.hashKeys().arrayListValues().build();
for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeList) {
for (GT_Recipe recipe : RecipeMaps.circuitAssemblerRecipes.getAllRecipes()) {
ItemComponent output = (ItemComponent) Iterables
.getOnlyElement(GregTechRecipeUtil.buildComponentsFromItemOutputs(recipe)).component();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import gregtech.api.enums.OrePrefixes;
import gregtech.api.objects.ItemData;
import gregtech.api.recipe.RecipeMaps;
import gregtech.api.util.GT_Recipe;

class RecipeHandler {
Expand Down Expand Up @@ -85,7 +86,7 @@ public int compareTo(Recipe other) {

/** This method must be called before any other methods are called. */
void initialize() {
GT_Recipe.GT_Recipe_Map.sLaserEngraverRecipes.mRecipeList.forEach(this::handleRecipe);
RecipeMaps.laserEngraverRecipes.getAllRecipes().forEach(this::handleRecipe);

// Check that lenses of the same colour all have the same recipes.
for (LensColour colour : lensColours.keySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.objects.ItemData;
import gregtech.api.recipe.RecipeMaps;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Recipe;

Expand Down Expand Up @@ -117,7 +118,7 @@ private void insertIntoSlot(Diagram.Builder builder, Materials material) {
}

void initialize() {
for (GT_Recipe ebfRecipe : GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeList) {
for (GT_Recipe ebfRecipe : RecipeMaps.blastFurnaceRecipes.getAllRecipes()) {
for (ItemStack output : ebfRecipe.mOutputs) {
ItemData outData = GT_OreDictUnificator.getAssociation(output);
if ((outData != null) && outData.hasValidMaterialData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import gregtech.api.enums.Materials;
import gregtech.api.items.GT_MetaGenerated_Tool;
import gregtech.api.util.GT_Recipe;
import gregtech.api.recipe.RecipeMaps;
import gregtech.common.items.GT_MetaGenerated_Tool_01;
import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools;

Expand Down Expand Up @@ -163,7 +163,7 @@ void initialize() {
// First pass: find all tools with recipes, and group them by base NBT item stack.
((List<IRecipe>) CraftingManager.getInstance().getRecipeList())
.forEach(recipe -> addTool(recipe.getRecipeOutput()));
GT_Recipe.GT_Recipe_Map.sAssemblerRecipes.mRecipeList.forEach(recipe -> addTool(recipe.getOutput(0)));
RecipeMaps.assemblerRecipes.getAllRecipes().forEach(recipe -> addTool(recipe.getOutput(0)));

// Second pass: iterate through and construct DisplayComponents for found tools.
// We iterate on SortedSet copies so that the resulting lists of tools are ordered.
Expand Down
Loading

0 comments on commit 6cf9b9e

Please sign in to comment.