mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-12-22 14:59:22 +01:00
crafttweaker!
This commit is contained in:
parent
ac9b248e84
commit
15f067a1c9
15 changed files with 180 additions and 304 deletions
|
@ -1,5 +1,7 @@
|
|||
# Editing Nature's Aura recipes with CraftTweaker
|
||||
Note that both [CraftTweaker](https://minecraft.curseforge.com/projects/crafttweaker) and [MTLib](https://minecraft.curseforge.com/projects/mtlib) are required for this compatibility.
|
||||
Note that [CraftTweaker](https://minecraft.curseforge.com/projects/crafttweaker) is required for this compatibility.
|
||||
|
||||
***This documentation is for 1.15. For the 1.12 documentation, [click here](https://github.com/Ellpeck/NaturesAura/blob/1.12/CraftTweakerCompat.md).***
|
||||
|
||||
A few notes that apply for most of the recipe types:
|
||||
- If you don't know how the CraftTweaker syntax works, [read up on it](https://docs.blamejared.com/en/#Getting_Started/) first.
|
||||
|
@ -14,37 +16,54 @@ __The replacement recipe that is added for any given item inside of Nature's Aur
|
|||
|
||||
As an example, the following piece of code will remove the existing recipe of the Imperceptible Builder and replace it with a new one. Checking its Book of Natural Aura entry will then also display the new recipe correctly without errors.
|
||||
```
|
||||
recipes.remove(<naturesaura:placer>);
|
||||
recipes.addShapeless("placer", <naturesaura:placer>, [<naturesaura:infused_iron>, <minecraft:piston>]);
|
||||
recipes.remove(<item:naturesaura:placer>);
|
||||
recipes.addShapeless("placer", <item:naturesaura:placer>, [<item:naturesaura:infused_iron>, <item:minecraft:piston>]);
|
||||
```
|
||||
Note that the name of the recipe is supplied as `placer` because the item id of the Imperceptible Builder is `naturesaura:placer`. Not doing this would lead to the Book of Natural Aura not displaying the new recipe.
|
||||
|
||||
_When adding a new recipe without replacing an existing one, the name of the newly added recipe does not matter._
|
||||
|
||||
## Natural Altar
|
||||
`mods.naturesaura.Altar.addRecipe(String name, IIngredient input, IItemStack output, IIngredient catalyst, int aura, int time)`
|
||||
```zs
|
||||
mods.naturesaura.Altar.addRecipe(String name, IIngredient input, IItemStack output, String auraType, int aura, int time, IIngredient catalyst)
|
||||
```
|
||||
|
||||
- `auraType` is the type of aura required for this recipe. For the regular Natural Altar, use `naturesaura:overworld`. For the nether variant of the altar, use `naturesaura:nether`.
|
||||
- `catalyst` is the catalyst block that is placed on one of the four corner blocks, can be `null`
|
||||
|
||||
`mods.naturesaura.Altar.removeRecipe(IItemStack output)`
|
||||
```zs
|
||||
mods.naturesaura.Altar.removeRecipe(IItemStack output)
|
||||
```
|
||||
|
||||
## Altar of Birthing
|
||||
`mods.naturesaura.AnimalSpawner.addRecipe(String name, String entity, int aura, int time, IIngredient[] ingredients)`
|
||||
```zs
|
||||
mods.naturesaura.AnimalSpawner.addRecipe(String name, String entity, int aura, int time, IIngredient[] ingredients)
|
||||
```
|
||||
- `entity` is the registry name of the entity that you want to spawn
|
||||
|
||||
`mods.naturesaura.AnimalSpawner.removeRecipe(String name)`
|
||||
```zs
|
||||
mods.naturesaura.AnimalSpawner.removeRecipe(String name)
|
||||
```
|
||||
- `entity` is the registry name of the entity whose spawning recipe should be removed
|
||||
|
||||
## Offering to the Gods
|
||||
`mods.naturesaura.Offering.addRecipe(String name, IIngredient input, int inputAmount, IIngredient startItem, IItemStack output)`
|
||||
```zs
|
||||
mods.naturesaura.Offering.addRecipe(String name, IIngredient input, int inputAmount, IIngredient startItem, IItemStack output)
|
||||
```
|
||||
- `inputAmount` is the amount of items required for the input. Note that this means that the amount of the `input` variable is ignored
|
||||
- `startItem` is the item required to start the offering, should pretty much always be `naturesaura:calling_spirit`
|
||||
|
||||
`mods.naturesaura.Offering.removeRecipe(IItemStack output)`
|
||||
```zs
|
||||
mods.naturesaura.Offering.removeRecipe(IItemStack output)
|
||||
```
|
||||
|
||||
## Ritual of the Forest
|
||||
`mods.naturesaura.TreeRitual.addRecipe(String name, IIngredient saplingType, IItemStack result, int time, IIngredient[] items)`
|
||||
```zs
|
||||
mods.naturesaura.TreeRitual.addRecipe(String name, IIngredient saplingType, IItemStack result, int time, IIngredient[] items)
|
||||
```
|
||||
- `saplingType` is an item representation of the sapling that needs to be placed and grown into a tree
|
||||
- `items` are the items that need to be placed on the wooden stands
|
||||
|
||||
`mods.naturesaura.TreeRitual.removeRecipe(IItemStack output)`
|
||||
```zs
|
||||
mods.naturesaura.TreeRitual.removeRecipe(IItemStack output)
|
||||
```
|
|
@ -68,7 +68,7 @@ public final class NaturesAura {
|
|||
Helper.registerCap(IAuraChunk.class);
|
||||
Helper.registerCap(IWorldData.class);
|
||||
|
||||
Compat.preInit();
|
||||
Compat.setup();
|
||||
PacketHandler.init();
|
||||
new Multiblocks();
|
||||
|
||||
|
@ -87,7 +87,6 @@ public final class NaturesAura {
|
|||
}
|
||||
|
||||
private void postInit(FMLCommonSetupEvent event) {
|
||||
Compat.postInit();
|
||||
proxy.postInit(event);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package de.ellpeck.naturesaura.compat;
|
|||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.compat.crafttweaker.CraftTweakerCompat;
|
||||
import de.ellpeck.naturesaura.compat.enchantibility.EnchantibilityCompat;
|
||||
import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat;
|
||||
import de.ellpeck.naturesaura.data.ItemTagProvider;
|
||||
|
@ -18,22 +17,17 @@ public final class Compat {
|
|||
private static final Map<String, Supplier<ICompat>> MODULE_TYPES = ImmutableMap.<String, Supplier<ICompat>>builder()
|
||||
.put("patchouli", PatchouliCompat::new)
|
||||
.put("curios", CuriosCompat::new)
|
||||
.put("crafttweaker", CraftTweakerCompat::new)
|
||||
.put("enchantability", EnchantibilityCompat::new)
|
||||
.build();
|
||||
private static final Map<String, ICompat> MODULES = new HashMap<>();
|
||||
|
||||
public static void preInit() {
|
||||
public static void setup() {
|
||||
populateModules(ModList.get()::isLoaded);
|
||||
MODULES.values().forEach(ICompat::preInit);
|
||||
MODULES.values().forEach(ICompat::setup);
|
||||
}
|
||||
|
||||
public static void preInitClient() {
|
||||
MODULES.values().forEach(ICompat::preInitClient);
|
||||
}
|
||||
|
||||
public static void postInit() {
|
||||
MODULES.values().forEach(ICompat::postInit);
|
||||
public static void setupClient() {
|
||||
MODULES.values().forEach(ICompat::setupClient);
|
||||
}
|
||||
|
||||
public static boolean hasCompat(String mod) {
|
||||
|
|
|
@ -41,11 +41,16 @@ public class CuriosCompat implements ICompat {
|
|||
.build();
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
public void setup() {
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(this); // inter mod comms
|
||||
MinecraftForge.EVENT_BUS.register(this); // capabilities
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupClient() {
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void sendImc(InterModEnqueueEvent event) {
|
||||
TYPES.values().stream().distinct().forEach(t -> {
|
||||
|
@ -85,16 +90,6 @@ public class CuriosCompat implements ICompat {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInitClient() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItemTags(ItemTagProvider provider) {
|
||||
for (Map.Entry<Item, Tag<Item>> entry : TYPES.entrySet())
|
||||
|
|
|
@ -4,11 +4,9 @@ import de.ellpeck.naturesaura.data.ItemTagProvider;
|
|||
|
||||
public interface ICompat {
|
||||
|
||||
void preInit();
|
||||
void setup();
|
||||
|
||||
void preInitClient();
|
||||
|
||||
void postInit();
|
||||
void setupClient();
|
||||
|
||||
void addItemTags(ItemTagProvider provider);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package de.ellpeck.naturesaura.compat.crafttweaker;
|
||||
|
||||
import com.blamejared.crafttweaker.api.actions.IAction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class AddAction<T> implements IAction {
|
||||
|
||||
private final Map<ResourceLocation, T> registry;
|
||||
private final ResourceLocation res;
|
||||
private final T recipe;
|
||||
|
||||
public AddAction(Map<ResourceLocation, T> registry, ResourceLocation res, T recipe) {
|
||||
this.registry = registry;
|
||||
this.res = res;
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
this.registry.put(this.res, this.recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding recipe " + this.res;
|
||||
}
|
||||
}
|
|
@ -1,70 +1,40 @@
|
|||
/* TODO crafttweaker or whatever
|
||||
package de.ellpeck.naturesaura.compat.crafttweaker;
|
||||
|
||||
import com.blamejared.crafttweaker.api.CraftTweakerAPI;
|
||||
import com.blamejared.crafttweaker.api.annotations.ZenRegister;
|
||||
import com.blamejared.crafttweaker.api.item.IIngredient;
|
||||
import com.blamejared.crafttweaker.api.item.IItemStack;
|
||||
import com.blamejared.crafttweaker.api.minecraft.CraftTweakerMC;
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
|
||||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.openzen.zencode.java.ZenCodeType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@ZenRegister
|
||||
@Zen("mods." + NaturesAura.MOD_ID + ".Altar")
|
||||
@ZenCodeType.Name("mods." + NaturesAura.MOD_ID + ".Altar")
|
||||
public final class AltarTweaker {
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(String name, IIngredient input, IItemStack output, IIngredient catalyst, int aura, int time) {
|
||||
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> {
|
||||
ResourceLocation res = new ResourceLocation(Compat.CRAFT_TWEAKER, name);
|
||||
return new Add(Collections.singletonMap(res, new AltarRecipe(res,
|
||||
CraftTweakerMC.getIngredient(input),
|
||||
InputHelper.toStack(output),
|
||||
CraftTweakerMC.getIngredient(catalyst),
|
||||
aura, time)));
|
||||
});
|
||||
@ZenCodeType.Method
|
||||
public static void addRecipe(String name, IIngredient input, IItemStack output, String auraType, int aura, int time, @ZenCodeType.Optional IIngredient catalyst) {
|
||||
ResourceLocation res = new ResourceLocation("crafttweaker", name);
|
||||
CraftTweakerAPI.apply(new AddAction<>(NaturesAuraAPI.ALTAR_RECIPES, res, new AltarRecipe(res,
|
||||
input.asVanillaIngredient(),
|
||||
output.getInternal(),
|
||||
NaturesAuraAPI.AURA_TYPES.get(new ResourceLocation(auraType)),
|
||||
catalyst == null ? Ingredient.EMPTY : catalyst.asVanillaIngredient(),
|
||||
aura, time)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
@ZenCodeType.Method
|
||||
public static void removeRecipe(IItemStack output) {
|
||||
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> {
|
||||
Map<ResourceLocation, AltarRecipe> recipes = new HashMap<>();
|
||||
for (AltarRecipe recipe : NaturesAuraAPI.ALTAR_RECIPES.values())
|
||||
if (Helper.areItemsEqual(recipe.output, InputHelper.toStack(output), true))
|
||||
recipes.put(recipe.name, recipe);
|
||||
return new Remove(recipes);
|
||||
});
|
||||
}
|
||||
|
||||
private static class Add extends BaseMapAddition<ResourceLocation, AltarRecipe> {
|
||||
|
||||
protected Add(Map<ResourceLocation, AltarRecipe> map) {
|
||||
super("Natural Altar", NaturesAuraAPI.ALTAR_RECIPES, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Map.Entry<ResourceLocation, AltarRecipe> recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getValue().output);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends BaseMapRemoval<ResourceLocation, AltarRecipe> {
|
||||
|
||||
protected Remove(Map<ResourceLocation, AltarRecipe> map) {
|
||||
super("Natural Altar", NaturesAuraAPI.ALTAR_RECIPES, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Map.Entry<ResourceLocation, AltarRecipe> recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getValue().output);
|
||||
}
|
||||
List<ResourceLocation> recipes = new ArrayList<>();
|
||||
for (AltarRecipe recipe : NaturesAuraAPI.ALTAR_RECIPES.values())
|
||||
if (Helper.areItemsEqual(recipe.output, output.getInternal(), true))
|
||||
recipes.add(recipe.name);
|
||||
CraftTweakerAPI.apply(new RemoveAction(NaturesAuraAPI.ALTAR_RECIPES, recipes));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -1,68 +1,35 @@
|
|||
/* TODO crafttweaker
|
||||
package de.ellpeck.naturesaura.compat.crafttweaker;
|
||||
|
||||
import com.blamejared.mtlib.utils.BaseMapAddition;
|
||||
import com.blamejared.mtlib.utils.BaseMapRemoval;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.minecraft.CraftTweakerMC;
|
||||
import com.blamejared.crafttweaker.api.CraftTweakerAPI;
|
||||
import com.blamejared.crafttweaker.api.annotations.ZenRegister;
|
||||
import com.blamejared.crafttweaker.api.item.IIngredient;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe;
|
||||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.openzen.zencode.java.ZenCodeType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenRegister
|
||||
@ZenClass("mods." + NaturesAura.MOD_ID + ".AnimalSpawner")
|
||||
@ZenCodeType.Name("mods." + NaturesAura.MOD_ID + ".AnimalSpawner")
|
||||
public final class AnimalSpawnerTweaker {
|
||||
|
||||
@ZenMethod
|
||||
@ZenCodeType.Method
|
||||
public static void addRecipe(String name, String entity, int aura, int time, IIngredient[] ingredients) {
|
||||
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> {
|
||||
ResourceLocation res = new ResourceLocation(Compat.CRAFT_TWEAKER, name);
|
||||
return new Add(Collections.singletonMap(res, new AnimalSpawnerRecipe(res, new ResourceLocation(entity), aura, time,
|
||||
Arrays.stream(ingredients).map(CraftTweakerMC::getIngredient).toArray(Ingredient[]::new)
|
||||
)));
|
||||
});
|
||||
ResourceLocation res = new ResourceLocation("crafttweaker", name);
|
||||
CraftTweakerAPI.apply(new AddAction<>(NaturesAuraAPI.ANIMAL_SPAWNER_RECIPES, res, new AnimalSpawnerRecipe(res,
|
||||
ForgeRegistries.ENTITIES.getValue(new ResourceLocation(entity)), aura, time,
|
||||
Arrays.stream(ingredients).map(IIngredient::asVanillaIngredient).toArray(Ingredient[]::new))));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
@ZenCodeType.Method
|
||||
public static void removeRecipe(String name) {
|
||||
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> {
|
||||
ResourceLocation res = new ResourceLocation(name);
|
||||
return new Remove(Collections.singletonMap(res, NaturesAuraAPI.ANIMAL_SPAWNER_RECIPES.get(res)));
|
||||
});
|
||||
}
|
||||
|
||||
private static class Add extends BaseMapAddition<ResourceLocation, AnimalSpawnerRecipe> {
|
||||
|
||||
protected Add(Map<ResourceLocation, AnimalSpawnerRecipe> map) {
|
||||
super("AnimalSpawner", NaturesAuraAPI.ANIMAL_SPAWNER_RECIPES, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Map.Entry<ResourceLocation, AnimalSpawnerRecipe> recipe) {
|
||||
return recipe.getValue().name.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends BaseMapRemoval<ResourceLocation, AnimalSpawnerRecipe> {
|
||||
|
||||
protected Remove(Map<ResourceLocation, AnimalSpawnerRecipe> map) {
|
||||
super("AnimalSpawner", NaturesAuraAPI.ANIMAL_SPAWNER_RECIPES, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Map.Entry<ResourceLocation, AnimalSpawnerRecipe> recipe) {
|
||||
return recipe.getValue().name.toString();
|
||||
}
|
||||
CraftTweakerAPI.apply(new RemoveAction(NaturesAuraAPI.ANIMAL_SPAWNER_RECIPES, Collections.singletonList(new ResourceLocation(name))));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
package de.ellpeck.naturesaura.compat.crafttweaker;
|
||||
|
||||
import com.blamejared.crafttweaker.api.CraftTweakerAPI;
|
||||
import com.blamejared.crafttweaker.api.actions.IAction;
|
||||
import de.ellpeck.naturesaura.compat.ICompat;
|
||||
import de.ellpeck.naturesaura.data.ItemTagProvider;
|
||||
import net.minecraftforge.fml.DeferredWorkQueue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class CraftTweakerCompat implements ICompat {
|
||||
|
||||
public static final List<Supplier<IAction>> SCHEDULED_ACTIONS = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInitClient() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
DeferredWorkQueue.runLater(() -> {
|
||||
for (Supplier<IAction> action : SCHEDULED_ACTIONS)
|
||||
CraftTweakerAPI.apply(action.get());
|
||||
SCHEDULED_ACTIONS.clear();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItemTags(ItemTagProvider provider) {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,14 +1,9 @@
|
|||
/* TODO crafttweaker
|
||||
package de.ellpeck.naturesaura.compat.crafttweaker;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.utils.BaseMapAddition;
|
||||
import com.blamejared.mtlib.utils.BaseMapRemoval;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.minecraft.CraftTweakerMC;
|
||||
import com.blamejared.crafttweaker.api.CraftTweakerAPI;
|
||||
import com.blamejared.crafttweaker.api.annotations.ZenRegister;
|
||||
import com.blamejared.crafttweaker.api.item.IIngredient;
|
||||
import com.blamejared.crafttweaker.api.item.IItemStack;
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
|
@ -16,61 +11,29 @@ import de.ellpeck.naturesaura.api.recipes.OfferingRecipe;
|
|||
import de.ellpeck.naturesaura.api.recipes.ing.AmountIngredient;
|
||||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import org.openzen.zencode.java.ZenCodeType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@ZenRegister
|
||||
@ZenClass("mods." + NaturesAura.MOD_ID + ".Offering")
|
||||
@ZenCodeType.Name("mods." + NaturesAura.MOD_ID + ".Offering")
|
||||
public final class OfferingTweaker {
|
||||
|
||||
@ZenMethod
|
||||
@ZenCodeType.Method
|
||||
public static void addRecipe(String name, IIngredient input, int inputAmount, IIngredient startItem, IItemStack output) {
|
||||
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> {
|
||||
ResourceLocation res = new ResourceLocation(Compat.CRAFT_TWEAKER, name);
|
||||
return new Add(Collections.singletonMap(res, new OfferingRecipe(res,
|
||||
new AmountIngredient(CraftTweakerMC.getIngredient(input), inputAmount),
|
||||
CraftTweakerMC.getIngredient(startItem),
|
||||
InputHelper.toStack(output))));
|
||||
});
|
||||
ResourceLocation res = new ResourceLocation("crafttweaker", name);
|
||||
CraftTweakerAPI.apply(new AddAction<>(NaturesAuraAPI.OFFERING_RECIPES, res, new OfferingRecipe(res,
|
||||
new AmountIngredient(input.asVanillaIngredient(), inputAmount),
|
||||
startItem.asVanillaIngredient(),
|
||||
output.getInternal())));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
@ZenCodeType.Method
|
||||
public static void removeRecipe(IItemStack output) {
|
||||
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> {
|
||||
Map<ResourceLocation, OfferingRecipe> recipes = new HashMap<>();
|
||||
for (OfferingRecipe recipe : NaturesAuraAPI.OFFERING_RECIPES.values())
|
||||
if (Helper.areItemsEqual(recipe.output, InputHelper.toStack(output), true))
|
||||
recipes.put(recipe.name, recipe);
|
||||
return new Remove(recipes);
|
||||
});
|
||||
}
|
||||
|
||||
private static class Add extends BaseMapAddition<ResourceLocation, OfferingRecipe> {
|
||||
|
||||
protected Add(Map<ResourceLocation, OfferingRecipe> map) {
|
||||
super("Offering", NaturesAuraAPI.OFFERING_RECIPES, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Map.Entry<ResourceLocation, OfferingRecipe> recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getValue().output);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends BaseMapRemoval<ResourceLocation, OfferingRecipe> {
|
||||
|
||||
protected Remove(Map<ResourceLocation, OfferingRecipe> map) {
|
||||
super("Offering", NaturesAuraAPI.OFFERING_RECIPES, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Map.Entry<ResourceLocation, OfferingRecipe> recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getValue().output);
|
||||
}
|
||||
List<ResourceLocation> recipes = new ArrayList<>();
|
||||
for (OfferingRecipe recipe : NaturesAuraAPI.OFFERING_RECIPES.values())
|
||||
if (Helper.areItemsEqual(recipe.output, output.getInternal(), true))
|
||||
recipes.add(recipe.name);
|
||||
CraftTweakerAPI.apply(new RemoveAction(NaturesAuraAPI.OFFERING_RECIPES, recipes));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package de.ellpeck.naturesaura.compat.crafttweaker;
|
||||
|
||||
import com.blamejared.crafttweaker.api.actions.IAction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class RemoveAction implements IAction {
|
||||
private final Map<ResourceLocation, ?> registry;
|
||||
private final List<ResourceLocation> recipes;
|
||||
|
||||
public RemoveAction(Map<ResourceLocation, ?> registry, List<ResourceLocation> recipes) {
|
||||
this.registry = registry;
|
||||
this.recipes = recipes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (ResourceLocation recipe : this.recipes)
|
||||
this.registry.remove(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing recipes " + this.recipes;
|
||||
}
|
||||
}
|
|
@ -1,14 +1,9 @@
|
|||
/*
|
||||
package de.ellpeck.naturesaura.compat.crafttweaker;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.utils.BaseMapAddition;
|
||||
import com.blamejared.mtlib.utils.BaseMapRemoval;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.minecraft.CraftTweakerMC;
|
||||
import com.blamejared.crafttweaker.api.CraftTweakerAPI;
|
||||
import com.blamejared.crafttweaker.api.annotations.ZenRegister;
|
||||
import com.blamejared.crafttweaker.api.item.IIngredient;
|
||||
import com.blamejared.crafttweaker.api.item.IItemStack;
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
|
@ -16,64 +11,31 @@ import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
|
|||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import org.openzen.zencode.java.ZenCodeType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@ZenRegister
|
||||
@ZenClass("mods." + NaturesAura.MOD_ID + ".TreeRitual")
|
||||
@ZenCodeType.Name("mods." + NaturesAura.MOD_ID + ".TreeRitual")
|
||||
public final class TreeRitualTweaker {
|
||||
|
||||
@ZenMethod
|
||||
@ZenCodeType.Method
|
||||
public static void addRecipe(String name, IIngredient saplingType, IItemStack result, int time, IIngredient[] items) {
|
||||
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> {
|
||||
ResourceLocation res = new ResourceLocation(Compat.CRAFT_TWEAKER, name);
|
||||
return new Add(Collections.singletonMap(res, new TreeRitualRecipe(res,
|
||||
CraftTweakerMC.getIngredient(saplingType),
|
||||
InputHelper.toStack(result),
|
||||
time,
|
||||
Arrays.stream(items).map(CraftTweakerMC::getIngredient).toArray(Ingredient[]::new)
|
||||
)));
|
||||
});
|
||||
ResourceLocation res = new ResourceLocation("crafttweaker", name);
|
||||
CraftTweakerAPI.apply(new AddAction<>(NaturesAuraAPI.TREE_RITUAL_RECIPES, res, new TreeRitualRecipe(res,
|
||||
saplingType.asVanillaIngredient(),
|
||||
result.getInternal(),
|
||||
time,
|
||||
Arrays.stream(items).map(IIngredient::asVanillaIngredient).toArray(Ingredient[]::new)
|
||||
)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
@ZenCodeType.Method
|
||||
public static void removeRecipe(IItemStack output) {
|
||||
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> {
|
||||
Map<ResourceLocation, TreeRitualRecipe> recipes = new HashMap<>();
|
||||
for (TreeRitualRecipe recipe : NaturesAuraAPI.TREE_RITUAL_RECIPES.values())
|
||||
if (Helper.areItemsEqual(recipe.result, InputHelper.toStack(output), true))
|
||||
recipes.put(recipe.name, recipe);
|
||||
return new Remove(recipes);
|
||||
});
|
||||
}
|
||||
|
||||
private static class Add extends BaseMapAddition<ResourceLocation, TreeRitualRecipe> {
|
||||
|
||||
protected Add(Map<ResourceLocation, TreeRitualRecipe> map) {
|
||||
super("Tree Ritual", NaturesAuraAPI.TREE_RITUAL_RECIPES, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Map.Entry<ResourceLocation, TreeRitualRecipe> recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getValue().result);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends BaseMapRemoval<ResourceLocation, TreeRitualRecipe> {
|
||||
|
||||
protected Remove(Map<ResourceLocation, TreeRitualRecipe> map) {
|
||||
super("Tree Ritual", NaturesAuraAPI.TREE_RITUAL_RECIPES, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Map.Entry<ResourceLocation, TreeRitualRecipe> recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getValue().result);
|
||||
}
|
||||
List<ResourceLocation> recipes = new ArrayList<>();
|
||||
for (TreeRitualRecipe recipe : NaturesAuraAPI.TREE_RITUAL_RECIPES.values())
|
||||
if (Helper.areItemsEqual(recipe.result, output.getInternal(), true))
|
||||
recipes.add(recipe.name);
|
||||
CraftTweakerAPI.apply(new RemoveAction(NaturesAuraAPI.TREE_RITUAL_RECIPES, recipes));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Collections;
|
|||
|
||||
public class EnchantibilityCompat implements ICompat {
|
||||
@Override
|
||||
public void preInit() {
|
||||
public void setup() {
|
||||
DeferredWorkQueue.runLater(() -> {
|
||||
IInternals api = EnchantabilityApi.getInstance();
|
||||
api.registerEnchantEffect(EnchantibilityAuraMending.RES, ModEnchantments.AURA_MENDING, EnchantibilityAuraMending::new);
|
||||
|
@ -21,12 +21,7 @@ public class EnchantibilityCompat implements ICompat {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void preInitClient() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
public void setupClient() {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class PatchouliCompat implements ICompat {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
public void setup() {
|
||||
DeferredWorkQueue.runLater(() -> {
|
||||
PatchouliAPI.instance.setConfigFlag(NaturesAura.MOD_ID + ":rf_converter", ModConfig.instance.rfConverter.get());
|
||||
PatchouliAPI.instance.setConfigFlag(NaturesAura.MOD_ID + ":chunk_loader", ModConfig.instance.chunkLoader.get());
|
||||
|
@ -64,7 +64,7 @@ public class PatchouliCompat implements ICompat {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void preInitClient() {
|
||||
public void setupClient() {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
|
@ -73,11 +73,6 @@ public class PatchouliCompat implements ICompat {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void onBookDraw(BookDrawScreenEvent event) {
|
||||
|
|
|
@ -39,7 +39,7 @@ public class ClientProxy implements IProxy {
|
|||
@Override
|
||||
public void preInit(FMLCommonSetupEvent event) {
|
||||
MinecraftForge.EVENT_BUS.register(new ClientEvents());
|
||||
Compat.preInitClient();
|
||||
Compat.setupClient();
|
||||
ScreenManager.registerFactory(ModContainers.ENDER_CRATE, GuiEnderCrate::new);
|
||||
ScreenManager.registerFactory(ModContainers.ENDER_ACCESS, GuiEnderCrate::new);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue