├── .idea ├── .name ├── highlighting.xml ├── scopes │ ├── lib.xml │ ├── main.xml │ └── scope_settings.xml ├── vcs.xml ├── encodings.xml ├── modules.xml ├── inspectionProfiles │ ├── profiles_settings.xml │ └── Project_Default.xml ├── copyright │ ├── profiles_settings.xml │ ├── MMPL__lib_.xml │ └── MMPL__neiaddons_.xml ├── scala_settings.xml ├── scala_compiler.xml ├── gradle.xml ├── compiler.xml ├── misc.xml ├── codeStyleSettings.xml └── uiDesigner.xml ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── resources ├── assets │ └── neiaddons │ │ ├── textures │ │ ├── gui │ │ │ ├── breeding.png │ │ │ ├── breeding.psd │ │ │ ├── exnihilo.png │ │ │ ├── exnihilo.psd │ │ │ ├── isolator.png │ │ │ ├── isolator.psd │ │ │ ├── products.png │ │ │ └── products.psd │ │ └── items │ │ │ └── invalid.png │ │ └── lang │ │ ├── ru_RU.lang │ │ ├── it_IT.lang │ │ ├── zh_CN.lang │ │ ├── cs_CZ.lang │ │ ├── en_US.lang │ │ ├── fr_CA.lang │ │ └── fr_FR.lang ├── neiaddons_at.cfg └── mcmod.info ├── .gitignore ├── readme.md ├── src └── net │ └── bdew │ └── neiaddons │ ├── appeng │ ├── AppEngHelper.java │ ├── SlotHelper.java │ ├── SetFakeSlotCommandHandler.java │ ├── AddonAppeng.java │ └── AppEngGuiHandler.java │ ├── api │ ├── SubPacketHandler.java │ └── NEIAddon.java │ ├── developer │ ├── DeveloperHelper.java │ ├── AddonDeveloper.java │ └── DeveloperGuiHandler.java │ ├── forestry │ ├── bees │ │ ├── BeeBreedingHandler.java │ │ ├── BeeProduceHandler.java │ │ └── BeeHelper.java │ ├── trees │ │ ├── TreeBreedingHandler.java │ │ ├── TreeProduceHandler.java │ │ └── TreeHelper.java │ ├── butterflies │ │ ├── ButterflyBreedingHandler.java │ │ └── ButterflyHelper.java │ ├── MutationDumper.scala │ ├── AddonForestry.java │ ├── GeneticsUtils.java │ ├── BaseProduceRecipeHandler.java │ └── BaseBreedingRecipeHandler.java │ ├── utils │ ├── PositionedStackWithTip.java │ ├── ItemStackWithTip.java │ ├── LabeledPositionedStack.java │ ├── TypedField.java │ ├── ModItemFilter.java │ ├── TypedMethod.java │ ├── SetRecipeCommandHandler.java │ └── CustomOverlayHandler.java │ ├── botany │ ├── flowers │ │ ├── FlowerBreedingHandler.java │ │ └── FlowerHelper.java │ └── AddonBotany.java │ ├── crafting │ ├── AddonCraftingTablesClient.java │ └── AddonCraftingTables.java │ ├── network │ ├── PacketHelper.java │ ├── NBTMessageCodec.java │ ├── ClientHandler.java │ ├── NetChannel.java │ └── ServerHandler.java │ ├── NEIAddonsConfig.java │ ├── exnihilo │ ├── WailaHandler.java │ ├── AddonExnihilo.java │ └── waila │ │ ├── BeeTrapHandler.java │ │ ├── BarrelHandler.java │ │ └── CrucibleHandler.java │ ├── BaseAddon.java │ ├── NEIAddons.java │ └── Utils.java ├── gradlew.bat ├── MMPL-1.0.txt └── gradlew /.idea/.name: -------------------------------------------------------------------------------- 1 | neiaddons -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'neiaddons' -------------------------------------------------------------------------------- /.idea/highlighting.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bdew-minecraft/neiaddons/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.idea/scopes/lib.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /resources/assets/neiaddons/textures/gui/breeding.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bdew-minecraft/neiaddons/HEAD/resources/assets/neiaddons/textures/gui/breeding.png -------------------------------------------------------------------------------- /resources/assets/neiaddons/textures/gui/breeding.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bdew-minecraft/neiaddons/HEAD/resources/assets/neiaddons/textures/gui/breeding.psd -------------------------------------------------------------------------------- /resources/assets/neiaddons/textures/gui/exnihilo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bdew-minecraft/neiaddons/HEAD/resources/assets/neiaddons/textures/gui/exnihilo.png -------------------------------------------------------------------------------- /resources/assets/neiaddons/textures/gui/exnihilo.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bdew-minecraft/neiaddons/HEAD/resources/assets/neiaddons/textures/gui/exnihilo.psd -------------------------------------------------------------------------------- /resources/assets/neiaddons/textures/gui/isolator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bdew-minecraft/neiaddons/HEAD/resources/assets/neiaddons/textures/gui/isolator.png -------------------------------------------------------------------------------- /resources/assets/neiaddons/textures/gui/isolator.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bdew-minecraft/neiaddons/HEAD/resources/assets/neiaddons/textures/gui/isolator.psd -------------------------------------------------------------------------------- /resources/assets/neiaddons/textures/gui/products.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bdew-minecraft/neiaddons/HEAD/resources/assets/neiaddons/textures/gui/products.png -------------------------------------------------------------------------------- /resources/assets/neiaddons/textures/gui/products.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bdew-minecraft/neiaddons/HEAD/resources/assets/neiaddons/textures/gui/products.psd -------------------------------------------------------------------------------- /resources/assets/neiaddons/textures/items/invalid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bdew-minecraft/neiaddons/HEAD/resources/assets/neiaddons/textures/items/invalid.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /out 3 | /build 4 | /run 5 | /.idea/workspace.xml 6 | /.idea/dictionaries 7 | /eclipse 8 | /.gradle 9 | /*.iml 10 | /*.ipr 11 | /.idea/libraries/Gradle__* 12 | -------------------------------------------------------------------------------- /.idea/scopes/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Jul 02 15:54:47 CDT 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-bin.zip 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/scala_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /resources/neiaddons_at.cfg: -------------------------------------------------------------------------------- 1 | # Shamelessly stolen from NEI 2 | public net.minecraft.client.gui.inventory.GuiContainer field_146999_f #xSize 3 | public net.minecraft.client.gui.inventory.GuiContainer field_147000_g #ySize 4 | public net.minecraft.client.gui.inventory.GuiContainer field_147003_i #guiLeft 5 | public net.minecraft.client.gui.inventory.GuiContainer field_147009_r #guiTop 6 | -------------------------------------------------------------------------------- /.idea/scala_compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | NEI Addons 2 | ========== 3 | 4 | ### [Mod documentation and downloads](http://bdew.net/neiaddons) 5 | ### [Downloads on CurseForge](http://minecraft.curseforge.com/mc-mods/nei-addons/files/) 6 | ### [Minecraft Forums thread](http://www.minecraftforum.net/topic/1803460-) 7 | 8 | 9 | This mod is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. 10 | 11 | Please check the contents of the license located in https://raw.github.com/bdew/neiaddons/master/MMPL-1.0.txt 12 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15 | 16 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/appeng/AppEngHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.appeng; 11 | 12 | import codechicken.nei.api.API; 13 | 14 | public class AppEngHelper { 15 | public static void init() { 16 | API.registerNEIGuiHandler(new AppEngGuiHandler()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/api/SubPacketHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.api; 11 | 12 | import net.minecraft.entity.player.EntityPlayerMP; 13 | import net.minecraft.nbt.NBTTagCompound; 14 | 15 | public interface SubPacketHandler { 16 | void handle(NBTTagCompound data, EntityPlayerMP player); 17 | } 18 | -------------------------------------------------------------------------------- /.idea/copyright/MMPL__lib_.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/developer/DeveloperHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.developer; 11 | 12 | import codechicken.nei.guihook.GuiContainerManager; 13 | 14 | public class DeveloperHelper { 15 | public static void init() { 16 | GuiContainerManager.addTooltipHandler(new DeveloperGuiHandler()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.idea/copyright/MMPL__neiaddons_.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/forestry/bees/BeeBreedingHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.forestry.bees; 11 | 12 | import net.bdew.neiaddons.forestry.BaseBreedingRecipeHandler; 13 | 14 | public class BeeBreedingHandler extends BaseBreedingRecipeHandler { 15 | 16 | public BeeBreedingHandler() { 17 | super(BeeHelper.root); 18 | } 19 | 20 | @Override 21 | public String getRecipeIdent() { 22 | return "beebreeding"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/utils/PositionedStackWithTip.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.utils; 11 | 12 | import codechicken.nei.PositionedStack; 13 | 14 | import java.util.List; 15 | 16 | public class PositionedStackWithTip extends PositionedStack { 17 | public List tip; 18 | 19 | public PositionedStackWithTip(ItemStackWithTip stack, int x, int y) { 20 | super(stack.itemStack, x, y); 21 | this.tip = stack.tip; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/forestry/trees/TreeBreedingHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.forestry.trees; 11 | 12 | import net.bdew.neiaddons.forestry.BaseBreedingRecipeHandler; 13 | 14 | public class TreeBreedingHandler extends BaseBreedingRecipeHandler { 15 | 16 | public TreeBreedingHandler() { 17 | super(TreeHelper.root); 18 | } 19 | 20 | @Override 21 | public String getRecipeIdent() { 22 | return "treebreeding"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/botany/flowers/FlowerBreedingHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.botany.flowers; 11 | 12 | import net.bdew.neiaddons.forestry.BaseBreedingRecipeHandler; 13 | 14 | public class FlowerBreedingHandler extends BaseBreedingRecipeHandler { 15 | 16 | public FlowerBreedingHandler() { 17 | super(FlowerHelper.root); 18 | } 19 | 20 | @Override 21 | public String getRecipeIdent() { 22 | return "flowerbreeding"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/forestry/butterflies/ButterflyBreedingHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.forestry.butterflies; 11 | 12 | import net.bdew.neiaddons.forestry.BaseBreedingRecipeHandler; 13 | 14 | public class ButterflyBreedingHandler extends BaseBreedingRecipeHandler { 15 | 16 | public ButterflyBreedingHandler() { 17 | super(ButterflyHelper.root); 18 | } 19 | 20 | @Override 21 | public String getRecipeIdent() { 22 | return "butterflybreeding"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/appeng/SlotHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.appeng; 11 | 12 | import net.minecraft.inventory.Slot; 13 | 14 | public class SlotHelper { 15 | public static boolean isSlotEnabled(Slot s) { 16 | if (AddonAppeng.clsSlotFake.isInstance(s)) { 17 | try { 18 | return (Boolean) AddonAppeng.mSlotFakeIsEnabled.invoke(s); 19 | } catch (Throwable e) { 20 | return false; 21 | } 22 | } else { 23 | return false; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/api/NEIAddon.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.api; 11 | 12 | import cpw.mods.fml.relauncher.Side; 13 | 14 | public interface NEIAddon { 15 | String getName(); 16 | 17 | boolean isActive(); 18 | 19 | boolean isEnabledByDefault(); 20 | 21 | /** 22 | * Called from FMLPreInitializationEvent 23 | * 24 | * @throws Exception 25 | */ 26 | @SuppressWarnings("RedundantThrows") 27 | void init(Side side) throws Exception; 28 | 29 | /** 30 | * Called from NEI loadConfig 31 | */ 32 | void loadClient(); 33 | } 34 | -------------------------------------------------------------------------------- /resources/assets/neiaddons/lang/ru_RU.lang: -------------------------------------------------------------------------------- 1 | bdew.neiaddons.genetics=Forestry: Генетика 2 | bdew.neiaddons.exnihilo=Ex Nihilo 3 | 4 | bdew.neiaddons.breeding.beebreeding=Разведение пчёл 5 | bdew.neiaddons.produce.beeproduce=Продукты пчёл 6 | 7 | bdew.neiaddons.breeding.treebreeding=Разведение деревьев 8 | bdew.neiaddons.produce.treeproduce=Продукты деревьев 9 | 10 | bdew.neiaddons.breeding.flowerbreeding=Разведение цветов 11 | 12 | bdew.neiaddons.breeding.butterflybreeding=Разведение бабочек 13 | 14 | bdew.exnihilo.hammer.label=Молот ExNihilo 15 | bdew.exnihilo.sieve.label=Сито ExNihilo 16 | 17 | bdew.exnihilo.barrel.burn=Сгорит через %s секунд(-ы)!!! 18 | bdew.exnihilo.beetrap.spawn=Cпаунит: %s%% 19 | bdew.exnihilo.crucible.fluid=Жидкость: %s %s мВ 20 | bdew.exnihilo.crucible.solid=Твёрдая масса: %s %s 21 | 22 | bdew.neiaddons.noserver=Для этой функции NEI Addons требуется установить на сервер 23 | -------------------------------------------------------------------------------- /resources/assets/neiaddons/lang/it_IT.lang: -------------------------------------------------------------------------------- 1 | bdew.neiaddons.genetics=Forestry genetica 2 | bdew.neiaddons.exnihilo=Ex Nihilo 3 | 4 | bdew.neiaddons.breeding.beebreeding=Incrocio di api 5 | bdew.neiaddons.produce.beeproduce=Produz. di api 6 | 7 | bdew.neiaddons.breeding.treebreeding=Incrocio di alberi 8 | bdew.neiaddons.produce.treeproduce=Produz. di alberi 9 | 10 | bdew.neiaddons.breeding.flowerbreeding=Incrocio di fiori 11 | 12 | bdew.neiaddons.breeding.butterflybreeding=Incroc. di farfalle 13 | 14 | bdew.exnihilo.hammer.label=ExNihilo Martello 15 | bdew.exnihilo.sieve.label=ExNihilo Setaccio 16 | 17 | bdew.exnihilo.barrel.burn=Brucierà per %s secondi!!! 18 | bdew.exnihilo.beetrap.spawn=Generazione: %s%% 19 | bdew.exnihilo.crucible.fluid=Fluidi: %s %s mB 20 | bdew.exnihilo.crucible.solid=Solidi: %s %s 21 | 22 | bdew.neiaddons.noserver=Questa funzione richiede che NEI Addons sia insallato sul server 23 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/utils/ItemStackWithTip.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.utils; 11 | 12 | import net.minecraft.item.ItemStack; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | public class ItemStackWithTip { 18 | public ItemStack itemStack; 19 | public List tip; 20 | 21 | public ItemStackWithTip(ItemStack itemStack) { 22 | this(itemStack, new ArrayList()); 23 | } 24 | 25 | public ItemStackWithTip(ItemStack itemStack, List tip) { 26 | this.itemStack = itemStack; 27 | this.tip = tip; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/crafting/AddonCraftingTablesClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.crafting; 11 | 12 | import codechicken.nei.api.API; 13 | import codechicken.nei.recipe.DefaultOverlayHandler; 14 | import net.minecraft.client.gui.inventory.GuiContainer; 15 | 16 | class AddonCraftingTablesClient { 17 | public static void load() { 18 | for (Class tableClass : AddonCraftingTables.craftingTables) { 19 | API.registerGuiOverlay(tableClass, "crafting"); 20 | API.registerGuiOverlayHandler(tableClass, new DefaultOverlayHandler(), "crafting"); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /resources/assets/neiaddons/lang/zh_CN.lang: -------------------------------------------------------------------------------- 1 | bdew.neiaddons.genetics=林业基因 2 | bdew.neiaddons.exnihilo=无中生有 3 | 4 | bdew.neiaddons.breeding.beebreeding=蜜蜂杂交 5 | bdew.neiaddons.produce.beeproduce=蜜蜂产物 6 | 7 | bdew.neiaddons.breeding.treebreeding=树木杂交 8 | bdew.neiaddons.produce.treeproduce=树木产物 9 | 10 | bdew.neiaddons.breeding.flowerbreeding=花卉杂交 11 | 12 | bdew.neiaddons.breeding.butterflybreeding=蝴蝶杂交 13 | 14 | bdew.exnihilo.hammer.label=无中生有-锤 15 | bdew.exnihilo.sieve.label=无中生有-筛子 16 | 17 | bdew.exnihilo.barrel.burn=将在 %s 后燃烧!!! 18 | bdew.exnihilo.beetrap.spawn=生成: %s%% 19 | bdew.exnihilo.crucible.fluid=流体: %s %s mB 20 | bdew.exnihilo.crucible.solid=固体: %s %s 21 | 22 | bdew.neiaddons.noserver=本功能需要在NEI Addons被安装到服务器端后才被支持 23 | 24 | nei.options.tools.dump.neiaddons=NEI Addons 25 | nei.options.tools.dump.neiaddons.dumped=%s 已导出至 %s 26 | nei.options.tools.dump.neiaddons.bee_mutations=蜜蜂变异 27 | nei.options.tools.dump.neiaddons.tree_mutations=树木变异 28 | nei.options.tools.dump.neiaddons.flower_mutations=花卉变异 29 | -------------------------------------------------------------------------------- /resources/assets/neiaddons/lang/cs_CZ.lang: -------------------------------------------------------------------------------- 1 | bdew.neiaddons.genetics=Forestry Genetics 2 | bdew.neiaddons.exnihilo=Ex Nihilo 3 | 4 | bdew.neiaddons.breeding.beebreeding=Množení včel 5 | bdew.neiaddons.produce.beeproduce=Produkce včel 6 | 7 | bdew.neiaddons.breeding.treebreeding=Množení stromů 8 | bdew.neiaddons.produce.treeproduce=Produkce stromů 9 | 10 | bdew.neiaddons.breeding.flowerbreeding=Množení kytek 11 | 12 | bdew.neiaddons.breeding.butterflybreeding=Množení motýlů 13 | 14 | bdew.exnihilo.hammer.label=ExNihilovo kladivo 15 | bdew.exnihilo.sieve.label=ExNihilovo síto 16 | 17 | bdew.exnihilo.barrel.burn=Shoří za %s sekund!!! 18 | bdew.exnihilo.beetrap.spawn=Spawnuji: %s%% 19 | bdew.exnihilo.crucible.fluid=Tekutina: %s %s mB 20 | bdew.exnihilo.crucible.solid=Pevné: %s %s 21 | 22 | bdew.neiaddons.noserver=Tato funkce vyžaduje instalaci NEI Addons na server 23 | 24 | nei.options.tools.dump.neiaddons=NEI Addons 25 | nei.options.tools.dump.neiaddons.dumped=%s vypsáno do %s 26 | nei.options.tools.dump.neiaddons.bee_mutations=Mutace včel 27 | nei.options.tools.dump.neiaddons.tree_mutations=Mutace stromů 28 | nei.options.tools.dump.neiaddons.flower_mutations=Mutace kytek 29 | -------------------------------------------------------------------------------- /resources/assets/neiaddons/lang/en_US.lang: -------------------------------------------------------------------------------- 1 | bdew.neiaddons.genetics=Forestry Genetics 2 | bdew.neiaddons.exnihilo=Ex Nihilo 3 | 4 | bdew.neiaddons.breeding.beebreeding=Bee Breeding 5 | bdew.neiaddons.produce.beeproduce=Bee Produce 6 | 7 | bdew.neiaddons.breeding.treebreeding=Tree Breeding 8 | bdew.neiaddons.produce.treeproduce=Tree Produce 9 | 10 | bdew.neiaddons.breeding.flowerbreeding=Flower Breeding 11 | 12 | bdew.neiaddons.breeding.butterflybreeding=Butterfly Breeding 13 | 14 | bdew.exnihilo.hammer.label=ExNihilo Hammer 15 | bdew.exnihilo.sieve.label=ExNihilo Sieve 16 | 17 | bdew.exnihilo.barrel.burn=Will burn in %s seconds!!! 18 | bdew.exnihilo.beetrap.spawn=Spawning: %s%% 19 | bdew.exnihilo.crucible.fluid=Fluid: %s %s mB 20 | bdew.exnihilo.crucible.solid=Solid: %s %s 21 | 22 | bdew.neiaddons.noserver=This function requires NEI Addons to be installed on the server 23 | 24 | nei.options.tools.dump.neiaddons=NEI Addons 25 | nei.options.tools.dump.neiaddons.dumped=%s dumped to %s 26 | nei.options.tools.dump.neiaddons.bee_mutations=Bee Mutations 27 | nei.options.tools.dump.neiaddons.tree_mutations=Tree Mutations 28 | nei.options.tools.dump.neiaddons.flower_mutations=Flower Mutations 29 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/network/PacketHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.network; 11 | 12 | import net.bdew.neiaddons.NEIAddons; 13 | import net.minecraft.entity.player.EntityPlayerMP; 14 | import net.minecraft.nbt.NBTTagCompound; 15 | 16 | public class PacketHelper { 17 | private static NBTTagCompound makePacket(String cmd, NBTTagCompound data) { 18 | NBTTagCompound nbt = new NBTTagCompound(); 19 | 20 | nbt.setString("cmd", cmd); 21 | nbt.setTag("data", data); 22 | 23 | return nbt; 24 | } 25 | 26 | public static void sendToServer(String cmd, NBTTagCompound data) { 27 | 28 | NEIAddons.channel.sendToServer(makePacket(cmd, data)); 29 | } 30 | 31 | public static void sendToClient(String cmd, NBTTagCompound data, EntityPlayerMP player) { 32 | NEIAddons.channel.sendTo(makePacket(cmd, data), player); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/NEIAddonsConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons; 11 | 12 | import codechicken.nei.api.IConfigureNEI; 13 | import net.bdew.neiaddons.api.NEIAddon; 14 | 15 | public class NEIAddonsConfig implements IConfigureNEI { 16 | @Override 17 | public void loadConfig() { 18 | for (NEIAddon addon : NEIAddons.addons) { 19 | if (addon.isActive()) { 20 | try { 21 | addon.loadClient(); 22 | } catch (Throwable e) { 23 | NEIAddons.logWarningExc(e, "Addon %s failed client initialization", addon.getName()); 24 | } 25 | } 26 | } 27 | } 28 | 29 | @Override 30 | public String getName() { 31 | return "NEI Addons"; 32 | } 33 | 34 | @Override 35 | public String getVersion() { 36 | return "NEIADDONS_VER"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /resources/assets/neiaddons/lang/fr_CA.lang: -------------------------------------------------------------------------------- 1 | bdew.neiaddons.genetics=Forestry Genetics 2 | bdew.neiaddons.exnihilo=Ex Nihilo 3 | 4 | bdew.neiaddons.breeding.beebreeding=Élevage d'abeille 5 | bdew.neiaddons.produce.beeproduce=Production d'abeille 6 | 7 | bdew.neiaddons.breeding.treebreeding=Arboriculture 8 | bdew.neiaddons.produce.treeproduce=Production arboricole 9 | 10 | bdew.neiaddons.breeding.flowerbreeding=Horticulture 11 | 12 | bdew.neiaddons.breeding.butterflybreeding=Élevage de papillon 13 | 14 | bdew.exnihilo.hammer.label=Marteau ExNihilo 15 | bdew.exnihilo.sieve.label=Tamis ExNihilo 16 | 17 | bdew.exnihilo.barrel.burn=Brulera en %s secondes!!! 18 | bdew.exnihilo.beetrap.spawn=Engendrement: %s%% 19 | bdew.exnihilo.crucible.fluid=Fluide: %s %s mB 20 | bdew.exnihilo.crucible.solid=Solide: %s %s 21 | 22 | bdew.neiaddons.noserver=Cette fonction exige que NEI Addons soit installé sur le serveur 23 | 24 | nei.options.tools.dump.neiaddons=NEI Addons 25 | nei.options.tools.dump.neiaddons.dumped=%s a déposé à %s 26 | nei.options.tools.dump.neiaddons.bee_mutations=Mutations d'abeille 27 | nei.options.tools.dump.neiaddons.tree_mutations=Mutations d'arbre 28 | nei.options.tools.dump.neiaddons.flower_mutations=Mutations de fleur 29 | -------------------------------------------------------------------------------- /resources/assets/neiaddons/lang/fr_FR.lang: -------------------------------------------------------------------------------- 1 | bdew.neiaddons.genetics=Forestry Genetics 2 | bdew.neiaddons.exnihilo=Ex Nihilo 3 | 4 | bdew.neiaddons.breeding.beebreeding=Élevage d'abeille 5 | bdew.neiaddons.produce.beeproduce=Production d'abeille 6 | 7 | bdew.neiaddons.breeding.treebreeding=Arboriculture 8 | bdew.neiaddons.produce.treeproduce=Production arboricole 9 | 10 | bdew.neiaddons.breeding.flowerbreeding=Horticulture 11 | 12 | bdew.neiaddons.breeding.butterflybreeding=Élevage de papillon 13 | 14 | bdew.exnihilo.hammer.label=Marteau ExNihilo 15 | bdew.exnihilo.sieve.label=Tamis ExNihilo 16 | 17 | bdew.exnihilo.barrel.burn=Brulera en %s secondes!!! 18 | bdew.exnihilo.beetrap.spawn=Engendrement: %s%% 19 | bdew.exnihilo.crucible.fluid=Fluide: %s %s mB 20 | bdew.exnihilo.crucible.solid=Solide: %s %s 21 | 22 | bdew.neiaddons.noserver=Cette fonction exige que NEI Addons soit installé sur le serveur 23 | 24 | nei.options.tools.dump.neiaddons=NEI Addons 25 | nei.options.tools.dump.neiaddons.dumped=%s a déposé à %s 26 | nei.options.tools.dump.neiaddons.bee_mutations=Mutations d'abeille 27 | nei.options.tools.dump.neiaddons.tree_mutations=Mutations d'arbre 28 | nei.options.tools.dump.neiaddons.flower_mutations=Mutations de fleur 29 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/forestry/bees/BeeProduceHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.forestry.bees; 11 | 12 | import forestry.api.apiculture.IAlleleBeeSpecies; 13 | import forestry.api.genetics.IAlleleSpecies; 14 | import net.bdew.neiaddons.forestry.BaseProduceRecipeHandler; 15 | import net.minecraft.item.Item; 16 | 17 | import java.util.Collection; 18 | import java.util.Map; 19 | 20 | public class BeeProduceHandler extends BaseProduceRecipeHandler { 21 | 22 | public BeeProduceHandler() { 23 | super(BeeHelper.root); 24 | } 25 | 26 | @Override 27 | public String getRecipeIdent() { 28 | return "beeproduce"; 29 | } 30 | 31 | @Override 32 | public Collection getAllSpecies() { 33 | return BeeHelper.allSpecies; 34 | } 35 | 36 | @Override 37 | public Map> getProduceCache() { 38 | return BeeHelper.productsCache; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/forestry/trees/TreeProduceHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.forestry.trees; 11 | 12 | import forestry.api.arboriculture.IAlleleTreeSpecies; 13 | import forestry.api.genetics.IAlleleSpecies; 14 | import net.bdew.neiaddons.forestry.BaseProduceRecipeHandler; 15 | import net.minecraft.item.Item; 16 | 17 | import java.util.Collection; 18 | import java.util.Map; 19 | 20 | public class TreeProduceHandler extends BaseProduceRecipeHandler { 21 | 22 | public TreeProduceHandler() { 23 | super(TreeHelper.root); 24 | } 25 | 26 | @Override 27 | public String getRecipeIdent() { 28 | return "treeproduce"; 29 | } 30 | 31 | @Override 32 | public Collection getAllSpecies() { 33 | return TreeHelper.allSpecies; 34 | } 35 | 36 | @Override 37 | public Map> getProduceCache() { 38 | return TreeHelper.productsCache; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/utils/LabeledPositionedStack.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.utils; 11 | 12 | import codechicken.nei.PositionedStack; 13 | import net.bdew.neiaddons.Utils; 14 | 15 | public class LabeledPositionedStack extends PositionedStack { 16 | 17 | private final String label; 18 | private final int yoffs; 19 | 20 | public LabeledPositionedStack(Object stack, int x, int y, String label, int yoffs) { 21 | super(stack, x, y); 22 | this.label = label; 23 | this.yoffs = yoffs; 24 | } 25 | 26 | public void drawLabel() { 27 | if (label.contains(" ")) { 28 | String[] parts = label.split(" "); 29 | for (int i = 0; i < parts.length; i++) { 30 | Utils.drawCenteredString(parts[i], relx + 8, rely + 8 + yoffs + 9 * i, 0xFFFFFF); 31 | } 32 | } else { 33 | Utils.drawCenteredString(label, relx + 8, rely + 8 + yoffs, 0xFFFFFF); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /.idea/codeStyleSettings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 26 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/utils/TypedField.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.utils; 11 | 12 | import java.lang.reflect.Field; 13 | 14 | public class TypedField { 15 | private Field field; 16 | private Class cls; 17 | 18 | public TypedField(Field field, Class cls) { 19 | this.field = field; 20 | this.cls = cls; 21 | } 22 | 23 | @SuppressWarnings("unchecked") 24 | public T get(Object obj) { 25 | try { 26 | Object res = field.get(obj); 27 | if (cls.isInstance(res)) 28 | return (T) res; 29 | else 30 | throw new RuntimeException(String.format("Wrong field type. Expected %s, got %s", cls, res.getClass())); 31 | } catch (IllegalAccessException e) { 32 | throw new RuntimeException(e); 33 | } 34 | } 35 | 36 | public static TypedField from(Class cls, String name, Class result) throws NoSuchFieldException { 37 | return new TypedField(cls.getField(name), result); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/utils/ModItemFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.utils; 11 | 12 | import codechicken.nei.api.ItemFilter; 13 | import net.minecraft.item.Item; 14 | import net.minecraft.item.ItemBlock; 15 | import net.minecraft.item.ItemStack; 16 | 17 | public class ModItemFilter implements ItemFilter { 18 | private String modId; 19 | private Boolean items; 20 | 21 | public ModItemFilter(String modId, Boolean items) { 22 | this.modId = modId; 23 | this.items = items; 24 | } 25 | 26 | @Override 27 | public boolean matches(ItemStack item) { 28 | if (item == null || item.getItem() == null) return false; 29 | if (item.getItem() instanceof ItemBlock && items) return false; 30 | if (!(item.getItem() instanceof ItemBlock) && !items) return false; 31 | String itemName = Item.itemRegistry.getNameForObject(item.getItem()); 32 | if (itemName == null) return false; 33 | String[] s = itemName.split(":"); 34 | return (s.length > 1) && s[0].equals(modId); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/appeng/SetFakeSlotCommandHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.appeng; 11 | 12 | import net.bdew.neiaddons.api.SubPacketHandler; 13 | import net.minecraft.entity.player.EntityPlayerMP; 14 | import net.minecraft.inventory.Container; 15 | import net.minecraft.inventory.Slot; 16 | import net.minecraft.item.ItemStack; 17 | import net.minecraft.nbt.NBTTagCompound; 18 | 19 | public class SetFakeSlotCommandHandler implements SubPacketHandler { 20 | @Override 21 | public void handle(NBTTagCompound data, EntityPlayerMP player) { 22 | ItemStack stack = ItemStack.loadItemStackFromNBT(data.getCompoundTag("item")); 23 | int slotNum = data.getInteger("slot"); 24 | Container cont = player.openContainer; 25 | if ((cont != null) && AddonAppeng.clsBaseContainer.isInstance(cont)) { 26 | Slot slot = cont.getSlot(slotNum); 27 | if ((slot != null) && AddonAppeng.clsSlotFake.isInstance(slot) && SlotHelper.isSlotEnabled(slot)) { 28 | slot.putStack(stack); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 19 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/utils/TypedMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.utils; 11 | 12 | import java.lang.reflect.InvocationTargetException; 13 | import java.lang.reflect.Method; 14 | 15 | public class TypedMethod { 16 | private Method field; 17 | private Class cls; 18 | 19 | public TypedMethod(Method method, Class cls) { 20 | this.field = method; 21 | this.cls = cls; 22 | } 23 | 24 | @SuppressWarnings("unchecked") 25 | public T call(Object obj, Object... args) { 26 | try { 27 | Object res = field.invoke(obj, args); 28 | if (cls.isInstance(res)) 29 | return (T) res; 30 | else 31 | throw new RuntimeException(String.format("Wrong return type. Expected %s, got %s", cls, res.getClass())); 32 | } catch (IllegalAccessException e) { 33 | throw new RuntimeException(e); 34 | } catch (InvocationTargetException e) { 35 | throw new RuntimeException(e); 36 | } 37 | } 38 | 39 | public static TypedMethod from(Class cls, String name, Class result) throws NoSuchMethodException { 40 | return new TypedMethod(cls.getMethod(name), result); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/developer/AddonDeveloper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.developer; 11 | 12 | import cpw.mods.fml.common.Mod; 13 | import cpw.mods.fml.common.Mod.EventHandler; 14 | import cpw.mods.fml.common.Mod.Instance; 15 | import cpw.mods.fml.common.event.FMLPreInitializationEvent; 16 | import cpw.mods.fml.relauncher.Side; 17 | import cpw.mods.fml.relauncher.SideOnly; 18 | import net.bdew.neiaddons.BaseAddon; 19 | import net.bdew.neiaddons.NEIAddons; 20 | 21 | @Mod(modid = NEIAddons.modId + "|Developer", name = "NEI Addons: Developer Tools", version = "NEIADDONS_VER", dependencies = "after:NEIAddons") 22 | public class AddonDeveloper extends BaseAddon { 23 | 24 | @Instance(NEIAddons.modId + "|Developer") 25 | public static AddonDeveloper instance; 26 | 27 | @Override 28 | public String getName() { 29 | return "Developer Tools"; 30 | } 31 | 32 | @Override 33 | public boolean checkSide(Side side) { 34 | return side.isClient(); 35 | } 36 | 37 | @Override 38 | public boolean isEnabledByDefault() { 39 | return false; 40 | } 41 | 42 | @Override 43 | @EventHandler 44 | public void preInit(FMLPreInitializationEvent ev) { 45 | doPreInit(ev); 46 | } 47 | 48 | @Override 49 | public void init(Side side) throws Exception { 50 | active = true; 51 | } 52 | 53 | @Override 54 | @SideOnly(Side.CLIENT) 55 | public void loadClient() { 56 | DeveloperHelper.init(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/exnihilo/WailaHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.exnihilo; 11 | 12 | import mcp.mobius.waila.api.IWailaRegistrar; 13 | import net.bdew.neiaddons.Utils; 14 | import net.bdew.neiaddons.exnihilo.waila.BarrelHandler; 15 | import net.bdew.neiaddons.exnihilo.waila.BeeTrapHandler; 16 | import net.bdew.neiaddons.exnihilo.waila.CrucibleHandler; 17 | import net.minecraft.tileentity.TileEntity; 18 | 19 | public class WailaHandler { 20 | static public Class clsTeBarrel; 21 | static public Class clsTeCrucible; 22 | static public Class clsTeBeeTrap; 23 | 24 | static private void loadClasses() throws ClassNotFoundException { 25 | clsTeBarrel = Utils.getAndCheckClass("exnihilo.blocks.tileentities.TileEntityBarrel", TileEntity.class); 26 | clsTeCrucible = Utils.getAndCheckClass("exnihilo.blocks.tileentities.TileEntityCrucible", TileEntity.class); 27 | clsTeBeeTrap = Utils.getAndCheckClass("exnihilo.blocks.tileentities.TileEntityBeeTrap", TileEntity.class); 28 | } 29 | 30 | static public void loadCallback(IWailaRegistrar reg) { 31 | try { 32 | loadClasses(); 33 | reg.registerBodyProvider(new CrucibleHandler(), clsTeCrucible); 34 | reg.registerBodyProvider(new BarrelHandler(), clsTeBarrel); 35 | reg.registerBodyProvider(new BeeTrapHandler(), clsTeBeeTrap); 36 | } catch (Throwable t) { 37 | AddonExnihilo.instance.logWarning("WAILA support load failed: %s", t.toString()); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/exnihilo/AddonExnihilo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.exnihilo; 11 | 12 | import cpw.mods.fml.common.Mod; 13 | import cpw.mods.fml.common.Mod.EventHandler; 14 | import cpw.mods.fml.common.event.FMLInterModComms; 15 | import cpw.mods.fml.common.event.FMLPreInitializationEvent; 16 | import cpw.mods.fml.relauncher.Side; 17 | import cpw.mods.fml.relauncher.SideOnly; 18 | import net.bdew.neiaddons.BaseAddon; 19 | import net.bdew.neiaddons.NEIAddons; 20 | 21 | @Mod(modid = NEIAddons.modId + "|ExNihilo", name = "NEI Addons: Ex Nihilo", version = "NEIADDONS_VER", dependencies = "after:exnihilo") 22 | public class AddonExnihilo extends BaseAddon { 23 | @Mod.Instance(NEIAddons.modId + "|ExNihilo") 24 | public static AddonExnihilo instance; 25 | 26 | @Override 27 | public String getName() { 28 | return "Ex Nihilo"; 29 | } 30 | 31 | @Override 32 | public boolean checkSide(Side side) { 33 | return side.isClient(); 34 | } 35 | 36 | @Override 37 | public String[] getDependencies() { 38 | return new String[]{"exnihilo", "Waila"}; 39 | } 40 | 41 | @EventHandler 42 | public void preInit(FMLPreInitializationEvent ev) { 43 | doPreInit(ev); 44 | } 45 | 46 | @Override 47 | public void init(Side side) throws Exception { 48 | active = true; 49 | FMLInterModComms.sendMessage("Waila", "register", "net.bdew.neiaddons.exnihilo.WailaHandler.loadCallback"); 50 | } 51 | 52 | @Override 53 | @SideOnly(Side.CLIENT) 54 | public void loadClient() { 55 | // Currently this addon includes only some WAILA handlers 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/forestry/MutationDumper.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.forestry 11 | 12 | import java.io.File 13 | 14 | import codechicken.nei.config.ArrayDumper 15 | import forestry.api.genetics.{IMutation, ISpeciesRoot} 16 | import net.minecraft.util.{ChatComponentTranslation, IChatComponent} 17 | 18 | class MutationDumper(root: ISpeciesRoot, suffix: String) extends ArrayDumper[IMutation]("tools.dump.neiaddons." + suffix) { 19 | 20 | import scala.collection.JavaConversions._ 21 | 22 | override def header() = Array("UID", "Name", "Allele0", "Allele1", "isSecret", "baseChance", "conditions") 23 | 24 | override def array(): Array[IMutation] = root.getMutations(false).toArray(Array.empty) 25 | 26 | override def dump(mutation: IMutation, id: Int) = { 27 | val speciesKey = root.getKaryotypeKey.ordinal() 28 | val conditions = try { 29 | Option(mutation.getSpecialConditions) map (x => x.mkString("|")) getOrElse "" 30 | } catch { 31 | case t: Throwable => 32 | AddonForestry.instance.logSevereExc(t, "Error in mutation.getSpecialConditions for mutation %s + %s -> %s", 33 | mutation.getAllele0.getUID, mutation.getAllele1.getUID, mutation.getTemplate()(0).getUID) 34 | "[Error]" 35 | } 36 | Array( 37 | mutation.getTemplate()(speciesKey).getUID, 38 | mutation.getTemplate()(speciesKey).getName, 39 | mutation.getAllele0.getUID, 40 | mutation.getAllele1.getUID, 41 | mutation.isSecret.toString, 42 | "%.1f".format(mutation.getBaseChance), 43 | conditions 44 | ) 45 | } 46 | 47 | override def dumpMessage(file: File): IChatComponent = 48 | new ChatComponentTranslation("nei.options.tools.dump.neiaddons.dumped", translateN(name + "s"), "dumps/" + file.getName) 49 | 50 | override def modeCount() = 0 51 | } 52 | 53 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/botany/flowers/FlowerHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.botany.flowers; 11 | 12 | import codechicken.nei.api.API; 13 | import forestry.api.genetics.AlleleManager; 14 | import forestry.api.genetics.IAlleleSpecies; 15 | import forestry.api.genetics.ISpeciesRoot; 16 | import net.bdew.neiaddons.Utils; 17 | import net.bdew.neiaddons.botany.AddonBotany; 18 | import net.bdew.neiaddons.forestry.MutationDumper; 19 | 20 | public class FlowerHelper { 21 | 22 | public static Class flowerSpeciesClass; 23 | 24 | public static ISpeciesRoot root; 25 | 26 | public static void setup() { 27 | root = AlleleManager.alleleRegistry.getSpeciesRoot("rootFlowers"); 28 | 29 | if (root == null) { 30 | AddonBotany.instance.logWarning("Failed to load Flower root, Botany support disabled"); 31 | return; 32 | } 33 | 34 | try { 35 | flowerSpeciesClass = Utils.getAndCheckClass("binnie.botany.api.IAlleleFlowerSpecies", IAlleleSpecies.class); 36 | } catch (Throwable e) { 37 | AddonBotany.instance.logWarningExc(e, "Failed to load Flower species interface, Botany support disabled"); 38 | return; 39 | } 40 | 41 | AddonBotany.instance.logInfo("Root=%s Species=%s", root, flowerSpeciesClass); 42 | 43 | if (AddonBotany.showFlowerMutations) { 44 | FlowerBreedingHandler breedingRecipeHandler = new FlowerBreedingHandler(); 45 | API.registerRecipeHandler(breedingRecipeHandler); 46 | API.registerUsageHandler(breedingRecipeHandler); 47 | AddonBotany.instance.registerWithNEIPlugins(breedingRecipeHandler.getRecipeName(), breedingRecipeHandler.getRecipeIdent()); 48 | } 49 | 50 | API.addOption(new MutationDumper(root, "flower_mutation")); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/network/NBTMessageCodec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.network; 11 | 12 | import cpw.mods.fml.common.network.NetworkRegistry; 13 | import cpw.mods.fml.common.network.internal.FMLProxyPacket; 14 | import io.netty.buffer.ByteBuf; 15 | import io.netty.buffer.ByteBufInputStream; 16 | import io.netty.buffer.ByteBufOutputStream; 17 | import io.netty.buffer.Unpooled; 18 | import io.netty.channel.ChannelHandler; 19 | import io.netty.channel.ChannelHandlerContext; 20 | import io.netty.handler.codec.MessageToMessageCodec; 21 | import net.bdew.neiaddons.NEIAddons; 22 | import net.minecraft.nbt.CompressedStreamTools; 23 | import net.minecraft.nbt.NBTTagCompound; 24 | 25 | import java.io.DataInputStream; 26 | import java.io.DataOutputStream; 27 | import java.util.List; 28 | 29 | @ChannelHandler.Sharable 30 | public class NBTMessageCodec extends MessageToMessageCodec { 31 | @Override 32 | protected void encode(ChannelHandlerContext ctx, NBTTagCompound msg, List out) throws Exception { 33 | ByteBuf buff = Unpooled.buffer(); 34 | DataOutputStream writer = new DataOutputStream(new ByteBufOutputStream(buff)); 35 | CompressedStreamTools.write(msg, writer); 36 | out.add(new FMLProxyPacket(buff, ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get())); 37 | writer.close(); 38 | } 39 | 40 | @Override 41 | protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List out) throws Exception { 42 | DataInputStream stream = new DataInputStream(new ByteBufInputStream(msg.payload())); 43 | try { 44 | out.add(CompressedStreamTools.read(stream)); 45 | } catch (Throwable e) { 46 | NEIAddons.logSevereExc(e, "Error decoding packet"); 47 | } finally { 48 | stream.close(); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/utils/SetRecipeCommandHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.utils; 11 | 12 | import net.bdew.neiaddons.api.SubPacketHandler; 13 | import net.minecraft.entity.player.EntityPlayerMP; 14 | import net.minecraft.inventory.Container; 15 | import net.minecraft.inventory.Slot; 16 | import net.minecraft.item.ItemStack; 17 | import net.minecraft.nbt.NBTTagCompound; 18 | import net.minecraft.nbt.NBTTagList; 19 | 20 | import java.util.HashMap; 21 | 22 | public class SetRecipeCommandHandler implements SubPacketHandler { 23 | private Class ContainerClass; 24 | private Class SlotClass; 25 | 26 | public SetRecipeCommandHandler(Class containerClass, Class slotClass) { 27 | this.ContainerClass = containerClass; 28 | this.SlotClass = slotClass; 29 | } 30 | 31 | @Override 32 | public void handle(NBTTagCompound data, EntityPlayerMP player) { 33 | NBTTagList stacks = data.getTagList("stacks", 10); 34 | Container cont = player.openContainer; 35 | if (ContainerClass.isInstance(cont)) { 36 | HashMap stmap = new HashMap(); 37 | for (int i = 0; i < stacks.tagCount(); i++) { 38 | NBTTagCompound itemdata = stacks.getCompoundTagAt(i); 39 | stmap.put(itemdata.getInteger("slot"), ItemStack.loadItemStackFromNBT(itemdata)); 40 | } 41 | for (Object slotobj : cont.inventorySlots) { 42 | if (SlotClass.isInstance(slotobj)) { 43 | Slot slot = (Slot) slotobj; 44 | if (stmap.containsKey(slot.getSlotIndex())) { 45 | slot.putStack(stmap.get(slot.getSlotIndex())); 46 | } else { 47 | slot.putStack(null); 48 | } 49 | } 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/exnihilo/waila/BeeTrapHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.exnihilo.waila; 11 | 12 | import mcp.mobius.waila.api.IWailaConfigHandler; 13 | import mcp.mobius.waila.api.IWailaDataAccessor; 14 | import mcp.mobius.waila.api.IWailaDataProvider; 15 | import net.minecraft.client.resources.I18n; 16 | import net.minecraft.entity.player.EntityPlayerMP; 17 | import net.minecraft.item.ItemStack; 18 | import net.minecraft.nbt.NBTTagCompound; 19 | import net.minecraft.tileentity.TileEntity; 20 | import net.minecraft.world.World; 21 | 22 | import java.text.DecimalFormat; 23 | import java.util.List; 24 | 25 | public class BeeTrapHandler implements IWailaDataProvider { 26 | private static int TIMER_MAX = 6000; 27 | private DecimalFormat decFormat = new DecimalFormat("0.0"); 28 | 29 | @Override 30 | public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) { 31 | return tag; 32 | } 33 | 34 | @Override 35 | public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { 36 | return null; 37 | } 38 | 39 | @Override 40 | public List getWailaHead(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { 41 | return currenttip; 42 | } 43 | 44 | @Override 45 | public List getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { 46 | 47 | NBTTagCompound tag = accessor.getNBTData(); 48 | 49 | int timer = tag.getInteger("timer"); 50 | 51 | if (timer > 0) { 52 | currenttip.add(I18n.format("bdew.exnihilo.beetrap.spawn", decFormat.format(100F * timer / TIMER_MAX))); 53 | } 54 | 55 | return currenttip; 56 | } 57 | 58 | @Override 59 | public List getWailaTail(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { 60 | return currenttip; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/network/ClientHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.network; 11 | 12 | import cpw.mods.fml.common.FMLCommonHandler; 13 | import cpw.mods.fml.common.eventhandler.SubscribeEvent; 14 | import cpw.mods.fml.common.network.FMLNetworkEvent; 15 | import io.netty.channel.ChannelHandlerContext; 16 | import io.netty.channel.SimpleChannelInboundHandler; 17 | import net.bdew.neiaddons.NEIAddons; 18 | import net.minecraft.nbt.NBTTagCompound; 19 | import org.apache.commons.lang3.StringUtils; 20 | 21 | import java.util.Arrays; 22 | import java.util.HashSet; 23 | import java.util.Set; 24 | 25 | public class ClientHandler extends SimpleChannelInboundHandler { 26 | public static Set enabledCommands = new HashSet(); 27 | 28 | public ClientHandler() { 29 | FMLCommonHandler.instance().bus().register(this); 30 | } 31 | 32 | @SubscribeEvent 33 | public void handleConnectEvent(FMLNetworkEvent.ClientConnectedToServerEvent ev) { 34 | NEIAddons.logInfo("Connected to new server, resetting commands"); 35 | enabledCommands.clear(); 36 | } 37 | 38 | @Override 39 | protected void channelRead0(ChannelHandlerContext ctx, NBTTagCompound msg) throws Exception { 40 | String cmd = msg.getString("cmd"); 41 | NBTTagCompound data = msg.getCompoundTag("data"); 42 | try { 43 | if (cmd.equals("hello")) { 44 | NEIAddons.logInfo("Received handshake from server"); 45 | enabledCommands.clear(); 46 | if (data.getInteger("version") != NEIAddons.netVersion) { 47 | NEIAddons.logWarning("Client/Server version mismatch! client=%d server=%d", data.getInteger("version"), NEIAddons.netVersion); 48 | return; 49 | } 50 | String cmds = data.getString("commands"); 51 | NEIAddons.logInfo("Available server commands: %s", cmds); 52 | enabledCommands.addAll(Arrays.asList(StringUtils.split(cmds, ';'))); 53 | } else { 54 | NEIAddons.logWarning("Uknown packet from server: %s", cmd); 55 | } 56 | } catch (Throwable e) { 57 | NEIAddons.logSevereExc(e, "Error handling packet from server"); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/botany/AddonBotany.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.botany; 11 | 12 | import cpw.mods.fml.common.Mod; 13 | import cpw.mods.fml.common.Mod.EventHandler; 14 | import cpw.mods.fml.common.Mod.Instance; 15 | import cpw.mods.fml.common.event.FMLInterModComms; 16 | import cpw.mods.fml.common.event.FMLPreInitializationEvent; 17 | import cpw.mods.fml.relauncher.Side; 18 | import cpw.mods.fml.relauncher.SideOnly; 19 | import net.bdew.neiaddons.BaseAddon; 20 | import net.bdew.neiaddons.NEIAddons; 21 | import net.bdew.neiaddons.botany.flowers.FlowerHelper; 22 | import net.minecraft.client.resources.I18n; 23 | 24 | @Mod(modid = NEIAddons.modId + "|Botany", name = "NEI Addons: Botany", version = "NEIADDONS_VER", dependencies = "after:NEIAddons;after:Botany") 25 | public class AddonBotany extends BaseAddon { 26 | public static boolean showFlowerMutations; 27 | public static boolean loadBlacklisted; 28 | 29 | @Instance(NEIAddons.modId + "|Botany") 30 | public static AddonBotany instance; 31 | 32 | @Override 33 | public boolean checkSide(Side side) { 34 | return side.isClient(); 35 | } 36 | 37 | @Override 38 | public String getName() { 39 | return "Botany"; 40 | } 41 | 42 | @Override 43 | public String[] getDependencies() { 44 | return new String[]{"Botany"}; 45 | } 46 | 47 | @Override 48 | @EventHandler 49 | public void preInit(FMLPreInitializationEvent ev) { 50 | doPreInit(ev); 51 | } 52 | 53 | @Override 54 | public void init(Side side) throws Exception { 55 | showFlowerMutations = NEIAddons.config.get(getName(), "Show Flower Mutations", true, "Set to false to disable flower mutations browsing").getBoolean(false); 56 | 57 | loadBlacklisted = NEIAddons.config.get(getName(), "Load blacklisted", false, "Set to true to load blacklisted species and alleles, it's dangerous and (mostly) useless").getBoolean(false); 58 | 59 | active = true; 60 | } 61 | 62 | public void registerWithNEIPlugins(String name, String id) { 63 | FMLInterModComms.sendRuntimeMessage(this, "NEIPlugins", "register-crafting-handler", String.format("%s@%s@%s", I18n.format("bdew.neiaddons.genetics"), name, id)); 64 | } 65 | 66 | @Override 67 | @SideOnly(Side.CLIENT) 68 | public void loadClient() { 69 | FlowerHelper.setup(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/exnihilo/waila/BarrelHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.exnihilo.waila; 11 | 12 | import mcp.mobius.waila.api.IWailaConfigHandler; 13 | import mcp.mobius.waila.api.IWailaDataAccessor; 14 | import mcp.mobius.waila.api.IWailaDataProvider; 15 | import net.minecraft.client.resources.I18n; 16 | import net.minecraft.entity.player.EntityPlayerMP; 17 | import net.minecraft.item.ItemStack; 18 | import net.minecraft.nbt.NBTTagCompound; 19 | import net.minecraft.tileentity.TileEntity; 20 | import net.minecraft.util.EnumChatFormatting; 21 | import net.minecraft.world.World; 22 | import net.minecraftforge.fluids.Fluid; 23 | import net.minecraftforge.fluids.FluidRegistry; 24 | 25 | import java.text.DecimalFormat; 26 | import java.util.List; 27 | 28 | public class BarrelHandler implements IWailaDataProvider { 29 | private DecimalFormat decFormat = new DecimalFormat("0.0"); 30 | 31 | @Override 32 | public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) { 33 | return tag; 34 | } 35 | 36 | @Override 37 | public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { 38 | return null; 39 | } 40 | 41 | @Override 42 | public List getWailaHead(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { 43 | return currenttip; 44 | } 45 | 46 | @Override 47 | public List getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { 48 | NBTTagCompound tag = accessor.getNBTData(); 49 | 50 | float volume = tag.getFloat("volume"); 51 | int timer = tag.getInteger("timer"); 52 | Fluid fluid = FluidRegistry.getFluid(tag.getShort("fluid")); 53 | 54 | if (fluid != null && fluid.getID() == FluidRegistry.LAVA.getID() && volume > 0 && (accessor.getBlock().getMaterial().getCanBurn())) { 55 | currenttip.add(EnumChatFormatting.RED + I18n.format("bdew.exnihilo.barrel.burn", decFormat.format((400F - timer) / 20)) + EnumChatFormatting.RESET); 56 | } 57 | 58 | return currenttip; 59 | } 60 | 61 | @Override 62 | public List getWailaTail(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { 63 | return currenttip; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/developer/DeveloperGuiHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.developer; 11 | 12 | import codechicken.nei.guihook.IContainerTooltipHandler; 13 | import net.minecraft.client.gui.inventory.GuiContainer; 14 | import net.minecraft.inventory.Slot; 15 | import net.minecraft.item.ItemStack; 16 | import net.minecraft.util.EnumChatFormatting; 17 | 18 | import java.util.List; 19 | 20 | public class DeveloperGuiHandler implements IContainerTooltipHandler { 21 | @Override 22 | public List handleTooltip(GuiContainer gui, int x, int y, List tip) { 23 | int slotNum = -1; 24 | Slot slot = null; 25 | for (int k = 0; k < gui.inventorySlots.inventorySlots.size(); k++) { 26 | slot = (Slot) gui.inventorySlots.inventorySlots.get(k); 27 | if (isMouseOverSlot(gui, slot, x, y)) { 28 | slotNum = k; 29 | break; 30 | } 31 | } 32 | if (slotNum > 0) { 33 | tip.add(String.format("%sSlot #%d", EnumChatFormatting.UNDERLINE, slotNum)); 34 | tip.add("G: " + gui.getClass().getSimpleName()); 35 | tip.add("C: " + gui.inventorySlots.getClass().getSimpleName()); 36 | tip.add("S: " + slot.getClass().getSimpleName()); 37 | if (slot.inventory != null) 38 | tip.add(String.format("I: %s (#%d)", slot.inventory.getClass().getSimpleName(), slot.getSlotIndex())); 39 | else 40 | tip.add(String.format("%sI: NULL", EnumChatFormatting.RED)); 41 | tip.add(String.format("%d/%d", slot.xDisplayPosition, slot.yDisplayPosition)); 42 | } 43 | return tip; 44 | } 45 | 46 | @Override 47 | public List handleItemDisplayName(GuiContainer guiContainer, ItemStack itemStack, List list) { 48 | return list; 49 | } 50 | 51 | @Override 52 | public List handleItemTooltip(GuiContainer guiContainer, ItemStack itemStack, int i, int i1, List list) { 53 | return list; 54 | } 55 | 56 | private boolean isMouseOverSlot(GuiContainer gui, Slot slot, int mouseX, int mouseY) { 57 | int slotX = slot.xDisplayPosition; 58 | int slotY = slot.yDisplayPosition; 59 | int slotW = 16; 60 | int slotH = 16; 61 | mouseX -= gui.guiLeft; 62 | mouseY -= gui.guiTop; 63 | return mouseX >= slotX - 1 && mouseX < slotX + slotW + 1 && mouseY >= slotY - 1 && mouseY < slotY + slotH + 1; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/forestry/butterflies/ButterflyHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.forestry.butterflies; 11 | 12 | import codechicken.nei.api.API; 13 | import forestry.api.genetics.AlleleManager; 14 | import forestry.api.lepidopterology.EnumFlutterType; 15 | import forestry.api.lepidopterology.IAlleleButterflySpecies; 16 | import forestry.api.lepidopterology.IButterflyRoot; 17 | import net.bdew.neiaddons.Utils; 18 | import net.bdew.neiaddons.forestry.AddonForestry; 19 | import net.bdew.neiaddons.forestry.GeneticsUtils; 20 | 21 | import java.util.Collection; 22 | 23 | public class ButterflyHelper { 24 | 25 | public static Collection allSpecies; 26 | // public static Map> productsCache; 27 | 28 | public static IButterflyRoot root; 29 | 30 | // private static void addProductToCache(int id, IAlleleBeeSpecies species) { 31 | // if (!productsCache.containsKey(id)) { 32 | // productsCache.put(id, new ArrayList()); 33 | // } 34 | // productsCache.get(id).add(species); 35 | // } 36 | 37 | public static void setup() { 38 | root = (IButterflyRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies"); 39 | 40 | if (root == null) { 41 | AddonForestry.instance.logWarning("Butterfly Species Root not found, some functionality will be unavailable"); 42 | return; 43 | } 44 | 45 | allSpecies = GeneticsUtils.getAllButterflySpecies(AddonForestry.loadBlacklisted); 46 | 47 | if (AddonForestry.showButterflyMutations) { 48 | ButterflyBreedingHandler breedingRecipeHandler = new ButterflyBreedingHandler(); 49 | API.registerRecipeHandler(breedingRecipeHandler); 50 | API.registerUsageHandler(breedingRecipeHandler); 51 | AddonForestry.instance.registerWithNEIPlugins(breedingRecipeHandler.getRecipeName(), breedingRecipeHandler.getRecipeIdent()); 52 | } 53 | 54 | // productsCache = new HashMap>(); 55 | 56 | for (IAlleleButterflySpecies species : allSpecies) { 57 | if (AddonForestry.addBees) { 58 | Utils.safeAddNBTItem(GeneticsUtils.stackFromSpecies(species, EnumFlutterType.BUTTERFLY.ordinal())); 59 | Utils.safeAddNBTItem(GeneticsUtils.stackFromSpecies(species, EnumFlutterType.CATERPILLAR.ordinal())); 60 | Utils.safeAddNBTItem(GeneticsUtils.stackFromSpecies(species, EnumFlutterType.SERUM.ordinal())); 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/appeng/AddonAppeng.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.appeng; 11 | 12 | import cpw.mods.fml.common.Mod; 13 | import cpw.mods.fml.common.Mod.EventHandler; 14 | import cpw.mods.fml.common.Mod.Instance; 15 | import cpw.mods.fml.common.event.FMLPreInitializationEvent; 16 | import cpw.mods.fml.relauncher.Side; 17 | import cpw.mods.fml.relauncher.SideOnly; 18 | import net.bdew.neiaddons.BaseAddon; 19 | import net.bdew.neiaddons.NEIAddons; 20 | import net.bdew.neiaddons.Utils; 21 | import net.bdew.neiaddons.network.ServerHandler; 22 | import net.minecraft.client.gui.inventory.GuiContainer; 23 | import net.minecraft.inventory.Container; 24 | import net.minecraft.inventory.Slot; 25 | 26 | import java.lang.reflect.Method; 27 | 28 | @Mod(modid = NEIAddons.modId + "|AppEng", name = "NEI Addons: Applied Energistics 2", version = "NEIADDONS_VER", dependencies = "after:NEIAddons;after:appliedenergistics2") 29 | public class AddonAppeng extends BaseAddon { 30 | 31 | @Instance(NEIAddons.modId + "|AppEng") 32 | public static AddonAppeng instance; 33 | 34 | public static final String setWorkbenchCommand = "SetAE2FakeSlot"; 35 | 36 | public static Class clsBaseGui; 37 | public static Class clsBaseContainer; 38 | public static Class clsSlotFake; 39 | public static Method mSlotFakeIsEnabled; 40 | 41 | @Override 42 | public String getName() { 43 | return "Applied Energistics 2"; 44 | } 45 | 46 | @Override 47 | public String[] getDependencies() { 48 | return new String[]{"appliedenergistics2"}; 49 | } 50 | 51 | @Override 52 | @EventHandler 53 | public void preInit(FMLPreInitializationEvent ev) { 54 | doPreInit(ev); 55 | } 56 | 57 | @Override 58 | public void init(Side side) throws Exception { 59 | try { 60 | clsBaseContainer = Utils.getAndCheckClass("appeng.container.AEBaseContainer", Container.class); 61 | clsSlotFake = Utils.getAndCheckClass("appeng.container.slot.SlotFake", Slot.class); 62 | mSlotFakeIsEnabled = clsSlotFake.getMethod("isEnabled"); 63 | if (side == Side.CLIENT) { 64 | clsBaseGui = Utils.getAndCheckClass("appeng.client.gui.AEBaseGui", GuiContainer.class); 65 | } 66 | 67 | ServerHandler.registerHandler(setWorkbenchCommand, new SetFakeSlotCommandHandler()); 68 | 69 | active = true; 70 | } catch (Throwable t) { 71 | logSevereExc(t, "Error finding cell workbench classes"); 72 | } 73 | } 74 | 75 | @Override 76 | @SideOnly(Side.CLIENT) 77 | public void loadClient() { 78 | AppEngHelper.init(); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /resources/mcmod.info: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "modid": "NEIAddons", 4 | "name": "NEI Addons", 5 | "description": "", 6 | "version": "@NEIADDONS_VER@", 7 | "url": "bdew.net/neiaddons", 8 | "updateUrl": "", 9 | "authorList": [ 10 | "bdew" 11 | ], 12 | "credits": "", 13 | "logoFile": "", 14 | "screenshots": [ 15 | ], 16 | "parent":"", 17 | "dependencies": [ 18 | ] 19 | }, 20 | { 21 | "modid": "NEIAddons|Forestry", 22 | "name": "NEI Addons: Forestry", 23 | "description": "", 24 | "version": "@NEIADDONS_VER@", 25 | "url": "http://bdew.net/neiaddons/", 26 | "updateUrl": "", 27 | "authorList": [ 28 | "bdew" 29 | ], 30 | "credits": "", 31 | "logoFile": "", 32 | "screenshots": [ 33 | ], 34 | "parent":"NEIAddons", 35 | "dependencies": [ 36 | "NEIAddons" 37 | ] 38 | }, 39 | { 40 | "modid": "NEIAddons|CraftingTables", 41 | "name": "NEI Addons: Crafting Tables", 42 | "description": "", 43 | "version": "@NEIADDONS_VER@", 44 | "url": "http://bdew.net/neiaddons/", 45 | "updateUrl": "", 46 | "authorList": [ 47 | "bdew" 48 | ], 49 | "credits": "", 50 | "logoFile": "", 51 | "screenshots": [ 52 | ], 53 | "parent":"NEIAddons", 54 | "dependencies": [ 55 | "NEIAddons" 56 | ] 57 | }, 58 | { 59 | "modid": "NEIAddons|AE", 60 | "name": "NEI Addons: Applied Energistics", 61 | "description": "", 62 | "version": "@NEIADDONS_VER@", 63 | "url": "http://bdew.net/neiaddons/", 64 | "updateUrl": "", 65 | "authorList": [ 66 | "bdew" 67 | ], 68 | "credits": "", 69 | "logoFile": "", 70 | "screenshots": [ 71 | ], 72 | "parent":"NEIAddons", 73 | "dependencies": [ 74 | "NEIAddons" 75 | ] 76 | }, 77 | { 78 | "modid": "NEIAddons|ExtraBees", 79 | "name": "NEI Addons: Extra Bees", 80 | "description": "", 81 | "version": "@NEIADDONS_VER@", 82 | "url": "http://bdew.net/neiaddons/", 83 | "updateUrl": "", 84 | "authorList": [ 85 | "bdew" 86 | ], 87 | "credits": "", 88 | "logoFile": "", 89 | "screenshots": [ 90 | ], 91 | "parent":"NEIAddons", 92 | "dependencies": [ 93 | "NEIAddons" 94 | ] 95 | }, 96 | { 97 | "modid": "NEIAddons|MiscPeripherals", 98 | "name": "NEI Addons: Misc Peripherals", 99 | "description": "", 100 | "version": "@NEIADDONS_VER@", 101 | "url": "http://bdew.net/neiaddons/", 102 | "updateUrl": "", 103 | "authorList": [ 104 | "bdew" 105 | ], 106 | "credits": "", 107 | "logoFile": "", 108 | "screenshots": [ 109 | ], 110 | "parent":"NEIAddons", 111 | "dependencies": [ 112 | "NEIAddons" 113 | ] 114 | }, 115 | { 116 | "modid": "NEIAddons|ExNihilo", 117 | "name": "NEI Addons: Ex Nihilo", 118 | "description": "", 119 | "version": "@NEIADDONS_VER@", 120 | "url": "http://bdew.net/neiaddons/", 121 | "updateUrl": "", 122 | "authorList": [ 123 | "bdew" 124 | ], 125 | "credits": "", 126 | "logoFile": "", 127 | "screenshots": [ 128 | ], 129 | "parent":"NEIAddons", 130 | "dependencies": [ 131 | "NEIAddons" 132 | ] 133 | } 134 | ] -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/network/NetChannel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.network; 11 | 12 | import cpw.mods.fml.common.network.FMLEmbeddedChannel; 13 | import cpw.mods.fml.common.network.FMLOutboundHandler; 14 | import cpw.mods.fml.common.network.NetworkRegistry; 15 | import cpw.mods.fml.relauncher.Side; 16 | import io.netty.channel.ChannelHandler; 17 | import net.minecraft.entity.player.EntityPlayerMP; 18 | import net.minecraft.nbt.NBTTagCompound; 19 | 20 | import java.util.EnumMap; 21 | 22 | public class NetChannel { 23 | public EnumMap channels; 24 | 25 | public NetChannel(String name) { 26 | channels = NetworkRegistry.INSTANCE.newChannel(name, new NBTMessageCodec()); 27 | } 28 | 29 | public void addHandler(Side side, ChannelHandler handler) { 30 | FMLEmbeddedChannel ch = channels.get(side); 31 | String name = ch.findChannelHandlerNameForType(NBTMessageCodec.class); 32 | ch.pipeline().addAfter(name, side + "Handler", handler); 33 | } 34 | 35 | public void sendToAll(NBTTagCompound message) { 36 | FMLEmbeddedChannel chan = this.channels.get(Side.SERVER); 37 | chan.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL); 38 | chan.writeAndFlush(message); 39 | } 40 | 41 | public void sendTo(NBTTagCompound message, EntityPlayerMP player) { 42 | FMLEmbeddedChannel chan = this.channels.get(Side.SERVER); 43 | chan.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER); 44 | chan.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player); 45 | chan.writeAndFlush(message); 46 | } 47 | 48 | public void sendToAllAround(NBTTagCompound message, NetworkRegistry.TargetPoint point) { 49 | FMLEmbeddedChannel chan = this.channels.get(Side.SERVER); 50 | chan.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT); 51 | chan.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point); 52 | chan.writeAndFlush(message); 53 | } 54 | 55 | public void sendToDimension(NBTTagCompound message, int dimensionId) { 56 | FMLEmbeddedChannel chan = this.channels.get(Side.SERVER); 57 | chan.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DIMENSION); 58 | chan.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(dimensionId); 59 | chan.writeAndFlush(message); 60 | } 61 | 62 | public void sendToServer(NBTTagCompound message) { 63 | FMLEmbeddedChannel chan = this.channels.get(Side.CLIENT); 64 | chan.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER); 65 | chan.writeAndFlush(message); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/exnihilo/waila/CrucibleHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.exnihilo.waila; 11 | 12 | import mcp.mobius.waila.api.IWailaConfigHandler; 13 | import mcp.mobius.waila.api.IWailaDataAccessor; 14 | import mcp.mobius.waila.api.IWailaDataProvider; 15 | import net.minecraft.block.Block; 16 | import net.minecraft.client.resources.I18n; 17 | import net.minecraft.entity.player.EntityPlayerMP; 18 | import net.minecraft.item.ItemStack; 19 | import net.minecraft.nbt.NBTTagCompound; 20 | import net.minecraft.tileentity.TileEntity; 21 | import net.minecraft.world.World; 22 | import net.minecraftforge.fluids.Fluid; 23 | import net.minecraftforge.fluids.FluidRegistry; 24 | import net.minecraftforge.fluids.FluidStack; 25 | 26 | import java.text.DecimalFormat; 27 | import java.util.List; 28 | 29 | public class CrucibleHandler implements IWailaDataProvider { 30 | private final DecimalFormat dec = new DecimalFormat("#,##0"); 31 | 32 | @Override 33 | public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) { 34 | return tag; 35 | } 36 | 37 | @Override 38 | public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { 39 | return null; 40 | } 41 | 42 | @Override 43 | public List getWailaHead(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { 44 | return currenttip; 45 | } 46 | 47 | @Override 48 | public List getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { 49 | NBTTagCompound tag = accessor.getNBTData(); 50 | float solidVolume = tag.getFloat("solidVolume"); 51 | float fluidVolume = tag.getFloat("fluidVolume"); 52 | String content = tag.getString("content"); 53 | int contentMeta = tag.getInteger("contentMeta"); 54 | Fluid fluid = FluidRegistry.getFluid(tag.getShort("fluid")); 55 | 56 | if (fluid != null && fluidVolume > 0) 57 | currenttip.add(I18n.format("bdew.exnihilo.crucible.fluid", fluid.getLocalizedName(new FluidStack(fluid, 1)), dec.format(fluidVolume))); 58 | 59 | if (!content.isEmpty() && solidVolume > 0) { 60 | ItemStack stack = new ItemStack((Block) Block.blockRegistry.getObject(content), 1, contentMeta); 61 | currenttip.add(I18n.format("bdew.exnihilo.crucible.solid", stack.getDisplayName(), dec.format(solidVolume))); 62 | } 63 | 64 | return currenttip; 65 | } 66 | 67 | @Override 68 | public List getWailaTail(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { 69 | return currenttip; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/appeng/AppEngGuiHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.appeng; 11 | 12 | import codechicken.nei.api.INEIGuiAdapter; 13 | import net.bdew.neiaddons.network.ClientHandler; 14 | import net.bdew.neiaddons.network.PacketHelper; 15 | import net.minecraft.client.Minecraft; 16 | import net.minecraft.client.gui.inventory.GuiContainer; 17 | import net.minecraft.inventory.Slot; 18 | import net.minecraft.item.ItemStack; 19 | import net.minecraft.nbt.NBTTagCompound; 20 | import net.minecraft.util.ChatComponentTranslation; 21 | import net.minecraft.util.ChatStyle; 22 | import net.minecraft.util.EnumChatFormatting; 23 | 24 | public class AppEngGuiHandler extends INEIGuiAdapter { 25 | @Override 26 | public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button) { 27 | if (AddonAppeng.clsBaseGui.isInstance(gui)) { 28 | int slotNum = -1; 29 | Slot slot = null; 30 | for (int k = 0; k < gui.inventorySlots.inventorySlots.size(); k++) { 31 | slot = (Slot) gui.inventorySlots.inventorySlots.get(k); 32 | if (isMouseOverSlot(gui, slot, mousex, mousey)) { 33 | slotNum = k; 34 | break; 35 | } 36 | } 37 | if ((slotNum > 0) && (AddonAppeng.clsSlotFake.isInstance(slot)) && SlotHelper.isSlotEnabled(slot)) { 38 | if (ClientHandler.enabledCommands.contains(AddonAppeng.setWorkbenchCommand)) { 39 | NBTTagCompound data = new NBTTagCompound(); 40 | data.setInteger("slot", slotNum); 41 | NBTTagCompound item = new NBTTagCompound(); 42 | draggedStack.writeToNBT(item); 43 | data.setTag("item", item); 44 | PacketHelper.sendToServer(AddonAppeng.setWorkbenchCommand, data); 45 | return true; 46 | } else { 47 | Minecraft.getMinecraft().thePlayer.addChatMessage( 48 | new ChatComponentTranslation("bdew.neiaddons.noserver").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)) 49 | ); 50 | } 51 | } 52 | } 53 | 54 | return super.handleDragNDrop(gui, mousex, mousey, draggedStack, button); 55 | } 56 | 57 | private boolean isMouseOverSlot(GuiContainer gui, Slot slot, int mouseX, int mouseY) { 58 | int slotX = slot.xDisplayPosition; 59 | int slotY = slot.yDisplayPosition; 60 | int slotW = 16; 61 | int slotH = 16; 62 | mouseX -= gui.guiLeft; 63 | mouseY -= gui.guiTop; 64 | return mouseX >= slotX - 1 && mouseX < slotX + slotW + 1 && mouseY >= slotY - 1 && mouseY < slotY + slotH + 1; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/crafting/AddonCraftingTables.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.crafting; 11 | 12 | import cpw.mods.fml.common.Mod; 13 | import cpw.mods.fml.common.Mod.EventHandler; 14 | import cpw.mods.fml.common.event.FMLPreInitializationEvent; 15 | import cpw.mods.fml.relauncher.Side; 16 | import cpw.mods.fml.relauncher.SideOnly; 17 | import net.bdew.neiaddons.BaseAddon; 18 | import net.bdew.neiaddons.NEIAddons; 19 | import net.bdew.neiaddons.Utils; 20 | import net.minecraft.client.gui.inventory.GuiContainer; 21 | 22 | import java.util.ArrayList; 23 | import java.util.Collection; 24 | 25 | @Mod(modid = NEIAddons.modId + "|CraftingTables", name = "NEI Addons: Crafting Tables", version = "NEIADDONS_VER", dependencies = "after:NEIAddons") 26 | public class AddonCraftingTables extends BaseAddon { 27 | 28 | public static Collection> craftingTables; 29 | 30 | @Override 31 | public String getName() { 32 | return "Crafting Tables"; 33 | } 34 | 35 | @Override 36 | public boolean checkSide(Side side) { 37 | return side.isClient(); 38 | } 39 | 40 | @EventHandler 41 | public void preInit(FMLPreInitializationEvent ev) { 42 | doPreInit(ev); 43 | } 44 | 45 | public void tryLoadTableClass(String modId, String className, String humanName) { 46 | try { 47 | if (verifyModVersion(modId)) { 48 | craftingTables.add(Utils.getAndCheckClass(className, GuiContainer.class)); 49 | logInfo("Registered %s", humanName); 50 | } else { 51 | logInfo("Not registering %s", humanName); 52 | } 53 | } catch (Throwable e) { 54 | logWarningExc(e, "Registering %s failed", humanName); 55 | } 56 | } 57 | 58 | @Override 59 | public void init(Side side) throws Exception { 60 | craftingTables = new ArrayList>(); 61 | 62 | tryLoadTableClass("EE3", "com.pahimar.ee3.client.gui.inventory.GuiPortableCrafting", "EE3 Minium Stone"); 63 | tryLoadTableClass("BuildCraft|Factory", "buildcraft.factory.gui.GuiAutoCrafting", "BC Autorcrafting Table"); 64 | tryLoadTableClass("powersuitaddons", "com.qmxtech.powersuitaddons.client.PortableCraftingGui", "MPSA In-Place Assembler"); 65 | tryLoadTableClass("ProjectE", "moze_intel.projecte.gameObjs.gui.GUIPhilosStone", "ProjectE Philosopher Stone"); 66 | tryLoadTableClass("BiblioCraft", "jds.bibliocraft.gui.GuiFancyWorkbench", "BiblioCraft Fancy Workbench"); 67 | tryLoadTableClass("RIO", "remoteio.client.gui.GuiIntelligentWorkbench", "RemoteIO Intelligent Workbench"); 68 | tryLoadTableClass("Railcraft", "mods.railcraft.client.gui.GuiCartWork", "Railcraft Work Cart"); 69 | 70 | 71 | if (craftingTables.size() > 0) { 72 | logInfo("%d crafting tables registered", craftingTables.size()); 73 | active = true; 74 | } 75 | } 76 | 77 | @Override 78 | @SideOnly(Side.CLIENT) 79 | public void loadClient() { 80 | AddonCraftingTablesClient.load(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /MMPL-1.0.txt: -------------------------------------------------------------------------------- 1 | Minecraft Mod Public License 2 | ============================ 3 | 4 | Version 1.0.1 5 | 6 | 0. Definitions 7 | -------------- 8 | 9 | Minecraft: Denotes a copy of the Minecraft game licensed by Mojang AB 10 | 11 | User: Anybody that interacts with the software in one of the following ways: 12 | - play 13 | - decompile 14 | - recompile or compile 15 | - modify 16 | - distribute 17 | 18 | Mod: The mod code designated by the present license, in source form, binary 19 | form, as obtained standalone, as part of a wider distribution or resulting from 20 | the compilation of the original or modified sources. 21 | 22 | Dependency: Code required for the mod to work properly. This includes 23 | dependencies required to compile the code as well as any file or modification 24 | that is explicitely or implicitely required for the mod to be working. 25 | 26 | 1. Scope 27 | -------- 28 | 29 | The present license is granted to any user of the mod. As a prerequisite, 30 | a user must own a legally acquired copy of Minecraft 31 | 32 | 2. Liability 33 | ------------ 34 | 35 | This mod is provided 'as is' with no warranties, implied or otherwise. The owner 36 | of this mod takes no responsibility for any damages incurred from the use of 37 | this mod. This mod alters fundamental parts of the Minecraft game, parts of 38 | Minecraft may not work with this mod installed. All damages caused from the use 39 | or misuse of this mad fall on the user. 40 | 41 | 3. Play rights 42 | -------------- 43 | 44 | The user is allowed to install this mod on a client or a server and to play 45 | without restriction. 46 | 47 | 4. Modification rights 48 | ---------------------- 49 | 50 | The user has the right to decompile the source code, look at either the 51 | decompiled version or the original source code, and to modify it. 52 | 53 | 5. Derivation rights 54 | -------------------- 55 | 56 | The user has the rights to derive code from this mod, that is to say to 57 | write code that extends or instanciate the mod classes or interfaces, refer to 58 | its objects, or calls its functions. This code is known as "derived" code, and 59 | can be licensed under a license different from this mod. 60 | 61 | 6. Distribution of original or modified copy rights 62 | --------------------------------------------------- 63 | 64 | Is subject to distribution rights this entire mod in its various forms. This 65 | include: 66 | - original binary or source forms of this mod files 67 | - modified versions of these binaries or source files, as well as binaries 68 | resulting from source modifications 69 | - patch to its source or binary files 70 | - any copy of a portion of its binary source files 71 | 72 | The user is allowed to redistribute this mod partially, in totality, or 73 | included in a distribution. 74 | 75 | When distributing binary files, the user must provide means to obtain its 76 | entire set of sources or modified sources at no costs. 77 | 78 | All distributions of this mod must remain licensed under the MMPL. 79 | 80 | All dependencies that this mod have on other mods or classes must be licensed 81 | under conditions comparable to this version of MMPL, with the exception of the 82 | Minecraft code and the mod loading framework (e.g. ModLoader, ModLoaderMP or 83 | Bukkit). 84 | 85 | Modified version of binaries and sources, as well as files containing sections 86 | copied from this mod, should be distributed under the terms of the present 87 | license. 88 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/network/ServerHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.network; 11 | 12 | import cpw.mods.fml.common.FMLCommonHandler; 13 | import cpw.mods.fml.common.eventhandler.SubscribeEvent; 14 | import cpw.mods.fml.common.gameevent.PlayerEvent; 15 | import cpw.mods.fml.common.network.NetworkRegistry; 16 | import io.netty.channel.ChannelHandlerContext; 17 | import io.netty.channel.SimpleChannelInboundHandler; 18 | import net.bdew.neiaddons.NEIAddons; 19 | import net.bdew.neiaddons.api.SubPacketHandler; 20 | import net.minecraft.entity.player.EntityPlayer; 21 | import net.minecraft.entity.player.EntityPlayerMP; 22 | import net.minecraft.nbt.NBTTagCompound; 23 | import net.minecraft.network.NetHandlerPlayServer; 24 | import org.apache.commons.lang3.StringUtils; 25 | 26 | import java.util.HashMap; 27 | import java.util.Map; 28 | 29 | public class ServerHandler extends SimpleChannelInboundHandler { 30 | private static Map handlers = new HashMap(); 31 | 32 | public ServerHandler() { 33 | FMLCommonHandler.instance().bus().register(this); 34 | } 35 | 36 | public static void registerHandler(String command, SubPacketHandler handler) { 37 | if (handlers.containsKey(command)) { 38 | throw new RuntimeException(String.format("Tried to register handler for command %s that's already registered for %s", command, handler.toString())); 39 | } 40 | handlers.put(command, handler); 41 | } 42 | 43 | @Override 44 | protected void channelRead0(ChannelHandlerContext ctx, NBTTagCompound msg) throws Exception { 45 | String cmd = msg.getString("cmd"); 46 | NBTTagCompound data = msg.getCompoundTag("data"); 47 | NetHandlerPlayServer nh = (NetHandlerPlayServer) (ctx.channel().attr(NetworkRegistry.NET_HANDLER).get()); 48 | processCommand(cmd, data, nh.playerEntity); 49 | } 50 | 51 | public void processCommand(String cmd, NBTTagCompound data, EntityPlayerMP from) { 52 | if (handlers.containsKey(cmd)) { 53 | NEIAddons.logInfo("Handling %s from %s -> %s", cmd, from.getDisplayName(), handlers.get(cmd).toString()); 54 | try { 55 | handlers.get(cmd).handle(data, from); 56 | } catch (Throwable e) { 57 | NEIAddons.logSevereExc(e, "Error processing command '%s' from '%s'", cmd, from.getDisplayName()); 58 | } 59 | } else { 60 | NEIAddons.logWarning("Uknown packet from client '%s': %s", from.getDisplayName(), cmd); 61 | } 62 | } 63 | 64 | private void sendPlayerHello(EntityPlayer player) { 65 | NBTTagCompound nbt = new NBTTagCompound(); 66 | nbt.setString("commands", StringUtils.join(handlers.keySet(), ';')); 67 | nbt.setInteger("version", NEIAddons.netVersion); 68 | PacketHelper.sendToClient("hello", nbt, (EntityPlayerMP) player); 69 | } 70 | 71 | @SubscribeEvent 72 | public void handlePlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent ev) { 73 | sendPlayerHello(ev.player); 74 | } 75 | 76 | @SubscribeEvent 77 | public void handlePlayerChangedDimension(PlayerEvent.PlayerChangedDimensionEvent ev) { 78 | sendPlayerHello(ev.player); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/forestry/trees/TreeHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.forestry.trees; 11 | 12 | import codechicken.nei.api.API; 13 | import forestry.api.arboriculture.EnumGermlingType; 14 | import forestry.api.arboriculture.IAlleleTreeSpecies; 15 | import forestry.api.arboriculture.ITreeRoot; 16 | import forestry.api.genetics.AlleleManager; 17 | import forestry.api.genetics.IAlleleSpecies; 18 | import net.bdew.neiaddons.Utils; 19 | import net.bdew.neiaddons.forestry.AddonForestry; 20 | import net.bdew.neiaddons.forestry.GeneticsUtils; 21 | import net.bdew.neiaddons.forestry.MutationDumper; 22 | import net.minecraft.item.Item; 23 | import net.minecraft.item.ItemStack; 24 | 25 | import java.util.ArrayList; 26 | import java.util.Collection; 27 | import java.util.HashMap; 28 | import java.util.Map; 29 | 30 | public class TreeHelper { 31 | public static Collection allSpecies; 32 | public static Map> productsCache = new HashMap>(); 33 | 34 | public static ITreeRoot root; 35 | 36 | private static void addProductToCache(Item item, IAlleleTreeSpecies species) { 37 | if (!productsCache.containsKey(item)) { 38 | productsCache.put(item, new ArrayList()); 39 | } 40 | productsCache.get(item).add(species); 41 | } 42 | 43 | public static void setup() { 44 | root = (ITreeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees"); 45 | 46 | if (root == null) { 47 | AddonForestry.instance.logWarning("Tree Species Root not found, some functionality will be unavailable"); 48 | return; 49 | } 50 | 51 | allSpecies = GeneticsUtils.getAllTreeSpecies(AddonForestry.loadBlacklisted); 52 | 53 | if (AddonForestry.showTreeMutations) { 54 | TreeBreedingHandler breedingRecipeHandler = new TreeBreedingHandler(); 55 | API.registerRecipeHandler(breedingRecipeHandler); 56 | API.registerUsageHandler(breedingRecipeHandler); 57 | AddonForestry.instance.registerWithNEIPlugins(breedingRecipeHandler.getRecipeName(), breedingRecipeHandler.getRecipeIdent()); 58 | } 59 | 60 | if (AddonForestry.showTreeProducts) { 61 | TreeProduceHandler produceRecipeHandler = new TreeProduceHandler(); 62 | API.registerRecipeHandler(produceRecipeHandler); 63 | API.registerUsageHandler(produceRecipeHandler); 64 | AddonForestry.instance.registerWithNEIPlugins(produceRecipeHandler.getRecipeName(), produceRecipeHandler.getRecipeIdent()); 65 | } 66 | 67 | for (IAlleleTreeSpecies species : allSpecies) { 68 | if (AddonForestry.addSaplings) { 69 | Utils.safeAddNBTItem(GeneticsUtils.stackFromSpecies(species, EnumGermlingType.SAPLING.ordinal())); 70 | } 71 | if (AddonForestry.addPollen) { 72 | Utils.safeAddNBTItem(GeneticsUtils.stackFromSpecies(species, EnumGermlingType.POLLEN.ordinal())); 73 | } 74 | for (ItemStack prod : GeneticsUtils.getProduceFromSpecies(species).keySet()) { 75 | addProductToCache(prod.getItem(), species); 76 | } 77 | for (ItemStack prod : GeneticsUtils.getSpecialtyFromSpecies(species).keySet()) { 78 | addProductToCache(prod.getItem(), species); 79 | } 80 | } 81 | 82 | API.addOption(new MutationDumper(root, "tree_mutation")); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/BaseAddon.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons; 11 | 12 | import cpw.mods.fml.common.Loader; 13 | import cpw.mods.fml.common.ModContainer; 14 | import cpw.mods.fml.common.event.FMLPreInitializationEvent; 15 | import cpw.mods.fml.common.versioning.ArtifactVersion; 16 | import cpw.mods.fml.common.versioning.VersionParser; 17 | import cpw.mods.fml.relauncher.Side; 18 | import net.bdew.neiaddons.api.NEIAddon; 19 | import org.apache.logging.log4j.Level; 20 | import org.apache.logging.log4j.Logger; 21 | 22 | import java.util.Map; 23 | 24 | public abstract class BaseAddon implements NEIAddon { 25 | 26 | protected boolean active = false; 27 | protected Logger log; 28 | 29 | @Override 30 | public final boolean isActive() { 31 | return active; 32 | } 33 | 34 | public final void logInfo(String message, Object... params) { 35 | log.log(Level.INFO, String.format(message, params)); 36 | } 37 | 38 | public final void logWarning(String message, Object... params) { 39 | log.log(Level.ERROR, String.format(message, params)); 40 | } 41 | 42 | public final void logSevere(String message, Object... params) { 43 | log.log(Level.ERROR, String.format(message, params)); 44 | } 45 | 46 | public final void logWarningExc(Throwable t, String message, Object... params) { 47 | log.log(Level.WARN, String.format(message, params), t); 48 | } 49 | 50 | public final void logSevereExc(Throwable t, String message, Object... params) { 51 | log.log(Level.ERROR, String.format(message, params), t); 52 | } 53 | 54 | /** 55 | * @return Array of version dependencies, format used by FML {@link VersionParser} 56 | */ 57 | public String[] getDependencies() { 58 | return new String[0]; 59 | } 60 | 61 | /** 62 | * @return true to continue loading 63 | */ 64 | public boolean checkSide(Side side) { 65 | return true; 66 | } 67 | 68 | public abstract void preInit(FMLPreInitializationEvent ev); 69 | 70 | public final void doPreInit(FMLPreInitializationEvent ev) { 71 | log = ev.getModLog(); 72 | if (!checkSide(ev.getSide())) { 73 | logInfo("Wrong side: %s, %s Addon not loading", ev.getSide().toString(), getName()); 74 | return; 75 | } 76 | 77 | for (String dep : getDependencies()) { 78 | if (!verifyModVersion(dep)) { 79 | logWarning("Requirements unmet, %s Addon not loading", getName()); 80 | return; 81 | } 82 | } 83 | 84 | NEIAddons.register(this); 85 | } 86 | 87 | protected boolean verifyModVersion(String spec) { 88 | ArtifactVersion req = VersionParser.parseVersionReference(spec); 89 | String modid = req.getLabel(); 90 | 91 | Map modlist = Loader.instance().getIndexedModList(); 92 | 93 | if (!modlist.containsKey(modid)) { 94 | logInfo("Required mod %s is not installed, dependent features will be unavailable", req.getLabel()); 95 | return false; 96 | } 97 | 98 | ArtifactVersion found = modlist.get(modid).getProcessedVersion(); 99 | 100 | if (found == null) { 101 | logInfo("Unable to determine version of required mod %s, dependent features will be unavailable", req.getLabel()); 102 | return false; 103 | } 104 | 105 | if (!req.containsVersion(found)) { 106 | logInfo("Version mismatch: %s is required while %s was detected, dependent features will be unavailable", req.toString(), found.getVersionString()); 107 | return false; 108 | } 109 | 110 | logInfo("Version check success: %s required / %s detected", req.toString(), found.getVersionString()); 111 | 112 | return true; 113 | } 114 | 115 | public boolean isEnabledByDefault() { 116 | return true; 117 | } 118 | } -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/forestry/AddonForestry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.forestry; 11 | 12 | import cpw.mods.fml.common.Mod; 13 | import cpw.mods.fml.common.Mod.EventHandler; 14 | import cpw.mods.fml.common.Mod.Instance; 15 | import cpw.mods.fml.common.event.FMLInterModComms; 16 | import cpw.mods.fml.common.event.FMLPreInitializationEvent; 17 | import cpw.mods.fml.relauncher.Side; 18 | import cpw.mods.fml.relauncher.SideOnly; 19 | import net.bdew.neiaddons.BaseAddon; 20 | import net.bdew.neiaddons.NEIAddons; 21 | import net.bdew.neiaddons.forestry.bees.BeeHelper; 22 | import net.bdew.neiaddons.forestry.butterflies.ButterflyHelper; 23 | import net.bdew.neiaddons.forestry.trees.TreeHelper; 24 | import net.minecraft.client.resources.I18n; 25 | 26 | @Mod(modid = NEIAddons.modId + "|Forestry", name = "NEI Addons: Forestry", version = "NEIADDONS_VER", dependencies = "after:NEIAddons;after:Forestry") 27 | public class AddonForestry extends BaseAddon { 28 | public static boolean showSecret; 29 | public static boolean addBees; 30 | public static boolean addCombs; 31 | public static boolean addSaplings; 32 | public static boolean addPollen; 33 | public static boolean loadBlacklisted; 34 | public static boolean showBeeMutations; 35 | public static boolean showBeeProducts; 36 | public static boolean showTreeMutations; 37 | public static boolean showTreeProducts; 38 | public static boolean showButterflyMutations; 39 | public static boolean showReqs; 40 | 41 | @Instance(NEIAddons.modId + "|Forestry") 42 | public static AddonForestry instance; 43 | 44 | @Override 45 | public String getName() { 46 | return "Forestry"; 47 | } 48 | 49 | @Override 50 | public String[] getDependencies() { 51 | return new String[]{"Forestry@[4.0.8.36,)"}; 52 | } 53 | 54 | @Override 55 | @EventHandler 56 | public void preInit(FMLPreInitializationEvent ev) { 57 | doPreInit(ev); 58 | } 59 | 60 | @Override 61 | public void init(Side side) throws Exception { 62 | showBeeMutations = NEIAddons.config.get(getName(), "Show Bee Mutations", true, "Set to false to disable bee mutations browsing").getBoolean(false); 63 | showBeeProducts = NEIAddons.config.get(getName(), "Show Bee Products", true, "Set to false to disable bee products browsing").getBoolean(false); 64 | 65 | showTreeMutations = NEIAddons.config.get(getName(), "Show Tree Mutations", true, "Set to false to disable tree mutations browsing").getBoolean(false); 66 | showTreeProducts = NEIAddons.config.get(getName(), "Show Tree Products", true, "Set to false to disable tree products browsing").getBoolean(false); 67 | 68 | showButterflyMutations = NEIAddons.config.get(getName(), "Show Butterfly Mutations", true, "Set to false to disable butterfly mutations browsing").getBoolean(false); 69 | //showButterflyProducts = NEIAddons.config.get(getName(), "Show Butterfly Products", true, "Set to false to disable butterfly products browsing").getBoolean(false); 70 | 71 | showSecret = NEIAddons.config.get(getName(), "Show Secret Mutations", false, "Set to true to show secret mutations").getBoolean(false); 72 | 73 | showReqs = NEIAddons.config.get(getName(), "Show Mutation Requirements", true, "Set to false disable display of mutation requirements").getBoolean(false); 74 | 75 | addBees = NEIAddons.config.get(getName(), "Add Bees to Search", true, "Set to true to add all bees to NEI search").getBoolean(false); 76 | addCombs = NEIAddons.config.get(getName(), "Add Combs to Search", false, "Set to true to add all combs that are produced by bees to NEI search").getBoolean(false); 77 | addSaplings = NEIAddons.config.get(getName(), "Add Saplings to Search", true, "Set to true to add all saplings to NEI search").getBoolean(false); 78 | addPollen = NEIAddons.config.get(getName(), "Add Pollen to Search", true, "Set to true to add all pollen types to NEI search").getBoolean(false); 79 | 80 | loadBlacklisted = NEIAddons.config.get(getName(), "Load blacklisted", false, "Set to true to load blacklisted species and alleles, it's dangerous and (mostly) useless").getBoolean(false); 81 | 82 | active = true; 83 | } 84 | 85 | public void registerWithNEIPlugins(String name, String id) { 86 | FMLInterModComms.sendRuntimeMessage(this, "NEIPlugins", "register-crafting-handler", String.format("%s@%s@%s", I18n.format("bdew.neiaddons.genetics"), name, id)); 87 | } 88 | 89 | @Override 90 | @SideOnly(Side.CLIENT) 91 | public void loadClient() { 92 | BeeHelper.setup(); 93 | TreeHelper.setup(); 94 | ButterflyHelper.setup(); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/NEIAddons.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons; 11 | 12 | import cpw.mods.fml.common.Loader; 13 | import cpw.mods.fml.common.Mod; 14 | import cpw.mods.fml.common.Mod.EventHandler; 15 | import cpw.mods.fml.common.event.FMLInitializationEvent; 16 | import cpw.mods.fml.common.event.FMLPreInitializationEvent; 17 | import cpw.mods.fml.relauncher.Side; 18 | import net.bdew.neiaddons.api.NEIAddon; 19 | import net.bdew.neiaddons.network.ClientHandler; 20 | import net.bdew.neiaddons.network.NetChannel; 21 | import net.bdew.neiaddons.network.ServerHandler; 22 | import net.minecraftforge.common.config.Configuration; 23 | import org.apache.logging.log4j.Level; 24 | import org.apache.logging.log4j.Logger; 25 | 26 | import java.util.ArrayList; 27 | import java.util.List; 28 | 29 | @Mod(modid = NEIAddons.modId, name = "NEI Addons", version = "NEIADDONS_VER", dependencies = "after:NotEnoughItems") 30 | public class NEIAddons { 31 | 32 | public static final String modId = "NEIAddons"; 33 | public static final String channelId = "bdew.neiaddons"; 34 | public static final int netVersion = 1; 35 | 36 | public static List addons; 37 | public static Configuration config; 38 | private static Logger log; 39 | 40 | public static ServerHandler serverHandler; 41 | public static ClientHandler clientHandler; 42 | public static NetChannel channel; 43 | 44 | public static void register(NEIAddon addon) { 45 | addons.add(addon); 46 | } 47 | 48 | public static void logInfo(String message, Object... params) { 49 | log.log(Level.INFO, String.format(message, params)); 50 | } 51 | 52 | public static void logWarning(String message, Object... params) { 53 | log.log(Level.WARN, String.format(message, params)); 54 | } 55 | 56 | public static void logSevere(String message, Object... params) { 57 | log.log(Level.ERROR, String.format(message, params)); 58 | } 59 | 60 | public static void logWarningExc(Throwable t, String message, Object... params) { 61 | log.log(Level.WARN, String.format(message, params), t); 62 | } 63 | 64 | public static void logSevereExc(Throwable t, String message, Object... params) { 65 | log.log(Level.ERROR, String.format(message, params), t); 66 | } 67 | 68 | @EventHandler 69 | public void preInit(FMLPreInitializationEvent event) { 70 | log = event.getModLog(); 71 | channel = new NetChannel(channelId); 72 | 73 | config = new Configuration(event.getSuggestedConfigurationFile()); 74 | config.addCustomCategoryComment("Addons", "Controls loading of different addons, set to false to disable"); 75 | addons = new ArrayList(); 76 | 77 | if (event.getSide() == Side.CLIENT && !Loader.isModLoaded("NotEnoughItems")) { 78 | logSevere("NEI doesn't seem to be installed... NEI Addons require it to do anything useful client-side"); 79 | } 80 | } 81 | 82 | @EventHandler 83 | public void init(FMLInitializationEvent event) { 84 | logInfo("Loading NEI Addons"); 85 | for (NEIAddon addon : addons) { 86 | if (config.get("Addons", addon.getName(), addon.isEnabledByDefault()).getBoolean(false)) { 87 | logInfo("Loading %s Addon...", addon.getName()); 88 | try { 89 | addon.init(event.getSide()); 90 | if (addon.isActive()) { 91 | logInfo("%s Addon successfully loadded", addon.getName()); 92 | } 93 | } catch (Exception e) { 94 | log.warn(String.format("Loading %s Addon - Failed:", addon.getName()), e); 95 | } 96 | } else { 97 | logInfo("%s Addon disabled - skipping", addon.getName()); 98 | } 99 | } 100 | 101 | config.save(); 102 | 103 | serverHandler = new ServerHandler(); 104 | channel.addHandler(Side.SERVER, serverHandler); 105 | 106 | if (event.getSide().isClient()) { 107 | clientHandler = new ClientHandler(); 108 | channel.addHandler(Side.CLIENT, clientHandler); 109 | } 110 | 111 | if (addons.size() > 0) { 112 | String addonslist = "Loaded Addons:"; 113 | for (NEIAddon addon : addons) { 114 | addonslist += "\n- " + addon.getName() + ": " + (addon.isActive() ? "Active" : "Inactive"); 115 | } 116 | Loader.instance().activeModContainer().getMetadata().description = addonslist; 117 | } else { 118 | Loader.instance().activeModContainer().getMetadata().description = "No Addons loaded :("; 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/Utils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons; 11 | 12 | import codechicken.nei.api.API; 13 | import net.minecraft.client.Minecraft; 14 | import net.minecraft.client.gui.FontRenderer; 15 | import net.minecraft.item.ItemStack; 16 | 17 | import java.lang.reflect.Field; 18 | import java.util.HashMap; 19 | import java.util.Map; 20 | import java.util.Map.Entry; 21 | 22 | public class Utils { 23 | @SuppressWarnings("unchecked") 24 | public static Class getAndCheckClass(String cls, Class sup) throws ClassNotFoundException { 25 | Class c = Class.forName(cls); 26 | if (c != null) { 27 | if (sup.isAssignableFrom(c)) { 28 | return (Class) c; 29 | } else { 30 | throw new RuntimeException(cls + " doesn't extend " + sup.getName()); 31 | } 32 | } else { 33 | throw new RuntimeException("Can't get " + cls); 34 | } 35 | } 36 | 37 | @SuppressWarnings("unchecked") 38 | public static T getAndCheckStaicField(String cls, String field, Class sup) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException { 39 | Class c = Class.forName(cls); 40 | if (c == null) throw new RuntimeException("Can't get " + cls); 41 | 42 | Field f = c.getField(field); 43 | if (f == null) throw new RuntimeException("Can't get " + cls + "." + field); 44 | 45 | Object v = f.get(null); 46 | if (v == null) throw new RuntimeException(cls + "." + field + " is null"); 47 | if (sup.isInstance(v)) { 48 | return (T) v; 49 | } else { 50 | throw new RuntimeException(String.format("%s.%s is of wrong type, expected: %s, got: %s", cls, field, sup, v.getClass())); 51 | } 52 | } 53 | 54 | public static void drawCenteredString(String s, int x, int y, int color) { 55 | FontRenderer f = Minecraft.getMinecraft().fontRenderer; 56 | f.drawString(s, x - f.getStringWidth(s) / 2, y, color); 57 | } 58 | 59 | public static void safeAddNBTItem(ItemStack item) { 60 | if (item == null) 61 | return; 62 | API.addItemListEntry(item); 63 | } 64 | 65 | /** 66 | * Like ItemStack.isItemStackEqual but ignores stack size 67 | */ 68 | public static boolean isSameItem(ItemStack s1, ItemStack s2) { 69 | if ((s1 == null) || (s2 == null)) 70 | return false; 71 | if (s1.getItem() != s2.getItem()) 72 | return false; 73 | if (s1.getItemDamage() != s2.getItemDamage()) 74 | return false; 75 | if ((s1.getTagCompound() == null) && (s2.getTagCompound() == null)) 76 | return true; 77 | if ((s1.getTagCompound() == null) || (s2.getTagCompound() == null)) 78 | return false; 79 | return s1.getTagCompound().equals(s2.getTagCompound()); 80 | } 81 | 82 | public static Map mergeStacks(Map stacks) { 83 | Map merged = new HashMap(); 84 | outer: 85 | for (Entry stack : stacks.entrySet()) { 86 | if (stack.getKey() == null) { 87 | NEIAddons.logSevere("Null ItemStack in mergeStacks!"); 88 | continue; 89 | } 90 | for (Entry mergedStack : merged.entrySet()) { 91 | if (isSameItem(stack.getKey(), mergedStack.getKey()) && (stack.getValue().equals(mergedStack.getValue()))) { 92 | mergedStack.getKey().stackSize += 1; 93 | continue outer; 94 | } 95 | } 96 | merged.put(stack.getKey().copy(), stack.getValue()); 97 | } 98 | return merged; 99 | } 100 | 101 | public static Map sanitizeDrops(Map drops, String origin) { 102 | Map res = new HashMap(); 103 | boolean complained = false; 104 | if (drops == null) { 105 | NEIAddons.logWarning("%s returned null", origin); 106 | return res; 107 | } 108 | for (Entry ent : drops.entrySet()) { 109 | if (ent.getKey() == null || ent.getKey().getItem() == null) { 110 | if (!complained) { 111 | NEIAddons.logWarning("%s contains nulls and/or corrupt item stacks", origin); 112 | complained = true; 113 | } 114 | continue; 115 | } 116 | res.put(ent.getKey(), ent.getValue()); 117 | } 118 | return res; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/utils/CustomOverlayHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.utils; 11 | 12 | import codechicken.nei.LayoutManager; 13 | import codechicken.nei.NEIClientUtils; 14 | import codechicken.nei.OffsetPositioner; 15 | import codechicken.nei.PositionedStack; 16 | import codechicken.nei.api.DefaultOverlayRenderer; 17 | import codechicken.nei.api.IOverlayHandler; 18 | import codechicken.nei.api.IStackPositioner; 19 | import codechicken.nei.guihook.GuiContainerManager; 20 | import codechicken.nei.recipe.IRecipeHandler; 21 | import net.bdew.neiaddons.NEIAddons; 22 | import net.bdew.neiaddons.network.ClientHandler; 23 | import net.bdew.neiaddons.network.PacketHelper; 24 | import net.minecraft.client.Minecraft; 25 | import net.minecraft.client.gui.inventory.GuiContainer; 26 | import net.minecraft.inventory.Slot; 27 | import net.minecraft.item.ItemStack; 28 | import net.minecraft.nbt.NBTTagCompound; 29 | import net.minecraft.nbt.NBTTagList; 30 | 31 | import java.util.List; 32 | 33 | import static codechicken.nei.NEIServerUtils.areStacksSameType; 34 | 35 | public class CustomOverlayHandler implements IOverlayHandler { 36 | private boolean invert; 37 | private String command; 38 | private int xOffs, yOffs; 39 | private Class craftingSlot; 40 | 41 | public CustomOverlayHandler(String command, int xOffs, int yOffs, boolean invert, Class craftingSlot) { 42 | super(); 43 | this.command = command; 44 | this.xOffs = xOffs; 45 | this.yOffs = yOffs; 46 | this.craftingSlot = craftingSlot; 47 | this.invert = invert; 48 | } 49 | 50 | private Slot findMatchingSlot(GuiContainer cont, PositionedStack pstack) { 51 | for (Object slotob : cont.inventorySlots.inventorySlots) { 52 | Slot slot = (Slot) slotob; 53 | if ((slot.xDisplayPosition == pstack.relx + xOffs) && (slot.yDisplayPosition == pstack.rely + yOffs)) { 54 | return slot; 55 | } 56 | } 57 | NEIAddons.logWarning("Failed to find matching slot - (%d,%d) in %s", pstack.relx + xOffs, pstack.rely + yOffs, cont.toString()); 58 | return null; 59 | } 60 | 61 | private Boolean isValidSlot(Slot slot) { 62 | // Don't try to take items from special slots 63 | return (slot.inventory == Minecraft.getMinecraft().thePlayer.inventory) || (slot.getClass() == Slot.class); 64 | } 65 | 66 | private Slot findItem(GuiContainer cont, PositionedStack p) { 67 | for (ItemStack teststack : p.items) { 68 | for (Object slotob : cont.inventorySlots.inventorySlots) { 69 | Slot slot = (Slot) slotob; 70 | if (isValidSlot(slot)) { 71 | ItemStack stack = slot.getStack(); 72 | if (stack != null && areStacksSameType(stack, teststack)) { 73 | return slot; 74 | } 75 | } 76 | } 77 | } 78 | return null; 79 | } 80 | 81 | @Override 82 | public void overlayRecipe(GuiContainer cont, IRecipeHandler recipe, int recipeIndex, boolean shift) { 83 | List ingr = recipe.getIngredientStacks(recipeIndex); 84 | 85 | if (invert) { 86 | shift = !shift; 87 | } 88 | 89 | if (!shift) { 90 | IStackPositioner positioner = new OffsetPositioner(xOffs, yOffs); 91 | LayoutManager.overlayRenderer = new DefaultOverlayRenderer(ingr, positioner); 92 | } else if (ClientHandler.enabledCommands.contains(command)) { 93 | NBTTagList stacksnbt = new NBTTagList(); 94 | 95 | for (PositionedStack pstack : ingr) { 96 | if (pstack != null) { 97 | // This is back-asswards but i don't see a better way :( 98 | int x = (pstack.relx - 25) / 18; 99 | int y = (pstack.rely - 6) / 18; 100 | 101 | ItemStack stack = pstack.item; 102 | NBTTagCompound stacknbt = stack.writeToNBT(new NBTTagCompound()); 103 | stacknbt.setInteger("slot", y * 3 + x); 104 | stacksnbt.appendTag(stacknbt); 105 | } 106 | 107 | ItemStack stack = recipe.getResultStack(recipeIndex).items[0]; 108 | NBTTagCompound stacknbt = stack.writeToNBT(new NBTTagCompound()); 109 | stacknbt.setInteger("slot", 9); 110 | stacksnbt.appendTag(stacknbt); 111 | } 112 | 113 | NBTTagCompound data = new NBTTagCompound(); 114 | data.setTag("stacks", stacksnbt); 115 | 116 | PacketHelper.sendToServer(command, data); 117 | } else { 118 | if (NEIClientUtils.getHeldItem() != null) { 119 | return; 120 | } 121 | NEIAddons.logInfo("Don't have server support, moving recipe manually"); 122 | GuiContainerManager manager = GuiContainerManager.getManager(cont); 123 | //noinspection ConstantConditions 124 | if (manager != null) { 125 | for (Object slotob : cont.inventorySlots.inventorySlots) { 126 | if (craftingSlot.isInstance(slotob)) { 127 | Slot slot = (Slot) slotob; 128 | // Left click once to clear 129 | manager.handleSlotClick(slot.slotNumber, 0, 0); 130 | } 131 | } 132 | for (PositionedStack pstack : ingr) { 133 | if (pstack != null) { 134 | 135 | Slot slotTo = findMatchingSlot(cont, pstack); 136 | if (slotTo == null) 137 | continue; 138 | 139 | Slot slotFrom = findItem(cont, pstack); 140 | if (slotFrom == null) 141 | continue; 142 | 143 | NEIAddons.logInfo("Moving from slot %s[%d] to %s[%d]", slotFrom.toString(), slotFrom.slotNumber, slotTo.toString(), slotTo.slotNumber); 144 | 145 | // pick up item 146 | manager.handleSlotClick(slotFrom.slotNumber, 0, 0); 147 | // right click to add 1 148 | manager.handleSlotClick(slotTo.slotNumber, 1, 0); 149 | // put item back 150 | manager.handleSlotClick(slotFrom.slotNumber, 0, 0); 151 | } 152 | } 153 | } 154 | } 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/forestry/GeneticsUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.forestry; 11 | 12 | import forestry.api.apiculture.EnumBeeType; 13 | import forestry.api.apiculture.IAlleleBeeSpecies; 14 | import forestry.api.apiculture.IBeeRoot; 15 | import forestry.api.arboriculture.EnumGermlingType; 16 | import forestry.api.arboriculture.IAlleleTreeSpecies; 17 | import forestry.api.arboriculture.ITree; 18 | import forestry.api.arboriculture.ITreeRoot; 19 | import forestry.api.genetics.*; 20 | import forestry.api.lepidopterology.IAlleleButterflySpecies; 21 | import net.bdew.neiaddons.Utils; 22 | import net.minecraft.item.ItemStack; 23 | 24 | import java.util.ArrayList; 25 | import java.util.Collection; 26 | import java.util.HashMap; 27 | import java.util.Map; 28 | import java.util.Map.Entry; 29 | 30 | public class GeneticsUtils { 31 | public enum RecipePosition { 32 | Parent1, Parent2, Offspring, Producer 33 | } 34 | 35 | public static Map beePositionToType; 36 | public static Map treePositionToType; 37 | 38 | static { 39 | beePositionToType = new HashMap(); 40 | beePositionToType.put(RecipePosition.Parent1, EnumBeeType.PRINCESS.ordinal()); 41 | beePositionToType.put(RecipePosition.Parent2, EnumBeeType.DRONE.ordinal()); 42 | beePositionToType.put(RecipePosition.Offspring, EnumBeeType.QUEEN.ordinal()); 43 | beePositionToType.put(RecipePosition.Producer, EnumBeeType.QUEEN.ordinal()); 44 | 45 | treePositionToType = new HashMap(); 46 | treePositionToType.put(RecipePosition.Parent1, EnumGermlingType.SAPLING.ordinal()); 47 | treePositionToType.put(RecipePosition.Parent2, EnumGermlingType.POLLEN.ordinal()); 48 | treePositionToType.put(RecipePosition.Offspring, EnumGermlingType.SAPLING.ordinal()); 49 | treePositionToType.put(RecipePosition.Producer, EnumGermlingType.SAPLING.ordinal()); 50 | } 51 | 52 | public static ItemStack stackFromSpecies(IAlleleSpecies species, RecipePosition position) { 53 | ISpeciesRoot root = species.getRoot(); 54 | int type = 0; 55 | if (root instanceof IBeeRoot) { 56 | type = beePositionToType.get(position); 57 | } else if (root instanceof ITreeRoot) { 58 | type = treePositionToType.get(position); 59 | } 60 | return stackFromSpecies(species, type); 61 | } 62 | 63 | public static ItemStack stackFromSpecies(IAlleleSpecies species, int type) { 64 | ISpeciesRoot root = species.getRoot(); 65 | IAllele[] template = root.getTemplate(species.getUID()); 66 | if (template == null) { 67 | AddonForestry.instance.logWarning("Template for %s is null, wtf?", species.getUID()); 68 | return null; 69 | } 70 | IIndividual individual = root.templateAsIndividual(template); 71 | individual.analyze(); 72 | ItemStack stack = root.getMemberStack(individual, type); 73 | if (stack == null) { 74 | AddonForestry.instance.logWarning("Got null from getMemberStack, wtf? (%s)", species.getUID()); 75 | } 76 | return stack; 77 | } 78 | 79 | public static Collection getAllBeeSpecies(boolean includeBlacklisted) { 80 | return getAllTypedSpecies(IAlleleBeeSpecies.class, includeBlacklisted); 81 | } 82 | 83 | public static Collection getAllButterflySpecies(boolean includeBlacklisted) { 84 | return getAllTypedSpecies(IAlleleButterflySpecies.class, includeBlacklisted); 85 | } 86 | 87 | public static Collection getAllTreeSpecies(boolean includeBlacklisted) { 88 | return getAllTypedSpecies(IAlleleTreeSpecies.class, includeBlacklisted); 89 | } 90 | 91 | @SuppressWarnings("unchecked") 92 | public static Collection getAllTypedSpecies(Class type, boolean includeBlacklisted) { 93 | ArrayList list = new ArrayList(); 94 | for (Entry entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) { 95 | if (type.isInstance(entry.getValue())) { 96 | if (includeBlacklisted || !AlleleManager.alleleRegistry.isBlacklisted(entry.getValue().getUID())) { 97 | list.add((T) entry.getValue()); 98 | } 99 | } 100 | } 101 | return list; 102 | } 103 | 104 | static public Map getProduceFromSpecies(IAlleleSpecies species) { 105 | if (species instanceof IAlleleBeeSpecies) { 106 | return Utils.sanitizeDrops(((IAlleleBeeSpecies) species).getProductChances(), species.getUID() + " drops"); 107 | } else if (species instanceof IAlleleTreeSpecies) { 108 | Map result = new HashMap(); 109 | ITreeRoot root = (ITreeRoot) species.getRoot(); 110 | IAllele[] template = root.getTemplate(species.getUID()); 111 | if (template == null) { 112 | AddonForestry.instance.logWarning("Template for %s is null, wtf?", species.getUID()); 113 | return result; 114 | } 115 | ITree tree = root.templateAsIndividual(template); 116 | for (ItemStack stack : tree.getProduceList()) { 117 | if (stack == null || stack.getItem() == null) { 118 | AddonForestry.instance.logWarning("%s returned null in produce list", species.getUID()); 119 | continue; 120 | } 121 | result.put(stack, 1F); 122 | } 123 | return result; 124 | } 125 | return new HashMap(); 126 | } 127 | 128 | static public Map getSpecialtyFromSpecies(IAlleleSpecies species) { 129 | if (species instanceof IAlleleBeeSpecies) { 130 | return Utils.sanitizeDrops(((IAlleleBeeSpecies) species).getSpecialtyChances(), species.getUID() + " specialty"); 131 | } else if (species instanceof IAlleleTreeSpecies) { 132 | Map result = new HashMap(); 133 | ITreeRoot root = (ITreeRoot) species.getRoot(); 134 | IAllele[] template = root.getTemplate(species.getUID()); 135 | if (template == null) { 136 | AddonForestry.instance.logWarning("Template for %s is null, wtf?", species.getUID()); 137 | return result; 138 | } 139 | ITree tree = root.templateAsIndividual(template); 140 | for (ItemStack stack : tree.getSpecialtyList()) { 141 | if (stack == null || stack.getItem() == null) { 142 | AddonForestry.instance.logWarning("%s returned null in specialty list", species.getUID()); 143 | continue; 144 | } 145 | result.put(stack, 1F); 146 | } 147 | return result; 148 | } 149 | return new HashMap(); 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/forestry/bees/BeeHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.forestry.bees; 11 | 12 | import codechicken.nei.api.API; 13 | import cpw.mods.fml.common.Loader; 14 | import cpw.mods.fml.common.registry.GameRegistry; 15 | import forestry.api.apiculture.EnumBeeType; 16 | import forestry.api.apiculture.IAlleleBeeSpecies; 17 | import forestry.api.apiculture.IBeeRoot; 18 | import forestry.api.genetics.AlleleManager; 19 | import forestry.api.genetics.IAlleleSpecies; 20 | import net.bdew.neiaddons.Utils; 21 | import net.bdew.neiaddons.forestry.AddonForestry; 22 | import net.bdew.neiaddons.forestry.GeneticsUtils; 23 | import net.bdew.neiaddons.forestry.MutationDumper; 24 | import net.minecraft.item.Item; 25 | import net.minecraft.item.ItemStack; 26 | 27 | import java.util.*; 28 | 29 | public class BeeHelper { 30 | 31 | public static Collection allSpecies; 32 | public static Map> productsCache = new HashMap>(); 33 | 34 | public static IBeeRoot root; 35 | 36 | private static void addProductToCache(Item item, IAlleleBeeSpecies species) { 37 | if (!productsCache.containsKey(item)) { 38 | productsCache.put(item, new ArrayList()); 39 | } 40 | productsCache.get(item).add(species); 41 | } 42 | 43 | private static void addHandlers() { 44 | if (AddonForestry.showBeeMutations) { 45 | BeeBreedingHandler breedingRecipeHandler = new BeeBreedingHandler(); 46 | API.registerRecipeHandler(breedingRecipeHandler); 47 | API.registerUsageHandler(breedingRecipeHandler); 48 | AddonForestry.instance.registerWithNEIPlugins(breedingRecipeHandler.getRecipeName(), breedingRecipeHandler.getRecipeIdent()); 49 | } 50 | 51 | if (AddonForestry.showBeeProducts) { 52 | BeeProduceHandler productsRecipeHandler = new BeeProduceHandler(); 53 | API.registerRecipeHandler(productsRecipeHandler); 54 | API.registerUsageHandler(productsRecipeHandler); 55 | AddonForestry.instance.registerWithNEIPlugins(productsRecipeHandler.getRecipeName(), productsRecipeHandler.getRecipeIdent()); 56 | } 57 | } 58 | 59 | public static void setup() { 60 | root = (IBeeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootBees"); 61 | 62 | if (root == null) { 63 | AddonForestry.instance.logWarning("Bee Species Root not found, some functionality will be unavailable"); 64 | return; 65 | } 66 | 67 | allSpecies = GeneticsUtils.getAllBeeSpecies(AddonForestry.loadBlacklisted); 68 | 69 | addHandlers(); 70 | 71 | HashMap> seencombs = new HashMap>(); 72 | 73 | List modCombs = getMobCombs(); 74 | for (Item combItem : modCombs) { 75 | seencombs.put(combItem, new HashSet()); 76 | } 77 | 78 | for (IAlleleBeeSpecies species : allSpecies) { 79 | if (AddonForestry.addBees) { 80 | Utils.safeAddNBTItem(GeneticsUtils.stackFromSpecies(species, EnumBeeType.QUEEN.ordinal())); 81 | Utils.safeAddNBTItem(GeneticsUtils.stackFromSpecies(species, EnumBeeType.DRONE.ordinal())); 82 | Utils.safeAddNBTItem(GeneticsUtils.stackFromSpecies(species, EnumBeeType.PRINCESS.ordinal())); 83 | } 84 | for (ItemStack prod : GeneticsUtils.getProduceFromSpecies(species).keySet()) { 85 | addProductToCache(prod.getItem(), species); 86 | if (AddonForestry.addCombs && seencombs.containsKey(prod.getItem())) { 87 | seencombs.get(prod.getItem()).add(prod.getItemDamage()); 88 | } 89 | } 90 | for (ItemStack prod : GeneticsUtils.getSpecialtyFromSpecies(species).keySet()) { 91 | addProductToCache(prod.getItem(), species); 92 | if (AddonForestry.addCombs && seencombs.containsKey(prod.getItem())) { 93 | seencombs.get(prod.getItem()).add(prod.getItemDamage()); 94 | } 95 | } 96 | } 97 | 98 | if (AddonForestry.addCombs) { 99 | for (Item combItem : modCombs) { 100 | HashSet subitems = seencombs.get(combItem); 101 | 102 | ArrayList combs = new ArrayList(); 103 | combItem.getSubItems(combItem, null, combs); 104 | 105 | for (ItemStack item : combs) { 106 | subitems.add(item.getItemDamage()); 107 | AddonForestry.instance.logInfo("Registering comb variant for %s: %s", combItem.getClass().getName(), item.toString()); 108 | API.addItemListEntry(item); 109 | } 110 | } 111 | } 112 | 113 | API.addOption(new MutationDumper(root, "bee_mutation")); 114 | } 115 | 116 | private static List getMobCombs() { 117 | List res = new ArrayList(); 118 | 119 | Item vanillaComb = GameRegistry.findItem("Forestry", "beeCombs"); 120 | 121 | if (vanillaComb == null) { 122 | AddonForestry.instance.logWarning("Failed to get forestry bee comb item, something is messed up"); 123 | } else { 124 | res.add(vanillaComb); 125 | } 126 | 127 | if (Loader.isModLoaded("ExtraBees")) { 128 | try { 129 | Class ebItems = Class.forName("binnie.extrabees.ExtraBees"); 130 | Object ebComb = ebItems.getField("comb").get(null); 131 | if (ebComb instanceof Item) { 132 | AddonForestry.instance.logInfo("Loaded Extra Bees comb item: %s (%s)", ebComb.toString(), ebComb); 133 | res.add((Item) ebComb); 134 | } else { 135 | AddonForestry.instance.logWarning("Extra Bees comb is not Item subclass!"); 136 | } 137 | } catch (Throwable e) { 138 | AddonForestry.instance.logWarningExc(e, "Error locating Extra Bees comb item"); 139 | } 140 | } 141 | 142 | if (Loader.isModLoaded("MagicBees")) { 143 | try { 144 | Class mbConfig = Class.forName("magicbees.main.Config"); 145 | Object mbComb = mbConfig.getField("combs").get(null); 146 | AddonForestry.instance.logInfo("Loaded TB comb item: %s", mbComb.toString()); 147 | if (mbComb instanceof Item) { 148 | AddonForestry.instance.logInfo("Loaded Magic Bees comb item: %s (%s)", mbComb.toString(), mbComb); 149 | res.add((Item) mbComb); 150 | } else { 151 | AddonForestry.instance.logWarning("Magic Bees comb is not Item subclass!"); 152 | } 153 | } catch (Throwable e) { 154 | AddonForestry.instance.logWarningExc(e, "Error locating Magic Bees comb item"); 155 | } 156 | } 157 | 158 | return res; 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/forestry/BaseProduceRecipeHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.forestry; 11 | 12 | import codechicken.nei.NEIClientUtils; 13 | import codechicken.nei.PositionedStack; 14 | import codechicken.nei.recipe.TemplateRecipeHandler; 15 | import forestry.api.genetics.IAlleleSpecies; 16 | import forestry.api.genetics.IIndividual; 17 | import forestry.api.genetics.ISpeciesRoot; 18 | import net.bdew.neiaddons.Utils; 19 | import net.bdew.neiaddons.utils.LabeledPositionedStack; 20 | import net.minecraft.client.Minecraft; 21 | import net.minecraft.client.gui.FontRenderer; 22 | import net.minecraft.client.resources.I18n; 23 | import net.minecraft.item.Item; 24 | import net.minecraft.item.ItemStack; 25 | 26 | import java.awt.*; 27 | import java.util.ArrayList; 28 | import java.util.Collection; 29 | import java.util.Map; 30 | import java.util.Map.Entry; 31 | 32 | public abstract class BaseProduceRecipeHandler extends TemplateRecipeHandler { 33 | 34 | private final ISpeciesRoot speciesRoot; 35 | private final Map> cache; 36 | 37 | public BaseProduceRecipeHandler(ISpeciesRoot root) { 38 | this.speciesRoot = root; 39 | cache = getProduceCache(); 40 | } 41 | 42 | public class CachedProduceRecipe extends CachedRecipe { 43 | private LabeledPositionedStack producer; 44 | private ArrayList products; 45 | 46 | public CachedProduceRecipe(IAlleleSpecies species) { 47 | ItemStack producerStack = GeneticsUtils.stackFromSpecies(species, GeneticsUtils.RecipePosition.Producer); 48 | if (producerStack == null) { 49 | AddonForestry.instance.logWarning("Producer is null... wtf? species = %s", species.getUID()); 50 | } else { 51 | producer = new LabeledPositionedStack(producerStack, 22, 19, species.getName(), 13); 52 | } 53 | 54 | products = new ArrayList(); 55 | 56 | int i = 0; 57 | for (Entry product : Utils.mergeStacks(GeneticsUtils.getProduceFromSpecies(species)).entrySet()) { 58 | String label = String.format("%.1f%%", product.getValue() * 100F); 59 | products.add(new LabeledPositionedStack(product.getKey(), 96 + 22 * i++, 8, label, 10)); 60 | } 61 | 62 | i = 0; 63 | for (Entry product : Utils.mergeStacks(GeneticsUtils.getSpecialtyFromSpecies(species)).entrySet()) { 64 | String label = String.format("%.1f%%", product.getValue() * 100F); 65 | products.add(new LabeledPositionedStack(product.getKey(), 96 + 22 * i++, 36, label, 10)); 66 | } 67 | } 68 | 69 | public boolean isNoOutput() { 70 | return products.size() == 0; 71 | } 72 | 73 | @Override 74 | public ArrayList getIngredients() { 75 | ArrayList list = new ArrayList(); 76 | list.add(producer); 77 | return list; 78 | } 79 | 80 | @Override 81 | public ArrayList getOtherStacks() { 82 | ArrayList list = new ArrayList(); 83 | if (products.size() > 1) { 84 | for (int i = 1; i < products.size(); i++) { 85 | list.add(products.get(i)); 86 | } 87 | } 88 | return list; 89 | } 90 | 91 | @Override 92 | public PositionedStack getResult() { 93 | if (products.size() > 0) { 94 | return products.get(0); 95 | } else { 96 | return null; 97 | } 98 | } 99 | } 100 | 101 | @Override 102 | public void loadCraftingRecipes(String outputId, Object... results) { 103 | if (outputId.equals("item")) { 104 | loadCraftingRecipes((ItemStack) results[0]); 105 | return; 106 | } 107 | 108 | if (!outputId.equals(getRecipeIdent())) { 109 | return; 110 | } 111 | 112 | for (IAlleleSpecies species : getAllSpecies()) { 113 | CachedProduceRecipe rec = new CachedProduceRecipe(species); 114 | if (!rec.isNoOutput()) { 115 | arecipes.add(rec); 116 | } 117 | } 118 | } 119 | 120 | @Override 121 | public void loadCraftingRecipes(ItemStack result) { 122 | if (cache == null) return; 123 | if (result == null) { 124 | AddonForestry.instance.logWarning("loadCraftingRecipes() called with null, something is FUBAR."); 125 | return; 126 | } 127 | if (!cache.containsKey(result.getItem())) { 128 | return; 129 | } 130 | for (IAlleleSpecies species : cache.get(result.getItem())) { 131 | CachedProduceRecipe recipe = new CachedProduceRecipe(species); 132 | for (LabeledPositionedStack stack : recipe.products) { 133 | if (NEIClientUtils.areStacksSameTypeCrafting(stack.item, result)) { 134 | arecipes.add(recipe); 135 | break; 136 | } 137 | } 138 | } 139 | } 140 | 141 | @Override 142 | public void loadUsageRecipes(ItemStack ingredient) { 143 | if (!speciesRoot.isMember(ingredient)) { 144 | return; 145 | } 146 | IIndividual member = speciesRoot.getMember(ingredient); 147 | if (member == null || member.getGenome() == null || member.getGenome().getPrimary() == null) { 148 | AddonForestry.instance.logWarning("Individual or genome is null searching recipe for %s", ingredient.toString()); 149 | return; 150 | } 151 | arecipes.add(new CachedProduceRecipe(member.getGenome().getPrimary())); 152 | } 153 | 154 | @Override 155 | public void loadTransferRects() { 156 | transferRects.add(new RecipeTransferRect(new Rectangle(48, 22, 21, 15), getRecipeIdent())); 157 | } 158 | 159 | @Override 160 | public void drawExtras(int recipe) { 161 | CachedProduceRecipe rec = (CachedProduceRecipe) arecipes.get(recipe); 162 | rec.producer.drawLabel(); 163 | for (LabeledPositionedStack stack : rec.products) { 164 | stack.drawLabel(); 165 | } 166 | FontRenderer f = Minecraft.getMinecraft().fontRenderer; 167 | f.drawString("Prod:", 65, 8 + 4, 0xFFFFFF); 168 | f.drawString("Spec:", 65, 36 + 4, 0xFFF200); 169 | } 170 | 171 | public abstract String getRecipeIdent(); 172 | 173 | public abstract Collection getAllSpecies(); 174 | 175 | public abstract Map> getProduceCache(); 176 | 177 | @Override 178 | public String getGuiTexture() { 179 | return "neiaddons:textures/gui/products.png"; 180 | } 181 | 182 | @Override 183 | public final String getRecipeName() { 184 | return I18n.format("bdew.neiaddons.produce." + getRecipeIdent()); 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /src/net/bdew/neiaddons/forestry/BaseBreedingRecipeHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) bdew, 2013 - 2015 3 | * https://github.com/bdew/neiaddons 4 | * 5 | * This mod is distributed under the terms of the Minecraft Mod Public 6 | * License 1.0, or MMPL. Please check the contents of the license located in 7 | * http://bdew.net/minecraft-mod-public-license/ 8 | */ 9 | 10 | package net.bdew.neiaddons.forestry; 11 | 12 | import codechicken.lib.gui.GuiDraw; 13 | import codechicken.nei.PositionedStack; 14 | import codechicken.nei.guihook.GuiContainerManager; 15 | import codechicken.nei.recipe.GuiRecipe; 16 | import codechicken.nei.recipe.TemplateRecipeHandler; 17 | import forestry.api.genetics.IAlleleSpecies; 18 | import forestry.api.genetics.IIndividual; 19 | import forestry.api.genetics.IMutation; 20 | import forestry.api.genetics.ISpeciesRoot; 21 | import net.bdew.neiaddons.Utils; 22 | import net.bdew.neiaddons.utils.LabeledPositionedStack; 23 | import net.minecraft.client.resources.I18n; 24 | import net.minecraft.item.ItemStack; 25 | import net.minecraft.util.EnumChatFormatting; 26 | 27 | import java.awt.*; 28 | import java.util.ArrayList; 29 | import java.util.Collection; 30 | import java.util.Collections; 31 | import java.util.List; 32 | 33 | public abstract class BaseBreedingRecipeHandler extends TemplateRecipeHandler { 34 | 35 | private final ISpeciesRoot speciesRoot; 36 | 37 | public BaseBreedingRecipeHandler(ISpeciesRoot root) { 38 | this.speciesRoot = root; 39 | } 40 | 41 | public class CachedBreedingRecipe extends CachedRecipe { 42 | LabeledPositionedStack parrent1, parrent2, result; 43 | public float chance; 44 | public Collection requirements; 45 | public Boolean derp = false; 46 | 47 | public CachedBreedingRecipe(IMutation mutation) { 48 | ItemStack stackParent1 = GeneticsUtils.stackFromSpecies(mutation.getAllele0(), GeneticsUtils.RecipePosition.Parent1); 49 | ItemStack stackParent2 = GeneticsUtils.stackFromSpecies(mutation.getAllele1(), GeneticsUtils.RecipePosition.Parent2); 50 | ItemStack stackResult = GeneticsUtils.stackFromSpecies((IAlleleSpecies) mutation.getTemplate()[0], GeneticsUtils.RecipePosition.Offspring); 51 | 52 | parrent1 = new LabeledPositionedStack(stackParent1, 22, 19, mutation.getAllele0().getName(), 13); 53 | parrent2 = new LabeledPositionedStack(stackParent2, 75, 19, mutation.getAllele1().getName(), 13); 54 | result = new LabeledPositionedStack(stackResult, 129, 19, mutation.getTemplate()[0].getName(), 13); 55 | chance = mutation.getBaseChance(); 56 | 57 | try { 58 | requirements = mutation.getSpecialConditions(); 59 | } catch (Throwable t) { 60 | AddonForestry.instance.logSevereExc(t, "Error in mutation.getSpecialConditions for mutation %s + %s -> %s", 61 | mutation.getAllele0().getUID(), mutation.getAllele1().getUID(), mutation.getTemplate()[0].getUID()); 62 | requirements = Collections.singletonList(EnumChatFormatting.RED + "Error! See log for details"); 63 | derp = true; 64 | } 65 | 66 | if (requirements == null) { 67 | AddonForestry.instance.logWarning("Mutation %s + %s -> %s is returning null from getSpecialConditions", 68 | mutation.getAllele0().getUID(), mutation.getAllele1().getUID(), mutation.getTemplate()[0].getUID()); 69 | requirements = new ArrayList(); 70 | } 71 | } 72 | 73 | @Override 74 | public PositionedStack getResult() { 75 | return result; 76 | } 77 | 78 | @Override 79 | public ArrayList getIngredients() { 80 | ArrayList list = new ArrayList(); 81 | list.add(parrent1); 82 | list.add(parrent2); 83 | return list; 84 | } 85 | } 86 | 87 | @Override 88 | public void loadCraftingRecipes(String outputId, Object... results) { 89 | if (outputId.equals("item")) { 90 | loadCraftingRecipes((ItemStack) results[0]); 91 | return; 92 | } 93 | 94 | if (!outputId.equals(getRecipeIdent())) { 95 | return; 96 | } 97 | 98 | for (IMutation mutation : speciesRoot.getMutations(false)) { 99 | if (!mutation.isSecret() || AddonForestry.showSecret) { 100 | arecipes.add(new CachedBreedingRecipe(mutation)); 101 | } 102 | } 103 | } 104 | 105 | @Override 106 | public void loadCraftingRecipes(ItemStack result) { 107 | if (!speciesRoot.isMember(result)) { 108 | return; 109 | } 110 | IIndividual resultIndividual = speciesRoot.getMember(result); 111 | if (resultIndividual == null) { 112 | AddonForestry.instance.logWarning("IIndividual is null searching recipe for %s", result.toString()); 113 | return; 114 | } 115 | if (resultIndividual.getGenome() == null) { 116 | AddonForestry.instance.logWarning("Genome is null when searching recipe for %s", result.toString()); 117 | return; 118 | } 119 | if (resultIndividual.getGenome().getPrimary() == null) { 120 | AddonForestry.instance.logWarning("Species is null when searching recipe for %s", result.toString()); 121 | return; 122 | } 123 | IAlleleSpecies species = resultIndividual.getGenome().getPrimary(); 124 | 125 | for (IMutation mutation : speciesRoot.getMutations(false)) { 126 | if (mutation.getTemplate()[0].equals(species)) { 127 | if (!mutation.isSecret() || AddonForestry.showSecret) { 128 | arecipes.add(new CachedBreedingRecipe(mutation)); 129 | } 130 | } 131 | } 132 | } 133 | 134 | @Override 135 | public void loadUsageRecipes(ItemStack ingredient) { 136 | if (!speciesRoot.isMember(ingredient)) { 137 | return; 138 | } 139 | IIndividual individual = speciesRoot.getMember(ingredient); 140 | if (individual == null) { 141 | AddonForestry.instance.logWarning("IIndividual is null searching recipe for %s", ingredient.toString()); 142 | return; 143 | } 144 | if (individual.getGenome() == null) { 145 | AddonForestry.instance.logWarning("Genome is null when searching recipe for %s", ingredient.toString()); 146 | return; 147 | } 148 | if (individual.getGenome().getPrimary() == null) { 149 | AddonForestry.instance.logWarning("Species is null when searching recipe for %s", ingredient.toString()); 150 | return; 151 | } 152 | IAlleleSpecies species = individual.getGenome().getPrimary(); 153 | 154 | for (IMutation mutation : speciesRoot.getMutations(false)) { 155 | if (mutation.getAllele0().equals(species) || mutation.getAllele1().equals(species)) { 156 | if (!mutation.isSecret() || AddonForestry.showSecret) { 157 | arecipes.add(new CachedBreedingRecipe(mutation)); 158 | } 159 | } 160 | } 161 | } 162 | 163 | @Override 164 | public void loadTransferRects() { 165 | transferRects.add(new RecipeTransferRect(new Rectangle(49, 26, 15, 15), getRecipeIdent())); 166 | transferRects.add(new RecipeTransferRect(new Rectangle(98, 26, 21, 18), getRecipeIdent())); 167 | } 168 | 169 | @Override 170 | public void drawExtras(int recipe) { 171 | CachedBreedingRecipe rec = (CachedBreedingRecipe) arecipes.get(recipe); 172 | rec.result.drawLabel(); 173 | rec.parrent1.drawLabel(); 174 | rec.parrent2.drawLabel(); 175 | if (rec.derp) { 176 | Utils.drawCenteredString(EnumChatFormatting.OBFUSCATED + "DERP", 108, 15, 0xFF0000); 177 | } else if (rec.requirements.size() > 0 && AddonForestry.showReqs) { 178 | Utils.drawCenteredString(String.format("[%.0f%%]", rec.chance), 108, 15, 0xFF0000); 179 | } else { 180 | Utils.drawCenteredString(String.format("%.0f%%", rec.chance), 108, 15, 0xFFFFFF); 181 | } 182 | } 183 | 184 | public abstract String getRecipeIdent(); 185 | 186 | @Override 187 | public String getGuiTexture() { 188 | return "neiaddons:textures/gui/breeding.png"; 189 | } 190 | 191 | @Override 192 | public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) { 193 | CachedBreedingRecipe rec = (CachedBreedingRecipe) arecipes.get(recipe); 194 | if (AddonForestry.showReqs && rec.requirements.size() > 0 && GuiContainerManager.shouldShowTooltip(gui) && currenttip.size() == 0) { 195 | Point offset = gui.getRecipePosition(recipe); 196 | Point pos = GuiDraw.getMousePosition(); 197 | Point relMouse = new Point(pos.x - gui.guiLeft - offset.x, pos.y - gui.guiTop - offset.y); 198 | Rectangle tiprect = new Rectangle(108 - 24, 15 - 2, 48, 12); 199 | if (tiprect.contains(relMouse)) { 200 | currenttip.addAll(rec.requirements); 201 | return currenttip; 202 | } 203 | } 204 | return super.handleTooltip(gui, currenttip, recipe); 205 | } 206 | 207 | @Override 208 | public final String getRecipeName() { 209 | return I18n.format("bdew.neiaddons.breeding." + getRecipeIdent()); 210 | } 211 | } 212 | --------------------------------------------------------------------------------