crafttweaker!

This commit is contained in:
Ellpeck 2020-04-26 20:40:28 +02:00
parent ac9b248e84
commit 15f067a1c9
15 changed files with 180 additions and 304 deletions

View file

@ -1,5 +1,7 @@
# Editing Nature's Aura recipes with CraftTweaker # 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: 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. - 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. 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.remove(<item:naturesaura:placer>);
recipes.addShapeless("placer", <naturesaura:placer>, [<naturesaura:infused_iron>, <minecraft:piston>]); 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. 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._ _When adding a new recipe without replacing an existing one, the name of the newly added recipe does not matter._
## Natural Altar ## 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` - `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 ## 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 - `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 - `entity` is the registry name of the entity whose spawning recipe should be removed
## Offering to the Gods ## 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 - `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` - `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 ## 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 - `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 - `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)
```

View file

@ -68,7 +68,7 @@ public final class NaturesAura {
Helper.registerCap(IAuraChunk.class); Helper.registerCap(IAuraChunk.class);
Helper.registerCap(IWorldData.class); Helper.registerCap(IWorldData.class);
Compat.preInit(); Compat.setup();
PacketHandler.init(); PacketHandler.init();
new Multiblocks(); new Multiblocks();
@ -87,7 +87,6 @@ public final class NaturesAura {
} }
private void postInit(FMLCommonSetupEvent event) { private void postInit(FMLCommonSetupEvent event) {
Compat.postInit();
proxy.postInit(event); proxy.postInit(event);
} }

View file

@ -2,7 +2,6 @@ package de.ellpeck.naturesaura.compat;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.compat.crafttweaker.CraftTweakerCompat;
import de.ellpeck.naturesaura.compat.enchantibility.EnchantibilityCompat; import de.ellpeck.naturesaura.compat.enchantibility.EnchantibilityCompat;
import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat; import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat;
import de.ellpeck.naturesaura.data.ItemTagProvider; 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() private static final Map<String, Supplier<ICompat>> MODULE_TYPES = ImmutableMap.<String, Supplier<ICompat>>builder()
.put("patchouli", PatchouliCompat::new) .put("patchouli", PatchouliCompat::new)
.put("curios", CuriosCompat::new) .put("curios", CuriosCompat::new)
.put("crafttweaker", CraftTweakerCompat::new)
.put("enchantability", EnchantibilityCompat::new) .put("enchantability", EnchantibilityCompat::new)
.build(); .build();
private static final Map<String, ICompat> MODULES = new HashMap<>(); private static final Map<String, ICompat> MODULES = new HashMap<>();
public static void preInit() { public static void setup() {
populateModules(ModList.get()::isLoaded); populateModules(ModList.get()::isLoaded);
MODULES.values().forEach(ICompat::preInit); MODULES.values().forEach(ICompat::setup);
} }
public static void preInitClient() { public static void setupClient() {
MODULES.values().forEach(ICompat::preInitClient); MODULES.values().forEach(ICompat::setupClient);
}
public static void postInit() {
MODULES.values().forEach(ICompat::postInit);
} }
public static boolean hasCompat(String mod) { public static boolean hasCompat(String mod) {

View file

@ -41,11 +41,16 @@ public class CuriosCompat implements ICompat {
.build(); .build();
@Override @Override
public void preInit() { public void setup() {
FMLJavaModLoadingContext.get().getModEventBus().register(this); // inter mod comms FMLJavaModLoadingContext.get().getModEventBus().register(this); // inter mod comms
MinecraftForge.EVENT_BUS.register(this); // capabilities MinecraftForge.EVENT_BUS.register(this); // capabilities
} }
@Override
public void setupClient() {
}
@SubscribeEvent @SubscribeEvent
public void sendImc(InterModEnqueueEvent event) { public void sendImc(InterModEnqueueEvent event) {
TYPES.values().stream().distinct().forEach(t -> { TYPES.values().stream().distinct().forEach(t -> {
@ -85,16 +90,6 @@ public class CuriosCompat implements ICompat {
} }
} }
@Override
public void preInitClient() {
}
@Override
public void postInit() {
}
@Override @Override
public void addItemTags(ItemTagProvider provider) { public void addItemTags(ItemTagProvider provider) {
for (Map.Entry<Item, Tag<Item>> entry : TYPES.entrySet()) for (Map.Entry<Item, Tag<Item>> entry : TYPES.entrySet())

View file

@ -4,11 +4,9 @@ import de.ellpeck.naturesaura.data.ItemTagProvider;
public interface ICompat { public interface ICompat {
void preInit(); void setup();
void preInitClient(); void setupClient();
void postInit();
void addItemTags(ItemTagProvider provider); void addItemTags(ItemTagProvider provider);
} }

View file

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

View file

@ -1,70 +1,40 @@
/* TODO crafttweaker or whatever
package de.ellpeck.naturesaura.compat.crafttweaker; package de.ellpeck.naturesaura.compat.crafttweaker;
import com.blamejared.crafttweaker.api.CraftTweakerAPI;
import com.blamejared.crafttweaker.api.annotations.ZenRegister; import com.blamejared.crafttweaker.api.annotations.ZenRegister;
import com.blamejared.crafttweaker.api.item.IIngredient; import com.blamejared.crafttweaker.api.item.IIngredient;
import com.blamejared.crafttweaker.api.item.IItemStack; import com.blamejared.crafttweaker.api.item.IItemStack;
import com.blamejared.crafttweaker.api.minecraft.CraftTweakerMC;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.recipes.AltarRecipe; 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 net.minecraft.util.ResourceLocation;
import org.openzen.zencode.java.ZenCodeType;
import java.util.Collections; import java.util.*;
import java.util.HashMap;
import java.util.Map;
@ZenRegister @ZenRegister
@Zen("mods." + NaturesAura.MOD_ID + ".Altar") @ZenCodeType.Name("mods." + NaturesAura.MOD_ID + ".Altar")
public final class AltarTweaker { public final class AltarTweaker {
@ZenMethod @ZenCodeType.Method
public static void addRecipe(String name, IIngredient input, IItemStack output, IIngredient catalyst, int aura, int time) { public static void addRecipe(String name, IIngredient input, IItemStack output, String auraType, int aura, int time, @ZenCodeType.Optional IIngredient catalyst) {
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> { ResourceLocation res = new ResourceLocation("crafttweaker", name);
ResourceLocation res = new ResourceLocation(Compat.CRAFT_TWEAKER, name); CraftTweakerAPI.apply(new AddAction<>(NaturesAuraAPI.ALTAR_RECIPES, res, new AltarRecipe(res,
return new Add(Collections.singletonMap(res, new AltarRecipe(res, input.asVanillaIngredient(),
CraftTweakerMC.getIngredient(input), output.getInternal(),
InputHelper.toStack(output), NaturesAuraAPI.AURA_TYPES.get(new ResourceLocation(auraType)),
CraftTweakerMC.getIngredient(catalyst), catalyst == null ? Ingredient.EMPTY : catalyst.asVanillaIngredient(),
aura, time))); aura, time)));
});
} }
@ZenMethod @ZenCodeType.Method
public static void removeRecipe(IItemStack output) { public static void removeRecipe(IItemStack output) {
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> { List<ResourceLocation> recipes = new ArrayList<>();
Map<ResourceLocation, AltarRecipe> recipes = new HashMap<>(); for (AltarRecipe recipe : NaturesAuraAPI.ALTAR_RECIPES.values())
for (AltarRecipe recipe : NaturesAuraAPI.ALTAR_RECIPES.values()) if (Helper.areItemsEqual(recipe.output, output.getInternal(), true))
if (Helper.areItemsEqual(recipe.output, InputHelper.toStack(output), true)) recipes.add(recipe.name);
recipes.put(recipe.name, recipe); CraftTweakerAPI.apply(new RemoveAction(NaturesAuraAPI.ALTAR_RECIPES, recipes));
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);
}
} }
} }
*/

View file

@ -1,68 +1,35 @@
/* TODO crafttweaker
package de.ellpeck.naturesaura.compat.crafttweaker; package de.ellpeck.naturesaura.compat.crafttweaker;
import com.blamejared.mtlib.utils.BaseMapAddition; import com.blamejared.crafttweaker.api.CraftTweakerAPI;
import com.blamejared.mtlib.utils.BaseMapRemoval; import com.blamejared.crafttweaker.api.annotations.ZenRegister;
import crafttweaker.annotations.ZenRegister; import com.blamejared.crafttweaker.api.item.IIngredient;
import crafttweaker.api.item.IIngredient;
import crafttweaker.api.minecraft.CraftTweakerMC;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe; import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe;
import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.compat.Compat;
import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import stanhebben.zenscript.annotations.ZenClass; import net.minecraftforge.registries.ForgeRegistries;
import stanhebben.zenscript.annotations.ZenMethod; import org.openzen.zencode.java.ZenCodeType;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
@ZenRegister @ZenRegister
@ZenClass("mods." + NaturesAura.MOD_ID + ".AnimalSpawner") @ZenCodeType.Name("mods." + NaturesAura.MOD_ID + ".AnimalSpawner")
public final class AnimalSpawnerTweaker { public final class AnimalSpawnerTweaker {
@ZenMethod @ZenCodeType.Method
public static void addRecipe(String name, String entity, int aura, int time, IIngredient[] ingredients) { public static void addRecipe(String name, String entity, int aura, int time, IIngredient[] ingredients) {
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> { ResourceLocation res = new ResourceLocation("crafttweaker", name);
ResourceLocation res = new ResourceLocation(Compat.CRAFT_TWEAKER, name); CraftTweakerAPI.apply(new AddAction<>(NaturesAuraAPI.ANIMAL_SPAWNER_RECIPES, res, new AnimalSpawnerRecipe(res,
return new Add(Collections.singletonMap(res, new AnimalSpawnerRecipe(res, new ResourceLocation(entity), aura, time, ForgeRegistries.ENTITIES.getValue(new ResourceLocation(entity)), aura, time,
Arrays.stream(ingredients).map(CraftTweakerMC::getIngredient).toArray(Ingredient[]::new) Arrays.stream(ingredients).map(IIngredient::asVanillaIngredient).toArray(Ingredient[]::new))));
)));
});
} }
@ZenMethod @ZenCodeType.Method
public static void removeRecipe(String name) { public static void removeRecipe(String name) {
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> { CraftTweakerAPI.apply(new RemoveAction(NaturesAuraAPI.ANIMAL_SPAWNER_RECIPES, Collections.singletonList(new ResourceLocation(name))));
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();
}
} }
} }
*/

View file

@ -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) {
}
}

View file

@ -1,14 +1,9 @@
/* TODO crafttweaker
package de.ellpeck.naturesaura.compat.crafttweaker; package de.ellpeck.naturesaura.compat.crafttweaker;
import com.blamejared.mtlib.helpers.InputHelper; import com.blamejared.crafttweaker.api.CraftTweakerAPI;
import com.blamejared.mtlib.helpers.LogHelper; import com.blamejared.crafttweaker.api.annotations.ZenRegister;
import com.blamejared.mtlib.utils.BaseMapAddition; import com.blamejared.crafttweaker.api.item.IIngredient;
import com.blamejared.mtlib.utils.BaseMapRemoval; import com.blamejared.crafttweaker.api.item.IItemStack;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.item.IIngredient;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.minecraft.CraftTweakerMC;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; 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.api.recipes.ing.AmountIngredient;
import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.compat.Compat;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import stanhebben.zenscript.annotations.ZenClass; import org.openzen.zencode.java.ZenCodeType;
import stanhebben.zenscript.annotations.ZenMethod;
import java.util.Collections; import java.util.*;
import java.util.HashMap;
import java.util.Map;
@ZenRegister @ZenRegister
@ZenClass("mods." + NaturesAura.MOD_ID + ".Offering") @ZenCodeType.Name("mods." + NaturesAura.MOD_ID + ".Offering")
public final class OfferingTweaker { public final class OfferingTweaker {
@ZenMethod @ZenCodeType.Method
public static void addRecipe(String name, IIngredient input, int inputAmount, IIngredient startItem, IItemStack output) { public static void addRecipe(String name, IIngredient input, int inputAmount, IIngredient startItem, IItemStack output) {
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> { ResourceLocation res = new ResourceLocation("crafttweaker", name);
ResourceLocation res = new ResourceLocation(Compat.CRAFT_TWEAKER, name); CraftTweakerAPI.apply(new AddAction<>(NaturesAuraAPI.OFFERING_RECIPES, res, new OfferingRecipe(res,
return new Add(Collections.singletonMap(res, new OfferingRecipe(res, new AmountIngredient(input.asVanillaIngredient(), inputAmount),
new AmountIngredient(CraftTweakerMC.getIngredient(input), inputAmount), startItem.asVanillaIngredient(),
CraftTweakerMC.getIngredient(startItem), output.getInternal())));
InputHelper.toStack(output))));
});
} }
@ZenMethod @ZenCodeType.Method
public static void removeRecipe(IItemStack output) { public static void removeRecipe(IItemStack output) {
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> { List<ResourceLocation> recipes = new ArrayList<>();
Map<ResourceLocation, OfferingRecipe> recipes = new HashMap<>(); for (OfferingRecipe recipe : NaturesAuraAPI.OFFERING_RECIPES.values())
for (OfferingRecipe recipe : NaturesAuraAPI.OFFERING_RECIPES.values()) if (Helper.areItemsEqual(recipe.output, output.getInternal(), true))
if (Helper.areItemsEqual(recipe.output, InputHelper.toStack(output), true)) recipes.add(recipe.name);
recipes.put(recipe.name, recipe); CraftTweakerAPI.apply(new RemoveAction(NaturesAuraAPI.OFFERING_RECIPES, recipes));
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);
}
} }
} }
*/

View file

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

View file

@ -1,14 +1,9 @@
/*
package de.ellpeck.naturesaura.compat.crafttweaker; package de.ellpeck.naturesaura.compat.crafttweaker;
import com.blamejared.mtlib.helpers.InputHelper; import com.blamejared.crafttweaker.api.CraftTweakerAPI;
import com.blamejared.mtlib.helpers.LogHelper; import com.blamejared.crafttweaker.api.annotations.ZenRegister;
import com.blamejared.mtlib.utils.BaseMapAddition; import com.blamejared.crafttweaker.api.item.IIngredient;
import com.blamejared.mtlib.utils.BaseMapRemoval; import com.blamejared.crafttweaker.api.item.IItemStack;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.item.IIngredient;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.minecraft.CraftTweakerMC;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
@ -16,64 +11,31 @@ import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.compat.Compat;
import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import stanhebben.zenscript.annotations.ZenClass; import org.openzen.zencode.java.ZenCodeType;
import stanhebben.zenscript.annotations.ZenMethod;
import java.util.Arrays; import java.util.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@ZenRegister @ZenRegister
@ZenClass("mods." + NaturesAura.MOD_ID + ".TreeRitual") @ZenCodeType.Name("mods." + NaturesAura.MOD_ID + ".TreeRitual")
public final class TreeRitualTweaker { public final class TreeRitualTweaker {
@ZenMethod @ZenCodeType.Method
public static void addRecipe(String name, IIngredient saplingType, IItemStack result, int time, IIngredient[] items) { public static void addRecipe(String name, IIngredient saplingType, IItemStack result, int time, IIngredient[] items) {
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> { ResourceLocation res = new ResourceLocation("crafttweaker", name);
ResourceLocation res = new ResourceLocation(Compat.CRAFT_TWEAKER, name); CraftTweakerAPI.apply(new AddAction<>(NaturesAuraAPI.TREE_RITUAL_RECIPES, res, new TreeRitualRecipe(res,
return new Add(Collections.singletonMap(res, new TreeRitualRecipe(res, saplingType.asVanillaIngredient(),
CraftTweakerMC.getIngredient(saplingType), result.getInternal(),
InputHelper.toStack(result), time,
time, Arrays.stream(items).map(IIngredient::asVanillaIngredient).toArray(Ingredient[]::new)
Arrays.stream(items).map(CraftTweakerMC::getIngredient).toArray(Ingredient[]::new) )));
)));
});
} }
@ZenMethod @ZenCodeType.Method
public static void removeRecipe(IItemStack output) { public static void removeRecipe(IItemStack output) {
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> { List<ResourceLocation> recipes = new ArrayList<>();
Map<ResourceLocation, TreeRitualRecipe> recipes = new HashMap<>(); for (TreeRitualRecipe recipe : NaturesAuraAPI.TREE_RITUAL_RECIPES.values())
for (TreeRitualRecipe recipe : NaturesAuraAPI.TREE_RITUAL_RECIPES.values()) if (Helper.areItemsEqual(recipe.result, output.getInternal(), true))
if (Helper.areItemsEqual(recipe.result, InputHelper.toStack(output), true)) recipes.add(recipe.name);
recipes.put(recipe.name, recipe); CraftTweakerAPI.apply(new RemoveAction(NaturesAuraAPI.TREE_RITUAL_RECIPES, recipes));
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);
}
} }
} }
*/

View file

@ -12,7 +12,7 @@ import java.util.Collections;
public class EnchantibilityCompat implements ICompat { public class EnchantibilityCompat implements ICompat {
@Override @Override
public void preInit() { public void setup() {
DeferredWorkQueue.runLater(() -> { DeferredWorkQueue.runLater(() -> {
IInternals api = EnchantabilityApi.getInstance(); IInternals api = EnchantabilityApi.getInstance();
api.registerEnchantEffect(EnchantibilityAuraMending.RES, ModEnchantments.AURA_MENDING, EnchantibilityAuraMending::new); api.registerEnchantEffect(EnchantibilityAuraMending.RES, ModEnchantments.AURA_MENDING, EnchantibilityAuraMending::new);
@ -21,12 +21,7 @@ public class EnchantibilityCompat implements ICompat {
} }
@Override @Override
public void preInitClient() { public void setupClient() {
}
@Override
public void postInit() {
} }

View file

@ -56,7 +56,7 @@ public class PatchouliCompat implements ICompat {
} }
@Override @Override
public void preInit() { public void setup() {
DeferredWorkQueue.runLater(() -> { DeferredWorkQueue.runLater(() -> {
PatchouliAPI.instance.setConfigFlag(NaturesAura.MOD_ID + ":rf_converter", ModConfig.instance.rfConverter.get()); PatchouliAPI.instance.setConfigFlag(NaturesAura.MOD_ID + ":rf_converter", ModConfig.instance.rfConverter.get());
PatchouliAPI.instance.setConfigFlag(NaturesAura.MOD_ID + ":chunk_loader", ModConfig.instance.chunkLoader.get()); PatchouliAPI.instance.setConfigFlag(NaturesAura.MOD_ID + ":chunk_loader", ModConfig.instance.chunkLoader.get());
@ -64,7 +64,7 @@ public class PatchouliCompat implements ICompat {
} }
@Override @Override
public void preInitClient() { public void setupClient() {
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }
@ -73,11 +73,6 @@ public class PatchouliCompat implements ICompat {
} }
@Override
public void postInit() {
}
@SubscribeEvent @SubscribeEvent
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void onBookDraw(BookDrawScreenEvent event) { public void onBookDraw(BookDrawScreenEvent event) {

View file

@ -39,7 +39,7 @@ public class ClientProxy implements IProxy {
@Override @Override
public void preInit(FMLCommonSetupEvent event) { public void preInit(FMLCommonSetupEvent event) {
MinecraftForge.EVENT_BUS.register(new ClientEvents()); MinecraftForge.EVENT_BUS.register(new ClientEvents());
Compat.preInitClient(); Compat.setupClient();
ScreenManager.registerFactory(ModContainers.ENDER_CRATE, GuiEnderCrate::new); ScreenManager.registerFactory(ModContainers.ENDER_CRATE, GuiEnderCrate::new);
ScreenManager.registerFactory(ModContainers.ENDER_ACCESS, GuiEnderCrate::new); ScreenManager.registerFactory(ModContainers.ENDER_ACCESS, GuiEnderCrate::new);
} }