Skip to content

Commit

Permalink
Aether Legacy Support (#126)
Browse files Browse the repository at this point in the history
* 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
mcadventurecity authored Mar 14, 2024
1 parent af72dac commit 4f106e3
Show file tree
Hide file tree
Showing 11 changed files with 424 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ dependencies {
runtimeOnly rfg.deobf('curse.maven:advancedmortars-283777:2780626')
}

compileOnly rfg.deobf('curse.maven:aether-255308:3280119')
if (project.debug_aether.toBoolean()) {
runtimeOnly rfg.deobf('curse.maven:aether-255308:3280119')
}

compileOnly rfg.deobf('curse.maven:pyrotech-306676:4956838')
compileOnly rfg.deobf('curse.maven:athenaeum-284350:4633750')

Expand All @@ -244,7 +249,6 @@ dependencies {
runtimeOnly rfg.deobf("curse.maven:dropt-284973:3758733")
}


}

minecraft {
Expand Down
63 changes: 63 additions & 0 deletions examples/postInit/aether_legacy.groovy
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)

1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Debug mod compat
debug_actually_additions = false
debug_adv_mortars = false
debug_aether = false
debug_applied_energistics_2 = false
debug_astral = false
debug_avaritia = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.cleanroommc.groovyscript.api.IDynamicGroovyProperty;
import com.cleanroommc.groovyscript.compat.mods.actuallyadditions.ActuallyAdditions;
import com.cleanroommc.groovyscript.compat.mods.advancedmortars.AdvancedMortars;
import com.cleanroommc.groovyscript.compat.mods.aetherlegacy.Aether;
import com.cleanroommc.groovyscript.compat.mods.appliedenergistics2.AppliedEnergistics2;
import com.cleanroommc.groovyscript.compat.mods.astralsorcery.AstralSorcery;
import com.cleanroommc.groovyscript.compat.mods.avaritia.Avaritia;
Expand Down Expand Up @@ -52,6 +53,7 @@ public class ModSupport implements IDynamicGroovyProperty {

public static final GroovyContainer<ActuallyAdditions> ACTUALLY_ADDITIONS = new InternalModContainer<>("actuallyadditions", "Actually Additions", ActuallyAdditions::new, "aa");
public static final GroovyContainer<AdvancedMortars> ADVANCED_MORTARS = new InternalModContainer<>("advancedmortars", "Advanced Mortars", AdvancedMortars::new);
public static final GroovyContainer<Aether> AETHER = new InternalModContainer<>("aether_legacy", "The Aether", Aether::new, "aether");
public static final GroovyContainer<AppliedEnergistics2> APPLIED_ENERGISTICS_2 = new InternalModContainer<>("appliedenergistics2", "Applied Energistics 2", AppliedEnergistics2::new, "ae2");
public static final GroovyContainer<AstralSorcery> ASTRAL_SORCERY = new InternalModContainer<>("astralsorcery", "Astral Sorcery", AstralSorcery::new, "astral");
public static final GroovyContainer<Avaritia> AVARITIA = new InternalModContainer<>("avaritia", "Avaritia", Avaritia::new);
Expand Down
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;
}
}

}
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);
}

}
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;
}
}

}
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);
}
});
}
}
Loading

0 comments on commit 4f106e3

Please sign in to comment.