add crafttweaker compat

This commit is contained in:
Ellpeck 2018-11-11 16:50:51 +01:00
parent 436f3b809b
commit dbeb2914f1
9 changed files with 199 additions and 14 deletions

View file

@ -21,6 +21,7 @@ compileJava {
} }
repositories { repositories {
mavenCentral()
maven { maven {
url = "http://dvs1.progwml6.com/files/maven" url = "http://dvs1.progwml6.com/files/maven"
} }
@ -33,9 +34,13 @@ repositories {
} }
dependencies { dependencies {
compile "vazkii.patchouli:Patchouli:1.0-6.8"
deobfCompile "mezz.jei:jei_1.12.2:4.13.1.220" deobfCompile "mezz.jei:jei_1.12.2:4.13.1.220"
deobfCompile "com.azanor.baubles:Baubles:1.12-1.5.2" 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"
} }

View file

@ -63,7 +63,7 @@ public final class NaturesAura {
new ModBlocks(); new ModBlocks();
new ModItems(); new ModItems();
Compat.init(); Compat.preInit();
PacketHandler.init(); PacketHandler.init();
ModRegistry.preInit(event); ModRegistry.preInit(event);
new Multiblocks(); new Multiblocks();
@ -86,6 +86,7 @@ public final class NaturesAura {
@EventHandler @EventHandler
public void postInit(FMLPostInitializationEvent event) { public void postInit(FMLPostInitializationEvent event) {
ModRegistry.postInit(event); ModRegistry.postInit(event);
Compat.postInit();
proxy.postInit(event); proxy.postInit(event);
if (ModConfig.general.removeDragonBreathContainerItem) { if (ModConfig.general.removeDragonBreathContainerItem) {

View file

@ -21,7 +21,10 @@ public class AltarRecipe {
this.catalyst = catalyst; this.catalyst = catalyst;
this.aura = aura; this.aura = aura;
this.time = time; this.time = time;
}
public AltarRecipe register(){
NaturesAuraAPI.ALTAR_RECIPES.put(this.name, this); NaturesAuraAPI.ALTAR_RECIPES.put(this.name, this);
return this;
} }
} }

View file

@ -18,7 +18,10 @@ public class TreeRitualRecipe {
this.items = items; this.items = items;
this.result = result; this.result = result;
this.time = time; this.time = time;
}
public TreeRitualRecipe register() {
NaturesAuraAPI.TREE_RITUAL_RECIPES.put(this.name, this); NaturesAuraAPI.TREE_RITUAL_RECIPES.put(this.name, this);
return this;
} }
} }

View file

@ -1,16 +1,24 @@
package de.ellpeck.naturesaura.compat; package de.ellpeck.naturesaura.compat;
import de.ellpeck.naturesaura.compat.crafttweaker.CraftTweakerCompat;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Loader;
public final class Compat { public final class Compat {
public static boolean baubles; public static boolean baubles;
public static boolean craftTweaker;
public static void init() { public static void preInit() {
baubles = Loader.isModLoaded("baubles"); baubles = Loader.isModLoaded("baubles");
if (baubles) { craftTweaker = Loader.isModLoaded("crafttweaker");
if (baubles)
MinecraftForge.EVENT_BUS.register(new BaublesCompat()); MinecraftForge.EVENT_BUS.register(new BaublesCompat());
} }
public static void postInit() {
if (craftTweaker)
CraftTweakerCompat.postInit();
} }
} }

View file

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

View file

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

View file

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

View file

@ -20,7 +20,7 @@ public final class ModRecipes {
new ItemStack(Items.SPIDER_EYE), new ItemStack(Items.SPIDER_EYE),
new ItemStack(Items.GOLD_INGOT), new ItemStack(Items.GOLD_INGOT),
new ItemStack(ModItems.GOLD_LEAF), 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 TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "nature_altar"),
new ItemStack(Blocks.SAPLING), new ItemStack(ModBlocks.NATURE_ALTAR), 500, new ItemStack(Blocks.SAPLING), new ItemStack(ModBlocks.NATURE_ALTAR), 500,
new ItemStack(Blocks.STONE), new ItemStack(Blocks.STONE),
@ -28,7 +28,7 @@ public final class ModRecipes {
new ItemStack(Blocks.STONE), new ItemStack(Blocks.STONE),
new ItemStack(ModItems.GOLD_LEAF), new ItemStack(ModItems.GOLD_LEAF),
new ItemStack(Items.GOLD_INGOT), 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 TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "ancient_sapling"),
new ItemStack(Blocks.SAPLING), new ItemStack(ModBlocks.ANCIENT_SAPLING), 200, new ItemStack(Blocks.SAPLING), new ItemStack(ModBlocks.ANCIENT_SAPLING), 200,
new ItemStack(Blocks.SAPLING), new ItemStack(Blocks.SAPLING),
@ -36,7 +36,7 @@ public final class ModRecipes {
new ItemStack(Blocks.RED_FLOWER), new ItemStack(Blocks.RED_FLOWER),
new ItemStack(Items.WHEAT_SEEDS), new ItemStack(Items.WHEAT_SEEDS),
new ItemStack(Items.REEDS), 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 TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "furnace_heater"),
new ItemStack(Blocks.SAPLING), new ItemStack(ModBlocks.FURNACE_HEATER), 600, new ItemStack(Blocks.SAPLING), new ItemStack(ModBlocks.FURNACE_HEATER), 600,
new ItemStack(ModBlocks.INFUSED_STONE), new ItemStack(ModBlocks.INFUSED_STONE),
@ -46,7 +46,7 @@ public final class ModRecipes {
new ItemStack(Items.FIRE_CHARGE), new ItemStack(Items.FIRE_CHARGE),
new ItemStack(Items.FLINT), new ItemStack(Items.FLINT),
new ItemStack(Blocks.MAGMA), 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 TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "conversion_catalyst"),
new ItemStack(Blocks.SAPLING, 1, 3), new ItemStack(ModBlocks.CONVERSION_CATALYST), 600, new ItemStack(Blocks.SAPLING, 1, 3), new ItemStack(ModBlocks.CONVERSION_CATALYST), 600,
new ItemStack(Blocks.STONEBRICK, 1, 1), new ItemStack(Blocks.STONEBRICK, 1, 1),
@ -54,20 +54,20 @@ public final class ModRecipes {
new ItemStack(Items.BREWING_STAND), new ItemStack(Items.BREWING_STAND),
new ItemStack(Items.GOLD_INGOT), new ItemStack(Items.GOLD_INGOT),
new ItemStack(ModItems.GOLD_LEAF), new ItemStack(ModItems.GOLD_LEAF),
new ItemStack(Blocks.GLOWSTONE)); new ItemStack(Blocks.GLOWSTONE)).register();
new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "infused_iron"), new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "infused_iron"),
new ItemStack(Items.IRON_INGOT), new ItemStack(ModItems.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 AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "infused_stone"),
new ItemStack(Blocks.STONE), new ItemStack(ModBlocks.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"), new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "chorus"),
ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), AuraType.END), new ItemStack(Items.DRAGON_BREATH), 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 AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "leather"),
new ItemStack(Items.ROTTEN_FLESH), new ItemStack(Items.LEATHER), new ItemStack(Items.ROTTEN_FLESH), new ItemStack(Items.LEATHER),
ModBlocks.CONVERSION_CATALYST, 400, 50); ModBlocks.CONVERSION_CATALYST, 400, 50).register();
} }
} }