generated from CleanroomMC/ForgeDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 30
EvilCraft compat #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
EvilCraft compat #58
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
04a56dc
add EvilCraft compat
WaitingIdly 885f904
add compat examples
WaitingIdly 0ac0bfa
fix an extra space in item input checks
WaitingIdly 0548906
fix typo
WaitingIdly d991525
Merge branch 'heads/upstream/master' into evilcraft
WaitingIdly e71ac87
case EnvironmentalAccumulator weather I/O to match bracket handler
WaitingIdly 9c0296f
address review
WaitingIdly e7ef6a9
Merge branch 'master' into evilcraft
brachy84 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,70 @@ | ||
|
|
||
| // Weather Bracket Handler | ||
| weather('clear') | ||
| weather('rain') | ||
| weather('lightning') | ||
|
|
||
|
|
||
| // Blood Infuser: | ||
| // Consumes an item, some fluid, and requires a given tier of Promise of Tenacity to produce the output and some experience after a duration. | ||
| mods.evilcraft.bloodinfuser.recipeBuilder() | ||
| .input(item('minecraft:clay')) | ||
| .output(item('minecraft:clay')) | ||
| .fluidInput(fluid('evilcraftblood') * 1000) | ||
| .tier(3) // Optional integer. Requires at least this tier of Promise of Tenacity to craft. Defaults to 0. | ||
| .duration(100) // Optional integer. Time in ticks for the recipe to complete. Defaults to 0. | ||
| .xp(10000) // Optional float. Experience gained when completing the recipe. Defaults to 0. | ||
| .register() | ||
|
|
||
| mods.evilcraft.bloodinfuser.recipeBuilder() | ||
| .input(item('minecraft:gold_ingot')) | ||
| .output(item('minecraft:clay')) | ||
| .fluidInput(100000) // Calling `fluidInput` with just an integer will automatically consider the fluid as "evilcraftblood". | ||
| .register() | ||
|
|
||
| mods.evilcraft.bloodinfuser.recipeBuilder() | ||
| .input(item('minecraft:diamond')) | ||
| .output(item('minecraft:clay') * 4) | ||
| .fluidInput(5000) // `blood` can also be used as an alias for `fluidInput` when only an integer is used. | ||
| .tier(1) | ||
| .register() | ||
|
|
||
| mods.evilcraft.bloodinfuser.removeByInput(item('evilcraft:dark_gem')) | ||
| mods.evilcraft.bloodinfuser.removeByOutput(item('minecraft:leather')) | ||
| //mods.evilcraft.bloodinfuser.removeAll() | ||
|
|
||
|
|
||
| // Environmental Accumulator: | ||
| // Consumes an item to give an output, possibly changing the weather. Has a cooldown time or a blood cost. | ||
| mods.evilcraft.environmentalaccumulator.recipeBuilder() | ||
| .input(item('minecraft:clay')) | ||
| .output(item('minecraft:clay') * 2) | ||
| .inputWeather(weather('clear')) | ||
| .outputWeather(weather('rain')) | ||
| .processingspeed(1) // Optional doube. Controls the visual rotation of the item while crafting. Defaults to the amount set in the config. | ||
| .cooldowntime(1000) // Optional integer. Time it takes before another recipe can be run. Defaults to the time set in the config. | ||
| // cooldowntime also controls the amount of evilcraftblood consumed by the Sanguinary Environmental Accumulator | ||
| .duration(10) // Optional integer. Time it takes to complete the recipe. Defaults to the time set in the config. | ||
| .register() | ||
|
|
||
| mods.evilcraft.environmentalaccumulator.recipeBuilder() | ||
| .input(item('minecraft:gold_ingot')) | ||
| .output(item('minecraft:diamond')) | ||
| .inputWeather(weather('rain')) | ||
| .outputWeather(weather('lightning')) | ||
| .speed(10) // Short for processingspeed. | ||
| .cooldown(1) // Short for cooldowntime. | ||
| .register() | ||
|
|
||
| mods.evilcraft.environmentalaccumulator.recipeBuilder() | ||
| .input(item('minecraft:diamond')) | ||
| .output(item('minecraft:clay') * 16) | ||
| .inputWeather(weather('lightning')) | ||
| .outputWeather(weather('lightning')) | ||
| .register() | ||
|
|
||
|
|
||
| mods.evilcraft.environmentalaccumulator.removeByInput(item('evilcraft:exalted_crafter:1')) | ||
| mods.evilcraft.environmentalaccumulator.removeByOutput(item('evilcraft:exalted_crafter:2')) | ||
| //mods.evilcraft.environmentalaccumulator.removeAll() | ||
|
|
This file contains hidden or 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 hidden or 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
141 changes: 141 additions & 0 deletions
141
src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/BloodInfuser.java
This file contains hidden or 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,141 @@ | ||
| package com.cleanroommc.groovyscript.compat.mods.evilcraft; | ||
|
|
||
| import com.cleanroommc.groovyscript.api.GroovyLog; | ||
| 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.Fluid; | ||
| import net.minecraftforge.fluids.FluidRegistry; | ||
| import net.minecraftforge.fluids.FluidStack; | ||
| import org.cyclops.cyclopscore.recipe.custom.api.IRecipe; | ||
| import org.cyclops.cyclopscore.recipe.custom.component.IngredientRecipeComponent; | ||
| import org.cyclops.evilcraft.core.recipe.custom.DurationXpRecipeProperties; | ||
| import org.cyclops.evilcraft.core.recipe.custom.IngredientFluidStackAndTierRecipeComponent; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| public class BloodInfuser extends VirtualizedRegistry<IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties>> { | ||
|
|
||
| public BloodInfuser() { | ||
| super(); | ||
| } | ||
|
|
||
| public RecipeBuilder recipeBuilder() { | ||
| return new RecipeBuilder(); | ||
| } | ||
|
|
||
| @Override | ||
| public void onReload() { | ||
| removeScripted().forEach(org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes()::remove); | ||
| restoreFromBackup().forEach(org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes()::add); | ||
| } | ||
|
|
||
| public void add(IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties> recipe) { | ||
| this.add(recipe, true); | ||
| } | ||
|
|
||
| public void add(IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties> recipe, boolean add) { | ||
| if (recipe == null) return; | ||
| addScripted(recipe); | ||
| if (add) org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().add(recipe); | ||
| } | ||
|
|
||
| public boolean remove(IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties> recipe) { | ||
| if (recipe == null) return false; | ||
| addBackup(recipe); | ||
| org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().remove(recipe); | ||
| return true; | ||
| } | ||
|
|
||
| public boolean removeByInput(ItemStack input) { | ||
| return org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().removeIf(r -> { | ||
| if (r.getInput().getIngredient().test(input)) { | ||
| addBackup(r); | ||
| return true; | ||
| } | ||
| return false; | ||
| }); | ||
| } | ||
|
|
||
| public boolean removeByOutput(ItemStack input) { | ||
| return org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().removeIf(r -> { | ||
| if (r.getOutput().getIngredient().test(input)) { | ||
| addBackup(r); | ||
| return true; | ||
| } | ||
| return false; | ||
| }); | ||
| } | ||
|
|
||
| public void removeAll() { | ||
| org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().forEach(this::addBackup); | ||
| org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().clear(); | ||
| } | ||
|
|
||
| public SimpleObjectStream<IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties>> streamRecipes() { | ||
| return new SimpleObjectStream<>(org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes()) | ||
| .setRemover(this::remove); | ||
| } | ||
|
|
||
| public static class RecipeBuilder extends AbstractRecipeBuilder<IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties>> { | ||
|
|
||
| private static final Fluid bloodFluid = FluidRegistry.getFluid("evilcraftblood"); | ||
|
|
||
| private int tier = 0; | ||
| private int duration = 0; | ||
| private float xp = 0; | ||
|
|
||
| public RecipeBuilder tier(int tier) { | ||
| this.tier = tier; | ||
| return this; | ||
| } | ||
|
|
||
| public RecipeBuilder duration(int duration) { | ||
| this.duration = duration; | ||
| return this; | ||
| } | ||
|
|
||
| public RecipeBuilder xp(float xp) { | ||
| this.xp = xp; | ||
| return this; | ||
| } | ||
|
|
||
| public RecipeBuilder blood(int amount) { | ||
| this.fluidInput.add(new FluidStack(bloodFluid, amount)); | ||
| return this; | ||
| } | ||
|
|
||
| public RecipeBuilder fluidInput(int amount) { | ||
| this.fluidInput.add(new FluidStack(bloodFluid, amount)); | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public String getErrorMsg() { | ||
| return "Error adding EvilCraft Blood Infuser Recipe"; | ||
| } | ||
|
|
||
| @Override | ||
| public void validate(GroovyLog.Msg msg) { | ||
| validateItems(msg, 1, 1, 1, 1); | ||
| validateFluids(msg, 1, 1, 0, 0); | ||
| msg.add(tier < 0 || tier > 3, "tier must be between 0 and 3, yet it was {}", tier); | ||
| msg.add(duration < 0, "duration must be a non negative integer, yet it was {}", duration); | ||
| msg.add(xp < 0, "xp must be a non negative integer, yet it was {}", xp); | ||
| } | ||
|
|
||
| @Override | ||
| public @Nullable IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties> register() { | ||
| if (!validate()) return null; | ||
| IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties> recipe = | ||
| org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().registerRecipe( | ||
| new IngredientFluidStackAndTierRecipeComponent(input.get(0).toMcIngredient(), fluidInput.get(0), tier), | ||
| new IngredientRecipeComponent(output.get(0)), | ||
| new DurationXpRecipeProperties(duration, xp) | ||
| ); | ||
| ModSupport.EVILCRAFT.get().bloodInfuser.add(recipe, false); | ||
| return recipe; | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.