diff --git a/src/main/java/magicbees/main/Config.java b/src/main/java/magicbees/main/Config.java index 9f8e059..94b96eb 100644 --- a/src/main/java/magicbees/main/Config.java +++ b/src/main/java/magicbees/main/Config.java @@ -152,6 +152,8 @@ public class Config public static Block tcLog; public static Block tcLeaf; public static Block tcWarded; + public static Block tcWooden; + public static Block tcMetal; //----- Thaumcraft Items ----------------------------------- public static Item tcFilledJar; public static Item tcMiscResource; diff --git a/src/main/java/magicbees/main/utils/CraftingManager.java b/src/main/java/magicbees/main/utils/CraftingManager.java index f354b99..aec19fd 100644 --- a/src/main/java/magicbees/main/utils/CraftingManager.java +++ b/src/main/java/magicbees/main/utils/CraftingManager.java @@ -1,6 +1,5 @@ package magicbees.main.utils; -import cpw.mods.fml.common.registry.GameRegistry; import magicbees.item.ItemCapsule; import magicbees.item.types.CombType; import magicbees.item.types.DropType; @@ -23,6 +22,7 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; +import cpw.mods.fml.common.registry.GameRegistry; import forestry.api.recipes.RecipeManagers; public class CraftingManager @@ -379,13 +379,13 @@ public class CraftingManager }); } - // TODO: Finalize recipe. output = new ItemStack(Config.visAuraProvider); GameRegistry.addRecipe(output, new Object[] { - " p ", "igi", "iii", - 'p', Config.pollen.getStackForType(PollenType.UNUSUAL), - 'i', Items.iron_ingot, - 'g', Blocks.glass + "ngn", "gvg", "npn", + 'n', Items.gold_nugget, + 'g', new ItemStack(Config.tcWooden, 1, ThaumcraftHelper.WoodenDeviceType.PLANKS_GREATWOOD.ordinal()), + 'v', new ItemStack(Config.tcMetal, 1, ThaumcraftHelper.MetalDeviceType.VIS_RELAY.ordinal()), + 'p', Config.pollen.getStackForType(PollenType.UNUSUAL) }); } diff --git a/src/main/java/magicbees/main/utils/compat/ThaumcraftHelper.java b/src/main/java/magicbees/main/utils/compat/ThaumcraftHelper.java index 86885ae..3dd321a 100644 --- a/src/main/java/magicbees/main/utils/compat/ThaumcraftHelper.java +++ b/src/main/java/magicbees/main/utils/compat/ThaumcraftHelper.java @@ -31,10 +31,8 @@ import thaumcraft.api.research.ResearchPage; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; -public class ThaumcraftHelper -{ - public enum MiscResource - { +public class ThaumcraftHelper { + public enum MiscResource { ALUMENTUM, NITOR, THAUMIUM, @@ -45,92 +43,119 @@ public class ThaumcraftHelper ENCHANTED_FABRIC, FLUX_FILTER, KNOWLEDGE_FRAGMENT, - MIRRORED_GLASS,; + MIRRORED_GLASS, + ; } - public enum NuggetType - { + public enum NuggetType { IRON, COPPER, TIN, SILVER, LEAD, QUICKSILVER, - THAUMIUM, _7, _8, _9, _10, _11, _12, _13, _14, _15, + THAUMIUM, + _7, _8, _9, _10, _11, _12, _13, _14, _15, NATIVE_IRON, NATIVE_COPPER, NATIVE_TIN, NATIVE_SILVER, - NATIVE_LEAD, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, - NATIVE_GOLD,; + NATIVE_LEAD, + _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, + NATIVE_GOLD, + ; } - public enum ShardType - { + public enum ShardType { AIR, FIRE, WATER, EARTH, ORDER, - CHAOS,; + CHAOS, + BALANCED, + ; } - public enum Entity - { + public enum MetalDeviceType { + CRUCIBLE, + ALEMBIC, + VIS_CHARGE_RELAY, + ADVANCED_ALCHEMICAL_CONSTRUCT, + _4, + ITEM_GRATE, + _6, + ARCANE_LAMP, + LAMP_OF_GROWTH, + ALCHEMICAL_CONSTRUCT, + THAUMATORIUM, + _11, + MNEMONIC_MATRIX, + LAMP_OF_FERTILITY, + VIS_RELAY, + ; + } + + public enum WoodenDeviceType { + BELLOWS, + EAR, + PRESSURE_PLATE, + BORE_BASE, + BORE, + PLANKS_GREATWOOD, + PLANKS_SILVERWOOD, + BANNER, + ; + } + + public enum Entity { BRAINY_ZOMBIE("entBrainyZombie", "EntityBrainyZombie"), GIANT_BRAINY_ZOMBIE("entGiantBrainyZombie", "EntityGiantBrainyZombie"), WISP("entWisp", "EntityWisp"), - FIREBAT("entFirebat", "EntityFireBat"),; + FIREBAT("entFirebat", "EntityFireBat"), + ; private static String packageName = "thaumcraft.common.entities.monster."; public String entityID; private String className; - private Entity(String id, String clazz) - { + private Entity(String id, String clazz) { this.entityID = id; this.className = clazz; } - public String getClassName() - { + public String getClassName() { return packageName + this.className; } } - public enum BlockPlant - { + public enum BlockPlant { GREATWOOD_SAPLING, SILVERWOOD_SAPLING, SHIMMERLEAF, CINDERPEARL, - PURIFYING_PLANT,; + PURIFYING_PLANT, + ; } - public enum TreeType - { + public enum TreeType { GREATWOOD, - SILVERWOOD,; + SILVERWOOD, + ; } - public static final String Name = "Thaumcraft"; private static boolean isThaumcraftPresent = false; - public static boolean isActive() - { + public static boolean isActive() { return isThaumcraftPresent; } - public static void preInit() - { - if (Loader.isModLoaded(Name) && Config.thaumcraftActive) - { + public static void preInit() { + if (Loader.isModLoaded(Name) && Config.thaumcraftActive) { isThaumcraftPresent = true; - } - else - { + } else { // Switch off TC-dependant items. ResourceType.LORE_FRAGMENT.setHidden(); ResourceType.TC_DUST_AIR.setHidden(); @@ -142,23 +167,22 @@ public class ThaumcraftHelper } } - public static void init() - { - //if (isActive()) { } + public static void init() { + // if (isActive()) { } } - public static void postInit() - { - if (isActive()) - { + public static void postInit() { + if (isActive()) { // Apparently the Game Registry isn't populated until now. ): getBlocks(); getItems(); - aspectTime = new Aspect("tempus", 0xB68CFF, new Aspect[] { Aspect.VOID, Aspect.ORDER }, - new ResourceLocation(CommonProxy.DOMAIN, CommonProxy.TEXTURE + "aspects/tempus.png"), 1); + aspectTime = new Aspect("tempus", 0xB68CFF, new Aspect[] { + Aspect.VOID, Aspect.ORDER }, new ResourceLocation( + CommonProxy.DOMAIN, CommonProxy.TEXTURE + + "aspects/tempus.png"), 1); - //addItemsToBackpack(); + // addItemsToBackpack(); setupItemAspects(); setupCrafting(); setupResearch(); @@ -167,8 +191,7 @@ public class ThaumcraftHelper private static Object aspectTime; - private static void getBlocks() - { + private static void getBlocks() { Config.tcPlant = BlockInterface.getBlock(Name, "blockCustomPlant"); Config.tcCandle = BlockInterface.getBlock(Name, "blockCandle"); Config.tcCrystal = BlockInterface.getBlock(Name, "blockCrystal"); @@ -177,69 +200,36 @@ public class ThaumcraftHelper Config.tcLog = BlockInterface.getBlock(Name, "blockMagicalLog"); Config.tcLeaf = BlockInterface.getBlock(Name, "blockMagicalLeaves"); Config.tcWarded = BlockInterface.getBlock(Name, "blockWarded"); + Config.tcWooden = BlockInterface.getBlock(Name, "blockWoodenDevice"); + Config.tcMetal = BlockInterface.getBlock(Name, "blockMetalDevice"); } - private static void getItems() - { + private static void getItems() { Config.tcFilledJar = ItemInterface.getItem(Name, "BlockJarFilledItem"); Config.tcMiscResource = ItemInterface.getItem(Name, "ItemResource"); - //Config.tcEssentiaBottle = ItemInterface.getItem(Name, "BlockJarFilledItem"); + // Config.tcEssentiaBottle = ItemInterface.getItem(Name, + // "BlockJarFilledItem"); Config.tcShard = ItemInterface.getItem(Name, "ItemShard"); Config.tcGolem = ItemInterface.getItem(Name, "ItemGolemPlacer"); - //Config.tcWispEssence = ItemApi.getItem("itemWispEssence", 0).getItem(); + // Config.tcWispEssence = ItemApi.getItem("itemWispEssence", + // 0).getItem(); Config.tcNuggets = ItemInterface.getItem(Name, "ItemNugget"); Config.tcShard = ItemInterface.getItem(Name, "ItemShard"); - Config.tcNuggetChicken = ItemInterface.getItem(Name, "ItemNuggetChicken"); + Config.tcNuggetChicken = ItemInterface.getItem(Name, + "ItemNuggetChicken"); Config.tcNuggetBeef = ItemInterface.getItem(Name, "ItemNuggetBeef"); Config.tcNuggetPork = ItemInterface.getItem(Name, "ItemNuggetPork"); } - private static void addItemsToBackpack() - { -// if (Config.addThaumcraftItemsToBackpacks) -// { -// // Add all shards and Thaumium to miner's backpack -// String ids = Config.tcShard.itemID + ":" + -1 + ";" -// + Config.tcMiscResource.itemID + ":" + ThaumcraftHelper.MiscResource.THAUMIUM.ordinal(); -// FMLInterModComms.sendMessage("Forestry", "add-backpack-items", "miner@" + ids); -// -// // All resources go into Thaumaturge's backpack -// ids = Config.tcMiscResource.itemID + ":" + -1 + ";" -// + Config.tcShard.itemID + ":" + -1 + ";" -// + Config.tcFilledJar.itemID + ":" + -1 + ";" -// + Config.tcCrystal.blockID + ":" + -1 + ";" -// + Config.tcJar.blockID + ":" + -1 + ";" -// + Config.tcGolem.itemID + ":" + -1 + ";"; -// FMLInterModComms.sendMessage("Forestry", "add-backpack-items", "thaumaturge@" + ids); -// -// // Add some plants & saplings to Forester's -// ids = Config.tcPlant.blockID + ":" + "-1" + ";" -// + Config.tcLeaf.blockID + ":" + -1 + ";" -// + Config.tcLog.blockID + ":" + "-1"; -// FMLInterModComms.sendMessage("Forestry", "add-backpack-items", "forester@" + ids); -// -// // Add Wisp & brains to Hunter's -// ids = /*Config.tcWispEssence.itemID + ":" + -1 + ";" -// +*/ Config.tcMiscResource.itemID + ":" + ThaumcraftHelper.MiscResource.ZOMBIE_BRAIN.ordinal(); -// FMLInterModComms.sendMessage("Forestry", "add-backpack-items", "hunter@" + ids); -// -// // Add Marker, warded stone, candle to builder -// ids = Config.tcCandle.blockID + ":" + -1 + ";" -// + Config.tcMarker.blockID + ":" + -1 + ";" -// + Config.tcWarded.blockID + ":" + -1; -// FMLInterModComms.sendMessage("Forestry", "add-backpack-items", "builder@" + ids); -// } - } - - private static void setupCrafting() - { + private static void setupCrafting() { ItemStack input, output; input = Config.miscResources.getStackForType(ResourceType.TC_DUST_AIR); output = new ItemStack(Config.tcShard, 1, ShardType.AIR.ordinal()); GameRegistry.addShapelessRecipe(output, input, input, input, input); - input = Config.miscResources.getStackForType(ResourceType.TC_DUST_WATER); + input = Config.miscResources + .getStackForType(ResourceType.TC_DUST_WATER); output = new ItemStack(Config.tcShard, 1, ShardType.WATER.ordinal()); GameRegistry.addShapelessRecipe(output, input, input, input, input); @@ -247,77 +237,138 @@ public class ThaumcraftHelper output = new ItemStack(Config.tcShard, 1, ShardType.FIRE.ordinal()); GameRegistry.addShapelessRecipe(output, input, input, input, input); - input = Config.miscResources.getStackForType(ResourceType.TC_DUST_EARTH); + input = Config.miscResources + .getStackForType(ResourceType.TC_DUST_EARTH); output = new ItemStack(Config.tcShard, 1, ShardType.EARTH.ordinal()); GameRegistry.addShapelessRecipe(output, input, input, input, input); - input = Config.miscResources.getStackForType(ResourceType.TC_DUST_ORDER); + input = Config.miscResources + .getStackForType(ResourceType.TC_DUST_ORDER); output = new ItemStack(Config.tcShard, 1, ShardType.ORDER.ordinal()); GameRegistry.addShapelessRecipe(output, input, input, input, input); - input = Config.miscResources.getStackForType(ResourceType.TC_DUST_CHAOS); + input = Config.miscResources + .getStackForType(ResourceType.TC_DUST_CHAOS); output = new ItemStack(Config.tcShard, 1, ShardType.CHAOS.ordinal()); GameRegistry.addShapelessRecipe(output, input, input, input, input); - thaumScoop = ThaumcraftApi.addArcaneCraftingRecipe("MB_Scoop", new ItemStack(Config.thaumiumScoop), + thaumScoop = ThaumcraftApi.addArcaneCraftingRecipe("MB_Scoop", + new ItemStack(Config.thaumiumScoop), new AspectList().add(Aspect.ORDER, 2), new Object[] { - "sWs", "sTs", " T ", - 's', Items.stick, - 'W', Blocks.wool, - 'T', new ItemStack(Config.tcMiscResource, 1, MiscResource.THAUMIUM.ordinal()) - }); + "sWs", + "sTs", + " T ", + 's', + Items.stick, + 'W', + Blocks.wool, + 'T', + new ItemStack(Config.tcMiscResource, 1, + MiscResource.THAUMIUM.ordinal()) }); - thaumGrafter = ThaumcraftApi.addArcaneCraftingRecipe("MB_Grafter", new ItemStack(Config.thaumiumGrafter), + thaumGrafter = ThaumcraftApi.addArcaneCraftingRecipe("MB_Grafter", + new ItemStack(Config.thaumiumGrafter), new AspectList().add(Aspect.ORDER, 5), new Object[] { - " T", " s ", "s ", - 's', Items.stick, - 'T', new ItemStack(Config.tcMiscResource, 1, MiscResource.THAUMIUM.ordinal()) - }); + " T", + " s ", + "s ", + 's', + Items.stick, + 'T', + new ItemStack(Config.tcMiscResource, 1, + MiscResource.THAUMIUM.ordinal()) }); - frameMagic = ThaumcraftApi.addArcaneCraftingRecipe("MB_FrameMagic", new ItemStack(Config.hiveFrameMagic), - new AspectList().add(Aspect.ORDER, 5).add(Aspect.AIR, 2).add(Aspect.EARTH, 2), new Object[] { - "sss", "sCs", "sss", - 's', Items.stick, - 'C', new ItemStack(Config.tcMiscResource, 1, MiscResource.ENCHANTED_FABRIC.ordinal()) - }); + frameMagic = ThaumcraftApi.addArcaneCraftingRecipe( + "MB_FrameMagic", + new ItemStack(Config.hiveFrameMagic), + new AspectList().add(Aspect.ORDER, 5).add(Aspect.AIR, 2) + .add(Aspect.EARTH, 2), new Object[] { + "sss", + "sCs", + "sss", + 's', + Items.stick, + 'C', + new ItemStack(Config.tcMiscResource, 1, + MiscResource.ENCHANTED_FABRIC.ordinal()) }); - essenceLife = ThaumcraftApi.addCrucibleRecipe("MB_EssenceLife", Config.miscResources.getStackForType(ResourceType.ESSENCE_FALSE_LIFE), - new ItemStack(Blocks.red_flower), new AspectList().add(Aspect.EXCHANGE, 4).add(Aspect.PLANT, 4)); + essenceLife = ThaumcraftApi.addCrucibleRecipe("MB_EssenceLife", + Config.miscResources + .getStackForType(ResourceType.ESSENCE_FALSE_LIFE), + new ItemStack(Blocks.red_flower), + new AspectList().add(Aspect.EXCHANGE, 4).add(Aspect.PLANT, 4)); - essenceDeath = ThaumcraftApi.addCrucibleRecipe("MB_EssenceDeath", Config.miscResources.getStackForType(ResourceType.ESSENCE_SHALLOW_GRAVE), - new ItemStack(Items.rotten_flesh), new AspectList().add(Aspect.DEATH, 4).add(Aspect.ENTROPY, 4)); + essenceDeath = ThaumcraftApi.addCrucibleRecipe("MB_EssenceDeath", + Config.miscResources + .getStackForType(ResourceType.ESSENCE_SHALLOW_GRAVE), + new ItemStack(Items.rotten_flesh), + new AspectList().add(Aspect.DEATH, 4).add(Aspect.ENTROPY, 4)); - essenceArmor = ThaumcraftApi.addCrucibleRecipe("MB_EssenceArmor", Config.miscResources.getStackForType(ResourceType.ESSENCE_EVERLASTING_DURABILITY), - new ItemStack(Items.leather), new AspectList().add(Aspect.ARMOR, 4).add(Aspect.MAGIC, 2)); + essenceArmor = ThaumcraftApi + .addCrucibleRecipe( + "MB_EssenceArmor", + Config.miscResources + .getStackForType(ResourceType.ESSENCE_EVERLASTING_DURABILITY), + new ItemStack(Items.leather), + new AspectList().add(Aspect.ARMOR, 4).add(Aspect.MAGIC, + 2)); - output = Config.miscResources.getStackForType(ResourceType.ESSENCE_FICKLE_PERMANENCE); - essenceUnstableA = ThaumcraftApi.addCrucibleRecipe("MB_EssenceUnstable", output, - Config.propolis.getStackForType(PropolisType.UNSTABLE), new AspectList().add(Aspect.ENTROPY, 2).add(Aspect.EXCHANGE, 1)); + output = Config.miscResources + .getStackForType(ResourceType.ESSENCE_FICKLE_PERMANENCE); + essenceUnstableA = ThaumcraftApi + .addCrucibleRecipe( + "MB_EssenceUnstable", + output, + Config.propolis.getStackForType(PropolisType.UNSTABLE), + new AspectList().add(Aspect.ENTROPY, 2).add( + Aspect.EXCHANGE, 1)); - essenceUnstableB = ThaumcraftApi.addCrucibleRecipe("MB_EssenceUnstable", output, - new ItemStack(Blocks.netherrack), new AspectList().add(Aspect.ENTROPY, 8).add(Aspect.EXCHANGE, 5)); + essenceUnstableB = ThaumcraftApi + .addCrucibleRecipe( + "MB_EssenceUnstable", + output, + new ItemStack(Blocks.netherrack), + new AspectList().add(Aspect.ENTROPY, 8).add( + Aspect.EXCHANGE, 5)); - essenceTime = ThaumcraftApi.addCrucibleRecipe("MB_EssenceTime", Config.miscResources.getStackForType(ResourceType.ESSENCE_LOST_TIME), - new ItemStack(Items.clock), new AspectList().add(Aspect.ORDER, 10).add(Aspect.VOID, - 10).add(Aspect.TRAP, 4)); + essenceTime = ThaumcraftApi.addCrucibleRecipe("MB_EssenceTime", + Config.miscResources + .getStackForType(ResourceType.ESSENCE_LOST_TIME), + new ItemStack(Items.clock), + new AspectList().add(Aspect.ORDER, 10).add(Aspect.VOID, 10) + .add(Aspect.TRAP, 4)); input = new ItemStack(Items.ender_pearl); - singularityA = ThaumcraftApi.addInfusionCraftingRecipe("MB_DimensionalSingularity", Config.miscResources.getStackForType(ResourceType.DIMENSIONAL_SINGULARITY, 3), - 5, new AspectList().add(Aspect.ELDRITCH, 10).add(Aspect.EXCHANGE, 20), - new ItemStack(Blocks.gold_block), - new ItemStack[] { input, input }); + singularityA = ThaumcraftApi.addInfusionCraftingRecipe( + "MB_DimensionalSingularity", Config.miscResources + .getStackForType(ResourceType.DIMENSIONAL_SINGULARITY, + 3), 5, new AspectList() + .add(Aspect.ELDRITCH, 10).add(Aspect.EXCHANGE, 20), + new ItemStack(Blocks.gold_block), new ItemStack[] { input, + input }); ItemStack in2 = new ItemStack(Items.diamond); - singularityB = ThaumcraftApi.addInfusionCraftingRecipe("MB_DimensionalSingularity", Config.miscResources.getStackForType(ResourceType.DIMENSIONAL_SINGULARITY, 3), - 6, new AspectList().add(Aspect.ELDRITCH, 10).add(Aspect.EXCHANGE, 20).add(Aspect.VOID, 15), + singularityB = ThaumcraftApi.addInfusionCraftingRecipe( + "MB_DimensionalSingularity", + Config.miscResources.getStackForType( + ResourceType.DIMENSIONAL_SINGULARITY, 3), + 6, + new AspectList().add(Aspect.ELDRITCH, 10) + .add(Aspect.EXCHANGE, 20).add(Aspect.VOID, 15), Config.propolis.getStackForType(PropolisType.UNSTABLE), new ItemStack[] { input, input, in2 }); - essenceOblivion = ThaumcraftApi.addShapelessArcaneCraftingRecipe("MB_EssenceOblivion", Config.miscResources.getStackForType(ResourceType.ESSENCE_SCORNFUL_OBLIVION), - new AspectList().add(Aspect.ENTROPY, 25).add(Aspect.AIR, 40).add(Aspect.ORDER, 15), new Object[] { - Config.miscResources.getStackForType(ResourceType.DIMENSIONAL_SINGULARITY), - Blocks.dragon_egg, - }); + essenceOblivion = ThaumcraftApi + .addShapelessArcaneCraftingRecipe( + "MB_EssenceOblivion", + Config.miscResources + .getStackForType(ResourceType.ESSENCE_SCORNFUL_OBLIVION), + new AspectList().add(Aspect.ENTROPY, 25) + .add(Aspect.AIR, 40).add(Aspect.ORDER, 15), + new Object[] { + Config.miscResources + .getStackForType(ResourceType.DIMENSIONAL_SINGULARITY), + Blocks.dragon_egg, }); } private static Object frameMagic; @@ -333,57 +384,60 @@ public class ThaumcraftHelper private static Object essenceTime; private static Object essenceOblivion; - private static void setupResearch() - { + private static void setupResearch() { ArrayList list; ItemStack input; IRecipe recipe; String category = "MAGICBEES"; - ResearchCategories.registerCategory(category, new ResourceLocation(CommonProxy.DOMAIN, CommonProxy.ITEM_TEXTURE + "beeInfusion.png"), + ResearchCategories.registerCategory(category, new ResourceLocation( + CommonProxy.DOMAIN, CommonProxy.ITEM_TEXTURE + "beeInfusion.png"), new ResourceLocation("thaumcraft", "textures/gui/gui_researchback.png")); - ResearchItem rootNodeR = new ResearchItem("MB_Root", category, new AspectList(), + ResearchItem rootNodeR = new ResearchItem("MB_Root", category, + new AspectList(), 0, 0, 0, Config.miscResources.getStackForType(ResourceType.RESEARCH_BEEINFUSION)) - .setRound().setStub().setAutoUnlock() - .setPages(getResearchPage("MB_Root.1"), getResearchPage("MB_Root.2")) - .registerResearchItem(); + .setRound() + .setStub() + .setAutoUnlock() + .setPages(getResearchPage("MB_Root.1"), getResearchPage("MB_Root.2")).registerResearchItem(); list = new ArrayList(4); list.add(Config.miscResources.getStackForType(ResourceType.LORE_FRAGMENT)); list.add(Config.miscResources.getStackForType(ResourceType.LORE_FRAGMENT)); list.add(Config.miscResources.getStackForType(ResourceType.LORE_FRAGMENT)); list.add(Config.miscResources.getStackForType(ResourceType.LORE_FRAGMENT)); - recipe = new ShapelessRecipes(new ItemStack(Config.tcMiscResource, 1, MiscResource.KNOWLEDGE_FRAGMENT.ordinal()), list); + recipe = new ShapelessRecipes(new ItemStack(Config.tcMiscResource, 1, + MiscResource.KNOWLEDGE_FRAGMENT.ordinal()), list); - ResearchItem researchFragment = new ResearchItem("MB_LoreFragment", category, new AspectList(), + ResearchItem researchFragment = new ResearchItem("MB_LoreFragment", category, + new AspectList(), 0, -3, 0, Config.miscResources.getStackForType(ResourceType.LORE_FRAGMENT)) - .setPages(getResearchPage("MB_LoreFragment.1"), new ResearchPage(recipe)) - .setParents("MB_Root") - .setStub().setAutoUnlock().setRound() - .registerResearchItem(); + .setPages(getResearchPage("MB_LoreFragment.1"), new ResearchPage(recipe)).setParents("MB_Root") + .setStub().setAutoUnlock().setRound().registerResearchItem(); - ResearchItem thaumiumScoopR = new ResearchItem("MB_Scoop", category, new AspectList().add(Aspect.TOOL, 1).add(Aspect.MAGIC, 1).add(Aspect.AIR, 1), + ResearchItem thaumiumScoopR = new ResearchItem("MB_Scoop", category, + new AspectList().add(Aspect.TOOL, 1).add(Aspect.MAGIC, 1).add(Aspect.AIR, 1), -2, -3, 1, new ItemStack(Config.thaumiumScoop)) - .setPages(getResearchPage("MB_Scoop.1"), new ResearchPage((IArcaneRecipe)thaumScoop)) - .setParentsHidden("THAUMIUM") - .registerResearchItem(); + .setPages(getResearchPage("MB_Scoop.1"), new ResearchPage((IArcaneRecipe) thaumScoop)) + .setParentsHidden("THAUMIUM").registerResearchItem(); - ResearchItem thaumiumGrafterR = new ResearchItem("MB_Grafter", category, new AspectList().add(Aspect.TOOL, 2).add(Aspect.TREE, 1).add(Aspect.GREED, 1), + ResearchItem thaumiumGrafterR = new ResearchItem("MB_Grafter", category, + new AspectList().add(Aspect.TOOL, 2).add(Aspect.TREE, 1).add(Aspect.GREED, 1), -2, -1, 4, new ItemStack(Config.thaumiumGrafter)) - .setPages(getResearchPage("MB_Grafter.1"), new ResearchPage((IArcaneRecipe)thaumGrafter)) - .setParents("MB_Scoop") - .registerResearchItem(); + .setPages(getResearchPage("MB_Grafter.1"), new ResearchPage((IArcaneRecipe) thaumGrafter)) + .setParents("MB_Scoop").registerResearchItem(); - ResearchItem frameMagicR = new ResearchItem("MB_FrameMagic", category, new AspectList().add(Aspect.TOOL, 2).add(Aspect.ARMOR, 1), + ResearchItem frameMagicR = new ResearchItem("MB_FrameMagic", category, + new AspectList().add(Aspect.TOOL, 2).add(Aspect.ARMOR, 1), -2, 1, 2, new ItemStack(Config.hiveFrameMagic)) - .setPages(getResearchPage("MB_FrameMagic"), new ResearchPage((IArcaneRecipe)frameMagic)) - .registerResearchItem(); + .setPages(getResearchPage("MB_FrameMagic"), new ResearchPage((IArcaneRecipe) frameMagic)) + .registerResearchItem(); input = new ItemStack(Config.hiveFrameMagic); list = new ArrayList(2); @@ -391,125 +445,123 @@ public class ThaumcraftHelper list.add(input); recipe = new ShapelessRecipes(new ItemStack(Config.hiveFrameGentle), list); - ResearchItem essenceFalseLifeR = new ResearchItem("MB_EssenceLife", category, new AspectList().add(Aspect.LIFE, 2).add(Aspect.MAGIC, 1), + ResearchItem essenceFalseLifeR = new ResearchItem("MB_EssenceLife", category, + new AspectList().add(Aspect.LIFE, 2).add(Aspect.MAGIC, 1), 2, -1, 2, Config.miscResources.getStackForType(ResourceType.ESSENCE_FALSE_LIFE)) - .setPages(getResearchPage("MB_EssenceLife.1"), new ResearchPage((CrucibleRecipe)essenceLife), new ResearchPage(recipe)) - .setParentsHidden("CRUCIBLE") - .registerResearchItem(); + .setPages(getResearchPage("MB_EssenceLife.1"), + new ResearchPage((CrucibleRecipe) essenceLife), + new ResearchPage(recipe)).setParentsHidden("CRUCIBLE") + .registerResearchItem(); list = new ArrayList(2); list.add(Config.miscResources.getStackForType(ResourceType.ESSENCE_EVERLASTING_DURABILITY)); list.add(input); recipe = new ShapelessRecipes(new ItemStack(Config.hiveFrameResilient), list); - ResearchItem essenceDurabilityR = new ResearchItem("MB_EssenceArmor", category, new AspectList().add(Aspect.ARMOR, 1).add(Aspect.MAGIC, 1), + ResearchItem essenceDurabilityR = new ResearchItem("MB_EssenceArmor", category, + new AspectList().add(Aspect.ARMOR, 1).add(Aspect.MAGIC, 1), 5, 0, 3, Config.miscResources.getStackForType(ResourceType.ESSENCE_EVERLASTING_DURABILITY)) - .setPages(getResearchPage("MB_EssenceArmor.1"), new ResearchPage((CrucibleRecipe)essenceArmor), new ResearchPage(recipe)) - .setParents("MB_EssenceLife") - .registerResearchItem(); + .setPages(getResearchPage("MB_EssenceArmor.1"), + new ResearchPage((CrucibleRecipe) essenceArmor), + new ResearchPage(recipe)).setParents("MB_EssenceLife") + .registerResearchItem(); list = new ArrayList(2); - list.add(Config.miscResources.getStackForType(ResourceType.ESSENCE_FICKLE_PERMANENCE)); + list.add(Config.miscResources .getStackForType(ResourceType.ESSENCE_FICKLE_PERMANENCE)); list.add(input); recipe = new ShapelessRecipes(new ItemStack(Config.hiveFrameMetabolic), list); - ResearchItem essenceUnstableR = new ResearchItem("MB_EssenceUnstable", category, new AspectList().add(Aspect.ENTROPY, 2).add(Aspect.ORDER, 1), + ResearchItem essenceUnstableR = new ResearchItem( "MB_EssenceUnstable", category, + new AspectList().add(Aspect.ENTROPY, 2).add(Aspect.ORDER, 1), 3, 1, 4, Config.miscResources.getStackForType(ResourceType.ESSENCE_FICKLE_PERMANENCE)) - .setPages(getResearchPage("MB_EssenceUnstable.1"), new ResearchPage((CrucibleRecipe)essenceUnstableA), - new ResearchPage((CrucibleRecipe)essenceUnstableB), new ResearchPage(recipe)) - .setParents("MB_EssenceLife") - .setConcealed() - .registerResearchItem(); + .setPages(getResearchPage("MB_EssenceUnstable.1"), + new ResearchPage((CrucibleRecipe) essenceUnstableA), + new ResearchPage((CrucibleRecipe) essenceUnstableB), + new ResearchPage(recipe)).setParents("MB_EssenceLife") + .setConcealed().registerResearchItem(); list = new ArrayList(2); - list.add(Config.miscResources.getStackForType(ResourceType.ESSENCE_SHALLOW_GRAVE)); + list.add(Config.miscResources .getStackForType(ResourceType.ESSENCE_SHALLOW_GRAVE)); list.add(input); recipe = new ShapelessRecipes(new ItemStack(Config.hiveFrameNecrotic), list); - ResearchItem essenceShallowGraveR = new ResearchItem("MB_EssenceDeath", category, new AspectList().add(Aspect.DEATH, 2).add(Aspect.MAGIC, 1), + ResearchItem essenceShallowGraveR = new ResearchItem("MB_EssenceDeath", category, + new AspectList().add(Aspect.DEATH, 2).add(Aspect.MAGIC, 1), 2, 3, 2, - Config.miscResources.getStackForType(ResourceType.ESSENCE_SHALLOW_GRAVE)) - .setPages(getResearchPage("MB_EssenceDeath.1"), new ResearchPage((CrucibleRecipe)essenceDeath), new ResearchPage(recipe)) - .setParents("MB_EssenceUnstable") - .setConcealed() - .registerResearchItem(); + Config.miscResources .getStackForType(ResourceType.ESSENCE_SHALLOW_GRAVE)) + .setPages(getResearchPage("MB_EssenceDeath.1"), + new ResearchPage((CrucibleRecipe) essenceDeath), + new ResearchPage(recipe)) + .setParents("MB_EssenceUnstable").setConcealed() + .registerResearchItem(); list = new ArrayList(2); list.add(Config.miscResources.getStackForType(ResourceType.ESSENCE_LOST_TIME)); list.add(input); recipe = new ShapelessRecipes(new ItemStack(Config.hiveFrameTemporal), list); - ResearchItem essenceTimeR = new ResearchItem("MB_EssenceTime", category, new AspectList().add((Aspect)aspectTime, 2).add(Aspect.MAGIC, 1), + ResearchItem essenceTimeR = new ResearchItem("MB_EssenceTime", category, + new AspectList().add((Aspect) aspectTime, 2).add(Aspect.MAGIC, 1), 0, 2, 5, Config.miscResources.getStackForType(ResourceType.ESSENCE_LOST_TIME)) - .setPages(getResearchPage("MB_EssenceTime.1"), new ResearchPage((CrucibleRecipe)essenceTime), new ResearchPage(recipe)) - .setParents("MB_EssenceUnstable") - .setConcealed() - .registerResearchItem(); + .setPages(getResearchPage("MB_EssenceTime.1"), + new ResearchPage((CrucibleRecipe) essenceTime), + new ResearchPage(recipe)) + .setParents("MB_EssenceUnstable").setConcealed() + .registerResearchItem(); - ResearchItem singularityR = new ResearchItem("MB_DimensionalSingularity", category, new AspectList().add(Aspect.ELDRITCH, 2).add((Aspect)aspectTime, 1).add(Aspect.VOID, 1), + ResearchItem singularityR = new ResearchItem("MB_DimensionalSingularity", category, + new AspectList().add(Aspect.ELDRITCH, 2).add((Aspect) aspectTime, 1).add(Aspect.VOID, 1), -1, 4, 5, Config.miscResources.getStackForType(ResourceType.DIMENSIONAL_SINGULARITY)) - .setPages(getResearchPage("MB_DimensionalSingularity.1"), new ResearchPage((InfusionRecipe)singularityA), new ResearchPage((InfusionRecipe)singularityB)) - .setParents("MB_FrameMagic", "MB_EssenceTime", "MB_EssenceDeath") - .setConcealed() - .setSpecial() - .registerResearchItem(); + .setPages(getResearchPage("MB_DimensionalSingularity.1"), + new ResearchPage((InfusionRecipe) singularityA), + new ResearchPage((InfusionRecipe) singularityB)) + .setParents("MB_FrameMagic", "MB_EssenceTime", "MB_EssenceDeath").setConcealed().setSpecial() + .registerResearchItem(); list = new ArrayList(2); list.add(Config.miscResources.getStackForType(ResourceType.ESSENCE_SCORNFUL_OBLIVION)); list.add(ItemInterface.getItemStack("frameProven")); recipe = new ShapelessRecipes(new ItemStack(Config.hiveFrameOblivion), list); - ResearchItem essenceOblivionR = new ResearchItem("MB_EssenceOblivion", category, new AspectList().add(Aspect.VOID, 2).add(Aspect.HUNGER, 1).add((Aspect)aspectTime, 1), + ResearchItem essenceOblivionR = new ResearchItem("MB_EssenceOblivion", category, + new AspectList().add(Aspect.VOID, 2).add(Aspect.HUNGER, 1).add((Aspect) aspectTime, 1), -3, 3, 5, Config.miscResources.getStackForType(ResourceType.ESSENCE_SCORNFUL_OBLIVION)) - .setPages(getResearchPage("MB_EssenceOblivion.1"), new ResearchPage((IArcaneRecipe)essenceOblivion), new ResearchPage(recipe)) - .setParents("MB_DimensionalSingularity") - .setConcealed() - .registerResearchItem(); + .setPages(getResearchPage("MB_EssenceOblivion.1"), + new ResearchPage((IArcaneRecipe) essenceOblivion), + new ResearchPage(recipe)) + .setParents("MB_DimensionalSingularity").setConcealed() + .registerResearchItem(); } - private static ResearchPage getResearchPage(String ident) - { - // Helps get around all the stupid XML Doctype restrictions. - return new ResearchPage(LocalizationManager.getLocalizedString("tc.research_page." + ident) - .replaceAll("##lineBreak##", "
") - .replaceAll("##horizontalRule##", "") - .replaceAll("##img##", "") - .replaceAll("##/img##", "")); + private static ResearchPage getResearchPage(String ident) { + return new ResearchPage(LocalizationManager.getLocalizedString("tc.research_page." + ident)); } - private static void setupItemAspects() - { + private static void setupItemAspects() { ItemStack item; AspectList list; - ThaumcraftApi.registerObjectTag(new ItemStack(Items.clock), new AspectList(new ItemStack(Items.clock)).add( - (Aspect)aspectTime, 4)); - ThaumcraftApi.registerObjectTag(new ItemStack(Items.repeater), new AspectList(new ItemStack(Items.repeater)).add( - (Aspect)aspectTime, 2)); - + ThaumcraftApi.registerObjectTag(new ItemStack(Items.clock), new AspectList(new ItemStack(Items.clock)).add((Aspect) aspectTime, 4)); + ThaumcraftApi.registerObjectTag(new ItemStack(Items.repeater), new AspectList(new ItemStack(Items.repeater)).add((Aspect) aspectTime, 2)); list = new AspectList(new ItemStack(Blocks.log)); - for (int i = 1; i <= 8; i++) - { + for (int i = 1; i <= 8; i++) { item = ItemInterface.getItemStack("log" + i); - if (item != null) - { + if (item != null) { ThaumcraftApi.registerObjectTag(item, list); } } list = new AspectList(new ItemStack(Blocks.planks)); - for (int i = 1; i <= 2; i++) - { + for (int i = 1; i <= 2; i++) { item = ItemInterface.getItemStack("planks" + i); - if (item != null) - { + if (item != null) { ThaumcraftApi.registerObjectTag(item, list); } } @@ -543,18 +595,15 @@ public class ThaumcraftHelper item = ForestryBlock.saplingGE.getItemStack(); ThaumcraftApi.registerObjectTag(item, list); - list = new AspectList()/*.add(Aspect.SEED, 1)*/.add(Aspect.PLANT, 1); + list = new AspectList()/* .add(Aspect.SEED, 1) */.add(Aspect.PLANT, 1); item = ForestryItem.pollenFertile.getItemStack(); ThaumcraftApi.registerObjectTag(item, list); list = new AspectList().add(Aspect.CRYSTAL, 1).add(Aspect.EARTH, 2); item = ForestryItem.apatite.getItemStack(); - ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.BlockResource.APATITE.ordinal()), - list.copy()/*.add(Aspect.STONE, 2)*/); + ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1,ForestryHelper.BlockResource.APATITE.ordinal()), list.copy()); item = ForestryItem.apatite.getItemStack(); - ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, item.getItemDamage()), - list.copy().add(Aspect.CRYSTAL, 2)); - + ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, item.getItemDamage()), list.copy().add(Aspect.CRYSTAL, 2)); list = new AspectList().add(Aspect.MOTION, 2).add(Aspect.FLIGHT, 1); item = ItemInterface.getItemStack("beeDroneGE"); @@ -585,47 +634,30 @@ public class ThaumcraftHelper list = new AspectList().add(Aspect.SLIME, 1); item = ItemInterface.getItemStack("propolis"); - ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.Propolis.NORMAL.ordinal()), - list); - ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.Propolis.SILKY.ordinal()), - list.copy().add(Aspect.SLIME, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.Propolis.PULSATING.ordinal()), - list.copy().add(Aspect.ELDRITCH, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.UNSTABLE.ordinal()), - list.copy().add(Aspect.ENTROPY, 1).add(Aspect.EXCHANGE, 1)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.AIR.ordinal()), - list.copy().add(Aspect.AIR, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.WATER.ordinal()), - list.copy().add(Aspect.WATER, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.FIRE.ordinal()), - list.copy().add(Aspect.FIRE, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.EARTH.ordinal()), - list.copy().add(Aspect.EARTH, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.ORDER.ordinal()), - list.copy().add(Aspect.ORDER, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.CHAOS.ordinal()), - list.copy().add(Aspect.ENTROPY, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.Propolis.NORMAL.ordinal()), list); + ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.Propolis.SILKY.ordinal()), list.copy().add(Aspect.SLIME, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.Propolis.PULSATING.ordinal()), list.copy().add(Aspect.ELDRITCH, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.UNSTABLE.ordinal()), list.copy().add(Aspect.ENTROPY, 1).add(Aspect.EXCHANGE, 1)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.AIR.ordinal()), list.copy().add(Aspect.AIR, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.WATER.ordinal()), list.copy().add(Aspect.WATER, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.FIRE.ordinal()), list.copy().add(Aspect.FIRE, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.EARTH.ordinal()), list.copy().add(Aspect.EARTH, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.ORDER.ordinal()), list.copy().add(Aspect.ORDER, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.propolis, 1, PropolisType.CHAOS.ordinal()), list.copy().add(Aspect.ENTROPY, 2)); list = new AspectList().add(Aspect.PLANT, 2); item = ItemInterface.getItemStack("pollen"); ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.Pollen.NORMAL.ordinal()), list); - ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.Pollen.CRYSTALLINE.ordinal()), - list.copy()/*.add(Aspect.ICE, 2)*/); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.pollen, 1, PollenType.UNUSUAL.ordinal()), - list.copy().add(Aspect.MAGIC, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.pollen, 1, PollenType.PHASED.ordinal()), - list.copy().add((Aspect)aspectTime, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(item.getItem(), 1, ForestryHelper.Pollen.CRYSTALLINE.ordinal()), list.copy()); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.pollen, 1, PollenType.UNUSUAL.ordinal()), list.copy().add(Aspect.MAGIC, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.pollen, 1, PollenType.PHASED.ordinal()), list.copy().add((Aspect) aspectTime, 2)); list = new AspectList().add(Aspect.ORDER, 1); item = ItemInterface.getItemStack("beeswax"); - ThaumcraftApi.registerObjectTag(item, new int[] { item.getItemDamage() }, list.copy().add(Aspect.ORDER, - 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.wax, 1, WaxType.MAGIC.ordinal()), - list.copy().add(Aspect.MAGIC, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.wax, 1, WaxType.SOUL.ordinal()), - list.copy().add(Aspect.SOUL, 2)); - ThaumcraftApi.registerObjectTag(new ItemStack(Config.wax, 1, WaxType.AMNESIC.ordinal()), - list.copy().add(Aspect.MIND, 2)); + ThaumcraftApi.registerObjectTag(item, new int[] { item.getItemDamage() }, list.copy().add(Aspect.ORDER, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.wax, 1, WaxType.MAGIC.ordinal()), list.copy().add(Aspect.MAGIC, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.wax, 1, WaxType.SOUL.ordinal()), list.copy().add(Aspect.SOUL, 2)); + ThaumcraftApi.registerObjectTag(new ItemStack(Config.wax, 1, WaxType.AMNESIC.ordinal()), list.copy().add(Aspect.MIND, 2)); list = new AspectList().add(Aspect.EXCHANGE, 2).add(Aspect.LIFE, 2); item = ItemInterface.getItemStack("honeyDrop"); @@ -653,7 +685,6 @@ public class ThaumcraftHelper ThaumcraftApi.registerObjectTag(item, new int[] { item.getItemDamage() }, new AspectList().add(Aspect.ARMOR, 6)); item = Config.miscResources.getStackForType(ResourceType.ESSENCE_LOST_TIME); - ThaumcraftApi.registerObjectTag(item, new int[] { item.getItemDamage() }, new AspectList().add(Aspect.VOID, - 6).add((Aspect)aspectTime, 8)); + ThaumcraftApi.registerObjectTag(item, new int[] { item.getItemDamage() }, new AspectList().add(Aspect.VOID, 6).add((Aspect) aspectTime, 8)); } } diff --git a/src/main/java/magicbees/tileentity/TileEntityMagicApiary.java b/src/main/java/magicbees/tileentity/TileEntityMagicApiary.java index 875c3d2..8ccd674 100644 --- a/src/main/java/magicbees/tileentity/TileEntityMagicApiary.java +++ b/src/main/java/magicbees/tileentity/TileEntityMagicApiary.java @@ -1,12 +1,15 @@ package magicbees.tileentity; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + import magicbees.api.bees.IMagicApiaryAuraProvider; import magicbees.bees.BeeManager; import magicbees.main.CommonProxy; import magicbees.main.MagicBees; import magicbees.main.utils.ChunkCoords; import magicbees.main.utils.ItemStackUtils; -import magicbees.main.utils.LogHelper; import magicbees.main.utils.net.NetworkEventHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; @@ -16,6 +19,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Vec3; import net.minecraft.world.ChunkPosition; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; @@ -704,14 +708,7 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory return; } - if (this.auraProviderPosition == null) { - this.auraProviderPosition = new ChunkCoords(0, - xCoord - AURAPROVIDER_SEARCH_RADIUS, - (yCoord - AURAPROVIDER_SEARCH_RADIUS >= 0) ? yCoord - AURAPROVIDER_SEARCH_RADIUS : 0, - zCoord - AURAPROVIDER_SEARCH_RADIUS); - LogHelper.info("Apiary starting search"); - } - else { + if (this.auraProviderPosition != null) { // Will end up here after loading from save with a valid auraProvider. if (locationHasAuraProvider(auraProviderPosition)) { IMagicApiaryAuraProvider provider = (IMagicApiaryAuraProvider)(worldObj.getTileEntity(auraProviderPosition.x, @@ -724,50 +721,51 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory return; } } - - int blocksCounted = 0; - int x = auraProviderPosition.x; - int y = auraProviderPosition.y; - int z = auraProviderPosition.z; - while ((y < yCoord + AURAPROVIDER_SEARCH_RADIUS) && blocksCounted < MAX_BLOCKS_SEARCH_PER_CHECK) { - while ((z < zCoord + AURAPROVIDER_SEARCH_RADIUS) && blocksCounted < MAX_BLOCKS_SEARCH_PER_CHECK) { - while ((x < xCoord + AURAPROVIDER_SEARCH_RADIUS) && blocksCounted < MAX_BLOCKS_SEARCH_PER_CHECK) { - if (locationHasAuraProvider(x, y, z)) { - LogHelper.info("Apiary found aura provider!"); - this.auraProvider = (IMagicApiaryAuraProvider)(worldObj.getTileEntity(x, y, z)); - saveAuraProviderPosition(x, y, z); - return; - } - - ++blocksCounted; - ++x; - } - if (blocksCounted < MAX_BLOCKS_SEARCH_PER_CHECK) { - ++z; - x = xCoord - AURAPROVIDER_SEARCH_RADIUS; + else { + List chunks = getChunksInSearchRange(); + for (Chunk chunk : chunks) { + if (searchChunkForBooster(chunk)) { + break; } } - if (blocksCounted < MAX_BLOCKS_SEARCH_PER_CHECK) { - ++y; - z = zCoord - AURAPROVIDER_SEARCH_RADIUS; - } - } - - LogHelper.info("Apiary suspending search"); - - if (auraProvider == null) { - saveAuraProviderPosition(x, y, z); - - if (auraProviderPosition.y >= yCoord + AURAPROVIDER_SEARCH_RADIUS) { - LogHelper.info("Apiary finished scanning blocks; did not find aura provider."); - this.auraProviderPosition = null; - return; - } } } - + + private List getChunksInSearchRange() { + List chunks = new ArrayList(4); + chunks.add(worldObj.getChunkFromBlockCoords(xCoord - AURAPROVIDER_SEARCH_RADIUS, zCoord - AURAPROVIDER_SEARCH_RADIUS)); + Chunk chunk = worldObj.getChunkFromBlockCoords(xCoord + AURAPROVIDER_SEARCH_RADIUS, zCoord - AURAPROVIDER_SEARCH_RADIUS); + if (!chunks.contains(chunk)) { + chunks.add(chunk); + } + chunk = worldObj.getChunkFromBlockCoords(xCoord - AURAPROVIDER_SEARCH_RADIUS, zCoord + AURAPROVIDER_SEARCH_RADIUS); + if (!chunks.contains(chunk)) { + chunks.add(chunk); + } + chunk = worldObj.getChunkFromBlockCoords(xCoord + AURAPROVIDER_SEARCH_RADIUS, zCoord + AURAPROVIDER_SEARCH_RADIUS); + if (!chunks.contains(chunk)) { + chunks.add(chunk); + } + return chunks; + } + + private boolean searchChunkForBooster(Chunk chunk) { + Vec3 apiaryPos = Vec3.createVectorHelper(xCoord, yCoord, zCoord); + for (Map.Entry entry : ((Map)chunk.chunkTileEntityMap).entrySet()) { + TileEntity entity = entry.getValue(); + if (entity instanceof IMagicApiaryAuraProvider) { + Vec3 tePos = Vec3.createVectorHelper(entity.xCoord, entity.yCoord, entity.zCoord); + Vec3 result = apiaryPos.subtract(tePos); + if (result.lengthVector() <= AURAPROVIDER_SEARCH_RADIUS) { + saveAuraProviderPosition(entity.xCoord, entity.yCoord, entity.zCoord); + } + } + } + return false; + } + private void saveAuraProviderPosition(int x, int y, int z) { - auraProviderPosition = new ChunkCoords(auraProviderPosition.dimension, x, y, z); + auraProviderPosition = new ChunkCoords(worldObj.provider.dimensionId, x, y, z); } private boolean locationHasAuraProvider(ChunkCoords coords) {