Skip to content

Commit

Permalink
add Industrial Foregoing compat (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
WaitingIdly authored Jun 16, 2024
1 parent 21915c9 commit f88c6dc
Show file tree
Hide file tree
Showing 19 changed files with 1,302 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final def mod_dependencies = [
'aether-255308:3280119' : [project.debug_aether],
'alchemistry-293425:3186612' : [project.debug_alchemistry],
'alchemylib-293426:2761706' : [project.debug_alchemistry],
'shadowfacts-forgelin-248453:2785465' : [project.debug_alchemistry],
'shadowfacts-forgelin-248453:2785465' : [project.debug_alchemistry, project.debug_industrial_foregoing],
'ae2-extended-life-570458:4553942' : [project.debug_applied_energistics_2],
'arcane-archives-311357:3057332' : [project.debug_arcane_archives],
'guidebook-253874:2989594' : [project.debug_arcane_archives],
Expand Down Expand Up @@ -63,6 +63,8 @@ final def mod_dependencies = [
// WARNING: experimental must be placed before classic, otherwise you will crash when debugging either. Check FluidGenerator compat to confirm
'industrialcraft_experimental-242638:3838713' : [project.debug_industrial_craft_2_experimental],
'industrialcraft_classic-242942:3093607' : [project.debug_industrial_craft_2_classic],
'tesla-core-lib-254602:3438487' : [project.debug_industrial_foregoing],
'industrialforegoing-266515:2745321' : [project.debug_industrial_foregoing],
'inspirations-284007:2843007' : [project.debug_inspirations],
'mantle-74924:2713386' : [project.debug_inspirations, project.debug_tinkers],
'common-capabilities-247007:3053017' : [project.debug_integrated_dynamics],
Expand Down
118 changes: 118 additions & 0 deletions examples/postInit/industrialforegoing.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@

// Auto generated groovyscript example file
// MODS_LOADED: industrialforegoing

import net.minecraft.potion.PotionEffect

println 'mod \'industrialforegoing\' detected, running script'

// Bioreactor:
// Converts an input item into Biofuel, with the amount of Biofuel generated being based on the number of concurrent
// conversion processes inside the Bioreactor.

mods.industrialforegoing.bio_reactor.removeByInput(item('minecraft:wheat_seeds'))
// mods.industrialforegoing.bio_reactor.removeAll()

mods.industrialforegoing.bio_reactor.add(item('minecraft:clay'))

// Latex Extractor:
// Converts an input block in-world into a fluidstack over time, eventually breaking the block.

mods.industrialforegoing.extractor.removeByInput(item('minecraft:log2:1'))
// mods.industrialforegoing.extractor.removeByOutput(fluid('latex'))
// mods.industrialforegoing.extractor.removeAll()

mods.industrialforegoing.extractor.add(item('minecraft:clay'), fluid('lava') * 50)
mods.industrialforegoing.extractor.add(item('minecraft:stone'), fluid('water') * 100, 1)

// Fluid Dictionary Converter:
// Converts one fluid into another fluid at a given ratio.

// mods.industrialforegoing.fluid_dictionary.removeByInput(fluid('essence'))
// mods.industrialforegoing.fluid_dictionary.removeByOutput(fluid(essence'))
// mods.industrialforegoing.fluid_dictionary.removeAll()

mods.industrialforegoing.fluid_dictionary.add(fluid('biofuel'), fluid('latex'),)
mods.industrialforegoing.fluid_dictionary.add(fluid('latex'), fluid('biofuel'),)
mods.industrialforegoing.fluid_dictionary.add(fluid('essence'), fluid('latex'), 2)
mods.industrialforegoing.fluid_dictionary.add(fluid('latex'), fluid('essence'), 0.5)

// Laser Drill:
// Converts power into ores, with a given weight, between a minimum and maximum Y value, in any whitelisted biome or not in
// any blacklisted biome, and with a specific color of laser lens impacting the probability.

mods.industrialforegoing.laser_drill.removeByBlacklist(biome('minecraft:sky'))
mods.industrialforegoing.laser_drill.removeByLens(5)
// mods.industrialforegoing.laser_drill.removeByLens(item('industrialforegoing:laser_lens:5'))
mods.industrialforegoing.laser_drill.removeByOutput(item('minecraft:coal_ore'))
mods.industrialforegoing.laser_drill.removeByWhitelist(biome('minecraft:hell'))
// mods.industrialforegoing.laser_drill.removeAll()

mods.industrialforegoing.laser_drill.recipeBuilder()
.output(item('minecraft:clay'))
.lensMeta(5)
.weight(100)
.register()


// Fermentation Station:
// Converts an input fluidstack into an output fluidstack.

mods.industrialforegoing.ore_fermenter.removeByInput(fluid('if.ore_fluid_raw').withNbt([Ore: 'oreRedstone']))
// mods.industrialforegoing.ore_fermenter.removeByOutput(fluid('if.ore_fluid_fermented').withNbt([Ore: 'oreRedstone']))
// mods.industrialforegoing.ore_fermenter.removeAll()

mods.industrialforegoing.ore_fermenter.add(fluid('if.ore_fluid_raw').withNbt(['Ore': 'oreGold']), fluid('if.ore_fluid_fermented').withNbt(['Ore': 'oreGold']) * 2)

// Washing Factory:
// Converts an input itemstack and input fluidstack into an output fluidstack.

// mods.industrialforegoing.ore_raw.removeByInput(fluid('meat'))
mods.industrialforegoing.ore_raw.removeByOre(ore('oreRedstone'))
// mods.industrialforegoing.ore_raw.removeByOre('oreRedstone')
// mods.industrialforegoing.ore_raw.removeByOutput(fluid('if.ore_fluid_raw').withNbt(['Ore': 'oreRedstone']),)
// mods.industrialforegoing.ore_raw.removeAll()

mods.industrialforegoing.ore_raw.add(ore('stone'), fluid('water') * 1000, fluid('lava') * 50)
mods.industrialforegoing.ore_raw.add(ore('oreGold'), fluid('meat') * 200, fluid('if.ore_fluid_raw').withNbt(['Ore': 'oreGold']) * 300)

// Fluid Sieving Machine:
// Converts an input itemstack and input fluidstack into an output itemstack.

mods.industrialforegoing.ore_sieve.removeByInput(fluid('if.pink_slime'))
mods.industrialforegoing.ore_sieve.removeByInput(item('minecraft:sand'))
// mods.industrialforegoing.ore_sieve.removeByOutput(item('industrialforegoing:pink_slime_ingot)
// mods.industrialforegoing.ore_sieve.removeAll()

mods.industrialforegoing.ore_sieve.add(fluid('lava') * 5, item('minecraft:gold_ingot'), item('minecraft:clay'))
mods.industrialforegoing.ore_sieve.add(fluid('if.ore_fluid_fermented').withNbt(['Ore': 'oreGold']) * 100, item('minecraft:nether_star') * 2, item('minecraft:clay'))

// Protein Reactor:
// Converts an input item into Protein, with the amount of Protein generated being based on the number of concurrent
// conversion processes inside the Protein Reactor.

mods.industrialforegoing.protein_reactor.removeByInput(item('minecraft:porkchop'))
// mods.industrialforegoing.protein_reactor.removeAll()

mods.industrialforegoing.protein_reactor.add(item('minecraft:clay'))

// Sludge Refiner:
// Converts 1000mb of Sludge into a random itemstack based on the weight of the given itemstack.

mods.industrialforegoing.sludge_refiner.removeByOutput(item('minecraft:clay_ball'))
// mods.industrialforegoing.sludge_refiner.removeAll()

mods.industrialforegoing.sludge_refiner.add(item('minecraft:gold_ingot'), 5)

// Straw:
// Converts an fluid block in-world into various effects for the player when consumed via a straw.

// mods.industrialforegoing.straw.removeAll()

mods.industrialforegoing.straw.recipeBuilder()
.fluidInput(fluid('if.pink_slime'))
.effect(new PotionEffect(potion('minecraft:strength'), 1800, 3))
.register()



1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ debug_forestry = false
debug_immersive_engineering = false
debug_industrial_craft_2_classic = false
debug_industrial_craft_2_experimental = false
debug_industrial_foregoing = false
debug_inspirations = false
debug_integrated_dynamics = false
debug_mekanism = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.cleanroommc.groovyscript.compat.mods.forestry.Forestry;
import com.cleanroommc.groovyscript.compat.mods.ic2.IC2;
import com.cleanroommc.groovyscript.compat.mods.immersiveengineering.ImmersiveEngineering;
import com.cleanroommc.groovyscript.compat.mods.industrialforegoing.IndustrialForegoing;
import com.cleanroommc.groovyscript.compat.mods.inspirations.Inspirations;
import com.cleanroommc.groovyscript.compat.mods.integrateddynamics.IntegratedDynamics;
import com.cleanroommc.groovyscript.compat.mods.jei.JustEnoughItems;
Expand Down Expand Up @@ -82,6 +83,7 @@ public class ModSupport {
public static final GroovyContainer<Forestry> FORESTRY = new InternalModContainer<>("forestry", "Forestry", Forestry::new);
public static final GroovyContainer<ImmersiveEngineering> IMMERSIVE_ENGINEERING = new InternalModContainer<>("immersiveengineering", "Immersive Engineering", ImmersiveEngineering::new, "ie");
public static final GroovyContainer<IC2> INDUSTRIALCRAFT = new InternalModContainer<>("ic2", "Industrial Craft 2", IC2::new, "industrialcraft");
public static final GroovyContainer<IndustrialForegoing> INDUSTRIAL_FOREGOING = new InternalModContainer<>("industrialforegoing", "Industrial Foregoing", IndustrialForegoing::new);
public static final GroovyContainer<Inspirations> INSPIRATIONS = new InternalModContainer<>("inspirations", "Inspirations", Inspirations::new);
public static final GroovyContainer<IntegratedDynamics> INTEGRATED_DYNAMICS = new InternalModContainer<>("integrateddynamics", "Integrated Dynamics", IntegratedDynamics::new, "id");
public static final GroovyContainer<JustEnoughItems> JEI = new InternalModContainer<>("jei", "Just Enough Items", JustEnoughItems::new, "hei");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.cleanroommc.groovyscript.compat.mods.industrialforegoing;

import com.buuz135.industrial.api.recipe.BioReactorEntry;
import com.buuz135.industrial.api.recipe.IReactorEntry;
import com.cleanroommc.groovyscript.api.GroovyBlacklist;
import com.cleanroommc.groovyscript.api.IIngredient;
import com.cleanroommc.groovyscript.api.documentation.annotations.Example;
import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription;
import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription;
import com.cleanroommc.groovyscript.helper.SimpleObjectStream;
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry;
import com.google.common.base.Predicate;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import org.jetbrains.annotations.Nullable;

@RegistryDescription
public class BioReactor extends VirtualizedRegistry<IReactorEntry> {

@Override
@GroovyBlacklist
public void onReload() {
BioReactorEntry.BIO_REACTOR_ENTRIES.removeAll(removeScripted());
BioReactorEntry.BIO_REACTOR_ENTRIES.addAll(restoreFromBackup());
}

@MethodDescription(description = "groovyscript.wiki.industrialforegoing.bio_reactor.add0", type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:clay')"))
public IReactorEntry add(ItemStack input) {
return add(input, null);
}

@MethodDescription(description = "groovyscript.wiki.industrialforegoing.bio_reactor.add1", type = MethodDescription.Type.ADDITION)
public IReactorEntry add(ItemStack input, @Nullable Predicate<NBTTagCompound> nbtCheck) {
IReactorEntry recipe = new BioReactorEntry(input, nbtCheck);
add(recipe);
return recipe;
}

public void add(IReactorEntry recipe) {
if (recipe == null) return;
addScripted(recipe);
BioReactorEntry.BIO_REACTOR_ENTRIES.add(recipe);
}

public boolean remove(IReactorEntry recipe) {
if (recipe == null) return false;
addBackup(recipe);
BioReactorEntry.BIO_REACTOR_ENTRIES.remove(recipe);
return true;
}

@MethodDescription(example = @Example("item('minecraft:wheat_seeds')"))
public boolean removeByInput(IIngredient input) {
return BioReactorEntry.BIO_REACTOR_ENTRIES.removeIf(recipe -> {
if (input.test(recipe.getStack())) {
addBackup(recipe);
return true;
}
return false;
});
}

@MethodDescription(priority = 2000, example = @Example(commented = true))
public void removeAll() {
BioReactorEntry.BIO_REACTOR_ENTRIES.forEach(this::addBackup);
BioReactorEntry.BIO_REACTOR_ENTRIES.clear();
}

@MethodDescription(type = MethodDescription.Type.QUERY)
public SimpleObjectStream<IReactorEntry> streamRecipes() {
return new SimpleObjectStream<>(BioReactorEntry.BIO_REACTOR_ENTRIES)
.setRemover(this::remove);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package com.cleanroommc.groovyscript.compat.mods.industrialforegoing;

import com.buuz135.industrial.api.extractor.ExtractorEntry;
import com.cleanroommc.groovyscript.api.GroovyBlacklist;
import com.cleanroommc.groovyscript.api.IIngredient;
import com.cleanroommc.groovyscript.api.documentation.annotations.Example;
import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription;
import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription;
import com.cleanroommc.groovyscript.helper.Alias;
import com.cleanroommc.groovyscript.helper.SimpleObjectStream;
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;

@RegistryDescription
public class Extractor extends VirtualizedRegistry<ExtractorEntry> {

public Extractor() {
super(Alias.generateOfClass(Extractor.class).andGenerate("TreeFluidExtractor"));
}

@Override
@GroovyBlacklist
public void onReload() {
ExtractorEntry.EXTRACTOR_ENTRIES.removeAll(removeScripted());
ExtractorEntry.EXTRACTOR_ENTRIES.addAll(restoreFromBackup());
}

@MethodDescription(description = "groovyscript.wiki.industrialforegoing.extractor.add0", type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:clay'), fluid('lava') * 50"))
public ExtractorEntry add(ItemStack input, FluidStack output) {
return add(input, output, 0.005F);
}

@MethodDescription(description = "groovyscript.wiki.industrialforegoing.extractor.add1", type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:stone'), fluid('water') * 100, 1"))
public ExtractorEntry add(ItemStack input, FluidStack output, float breakChance) {
ExtractorEntry recipe = new ExtractorEntry(input, output, breakChance);
add(recipe);
return recipe;
}

public void add(ExtractorEntry recipe) {
if (recipe == null) return;
addScripted(recipe);
ExtractorEntry.EXTRACTOR_ENTRIES.add(recipe);
}

public boolean remove(ExtractorEntry recipe) {
if (recipe == null) return false;
addBackup(recipe);
ExtractorEntry.EXTRACTOR_ENTRIES.remove(recipe);
return true;
}

@MethodDescription(example = @Example("item('minecraft:log2:1')"))
public boolean removeByInput(IIngredient input) {
return ExtractorEntry.EXTRACTOR_ENTRIES.removeIf(recipe -> {
if (input.test(recipe.getItemStack())) {
addBackup(recipe);
return true;
}
return false;
});
}

@MethodDescription(example = @Example(value = "fluid('latex')", commented = true))
public boolean removeByOutput(IIngredient output) {
return ExtractorEntry.EXTRACTOR_ENTRIES.removeIf(recipe -> {
if (output.test(recipe.getFluidStack())) {
addBackup(recipe);
return true;
}
return false;
});
}

@MethodDescription(priority = 2000, example = @Example(commented = true))
public void removeAll() {
ExtractorEntry.EXTRACTOR_ENTRIES.forEach(this::addBackup);
ExtractorEntry.EXTRACTOR_ENTRIES.clear();
}

@MethodDescription(type = MethodDescription.Type.QUERY)
public SimpleObjectStream<ExtractorEntry> streamRecipes() {
return new SimpleObjectStream<>(ExtractorEntry.EXTRACTOR_ENTRIES)
.setRemover(this::remove);
}

}
Loading

0 comments on commit f88c6dc

Please sign in to comment.