generated from CleanroomMC/TemplateDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Start Aether Legacy Support * Start Aether Legacy Support * Rewrite to use Forge registry wrapper * Add Documentation Annotations * Changes from Review * More Changes from Review * Turn off debug mode * A couple quick fixes * Review Cleanup * More Fixes/Refactoring from Review
- Loading branch information
1 parent
af72dac
commit 4f106e3
Showing
11 changed files
with
424 additions
and
1 deletion.
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,63 @@ | ||
|
||
// Auto generated groovyscript example file | ||
// MODS_LOADED: aether_legacy | ||
|
||
println 'mod \'aether_legacy\' detected, running script' | ||
|
||
// Accessory: | ||
// The Aether Accessory system. | ||
|
||
mods.aether_legacy.accessory.removeByInput(item('aether_legacy:iron_pendant')) | ||
// mods.aether_legacy.accessory.removeAll() | ||
|
||
mods.aether_legacy.accessory.recipeBuilder() | ||
.input(item('minecraft:shield')) | ||
.accessoryType('shield') | ||
.register() | ||
|
||
|
||
|
||
// Enchanter: | ||
// Enchanting is a mechanic used to create new items, as well as repair tools, armor, and weapons, using the Altar block. | ||
|
||
mods.aether_legacy.enchanter.removeByOutput(item('aether_legacy:enchanted_gravitite')) | ||
// mods.aether_legacy.enchanter.removeAll() | ||
|
||
mods.aether_legacy.enchanter.recipeBuilder() | ||
.input(item('minecraft:clay')) | ||
.output(item('minecraft:diamond')) | ||
.time(200) | ||
.register() | ||
|
||
|
||
|
||
// Enchanter Fuel: | ||
// By default, the Enchantar (Altar) takes Ambrosium Shards as fuel. Using GroovyScript, custom fuels can be added. | ||
|
||
mods.aether_legacy.enchanter_fuel.removeByItem(item('aether_legacy:ambrosium_shard')) | ||
// mods.aether_legacy.enchanter_fuel.removeAll() | ||
|
||
mods.aether_legacy.enchanter_fuel.add(item('minecraft:blaze_rod'), 1000) | ||
|
||
// Freezer: | ||
// The Freezer is used to turn certain items into frozen versions. | ||
|
||
mods.aether_legacy.freezer.removeByOutput(item('minecraft:obsidian')) | ||
// mods.aether_legacy.freezer.removeAll() | ||
|
||
mods.aether_legacy.freezer.recipeBuilder() | ||
.input(item('minecraft:clay')) | ||
.output(item('minecraft:dirt')) | ||
.time(200) | ||
.register() | ||
|
||
|
||
|
||
// Freezer: | ||
// By default, the Freezer takes Icestone as fuel. Using GroovyScript, custom fuels can be added. | ||
|
||
mods.aether_legacy.freezer_fuel.removeByItem(item('aether_legacy:icestone')) | ||
// mods.aether_legacy.freezer_fuel.removeAll() | ||
|
||
mods.aether_legacy.freezer_fuel.add(item('minecraft:packed_ice'), 1000) | ||
|
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
94 changes: 94 additions & 0 deletions
94
src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Accessory.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,94 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.aetherlegacy; | ||
|
||
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.EnumHelper; | ||
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; | ||
import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; | ||
import com.gildedgames.the_aether.api.accessories.AccessoryType; | ||
import com.gildedgames.the_aether.api.accessories.AetherAccessory; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.fml.common.registry.GameRegistry; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Arrays; | ||
|
||
@RegistryDescription | ||
public class Accessory extends ForgeRegistryWrapper<AetherAccessory> { | ||
|
||
public Accessory() { | ||
super(GameRegistry.findRegistry(AetherAccessory.class), Alias.generateOfClass(Accessory.class)); | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.ADDITION) | ||
public void add(ItemStack item, String type) { | ||
AccessoryType accessoryType = EnumHelper.valueOfNullable(AccessoryType.class, type, false); | ||
if (accessoryType == null) { | ||
GroovyLog.msg("Error adding Aether accessory") | ||
.add(accessoryType == null, "type with name {} does not exist. Valid values are {}.", type, Arrays.toString(AccessoryType.values())) | ||
.error() | ||
.post(); | ||
return; | ||
} | ||
AetherAccessory accessory = new AetherAccessory(item, accessoryType); | ||
add(accessory); | ||
} | ||
|
||
@MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("item('aether_legacy:iron_pendant')")) | ||
public void removeByInput(IIngredient input) { | ||
this.getRegistry().getValuesCollection().forEach(accessory -> { | ||
if (input.test(accessory.getAccessoryStack())) { | ||
remove(accessory); | ||
} | ||
}); | ||
} | ||
|
||
@RecipeBuilderDescription(example = @Example(".input(item('minecraft:shield')).accessoryType('shield')")) | ||
public RecipeBuilder recipeBuilder() { | ||
return new RecipeBuilder(); | ||
} | ||
|
||
@Property(property = "input", valid = @Comp("1")) | ||
public static class RecipeBuilder extends AbstractRecipeBuilder<AetherAccessory> { | ||
|
||
@Property | ||
private AccessoryType accessoryType; | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder accessoryType(String type) { | ||
accessoryType = EnumHelper.valueOfNullable(AccessoryType.class, type, false); | ||
return this; | ||
} | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder accessoryType(AccessoryType type) { | ||
accessoryType = type; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getErrorMsg() { | ||
return "Error adding Aether Accessory"; | ||
} | ||
|
||
@Override | ||
public void validate(GroovyLog.Msg msg) { | ||
validateItems(msg, 1, 1, 0, 0); | ||
validateFluids(msg); | ||
msg.add(accessoryType == null, "type with name {} does not exist. Valid values are {}.", accessoryType.toString(), Arrays.toString(AccessoryType.values())); | ||
} | ||
|
||
@RecipeBuilderRegistrationMethod | ||
@Override | ||
public @Nullable AetherAccessory register() { | ||
if (!validate()) return null; | ||
|
||
AetherAccessory accessory = new AetherAccessory(input.get(0).getMatchingStacks()[0], accessoryType); | ||
Aether.accessory.add(accessory); | ||
return accessory; | ||
} | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Aether.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,21 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.aetherlegacy; | ||
|
||
import com.cleanroommc.groovyscript.compat.mods.ModPropertyContainer; | ||
|
||
public class Aether extends ModPropertyContainer { | ||
|
||
public static final Enchanter enchanter = new Enchanter(); | ||
public static final EnchanterFuel enchanterFuel = new EnchanterFuel(); | ||
public static final Freezer freezer = new Freezer(); | ||
public static final FreezerFuel freezerFuel = new FreezerFuel(); | ||
public static final Accessory accessory = new Accessory(); | ||
|
||
public Aether() { | ||
addRegistry(enchanter); | ||
addRegistry(enchanterFuel); | ||
addRegistry(freezer); | ||
addRegistry(freezerFuel); | ||
addRegistry(accessory); | ||
} | ||
|
||
} |
77 changes: 77 additions & 0 deletions
77
src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Enchanter.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,77 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.aetherlegacy; | ||
|
||
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.recipe.AbstractRecipeBuilder; | ||
import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; | ||
import com.gildedgames.the_aether.api.enchantments.AetherEnchantment; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.fml.common.registry.GameRegistry; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@RegistryDescription | ||
public class Enchanter extends ForgeRegistryWrapper<AetherEnchantment> { | ||
|
||
public Enchanter() { | ||
super(GameRegistry.findRegistry(AetherEnchantment.class), Alias.generateOfClass(Enchanter.class)); | ||
} | ||
|
||
@RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).time(200)")) | ||
public RecipeBuilder recipeBuilder() { | ||
return new RecipeBuilder(); | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.ADDITION) | ||
public void add(ItemStack input, ItemStack output, int timeRequired) { | ||
AetherEnchantment enchantment = new AetherEnchantment(input, output, timeRequired); | ||
add(enchantment); | ||
} | ||
|
||
@MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('aether_legacy:enchanted_gravitite')")) | ||
public void removeByOutput(IIngredient output) { | ||
this.getRegistry().getValuesCollection().forEach(enchantment -> { | ||
if (output.test(enchantment.getOutput())) { | ||
remove(enchantment); | ||
} | ||
}); | ||
} | ||
|
||
@Property(property = "input", valid = @Comp("1")) | ||
@Property(property = "output", valid = @Comp("1")) | ||
public static class RecipeBuilder extends AbstractRecipeBuilder<AetherEnchantment> { | ||
|
||
@Property(valid = @Comp(type = Comp.Type.GTE, value = "0")) | ||
private int time; | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder time(int time) { | ||
this.time = time; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getErrorMsg() { | ||
return "Error adding Aether Enchanter Recipe"; | ||
} | ||
|
||
@Override | ||
public void validate(GroovyLog.Msg msg) { | ||
validateItems(msg, 1, 1, 1, 1); | ||
validateFluids(msg); | ||
msg.add(time < 0, "time must be a non-negative integer, yet it was {}", time); | ||
} | ||
|
||
@RecipeBuilderRegistrationMethod | ||
@Override | ||
public @Nullable AetherEnchantment register() { | ||
if (!validate()) return null; | ||
|
||
AetherEnchantment enchantment = new AetherEnchantment(input.get(0).getMatchingStacks()[0], output.get(0), time); | ||
Aether.enchanter.add(enchantment); | ||
return enchantment; | ||
} | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/EnchanterFuel.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,34 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.aetherlegacy; | ||
|
||
import com.cleanroommc.groovyscript.api.IIngredient; | ||
import com.cleanroommc.groovyscript.api.documentation.annotations.Example; | ||
import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; | ||
import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; | ||
import com.cleanroommc.groovyscript.helper.Alias; | ||
import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; | ||
import com.gildedgames.the_aether.api.enchantments.AetherEnchantmentFuel; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.fml.common.registry.GameRegistry; | ||
|
||
@RegistryDescription | ||
public class EnchanterFuel extends ForgeRegistryWrapper<AetherEnchantmentFuel> { | ||
|
||
public EnchanterFuel() { | ||
super(GameRegistry.findRegistry(AetherEnchantmentFuel.class), Alias.generateOfClass(EnchanterFuel.class)); | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:blaze_rod'), 1000")) | ||
public void add(ItemStack fuel, int timeGiven) { | ||
AetherEnchantmentFuel enchantmentFuel = new AetherEnchantmentFuel(fuel, timeGiven); | ||
add(enchantmentFuel); | ||
} | ||
|
||
@MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("item('aether_legacy:ambrosium_shard')")) | ||
public void removeByItem(IIngredient fuel) { | ||
this.getRegistry().getValuesCollection().forEach(enchantmentFuel -> { | ||
if (fuel.test(enchantmentFuel.getFuelStack())) { | ||
remove(enchantmentFuel); | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.