This post was removed from Minecraft Forums during the twitch merger (2018/2019). I have been able to retrieve the original text, and have reformatted it for the website. Areas in Boxes were originally Spoiler tabs (collapsing areas).
[1.10.2] ModHelpers - Easy integration with other mods!
After spending way too long searching for how to integrate my mod s with other, more popular mods, I thought it would help to upload what I coded to aid other new modders.
These will be java class files that you can call functions to do simple integration.
They are for 1.10.2 (may work 1.11.2 with a little tweaking), and can be placed anywhere in your development area.
These are not for full addons: They will only cover the simpler integration that doesn't require the other mod to be loaded.
There may also be a couple of extra helpers (like the loot table helper).
Unfortunately, you will need to add the source files as libraries or references, so that the files would be valid to compile. I don't know how to get around this. This only has to be for in eclipse/Intellij etc.
You will want to compile these files with your mod, including in your final build.
The Files
IC2 Helper
package com.modHelpers; import ic2.api.recipe.Recipes; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class HelperIC2 { /** *Needs to be called in Init *@author ekul6547 */ public static void addMaceratorRecipe(ItemStack input, ItemStack outputA){ Recipes.macerator.addRecipe(new ic2.api.recipe.RecipeInputItemStack(input,input.stackSize), new NBTTagCompound(), false, outputA); } public static void addExtractorRecipe(ItemStack input, ItemStack outputA){ Recipes.extractor.addRecipe(new ic2.api.recipe.RecipeInputItemStack(input,input.stackSize), new NBTTagCompound(), false, outputA); } public static void addCompressorRecipe(ItemStack input, ItemStack outputA){ Recipes.compressor.addRecipe(new ic2.api.recipe.RecipeInputItemStack(input,input.stackSize), new NBTTagCompound(), false, outputA); } public static void addCentrifugeRecipe(ItemStack input, ItemStack outputA){ Recipes.centrifuge.addRecipe(new ic2.api.recipe.RecipeInputItemStack(input,input.stackSize), new NBTTagCompound(), false, outputA); } public static void addBlockCutterRecipe(ItemStack input, ItemStack outputA){ Recipes.blockcutter.addRecipe(new ic2.api.recipe.RecipeInputItemStack(input,input.stackSize), new NBTTagCompound(), false, outputA); } public static void addBlastFurnaceRecipe(ItemStack input, ItemStack outputA){ Recipes.blastfurnace.addRecipe(new ic2.api.recipe.RecipeInputItemStack(input,input.stackSize), new NBTTagCompound(), false, outputA); } public static void addRecyclerRecipe(ItemStack input, ItemStack outputA){ Recipes.recycler.addRecipe(new ic2.api.recipe.RecipeInputItemStack(input,input.stackSize), new NBTTagCompound(), false, outputA); } }
JEI Helper
package com.modHelpers; import mezz.jei.api.*; import mezz.jei.api.ingredients.IModIngredientRegistration; import net.minecraft.item.ItemStack; import javax.annotation.Nonnull; import java.util.ArrayList; /** * To add item descriptions to items and blocks in JEI * call addJEIDescription() in preInit * Not to add new categories or custom recipes (yet!) * @author ekul6547 */ @JEIPlugin public class HelperJei implements IModPlugin{ public static class itemDesc { public ItemStack itemStack; public String[] descriptions; public itemDesc(ItemStack stack, String... descs){ itemStack = stack; descriptions = descs; }} public static ArrayList<itemDesc> descReg = new ArrayList<itemDesc>(); public static IJeiRuntime RUNTIME = null; public HelperJei(){System.out.println("HelperJei ACTIVATED!!!");} @Override public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry) { } @Override public void registerIngredients(IModIngredientRegistration registry) { } public void register(@Nonnull IModRegistry registry) { for(itemDesc desc : descReg) { registry.addDescription(desc.itemStack, desc.descriptions); System.out.println("HelperJei added description for:"+desc.itemStack.getDisplayName()); }} /* Call this preInit */ public static void addJEIDescription(ItemStack stack, String... descs){ descReg.add(new itemDesc(stack,descs)); } public void onRuntimeAvailable(@Nonnull IJeiRuntime jeiRuntime){ RUNTIME = jeiRuntime; } } }
ProjectE Helper
package com.modHelpers; import moze_intel.projecte.api.ProjectEAPI; import net.minecraft.item.ItemStack; public class HelperProjectE { /** * Called anytime after items are declared * @author ekul6547 */ public static void setEMC(ItemStack stack, int value){ ProjectEAPI.getEMCProxy().registerCustomEMC(stack, value); } public static int getEMC(ItemStack stack){
return ProjectEAPI.getEMCProxy().getValue(stack);
} public static boolean hasEMC(ItemStack stack) {
return ProjectEAPI.getEMCProxy().hasValue(stack);
} }
Loot Helper
Credit to Draco18s for the code
package com.modHelpers; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import net.minecraft.item.Item; import net.minecraft.world.storage.loot.LootEntry; import net.minecraft.world.storage.loot.LootEntryItem; import net.minecraft.world.storage.loot.LootPool; import net.minecraft.world.storage.loot.LootTable; import net.minecraft.world.storage.loot.RandomValueRange; import net.minecraft.world.storage.loot.conditions.LootCondition; import net.minecraft.world.storage.loot.conditions.RandomChance; import net.minecraft.world.storage.loot.functions.LootFunction; import net.minecraft.world.storage.loot.functions.LootingEnchantBonus; import net.minecraft.world.storage.loot.functions.SetCount; import net.minecraft.world.storage.loot.functions.SetMetadata; import net.minecraftforge.fml.relauncher.ReflectionHelper; /** * LootUtils supplies several methods for easing the process of modifying loot * tables during the LootTableLoadEvent. * @author Draco18s * @URL https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/hardlib/util/LootUtils.java */ public class HelperLoot { public static void removeLootFromTable(LootTable table, Item toRemove) { List<LootPool> pools = ReflectionHelper.getPrivateValue(LootTable.class, table, "pools", "field_186466_c"); for(LootPool pool : pools) { List<LootEntry> entries = ReflectionHelper.getPrivateValue(LootPool.class, pool, "lootEntries", "field_186453_a"); Iterator<LootEntry> it = entries.iterator(); while(it.hasNext()) { LootEntry entry = it.next(); if(entry instanceof LootEntryItem) { LootEntryItem lei = (LootEntryItem)entry; Item i = ReflectionHelper.getPrivateValue(LootEntryItem.class, lei, "item", "field_186368_a"); if(i == toRemove) { it.remove(); break; }}}}} public static void addItemToTable(LootTable table, Item item, int weight, float numRolls, float probability, int minQuantity, int maxQuantity, float minLootBonus, float maxLootBonus, String name) { addItemToTable(table, item, 0, 0, weight, numRolls, probability, minQuantity, maxQuantity, minLootBonus, maxLootBonus, name); } public static void addItemToTable(LootTable table, Item item, int weight, float numRolls, float probability, int minQuantity, int maxQuantity, float minLootBonus, float maxLootBonus, String name, IMethod LootCallbacks, ICondition LootConditions) {
addItemToTable(table, item, 0, 0, weight, numRolls, probability, minQuantity, maxQuantity, minLootBonus, maxLootBonus, name, LootCallbacks, LootConditions);
} public static void addItemToTable(LootTable table, Item item, int weight, float numRolls, float probability, int minQuantity, int maxQuantity, float minLootBonus, float maxLootBonus, String name, IMethod LootCallbacks) {
addItemToTable(table, item, 0, 0, weight, numRolls, probability, minQuantity, maxQuantity, minLootBonus, maxLootBonus, name, LootCallbacks, new ICondition() { @Override public void FunctionsCallback(ArrayList<LootCondition> lootconds) {} });} public static void addItemToTable(LootTable table, Item item, int weight, float numRolls, float probability, int minQuantity, int maxQuantity, float minLootBonus, float maxLootBonus, String name, ICondition LootConditions) { addItemToTable(table, item, 0, 0, weight, numRolls, probability, minQuantity, maxQuantity, minLootBonus, maxLootBonus, name, new IMethod() { @Override public void FunctionsCallback(ArrayList<LootFunction> lootfuncs) {} }, LootConditions); } public static void addItemToTable(LootTable table, Item item, int minMeta, int maxMeta, int weight, float numRolls, float probability, int minQuantity, int maxQuantity, float minLootBonus, float maxLootBonus, String name) { addItemToTable(table, item, 0, 0, weight, numRolls, probability, minQuantity, maxQuantity, minLootBonus, maxLootBonus, name, new IMethod() { @Override public void FunctionsCallback(ArrayList<LootFunction> lootfuncs) {} }, new ICondition() { @Override public void FunctionsCallback(ArrayList<LootCondition> lootconds) {} });} public static void addItemToTable(LootTable table, Item item, int minMeta, int maxMeta, int weight, float numRolls, float probability, int minQuantity, int maxQuantity, float minLootBonus, float maxLootBonus, String name, IMethod LootCallbacks, ICondition LootConditions) { ArrayList<LootCondition> _conditions = new ArrayList<LootCondition>(); _conditions.add(new RandomChance(probability)); LootConditions.FunctionsCallback(_conditions); LootCondition[] lchance = _conditions.toArray(new LootCondition[0]); /LootCondition[] lchance = {new RandomChance(probability)};/ ArrayList<LootFunction> _functions = new ArrayList<LootFunction>(); _functions.add(new SetCount(lchance, new RandomValueRange(minQuantity, maxQuantity))); _functions.add(new LootingEnchantBonus(new LootCondition[]{}, new RandomValueRange(minLootBonus, maxLootBonus), 0)); _functions.add(new SetMetadata(new LootCondition[]{}, new RandomValueRange(minMeta, maxMeta))); LootCallbacks.FunctionsCallback(_functions); LootFunction[] lcount = _functions.toArray(new LootFunction[0]); /ArrayList<LootEntryItem> _entries = new ArrayList<LootEntryItem>(); _entries.add(new LootEntryItem(item, weight, 1, lcount, lchance, name)); LootEntryItem[] leitem = _entries.toArray(new LootEntryItem[0]);/ LootEntryItem[] leitem = {new LootEntryItem(item, weight, 1, lcount, lchance, name)}; LootPool newPool = createLootPool(leitem, lcount, lchance, new RandomValueRange(numRolls), new RandomValueRange(0), name); addItemToTable(table, newPool); } public static LootPool createLootPool(LootEntryItem[] leitem, LootFunction[] lcount, LootCondition[] lchance, RandomValueRange numRolls, RandomValueRange bonusRolls, String name) { return new LootPool(leitem, lchance, numRolls, bonusRolls, name); } public static void addItemToTable(LootTable table, LootPool pool) { table.addPool(pool); } public static interface IMethod { public void FunctionsCallback(ArrayList<LootFunction> lootfuncs); } public static interface ICondition { public void FunctionsCallback(ArrayList<LootCondition> lootconds); } }
Tinkers Construct
package com.modHelpers; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.common.event.FMLInterModComms; import slimeknights.mantle.util.RecipeMatch; import slimeknights.tconstruct.TinkerIntegration; import slimeknights.tconstruct.library.MaterialIntegration; import slimeknights.tconstruct.library.TinkerRegistry; import slimeknights.tconstruct.library.Util; import slimeknights.tconstruct.library.materials.*; import slimeknights.tconstruct.library.materials.Material; import slimeknights.tconstruct.library.smeltery.CastingRecipe; import slimeknights.tconstruct.library.traits.ITrait; import slimeknights.tconstruct.tools.TinkerMaterials; import javax.annotation.Nullable; public class HelperTinker { /** * Call this first to get main material * @param identifier To Identify by * @param color Color (0xffffff = white) * @param oreDictIngot Ore Dictionary Value for an item * @param craftable Can be craftable, normal patterns not casts */ public static Material newMaterial(String identifier, int color, String oreDictIngot, boolean craftable){ Material mat = new Material(identifier, color); TinkerMaterials.materials.add(mat); mat.setCraftable(craftable); mat.addItemIngot(oreDictIngot); return mat; } /** * Call this last to register your mat * @param mat */ public static void registerMat(Material mat){ TinkerIntegration.integrationList.add(new MaterialIntegration(mat)); } public static Material setCastingFluid(Material mat, Fluid fluid){ mat.setFluid(fluid); mat.setCastable(true); return mat; } public static void addBasinRecipe(ItemStack output, Fluid fluid, int amount, int time){ TinkerRegistry.registerBasinCasting(new CastingRecipe(output,null,fluid,amount,time)); } public static void addBasinRecipe(ItemStack output, @Nullable ItemStack cast, Fluid fluid, int amount, int time, boolean consumeCast, boolean switchOutput){ TinkerRegistry.registerBasinCasting(new CastingRecipe(output, RecipeMatch.ofNBT(cast), new FluidStack(fluid, amount), consumeCast, switchOutput)); } public static void addTableRecipe(ItemStack output, Fluid fluid, int amount, int time){ TinkerRegistry.registerBasinCasting(new CastingRecipe(output,null,fluid,amount,time)); } public static void addTableRecipe(ItemStack output, @Nullable ItemStack cast, Fluid fluid, int amount, int time, boolean consumeCast, boolean switchOut){ TinkerRegistry.registerBasinCasting(new CastingRecipe(output,RecipeMatch.ofNBT(cast),new FluidStack(fluid,amount),time,consumeCast,switchOut)); } public static void addMeltingRecipe(ItemStack stack, FluidStack fluidStack){ TinkerRegistry.registerMelting(stack,fluidStack.getFluid(),fluidStack.amount); } public static void addMeltingRecipe(ItemStack stack, Fluid fluid, int amount){ TinkerRegistry.registerMelting(stack,fluid,amount); } public static void addOreDictMeltingRecipe(String ore, Fluid fluid, int amount){ TinkerRegistry.registerMelting(ore,fluid,amount); } public static void addCastForItem(Item item){ TinkerRegistry.addCastForItem(item); } public static void addSmelteryFuel(FluidStack stack, int duration){ TinkerRegistry.registerSmelteryFuel(stack, duration); } /** * * @param mat * @param representativeItem * @return */ public static Material addRepresentativeItem(Material mat, ItemStack representativeItem){ mat.setRepresentativeItem(representativeItem); return mat; } public static Material addMaterialStats(Material mat, AbstractMaterialStats... stats){ for(AbstractMaterialStats s : stats){ TinkerRegistry.addMaterialStats(mat,s); } return mat; } public static Material addGlobalTraits(Material mat, ITrait... traits){ for(ITrait t : traits) { mat.addTrait(t); } return mat; } public static Material addSpecificTraits(Material mat, String dependancy, ITrait... traits){ for(ITrait t : traits) { mat.addTrait(t,dependancy); } return mat; } //IMC Integration public static Fluid newFluid(String fluidName, int Color, boolean useLavaMaterial, String oreDictSuffix, boolean newToolForge){ return newFluid(fluidName, Color, useLavaMaterial, oreDictSuffix, newToolForge, new ResourceLocation("tconstruct:blocks/fluids/molten_metal"), new ResourceLocation("tconstruct:blocks/fluids/molten_metal_flow")); } /** * Create a new fluid for smeltery, and config for it. * @param fluidName Name of the fluid * @param useLavaMaterial Fluid has Lava physics instead of Water * @param oreDictSuffix Suffix for the appropriate ore dictionary (ingotFoo, blockFoo, oreFoo, dustFoo...) * @param newToolForge Can blockFoo be used to create a ToolForge * @param fluidStill Custom fluid texture for Still (optional) * @param fluidFlow Custom fluid texture for flowing (optional) */ public static Fluid newFluid(String fluidName, final int Color, boolean useLavaMaterial, String oreDictSuffix, boolean newToolForge, ResourceLocation fluidStill, ResourceLocation fluidFlow){ // create fluid. // You don't need to add textures for the fluid, just create a Fluid Class that overwrites getColor // and pass the following as still and flowing ResourceLocation: // still: "tconstruct:blocks/fluids/molten_metal" // flowing: "tconstruct:blocks/fluids/molten_metal_flow" Fluid myFluid = new Fluid(fluidName, fluidStill, fluidFlow){ @Override public int getColor() { return Color; } }; FluidRegistry.registerFluid(myFluid); // fluid has to be registered FluidRegistry.addBucketForFluid(myFluid); // add a bucket for the fluid // add block for fluid (if desired) if(useLavaMaterial){ Block fluidBlock = new BlockFluidClassic(myFluid, net.minecraft.block.material.Material.LAVA); }else { Block fluidBlock = new BlockFluidClassic(myFluid, net.minecraft.block.material.Material.WATER); } // <register block regularly> // create NBT for the IMC NBTTagCompound tag = new NBTTagCompound(); tag.setString("fluid", myFluid.getName()); // name of the fluid tag.setString("ore", oreDictSuffix); // ore-suffix: ingotFoo, blockFoo, oreFoo,... tag.setBoolean("toolforge", newToolForge); // if set to true, blockFoo can be used to build a toolforge //tag.setTag("alloy", alloysTagList); // you can also send an alloy with the registration (see below) // send the NBT to TCon FMLInterModComms.sendMessage("tconstruct", "integrateSmeltery", tag); return myFluid; } /** * Allow two or more fluids to mix/alloy together in the smeltery to form a new one. * @param fluidOutput FluidStack output - 144 = one ingot, amount here is produced from alloy * @param fluidInputs FluidStack[] inputs - 144 = one ingot, so advisable to add them to a multiple of 144 */ public static void addFluidAlloy(FluidStack fluidOutput, FluidStack... fluidInputs){ NBTTagList tagList = new NBTTagList(); // if you have access to the fluid-instance you can also do FluidStack.writeToNBT tagList.appendTag(fluidOutput.writeToNBT(new NBTTagCompound())); // first alloy fluid for(FluidStack input : fluidInputs) { tagList.appendTag(input.writeToNBT(new NBTTagCompound())); } NBTTagCompound message = new NBTTagCompound(); message.setTag("alloy", tagList); FMLInterModComms.sendMessage("tconstruct", "alloy", message); } /** * Blacklist an item from working in the smeltery * Won't work with general ores, blocks, ingots etc.. from ore dictionary * Tinkers allows you to smelt items that use X in their crafting, like armor, and this blocks those */ public static void blacklistSmelt(ItemStack stack){ FMLInterModComms.sendMessage("tconstruct", "blacklistMelting", stack); } public static void blacklistSmelt(String name){ FMLInterModComms.sendMessage("tconstruct", "blacklistMelting", name); } public static void addDryingRackRecipe(ItemStack input, ItemStack output, int timeSeconds){ // Adding it via Itemstack: Turns vanilla gold ore into a gold block in 3 minutes NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setTag("input", input.writeToNBT(new NBTTagCompound())); tagCompound.setTag("output", output.writeToNBT(new NBTTagCompound())); tagCompound.setInteger("time", timeSeconds); FMLInterModComms.sendMessage(Util.MODID, "addDryingRecipe", tagCompound); } public static void addDryingRackRecipe(String input, ItemStack output, int timeSeconds){ NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setString("input", input); tagCompound.setTag("output", output.writeToNBT(new NBTTagCompound())); tagCompound.setInteger("time", timeSeconds); FMLInterModComms.sendMessage(Util.MODID, "addDryingRecipe", tagCompound); } public static void addDryingRackRecipe(ItemStack input, String output, int timeSeconds){ NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setTag("input", input.writeToNBT(new NBTTagCompound())); tagCompound.setString("output", output); tagCompound.setInteger("time", timeSeconds); FMLInterModComms.sendMessage(Util.MODID, "addDryingRecipe", tagCompound); } public static void addDryingRackRecipe(String input, String output, int timeSeconds){ NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setString("input", input); tagCompound.setString("output", output); tagCompound.setInteger("time", timeSeconds); FMLInterModComms.sendMessage(Util.MODID, "addDryingRecipe", tagCompound); } }
TESLA
package com.modHelpers; import net.darkhax.tesla.api.implementation.BaseTeslaContainer; import net.darkhax.tesla.api.implementation.BaseTeslaContainerProvider; import net.darkhax.tesla.capability.TeslaCapabilities; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import java.util.List; /** * Called from within the item code * @author ekul6547 * * put in Item code: boolean powered = Loader.isModLoaded("tesla"); //true if mod loaded. Put all HelperTESLA in an if statement of this to allow items to exist without power @Override public ICapabilityProvider initCapabilities(final ItemStack stack, NBTTagCompound nbt) { if(powered) { return new HelperTESLA.powerProvider(stack, maxCapacity, inputRate, outputRate); }else{ return null; }} */ public class HelperTESLA { public static class powerProvider extends BaseTeslaContainerProvider{ public powerProvider(final ItemStack stack, int capacity, int input, int output){ super(new BaseTeslaContainer(20000, 20, 20){ @Override public long givePower(long Tesla, boolean simulated) { //setDamage(stack, 0); return super.givePower(Tesla, simulated); } @Override public long takePower(long Tesla, boolean simulated) { //setDamage(stack, 0); return super.takePower(Tesla, simulated); } }); } } public static class displayInfo { public displayInfo(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced){ final BaseTeslaContainer container = (BaseTeslaContainer) stack.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN); stack.setItemDamage(((int) (container.getStoredPower()/container.getCapacity())*stack.getMaxDamage())); tooltip.add("Power: " + container.getStoredPower() + "/" + container.getCapacity()); } } /** * Take power from stack * @param stack * @param amount * @return returns the amount taken (so if only 8 is left, and you asked for 20, it will return 8) * Also wont return above the output rate */ public static long takePower(ItemStack stack, int amount) { BaseTeslaContainer container = (BaseTeslaContainer) stack.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN); return container.takePower(amount, false); } /** * Check if you can take from stack * @param stack * @param amount * @return returns true if you can take a certain amount of power from a container */ public static boolean canTake(ItemStack stack, int amount){ BaseTeslaContainer container = (BaseTeslaContainer) stack.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN); return (getPower(stack) - amount >= 0); } /** * Give power to stack * @param stack * @param amount * @return returns the amount accepted (so if you gave it 20, and it could only support 8 more, it will return 8) * (so do amount - returned amount to see non-accepted energy) * Also wont accept over input rate */ public static long givePower(ItemStack stack, int amount) { BaseTeslaContainer container = (BaseTeslaContainer) stack.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN); return container.givePower(amount, false); } /** * Check if you can give to stack * @param stack * @param amount * @return returns true if you can give a certain amount of power to a container */ public static boolean canGive(ItemStack stack, int amount){ BaseTeslaContainer container = (BaseTeslaContainer) stack.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN); return (getPower(stack) + amount <= getMaxPower(stack)); } public static long getPower(ItemStack stack) { BaseTeslaContainer container = (BaseTeslaContainer) stack.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN); return container.getStoredPower(); } public static long getMaxPower(ItemStack stack){ BaseTeslaContainer container = (BaseTeslaContainer) stack.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN); return container.getCapacity(); } public static long getInputRate(ItemStack stack){ BaseTeslaContainer container = (BaseTeslaContainer) stack.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN); return container.getInputRate(); } public static long getOutputRate(ItemStack stack){ BaseTeslaContainer container = (BaseTeslaContainer) stack.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN); return container.getOutputRate(); } }
Examples
IC2 Example (ProjectE is basically the same)
public static void LoadIC2(){ //Called from Init if(Loader.isModLoaded("IC2")){ try { HelperIC2.addMaceratorRecipe(new ItemStack(Items.DIAMOND,1),new ItemStack(Items.COAL,1)); HelperIC2.addMaceratorRecipe(new ItemStack(Items.GOLD_INGOT,1),new ItemStack(Items.GOLDEN_APPLE,1)); }catch(java.lang.NoClassDefFoundError Nclass){ System.out.println("EKUL:IC2:"+Nclass); } } }
JEI Example
public static void LoadJEI(){ //Called from preInit if(Loader.isModLoaded("JEI")){ try{ HelperJei.addJEIDescription(new ItemStack(Blocks.BEDROCK),"Bedrock can be harvested!"); }catch(java.lang.NullPointerException nullus){ System.out.println("EKUL:JEI:"+nullus); } } }
Loot Example
@SubscribeEvent public void lootTableLoad(LootTableLoadEvent event){ if(event.getName().getResourcePath().equals("entities/sheep/blue")){ LootTable loot = event.getTable(); HelperLoot.addItemToTable(loot,Blocks.LAPIS_BLOCK,1,1F,0.5F,0,1,0F,1F,"minecraft:lapis_block"); } }
Tinkers Construct example
public static void LoadTinker(){ if(Loader.isModLoaded("tconstruct")){ try{ ModTinkersIntegration.LoadTinkers(); }catch(java.lang.NoClassDefFoundError Nclass){ System.out.println("TINKER:"+Nclass); } } }
public class ModTinkersIntegration { public static void LoadTinkers(){ Fluid runicFluid = HelperTinker.newFluid("RunicF", 0xf0312f, true, "Runic", true); Material runicMat = HelperTinker.newMaterial("runic",0xf0312f, "gemRunic", false); runicMat = HelperTinker.addRepresentativeItem(runicMat, new ItemStack(EkulItems.item_runicGem)); runicMat = HelperTinker.setCastingFluid(runicMat, runicFluid); runicMat = HelperTinker.addGlobalTraits(runicMat, TinkerTraits.writable, TinkerTraits.dense, TinkerTraits.sharp); runicMat = HelperTinker.addMaterialStats(runicMat, new HeadMaterialStats(6192, 16, 10, 5), new HandleMaterialStats(2.0f, 6192), new ExtraMaterialStats(256), new BowMaterialStats(0.3f, 7f, 9f)); HelperTinker.registerMat(runicMat); HelperTinker.addMeltingRecipe(new ItemStack(EkulBlocks.block_runiBlock), new FluidStack(runicFluid,144)); } }
TESLA example
import com.modHelpers.HelperTESLA; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.fml.common.Loader; import java.util.List; public class ItemBattery extends Item{ public String name; boolean powered = Loader.isModLoaded("tesla"); public ItemBattery(String name) { this.name = name; setUnlocalizedName(name); setRegistryName(name); } @Override public void registerItemModel(Item item) { ModClass.proxy.registerItemRenderer(item, 0, name); } @Override public void addInformation (ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) { super.addInformation(stack, player, tooltip, advanced); if(powered) { new HelperTESLA.displayInfo(stack, player, tooltip, advanced); } } @Override public ICapabilityProvider initCapabilities(final ItemStack stack, NBTTagCompound nbt) { if(powered) { return new HelperTESLA.powerProvider(stack, 20000, 200, 200); }else{ return null; } } }
Planned Helpers
- EnderIO
- InvTweaks
- Nether Metals
- RFTools
- Waila
- MultiPart
- AbyssalCraft
- Forestry
- AE2
- bauble
- TESLA
- Blood magic
- Botania
I will try to work on new ones. I don't have much free time, so any help is appreciated.
If you want to create a helper, I can list it here, just make it follow one rule: It won't cause your own mod to require the other mod to load.
You can find my mod here: It incorporates many of these helpers
https://minecraft.curseforge.com/projects/ekuls-mod
Source can be found here to see how I used these:
https://github.com/ekul6547/Ekuls-Mod-2
Any questions? Ask in the comments below. I will attempt to answer them.