generated from CleanroomMC/TemplateDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add EssentialCraft 4 compatibility (#176)
* added essentialcraft compatibility * ec4: addressed the PR questions * ec4: addressed more PR questions * ec4: extensively mixin Magmatic to fix crashes * ec4: pr fixes * ec4: pr fixes
- Loading branch information
1 parent
3c0af9b
commit 9005864
Showing
17 changed files
with
901 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,91 @@ | ||
|
||
// Auto generated groovyscript example file | ||
// MODS_LOADED: essentialcraft | ||
|
||
println 'mod \'essentialcraft\' detected, running script' | ||
|
||
// Demon Trade: | ||
// Adds an item that can be sold to Demons to obtain Ackronite. Note that each demon that spawns has a random item that it | ||
// can accept, and will not accept any other item. | ||
|
||
mods.essentialcraft.demon_trade.remove(entity('minecraft:enderman')) | ||
mods.essentialcraft.demon_trade.remove(item('minecraft:nether_star')) | ||
// mods.essentialcraft.demon_trade.removeAll() | ||
|
||
mods.essentialcraft.demon_trade.add(entity('minecraft:chicken')) | ||
mods.essentialcraft.demon_trade.add(item('minecraft:diamond')) | ||
|
||
// Magician Table: | ||
// A 5-slot processing machine using MRU. Can be upgraded with various plates to increase its speed. | ||
|
||
mods.essentialcraft.magician_table.removeByOutput(item('essentialcraft:genitem')) | ||
// mods.essentialcraft.magician_table.removeAll() | ||
|
||
mods.essentialcraft.magician_table.recipeBuilder() | ||
.input(item('minecraft:diamond'), ore('ingotGold'), ore('ingotGold'), ore('stickWood'), ore('stickWood')) | ||
.output(item('minecraft:iron_ingot')) | ||
.mru(500) | ||
.register() | ||
|
||
|
||
// Magmatic Smeltery: | ||
// A machine used to quadruple ores using MRU and lava. Also adds the same recipes for Magmatic Furnace, which is used to | ||
// double ores using MRU. | ||
|
||
mods.essentialcraft.magmatic_smeltery.removeByInput(ore('oreIron')) | ||
mods.essentialcraft.magmatic_smeltery.removeByInput('oreDiamond') | ||
// mods.essentialcraft.magmatic_smeltery.removeAll() | ||
|
||
mods.essentialcraft.magmatic_smeltery.recipeBuilder() | ||
.input('blockIron') | ||
.output('ingotGold') | ||
.factor(3) | ||
.color(0x0000ff) | ||
.register() | ||
|
||
|
||
// Mithriline Furnace: | ||
// Converts various items into other items using ESPE. | ||
|
||
mods.essentialcraft.mithriline_furnace.removeByInput(ore('dustGlowstone')) | ||
mods.essentialcraft.mithriline_furnace.removeByOutput(item('minecraft:emerald')) | ||
// mods.essentialcraft.mithriline_furnace.removeAll() | ||
|
||
mods.essentialcraft.mithriline_furnace.recipeBuilder() | ||
.input(item('minecraft:coal_block') * 3) | ||
.output(item('minecraft:diamond_block')) | ||
.espe(500) | ||
.register() | ||
|
||
|
||
// Radiating Chamber: | ||
// Combines two items together using MRU to obtain a third item. Can optionally require a specific range of MRU balance to | ||
// execute the recipe. | ||
|
||
mods.essentialcraft.radiating_chamber.removeByOutput(item('essentialcraft:genitem', 42)) | ||
// mods.essentialcraft.radiating_chamber.removeAll() | ||
|
||
mods.essentialcraft.radiating_chamber.recipeBuilder() | ||
.input(item('minecraft:nether_star'), item('minecraft:stone')) | ||
.output(item('minecraft:beacon')) | ||
.time(100) | ||
.mruPerTick(10.0f) | ||
.upperBalance(1.5f) | ||
.lowerBalance(0.25f) | ||
.register() | ||
|
||
|
||
// Wind Rune: | ||
// Transforms various items using ESPE. | ||
|
||
mods.essentialcraft.wind_rune.removeByInput(item('minecraft:diamond')) | ||
mods.essentialcraft.wind_rune.removeByOutput(item('essentialcraft:air_potion')) | ||
// mods.essentialcraft.wind_rune.removeAll() | ||
|
||
mods.essentialcraft.wind_rune.recipeBuilder() | ||
.input(item('minecraft:gold_block')) | ||
.output(item('minecraft:diamond_block')) | ||
.espe(500) | ||
.register() | ||
|
||
|
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
91 changes: 91 additions & 0 deletions
91
src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/DemonTradeManager.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,91 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.essentialcraft; | ||
|
||
import com.cleanroommc.groovyscript.api.IIngredient; | ||
import com.cleanroommc.groovyscript.api.documentation.annotations.Admonition; | ||
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.helper.SimpleObjectStream; | ||
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; | ||
import net.minecraft.item.ItemStack; | ||
import essentialcraft.api.DemonTrade; | ||
import net.minecraftforge.fml.common.registry.EntityEntry; | ||
|
||
@RegistryDescription( | ||
category = RegistryDescription.Category.ENTRIES, | ||
admonition = @Admonition(value = "groovyscript.wiki.essentialcraft.demon_trade.note0", type = Admonition.Type.DANGER)) | ||
public class DemonTradeManager extends VirtualizedRegistry<DemonTrade> { | ||
public DemonTradeManager() { | ||
super(Alias.generateOf("DemonTrade")); | ||
} | ||
|
||
@Override | ||
public void onReload() { | ||
removeScripted().forEach(DemonTrade::removeTrade); | ||
restoreFromBackup().forEach(r -> { | ||
DemonTrade.TRADES.add(r); | ||
if (r.desiredItem.isEmpty()) { | ||
DemonTrade.ALL_MOBS.add(r.entityType); | ||
} | ||
}); | ||
} | ||
|
||
@MethodDescription(example = @Example("item('minecraft:diamond')"), type = MethodDescription.Type.ADDITION) | ||
public void add(IIngredient x) { | ||
for (ItemStack it : x.getMatchingStacks()) { | ||
DemonTrade t = new DemonTrade(it); // this automatically registers the trade | ||
addScripted(t); | ||
} | ||
} | ||
|
||
@MethodDescription(example = @Example("entity('minecraft:chicken')"), type = MethodDescription.Type.ADDITION) | ||
public void add(EntityEntry x) { | ||
DemonTrade t = new DemonTrade(x); // this automatically registers the trade | ||
addScripted(t); | ||
} | ||
|
||
@MethodDescription(example = @Example("item('minecraft:nether_star')")) | ||
public boolean remove(IIngredient x) { | ||
return DemonTrade.TRADES.removeIf(r -> { | ||
if (!r.desiredItem.isEmpty() && x.test(r.desiredItem)) { | ||
addBackup(r); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@MethodDescription(description = "groovyscript.wiki.essentialcraft.demon_trade.removeEntity", example = @Example("entity('minecraft:enderman')")) | ||
public boolean remove(EntityEntry x) { | ||
return DemonTrade.TRADES.removeIf(r -> { | ||
if (r.desiredItem.isEmpty() && x.equals(r.entityType)) { | ||
addBackup(r); | ||
DemonTrade.ALL_MOBS.remove(r.entityType); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
private boolean remove(DemonTrade t) { | ||
if (DemonTrade.TRADES.stream().anyMatch(r -> r.equals(t))) { | ||
addBackup(t); | ||
DemonTrade.removeTrade(t); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@MethodDescription(priority = 2000, example = @Example(commented = true)) | ||
public void removeAll() { | ||
DemonTrade.TRADES.forEach(this::addBackup); | ||
DemonTrade.TRADES.clear(); | ||
DemonTrade.ALL_MOBS.clear(); | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.QUERY) | ||
public SimpleObjectStream<DemonTrade> streamRecipes() { | ||
return new SimpleObjectStream<>(DemonTrade.TRADES).setRemover(this::remove); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/EssentialCraft.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.essentialcraft; | ||
|
||
import com.cleanroommc.groovyscript.compat.mods.ModPropertyContainer; | ||
|
||
public class EssentialCraft extends ModPropertyContainer { | ||
public final DemonTradeManager demonTrade = new DemonTradeManager(); | ||
public final MagicianTable magicianTable = new MagicianTable(); | ||
public final MagmaticSmeltery magmaticSmeltery = new MagmaticSmeltery(); | ||
public final MithrilineFurnace mithrilineFurnace = new MithrilineFurnace(); | ||
public final RadiatingChamber radiatingChamber = new RadiatingChamber(); | ||
public final WindRune windRune = new WindRune(); | ||
|
||
public EssentialCraft() { | ||
addRegistry(demonTrade); | ||
addRegistry(magicianTable); | ||
addRegistry(magmaticSmeltery); | ||
addRegistry(mithrilineFurnace); | ||
addRegistry(radiatingChamber); | ||
addRegistry(windRune); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/MagicianTable.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,89 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.essentialcraft; | ||
|
||
import com.cleanroommc.groovyscript.api.GroovyLog; | ||
import com.cleanroommc.groovyscript.api.IIngredient; | ||
import com.cleanroommc.groovyscript.api.documentation.annotations.*; | ||
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 essentialcraft.api.MagicianTableRecipe; | ||
import essentialcraft.api.MagicianTableRecipes; | ||
import net.minecraft.item.crafting.Ingredient; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.essentialcraft.magician_table.note0", type = Admonition.Type.WARNING)) | ||
public class MagicianTable extends VirtualizedRegistry<MagicianTableRecipe> { | ||
|
||
@RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond'), ore('ingotGold'), ore('ingotGold'), ore('stickWood'), ore('stickWood')).output(item('minecraft:iron_ingot')).mru(500)")) | ||
public MagicianTable.RecipeBuilder recipeBuilder() { | ||
return new MagicianTable.RecipeBuilder(); | ||
} | ||
|
||
@Override | ||
public void onReload() { | ||
removeScripted().forEach(MagicianTableRecipes::removeRecipe); | ||
restoreFromBackup().forEach(MagicianTableRecipes::addRecipe); | ||
} | ||
|
||
@MethodDescription(example = @Example("item('essentialcraft:genitem')")) | ||
public boolean removeByOutput(IIngredient x) { | ||
return MagicianTableRecipes.RECIPES.removeIf(r -> { | ||
if (x.test(r.getRecipeOutput())) { | ||
addBackup(r); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@MethodDescription(priority = 2000, example = @Example(commented = true)) | ||
public void removeAll() { | ||
MagicianTableRecipes.RECIPES.forEach(this::addBackup); | ||
MagicianTableRecipes.RECIPES.clear(); | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.QUERY) | ||
public SimpleObjectStream<MagicianTableRecipe> streamRecipes() { | ||
return new SimpleObjectStream<>(MagicianTableRecipes.RECIPES).setRemover(r -> { | ||
addBackup(r); | ||
return MagicianTableRecipes.RECIPES.remove(r); | ||
}); | ||
} | ||
|
||
@Property(property = "input", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "5", type = Comp.Type.LTE)}) | ||
@Property(property = "output", valid = @Comp("1")) | ||
public static class RecipeBuilder extends AbstractRecipeBuilder<MagicianTableRecipe> { | ||
@Property(valid = @Comp(type = Comp.Type.GTE, value = "1")) | ||
private int mru; | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder mru(int cost) { | ||
mru = cost; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getErrorMsg() { | ||
return "Error adding Magician Table Recipe"; | ||
} | ||
|
||
@Override | ||
public void validate(GroovyLog.Msg msg) { | ||
validateItems(msg, 1, 5, 1, 1); | ||
validateFluids(msg); | ||
msg.add(mru < 1, "mru cost must be 1 or greater, got {}", mru); | ||
} | ||
|
||
@Override | ||
@RecipeBuilderRegistrationMethod | ||
public @Nullable MagicianTableRecipe register() { | ||
if (!validate()) return null; | ||
Ingredient[] inputIngredient = input.stream().map(IIngredient::toMcIngredient).toArray(Ingredient[]::new); | ||
MagicianTableRecipe recipe = new MagicianTableRecipe(inputIngredient, output.get(0), mru); | ||
ModSupport.ESSENTIALCRAFT.get().magicianTable.addScripted(recipe); | ||
MagicianTableRecipes.addRecipe(recipe); | ||
return recipe; | ||
} | ||
} | ||
} |
Oops, something went wrong.