generated from CleanroomMC/TemplateDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* alchemistry compat * remove a critical skill issue * did a bad and forgot a description * add some basic add methods
- Loading branch information
1 parent
3385225
commit 4f1ec82
Showing
12 changed files
with
1,057 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
|
||
// Auto generated groovyscript example file | ||
// MODS_LOADED: alchemistry | ||
|
||
println 'mod \'alchemistry\' detected, running script' | ||
|
||
// groovyscript.wiki.alchemistry.atomizer.title: | ||
// groovyscript.wiki.alchemistry.atomizer.description | ||
|
||
mods.alchemistry.atomizer.removeByInput(fluid('water')) | ||
// mods.alchemistry.atomizer.removeByOutput(item('alchemistry:compound:7')) | ||
// mods.alchemistry.atomizer.removeAll() | ||
|
||
mods.alchemistry.atomizer.recipeBuilder() | ||
.fluidInput(fluid('water') * 125) | ||
.output(item('minecraft:clay')) | ||
.register() | ||
|
||
mods.alchemistry.atomizer.recipeBuilder() | ||
.fluidInput(fluid('lava') * 500) | ||
.output(item('minecraft:gold_ingot')) | ||
.reversible() | ||
.register() | ||
|
||
|
||
// groovyscript.wiki.alchemistry.combiner.title: | ||
// groovyscript.wiki.alchemistry.combiner.description | ||
|
||
mods.alchemistry.combiner.removeByInput(element('carbon')) | ||
mods.alchemistry.combiner.removeByOutput(item('minecraft:glowstone')) | ||
// mods.alchemistry.combiner.removeAll() | ||
|
||
mods.alchemistry.combiner.recipeBuilder() | ||
.input(item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2) | ||
.output(item('minecraft:gold_block') * 2) | ||
.register() | ||
|
||
mods.alchemistry.combiner.recipeBuilder() | ||
.input(ItemStack.EMPTY, ItemStack.EMPTY, item('minecraft:clay')) | ||
.output(item('minecraft:gold_ingot')) | ||
.register() | ||
|
||
|
||
// groovyscript.wiki.alchemistry.dissolver.title: | ||
// groovyscript.wiki.alchemistry.dissolver.description | ||
|
||
mods.alchemistry.dissolver.removeByInput(item('alchemistry:compound:1')) | ||
// mods.alchemistry.dissolver.removeAll() | ||
|
||
mods.alchemistry.dissolver.recipeBuilder() | ||
.input(item('minecraft:gold_ingot')) | ||
.probabilityOutput(item('minecraft:clay')) | ||
.reversible() | ||
.rolls(1) | ||
.register() | ||
|
||
mods.alchemistry.dissolver.recipeBuilder() | ||
.input(item('minecraft:diamond')) | ||
.probabilityOutput(30, item('minecraft:clay')) | ||
.probabilityOutput(30, item('minecraft:clay')) | ||
.probabilityOutput(30, item('minecraft:clay')) | ||
.rolls(10) | ||
.register() | ||
|
||
|
||
// groovyscript.wiki.alchemistry.electrolyzer.title: | ||
// groovyscript.wiki.alchemistry.electrolyzer.description | ||
|
||
// mods.alchemistry.electrolyzer.removeByInput(fluid('water')) | ||
mods.alchemistry.electrolyzer.removeByInput(element('calcium_carbonate')) | ||
mods.alchemistry.electrolyzer.removeByOutput(element('chlorine')) | ||
// mods.alchemistry.electrolyzer.removeAll() | ||
|
||
mods.alchemistry.electrolyzer.recipeBuilder() | ||
.fluidInput(fluid('lava') * 100) | ||
.output(item('minecraft:clay')) | ||
.register() | ||
|
||
mods.alchemistry.electrolyzer.recipeBuilder() | ||
.fluidInput(fluid('water') * 100) | ||
.input(item('minecraft:gold_ingot')) | ||
.consumptionChance(100) | ||
.output(item('minecraft:gold_nugget') * 4) | ||
.output(item('minecraft:gold_nugget') * 4) | ||
.output(item('minecraft:gold_nugget') * 4) | ||
.output(item('minecraft:gold_nugget') * 4) | ||
.chance(50) | ||
.chance(50) | ||
.register() | ||
|
||
|
||
// groovyscript.wiki.alchemistry.evaporator.title: | ||
// groovyscript.wiki.alchemistry.evaporator.description | ||
|
||
mods.alchemistry.evaporator.removeByInput(fluid('lava')) | ||
mods.alchemistry.evaporator.removeByOutput(item('alchemistry:mineral_salt')) | ||
// mods.alchemistry.evaporator.removeAll() | ||
|
||
mods.alchemistry.evaporator.recipeBuilder() | ||
.fluidInput(fluid('lava') * 100) | ||
.output(item('minecraft:redstone') * 8) | ||
.register() | ||
|
||
mods.alchemistry.evaporator.recipeBuilder() | ||
.fluidInput(fluid('water') * 10) | ||
.output(item('minecraft:clay')) | ||
.register() | ||
|
||
|
||
// groovyscript.wiki.alchemistry.liquifier.title: | ||
// groovyscript.wiki.alchemistry.liquifier.description | ||
|
||
mods.alchemistry.liquifier.removeByInput(element('water')) | ||
// mods.alchemistry.liquifier.removeByOutput(fluid('water')) | ||
// mods.alchemistry.liquifier.removeAll() | ||
|
||
mods.alchemistry.liquifier.recipeBuilder() | ||
.input(element('carbon') * 32) | ||
.fluidOutput(fluid('water') * 1000) | ||
.register() | ||
|
||
mods.alchemistry.liquifier.recipeBuilder() | ||
.input(item('minecraft:magma')) | ||
.fluidOutput(fluid('lava') * 750) | ||
.register() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Alchemistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.alchemistry; | ||
|
||
import al132.alchemistry.chemistry.ChemicalCompound; | ||
import al132.alchemistry.chemistry.ChemicalElement; | ||
import al132.alchemistry.chemistry.CompoundRegistry; | ||
import al132.alchemistry.chemistry.ElementRegistry; | ||
import com.cleanroommc.groovyscript.api.Result; | ||
import com.cleanroommc.groovyscript.compat.mods.ModPropertyContainer; | ||
import com.cleanroommc.groovyscript.gameobjects.GameObjectHandlerManager; | ||
|
||
public class Alchemistry extends ModPropertyContainer { | ||
|
||
public final Atomizer atomizer = new Atomizer(); | ||
public final Combiner combiner = new Combiner(); | ||
public final Dissolver dissolver = new Dissolver(); | ||
public final Electrolyzer electrolyzer = new Electrolyzer(); | ||
public final Evaporator evaporator = new Evaporator(); | ||
public final Liquifier liquifier = new Liquifier(); | ||
|
||
public Alchemistry() { | ||
addRegistry(atomizer); | ||
addRegistry(combiner); | ||
addRegistry(dissolver); | ||
addRegistry(electrolyzer); | ||
addRegistry(evaporator); | ||
addRegistry(liquifier); | ||
// TODO: | ||
// Compound Creation and Element Creation | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
GameObjectHandlerManager.registerGameObjectHandler("alchemistry", "element", (s, args) -> { | ||
String parsedName = s.trim().toLowerCase().replace(" ", "_"); | ||
ChemicalCompound compound = CompoundRegistry.INSTANCE.get(parsedName); | ||
if (compound == null || compound.toItemStack(1).isEmpty()) { | ||
ChemicalElement element = ElementRegistry.INSTANCE.get(parsedName); | ||
if (element == null || element.toItemStack(1).isEmpty()) { | ||
return Result.error(); | ||
} | ||
return Result.some(element.toItemStack(1)); | ||
} | ||
return Result.some(compound.toItemStack(1)); | ||
}); | ||
} | ||
|
||
} |
130 changes: 130 additions & 0 deletions
130
src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Atomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.alchemistry; | ||
|
||
import al132.alchemistry.recipes.AtomizerRecipe; | ||
import al132.alchemistry.recipes.LiquifierRecipe; | ||
import al132.alchemistry.recipes.ModRecipes; | ||
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.helper.SimpleObjectStream; | ||
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; | ||
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.fluids.FluidStack; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@RegistryDescription | ||
public class Atomizer extends VirtualizedRegistry<AtomizerRecipe> { | ||
|
||
@Override | ||
public void onReload() { | ||
removeScripted().forEach(recipe -> ModRecipes.INSTANCE.getAtomizerRecipes().removeIf(r -> r == recipe)); | ||
ModRecipes.INSTANCE.getAtomizerRecipes().addAll(restoreFromBackup()); | ||
} | ||
|
||
@RecipeBuilderDescription(example = { | ||
@Example(".fluidInput(fluid('water') * 125).output(item('minecraft:clay'))"), | ||
@Example(".fluidInput(fluid('lava') * 500).output(item('minecraft:gold_ingot')).reversible()") | ||
}) | ||
public RecipeBuilder recipeBuilder() { | ||
return new RecipeBuilder(); | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.ADDITION) | ||
public AtomizerRecipe add(FluidStack input, ItemStack output) { | ||
return new RecipeBuilder().fluidInput(input).output(output).register(); | ||
} | ||
|
||
public AtomizerRecipe add(AtomizerRecipe recipe) { | ||
if (recipe != null) { | ||
addScripted(recipe); | ||
ModRecipes.INSTANCE.getAtomizerRecipes().add(recipe); | ||
} | ||
return recipe; | ||
} | ||
|
||
public boolean remove(AtomizerRecipe recipe) { | ||
if (ModRecipes.INSTANCE.getAtomizerRecipes().removeIf(r -> r == recipe)) { | ||
addBackup(recipe); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example(value = "item('alchemistry:compound:7')", commented = true)) | ||
public boolean removeByOutput(IIngredient output) { | ||
return ModRecipes.INSTANCE.getAtomizerRecipes().removeIf(r -> { | ||
if (output.test(r.getOutput())) { | ||
addBackup(r); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("fluid('water')")) | ||
public boolean removeByInput(FluidStack input) { | ||
return ModRecipes.INSTANCE.getAtomizerRecipes().removeIf(r -> { | ||
if (r.getInput().isFluidEqual(input)) { | ||
addBackup(r); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@MethodDescription(description = "groovyscript.wiki.streamRecipes", type = MethodDescription.Type.QUERY) | ||
public SimpleObjectStream<AtomizerRecipe> streamRecipes() { | ||
return new SimpleObjectStream<>(ModRecipes.INSTANCE.getAtomizerRecipes()).setRemover(this::remove); | ||
} | ||
|
||
@MethodDescription(description = "groovyscript.wiki.removeAll", priority = 2000, example = @Example(commented = true)) | ||
public void removeAll() { | ||
ModRecipes.INSTANCE.getAtomizerRecipes().forEach(this::addBackup); | ||
ModRecipes.INSTANCE.getAtomizerRecipes().clear(); | ||
} | ||
|
||
@Property(property = "fluidInput", valid = @Comp("1")) | ||
@Property(property = "output", valid = @Comp("1")) | ||
public static class RecipeBuilder extends AbstractRecipeBuilder<AtomizerRecipe> { | ||
|
||
@Property | ||
private boolean reversible; | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder reversible(boolean reversible) { | ||
this.reversible = reversible; | ||
return this; | ||
} | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder reversible() { | ||
this.reversible = !reversible; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getErrorMsg() { | ||
return "Error adding Alchemistry Atomizer recipe"; | ||
} | ||
|
||
@Override | ||
public void validate(GroovyLog.Msg msg) { | ||
validateItems(msg, 0, 0, 1, 1); | ||
validateFluids(msg, 1, 1, 0, 0); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
@RecipeBuilderRegistrationMethod | ||
public AtomizerRecipe register() { | ||
if (!validate()) return null; | ||
|
||
AtomizerRecipe recipe = new AtomizerRecipe(false, fluidInput.get(0), output.get(0)); | ||
if (reversible) ModSupport.ALCHEMISTRY.get().liquifier.add(new LiquifierRecipe(output.get(0), fluidInput.get(0))); | ||
ModSupport.ALCHEMISTRY.get().atomizer.add(recipe); | ||
return recipe; | ||
} | ||
} | ||
} |
Oops, something went wrong.