Skip to content

Commit

Permalink
add Primal Tech compat (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
WaitingIdly authored Jul 23, 2024
1 parent 109b425 commit bc0e1c5
Show file tree
Hide file tree
Showing 16 changed files with 744 additions and 0 deletions.
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ final def mod_dependencies = [
'mystical_agriculture-246640:2704562' : [project.debug_mystical_agriculture],
'natures-aura-306626:2882138' : [project.debug_natures_aura],
'packmode-278398:2567799' : [project.debug_packmode],
'primal-tech-290612:2801696' : [project.debug_primal_tech],
'pneumaticcraft-repressurized-281849:2978408' : [project.debug_pneumaticcraft],
'projecte-226410:2702991' : [project.debug_projecte],
'athenaeum-284350:4633750' : [project.debug_pyrotech],
Expand Down
91 changes: 91 additions & 0 deletions examples/postInit/primal_tech.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@

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

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

// Clay Kiln:
// Converts an input item into an output itemstack after a given amount of time. Requires the block below to be Minecraft
// Fire or a Primal Tech Flame Grilled Wopper. Takes some time to heat up before beginning to smelt items.

mods.primal_tech.clay_kiln.removeByInput(item('minecraft:gravel'))
mods.primal_tech.clay_kiln.removeByOutput(item('primal_tech:charcoal_block'))
// mods.primal_tech.clay_kiln.removeAll()

mods.primal_tech.clay_kiln.recipeBuilder()
.input(item('minecraft:diamond'))
.output(item('minecraft:clay'))
.cookTime(50)
.register()

mods.primal_tech.clay_kiln.recipeBuilder()
.input(item('minecraft:gold_ingot'))
.output(item('minecraft:diamond') * 4)
.cookTime(100)
.register()



// Stone Anvil:
// Converts an input item into an output itemstack after being interacted with by a player using a Stone Mallet.

// mods.primal_tech.stone_anvil.removeByInput(item('primal_tech:flint_block'))
mods.primal_tech.stone_anvil.removeByOutput(item('minecraft:flint'))
// mods.primal_tech.stone_anvil.removeAll()

mods.primal_tech.stone_anvil.recipeBuilder()
.input(item('minecraft:diamond'))
.output(item('minecraft:clay'))
.register()

mods.primal_tech.stone_anvil.recipeBuilder()
.input(item('minecraft:gold_ingot'))
.output(item('minecraft:diamond') * 4)
.register()



// Water Saw:
// Converts an input item into an output itemstack after a given amount of time. Requires the block below it to be a water
// source block, and the block below and behind it flowing water.

mods.primal_tech.water_saw.removeByInput(item('minecraft:log'))
mods.primal_tech.water_saw.removeByOutput(item('minecraft:planks:1'))
// mods.primal_tech.water_saw.removeAll()

mods.primal_tech.water_saw.recipeBuilder()
.input(item('minecraft:diamond'))
.output(item('minecraft:clay'))
.choppingTime(50)
.register()

mods.primal_tech.water_saw.recipeBuilder()
.input(item('minecraft:gold_ingot'))
.output(item('minecraft:diamond') * 4)
.choppingTime(100)
.register()



// Wooden Basin:
// Converts up to 4 items and 1000mb of fluid into an output itemstack.

mods.primal_tech.wooden_basin.removeByInput(fluid('lava'))
// mods.primal_tech.wooden_basin.removeByInput(item('minecraft:cobblestone'))
// mods.primal_tech.wooden_basin.removeByOutput(item('minecraft:obsidian'))
// mods.primal_tech.wooden_basin.removeAll()

mods.primal_tech.wooden_basin.recipeBuilder()
.input(item('minecraft:diamond'))
.fluidInput(fluid('lava'))
.output(item('minecraft:clay'))
.register()

mods.primal_tech.wooden_basin.recipeBuilder()
.input(item('minecraft:gold_ingot'), item('minecraft:clay'), item('minecraft:gold_ingot'), item('minecraft:clay'))
.fluidInput(fluid('water'))
.output(item('minecraft:diamond') * 4)
.register()



1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ debug_mystical_agriculture = false
debug_natures_aura = false
debug_packmode = false
debug_pneumaticcraft = false
debug_primal_tech = false
debug_prodigytech = false
debug_projecte = false
debug_pyrotech = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.cleanroommc.groovyscript.compat.mods.mysticalagriculture.MysticalAgriculture;
import com.cleanroommc.groovyscript.compat.mods.naturesaura.NaturesAura;
import com.cleanroommc.groovyscript.compat.mods.pneumaticcraft.PneumaticCraft;
import com.cleanroommc.groovyscript.compat.mods.primaltech.PrimalTech;
import com.cleanroommc.groovyscript.compat.mods.prodigytech.ProdigyTech;
import com.cleanroommc.groovyscript.compat.mods.projecte.ProjectE;
import com.cleanroommc.groovyscript.compat.mods.pyrotech.PyroTech;
Expand Down Expand Up @@ -106,6 +107,7 @@ public class ModSupport {
public static final GroovyContainer<LazyAE2> LAZYAE2 = new InternalModContainer<>("threng", "LazyAE2", LazyAE2::new, "lazyae2");
public static final GroovyContainer<NaturesAura> NATURES_AURA = new InternalModContainer<>("naturesaura", "Nature's Aura", NaturesAura::new);
public static final GroovyContainer<PneumaticCraft> PNEUMATIC_CRAFT = new InternalModContainer<>("pneumaticcraft", "PneumaticCraft: Repressurized", PneumaticCraft::new);
public static final GroovyContainer<PrimalTech> PRIMAL_TECH = new InternalModContainer<>("primal_tech", "Primal Tech", PrimalTech::new, "primaltech");
public static final GroovyContainer<ProdigyTech> PRODIGY_TECH = new InternalModContainer<>("prodigytech", "Prodigy Tech", ProdigyTech::new);
public static final GroovyContainer<ProjectE> PROJECT_E = new InternalModContainer<>("projecte", "ProjectE", ProjectE::new);
public static final GroovyContainer<PyroTech> PYROTECH = new InternalModContainer<>("pyrotech", "Pyrotech", PyroTech::new);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package com.cleanroommc.groovyscript.compat.mods.primaltech;

import com.cleanroommc.groovyscript.api.GroovyLog;
import com.cleanroommc.groovyscript.api.IIngredient;
import com.cleanroommc.groovyscript.api.documentation.annotations.*;
import com.cleanroommc.groovyscript.compat.mods.ModSupport;
import com.cleanroommc.groovyscript.core.mixin.primal_tech.ClayKilnRecipesAccessor;
import com.cleanroommc.groovyscript.helper.SimpleObjectStream;
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder;
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry;
import net.minecraft.item.ItemStack;
import org.jetbrains.annotations.Nullable;
import primal_tech.recipes.ClayKilnRecipes;

@RegistryDescription
public class ClayKiln extends VirtualizedRegistry<ClayKilnRecipes> {

@RecipeBuilderDescription(example = {
@Example(".input(item('minecraft:diamond')).output(item('minecraft:clay')).cookTime(50)"),
@Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond') * 4).cookTime(100)")
})
public static RecipeBuilder recipeBuilder() {
return new RecipeBuilder();
}

@Override
public void onReload() {
ClayKilnRecipesAccessor.getRecipes().removeAll(removeScripted());
ClayKilnRecipesAccessor.getRecipes().addAll(restoreFromBackup());
}

public void add(ClayKilnRecipes recipe) {
if (recipe != null) {
addScripted(recipe);
ClayKilnRecipesAccessor.getRecipes().add(recipe);
}
}

@MethodDescription(type = MethodDescription.Type.ADDITION)
public ClayKilnRecipes add(ItemStack output, IIngredient input, int cookTime) {
return recipeBuilder()
.cookTime(cookTime)
.input(input)
.output(output)
.register();
}

public boolean remove(ClayKilnRecipes recipe) {
if (ClayKilnRecipesAccessor.getRecipes().removeIf(r -> r == recipe)) {
addBackup(recipe);
return true;
}
return false;
}

@MethodDescription(example = @Example("item('minecraft:gravel')"))
public boolean removeByInput(IIngredient input) {
return ClayKilnRecipesAccessor.getRecipes().removeIf(recipe -> {
if (input.test(recipe.getInput())) {
addBackup(recipe);
return true;
}
return false;
});
}

@MethodDescription(example = @Example("item('primal_tech:charcoal_block')"))
public boolean removeByOutput(IIngredient output) {
return ClayKilnRecipesAccessor.getRecipes().removeIf(recipe -> {
if (output.test(recipe.getOutput())) {
addBackup(recipe);
return true;
}
return false;
});
}

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

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

@Property(property = "input", valid = @Comp("1"))
@Property(property = "output", valid = @Comp("1"))
public static class RecipeBuilder extends AbstractRecipeBuilder<ClayKilnRecipes> {

@Property(valid = @Comp(value = "0", type = Comp.Type.GTE))
private int cookTime;

@RecipeBuilderMethodDescription
public RecipeBuilder cookTime(int cookTime) {
this.cookTime = cookTime;
return this;
}

@Override
public String getErrorMsg() {
return "Error adding Primal Tech Clay Kiln recipe";
}

@Override
public void validate(GroovyLog.Msg msg) {
validateItems(msg, 1, 1, 1, 1);
validateFluids(msg);
msg.add(cookTime < 0, "cookTime must be greater than or equal to 0, yet it was {}", cookTime);
}

@Override
@RecipeBuilderRegistrationMethod
public @Nullable ClayKilnRecipes register() {
if (!validate()) return null;
ClayKilnRecipes recipe = null;
for (ItemStack matchingStack : input.get(0).getMatchingStacks()) {
recipe = ClayKilnRecipesAccessor.createClayKilnRecipes(output.get(0), matchingStack, cookTime);
ModSupport.PRIMAL_TECH.get().clayKiln.add(recipe);
}
return recipe;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.cleanroommc.groovyscript.compat.mods.primaltech;

import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer;

public class PrimalTech extends GroovyPropertyContainer {

public final ClayKiln clayKiln = new ClayKiln();
public final StoneAnvil stoneAnvil = new StoneAnvil();
public final WaterSaw waterSaw = new WaterSaw();
public final WoodenBasin woodenBasin = new WoodenBasin();

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

import com.cleanroommc.groovyscript.api.GroovyLog;
import com.cleanroommc.groovyscript.api.IIngredient;
import com.cleanroommc.groovyscript.api.documentation.annotations.*;
import com.cleanroommc.groovyscript.compat.mods.ModSupport;
import com.cleanroommc.groovyscript.core.mixin.primal_tech.StoneAnvilRecipesAccessor;
import com.cleanroommc.groovyscript.helper.SimpleObjectStream;
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder;
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry;
import net.minecraft.item.ItemStack;
import org.jetbrains.annotations.Nullable;
import primal_tech.recipes.StoneAnvilRecipes;

@RegistryDescription
public class StoneAnvil extends VirtualizedRegistry<StoneAnvilRecipes> {

@RecipeBuilderDescription(example = {
@Example(".input(item('minecraft:diamond')).output(item('minecraft:clay'))"),
@Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond') * 4)")
})
public static RecipeBuilder recipeBuilder() {
return new RecipeBuilder();
}

@Override
public void onReload() {
StoneAnvilRecipesAccessor.getRecipes().removeAll(removeScripted());
StoneAnvilRecipesAccessor.getRecipes().addAll(restoreFromBackup());
}

public void add(StoneAnvilRecipes recipe) {
if (recipe != null) {
addScripted(recipe);
StoneAnvilRecipesAccessor.getRecipes().add(recipe);
}
}

@MethodDescription(type = MethodDescription.Type.ADDITION)
public StoneAnvilRecipes add(ItemStack output, IIngredient input) {
return recipeBuilder()
.input(input)
.output(output)
.register();
}

public boolean remove(StoneAnvilRecipes recipe) {
if (StoneAnvilRecipesAccessor.getRecipes().removeIf(r -> r == recipe)) {
addBackup(recipe);
return true;
}
return false;
}

@MethodDescription(example = @Example(value = "item('primal_tech:flint_block')", commented = true))
public boolean removeByInput(IIngredient input) {
return StoneAnvilRecipesAccessor.getRecipes().removeIf(recipe -> {
if (input.test(recipe.getInput())) {
addBackup(recipe);
return true;
}
return false;
});
}

@MethodDescription(example = @Example("item('minecraft:flint')"))
public boolean removeByOutput(IIngredient output) {
return StoneAnvilRecipesAccessor.getRecipes().removeIf(recipe -> {
if (output.test(recipe.getOutput())) {
addBackup(recipe);
return true;
}
return false;
});
}

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

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

@Property(property = "input", valid = @Comp("1"))
@Property(property = "output", valid = @Comp("1"))
public static class RecipeBuilder extends AbstractRecipeBuilder<StoneAnvilRecipes> {

@Override
public String getErrorMsg() {
return "Error adding Primal Tech Stone Anvil recipe";
}

@Override
public void validate(GroovyLog.Msg msg) {
validateItems(msg, 1, 1, 1, 1);
validateFluids(msg);
}

@Override
@RecipeBuilderRegistrationMethod
public @Nullable StoneAnvilRecipes register() {
if (!validate()) return null;
StoneAnvilRecipes recipe = null;
for (ItemStack matchingStack : input.get(0).getMatchingStacks()) {
recipe = StoneAnvilRecipesAccessor.createStoneAnvilRecipes(output.get(0), matchingStack);
ModSupport.PRIMAL_TECH.get().stoneAnvil.add(recipe);
}
return recipe;
}
}
}
Loading

0 comments on commit bc0e1c5

Please sign in to comment.