Skip to content

Commit

Permalink
Allow Exclusion of Chanced Output Specification
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Jul 23, 2024
1 parent 7330b13 commit a4dd7db
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 9 deletions.
47 changes: 38 additions & 9 deletions src/main/groovy-tests/recipeMapTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,39 @@ import static gregtech.api.GTValues.*
// Find and Removing GT Recipe Helpers. Goes in Post Init.

// Building Test Recipes
mods.gregtech.sifter.recipeBuilder().inputs(metaitem('nomilabs:dustImpureOsmiridium8020')).outputs(item('minecraft:apple') * 64, item('minecraft:apple') * 64).EUt(50).duration(30).buildAndRegister()
mods.gregtech.sifter.recipeBuilder().inputs(item('minecraft:stick')).outputs(item('minecraft:apple') * 64).EUt(50).duration(30).buildAndRegister()
mods.gregtech.sifter.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.sifter.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.sifter.recipeBuilder().inputs(metaitem('nomilabs:dustPureOsmiridium8020')).outputs(item('minecraft:apple') * 64, item('minecraft:apple') * 64).EUt(50).duration(30).buildAndRegister()
mods.gregtech.sifter.recipeBuilder()
.inputs(metaitem('nomilabs:dustImpureOsmiridium8020'))
.outputs(item('minecraft:apple') * 64, item('minecraft:apple') * 64)
.EUt(VA[LV]).duration(30)
.buildAndRegister()

mods.gregtech.sifter.recipeBuilder()
.inputs(item('minecraft:stick'))
.outputs(item('minecraft:apple') * 64)
.EUt(VA[LV]).duration(30)
.buildAndRegister()

mods.gregtech.sifter.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(VA[LV]).duration(30)
.buildAndRegister()

mods.gregtech.sifter.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(VA[LV]).duration(30)
.buildAndRegister()

mods.gregtech.sifter.recipeBuilder()
.inputs(metaitem('nomilabs:dustPureOsmiridium8020'))
.outputs(item('minecraft:apple') * 64, item('minecraft:apple') * 64)
.EUt(VA[LV]).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)
Expand All @@ -31,6 +59,7 @@ mods.gregtech.sifter.removeByInput([item('minecraft:yellow_flower')], null)

// Find/Remove By Output
// Outputs Specification: List<ItemStack> itemOutputs, List<FluidStack> fluidOutputs, List<ChancedItemOutput> chancedItemOutputs, List<ChancedFluidOutput> chancedFluidOutputs
// (You can also exclude the Chanced Items and Fluids, e.g. List<ItemStack> itemOutputs, List<FluidStack> fluidOutputs)
// 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!
Expand Down Expand Up @@ -70,8 +99,8 @@ mods.gregtech.primitive_blast_furnace.changeAllRecipes()
.replaceAndRegister()
}

// Example 2: Making All Electronic Circuit Recipes Output Double and require an Apple, whilst Changing Recycling
mods.gregtech.circuit_assembler.changeByOutput([metaitem('circuit.electronic') * 2], null, null, null)
// Example 2: Making All Electronic Circuit Recipes Output Double and require an Apple, whilst Changing (Adding) Recycling
mods.gregtech.circuit_assembler.changeByOutput([metaitem('circuit.electronic') * 2], null) // Excluding Chanced Output Specification
.forEach { ChangeRecipeBuilder builder ->
builder.changeEachOutput { stack ->
stack.count *= 2
Expand All @@ -91,15 +120,15 @@ mods.gregtech.macerator.changeByInput([metaitem('plant_ball') * 2], null)
.replaceAndRegister()

// Example 4: Changing the Circuit Meta of a Recipe
mods.gregtech.assembler.changeByOutput([item('minecraft:iron_bars') * 4], null, null, null)
mods.gregtech.assembler.changeByOutput([item('minecraft:iron_bars') * 4], null)
.forEach { ChangeRecipeBuilder builder ->
builder.changeCircuitMeta { meta -> meta * 2 }
.replaceAndRegister()
}

// Example 5: Adding Alternative Chemical Reactor Recipes
// Alternative = `buildAndRegister` not `replaceAndRegister`
mods.gregtech.chemical_reactor.changeByOutput(null, [fluid('polytetrafluoroethylene')], null, null) // Change By Output ignores Amount
mods.gregtech.chemical_reactor.changeByOutput(null, [fluid('polytetrafluoroethylene')]) // Change By Output ignores Amount
.forEach { ChangeRecipeBuilder builder ->
builder.changeCircuitMeta { meta -> meta + 10 }
.builder { RecipeBuilder recipe ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,32 @@ private boolean removeByInput(Predicate<Recipe> condition, List<ItemStack> items
return true;
}

@Unique
@Nullable
public List<Recipe> findByOutput(long voltage, List<ItemStack> items, List<FluidStack> fluids) {
return findByOutput(voltage, items, fluids, null, null);
}

@Unique
@Nullable
public List<Recipe> findByOutput(List<ItemStack> items, List<FluidStack> fluids) {
return findByOutput(items, fluids, null, null);
}

@Unique
@Nullable
public List<Recipe> findByOutput(GTRecipeCategory category, List<ItemStack> items,
List<FluidStack> fluids) {
return findByOutput(category, items, fluids, null, null);
}

@Unique
@Nullable
@SuppressWarnings("DuplicatedCode")
public List<Recipe> findByOutput(Predicate<Recipe> condition, List<ItemStack> items, List<FluidStack> fluids) {
return findByOutput(condition, items, fluids, null, null);
}

@Unique
@Nullable
@SuppressWarnings("DuplicatedCode")
Expand Down Expand Up @@ -156,6 +182,26 @@ public List<Recipe> findByOutput(Predicate<Recipe> condition, List<ItemStack> it
condition);
}

@Unique
public boolean removeByOutput(long voltage, List<ItemStack> items, List<FluidStack> fluids) {
return removeByOutput(voltage, items, fluids, null, null);
}

@Unique
public boolean removeByOutput(List<ItemStack> items, List<FluidStack> fluids) {
return removeByOutput(items, fluids, null, null);
}

@Unique
public boolean removeByOutput(GTRecipeCategory category, List<ItemStack> items, List<FluidStack> fluids) {
return removeByOutput(category, items, fluids, null, null);
}

@Unique
public boolean removeByOutput(Predicate<Recipe> condition, List<ItemStack> items, List<FluidStack> fluids) {
return removeByOutput(condition, items, fluids, null, null);
}

@Unique
public boolean removeByOutput(long voltage, List<ItemStack> items, List<FluidStack> fluids,
List<ChancedItemOutput> chancedItems, List<ChancedFluidOutput> chancedFluids) {
Expand Down Expand Up @@ -272,6 +318,28 @@ private ChangeRecipeBuilder<?> changeByInput(Predicate<Recipe> condition, List<I
return new ChangeRecipeBuilder<>(recipe, recipeMap);
}

@Unique
public Stream<ChangeRecipeBuilder<?>> changeByOutput(long voltage, List<ItemStack> items, List<FluidStack> fluids) {
return changeByOutput(voltage, items, fluids, null, null);
}

@Unique
public Stream<ChangeRecipeBuilder<?>> changeByOutput(List<ItemStack> items, List<FluidStack> fluids) {
return changeByOutput(items, fluids, null, null);
}

@Unique
public Stream<ChangeRecipeBuilder<?>> changeByOutput(GTRecipeCategory category, List<ItemStack> items,
List<FluidStack> fluids) {
return changeByOutput(category, items, fluids, null, null);
}

@Unique
public Stream<ChangeRecipeBuilder<?>> changeByOutput(Predicate<Recipe> condition, List<ItemStack> items,
List<FluidStack> fluids) {
return changeByOutput(condition, items, fluids, null, null);
}

@Unique
public Stream<ChangeRecipeBuilder<?>> changeByOutput(long voltage, List<ItemStack> items, List<FluidStack> fluids,
List<ChancedItemOutput> chancedItems,
Expand Down

0 comments on commit a4dd7db

Please sign in to comment.