generated from CleanroomMC/ForgeDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 30
Avaritia compat #68
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
Avaritia compat #68
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
745f8bc
avaritia compat
brachy84 2f55385
reviews
brachy84 46e7045
example
brachy84 41920e0
Merge remote-tracking branch 'origin/master' into avaritia
brachy84 71d0947
more reviews
brachy84 2dc6520
check ingredient amount
brachy84 24f4535
Merge branch 'master' into avaritia
brachy84 bbd8e99
fix error
brachy84 4d00ab0
Merge branch 'master' into avaritia
brachy84 8343605
fix more merge errors
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,44 @@ | ||
|
|
||
| mods.avaritia.ExtremeCrafting.removeByOutput(item('avaritia:resource', 6)) | ||
| mods.avaritia.ExtremeCrafting.shapedBuilder() | ||
| .matrix([[item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')], | ||
| [item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')], | ||
| [item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')], | ||
| [item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')], | ||
| [item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')], | ||
| [item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')], | ||
| [item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')]]) | ||
| .output(item('minecraft:gold_block')) | ||
| .register() | ||
|
|
||
| mods.avaritia.ExtremeCrafting.shapedBuilder() | ||
| .output(item('minecraft:stone') * 64) | ||
| .matrix( | ||
| 'DLLLLLDDD', | ||
| ' DNIGIND', | ||
| 'DDDNIGIND', | ||
| ' DLLLLLD') | ||
| .key('D', item('minecraft:diamond')) | ||
| .key('L', item('minecraft:redstone')) | ||
| .key('N', item('minecraft:stone').reuse()) // stone will not be consumed in the recipe | ||
| .key('I', item('minecraft:iron_ingot')) | ||
| .key('G', item('minecraft:gold_ingot')) | ||
| .register() | ||
|
|
||
| mods.avaritia.ExtremeCrafting.shapelessBuilder() | ||
| .output(item('minecraft:stone') * 64) | ||
| .input(item('minecraft:stone'), | ||
| item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'), | ||
| item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'), | ||
| item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'), | ||
| item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'), | ||
| item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone')) | ||
| .register() | ||
|
|
||
| mods.avaritia.Compressor.removeByOutput(item('avaritia:singularity', 0)) | ||
| mods.avaritia.Compressor.add(item('minecraft:nether_star'), item('minecraft:clay_ball'), 100) // the last number is the required input amount | ||
| mods.avaritia.Compressor.recipeBuilder() | ||
| .input(item('minecraft:clay_ball')) | ||
| .output(item('minecraft:nether_star')) | ||
| .inputCount(100) // required input amount | ||
| .register() | ||
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
14 changes: 14 additions & 0 deletions
14
src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/Avaritia.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,14 @@ | ||
| package com.cleanroommc.groovyscript.compat.mods.avaritia; | ||
|
|
||
| import com.cleanroommc.groovyscript.compat.mods.ModPropertyContainer; | ||
|
|
||
| public class Avaritia extends ModPropertyContainer { | ||
|
|
||
| public final ExtremeCrafting extremeCrafting = new ExtremeCrafting(); | ||
| public final Compressor compressor = new Compressor(); | ||
|
|
||
| public Avaritia() { | ||
| addRegistry(this.extremeCrafting); | ||
brachy84 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| addRegistry(this.compressor); | ||
| } | ||
| } | ||
124 changes: 124 additions & 0 deletions
124
src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/Compressor.java
brachy84 marked this conversation as resolved.
Show resolved
Hide resolved
|
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,124 @@ | ||
| package com.cleanroommc.groovyscript.compat.mods.avaritia; | ||
|
|
||
| import com.cleanroommc.groovyscript.api.GroovyLog; | ||
| import com.cleanroommc.groovyscript.api.IIngredient; | ||
| import com.cleanroommc.groovyscript.helper.SimpleObjectStream; | ||
| import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; | ||
| import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; | ||
| import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; | ||
| import morph.avaritia.recipe.AvaritiaRecipeManager; | ||
| import morph.avaritia.recipe.compressor.CompressorRecipe; | ||
| import morph.avaritia.recipe.compressor.ICompressorRecipe; | ||
| import net.minecraft.item.ItemStack; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| import java.util.Collections; | ||
|
|
||
| public class Compressor extends VirtualizedRegistry<ICompressorRecipe> { | ||
|
|
||
| @Override | ||
| public void onReload() { | ||
| removeScripted().forEach(recipe -> AvaritiaRecipeManager.COMPRESSOR_RECIPES.values().removeIf(r -> r == recipe)); | ||
| restoreFromBackup().forEach(recipe -> AvaritiaRecipeManager.COMPRESSOR_RECIPES.put(recipe.getRegistryName(), recipe)); | ||
| } | ||
|
|
||
| public boolean remove(ICompressorRecipe recipe) { | ||
| recipe = AvaritiaRecipeManager.COMPRESSOR_RECIPES.remove(recipe.getRegistryName()); | ||
| if (recipe != null) { | ||
| addBackup(recipe); | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| public boolean removeByOutput(ItemStack output) { | ||
| if (IngredientHelper.isEmpty(output)) { | ||
| GroovyLog.msg("Error removing avaritia compressor recipe") | ||
| .add("output must not be empty") | ||
| .error() | ||
| .post(); | ||
| return false; | ||
| } | ||
| return AvaritiaRecipeManager.COMPRESSOR_RECIPES.values().removeIf(recipe -> { | ||
| if (recipe != null && recipe.getResult().isItemEqual(output)) { | ||
| addBackup(recipe); | ||
| return true; | ||
| } | ||
| return false; | ||
| }); | ||
| } | ||
|
|
||
| public void removeAll() { | ||
| AvaritiaRecipeManager.COMPRESSOR_RECIPES.values().forEach(this::addBackup); | ||
| AvaritiaRecipeManager.COMPRESSOR_RECIPES.values().clear(); | ||
| } | ||
|
|
||
| public SimpleObjectStream<ICompressorRecipe> streamRecipes() { | ||
| return new SimpleObjectStream<>(AvaritiaRecipeManager.COMPRESSOR_RECIPES.values()).setRemover(this::remove); | ||
| } | ||
|
|
||
| public RecipeBuilder recipeBuilder() { | ||
| return new RecipeBuilder(); | ||
| } | ||
|
|
||
| public void add(ICompressorRecipe recipe) { | ||
| AvaritiaRecipeManager.COMPRESSOR_RECIPES.put(recipe.getRegistryName(), recipe); | ||
| addScripted(recipe); | ||
| } | ||
|
|
||
| public void add(ItemStack output, IIngredient input, int cost) { | ||
| recipeBuilder() | ||
| .inputCount(cost) | ||
| .input(input) | ||
| .output(output) | ||
| .register(); | ||
| } | ||
|
|
||
| public class RecipeBuilder extends AbstractRecipeBuilder<ICompressorRecipe> { | ||
|
|
||
| private int inputCount = 300; | ||
|
|
||
| @Override | ||
| public AbstractRecipeBuilder<ICompressorRecipe> input(IIngredient ingredient) { | ||
| if (ingredient == null) return this; | ||
| if (ingredient.getAmount() > 1) { | ||
| this.inputCount = ingredient.getAmount(); | ||
| } | ||
| return super.input(ingredient.withAmount(1)); | ||
| } | ||
|
|
||
| public RecipeBuilder inputCount(int inputCount) { | ||
| this.inputCount = inputCount; | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public String getRecipeNamePrefix() { | ||
| return "avaritia_compressor_"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getErrorMsg() { | ||
| return "Error adding Avaritia compressor recipe"; | ||
| } | ||
|
|
||
| @Override | ||
| public void validate(GroovyLog.Msg msg) { | ||
| validateItems(msg, 1, 1, 1, 1); | ||
| validateFluids(msg); | ||
| validateName(); | ||
| if (this.inputCount <= 0) { | ||
| this.inputCount = 1; | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public @Nullable ICompressorRecipe register() { | ||
| if (!validate()) return null; | ||
| CompressorRecipe recipe = new CompressorRecipe(this.output.get(0), this.inputCount, true, Collections.singletonList(this.input.get(0).toMcIngredient())); | ||
| recipe.setRegistryName(this.name); | ||
| add(recipe); | ||
| 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.