Skip to content

Commit

Permalink
Change Composition, Recipe Search, Other Fixes, Update Buildscript
Browse files Browse the repository at this point in the history
Ton of stuff I did over the weekend... Don't even remember it all, but it works and its better now.
  • Loading branch information
IntegerLimit committed Feb 12, 2024
1 parent ec74c57 commit fd0e79d
Show file tree
Hide file tree
Showing 39 changed files with 2,115 additions and 299 deletions.
24 changes: 22 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 1705076830
//version: 1707604215
/*
* DO NOT CHANGE THIS FILE!
* Also, you may replace this file at any time if there is an update available.
Expand Down Expand Up @@ -446,6 +446,10 @@ repositories {
name 'GTNH Maven'
url 'https://nexus.gtnewhorizons.com/repository/public/'
}
maven {
name 'GTCEu Maven'
url 'https://maven.gtceu.com'
}
}
if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) {
// need to add this here even if we did not above
Expand Down Expand Up @@ -473,6 +477,22 @@ configurations {
config.extendsFrom(shadowCompile)
}
}

create("runtimeOnlyNonPublishable") {
description = "Runtime only dependencies that are not published alongside the jar"
canBeConsumed = false
canBeResolved = false
}
create("devOnlyNonPublishable") {
description = "Runtime and compiletime dependencies that are not published alongside the jar (compileOnly + runtimeOnlyNonPublishable)"
canBeConsumed = false
canBeResolved = false
}

compileOnly.extendsFrom(devOnlyNonPublishable)
runtimeOnlyNonPublishable.extendsFrom(devOnlyNonPublishable)
runtimeClasspath.extendsFrom(runtimeOnlyNonPublishable)
testRuntimeClasspath.extendsFrom(runtimeOnlyNonPublishable)
}

String mixinProviderSpec = 'zone.rong:mixinbooter:8.9'
Expand All @@ -493,7 +513,7 @@ dependencies {
transitive = false
}
} else if (forceEnableMixins.toBoolean()) {
runtimeOnly(mixinProviderSpec)
runtimeOnlyNonPublishable(mixinProviderSpec)
}

if (enableJUnit.toBoolean()) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ enable_rocketry = false

# Whether to enable Ender Storage in runtime. Enables remappers to remap items in ender storage.
# If this is set to false, the remappers will not apply there.
enable_ender_storage = false
enable_ender_storage = true

# Whether to enable Thermal Expansion and its deps in runtime. These are used for the excitation coil textures.
# If this is set to false, the top of the excitation coil will have a null texture.
Expand Down
31 changes: 31 additions & 0 deletions src/main/groovy-tests/recipeSearchTests.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Import Recipe Search Helpers, used for Chanced Item and Fluid Ingredients
import static com.nomiceu.nomilabs.groovy.GroovyHelpers.GTRecipeHelpers.*

// Building Test Recipes
mods.gregtech.arc_furnace.recipeBuilder().inputs(metaitem('nomilabs:dustImpureOsmiridium8020')).outputs(item('minecraft:apple') * 64, item('minecraft:apple') * 64).EUt(50).duration(30).buildAndRegister()
mods.gregtech.arc_furnace.recipeBuilder().inputs(item('minecraft:stick')).outputs(item('minecraft:apple') * 64).EUt(50).duration(30).buildAndRegister()
mods.gregtech.arc_furnace.recipeBuilder().inputs(item('minecraft:yellow_flower')).outputs(item('minecraft:apple') * 64, item('minecraft:apple') * 64, item('minecraft:apple') * 64).chancedOutput(item('minecraft:apple') * 64, 50, 1).chancedFluidOutput(fluid('fluorine') * 2000, 50, 1).EUt(50).duration(30).buildAndRegister()
mods.gregtech.arc_furnace.recipeBuilder().inputs(metaitem('nomilabs:dustOsmiridium8020')).outputs(item('minecraft:apple') * 64, item('minecraft:apple') * 64, item('minecraft:apple') * 64).chancedOutput(item('minecraft:apple') * 64, 50, 1).chancedFluidOutput(fluid('fluorine') * 2000, 50, 1).EUt(50).duration(30).buildAndRegister()
mods.gregtech.arc_furnace.recipeBuilder().inputs(metaitem('nomilabs:dustPureOsmiridium8020')).outputs(item('minecraft:apple') * 64, item('minecraft:apple') * 64).EUt(50).duration(30).buildAndRegister()

// Find/Remove By Input Extensions (Are Lists of: List<ItemStack> itemInputs, List<FluidStack> fluidInputs)
// mods.gregtech.<RECIPE_MAP>.removeByInput to remove, mods.gregtech.<RECIPE_MAP>.find to find (Returns null if no recipe found)
// Original: [long voltage, Inputs... (see above)] (Matches/Removes any recipe with that input, and that voltage or more, CHECKING AMOUNT)
// ALL FIND/REMOVE BY INPUT EXTENSIONS IGNORE THE AMOUNT!
// Three Extensions:
// [GTRecipeCategory category, Inputs... (see above)] (Matches/Removes any recipe with that input, and that category)
// [Inputs... (see above)] (Matches/Removes any recipe with that input)
// [Predicate<Recipe> predicate, Inputs... (see above)] (Matches/Removes any recipe with that input, and matching that predicate)
mods.gregtech.arc_furnace.removeByInput([item('minecraft:yellow_flower')], null)

// Find/Remove By Output
// Outputs Specification: List<ItemStack> itemOutputs, List<FluidStack> fluidOutputs, List<ChancedItemOutput> chancedItemOutputs, List<ChancedFluidOutput> chancedFluidOutputs
// Chanced Item/Fluid Outputs: chanced(item/fluid, chance, chanceBoost)
// mods.gregtech.<RECIPE_MAP>.removeByOutput to remove, mods.gregtech.<RECIPE_MAP>.findByOutput to find (Returns null if no recipes found)
// ALL FIND/REMOVE BY OUTPUT OPTIONS IGNORE THE AMOUNT!
// Four Options:
// [long voltage, Outputs... (see above)] (Matches/Removes any recipe with that output, and that voltage or more)
// [GTRecipeCategory category, Outputs... (see above)] (Matches/Removes any recipe with that output, and that category)
// [Outputs... (see above)] (Matches/Removes any recipe with that output)
// [Predicate<Recipe> predicate, Outputs... (see above)] (Matches/Removes any recipe with that output, and matching that predicate)
mods.gregtech.arc_furnace.removeByOutput(50, [item('minecraft:apple') * 64, item('minecraft:apple') * 64, item('minecraft:apple') * 64], null, [chanced(item('minecraft:apple') * 64, 50, 1)], [chanced(fluid('fluorine') * 2000, 50, 1)])
113 changes: 113 additions & 0 deletions src/main/groovy-tests/replaceCompositionTests.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// Imports Helpers (Only Needed to use Groovy Helper Calls,
// useful when you only have an ItemStack or FluidStack of a Material
import static com.nomiceu.nomilabs.groovy.GroovyHelpers.ChangeCompositionHelpers.*

// Imports Mixer Specification, needed to specify Mixer Specification if specifying how to change Mixer
import static com.nomiceu.nomilabs.groovy.CompositionBuilder.MixerSpecification

// Replace Composition (changes specified)
// Decomp recipes are either centrifuge or electrolyzer recipes, and require the material not to have the DISABLE_DECOMPOSITION flag, and either have a dust or fluid.
// You cannot enable them, if the material already has them disabled.
// Chemical Formula Changes are not recursive.
// However, changes will apply if you first change the inner materials before the outer.
// ABS Recipe requires the material to have a molten fluid, and Alloy Blast and Blast Properties, and not have the Disable ABS Recipe Flag.
// Mixer Recipe requires the material to have an existing mixer recipe, and have a Dust Property.

// You can get all material components of a material by holding an ItemStack of that material, then doing /gs hand!

// Having the target material be a Material Stack changes nothing.
// Having the component list be an item stack will grab the material, then use the stack's amount as the material amount.
// Having the component list be an fluid stack will grab the material, then use the fluid amount / 1000.
// You cannot have fractional components.
// You can have materials with only liquid forms (fluorine, mercury, etc.), as both inputs and outputs.

// Don't have recursive components! This will throw a Stack Overflow Error.

// How to specify a Material Stack
println("Material Stack of 1 Pyrite | " + materialstack('pyrite')) // Material Stack of 1 Pyrite
println("Material Stack of 6 Pyrite | " + materialstack('pyrite') * 6) // Material Stack of 6 Pyrite

println("Material Stack of 1 Pyrite | " + material('pyrite') * 1) // Material Stack of 1 Pyrite
println("Material Stack of 6 Pyrite | " + material('pyrite') * 6) // Material Stack of 6 Pyrite

// How not to specify a Material Stack
println("Material: Pyrite | " + material('pyrite')) // MATERIAL, not Material Stack! This will throw an error!

// Remove Decomposition by Material

// Call Change Composition On a FluidStack or ItemStack or MaterialStack or Material, with Groovy Helper Call
// Change Composition Selectively
changeComposition(material('osmiridium'))
// Remove Components
.removeComponents()
// Remove Decomposition (No Components, so is removed)
.changeDecompositionRecipes()
// Remove Mixer (No Components, so is removed)
.changeMixer()
// Save and Apply Change **IMPORTANT**
.change()

changeComposition(material('osmiridium'))
// Set Components, using a mixture of MaterialStacks, ItemStacks and FluidStacks
// This is 4 fluorine, not 4000, because fluids are divided by 1000
.setComponents([fluid('fluorine') * 4000, materialstack('rhodium'), materialstack('nomilabs:naquadah_oxide') * 4, materialstack('magnesium') * 3, metaitem('dustCarbon') * 2])
// Change ABS Recipe with new specified components
.changeABS()
// Change Chemical Formula (Also Saves the Change, so GS Hand shows new components instead of original)
.changeChemicalFormula()
// Save and Apply Change **IMPORTANT**
.change()

// Call Change Composition on a Material Object
material('ruthenium_trinium_americium_neutronate')
// Start the builder
.changeComposition()
// Set Components, using a mixture of MaterialStacks, ItemStacks and FluidStacks
.setComponents([materialstack('pyrite') * 4, materialstack('rhodium') * 2, materialstack('nomilabs:naquadah_oxide'), materialstack('magnesium'), materialstack('carbon')])
// Change ABS Recipes
.changeABS()
// Change Chemical Formula (Also Saves the Change, so GS Hand shows new components instead of original)
.changeChemicalFormula()
// Change Decomp Recipes
.changeDecompositionRecipes()
// Change Mixer, using all mixer defaults (see below for description)
.changeMixer()
// Save and Apply Change **IMPORTANT**
.change()

material('rhodium_plated_palladium')
// Start the builder
.changeComposition()
// Set Components, using a mixture of MaterialStacks, ItemStacks and FluidStacks
.setComponents([materialstack('pyrite') * 4, materialstack('rhodium') * 2, materialstack('nomilabs:naquadah_oxide'), materialstack('magnesium'), materialstack('carbon')])
// Change Chemical Formula (Also Saves the Change, so GS Hand shows new components instead of original)
.changeChemicalFormula()
// Change Decomp Recipes
.changeDecompositionRecipes()
// Override All, Some or None Mixer Specifications
// If none, can provide no params
// Call new MixerSpecification() to start the builder
// Builder Params and Defaults:
// EUt: How Much EU per Tick the Mixer Recipe uses. Default to EUt in original recipe.
// Output Amount: How much the Mixer Recipe Outputs. Defaults to Amount of Components (E.g. If 5 Pyrite and 2 Iron, outputs 7)
// Circuit: The circuit of the recipe, use 0 for none. Defaults to circuit in original mixer recipe.
.changeMixer(new MixerSpecification().overrideEUt(200).overrideOutputAmount(1).overrideDuration(250).overrideCircuit(0))
// Change ABS Recipes
.changeABS()
.change()

// Example of 'Recursive' Chemical Formula Change
// Redstone has Ruby as a Component
material('ruby')
.changeComposition()
// Originally 1 Chrome, 2 Aluminium, 3 Oxygen
.setComponents([materialstack('chrome') * 2, materialstack('aluminium') * 2, materialstack('oxygen') * 6])
.changeChemicalFormula() // Must call this, so the chemical formula is reloaded, and so that changes are saved
.change()

material('redstone')
.changeComposition()
// Marks this as a 'reload', meaning that components are the original ones from GT or the addon
.reloadComponents()
.changeChemicalFormula() // Must call this, so the chemical formula is reloaded
.change()
52 changes: 0 additions & 52 deletions src/main/groovy-tests/replaceDecompositionTests.groovy

This file was deleted.

36 changes: 31 additions & 5 deletions src/main/java/com/nomiceu/nomilabs/config/LabsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public class LabsConfig {
@Config.Name("content")
public static Content content = new Content();

@Config.Comment({"GroovyScript Extensions and Script Helper Settings"})
@Config.LangKey("config.nomilabs.groovy")
@Config.Name("groovyscript settings")
public static GroovyScriptSettings groovyScriptSettings = new GroovyScriptSettings();

@Config.Comment("Mod Integration Settings")
@Config.LangKey("config.nomilabs.mod_integration")
@Config.Name("mod integration")
Expand Down Expand Up @@ -122,6 +127,32 @@ public static class GTCustomContent {
}
}

public static class GroovyScriptSettings {
@Config.Comment({"Whether to enable GroovyScript Hand Additions.",
"[default: true]"})
@Config.LangKey("config.nomilabs.groovy.hand")
public boolean enableGroovyHandAdditions = true;

@Config.Comment({"Mode to Use for GT Recipe Output Searching.",
"'LINEAR_SEARCH' browses each recipe sequentially, 'FAST_TREE' navigates a tree structure and stops at the first match, while 'TREE' explores the entire tree structure before concluding.",
"Because of the extra generated tree, if no removals occur, TREE and FAST_TREE have a slightly longer launch time. They also have slightly higher memory usage (around 20-50MB in limited testing)",
"If a small amount of removals occur, game launching is around the same for all three, but TREE or FAST_TREE has the lowest script reload time.",
"With a moderate-high amount of removals, game launching and script reloading is much faster with FAST_TREE or TREE, and FAST_TREE does consistently out perform TREE in time.",
"TREE is a safer option if all recipes need to be grabbed, but FAST_TREE has not failed to grab any recipes in the limited testing.",
"If some recipes are left over, try using TREE mode.",
"Recipe Output Searching is used when replacing ABS recipes and Mixer Recipes in Composition Replacements, and in Recipe Output Searching or Removing.",
"[default: FAST_TREE]"})
@Config.LangKey("config.nomilabs.groovy.recipe_search_mode")
@Config.RequiresMcRestart
public GTRecipeSearchMode gtRecipeSearchMode = GTRecipeSearchMode.FAST_TREE;

public enum GTRecipeSearchMode {
LINEAR_SEARCH,
FAST_TREE,
TREE
}
}

public static class ModIntegration {
@Config.Comment({"Whether to enable NuclearCraft Integration, which fixes its crash with GTCEu.",
"[default: true]"})
Expand Down Expand Up @@ -165,11 +196,6 @@ public static class ModIntegration {
@Config.RequiresMcRestart
public boolean enableAdvancedRocketryIntegration = true;

@Config.Comment({"Whether to enable GroovyScript Hand Additions.",
"[default: true]"})
@Config.LangKey("config.nomilabs.mod_integration.groovy_hand")
public boolean enableGroovyHandAdditions = true;

public static class DraconicEvolutionIntegration {
@Config.Comment({"Whether to enable Draconic Evolution Integration, which adds many features, such as:",
"Allowing GregTech Draconium and Awakened Draconium in the reactor and energy core.",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.nomiceu.nomilabs.gregtech.mixinhelper;

import com.google.common.collect.ImmutableList;
import gregtech.api.recipes.Recipe;
import gregtech.api.unification.stack.MaterialStack;

import java.util.List;
import java.util.Map;

public interface AccessibleMaterial {
void setComponents(ImmutableList<MaterialStack> components, boolean changeFormula);

void setComponents(ImmutableList<MaterialStack> components);

void recalculateDecompositionType();

void setOriginalRecipes(CompositionRecipeType type, List<Recipe> originals);

Map<CompositionRecipeType, List<Recipe>> getOriginalRecipes();

ImmutableList<MaterialStack> getOriginalComponents();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.nomiceu.nomilabs.gregtech.mixinhelper;

import gregtech.api.unification.material.info.MaterialFlag;

public interface AccessibleMaterialFlags {
void removeFlags(MaterialFlag... toRemove);
}
Loading

0 comments on commit fd0e79d

Please sign in to comment.