-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
353 additions
and
5 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,19 @@ | ||
mods.harkenscythe.bloodAltar.recipeBuilder() | ||
.input(item('minecraft:cobblestone')) | ||
.output(item('minecraft:gravel')) | ||
.requiredBlood(42) | ||
.register() | ||
|
||
mods.harkenscythe.bloodAltar.removeByInput(item('minecraft:glass_bottle')) | ||
mods.harkenscythe.bloodAltar.removeByOutput(item('harkenscythe:bloodweave_cloth')) | ||
//mods.harkenscythe.bloodAltar.removeAll() | ||
|
||
mods.harkenscythe.soulAltar.recipeBuilder() | ||
.input(item('minecraft:gravel')) | ||
.output(item('minecraft:sand')) | ||
.requiredSouls(69) | ||
.register() | ||
|
||
mods.harkenscythe.soulAltar.removeByInput(item('minecraft:cookie')) | ||
mods.harkenscythe.soulAltar.removeByOutput(item('harkenscythe:soul_cake')) | ||
//mods.harkenscythe.soulAltar.removeAll() |
137 changes: 137 additions & 0 deletions
137
src/main/java/mod/emt/harkenscythe/compat/groovyscript/HSGroovyScriptBloodAltarRecipes.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,137 @@ | ||
package mod.emt.harkenscythe.compat.groovyscript; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import net.minecraft.item.ItemStack; | ||
|
||
import com.cleanroommc.groovyscript.api.GroovyLog; | ||
import com.cleanroommc.groovyscript.api.IIngredient; | ||
import com.cleanroommc.groovyscript.api.documentation.annotations.*; | ||
import com.cleanroommc.groovyscript.helper.Alias; | ||
import com.cleanroommc.groovyscript.helper.SimpleObjectStream; | ||
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; | ||
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; | ||
import mod.emt.harkenscythe.HarkenScythe; | ||
import mod.emt.harkenscythe.init.HSAltarRecipes; | ||
import mod.emt.harkenscythe.recipe.HSRecipeBloodAltar; | ||
|
||
@SuppressWarnings("unused") | ||
@RegistryDescription(linkGenerator = HarkenScythe.MOD_ID) | ||
public class HSGroovyScriptBloodAltarRecipes extends VirtualizedRegistry<HSRecipeBloodAltar> | ||
{ | ||
public HSGroovyScriptBloodAltarRecipes() | ||
{ | ||
super(Alias.generateOf("BloodAltar")); | ||
} | ||
|
||
@Override | ||
public void onReload() | ||
{ | ||
HSAltarRecipes.getBloodAltarRecipes().removeAll(removeScripted()); | ||
HSAltarRecipes.getBloodAltarRecipes().addAll(restoreFromBackup()); | ||
} | ||
|
||
public void add(HSRecipeBloodAltar t) | ||
{ | ||
HSAltarRecipes.getBloodAltarRecipes().add(t); | ||
addScripted(t); | ||
} | ||
|
||
public boolean remove(HSRecipeBloodAltar t) | ||
{ | ||
if (HSAltarRecipes.getBloodAltarRecipes().remove(t)) | ||
{ | ||
addBackup(t); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.QUERY) | ||
public SimpleObjectStream<HSRecipeBloodAltar> streamRecipes() | ||
{ | ||
return new SimpleObjectStream<>(HSAltarRecipes.getBloodAltarRecipes()).setRemover(this::remove); | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.REMOVAL, example = @Example("item('harkenscythe:bloodweave_cloth')")) | ||
public boolean removeByOutput(IIngredient output) | ||
{ | ||
return HSAltarRecipes.getBloodAltarRecipes().removeIf(r -> { | ||
if (output.test(r.getOutput())) | ||
{ | ||
addBackup(r); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.REMOVAL, example = @Example("item('minecraft:glass_bottle')")) | ||
public boolean removeByInput(IIngredient input) | ||
{ | ||
return HSAltarRecipes.getBloodAltarRecipes().removeIf(r -> { | ||
if (input.test(r.getInput())) | ||
{ | ||
addBackup(r); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.REMOVAL, priority = 2000, example = @Example(commented = true)) | ||
public void removeAll() | ||
{ | ||
HSAltarRecipes.getBloodAltarRecipes().forEach(this::addBackup); | ||
HSAltarRecipes.getBloodAltarRecipes().clear(); | ||
} | ||
|
||
@RecipeBuilderDescription(example = @Example(".input(item('minecraft:cobblestone')).output(item('minecraft:gravel')).requiredBlood(42)")) | ||
public RecipeBuilder recipeBuilder() | ||
{ | ||
return new RecipeBuilder(); | ||
} | ||
|
||
@Property(property = "input", valid = @Comp("1")) | ||
@Property(property = "output", valid = @Comp("1")) | ||
public static class RecipeBuilder extends AbstractRecipeBuilder<HSRecipeBloodAltar> | ||
{ | ||
@Property(valid = @Comp(type = Comp.Type.GTE, value = "1")) | ||
private int requiredBlood; | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder requiredBlood(int requiredBlood) | ||
{ | ||
this.requiredBlood = requiredBlood; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getErrorMsg() | ||
{ | ||
return "Error adding Harken Scythe Blood Altar ritual recipe"; | ||
} | ||
|
||
@Override | ||
public void validate(GroovyLog.Msg msg) | ||
{ | ||
validateItems(msg, 1, 1, 1, 1); | ||
msg.add(requiredBlood < 1, "requiredBlood must be 1 or greater"); | ||
} | ||
|
||
@Override | ||
@Nullable | ||
@RecipeBuilderRegistrationMethod | ||
public HSRecipeBloodAltar register() | ||
{ | ||
if (!validate()) return null; | ||
HSRecipeBloodAltar t = null; | ||
for (ItemStack in : input.get(0).getMatchingStacks()) | ||
{ | ||
t = new HSRecipeBloodAltar(in, output.get(0), requiredBlood); | ||
HSGroovyScriptPlugin.instance.bloodAltar.add(t); | ||
} | ||
return t; | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/mod/emt/harkenscythe/compat/groovyscript/HSGroovyScriptContainer.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,14 @@ | ||
package mod.emt.harkenscythe.compat.groovyscript; | ||
|
||
import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; | ||
|
||
public class HSGroovyScriptContainer extends GroovyPropertyContainer | ||
{ | ||
public final HSGroovyScriptBloodAltarRecipes bloodAltar = new HSGroovyScriptBloodAltarRecipes(); | ||
public final HSGroovyScriptSoulAltarRecipes soulAltar = new HSGroovyScriptSoulAltarRecipes(); | ||
|
||
public HSGroovyScriptContainer() | ||
{ | ||
addPropertyFieldsOf(this, false); | ||
} | ||
} |
40 changes: 35 additions & 5 deletions
40
src/main/java/mod/emt/harkenscythe/compat/groovyscript/HSGroovyScriptPlugin.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 |
---|---|---|
@@ -1,28 +1,58 @@ | ||
package mod.emt.harkenscythe.compat.groovyscript; | ||
|
||
import com.cleanroommc.groovyscript.GroovyScript; | ||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
import com.cleanroommc.groovyscript.api.GroovyBlacklist; | ||
import com.cleanroommc.groovyscript.api.GroovyPlugin; | ||
import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; | ||
import groovyjarjarantlr4.v4.runtime.misc.NotNull; | ||
import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; | ||
import com.cleanroommc.groovyscript.documentation.linkgenerator.BasicLinkGenerator; | ||
import com.cleanroommc.groovyscript.documentation.linkgenerator.LinkGeneratorHooks; | ||
import mod.emt.harkenscythe.HarkenScythe; | ||
|
||
public class HSGroovyScriptPlugin implements GroovyPlugin | ||
{ | ||
@GroovyBlacklist | ||
public static HSGroovyScriptContainer instance; | ||
|
||
@Override | ||
public @Nullable GroovyPropertyContainer createGroovyPropertyContainer() | ||
{ | ||
if (instance == null) instance = new HSGroovyScriptContainer(); | ||
return instance; | ||
} | ||
|
||
@Override | ||
public @NotNull String getModId() | ||
public @Nonnull String getModId() | ||
{ | ||
return HarkenScythe.MOD_ID; | ||
} | ||
|
||
@Override | ||
public @NotNull String getContainerName() | ||
public @Nonnull String getContainerName() | ||
{ | ||
return HarkenScythe.NAME; | ||
} | ||
|
||
@Override | ||
public void onCompatLoaded(GroovyContainer<?> container) | ||
{ | ||
GroovyScript.LOGGER.info(HarkenScythe.NAME + " container loaded"); | ||
LinkGeneratorHooks.registerLinkGenerator(new HarkenScytheLinkGenerator()); | ||
} | ||
|
||
private static class HarkenScytheLinkGenerator extends BasicLinkGenerator | ||
{ | ||
@Override | ||
public String id() | ||
{ | ||
return HarkenScythe.MOD_ID; | ||
} | ||
|
||
@Override | ||
protected String domain() | ||
{ | ||
return "https://github.com/Elite-Modding-Team/HarkenScytheResharpened/"; | ||
} | ||
} | ||
} |
137 changes: 137 additions & 0 deletions
137
src/main/java/mod/emt/harkenscythe/compat/groovyscript/HSGroovyScriptSoulAltarRecipes.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,137 @@ | ||
package mod.emt.harkenscythe.compat.groovyscript; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import net.minecraft.item.ItemStack; | ||
|
||
import com.cleanroommc.groovyscript.api.GroovyLog; | ||
import com.cleanroommc.groovyscript.api.IIngredient; | ||
import com.cleanroommc.groovyscript.api.documentation.annotations.*; | ||
import com.cleanroommc.groovyscript.helper.Alias; | ||
import com.cleanroommc.groovyscript.helper.SimpleObjectStream; | ||
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; | ||
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; | ||
import mod.emt.harkenscythe.HarkenScythe; | ||
import mod.emt.harkenscythe.init.HSAltarRecipes; | ||
import mod.emt.harkenscythe.recipe.HSRecipeSoulAltar; | ||
|
||
@SuppressWarnings("unused") | ||
@RegistryDescription(linkGenerator = HarkenScythe.MOD_ID) | ||
public class HSGroovyScriptSoulAltarRecipes extends VirtualizedRegistry<HSRecipeSoulAltar> | ||
{ | ||
public HSGroovyScriptSoulAltarRecipes() | ||
{ | ||
super(Alias.generateOf("SoulAltar")); | ||
} | ||
|
||
@Override | ||
public void onReload() | ||
{ | ||
HSAltarRecipes.getSoulAltarRecipes().removeAll(removeScripted()); | ||
HSAltarRecipes.getSoulAltarRecipes().addAll(restoreFromBackup()); | ||
} | ||
|
||
public void add(HSRecipeSoulAltar t) | ||
{ | ||
HSAltarRecipes.getSoulAltarRecipes().add(t); | ||
addScripted(t); | ||
} | ||
|
||
public boolean remove(HSRecipeSoulAltar t) | ||
{ | ||
if (HSAltarRecipes.getSoulAltarRecipes().remove(t)) | ||
{ | ||
addBackup(t); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.QUERY) | ||
public SimpleObjectStream<HSRecipeSoulAltar> streamRecipes() | ||
{ | ||
return new SimpleObjectStream<>(HSAltarRecipes.getSoulAltarRecipes()).setRemover(this::remove); | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.REMOVAL, example = @Example("item('harkenscythe:soul_cake')")) | ||
public boolean removeByOutput(IIngredient output) | ||
{ | ||
return HSAltarRecipes.getSoulAltarRecipes().removeIf(r -> { | ||
if (output.test(r.getOutput())) | ||
{ | ||
addBackup(r); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.REMOVAL, example = @Example("item('minecraft:cookie')")) | ||
public boolean removeByInput(IIngredient input) | ||
{ | ||
return HSAltarRecipes.getSoulAltarRecipes().removeIf(r -> { | ||
if (input.test(r.getInput())) | ||
{ | ||
addBackup(r); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.REMOVAL, priority = 2000, example = @Example(commented = true)) | ||
public void removeAll() | ||
{ | ||
HSAltarRecipes.getSoulAltarRecipes().forEach(this::addBackup); | ||
HSAltarRecipes.getSoulAltarRecipes().clear(); | ||
} | ||
|
||
@RecipeBuilderDescription(example = @Example(".input(item('minecraft:gravel')).output(item('minecraft:sand')).requiredSouls(69)")) | ||
public RecipeBuilder recipeBuilder() | ||
{ | ||
return new RecipeBuilder(); | ||
} | ||
|
||
@Property(property = "input", valid = @Comp("1")) | ||
@Property(property = "output", valid = @Comp("1")) | ||
public static class RecipeBuilder extends AbstractRecipeBuilder<HSRecipeSoulAltar> | ||
{ | ||
@Property(valid = @Comp(type = Comp.Type.GTE, value = "1")) | ||
private int requiredSouls; | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder requiredSouls(int requiredSouls) | ||
{ | ||
this.requiredSouls = requiredSouls; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getErrorMsg() | ||
{ | ||
return "Error adding Harken Scythe Soul Altar ritual recipe"; | ||
} | ||
|
||
@Override | ||
public void validate(GroovyLog.Msg msg) | ||
{ | ||
validateItems(msg, 1, 1, 1, 1); | ||
msg.add(requiredSouls < 1, "requiredSouls must be 1 or greater"); | ||
} | ||
|
||
@Override | ||
@Nullable | ||
@RecipeBuilderRegistrationMethod | ||
public HSRecipeSoulAltar register() | ||
{ | ||
if (!validate()) return null; | ||
HSRecipeSoulAltar t = null; | ||
for (ItemStack in : input.get(0).getMatchingStacks()) | ||
{ | ||
t = new HSRecipeSoulAltar(in, output.get(0), requiredSouls); | ||
HSGroovyScriptPlugin.instance.soulAltar.add(t); | ||
} | ||
return t; | ||
} | ||
} | ||
} |
Oops, something went wrong.