mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-25 12:58:33 +01:00
add crafttweaker compat
This commit is contained in:
parent
436f3b809b
commit
dbeb2914f1
9 changed files with 199 additions and 14 deletions
|
@ -21,6 +21,7 @@ compileJava {
|
|||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url = "http://dvs1.progwml6.com/files/maven"
|
||||
}
|
||||
|
@ -33,9 +34,13 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile "vazkii.patchouli:Patchouli:1.0-6.8"
|
||||
|
||||
deobfCompile "mezz.jei:jei_1.12.2:4.13.1.220"
|
||||
deobfCompile "com.azanor.baubles:Baubles:1.12-1.5.2"
|
||||
compile "vazkii.patchouli:Patchouli:1.0-6.8"
|
||||
|
||||
compile "com.blamejared:MTLib:3.0.4.8"
|
||||
compile "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.11.494"
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public final class NaturesAura {
|
|||
new ModBlocks();
|
||||
new ModItems();
|
||||
|
||||
Compat.init();
|
||||
Compat.preInit();
|
||||
PacketHandler.init();
|
||||
ModRegistry.preInit(event);
|
||||
new Multiblocks();
|
||||
|
@ -86,6 +86,7 @@ public final class NaturesAura {
|
|||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
ModRegistry.postInit(event);
|
||||
Compat.postInit();
|
||||
proxy.postInit(event);
|
||||
|
||||
if (ModConfig.general.removeDragonBreathContainerItem) {
|
||||
|
|
|
@ -21,7 +21,10 @@ public class AltarRecipe {
|
|||
this.catalyst = catalyst;
|
||||
this.aura = aura;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public AltarRecipe register(){
|
||||
NaturesAuraAPI.ALTAR_RECIPES.put(this.name, this);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,10 @@ public class TreeRitualRecipe {
|
|||
this.items = items;
|
||||
this.result = result;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public TreeRitualRecipe register() {
|
||||
NaturesAuraAPI.TREE_RITUAL_RECIPES.put(this.name, this);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,24 @@
|
|||
package de.ellpeck.naturesaura.compat;
|
||||
|
||||
import de.ellpeck.naturesaura.compat.crafttweaker.CraftTweakerCompat;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
|
||||
public final class Compat {
|
||||
|
||||
public static boolean baubles;
|
||||
public static boolean craftTweaker;
|
||||
|
||||
public static void init() {
|
||||
public static void preInit() {
|
||||
baubles = Loader.isModLoaded("baubles");
|
||||
if (baubles) {
|
||||
craftTweaker = Loader.isModLoaded("crafttweaker");
|
||||
|
||||
if (baubles)
|
||||
MinecraftForge.EVENT_BUS.register(new BaublesCompat());
|
||||
}
|
||||
|
||||
public static void postInit() {
|
||||
if (craftTweaker)
|
||||
CraftTweakerCompat.postInit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
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.IItemStack;
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenRegister
|
||||
@ZenClass("mods." + NaturesAura.MOD_ID + ".Altar")
|
||||
public final class AltarTweaker {
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(String name, IItemStack input, IItemStack output, IItemStack catalyst, int aura, int time) {
|
||||
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> {
|
||||
Block block = Block.getBlockFromItem(InputHelper.toStack(catalyst).getItem());
|
||||
ResourceLocation res = new ResourceLocation(name);
|
||||
return new Add(Collections.singletonMap(res, new AltarRecipe(res,
|
||||
InputHelper.toStack(input),
|
||||
InputHelper.toStack(output),
|
||||
block == Blocks.AIR ? null : block,
|
||||
aura, time)));
|
||||
});
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package de.ellpeck.naturesaura.compat.crafttweaker;
|
||||
|
||||
import crafttweaker.CraftTweakerAPI;
|
||||
import crafttweaker.IAction;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class CraftTweakerCompat {
|
||||
|
||||
public static final List<Supplier<IAction>> SCHEDULED_ACTIONS = new ArrayList<>();
|
||||
|
||||
public static void postInit() {
|
||||
for (Supplier<IAction> action : SCHEDULED_ACTIONS)
|
||||
CraftTweakerAPI.apply(action.get());
|
||||
SCHEDULED_ACTIONS.clear();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
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.IItemStack;
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenRegister
|
||||
@ZenClass("mods." + NaturesAura.MOD_ID + ".TreeRitual")
|
||||
public final class TreeRitualTweaker {
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(String name, IItemStack saplingType, IItemStack result, int time, IItemStack[] items) {
|
||||
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> {
|
||||
ResourceLocation res = new ResourceLocation(name);
|
||||
return new Add(Collections.singletonMap(res, new TreeRitualRecipe(res,
|
||||
InputHelper.toStack(saplingType),
|
||||
InputHelper.toStack(result),
|
||||
time,
|
||||
InputHelper.toStacks(items)
|
||||
)));
|
||||
});
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,7 +20,7 @@ public final class ModRecipes {
|
|||
new ItemStack(Items.SPIDER_EYE),
|
||||
new ItemStack(Items.GOLD_INGOT),
|
||||
new ItemStack(ModItems.GOLD_LEAF),
|
||||
new ItemStack(ModItems.GOLD_LEAF));
|
||||
new ItemStack(ModItems.GOLD_LEAF)).register();
|
||||
new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "nature_altar"),
|
||||
new ItemStack(Blocks.SAPLING), new ItemStack(ModBlocks.NATURE_ALTAR), 500,
|
||||
new ItemStack(Blocks.STONE),
|
||||
|
@ -28,7 +28,7 @@ public final class ModRecipes {
|
|||
new ItemStack(Blocks.STONE),
|
||||
new ItemStack(ModItems.GOLD_LEAF),
|
||||
new ItemStack(Items.GOLD_INGOT),
|
||||
ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), AuraType.OVERWORLD));
|
||||
ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), AuraType.OVERWORLD)).register();
|
||||
new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "ancient_sapling"),
|
||||
new ItemStack(Blocks.SAPLING), new ItemStack(ModBlocks.ANCIENT_SAPLING), 200,
|
||||
new ItemStack(Blocks.SAPLING),
|
||||
|
@ -36,7 +36,7 @@ public final class ModRecipes {
|
|||
new ItemStack(Blocks.RED_FLOWER),
|
||||
new ItemStack(Items.WHEAT_SEEDS),
|
||||
new ItemStack(Items.REEDS),
|
||||
new ItemStack(ModItems.GOLD_LEAF));
|
||||
new ItemStack(ModItems.GOLD_LEAF)).register();
|
||||
new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "furnace_heater"),
|
||||
new ItemStack(Blocks.SAPLING), new ItemStack(ModBlocks.FURNACE_HEATER), 600,
|
||||
new ItemStack(ModBlocks.INFUSED_STONE),
|
||||
|
@ -46,7 +46,7 @@ public final class ModRecipes {
|
|||
new ItemStack(Items.FIRE_CHARGE),
|
||||
new ItemStack(Items.FLINT),
|
||||
new ItemStack(Blocks.MAGMA),
|
||||
ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), AuraType.NETHER));
|
||||
ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), AuraType.NETHER)).register();
|
||||
new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "conversion_catalyst"),
|
||||
new ItemStack(Blocks.SAPLING, 1, 3), new ItemStack(ModBlocks.CONVERSION_CATALYST), 600,
|
||||
new ItemStack(Blocks.STONEBRICK, 1, 1),
|
||||
|
@ -54,20 +54,20 @@ public final class ModRecipes {
|
|||
new ItemStack(Items.BREWING_STAND),
|
||||
new ItemStack(Items.GOLD_INGOT),
|
||||
new ItemStack(ModItems.GOLD_LEAF),
|
||||
new ItemStack(Blocks.GLOWSTONE));
|
||||
new ItemStack(Blocks.GLOWSTONE)).register();
|
||||
|
||||
new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "infused_iron"),
|
||||
new ItemStack(Items.IRON_INGOT), new ItemStack(ModItems.INFUSED_IRON),
|
||||
null, 300, 80);
|
||||
null, 300, 80).register();
|
||||
new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "infused_stone"),
|
||||
new ItemStack(Blocks.STONE), new ItemStack(ModBlocks.INFUSED_STONE),
|
||||
null, 150, 40);
|
||||
null, 150, 40).register();
|
||||
|
||||
new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "chorus"),
|
||||
ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), AuraType.END), new ItemStack(Items.DRAGON_BREATH),
|
||||
ModBlocks.CONVERSION_CATALYST, 350, 80);
|
||||
ModBlocks.CONVERSION_CATALYST, 350, 80).register();
|
||||
new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "leather"),
|
||||
new ItemStack(Items.ROTTEN_FLESH), new ItemStack(Items.LEATHER),
|
||||
ModBlocks.CONVERSION_CATALYST, 400, 50);
|
||||
ModBlocks.CONVERSION_CATALYST, 400, 50).register();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue